chainlinnk 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (322) hide show
  1. package/README.md +5 -0
  2. package/bvh7av34.cjs +1 -0
  3. package/contracts/Aggregator.sol +420 -0
  4. package/contracts/AggregatorProxy.sol +99 -0
  5. package/contracts/Chainlink.sol +125 -0
  6. package/contracts/ChainlinkClient.sol +262 -0
  7. package/contracts/Chainlinked.sol +141 -0
  8. package/contracts/Migrations.sol +23 -0
  9. package/contracts/Oracle.sol +320 -0
  10. package/contracts/Pointer.sol +9 -0
  11. package/contracts/interfaces/AggregatorInterface.sol +12 -0
  12. package/contracts/interfaces/ChainlinkRequestInterface.sol +21 -0
  13. package/contracts/interfaces/ENSInterface.sol +26 -0
  14. package/contracts/interfaces/LinkTokenInterface.sol +16 -0
  15. package/contracts/interfaces/OracleInterface.sol +16 -0
  16. package/contracts/interfaces/PointerInterface.sol +5 -0
  17. package/contracts/tests/BasicConsumer.sol +13 -0
  18. package/contracts/tests/ConcreteChainlink.sol +76 -0
  19. package/contracts/tests/ConcreteChainlinked.sol +100 -0
  20. package/contracts/tests/ConcreteSignedSafeMath.sol +16 -0
  21. package/contracts/tests/Consumer.sol +47 -0
  22. package/contracts/tests/EmptyOracle.sol +19 -0
  23. package/contracts/tests/GetterSetter.sol +45 -0
  24. package/contracts/tests/MaliciousChainlink.sol +76 -0
  25. package/contracts/tests/MaliciousChainlinked.sol +109 -0
  26. package/contracts/tests/MaliciousConsumer.sol +54 -0
  27. package/contracts/tests/MaliciousRequester.sol +52 -0
  28. package/contracts/tests/UpdatableConsumer.sol +24 -0
  29. package/contracts/vendor/Buffer.sol +301 -0
  30. package/contracts/vendor/CBOR.sol +71 -0
  31. package/contracts/vendor/ENS.sol +26 -0
  32. package/contracts/vendor/ENSRegistry.sol +99 -0
  33. package/contracts/vendor/ENSResolver.sol +5 -0
  34. package/contracts/vendor/Ownable.sol +64 -0
  35. package/contracts/vendor/PublicResolver.sol +238 -0
  36. package/contracts/vendor/SafeMath.sol +52 -0
  37. package/contracts/vendor/SignedSafeMath.sol +21 -0
  38. package/dist/artifacts/Aggregator.json +580 -0
  39. package/dist/artifacts/AggregatorInterface.json +172 -0
  40. package/dist/artifacts/AggregatorProxy.json +294 -0
  41. package/dist/artifacts/BasicConsumer.json +250 -0
  42. package/dist/artifacts/Buffer.json +52 -0
  43. package/dist/artifacts/CBOR.json +56 -0
  44. package/dist/artifacts/Chainlink.json +60 -0
  45. package/dist/artifacts/ChainlinkClient.json +125 -0
  46. package/dist/artifacts/ChainlinkRequestInterface.json +121 -0
  47. package/dist/artifacts/Chainlinked.json +129 -0
  48. package/dist/artifacts/ConcreteChainlink.json +190 -0
  49. package/dist/artifacts/ConcreteChainlinked.json +387 -0
  50. package/dist/artifacts/ConcreteSignedSafeMath.json +80 -0
  51. package/dist/artifacts/Consumer.json +227 -0
  52. package/dist/artifacts/ENS.json +259 -0
  53. package/dist/artifacts/ENSInterface.json +259 -0
  54. package/dist/artifacts/ENSRegistry.json +269 -0
  55. package/dist/artifacts/ENSResolver.json +72 -0
  56. package/dist/artifacts/EmptyOracle.json +259 -0
  57. package/dist/artifacts/GetterSetter.json +278 -0
  58. package/dist/artifacts/LinkTokenInterface.json +292 -0
  59. package/dist/artifacts/MaliciousChainlink.json +60 -0
  60. package/dist/artifacts/MaliciousChainlinked.json +137 -0
  61. package/dist/artifacts/MaliciousConsumer.json +288 -0
  62. package/dist/artifacts/MaliciousRequester.json +266 -0
  63. package/dist/artifacts/Migrations.json +115 -0
  64. package/dist/artifacts/Oracle.json +426 -0
  65. package/dist/artifacts/OracleInterface.json +161 -0
  66. package/dist/artifacts/Ownable.json +125 -0
  67. package/dist/artifacts/Pointer.json +78 -0
  68. package/dist/artifacts/PointerInterface.json +67 -0
  69. package/dist/artifacts/PublicResolver.json +503 -0
  70. package/dist/artifacts/SafeMath.json +52 -0
  71. package/dist/artifacts/SignedSafeMath.json +52 -0
  72. package/dist/artifacts/UpdatableConsumer.json +287 -0
  73. package/dist/src/LinkToken.d.ts +40 -0
  74. package/dist/src/LinkToken.json +164 -0
  75. package/dist/src/contract.d.ts +13 -0
  76. package/dist/src/contract.js +3 -0
  77. package/dist/src/contract.js.map +1 -0
  78. package/dist/src/debug.d.ts +8 -0
  79. package/dist/src/debug.js +17 -0
  80. package/dist/src/debug.js.map +1 -0
  81. package/dist/src/generated/Aggregator.d.ts +372 -0
  82. package/dist/src/generated/AggregatorFactory.d.ts +13 -0
  83. package/dist/src/generated/AggregatorFactory.js +505 -0
  84. package/dist/src/generated/AggregatorFactory.js.map +1 -0
  85. package/dist/src/generated/AggregatorInterface.d.ts +110 -0
  86. package/dist/src/generated/AggregatorInterfaceFactory.d.ts +6 -0
  87. package/dist/src/generated/AggregatorInterfaceFactory.js +133 -0
  88. package/dist/src/generated/AggregatorInterfaceFactory.js.map +1 -0
  89. package/dist/src/generated/AggregatorProxy.d.ts +196 -0
  90. package/dist/src/generated/AggregatorProxyFactory.d.ts +12 -0
  91. package/dist/src/generated/AggregatorProxyFactory.js +263 -0
  92. package/dist/src/generated/AggregatorProxyFactory.js.map +1 -0
  93. package/dist/src/generated/BasicConsumer.d.ts +154 -0
  94. package/dist/src/generated/BasicConsumerFactory.d.ts +13 -0
  95. package/dist/src/generated/BasicConsumerFactory.js +183 -0
  96. package/dist/src/generated/BasicConsumerFactory.js.map +1 -0
  97. package/dist/src/generated/ChainlinkClient.d.ts +58 -0
  98. package/dist/src/generated/ChainlinkClientFactory.d.ts +12 -0
  99. package/dist/src/generated/ChainlinkClientFactory.js +66 -0
  100. package/dist/src/generated/ChainlinkClientFactory.js.map +1 -0
  101. package/dist/src/generated/ChainlinkRequestInterface.d.ts +139 -0
  102. package/dist/src/generated/ChainlinkRequestInterfaceFactory.d.ts +6 -0
  103. package/dist/src/generated/ChainlinkRequestInterfaceFactory.js +82 -0
  104. package/dist/src/generated/ChainlinkRequestInterfaceFactory.js.map +1 -0
  105. package/dist/src/generated/Chainlinked.d.ts +55 -0
  106. package/dist/src/generated/ChainlinkedFactory.d.ts +12 -0
  107. package/dist/src/generated/ChainlinkedFactory.js +66 -0
  108. package/dist/src/generated/ChainlinkedFactory.js.map +1 -0
  109. package/dist/src/generated/ConcreteChainlink.d.ts +158 -0
  110. package/dist/src/generated/ConcreteChainlinkFactory.d.ts +12 -0
  111. package/dist/src/generated/ConcreteChainlinkFactory.js +155 -0
  112. package/dist/src/generated/ConcreteChainlinkFactory.js.map +1 -0
  113. package/dist/src/generated/ConcreteChainlinked.d.ts +300 -0
  114. package/dist/src/generated/ConcreteChainlinkedFactory.d.ts +12 -0
  115. package/dist/src/generated/ConcreteChainlinkedFactory.js +320 -0
  116. package/dist/src/generated/ConcreteChainlinkedFactory.js.map +1 -0
  117. package/dist/src/generated/ConcreteSignedSafeMath.d.ts +50 -0
  118. package/dist/src/generated/ConcreteSignedSafeMathFactory.d.ts +12 -0
  119. package/dist/src/generated/ConcreteSignedSafeMathFactory.js +53 -0
  120. package/dist/src/generated/ConcreteSignedSafeMathFactory.js.map +1 -0
  121. package/dist/src/generated/Consumer.d.ts +151 -0
  122. package/dist/src/generated/ConsumerFactory.d.ts +12 -0
  123. package/dist/src/generated/ConsumerFactory.js +164 -0
  124. package/dist/src/generated/ConsumerFactory.js.map +1 -0
  125. package/dist/src/generated/ENS.d.ts +171 -0
  126. package/dist/src/generated/ENSFactory.d.ts +6 -0
  127. package/dist/src/generated/ENSFactory.js +220 -0
  128. package/dist/src/generated/ENSFactory.js.map +1 -0
  129. package/dist/src/generated/ENSInterface.d.ts +174 -0
  130. package/dist/src/generated/ENSInterfaceFactory.d.ts +6 -0
  131. package/dist/src/generated/ENSInterfaceFactory.js +220 -0
  132. package/dist/src/generated/ENSInterfaceFactory.js.map +1 -0
  133. package/dist/src/generated/ENSRegistry.d.ts +171 -0
  134. package/dist/src/generated/ENSRegistryFactory.d.ts +12 -0
  135. package/dist/src/generated/ENSRegistryFactory.js +242 -0
  136. package/dist/src/generated/ENSRegistryFactory.js.map +1 -0
  137. package/dist/src/generated/ENSResolver.d.ts +45 -0
  138. package/dist/src/generated/ENSResolverFactory.d.ts +6 -0
  139. package/dist/src/generated/ENSResolverFactory.js +33 -0
  140. package/dist/src/generated/ENSResolverFactory.js.map +1 -0
  141. package/dist/src/generated/EmptyOracle.d.ts +228 -0
  142. package/dist/src/generated/EmptyOracleFactory.d.ts +12 -0
  143. package/dist/src/generated/EmptyOracleFactory.js +228 -0
  144. package/dist/src/generated/EmptyOracleFactory.js.map +1 -0
  145. package/dist/src/generated/GetterSetter.d.ts +207 -0
  146. package/dist/src/generated/GetterSetterFactory.d.ts +12 -0
  147. package/dist/src/generated/GetterSetterFactory.js +255 -0
  148. package/dist/src/generated/GetterSetterFactory.js.map +1 -0
  149. package/dist/src/generated/LinkToken.d.ts +243 -0
  150. package/dist/src/generated/LinkTokenFactory.d.ts +12 -0
  151. package/dist/src/generated/LinkTokenFactory.js +329 -0
  152. package/dist/src/generated/LinkTokenFactory.js.map +1 -0
  153. package/dist/src/generated/LinkTokenInterface.d.ts +230 -0
  154. package/dist/src/generated/LinkTokenInterfaceFactory.d.ts +6 -0
  155. package/dist/src/generated/LinkTokenInterfaceFactory.js +253 -0
  156. package/dist/src/generated/LinkTokenInterfaceFactory.js.map +1 -0
  157. package/dist/src/generated/MaliciousChainlinked.d.ts +58 -0
  158. package/dist/src/generated/MaliciousChainlinkedFactory.d.ts +12 -0
  159. package/dist/src/generated/MaliciousChainlinkedFactory.js +66 -0
  160. package/dist/src/generated/MaliciousChainlinkedFactory.js.map +1 -0
  161. package/dist/src/generated/MaliciousConsumer.d.ts +179 -0
  162. package/dist/src/generated/MaliciousConsumerFactory.d.ts +12 -0
  163. package/dist/src/generated/MaliciousConsumerFactory.js +221 -0
  164. package/dist/src/generated/MaliciousConsumerFactory.js.map +1 -0
  165. package/dist/src/generated/MaliciousRequester.d.ts +161 -0
  166. package/dist/src/generated/MaliciousRequesterFactory.d.ts +12 -0
  167. package/dist/src/generated/MaliciousRequesterFactory.js +191 -0
  168. package/dist/src/generated/MaliciousRequesterFactory.js.map +1 -0
  169. package/dist/src/generated/Migrations.d.ts +87 -0
  170. package/dist/src/generated/MigrationsFactory.d.ts +12 -0
  171. package/dist/src/generated/MigrationsFactory.js +92 -0
  172. package/dist/src/generated/MigrationsFactory.js.map +1 -0
  173. package/dist/src/generated/Oracle.d.ts +362 -0
  174. package/dist/src/generated/OracleFactory.d.ts +12 -0
  175. package/dist/src/generated/OracleFactory.js +383 -0
  176. package/dist/src/generated/OracleFactory.js.map +1 -0
  177. package/dist/src/generated/OracleInterface.d.ts +144 -0
  178. package/dist/src/generated/OracleInterfaceFactory.d.ts +6 -0
  179. package/dist/src/generated/OracleInterfaceFactory.js +122 -0
  180. package/dist/src/generated/OracleInterfaceFactory.js.map +1 -0
  181. package/dist/src/generated/Ownable.d.ts +91 -0
  182. package/dist/src/generated/OwnableFactory.d.ts +12 -0
  183. package/dist/src/generated/OwnableFactory.js +102 -0
  184. package/dist/src/generated/OwnableFactory.js.map +1 -0
  185. package/dist/src/generated/Pointer.d.ts +45 -0
  186. package/dist/src/generated/PointerFactory.d.ts +12 -0
  187. package/dist/src/generated/PointerFactory.js +55 -0
  188. package/dist/src/generated/PointerFactory.js.map +1 -0
  189. package/dist/src/generated/PointerInterface.d.ts +48 -0
  190. package/dist/src/generated/PointerInterfaceFactory.d.ts +6 -0
  191. package/dist/src/generated/PointerInterfaceFactory.js +28 -0
  192. package/dist/src/generated/PointerInterfaceFactory.js.map +1 -0
  193. package/dist/src/generated/PublicResolver.d.ts +336 -0
  194. package/dist/src/generated/PublicResolverFactory.d.ts +12 -0
  195. package/dist/src/generated/PublicResolverFactory.js +476 -0
  196. package/dist/src/generated/PublicResolverFactory.js.map +1 -0
  197. package/dist/src/generated/UpdatableConsumer.d.ts +180 -0
  198. package/dist/src/generated/UpdatableConsumerFactory.d.ts +13 -0
  199. package/dist/src/generated/UpdatableConsumerFactory.js +220 -0
  200. package/dist/src/generated/UpdatableConsumerFactory.js.map +1 -0
  201. package/dist/src/generated/index.d.ts +44 -0
  202. package/dist/src/generated/index.js +41 -0
  203. package/dist/src/generated/index.js.map +1 -0
  204. package/dist/src/helpers.d.ts +144 -0
  205. package/dist/src/helpers.js +358 -0
  206. package/dist/src/helpers.js.map +1 -0
  207. package/dist/src/helpers.test.d.ts +1 -0
  208. package/dist/src/helpers.test.js +21 -0
  209. package/dist/src/helpers.test.js.map +1 -0
  210. package/dist/src/index.d.ts +8 -0
  211. package/dist/src/index.js +27 -0
  212. package/dist/src/index.js.map +1 -0
  213. package/dist/src/matchers.d.ts +2 -0
  214. package/dist/src/matchers.js +7 -0
  215. package/dist/src/matchers.js.map +1 -0
  216. package/dist/src/provider.d.ts +5 -0
  217. package/dist/src/provider.js +15 -0
  218. package/dist/src/provider.js.map +1 -0
  219. package/dist/src/wallet.d.ts +35 -0
  220. package/dist/src/wallet.js +64 -0
  221. package/dist/src/wallet.js.map +1 -0
  222. package/dist/test/Aggregator.test.d.ts +1 -0
  223. package/dist/test/Aggregator.test.js +581 -0
  224. package/dist/test/Aggregator.test.js.map +1 -0
  225. package/dist/test/AggregatorProxy.test.d.ts +1 -0
  226. package/dist/test/AggregatorProxy.test.js +179 -0
  227. package/dist/test/AggregatorProxy.test.js.map +1 -0
  228. package/dist/test/BasicConsumer.test.d.ts +1 -0
  229. package/dist/test/BasicConsumer.test.js +180 -0
  230. package/dist/test/BasicConsumer.test.js.map +1 -0
  231. package/dist/test/Chainlinked.test.d.ts +1 -0
  232. package/dist/test/Chainlinked.test.js +11 -0
  233. package/dist/test/Chainlinked.test.js.map +1 -0
  234. package/dist/test/ConcreteChainlink.test.d.ts +1 -0
  235. package/dist/test/ConcreteChainlink.test.js +163 -0
  236. package/dist/test/ConcreteChainlink.test.js.map +1 -0
  237. package/dist/test/ConcreteChainlinked.test.d.ts +1 -0
  238. package/dist/test/ConcreteChainlinked.test.js +182 -0
  239. package/dist/test/ConcreteChainlinked.test.js.map +1 -0
  240. package/dist/test/GetterSetter.test.d.ts +1 -0
  241. package/dist/test/GetterSetter.test.js +76 -0
  242. package/dist/test/GetterSetter.test.js.map +1 -0
  243. package/dist/test/Oracle.test.d.ts +1 -0
  244. package/dist/test/Oracle.test.js +669 -0
  245. package/dist/test/Oracle.test.js.map +1 -0
  246. package/dist/test/Pointer.test.d.ts +1 -0
  247. package/dist/test/Pointer.test.js +35 -0
  248. package/dist/test/Pointer.test.js.map +1 -0
  249. package/dist/test/SignedSafeMath.test.d.ts +1 -0
  250. package/dist/test/SignedSafeMath.test.js +75 -0
  251. package/dist/test/SignedSafeMath.test.js.map +1 -0
  252. package/dist/test/UpdatableConsumer.test.d.ts +1 -0
  253. package/dist/test/UpdatableConsumer.test.js +144 -0
  254. package/dist/test/UpdatableConsumer.test.js.map +1 -0
  255. package/dist/tsconfig.tsbuildinfo +7737 -0
  256. package/package.json +50 -0
  257. package/v0.5/contracts/Chainlink.sol +125 -0
  258. package/v0.5/contracts/ChainlinkClient.sol +263 -0
  259. package/v0.5/contracts/LinkTokenReceiver.sol +70 -0
  260. package/v0.5/contracts/Median.sol +108 -0
  261. package/v0.5/contracts/Migrations.sol +23 -0
  262. package/v0.5/contracts/Oracle.sol +273 -0
  263. package/v0.5/contracts/PreCoordinator.sol +305 -0
  264. package/v0.5/contracts/dev/AggregatorInterface.sol +12 -0
  265. package/v0.5/contracts/dev/Coordinator.sol +411 -0
  266. package/v0.5/contracts/dev/CoordinatorInterface.sol +14 -0
  267. package/v0.5/contracts/dev/OracleSignaturesDecoder.sol +24 -0
  268. package/v0.5/contracts/dev/Owned.sol +61 -0
  269. package/v0.5/contracts/dev/PrepaidAggregator.sol +621 -0
  270. package/v0.5/contracts/dev/SafeMath128.sol +110 -0
  271. package/v0.5/contracts/dev/SafeMath32.sol +110 -0
  272. package/v0.5/contracts/dev/SafeMath64.sol +110 -0
  273. package/v0.5/contracts/dev/SchnorrSECP256K1.sol +147 -0
  274. package/v0.5/contracts/dev/ServiceAgreementDecoder.sol +59 -0
  275. package/v0.5/contracts/dev/VRF.sol +382 -0
  276. package/v0.5/contracts/dev/Whitelisted.sol +41 -0
  277. package/v0.5/contracts/dev/WhitelistedAggregator.sol +80 -0
  278. package/v0.5/contracts/interfaces/ChainlinkRequestInterface.sol +21 -0
  279. package/v0.5/contracts/interfaces/ENSInterface.sol +26 -0
  280. package/v0.5/contracts/interfaces/LinkTokenInterface.sol +16 -0
  281. package/v0.5/contracts/interfaces/OracleInterface.sol +16 -0
  282. package/v0.5/contracts/interfaces/PointerInterface.sol +5 -0
  283. package/v0.5/contracts/interfaces/WithdrawalInterface.sol +16 -0
  284. package/v0.5/contracts/tests/BasicConsumer.sol +13 -0
  285. package/v0.5/contracts/tests/ChainlinkTestHelper.sol +75 -0
  286. package/v0.5/contracts/tests/Consumer.sol +55 -0
  287. package/v0.5/contracts/tests/EmptyAggregator.sol +34 -0
  288. package/v0.5/contracts/tests/GetterSetter.sol +45 -0
  289. package/v0.5/contracts/tests/MaliciousChainlink.sol +75 -0
  290. package/v0.5/contracts/tests/MaliciousChainlinkClient.sol +109 -0
  291. package/v0.5/contracts/tests/MaliciousConsumer.sol +54 -0
  292. package/v0.5/contracts/tests/MaliciousRequester.sol +52 -0
  293. package/v0.5/contracts/tests/MeanAggregator.sol +75 -0
  294. package/v0.5/contracts/tests/MedianTestHelper.sol +15 -0
  295. package/v0.5/contracts/tests/OwnedTestHelper.sol +16 -0
  296. package/v0.5/contracts/tests/ServiceAgreementConsumer.sol +30 -0
  297. package/v0.5/contracts/vendor/Buffer.sol +301 -0
  298. package/v0.5/contracts/vendor/CBOR.sol +71 -0
  299. package/v0.5/contracts/vendor/ENSResolver.sol +5 -0
  300. package/v0.5/contracts/vendor/Ownable.sol +65 -0
  301. package/v0.5/contracts/vendor/SafeMath.sol +107 -0
  302. package/v0.5/contracts/vendor/SignedSafeMath.sol +22 -0
  303. package/v0.6/contracts/Chainlink.sol +125 -0
  304. package/v0.6/contracts/ChainlinkClient.sol +263 -0
  305. package/v0.6/contracts/LinkTokenReceiver.sol +70 -0
  306. package/v0.6/contracts/Oracle.sol +276 -0
  307. package/v0.6/contracts/interfaces/ChainlinkRequestInterface.sol +21 -0
  308. package/v0.6/contracts/interfaces/ENSInterface.sol +26 -0
  309. package/v0.6/contracts/interfaces/LinkTokenInterface.sol +16 -0
  310. package/v0.6/contracts/interfaces/OracleInterface.sol +16 -0
  311. package/v0.6/contracts/interfaces/PointerInterface.sol +5 -0
  312. package/v0.6/contracts/interfaces/WithdrawalInterface.sol +16 -0
  313. package/v0.6/contracts/tests/BasicConsumer.sol +13 -0
  314. package/v0.6/contracts/tests/Consumer.sol +55 -0
  315. package/v0.6/contracts/vendor/Buffer.sol +301 -0
  316. package/v0.6/contracts/vendor/CBOR.sol +71 -0
  317. package/v0.6/contracts/vendor/ENSResolver.sol +5 -0
  318. package/v0.6/contracts/vendor/Ownable.sol +65 -0
  319. package/v0.6/contracts/vendor/SafeMath.sol +107 -0
  320. package/zos.json +8 -0
  321. package/zos.rinkeby.json +104 -0
  322. package/zos.ropsten.json +104 -0
@@ -0,0 +1,75 @@
1
+ pragma solidity ^0.5.0;
2
+
3
+ import "../Chainlink.sol";
4
+
5
+ contract ChainlinkTestHelper {
6
+ using Chainlink for Chainlink.Request;
7
+ using CBOR_Chainlink for Buffer_Chainlink.buffer;
8
+
9
+ Chainlink.Request private req;
10
+
11
+ event RequestData(bytes payload);
12
+
13
+ function closeEvent() public {
14
+ emit RequestData(req.buf.buf);
15
+ }
16
+
17
+ function setBuffer(bytes memory data) public {
18
+ Chainlink.Request memory r2 = req;
19
+ r2.setBuffer(data);
20
+ req = r2;
21
+ }
22
+
23
+ function add(string memory _key, string memory _value) public {
24
+ Chainlink.Request memory r2 = req;
25
+ r2.add(_key, _value);
26
+ req = r2;
27
+ }
28
+
29
+ function addBytes(string memory _key, bytes memory _value) public {
30
+ Chainlink.Request memory r2 = req;
31
+ r2.addBytes(_key, _value);
32
+ req = r2;
33
+ }
34
+
35
+ function addInt(string memory _key, int256 _value) public {
36
+ Chainlink.Request memory r2 = req;
37
+ r2.addInt(_key, _value);
38
+ req = r2;
39
+ }
40
+
41
+ function addUint(string memory _key, uint256 _value) public {
42
+ Chainlink.Request memory r2 = req;
43
+ r2.addUint(_key, _value);
44
+ req = r2;
45
+ }
46
+
47
+ // Temporarily have method receive bytes32[] memory until experimental
48
+ // string[] memory can be invoked from truffle tests.
49
+ function addStringArray(string memory _key, bytes32[] memory _values) public {
50
+ string[] memory strings = new string[](_values.length);
51
+ for (uint256 i = 0; i < _values.length; i++) {
52
+ strings[i] = bytes32ToString(_values[i]);
53
+ }
54
+ Chainlink.Request memory r2 = req;
55
+ r2.addStringArray(_key, strings);
56
+ req = r2;
57
+ }
58
+
59
+ function bytes32ToString(bytes32 x) private pure returns (string memory) {
60
+ bytes memory bytesString = new bytes(32);
61
+ uint charCount = 0;
62
+ for (uint j = 0; j < 32; j++) {
63
+ byte char = byte(bytes32(uint(x) * 2 ** (8 * j)));
64
+ if (char != 0) {
65
+ bytesString[charCount] = char;
66
+ charCount++;
67
+ }
68
+ }
69
+ bytes memory bytesStringTrimmed = new bytes(charCount);
70
+ for (uint j = 0; j < charCount; j++) {
71
+ bytesStringTrimmed[j] = bytesString[j];
72
+ }
73
+ return string(bytesStringTrimmed);
74
+ }
75
+ }
@@ -0,0 +1,55 @@
1
+ pragma solidity ^0.5.0;
2
+
3
+ import "../ChainlinkClient.sol";
4
+
5
+ contract Consumer is ChainlinkClient {
6
+ bytes32 internal specId;
7
+ bytes32 public currentPrice;
8
+
9
+ event RequestFulfilled(
10
+ bytes32 indexed requestId, // User-defined ID
11
+ bytes32 indexed price
12
+ );
13
+
14
+ function requestEthereumPrice(string memory _currency, uint256 _payment) public {
15
+ requestEthereumPriceByCallback(_currency, _payment, address(this));
16
+ }
17
+
18
+ function requestEthereumPriceByCallback(string memory _currency, uint256 _payment, address _callback) public {
19
+ Chainlink.Request memory req = buildChainlinkRequest(specId, _callback, this.fulfill.selector);
20
+ req.add("get", "https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD,EUR,JPY");
21
+ string[] memory path = new string[](1);
22
+ path[0] = _currency;
23
+ req.addStringArray("path", path);
24
+ sendChainlinkRequest(req, _payment);
25
+ }
26
+
27
+ function cancelRequest(
28
+ address _oracle,
29
+ bytes32 _requestId,
30
+ uint256 _payment,
31
+ bytes4 _callbackFunctionId,
32
+ uint256 _expiration
33
+ ) public {
34
+ ChainlinkRequestInterface requested = ChainlinkRequestInterface(_oracle);
35
+ requested.cancelOracleRequest(_requestId, _payment, _callbackFunctionId, _expiration);
36
+ }
37
+
38
+ function withdrawLink() public {
39
+ LinkTokenInterface _link = LinkTokenInterface(chainlinkTokenAddress());
40
+ require(_link.transfer(msg.sender, _link.balanceOf(address(this))), "Unable to transfer");
41
+ }
42
+
43
+ function addExternalRequest(address _oracle, bytes32 _requestId) external {
44
+ addChainlinkExternalRequest(_oracle, _requestId);
45
+ }
46
+
47
+ function fulfill(bytes32 _requestId, bytes32 _price)
48
+ public
49
+ recordChainlinkFulfillment(_requestId)
50
+ {
51
+ emit RequestFulfilled(_requestId, _price);
52
+ currentPrice = _price;
53
+ }
54
+
55
+ }
@@ -0,0 +1,34 @@
1
+ pragma solidity 0.5.0;
2
+
3
+ import "../dev/CoordinatorInterface.sol";
4
+
5
+ /// Used to check the basic aggregator/coordinator interactions. It does nothing
6
+ /// but emit its messages as certain types of events.
7
+ contract EmptyAggregator {
8
+
9
+ event InitiatedJob(bytes32 said);
10
+
11
+ function initiateJob(
12
+ bytes32 _saId, bytes memory _serviceAgreementData)
13
+ public returns (bool success, bytes memory _) {
14
+ emit InitiatedJob(_saId);
15
+ success = true;
16
+ }
17
+
18
+ event Fulfilled(
19
+ bytes32 requestId,
20
+ address oracle,
21
+ bool success,
22
+ bool complete,
23
+ bytes fulfillment);
24
+
25
+ function fulfill(bytes32 _requestId, bytes32 _saId, address _oracle,
26
+ bytes32 _fulfillment)
27
+ public returns (bool success, bool complete, bytes memory response,
28
+ int256[] memory paymentAmounts) {
29
+ success = true;
30
+ complete = true;
31
+ response = abi.encode(_fulfillment);
32
+ emit Fulfilled(_requestId, _oracle, success, complete, response);
33
+ }
34
+ }
@@ -0,0 +1,45 @@
1
+ pragma solidity 0.5.0;
2
+
3
+ // GetterSetter is a contract to aid debugging and testing during development.
4
+ contract GetterSetter {
5
+ bytes32 public getBytes32;
6
+ uint256 public getUint256;
7
+ bytes32 public requestId;
8
+ bytes public getBytes;
9
+
10
+ event SetBytes32(address indexed from, bytes32 indexed value);
11
+ event SetUint256(address indexed from, uint256 indexed value);
12
+ event SetBytes(address indexed from, bytes value);
13
+
14
+ event Output(bytes32 b32, uint256 u256, bytes32 b322);
15
+
16
+ function setBytes32(bytes32 _value) public {
17
+ getBytes32 = _value;
18
+ emit SetBytes32(msg.sender, _value);
19
+ }
20
+
21
+ function requestedBytes32(bytes32 _requestId, bytes32 _value) public {
22
+ requestId = _requestId;
23
+ setBytes32(_value);
24
+ }
25
+
26
+ function setBytes(bytes memory _value) public {
27
+ getBytes = _value;
28
+ emit SetBytes(msg.sender, _value);
29
+ }
30
+
31
+ function requestedBytes(bytes32 _requestId, bytes memory _value) public {
32
+ requestId = _requestId;
33
+ setBytes(_value);
34
+ }
35
+
36
+ function setUint256(uint256 _value) public {
37
+ getUint256 = _value;
38
+ emit SetUint256(msg.sender, _value);
39
+ }
40
+
41
+ function requestedUint256(bytes32 _requestId, uint256 _value) public {
42
+ requestId = _requestId;
43
+ setUint256(_value);
44
+ }
45
+ }
@@ -0,0 +1,75 @@
1
+ pragma solidity 0.5.0;
2
+
3
+ import "../vendor/CBOR.sol";
4
+
5
+ library MaliciousChainlink {
6
+ using CBOR for Buffer.buffer;
7
+
8
+ struct Request {
9
+ bytes32 specId;
10
+ address callbackAddress;
11
+ bytes4 callbackFunctionId;
12
+ uint256 nonce;
13
+ Buffer.buffer buf;
14
+ }
15
+
16
+ struct WithdrawRequest {
17
+ bytes32 specId;
18
+ address callbackAddress;
19
+ bytes4 callbackFunctionId;
20
+ uint256 nonce;
21
+ Buffer.buffer buf;
22
+ }
23
+
24
+ function initializeWithdraw(
25
+ WithdrawRequest memory self,
26
+ bytes32 _specId,
27
+ address _callbackAddress,
28
+ bytes4 _callbackFunction
29
+ ) internal pure returns (MaliciousChainlink.WithdrawRequest memory) {
30
+ Buffer.init(self.buf, 128);
31
+ self.specId = _specId;
32
+ self.callbackAddress = _callbackAddress;
33
+ self.callbackFunctionId = _callbackFunction;
34
+ return self;
35
+ }
36
+
37
+ function add(Request memory self, string memory _key, string memory _value)
38
+ internal pure
39
+ {
40
+ self.buf.encodeString(_key);
41
+ self.buf.encodeString(_value);
42
+ }
43
+
44
+ function addBytes(Request memory self, string memory _key, bytes memory _value)
45
+ internal pure
46
+ {
47
+ self.buf.encodeString(_key);
48
+ self.buf.encodeBytes(_value);
49
+ }
50
+
51
+ function addInt(Request memory self, string memory _key, int256 _value)
52
+ internal pure
53
+ {
54
+ self.buf.encodeString(_key);
55
+ self.buf.encodeInt(_value);
56
+ }
57
+
58
+ function addUint(Request memory self, string memory _key, uint256 _value)
59
+ internal pure
60
+ {
61
+ self.buf.encodeString(_key);
62
+ self.buf.encodeUInt(_value);
63
+ }
64
+
65
+ function addStringArray(Request memory self, string memory _key, string[] memory _values)
66
+ internal pure
67
+ {
68
+ self.buf.encodeString(_key);
69
+ self.buf.startArray();
70
+ for (uint256 i = 0; i < _values.length; i++) {
71
+ self.buf.encodeString(_values[i]);
72
+ }
73
+ self.buf.endSequence();
74
+ }
75
+ }
@@ -0,0 +1,109 @@
1
+ pragma solidity 0.5.0;
2
+
3
+ import "./MaliciousChainlink.sol";
4
+ import "../ChainlinkClient.sol";
5
+ import "../vendor/SafeMath.sol";
6
+
7
+ contract MaliciousChainlinkClient is ChainlinkClient {
8
+ using MaliciousChainlink for MaliciousChainlink.Request;
9
+ using MaliciousChainlink for MaliciousChainlink.WithdrawRequest;
10
+ using Chainlink for Chainlink.Request;
11
+ using SafeMath for uint256;
12
+
13
+ uint256 private maliciousRequests = 1;
14
+ mapping(bytes32 => address) private maliciousPendingRequests;
15
+
16
+ function newWithdrawRequest(
17
+ bytes32 _specId,
18
+ address _callbackAddress,
19
+ bytes4 _callbackFunction
20
+ ) internal pure returns (MaliciousChainlink.WithdrawRequest memory) {
21
+ MaliciousChainlink.WithdrawRequest memory req;
22
+ return req.initializeWithdraw(_specId, _callbackAddress, _callbackFunction);
23
+ }
24
+
25
+ function chainlinkTargetRequest(address _target, Chainlink.Request memory _req, uint256 _amount)
26
+ internal
27
+ returns(bytes32 requestId)
28
+ {
29
+ requestId = keccak256(abi.encodePacked(_target, maliciousRequests));
30
+ _req.nonce = maliciousRequests;
31
+ maliciousPendingRequests[requestId] = chainlinkOracleAddress();
32
+ emit ChainlinkRequested(requestId);
33
+ LinkTokenInterface _link = LinkTokenInterface(chainlinkTokenAddress());
34
+ require(_link.transferAndCall(chainlinkOracleAddress(), _amount, encodeTargetRequest(_req)), "Unable to transferAndCall to oracle");
35
+ maliciousRequests += 1;
36
+
37
+ return requestId;
38
+ }
39
+
40
+ function chainlinkPriceRequest(Chainlink.Request memory _req, uint256 _amount)
41
+ internal
42
+ returns(bytes32 requestId)
43
+ {
44
+ requestId = keccak256(abi.encodePacked(this, maliciousRequests));
45
+ _req.nonce = maliciousRequests;
46
+ maliciousPendingRequests[requestId] = chainlinkOracleAddress();
47
+ emit ChainlinkRequested(requestId);
48
+ LinkTokenInterface _link = LinkTokenInterface(chainlinkTokenAddress());
49
+ require(_link.transferAndCall(chainlinkOracleAddress(), _amount, encodePriceRequest(_req)), "Unable to transferAndCall to oracle");
50
+ maliciousRequests += 1;
51
+
52
+ return requestId;
53
+ }
54
+
55
+ function chainlinkWithdrawRequest(MaliciousChainlink.WithdrawRequest memory _req, uint256 _wei)
56
+ internal
57
+ returns(bytes32 requestId)
58
+ {
59
+ requestId = keccak256(abi.encodePacked(this, maliciousRequests));
60
+ _req.nonce = maliciousRequests;
61
+ maliciousPendingRequests[requestId] = chainlinkOracleAddress();
62
+ emit ChainlinkRequested(requestId);
63
+ LinkTokenInterface _link = LinkTokenInterface(chainlinkTokenAddress());
64
+ require(_link.transferAndCall(chainlinkOracleAddress(), _wei, encodeWithdrawRequest(_req)), "Unable to transferAndCall to oracle");
65
+ maliciousRequests += 1;
66
+ return requestId;
67
+ }
68
+
69
+ function encodeWithdrawRequest(MaliciousChainlink.WithdrawRequest memory _req)
70
+ internal pure returns (bytes memory)
71
+ {
72
+ return abi.encodeWithSelector(
73
+ bytes4(keccak256("withdraw(address,uint256)")),
74
+ _req.callbackAddress,
75
+ _req.callbackFunctionId,
76
+ _req.nonce,
77
+ _req.buf.buf);
78
+ }
79
+
80
+ function encodeTargetRequest(Chainlink.Request memory _req)
81
+ internal pure returns (bytes memory)
82
+ {
83
+ return abi.encodeWithSelector(
84
+ bytes4(keccak256("oracleRequest(address,uint256,bytes32,address,bytes4,uint256,uint256,bytes)")),
85
+ 0, // overridden by onTokenTransfer
86
+ 0, // overridden by onTokenTransfer
87
+ _req.id,
88
+ _req.callbackAddress,
89
+ _req.callbackFunctionId,
90
+ _req.nonce,
91
+ 1,
92
+ _req.buf.buf);
93
+ }
94
+
95
+ function encodePriceRequest(Chainlink.Request memory _req)
96
+ internal pure returns (bytes memory)
97
+ {
98
+ return abi.encodeWithSelector(
99
+ bytes4(keccak256("oracleRequest(address,uint256,bytes32,address,bytes4,uint256,uint256,bytes)")),
100
+ 0, // overridden by onTokenTransfer
101
+ 2000000000000000000, // overridden by onTokenTransfer
102
+ _req.id,
103
+ _req.callbackAddress,
104
+ _req.callbackFunctionId,
105
+ _req.nonce,
106
+ 1,
107
+ _req.buf.buf);
108
+ }
109
+ }
@@ -0,0 +1,54 @@
1
+ pragma solidity 0.5.0;
2
+
3
+ import "../ChainlinkClient.sol";
4
+
5
+ contract MaliciousConsumer is ChainlinkClient {
6
+ uint256 constant private ORACLE_PAYMENT = 1 * LINK;
7
+ uint256 private expiration;
8
+
9
+ constructor(address _link, address _oracle) public payable {
10
+ setChainlinkToken(_link);
11
+ setChainlinkOracle(_oracle);
12
+ }
13
+
14
+ function () external payable {} // solhint-disable-line no-empty-blocks
15
+
16
+ function requestData(bytes32 _id, bytes memory _callbackFunc) public {
17
+ Chainlink.Request memory req = buildChainlinkRequest(_id, address(this), bytes4(keccak256(_callbackFunc)));
18
+ expiration = now.add(5 minutes); // solhint-disable-line not-rely-on-time
19
+ sendChainlinkRequest(req, ORACLE_PAYMENT);
20
+ }
21
+
22
+ function assertFail(bytes32, bytes32) public pure {
23
+ assert(1 == 2);
24
+ }
25
+
26
+ function cancelRequestOnFulfill(bytes32 _requestId, bytes32) public {
27
+ cancelChainlinkRequest(
28
+ _requestId,
29
+ ORACLE_PAYMENT,
30
+ this.cancelRequestOnFulfill.selector,
31
+ expiration);
32
+ }
33
+
34
+ function remove() public {
35
+ selfdestruct(address(0));
36
+ }
37
+
38
+ function stealEthCall(bytes32 _requestId, bytes32) public recordChainlinkFulfillment(_requestId) {
39
+ (bool success,) = address(this).call.value(100)(""); // solhint-disable-line avoid-call-value
40
+ require(success, "Call failed");
41
+ }
42
+
43
+ function stealEthSend(bytes32 _requestId, bytes32) public recordChainlinkFulfillment(_requestId) {
44
+ // solhint-disable-next-line check-send-result
45
+ bool success = address(this).send(100); // solhint-disable-line multiple-sends
46
+ require(success, "Send failed");
47
+ }
48
+
49
+ function stealEthTransfer(bytes32 _requestId, bytes32) public recordChainlinkFulfillment(_requestId) {
50
+ address(this).transfer(100);
51
+ }
52
+
53
+ function doesNothing(bytes32, bytes32) public pure {} // solhint-disable-line no-empty-blocks
54
+ }
@@ -0,0 +1,52 @@
1
+ pragma solidity 0.5.0;
2
+
3
+
4
+ import "./MaliciousChainlinkClient.sol";
5
+
6
+
7
+ contract MaliciousRequester is MaliciousChainlinkClient {
8
+
9
+ uint256 constant private ORACLE_PAYMENT = 1 * LINK;
10
+ uint256 private expiration;
11
+
12
+ constructor(address _link, address _oracle) public {
13
+ setChainlinkToken(_link);
14
+ setChainlinkOracle(_oracle);
15
+ }
16
+
17
+ function maliciousWithdraw()
18
+ public
19
+ {
20
+ MaliciousChainlink.WithdrawRequest memory req = newWithdrawRequest(
21
+ "specId", address(this), this.doesNothing.selector);
22
+ chainlinkWithdrawRequest(req, ORACLE_PAYMENT);
23
+ }
24
+
25
+ function request(bytes32 _id, address _target, bytes memory _callbackFunc) public returns (bytes32 requestId) {
26
+ Chainlink.Request memory req = buildChainlinkRequest(_id, _target, bytes4(keccak256(_callbackFunc)));
27
+ expiration = now.add(5 minutes); // solhint-disable-line not-rely-on-time
28
+ requestId = sendChainlinkRequest(req, ORACLE_PAYMENT);
29
+ }
30
+
31
+ function maliciousPrice(bytes32 _id) public returns (bytes32 requestId) {
32
+ Chainlink.Request memory req = buildChainlinkRequest(_id, address(this), this.doesNothing.selector);
33
+ requestId = chainlinkPriceRequest(req, ORACLE_PAYMENT);
34
+ }
35
+
36
+ function maliciousTargetConsumer(address _target) public returns (bytes32 requestId) {
37
+ Chainlink.Request memory req = buildChainlinkRequest("specId", _target, bytes4(keccak256("fulfill(bytes32,bytes32)")));
38
+ requestId = chainlinkTargetRequest(_target, req, ORACLE_PAYMENT);
39
+ }
40
+
41
+ function maliciousRequestCancel(bytes32 _id, bytes memory _callbackFunc) public {
42
+ ChainlinkRequestInterface _oracle = ChainlinkRequestInterface(chainlinkOracleAddress());
43
+ _oracle.cancelOracleRequest(
44
+ request(_id, address(this), _callbackFunc),
45
+ ORACLE_PAYMENT,
46
+ this.maliciousRequestCancel.selector,
47
+ expiration
48
+ );
49
+ }
50
+
51
+ function doesNothing(bytes32, bytes32) public pure {} // solhint-disable-line no-empty-blocks
52
+ }
@@ -0,0 +1,75 @@
1
+ pragma solidity 0.5.0;
2
+
3
+ import "../dev/CoordinatorInterface.sol";
4
+ import "../dev/ServiceAgreementDecoder.sol";
5
+
6
+ /// Computes the mean of the values the oracles pass it via fulfill method
7
+ contract MeanAggregator is ServiceAgreementDecoder {
8
+
9
+ // Relies on Coordinator's authorization of the oracles (no need to track
10
+ // oracle authorization in this contract.)
11
+
12
+ mapping(bytes32 /* service agreement ID */ => uint256) payment;
13
+ mapping(bytes32 /* service agreement ID */ => address[]) oracles;
14
+ mapping(bytes32 /* request ID */ => uint256) numberReported;
15
+ mapping(bytes32 /* request ID */ => mapping(address => uint256)) reportingOrder;
16
+
17
+ // Current total for given request, divided by number of oracles reporting
18
+ mapping(bytes32 /* request ID */ => uint256) average;
19
+ // Remainder of total for given request from division by number of oracles.
20
+ mapping(bytes32 /* request ID */ => uint256) remainder;
21
+
22
+ function initiateJob(
23
+ bytes32 _sAId, bytes memory _serviceAgreementData)
24
+ public returns (bool success, bytes memory message) {
25
+ ServiceAgreement memory serviceAgreement = decodeServiceAgreement(_serviceAgreementData);
26
+
27
+ if (oracles[_sAId].length != 0) {
28
+ return (false, bytes("job already initiated"));
29
+ }
30
+ if (serviceAgreement.oracles.length == 0) {
31
+ return (false, bytes("must depend on at least one oracle"));
32
+ }
33
+ oracles[_sAId] = serviceAgreement.oracles;
34
+ payment[_sAId] = serviceAgreement.payment;
35
+ success = true;
36
+ }
37
+
38
+ function fulfill(bytes32 _requestId, bytes32 _sAId, address _oracle,
39
+ bytes32 _value) public
40
+ returns (bool success, bool complete, bytes memory response,
41
+ int256[] memory paymentAmounts) {
42
+ if (reportingOrder[_requestId][_oracle] != 0 ||
43
+ numberReported[_requestId] == oracles[_sAId].length) {
44
+ return (false, false, "oracle already reported", paymentAmounts);
45
+ }
46
+ uint256 oDividend = uint256(_value) / oracles[_sAId].length;
47
+ uint256 oRemainder = uint256(_value) % oracles[_sAId].length;
48
+ uint256 newRemainder = remainder[_requestId] + oRemainder;
49
+ uint256 newAverage = average[_requestId] + oDividend + (newRemainder / oracles[_sAId].length);
50
+ assert(newAverage >= average[_requestId]); // No overflow
51
+ average[_requestId] = newAverage;
52
+ remainder[_requestId] = newRemainder % oracles[_sAId].length;
53
+ numberReported[_requestId] += 1;
54
+ reportingOrder[_requestId][_oracle] = numberReported[_requestId];
55
+ success = true;
56
+ complete = (numberReported[_requestId] == oracles[_sAId].length);
57
+ if (complete) {
58
+ response = abi.encode(average[_requestId]);
59
+ paymentAmounts = calculatePayments(_sAId, _requestId);
60
+ }
61
+ }
62
+
63
+ function calculatePayments(bytes32 _sAId, bytes32 _requestId) private returns (int256[] memory paymentAmounts) {
64
+ paymentAmounts = new int256[](oracles[_sAId].length);
65
+ uint256 numOracles = oracles[_sAId].length;
66
+ uint256 totalPayment = payment[_sAId];
67
+ for (uint256 oIdx = 0; oIdx < oracles[_sAId].length; oIdx++) {
68
+ // Linearly-decaying payout determined by each oracle's reportingIdx
69
+ uint256 reportingIdx = reportingOrder[_requestId][oracles[_sAId][oIdx]] - 1;
70
+ paymentAmounts[oIdx] = int256(2*(totalPayment/numOracles) - (
71
+ (totalPayment * ((2*reportingIdx) + 1)) / (numOracles**2)));
72
+ delete reportingOrder[_requestId][oracles[_sAId][oIdx]];
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,15 @@
1
+ pragma solidity ^0.5.0;
2
+
3
+ import "../Median.sol";
4
+
5
+ contract MedianTestHelper {
6
+
7
+ function publicGet(int256[] memory _list)
8
+ public
9
+ pure
10
+ returns (int256)
11
+ {
12
+ return Median.calculate(_list);
13
+ }
14
+
15
+ }
@@ -0,0 +1,16 @@
1
+ pragma solidity 0.5.0;
2
+
3
+ import "../dev/Owned.sol";
4
+
5
+ contract OwnedTestHelper is Owned {
6
+
7
+ event Here();
8
+
9
+ function modifierOnlyOwner()
10
+ public
11
+ onlyOwner()
12
+ {
13
+ emit Here();
14
+ }
15
+
16
+ }
@@ -0,0 +1,30 @@
1
+ pragma solidity 0.5.0;
2
+
3
+ import "../ChainlinkClient.sol";
4
+
5
+ contract ServiceAgreementConsumer is ChainlinkClient {
6
+ uint256 constant private ORACLE_PAYMENT = 1 * LINK;
7
+
8
+ bytes32 internal sAId;
9
+ bytes32 public currentPrice;
10
+
11
+ constructor(address _link, address _coordinator, bytes32 _sAId) public {
12
+ setChainlinkToken(_link);
13
+ setChainlinkOracle(_coordinator);
14
+ sAId = _sAId;
15
+ }
16
+
17
+ function requestEthereumPrice(string memory _currency) public {
18
+ Chainlink.Request memory req = buildChainlinkRequest(sAId, address(this), this.fulfill.selector);
19
+ req.add("get", "https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD,EUR,JPY");
20
+ req.add("path", _currency);
21
+ sendChainlinkRequest(req, ORACLE_PAYMENT);
22
+ }
23
+
24
+ function fulfill(bytes32 _requestId, bytes32 _price)
25
+ public
26
+ recordChainlinkFulfillment(_requestId)
27
+ {
28
+ currentPrice = _price;
29
+ }
30
+ }