Skip to content

Commit e65c4d2

Browse files
jrainvilleiurimatias
authored andcommitted
feat(@embark/test-app): add Teller contracts and test as a new test dapp
1 parent 74e2935 commit e65c4d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+6917
-0
lines changed

dapps/tests/teller-contracts/.npmrc

Whitespace-only changes.
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
const LICENSE_PRICE = "1000000000000000000"; // 10 * Math.pow(1, 18)
2+
const ARB_LICENSE_PRICE = "1000000000000000000"; // 10 * Math.pow(10, 18)
3+
const FEE_MILLI_PERCENT = "1000"; // 1 percent
4+
const BURN_ADDRESS = "0x0000000000000000000000000000000000000002";
5+
const MAINNET_OWNER = "0x35f7C96C392cD70ca5DBaeDB2005a946A82e8a95";
6+
const RINKEBY_OWNER = "0xa019702a5743aFdd607c61321A90C43a8C1c69d9";
7+
const FALLBACK_ARBITRATOR_MAINNET = "0x35f7C96C392cD70ca5DBaeDB2005a946A82e8a95";
8+
const FALLBACK_ARBITRATOR_RINKEBY = "0xa019702a5743aFdd607c61321A90C43a8C1c69d9";
9+
const GAS_PRICE = "5000000000"; //5 gwei
10+
11+
12+
const dataMigration = require('./data.js');
13+
14+
module.exports = {
15+
default: {
16+
dappConnection: [
17+
"$EMBARK",
18+
"$WEB3",
19+
"ws://localhost:8546",
20+
"http://localhost:8545"
21+
],
22+
23+
dappAutoEnable: false,
24+
25+
gas: "auto",
26+
27+
strategy: 'explicit',
28+
29+
deploy: {
30+
Proxy: {
31+
deploy: false
32+
},
33+
License: {
34+
deploy: false
35+
},
36+
SellerLicense: {
37+
instanceOf: "License",
38+
args: [
39+
"$SNT",
40+
LICENSE_PRICE,
41+
"$KyberFeeBurner" // TODO: replace with "$StakingPool"
42+
]
43+
},
44+
SellerLicenseInstance: {
45+
instanceOf: "Proxy",
46+
proxyFor: 'SellerLicense',
47+
args: ["0x", "$SellerLicense"]
48+
},
49+
ArbitrationLicense: {
50+
args: [
51+
"$SNT",
52+
ARB_LICENSE_PRICE,
53+
"$KyberFeeBurner" // TODO: replace with "$StakingPool"
54+
]
55+
},
56+
ArbitrationLicenseInstance: {
57+
instanceOf: "Proxy",
58+
proxyFor: "ArbitrationLicense",
59+
args: ["0x", "$ArbitrationLicense"]
60+
},
61+
UserStore: {
62+
args: ["$SellerLicense", "$ArbitrationLicense"]
63+
},
64+
Medianizer: {
65+
66+
},
67+
OfferStore: {
68+
args: ["$UserStore", "$SellerLicense", "$ArbitrationLicense", BURN_ADDRESS, "$Medianizer"]
69+
},
70+
UserStoreInstance: {
71+
instanceOf: "Proxy",
72+
proxyFor: "UserStore",
73+
args: ["0x", "$UserStore"]
74+
},
75+
OfferStoreInstance: {
76+
instanceOf: "Proxy",
77+
proxyFor: "OfferStore",
78+
args: ["0x", "$OfferStore"]
79+
},
80+
Escrow: {
81+
args: ["$accounts[0]", FALLBACK_ARBITRATOR_MAINNET, "$ArbitrationLicense", "$OfferStore", "$UserStore", "$KyberFeeBurner", FEE_MILLI_PERCENT]
82+
},
83+
EscrowInstance: {
84+
instanceOf: "Proxy",
85+
proxyFor: "Escrow",
86+
args: ["0x", "$Escrow"]
87+
},
88+
"MiniMeToken": {"deploy": false},
89+
"MiniMeTokenFactory": {},
90+
"Fees": {
91+
"deploy": false
92+
},
93+
"SNT": {
94+
"instanceOf": "MiniMeToken",
95+
"args": [
96+
"$MiniMeTokenFactory",
97+
"0x0000000000000000000000000000000000000000",
98+
0,
99+
"TestMiniMeToken",
100+
18,
101+
"STT",
102+
true
103+
]
104+
},
105+
106+
/*
107+
"StakingPool": {
108+
file: 'staking-pool/contracts/StakingPool.sol',
109+
args: [
110+
"$SNT"
111+
]
112+
},
113+
*/
114+
115+
KyberNetworkProxy: {},
116+
KyberFeeBurner: { // TODO: replace BURN_ADDRESS with "$StakingPool"
117+
args: ["$SNT", BURN_ADDRESS, "$KyberNetworkProxy", "0x0000000000000000000000000000000000000000", "300"]
118+
}
119+
}
120+
},
121+
122+
development: {
123+
deploy: {
124+
StandardToken: {},
125+
DAI: {instanceOf: "StandardToken", onDeploy: ["DAI.methods.mint('$accounts[0]', '20000000000000000000').send()"]},
126+
MKR: {instanceOf: "StandardToken", onDeploy: ["MKR.methods.mint('$accounts[0]', '20000000000000000000').send()"]}
127+
},
128+
afterDeploy: dataMigration.bind(null, GAS_PRICE, LICENSE_PRICE, ARB_LICENSE_PRICE, FEE_MILLI_PERCENT, BURN_ADDRESS, null, null)
129+
},
130+
131+
132+
testnet: {
133+
gasPrice: GAS_PRICE,
134+
tracking: 'shared.rinkeby.json',
135+
afterDeploy: dataMigration.bind(null, GAS_PRICE, LICENSE_PRICE, ARB_LICENSE_PRICE, FEE_MILLI_PERCENT, BURN_ADDRESS, RINKEBY_OWNER, RINKEBY_OWNER),
136+
dappConnection: [
137+
"$WEB3",
138+
"https://rinkeby.infura.io/v3/c26e9ab0df094a4f99bd1ea030eb7d50"
139+
],
140+
deploy: {
141+
StandardToken: {deploy: false},
142+
DAI: {deploy: false},
143+
MKR: {deploy: false},
144+
KyberNetworkProxy: {
145+
// https://developer.kyber.network/docs/Environments-Rinkeby/
146+
address: "0xF77eC7Ed5f5B9a5aee4cfa6FFCaC6A4C315BaC76"
147+
}
148+
}
149+
},
150+
151+
ropsten: {
152+
gasPrice: "10000000000",
153+
tracking: 'shared.ropsten.json',
154+
deploy: {
155+
SNT: {
156+
address: "0xc55cf4b03948d7ebc8b9e8bad92643703811d162"
157+
},
158+
"MiniMeTokenFactory": {
159+
deploy: false
160+
},
161+
KyberNetworkProxy: {
162+
// https://developer.kyber.network/docs/Environments-Ropsten/
163+
address: "0x818E6FECD516Ecc3849DAf6845e3EC868087B755"
164+
}
165+
},
166+
afterDeploy: dataMigration.bind(null, GAS_PRICE, LICENSE_PRICE, ARB_LICENSE_PRICE, FEE_MILLI_PERCENT, BURN_ADDRESS, MAINNET_OWNER, FALLBACK_ARBITRATOR_RINKEBY),
167+
dappConnection: ["$WEB3"]
168+
},
169+
170+
// merges with the settings in default
171+
// used with "embark run livenet"
172+
livenet: {
173+
gasPrice: GAS_PRICE,
174+
tracking: 'shared.mainnet.json',
175+
afterDeploy: dataMigration.bind(null, GAS_PRICE, LICENSE_PRICE, ARB_LICENSE_PRICE, FEE_MILLI_PERCENT, BURN_ADDRESS, MAINNET_OWNER, FALLBACK_ARBITRATOR_MAINNET),
176+
dappConnection: [
177+
"$WEB3",
178+
"https://mainnet.infura.io/v3/c26e9ab0df094a4f99bd1ea030eb7d50"
179+
],
180+
deploy: {
181+
StandardToken: {deploy: false},
182+
DAI: {deploy: false},
183+
MKR: {deploy: false},
184+
SNT: {
185+
address: "0x744d70fdbe2ba4cf95131626614a1763df805b9e"
186+
},
187+
"MiniMeTokenFactory": {deploy: false},
188+
KyberNetworkProxy: {
189+
// https://developer.kyber.network/docs/Environments-Mainnet/
190+
address: "0x818E6FECD516Ecc3849DAf6845e3EC868087B755"
191+
},
192+
SellerLicense: {
193+
address: "0xD0fBD1a8D663B3D31312e0cb24910be82387266A"
194+
},
195+
SellerLicenseInstance: {
196+
instanceOf: "Proxy",
197+
proxyFor: 'SellerLicense',
198+
address: "0x18C8e4570DE4D1FA07E2ad8BE4bc0Fe8B2C2dc4d"
199+
},
200+
ArbitrationLicense: {
201+
address: "0x7e571b13aeb1a6abcfc470b7d033a6838e53f440"
202+
},
203+
ArbitrationLicenseInstance: {
204+
instanceOf: "Proxy",
205+
proxyFor: 'ArbitrationLicense',
206+
address: "0x3e7fc31b9bd5fafde828acc1fd7b7b3dd7c1d927"
207+
},
208+
UserStore: {
209+
address: "0x0ab611f28165a5b694959c1454c0a9027eae536d"
210+
},
211+
Medianizer: {
212+
address: "0x729D19f657BD0614b4985Cf1D82531c67569197B"
213+
},
214+
OfferStore: {
215+
address: "0x5EaE5D9Fc2F38d18D9F3Bfa584700801850670D0"
216+
},
217+
UserStoreInstance: {
218+
instanceOf: "Proxy",
219+
proxyFor: "UserStore",
220+
address: "0x61fbacebcef64e726ff5b848da5dff0c44c199f5"
221+
},
222+
OfferStoreInstance: {
223+
instanceOf: "Proxy",
224+
proxyFor: "OfferStore",
225+
address: "0xf0dfd170aedf576717b7de14dac257c832a364e2"
226+
},
227+
Escrow: {
228+
address: "0x727bF4BAed69265bBaFD39f0ab6e508F6fA118a7"
229+
},
230+
EscrowInstance: {
231+
instanceOf: "Proxy",
232+
proxyFor: 'Escrow',
233+
address: "0xD5baC31a10b8938dd47326f01802fa23f1032AeE"
234+
},
235+
KyberFeeBurner: {
236+
address: "0x7702CaaE3D8feE750c4464d80FCb14Ce05e00743"
237+
}
238+
}
239+
}
240+
};
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
pragma solidity >=0.5.0 <0.6.0;
2+
3+
contract Controlled {
4+
/// @notice The address of the controller is the only address that can call
5+
/// a function with this modifier
6+
modifier onlyController {
7+
require(msg.sender == controller, "Unauthorized");
8+
_;
9+
}
10+
11+
address payable public controller;
12+
13+
constructor() internal {
14+
controller = msg.sender;
15+
}
16+
17+
/// @notice Changes the controller of the contract
18+
/// @param _newController The new controller of the contract
19+
function changeController(address payable _newController) public onlyController {
20+
controller = _newController;
21+
}
22+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pragma solidity >=0.5.0 <0.6.0;
2+
3+
4+
/**
5+
* @title Medianizer Mock Contract
6+
*/
7+
contract Medianizer {
8+
function peek() public view returns (bytes32, bool) {
9+
return (bytes32(0x000000000000000000000000000000000000000000000008c233113a8becc000), true);
10+
}
11+
12+
function read() public view returns (bytes32) {
13+
return bytes32(0x000000000000000000000000000000000000000000000008c233113a8becc000);
14+
}
15+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/* solium-disable no-empty-blocks */
2+
/* solium-disable security/no-inline-assembly */
3+
4+
pragma solidity >=0.5.0 <0.6.0;
5+
6+
7+
/**
8+
* @dev Uses ethereum signed messages
9+
*/
10+
contract MessageSigned {
11+
12+
constructor() internal {}
13+
14+
/**
15+
* @dev recovers address who signed the message
16+
* @param _signHash operation ethereum signed message hash
17+
* @param _messageSignature message `_signHash` signature
18+
*/
19+
function _recoverAddress(bytes32 _signHash, bytes memory _messageSignature)
20+
internal
21+
pure
22+
returns(address)
23+
{
24+
uint8 v;
25+
bytes32 r;
26+
bytes32 s;
27+
(v,r,s) = signatureSplit(_messageSignature);
28+
return ecrecover(
29+
_signHash,
30+
v,
31+
r,
32+
s
33+
);
34+
}
35+
36+
/**
37+
* @dev Hash a hash with `"\x19Ethereum Signed Message:\n32"`
38+
* @param _hash Sign to hash.
39+
* @return Hash to be signed.
40+
*/
41+
function _getSignHash(bytes32 _hash) internal pure returns (bytes32 signHash) {
42+
signHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", _hash));
43+
}
44+
45+
/**
46+
* @dev divides bytes signature into `uint8 v, bytes32 r, bytes32 s`
47+
* @param _signature Signature string
48+
*/
49+
function signatureSplit(bytes memory _signature)
50+
internal
51+
pure
52+
returns (uint8 v, bytes32 r, bytes32 s)
53+
{
54+
require(_signature.length == 65, "Bad signature length");
55+
// The signature format is a compact form of:
56+
// {bytes32 r}{bytes32 s}{uint8 v}
57+
// Compact means, uint8 is not padded to 32 bytes.
58+
assembly {
59+
r := mload(add(_signature, 32))
60+
s := mload(add(_signature, 64))
61+
// Here we are loading the last 32 bytes, including 31 bytes
62+
// of 's'. There is no 'mload8' to do this.
63+
//
64+
// 'byte' is not working due to the Solidity parser, so lets
65+
// use the second best option, 'and'
66+
v := and(mload(add(_signature, 65)), 0xff)
67+
}
68+
if (v < 27) {
69+
v += 27;
70+
}
71+
require(v == 27 || v == 28, "Bad signature version");
72+
}
73+
}

0 commit comments

Comments
 (0)