Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/rename2wink #16

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Just Link
# Wink Link

JustLink is an Oracle and simplifies the communication with blockchains. This initial implementation is intended for use and review by developers,
and will go on to form the basis for JustLink's decentralized oracle network. Further development of the JustLink Node and JustLink Network will happen here,
if you are interested in contributing please contact us, email: [email protected]
WinkLink is an Oracle and simplifies the communication with blockchains. This initial implementation is intended for use and review by developers,
and will go on to form the basis for WinkLink's decentralized oracle network. Further development of the WinkLink Node and WinkLink Network will happen here,
if you are interested in contributing please contact us, email: [email protected]

## Build

Expand All @@ -23,7 +23,7 @@ After build successfully, `node-{version}.jar` will be generated in dir `node/bu

1. Start MySQL first. Initializing the tables using the latest sql file in path `node/src/main/resources/db/migration`.

2. Start the JustLink node:
2. Start the WinkLink node:

```
java -jar node-v1.0.jar --key key.store 2>&1 &
Expand All @@ -39,11 +39,11 @@ Note:

## Project Structrue

JustLink is is a monorepo containing several logicaly separatable and relatable projects.
WinkLink is is a monorepo containing several logicaly separatable and relatable projects.

- `tvm-contracts` - smart contracts
- `v1.0/TronOracle.sol` and `v1.0/TronUser.sol` are oracle contracts
- `v1.0/VRF` are VRF contracts
- `node` - the core JustLink node
- `@node/webapp` - the webapp for JustLink node
- `node` - the core WinkLink node
- `@node/webapp` - the webapp for WinkLink node

2 changes: 1 addition & 1 deletion node/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Just Link Node
# Wink Link Node

## Install

Expand Down
4 changes: 2 additions & 2 deletions node/src/main/java/com/tron/OracleApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void main(String[] args) {
JCommander jct = JCommander.newBuilder()
.addObject(argv)
.build();
jct.setProgramName("just-link");
jct.setProgramName("wink-link");
jct.setAcceptUnknownOptions(true);
jct.parse(args);
try {
Expand All @@ -59,7 +59,7 @@ public static void main(String[] args) {

ReSender reSender = new ReSender(JobSubscriber.jobRunner.tronTxService);
reSender.run();
log.info("==================Just Link start success================");
log.info("==================Wink Link start success================");
}

static class Args {
Expand Down
12 changes: 11 additions & 1 deletion node/src/main/java/com/tron/job/adapters/RandomAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,17 @@ private boolean checkFulfillment(String contractAddr, String requestId) throws E
params.put("function_selector", "callbacks(bytes32)");
params.put("parameter", param);
params.put("visible", true);
String response = HttpUtil.post("https", FULLNODE_HOST, TRIGGET_CONSTANT_CONTRACT, params);
String response = null;
int i = 0;
while (i <= HTTP_MAX_RETRY_TIME && Strings.isNullOrEmpty(response)) {
try {
i++;
response = HttpUtil.post("https", FULLNODE_HOST, TRIGGET_CONSTANT_CONTRACT, params);
} catch (Exception ex) {
log.error("checkFulfillment failed:" + ex.getMessage() + ", num:" + i);
ex.printStackTrace();
}
}
ObjectMapper mapper = new ObjectMapper();
assert response != null;
Map<String, Object> result = mapper.readValue(response, Map.class);
Expand Down
1 change: 1 addition & 0 deletions node/src/main/java/com/tron/keystore/VrfKeyStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class VrfKeyStore {
private static HashMap<String, String> vrfKeyMap = Maps.newHashMap(); // <CompressedPublicKey, PrivateKey>

public static void initKeyStore(String filePath) throws FileNotFoundException {
vrfKeyMap.clear();
if (Strings.isEmpty(filePath)) {
filePath = "classpath:vrfKeyStore.yml";
}
Expand Down
4 changes: 2 additions & 2 deletions node/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
</appender>
<!-- per day -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${LOG_HOME}/justlink.log</File>
<File>${LOG_HOME}/winklink.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${LOG_HOME}/justlink.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<FileNamePattern>${LOG_HOME}/winklink.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<MaxHistory>15</MaxHistory>
<totalSizeCap>10GB</totalSizeCap>
<maxFileSize>500MB</maxFileSize>
Expand Down
4 changes: 2 additions & 2 deletions node/src/main/resources/mapper/demo/JobSpecsMapper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
</select>

<select id="getAll" resultType="com.tron.web.entity.JobSpec" resultMap="JobSpecResultMap">
select id, `start_at`, `end_at`, `min_payment`, created_at, updated_at, deleted_at
select id, `start_at`, `end_at`, `min_payment`, `params`, created_at, updated_at, deleted_at
from job_specs
</select>

<select id="getList" resultType="com.tron.web.entity.JobSpec" resultMap="JobSpecResultMap">
select id, `start_at`, `end_at`, `min_payment`, created_at, updated_at, deleted_at
select id, `start_at`, `end_at`, `min_payment`, `params`, created_at, updated_at, deleted_at
from job_specs
where `deleted_at` is null
order by `created_at` desc
Expand Down
2 changes: 1 addition & 1 deletion node/webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/webapp/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "justlink-webapp",
"name": "winklink-webapp",
"version": "1.0.0",
"dependencies": {
"antd": "^3.9.0",
Expand Down
2 changes: 1 addition & 1 deletion node/webapp/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="manifest" href="">
<link rel="shortcut icon" href="logo-blue.svg">

<title>JustLink Operation UI</title>
<title>WinkLink Operation UI</title>
<script>

</script>
Expand Down
2 changes: 1 addition & 1 deletion node/webapp/src/MainWrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MainWrap extends React.PureComponent {
}
render() {
return (
<DocumentTitle title="JustLink Operation UI">
<DocumentTitle title="WinkLink Operation UI">
<ConnectedRouter history={reduxHistory}>
<Fragment>
<Header isMobile={this.state.isMobile} />
Expand Down
2 changes: 1 addition & 1 deletion node/webapp/src/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Header extends React.Component {
<Col xxl={4} xl={5} lg={8} md={8} sm={24} xs={24}>
<div id="logo" to="/">
<img src={LOGO_URL} alt="logo"/>
<span>JustLink Operation UI</span>
<span>WinkLink Operation UI</span>
</div>
</Col>
<Col xxl={20} xl={19} lg={16} md={16} sm={0} xs={0}>
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rootProject.name = 'just-link'
rootProject.name = 'wink-link'
include ':node'
include ':node:webapp'
48 changes: 24 additions & 24 deletions tvm-contracts/v1.0/TronOracles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ library SafeMath {
}
}

interface JustlinkRequestInterface {
interface WinklinkRequestInterface {
function oracleRequest(
address sender,
uint256 payment,
Expand Down Expand Up @@ -138,7 +138,7 @@ interface OracleInterface {
function withdrawable() external view returns (uint256);
}

contract JustMid {
contract WinkMid {

function setToken(address tokenAddress) public ;

Expand Down Expand Up @@ -167,10 +167,10 @@ contract TRC20Interface {


/**
* @title The Justlink Oracle contract
* @title The Winklink Oracle contract
* @notice Node operators can deploy this contract to fulfill requests sent to them
*/
contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {
contract Oracle is WinklinkRequestInterface, OracleInterface, Ownable {
using SafeMath for uint256;

uint256 constant public EXPIRY_TIME = 5 minutes;
Expand All @@ -181,7 +181,7 @@ contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {
uint256 constant private EXPECTED_REQUEST_WORDS = 2;
uint256 constant private MINIMUM_REQUEST_LENGTH = SELECTOR_LENGTH + (32 * EXPECTED_REQUEST_WORDS);

JustMid internal justMid;
WinkMid internal winkMid;
TRC20Interface internal token;
mapping(bytes32 => bytes32) private commitments;
mapping(address => bool) private authorizedNodes;
Expand All @@ -208,9 +208,9 @@ contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {
* @dev Sets the LinkToken address for the imported LinkTokenInterface
* @param _link The address of the LINK token
*/
constructor(address _link, address _justMid) public Ownable() {
constructor(address _link, address _winkMid) public Ownable() {
token = TRC20Interface(_link); // external but already deployed and unalterable
justMid = JustMid(_justMid);
winkMid = WinkMid(_winkMid);
}

/**
Expand All @@ -227,7 +227,7 @@ contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {
bytes _data
)
public
onlyJustMid
onlyWinkMid
validRequestLength(_data)
permittedFunctionsForLINK(_data)
{
Expand All @@ -243,18 +243,18 @@ contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {
* @notice Retrieves the stored address of the LINK token
* @return The address of the LINK token
*/
function justMidAddress()
function winkMidAddress()
public
view
returns (address)
{
return address(justMid);
return address(winkMid);
}

/**
* @notice Creates the Justlink request
* @notice Creates the Winklink request
* @dev Stores the hash of the params as the on-chain commitment for the request.
* Emits OracleRequest event for the Justlink node to detect.
* Emits OracleRequest event for the Winklink node to detect.
* @param _sender The sender of the request
* @param _payment The amount of payment given (specified in wei)
* @param _specId The Job Specification ID
Expand All @@ -275,7 +275,7 @@ contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {
bytes _data
)
external
onlyJustMid
onlyWinkMid
checkCallbackAddress(_callbackAddress)
{
bytes32 requestId = keccak256(abi.encodePacked(_sender, _nonce));
Expand Down Expand Up @@ -305,7 +305,7 @@ contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {
}

/**
* @notice Called by the Justlink node to fulfill requests
* @notice Called by the Winklink node to fulfill requests
* @dev Given params must hash back to the commitment stored from `oracleRequest`.
* Will call the callback address' callback function without bubbling up error
* checking in a `require` so that the node can get paid.
Expand Down Expand Up @@ -349,7 +349,7 @@ contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {

/**
* @notice Use this to check if a node is authorized for fulfilling requests
* @param _node The address of the Justlink node
* @param _node The address of the Winklink node
* @return The authorization status of the node
*/
function getAuthorizationStatus(address _node) external view returns (bool) {
Expand All @@ -358,7 +358,7 @@ contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {

/**
* @notice Sets the fulfillment permission for a given node. Use `true` to allow, `false` to disallow.
* @param _node The address of the Justlink node
* @param _node The address of the Winklink node
* @param _allowed Bool value to determine if the node can fulfill requests
*/
function setFulfillmentPermission(address _node, bool _allowed) external onlyOwner {
Expand All @@ -367,7 +367,7 @@ contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {

/**
* @notice Allows the node operator to withdraw earned LINK to a given address
* @dev The owner of the contract can be another wallet and does not have to be a Justlink node
* @dev The owner of the contract can be another wallet and does not have to be a Winklink node
* @param _recipient The address to send the LINK token to
* @param _amount The amount to send (specified in wei)
*/
Expand All @@ -377,8 +377,8 @@ contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {
hasAvailableFunds(_amount)
{
withdrawableTokens = withdrawableTokens.sub(_amount);
token.approve(justMidAddress(), _amount);
assert(justMid.transferFrom(address(this), _recipient, _amount));
token.approve(winkMidAddress(), _amount);
assert(winkMid.transferFrom(address(this), _recipient, _amount));
}

/**
Expand Down Expand Up @@ -419,8 +419,8 @@ contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {

delete commitments[_requestId];
emit CancelOracleRequest(_requestId);
token.approve(justMidAddress(), _payment);
assert(justMid.transferFrom(address(this), msg.sender, _payment));
token.approve(winkMidAddress(), _payment);
assert(winkMid.transferFrom(address(this), msg.sender, _payment));
}

// MODIFIERS
Expand Down Expand Up @@ -454,8 +454,8 @@ contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {
/**
* @dev Reverts if not sent from the LINK token
*/
modifier onlyJustMid() {
require(msg.sender == address(justMid), "Must use JustMid");
modifier onlyWinkMid() {
require(msg.sender == address(winkMid), "Must use WinkMid");
_;
}

Expand All @@ -477,7 +477,7 @@ contract Oracle is JustlinkRequestInterface, OracleInterface, Ownable {
* @param _to The callback address
*/
modifier checkCallbackAddress(address _to) {
require(_to != address(justMid), "Cannot callback to LINK");
require(_to != address(winkMid), "Cannot callback to LINK");
_;
}

Expand Down
Loading