@snapshot-labs/snapshot.js 0.2.2 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (287) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +0 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/plugins/charts/index.d.ts +5 -0
  5. package/dist/plugins/commentBox/index.d.ts +5 -0
  6. package/dist/plugins/index.d.ts +4 -0
  7. package/dist/rollup.cjs.config.dev.js +43 -0
  8. package/dist/rollup.config.dev.js +75 -0
  9. package/dist/sign/eip1271.d.ts +1 -1
  10. package/dist/sign/index.d.ts +2 -2
  11. package/dist/snapshot.cjs.js +73 -34
  12. package/dist/snapshot.esm.js +73 -34
  13. package/dist/snapshot.min.js +1 -1
  14. package/dist/strategies/aave-governance-power/index.d.ts +3 -0
  15. package/dist/strategies/aavegotchi/index.d.ts +6 -0
  16. package/dist/strategies/aavegotchi-agip/index.d.ts +3 -0
  17. package/dist/strategies/apescape/index.d.ts +6 -0
  18. package/dist/strategies/api/index.d.ts +6 -0
  19. package/dist/strategies/avn-balance-of-staked/index.d.ts +3 -0
  20. package/dist/strategies/badgeth/index.d.ts +3 -0
  21. package/dist/strategies/balance-of-with-min/index.d.ts +3 -0
  22. package/dist/strategies/balance-of-with-thresholds/index.d.ts +25 -0
  23. package/dist/strategies/balancer/index.d.ts +3 -0
  24. package/dist/strategies/balancer-delegation/index.d.ts +6 -0
  25. package/dist/strategies/balancer-smart-pool/index.d.ts +6 -0
  26. package/dist/strategies/balancer-unipool/index.d.ts +6 -0
  27. package/dist/strategies/brightid/index.d.ts +6 -0
  28. package/dist/strategies/cake/index.d.ts +3 -0
  29. package/dist/strategies/celer-sgn-delegation/index.d.ts +3 -0
  30. package/dist/strategies/comp-like-votes/index.d.ts +6 -0
  31. package/dist/strategies/contract-call/index.d.ts +6 -0
  32. package/dist/strategies/cream/index.d.ts +3 -0
  33. package/dist/strategies/ctoken/index.d.ts +3 -0
  34. package/dist/strategies/curio-cards-erc20-weighted/index.d.ts +3 -0
  35. package/dist/strategies/decentraland-estate-size/index.d.ts +3 -0
  36. package/dist/strategies/defidollar/index.d.ts +3 -0
  37. package/dist/strategies/delegation/index.d.ts +6 -0
  38. package/dist/strategies/dittomoney/index.d.ts +3 -0
  39. package/dist/strategies/ens-domains-owned/index.d.ts +3 -0
  40. package/dist/strategies/ens-reverse-record/index.d.ts +6 -0
  41. package/dist/strategies/erc1155-all-balances-of/index.d.ts +6 -0
  42. package/dist/strategies/erc1155-balance-of/index.d.ts +6 -0
  43. package/dist/strategies/erc1155-balance-of-cv/index.d.ts +6 -0
  44. package/dist/strategies/erc20-balance-of/index.d.ts +3 -0
  45. package/dist/strategies/erc20-balance-of-coeff/index.d.ts +3 -0
  46. package/dist/strategies/erc20-balance-of-cv/index.d.ts +6 -0
  47. package/dist/strategies/erc20-balance-of-delegation/index.d.ts +6 -0
  48. package/dist/strategies/erc20-balance-of-fixed-total/index.d.ts +6 -0
  49. package/dist/strategies/erc20-balance-of-quadratic-delegation/index.d.ts +6 -0
  50. package/dist/strategies/erc20-price/index.d.ts +3 -0
  51. package/dist/strategies/erc20-received/index.d.ts +10 -0
  52. package/dist/strategies/erc20-with-balance/index.d.ts +3 -0
  53. package/dist/strategies/erc721/index.d.ts +6 -0
  54. package/dist/strategies/erc721-enumerable/index.d.ts +3 -0
  55. package/dist/strategies/erc721-with-multiplier/index.d.ts +6 -0
  56. package/dist/strategies/erc721-with-tokenid/index.d.ts +21 -0
  57. package/dist/strategies/esd/index.d.ts +3 -0
  58. package/dist/strategies/esd-delegation/index.d.ts +6 -0
  59. package/dist/strategies/eth-balance/index.d.ts +6 -0
  60. package/dist/strategies/eth-philanthropy/index.d.ts +6 -0
  61. package/dist/strategies/eth-received/ElasticSearchTxResult.d.ts +71 -0
  62. package/dist/strategies/eth-received/index.d.ts +7 -0
  63. package/dist/strategies/eth-wallet-age/index.d.ts +3 -0
  64. package/dist/strategies/eth-with-balance/index.d.ts +3 -0
  65. package/dist/strategies/flashstake/index.d.ts +3 -0
  66. package/dist/strategies/frax-finance/index.d.ts +3 -0
  67. package/dist/strategies/governor-alpha/index.d.ts +6 -0
  68. package/dist/strategies/hopr-uni-lp-farm/index.d.ts +3 -0
  69. package/dist/strategies/ilv/index.d.ts +6 -0
  70. package/dist/strategies/impossible-finance/index.d.ts +6 -0
  71. package/dist/strategies/index.d.ts +243 -0
  72. package/dist/strategies/infinityprotocol-liquidity-pools/index.d.ts +3 -0
  73. package/dist/strategies/inverse-xinv/index.d.ts +6 -0
  74. package/dist/strategies/iotex-balance/index.d.ts +3 -0
  75. package/dist/strategies/iotex-staked-balance/index.d.ts +3 -0
  76. package/dist/strategies/liftkitchen/index.d.ts +3 -0
  77. package/dist/strategies/maker-ds-chief/index.d.ts +6 -0
  78. package/dist/strategies/masterchef/index.d.ts +3 -0
  79. package/dist/strategies/masterchef-pool-balance/index.d.ts +3 -0
  80. package/dist/strategies/masterchef-pool-balance-price/index.d.ts +6 -0
  81. package/dist/strategies/mithcash/index.d.ts +3 -0
  82. package/dist/strategies/modefi/index.d.ts +6 -0
  83. package/dist/strategies/modefi-staking/index.d.ts +6 -0
  84. package/dist/strategies/moloch/index.d.ts +6 -0
  85. package/dist/strategies/moloch-all/index.d.ts +6 -0
  86. package/dist/strategies/moloch-loot/index.d.ts +6 -0
  87. package/dist/strategies/multichain/index.d.ts +3 -0
  88. package/dist/strategies/multisig-owners/index.d.ts +6 -0
  89. package/dist/strategies/mushrooms/index.d.ts +6 -0
  90. package/dist/strategies/niu-staked/index.d.ts +6 -0
  91. package/dist/strategies/ocean-marketplace/index.d.ts +8 -0
  92. package/dist/strategies/ocean-marketplace/oceanUtils.d.ts +2 -0
  93. package/dist/strategies/ogn/index.d.ts +3 -0
  94. package/dist/strategies/opium/index.d.ts +3 -0
  95. package/dist/strategies/pagination/index.d.ts +3 -0
  96. package/dist/strategies/pancake/index.d.ts +6 -0
  97. package/dist/strategies/pepemon/index.d.ts +6 -0
  98. package/dist/strategies/piedao/index.d.ts +3 -0
  99. package/dist/strategies/planet-finance/index.d.ts +4 -0
  100. package/dist/strategies/pob-hash/index.d.ts +9 -0
  101. package/dist/strategies/rebased/index.d.ts +3 -0
  102. package/dist/strategies/ren-nodes/index.d.ts +3 -0
  103. package/dist/strategies/rnbw-balance/index.d.ts +3 -0
  104. package/dist/strategies/ruler-staked-lp/index.d.ts +6 -0
  105. package/dist/strategies/ruler-staked-token/index.d.ts +6 -0
  106. package/dist/strategies/saffron-finance/index.d.ts +6 -0
  107. package/dist/strategies/spookyswap/index.d.ts +6 -0
  108. package/dist/strategies/stablexswap/index.d.ts +6 -0
  109. package/dist/strategies/staked-keep/index.d.ts +3 -0
  110. package/dist/strategies/staked-uniswap/index.d.ts +6 -0
  111. package/dist/strategies/strategiesFull.d.ts +245 -0
  112. package/dist/strategies/sushiswap/index.d.ts +3 -0
  113. package/dist/strategies/synthetix/index.d.ts +3 -0
  114. package/dist/strategies/the-graph/baseStrategy.d.ts +4 -0
  115. package/dist/strategies/the-graph/graphUtils.d.ts +12 -0
  116. package/dist/strategies/the-graph/tokenLockWallets.d.ts +9 -0
  117. package/dist/strategies/the-graph-balance/balances.d.ts +2 -0
  118. package/dist/strategies/the-graph-balance/index.d.ts +6 -0
  119. package/dist/strategies/the-graph-delegation/delegators.d.ts +2 -0
  120. package/dist/strategies/the-graph-delegation/index.d.ts +6 -0
  121. package/dist/strategies/the-graph-indexing/index.d.ts +6 -0
  122. package/dist/strategies/the-graph-indexing/indexers.d.ts +2 -0
  123. package/dist/strategies/ticket/index.d.ts +6 -0
  124. package/dist/strategies/ticket-validity/index.d.ts +3 -0
  125. package/dist/strategies/tokenlon/index.d.ts +3 -0
  126. package/dist/strategies/tomb-finance/index.d.ts +6 -0
  127. package/dist/strategies/total-axion-shares/index.d.ts +3 -0
  128. package/dist/strategies/tranche-staking/index.d.ts +6 -0
  129. package/dist/strategies/tranche-staking-lp/index.d.ts +6 -0
  130. package/dist/strategies/tranche-staking-slice/index.d.ts +3 -0
  131. package/dist/strategies/typhoon/index.d.ts +3 -0
  132. package/dist/strategies/uni/index.d.ts +6 -0
  133. package/dist/strategies/unipool-same-token/index.d.ts +6 -0
  134. package/dist/strategies/unipool-univ2-lp/index.d.ts +6 -0
  135. package/dist/strategies/uniswap/index.d.ts +3 -0
  136. package/dist/strategies/whitelist/index.d.ts +6 -0
  137. package/dist/strategies/work/index.d.ts +6 -0
  138. package/dist/strategies/xcover/index.d.ts +6 -0
  139. package/dist/strategies/xdai-easy-staking/index.d.ts +3 -0
  140. package/dist/strategies/xdai-easy-staking/utils.d.ts +3 -0
  141. package/dist/strategies/xdai-posdao-staking/index.d.ts +3 -0
  142. package/dist/strategies/xdai-stake-delegation/index.d.ts +6 -0
  143. package/dist/strategies/xdai-stake-holders/index.d.ts +3 -0
  144. package/dist/strategies/xdai-stakers-and-holders/index.d.ts +3 -0
  145. package/dist/strategies/xrc20-balance-of/index.d.ts +3 -0
  146. package/dist/strategies/xseen/index.d.ts +6 -0
  147. package/dist/strategies/yearn-vault/index.d.ts +3 -0
  148. package/dist/strategies/zrx-voting-power/index.d.ts +3 -0
  149. package/dist/utils/contentHash.d.ts +28 -0
  150. package/package.json +2 -2
  151. package/src/client.ts +0 -0
  152. package/src/dist/index.js +14 -0
  153. package/src/dist/utils.js +291 -0
  154. package/src/networks/{fuse.png → 122.png} +0 -0
  155. package/src/networks/43114.png +0 -0
  156. package/src/networks.json +2 -2
  157. package/src/plugins/charts/index.ts +5 -0
  158. package/src/plugins/charts/logo.png +0 -0
  159. package/src/plugins/commentBox/index.ts +5 -0
  160. package/src/plugins/commentBox/logo.png +0 -0
  161. package/src/plugins/index.ts +5 -1
  162. package/src/plugins/safeSnap/dist/index.js +585 -0
  163. package/src/plugins/safeSnap/index.ts +22 -7
  164. package/src/sign/eip1271.ts +2 -2
  165. package/src/sign/index.ts +9 -5
  166. package/src/strategies/aave-governance-power/dist/index.js +110 -0
  167. package/src/strategies/aavegotchi/dist/index.js +156 -0
  168. package/src/strategies/aavegotchi-agip/dist/index.js +168 -0
  169. package/src/strategies/apescape/dist/index.js +164 -0
  170. package/src/strategies/api/dist/index.js +76 -0
  171. package/src/strategies/avn-balance-of-staked/dist/index.js +173 -0
  172. package/src/strategies/badgeth/dist/index.js +86 -0
  173. package/src/strategies/balance-of-with-min/dist/index.js +64 -0
  174. package/src/strategies/balance-of-with-thresholds/dist/index.js +73 -0
  175. package/src/strategies/balancer/dist/index.js +121 -0
  176. package/src/strategies/balancer-delegation/dist/index.js +62 -0
  177. package/src/strategies/balancer-smart-pool/dist/index.js +85 -0
  178. package/src/strategies/balancer-unipool/dist/index.js +141 -0
  179. package/src/strategies/brightid/dist/index.js +69 -0
  180. package/src/strategies/cake/dist/index.js +146 -0
  181. package/src/strategies/celer-sgn-delegation/dist/index.js +199 -0
  182. package/src/strategies/comp-like-votes/dist/index.js +91 -0
  183. package/src/strategies/contract-call/dist/index.js +76 -0
  184. package/src/strategies/cream/dist/index.js +310 -0
  185. package/src/strategies/ctoken/dist/index.js +145 -0
  186. package/src/strategies/curio-cards-erc20-weighted/dist/index.js +188 -0
  187. package/src/strategies/decentraland-estate-size/dist/index.js +101 -0
  188. package/src/strategies/defidollar/dist/index.js +106 -0
  189. package/src/strategies/delegation/dist/index.js +71 -0
  190. package/src/strategies/dist/index.js +248 -0
  191. package/src/strategies/dist/strategiesFull.js +246 -0
  192. package/src/strategies/dittomoney/dist/index.js +167 -0
  193. package/src/strategies/ens-domains-owned/dist/index.js +105 -0
  194. package/src/strategies/ens-reverse-record/dist/index.js +98 -0
  195. package/src/strategies/erc1155-all-balances-of/dist/index.js +99 -0
  196. package/src/strategies/erc1155-balance-of/dist/index.js +94 -0
  197. package/src/strategies/erc1155-balance-of-cv/dist/index.js +58 -0
  198. package/src/strategies/erc20-balance-of/dist/index.js +76 -0
  199. package/src/strategies/erc20-balance-of-delegation/dist/index.js +73 -0
  200. package/src/strategies/erc20-balance-of-quadratic-delegation/dist/index.js +75 -0
  201. package/src/strategies/erc20-price/dist/index.js +107 -0
  202. package/src/strategies/erc20-received/dist/index.js +166 -0
  203. package/src/strategies/erc20-with-balance/dist/index.js +61 -0
  204. package/src/strategies/erc721/dist/index.js +69 -0
  205. package/src/strategies/erc721-enumerable/dist/index.js +57 -0
  206. package/src/strategies/erc721-with-multiplier/dist/index.js +70 -0
  207. package/src/strategies/erc721-with-tokenid/dist/index.js +68 -0
  208. package/src/strategies/esd/dist/index.js +125 -0
  209. package/src/strategies/esd-delegation/dist/index.js +73 -0
  210. package/src/strategies/eth-balance/dist/index.js +72 -0
  211. package/src/strategies/eth-philanthropy/dist/index.js +81 -0
  212. package/src/strategies/eth-received/dist/index.js +127 -0
  213. package/src/strategies/eth-wallet-age/dist/index.js +126 -0
  214. package/src/strategies/eth-with-balance/dist/index.js +63 -0
  215. package/src/strategies/flashstake/dist/index.js +138 -0
  216. package/src/strategies/frax-finance/dist/index.js +236 -0
  217. package/src/strategies/governor-alpha/dist/index.js +71 -0
  218. package/src/strategies/hopr-uni-lp-farm/dist/index.js +232 -0
  219. package/src/strategies/ilv/dist/index.js +58 -0
  220. package/src/strategies/impossible-finance/dist/index.js +126 -0
  221. package/src/strategies/infinityprotocol-liquidity-pools/dist/index.js +120 -0
  222. package/src/strategies/inverse-xinv/dist/index.js +76 -0
  223. package/src/strategies/iotex-balance/dist/index.js +82 -0
  224. package/src/strategies/iotex-staked-balance/dist/index.js +79 -0
  225. package/src/strategies/liftkitchen/dist/index.js +167 -0
  226. package/src/strategies/masterchef/dist/index.js +183 -0
  227. package/src/strategies/masterchef-pool-balance/dist/index.js +190 -0
  228. package/src/strategies/masterchef-pool-balance-price/dist/index.js +442 -0
  229. package/src/strategies/mithcash/dist/index.js +133 -0
  230. package/src/strategies/modefi/dist/index.js +120 -0
  231. package/src/strategies/modefi-staking/dist/index.js +115 -0
  232. package/src/strategies/moloch-all/dist/index.js +154 -0
  233. package/src/strategies/moloch-loot/dist/index.js +153 -0
  234. package/src/strategies/multichain/dist/index.js +149 -0
  235. package/src/strategies/multisig-owners/dist/index.js +85 -0
  236. package/src/strategies/mushrooms/dist/index.js +202 -0
  237. package/src/strategies/niu-staked/dist/index.js +83 -0
  238. package/src/strategies/ocean-marketplace/dist/index.js +155 -0
  239. package/src/strategies/ogn/dist/index.js +105 -0
  240. package/src/strategies/opium/dist/index.js +153 -0
  241. package/src/strategies/pagination/dist/index.js +78 -0
  242. package/src/strategies/pancake/dist/index.js +140 -0
  243. package/src/strategies/pepemon/dist/index.js +177 -0
  244. package/src/strategies/piedao/dist/index.js +156 -0
  245. package/src/strategies/planet-finance/dist/index.js +190 -0
  246. package/src/strategies/pob-hash/dist/index.js +95 -0
  247. package/src/strategies/rebased/dist/index.js +134 -0
  248. package/src/strategies/ren-nodes/dist/index.js +148 -0
  249. package/src/strategies/rnbw-balance/dist/index.js +107 -0
  250. package/src/strategies/ruler-staked-lp/dist/index.js +156 -0
  251. package/src/strategies/ruler-staked-token/dist/index.js +100 -0
  252. package/src/strategies/saffron-finance/dist/index.js +293 -0
  253. package/src/strategies/spookyswap/dist/index.js +161 -0
  254. package/src/strategies/stablexswap/dist/index.js +153 -0
  255. package/src/strategies/staked-keep/dist/index.js +90 -0
  256. package/src/strategies/staked-uniswap/dist/index.js +112 -0
  257. package/src/strategies/sushiswap/dist/index.js +120 -0
  258. package/src/strategies/synthetix/dist/index.js +233 -0
  259. package/src/strategies/the-graph-balance/dist/index.js +55 -0
  260. package/src/strategies/the-graph-delegation/dist/index.js +55 -0
  261. package/src/strategies/the-graph-indexing/dist/index.js +55 -0
  262. package/src/strategies/ticket/dist/index.js +51 -0
  263. package/src/strategies/ticket-validity/dist/index.js +63 -0
  264. package/src/strategies/tokenlon/dist/index.js +211 -0
  265. package/src/strategies/tomb-finance/dist/index.js +130 -0
  266. package/src/strategies/total-axion-shares/dist/index.js +93 -0
  267. package/src/strategies/tranche-staking/dist/index.js +96 -0
  268. package/src/strategies/tranche-staking-lp/dist/index.js +133 -0
  269. package/src/strategies/tranche-staking-slice/dist/index.js +164 -0
  270. package/src/strategies/typhoon/dist/index.js +124 -0
  271. package/src/strategies/uni/dist/index.js +93 -0
  272. package/src/strategies/unipool-same-token/dist/index.js +98 -0
  273. package/src/strategies/unipool-univ2-lp/dist/index.js +105 -0
  274. package/src/strategies/uniswap/dist/index.js +120 -0
  275. package/src/strategies/whitelist/dist/index.js +56 -0
  276. package/src/strategies/work/dist/index.js +90 -0
  277. package/src/strategies/xcover/dist/index.js +95 -0
  278. package/src/strategies/xdai-easy-staking/dist/index.js +193 -0
  279. package/src/strategies/xdai-posdao-staking/dist/index.js +63 -0
  280. package/src/strategies/xdai-stake-delegation/dist/index.js +93 -0
  281. package/src/strategies/xdai-stake-holders/dist/index.js +63 -0
  282. package/src/strategies/xdai-stakers-and-holders/dist/index.js +137 -0
  283. package/src/strategies/xrc20-balance-of/dist/index.js +83 -0
  284. package/src/strategies/xseen/dist/index.js +121 -0
  285. package/src/strategies/zrx-voting-power/dist/index.js +104 -0
  286. package/src/utils/dist/provider.js +12 -0
  287. package/src/utils/dist/web3.js +73 -0
File without changes
Binary file
package/src/networks.json CHANGED
@@ -298,8 +298,8 @@
298
298
  ],
299
299
  "explorer": "https://www.wanscan.org"
300
300
  },
301
- "2109": {
302
- "key": "2109",
301
+ "43114": {
302
+ "key": "43114",
303
303
  "name": "Avalanche",
304
304
  "chainId": 43114,
305
305
  "network": "mainnet",
@@ -0,0 +1,5 @@
1
+ export default class Plugin {
2
+ public author = 'zerquix18';
3
+ public version = '0.1.0';
4
+ public name = 'Charts';
5
+ }
Binary file
@@ -0,0 +1,5 @@
1
+ export default class Plugin {
2
+ public author = 'spiritbro1';
3
+ public version = '0.0.1';
4
+ public name = 'Comment Box';
5
+ }
Binary file
@@ -1,13 +1,17 @@
1
1
  import aragon from './aragon';
2
+ import charts from './charts';
2
3
  import gnosis from './gnosis';
3
4
  import safeSnap from './safeSnap';
4
5
  import quorum from './quorum';
5
6
  import poap from './poap';
7
+ import commentBox from './commentBox';
6
8
 
7
9
  export default {
8
10
  aragon,
11
+ charts,
9
12
  gnosis,
10
13
  safeSnap,
11
14
  poap,
12
- quorum
15
+ quorum,
16
+ commentBox
13
17
  };
@@ -0,0 +1,585 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __spreadArrays = (this && this.__spreadArrays) || function () {
50
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
51
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
52
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
53
+ r[k] = a[j];
54
+ return r;
55
+ };
56
+ exports.__esModule = true;
57
+ var address_1 = require("@ethersproject/address");
58
+ var bignumber_1 = require("@ethersproject/bignumber/lib/bignumber");
59
+ var bytes_1 = require("@ethersproject/bytes");
60
+ var constants_1 = require("@ethersproject/constants");
61
+ var solidity_1 = require("@ethersproject/solidity");
62
+ var utils_1 = require("../../utils");
63
+ var provider_1 = require("../../utils/provider");
64
+ var hash_1 = require("@ethersproject/hash");
65
+ var contracts_1 = require("@ethersproject/contracts");
66
+ var EIP712_TYPES = {
67
+ Transaction: [
68
+ {
69
+ name: 'to',
70
+ type: 'address'
71
+ },
72
+ {
73
+ name: 'value',
74
+ type: 'uint256'
75
+ },
76
+ {
77
+ name: 'data',
78
+ type: 'bytes'
79
+ },
80
+ {
81
+ name: 'operation',
82
+ type: 'uint8'
83
+ },
84
+ {
85
+ name: 'nonce',
86
+ type: 'uint256'
87
+ }
88
+ ]
89
+ };
90
+ var ModuleAbi = [
91
+ // Events
92
+ 'event ProposalQuestionCreated(bytes32 indexed questionId, string indexed proposalId)',
93
+ // Read functions
94
+ 'function owner() view returns (address)',
95
+ 'function oracle() view returns (address)',
96
+ 'function questionCooldown() view returns (uint32)',
97
+ 'function buildQuestion(string proposalId, bytes32[] txHashes) view returns (string)',
98
+ 'function executedProposalTransactions(bytes32 questionHash, bytes32 txHash) view returns (bool)',
99
+ 'function questionIds(bytes32 questionHash) view returns (bytes32)',
100
+ 'function minimumBond() view returns (uint256)',
101
+ // Write functions
102
+ 'function addProposal(string proposalId, bytes32[] txHashes)',
103
+ 'function executeProposalWithIndex(string proposalId, bytes32[] txHashes, address to, uint256 value, bytes data, uint8 operation, uint256 txIndex)'
104
+ ];
105
+ var OracleAbi = [
106
+ // Events
107
+ "event LogNewAnswer(\n bytes32 answer,\n bytes32 indexed question_id,\n bytes32 history_hash,\n address indexed user,\n uint256 bond,\n uint256 ts,\n bool is_commitment\n )",
108
+ // Read functions
109
+ 'function resultFor(bytes32 question_id) view returns (bytes32)',
110
+ 'function getFinalizeTS(bytes32 question_id) view returns (uint32)',
111
+ 'function getBond(bytes32 question_id) view returns (uint256)',
112
+ 'function getBestAnswer(bytes32 question_id) view returns (uint32)',
113
+ 'function balanceOf(address) view returns (uint256)',
114
+ 'function getHistoryHash(bytes32 question_id) view returns (bytes32)',
115
+ 'function isFinalized(bytes32 question_id) view returns (bool)',
116
+ 'function token() view returns (address)',
117
+ // Write functions
118
+ 'function submitAnswer(bytes32 question_id, bytes32 answer, uint256 max_previous) external payable',
119
+ 'function submitAnswerERC20(bytes32 question_id, bytes32 answer, uint256 max_previous, uint256 tokens) external',
120
+ "function claimMultipleAndWithdrawBalance(\n bytes32[] question_ids,\n uint256[] lengths,\n bytes32[] hist_hashes,\n address[] addrs,\n uint256[] bonds,\n bytes32[] answers\n ) public",
121
+ 'function withdraw() public'
122
+ ];
123
+ var TokenAbi = [
124
+ //Read functions
125
+ 'function balanceOf(address account) view returns (uint256)',
126
+ 'function decimals() view returns (uint32)',
127
+ 'function symbol() view returns (string)',
128
+ 'function allowance(address owner, address spender) external view returns (uint256)',
129
+ // Write functions
130
+ 'function approve(address spender, uint256 value) external returns (bool)'
131
+ ];
132
+ var START_BLOCKS = {
133
+ 1: 6531147,
134
+ 4: 3175028
135
+ };
136
+ var buildQuestion = function (proposalId, txHashes) { return __awaiter(void 0, void 0, void 0, function () {
137
+ var hashesHash;
138
+ return __generator(this, function (_a) {
139
+ hashesHash = solidity_1.keccak256(['bytes32[]'], [txHashes]).slice(2);
140
+ return [2 /*return*/, proposalId + "\u241F" + hashesHash];
141
+ });
142
+ }); };
143
+ var getProposalDetails = function (provider, network, moduleAddress, questionHash, txHashes) { return __awaiter(void 0, void 0, Promise, function () {
144
+ var proposalInfo, questionId, nextIndexToExecute;
145
+ return __generator(this, function (_a) {
146
+ switch (_a.label) {
147
+ case 0: return [4 /*yield*/, utils_1.multicall(network, provider, ModuleAbi, [[moduleAddress, 'questionIds', [questionHash]]].concat(txHashes.map(function (txHash) { return [
148
+ moduleAddress,
149
+ 'executedProposalTransactions',
150
+ [questionHash, txHash]
151
+ ]; })))];
152
+ case 1:
153
+ proposalInfo = (_a.sent()).map(function (res) { return res[0]; });
154
+ questionId = proposalInfo[0];
155
+ nextIndexToExecute = proposalInfo.indexOf(false, 1) - 1;
156
+ return [2 /*return*/, {
157
+ questionId: questionId !== constants_1.HashZero ? questionId : undefined,
158
+ nextTxIndex: nextIndexToExecute < 0 || nextIndexToExecute >= txHashes.length
159
+ ? undefined
160
+ : nextIndexToExecute
161
+ }];
162
+ }
163
+ });
164
+ }); };
165
+ var getModuleDetails = function (provider, network, moduleAddress) { return __awaiter(void 0, void 0, Promise, function () {
166
+ var moduleDetails;
167
+ return __generator(this, function (_a) {
168
+ switch (_a.label) {
169
+ case 0: return [4 /*yield*/, utils_1.multicall(network, provider, ModuleAbi, [
170
+ [moduleAddress, 'owner'],
171
+ [moduleAddress, 'oracle'],
172
+ [moduleAddress, 'questionCooldown'],
173
+ [moduleAddress, 'minimumBond']
174
+ ])];
175
+ case 1:
176
+ moduleDetails = _a.sent();
177
+ return [2 /*return*/, {
178
+ dao: moduleDetails[0][0],
179
+ oracle: moduleDetails[1][0],
180
+ cooldown: moduleDetails[2][0],
181
+ minimumBond: moduleDetails[3][0]
182
+ }];
183
+ }
184
+ });
185
+ }); };
186
+ var checkPossibleExecution = function (provider, network, oracleAddress, questionId) { return __awaiter(void 0, void 0, Promise, function () {
187
+ var result, e_1;
188
+ return __generator(this, function (_a) {
189
+ switch (_a.label) {
190
+ case 0:
191
+ if (!questionId) return [3 /*break*/, 4];
192
+ _a.label = 1;
193
+ case 1:
194
+ _a.trys.push([1, 3, , 4]);
195
+ return [4 /*yield*/, utils_1.multicall(network, provider, OracleAbi, [
196
+ [oracleAddress, 'resultFor', [questionId]],
197
+ [oracleAddress, 'getFinalizeTS', [questionId]]
198
+ ])];
199
+ case 2:
200
+ result = _a.sent();
201
+ return [2 /*return*/, {
202
+ executionApproved: bignumber_1.BigNumber.from(result[0][0]).eq(bignumber_1.BigNumber.from(1)),
203
+ finalizedAt: bignumber_1.BigNumber.from(result[1][0]).toNumber()
204
+ }];
205
+ case 3:
206
+ e_1 = _a.sent();
207
+ return [3 /*break*/, 4];
208
+ case 4: return [2 /*return*/, {
209
+ executionApproved: false,
210
+ finalizedAt: undefined
211
+ }];
212
+ }
213
+ });
214
+ }); };
215
+ var retrieveInfoFromOracle = function (provider, network, oracleAddress, questionId) { return __awaiter(void 0, void 0, Promise, function () {
216
+ var result, currentBond, answer;
217
+ return __generator(this, function (_a) {
218
+ switch (_a.label) {
219
+ case 0:
220
+ if (!questionId) return [3 /*break*/, 2];
221
+ return [4 /*yield*/, utils_1.multicall(network, provider, OracleAbi, [
222
+ [oracleAddress, 'getFinalizeTS', [questionId]],
223
+ [oracleAddress, 'getBond', [questionId]],
224
+ [oracleAddress, 'getBestAnswer', [questionId]]
225
+ ])];
226
+ case 1:
227
+ result = _a.sent();
228
+ currentBond = bignumber_1.BigNumber.from(result[1][0]);
229
+ answer = bignumber_1.BigNumber.from(result[2][0]);
230
+ return [2 /*return*/, {
231
+ currentBond: currentBond,
232
+ isApproved: answer.eq(bignumber_1.BigNumber.from(1)),
233
+ endTime: bignumber_1.BigNumber.from(result[0][0]).toNumber()
234
+ }];
235
+ case 2: return [2 /*return*/, {
236
+ currentBond: undefined,
237
+ isApproved: false,
238
+ endTime: undefined
239
+ }];
240
+ }
241
+ });
242
+ }); };
243
+ var Plugin = /** @class */ (function () {
244
+ function Plugin() {
245
+ this.author = 'Gnosis';
246
+ this.version = '1.0.0';
247
+ this.name = 'SafeSnap';
248
+ this.website = 'https://safe.gnosis.io';
249
+ }
250
+ Plugin.prototype.validateTransaction = function (transaction) {
251
+ var addressEmptyOrValidate = transaction.to === '' || address_1.isAddress(transaction.to);
252
+ return (bignumber_1.isBigNumberish(transaction.value) &&
253
+ addressEmptyOrValidate &&
254
+ (!transaction.data || bytes_1.isHexString(transaction.data)) &&
255
+ transaction.operation in ['0', '1'] &&
256
+ bignumber_1.isBigNumberish(transaction.nonce));
257
+ };
258
+ Plugin.prototype.calcTransactionHash = function (network, moduleAddress, transaction) {
259
+ return __awaiter(this, void 0, void 0, function () {
260
+ var chainId, domain;
261
+ return __generator(this, function (_a) {
262
+ chainId = parseInt(network);
263
+ domain = {
264
+ chainId: chainId,
265
+ verifyingContract: moduleAddress
266
+ };
267
+ return [2 /*return*/, hash_1._TypedDataEncoder.hash(domain, EIP712_TYPES, transaction)];
268
+ });
269
+ });
270
+ };
271
+ Plugin.prototype.calcTransactionHashes = function (chainId, moduleAddress, transactions) {
272
+ return __awaiter(this, void 0, void 0, function () {
273
+ var domain;
274
+ return __generator(this, function (_a) {
275
+ domain = {
276
+ chainId: chainId,
277
+ verifyingContract: moduleAddress
278
+ };
279
+ return [2 /*return*/, transactions.map(function (tx) {
280
+ var txHash = hash_1._TypedDataEncoder.hash(domain, EIP712_TYPES, __assign({
281
+ // @ts-ignore
282
+ nonce: '0',
283
+ // @ts-ignore
284
+ data: '0x' }, tx));
285
+ return txHash;
286
+ })];
287
+ });
288
+ });
289
+ };
290
+ Plugin.prototype.getExecutionDetails = function (network, moduleAddress, proposalId, transactions) {
291
+ return __awaiter(this, void 0, Promise, function () {
292
+ var provider, chainId, txHashes, question, questionHash, proposalDetails, moduleDetails, questionState, infoFromOracle;
293
+ return __generator(this, function (_a) {
294
+ switch (_a.label) {
295
+ case 0:
296
+ provider = provider_1["default"](network);
297
+ chainId = parseInt(network);
298
+ return [4 /*yield*/, this.calcTransactionHashes(chainId, moduleAddress, transactions)];
299
+ case 1:
300
+ txHashes = _a.sent();
301
+ return [4 /*yield*/, buildQuestion(proposalId, txHashes)];
302
+ case 2:
303
+ question = _a.sent();
304
+ questionHash = solidity_1.keccak256(['string'], [question]);
305
+ return [4 /*yield*/, getProposalDetails(provider, network, moduleAddress, questionHash, txHashes)];
306
+ case 3:
307
+ proposalDetails = _a.sent();
308
+ return [4 /*yield*/, getModuleDetails(provider, network, moduleAddress)];
309
+ case 4:
310
+ moduleDetails = _a.sent();
311
+ return [4 /*yield*/, checkPossibleExecution(provider, network, moduleDetails.oracle, proposalDetails.questionId)];
312
+ case 5:
313
+ questionState = _a.sent();
314
+ return [4 /*yield*/, retrieveInfoFromOracle(provider, network, moduleDetails.oracle, proposalDetails.questionId)];
315
+ case 6:
316
+ infoFromOracle = _a.sent();
317
+ try {
318
+ return [2 /*return*/, __assign(__assign(__assign(__assign(__assign(__assign({}, moduleDetails), { proposalId: proposalId }), questionState), proposalDetails), { transactions: transactions,
319
+ txHashes: txHashes }), infoFromOracle)];
320
+ }
321
+ catch (e) {
322
+ throw new Error(e);
323
+ }
324
+ return [2 /*return*/];
325
+ }
326
+ });
327
+ });
328
+ };
329
+ Plugin.prototype.getModuleDetails = function (network, moduleAddress) {
330
+ return __awaiter(this, void 0, void 0, function () {
331
+ var provider;
332
+ return __generator(this, function (_a) {
333
+ provider = provider_1["default"](network);
334
+ return [2 /*return*/, getModuleDetails(provider, network, moduleAddress)];
335
+ });
336
+ });
337
+ };
338
+ Plugin.prototype.submitProposal = function (web3, moduleAddress, proposalId, transactions) {
339
+ return __awaiter(this, void 0, void 0, function () {
340
+ var txHashes, tx, receipt;
341
+ return __generator(this, function (_a) {
342
+ switch (_a.label) {
343
+ case 0: return [4 /*yield*/, this.calcTransactionHashes(web3.network.chainId, moduleAddress, transactions)];
344
+ case 1:
345
+ txHashes = _a.sent();
346
+ return [4 /*yield*/, utils_1.sendTransaction(web3, moduleAddress, ModuleAbi, 'addProposal', [proposalId, txHashes])];
347
+ case 2:
348
+ tx = _a.sent();
349
+ return [4 /*yield*/, tx.wait()];
350
+ case 3:
351
+ receipt = _a.sent();
352
+ console.log('[DAO module] submitted proposal:', receipt);
353
+ return [2 /*return*/];
354
+ }
355
+ });
356
+ });
357
+ };
358
+ Plugin.prototype.loadClaimBondData = function (web3, network, questionId, oracleAddress) {
359
+ return __awaiter(this, void 0, void 0, function () {
360
+ var contract, provider, _a, userBalance, bestAnswer, historyHash, isFinalized, tokenSymbol, tokenDecimals, token, _b, symbol, decimals, e_2, answersFilter, events, users, historyHashes, bonds, answers, alreadyClaimed, address, currentUserAnswers, votedForCorrectQuestion, hasBalance, firstHash;
361
+ return __generator(this, function (_c) {
362
+ switch (_c.label) {
363
+ case 0:
364
+ contract = new contracts_1.Contract(oracleAddress, OracleAbi, web3);
365
+ provider = provider_1["default"](network);
366
+ return [4 /*yield*/, utils_1.multicall(network, provider, OracleAbi, [
367
+ [oracleAddress, 'balanceOf', [web3.provider.selectedAddress]],
368
+ [oracleAddress, 'getBestAnswer', [questionId]],
369
+ [oracleAddress, 'getHistoryHash', [questionId]],
370
+ [oracleAddress, 'isFinalized', [questionId]]
371
+ ])];
372
+ case 1:
373
+ _a = _c.sent(), userBalance = _a[0][0], bestAnswer = _a[1][0], historyHash = _a[2][0], isFinalized = _a[3][0];
374
+ tokenSymbol = 'ETH';
375
+ tokenDecimals = 18;
376
+ _c.label = 2;
377
+ case 2:
378
+ _c.trys.push([2, 5, , 6]);
379
+ return [4 /*yield*/, utils_1.call(provider, OracleAbi, [
380
+ oracleAddress,
381
+ 'token',
382
+ []
383
+ ])];
384
+ case 3:
385
+ token = _c.sent();
386
+ return [4 /*yield*/, utils_1.multicall(network, provider, TokenAbi, [
387
+ [token, 'symbol', []],
388
+ [token, 'decimals', []]
389
+ ])];
390
+ case 4:
391
+ _b = _c.sent(), symbol = _b[0][0], decimals = _b[1][0];
392
+ tokenSymbol = symbol;
393
+ tokenDecimals = decimals;
394
+ return [3 /*break*/, 6];
395
+ case 5:
396
+ e_2 = _c.sent();
397
+ return [3 /*break*/, 6];
398
+ case 6:
399
+ answersFilter = contract.filters.LogNewAnswer(null, questionId);
400
+ return [4 /*yield*/, contract.queryFilter(answersFilter, START_BLOCKS[network])];
401
+ case 7:
402
+ events = _c.sent();
403
+ users = [];
404
+ historyHashes = [];
405
+ bonds = [];
406
+ answers = [];
407
+ // We need to send the information from last to first
408
+ events.reverse().forEach(function (_a) {
409
+ var args = _a.args;
410
+ users.push(args === null || args === void 0 ? void 0 : args.user.toLowerCase());
411
+ historyHashes.push(args === null || args === void 0 ? void 0 : args.history_hash);
412
+ bonds.push(args === null || args === void 0 ? void 0 : args.bond);
413
+ answers.push(args === null || args === void 0 ? void 0 : args.answer);
414
+ });
415
+ alreadyClaimed = bignumber_1.BigNumber.from(historyHash).eq(0);
416
+ address = web3.provider.selectedAddress.toLowerCase();
417
+ currentUserAnswers = users.map(function (user, i) {
418
+ if (user === address)
419
+ return answers[i];
420
+ });
421
+ votedForCorrectQuestion = currentUserAnswers.some(function (answer) {
422
+ if (answer) {
423
+ return bignumber_1.BigNumber.from(answer).eq(bestAnswer);
424
+ }
425
+ }) && isFinalized;
426
+ hasBalance = !userBalance.eq(0) && isFinalized;
427
+ // Remove the first history and add an empty one
428
+ // More info: https://github.com/realitio/realitio-contracts/blob/master/truffle/contracts/Realitio.sol#L502
429
+ historyHashes.shift();
430
+ firstHash = '0x0000000000000000000000000000000000000000000000000000000000000000';
431
+ historyHashes.push(firstHash);
432
+ return [2 /*return*/, {
433
+ tokenSymbol: tokenSymbol,
434
+ tokenDecimals: tokenDecimals,
435
+ canClaim: (!alreadyClaimed && votedForCorrectQuestion) || hasBalance,
436
+ data: {
437
+ length: [bonds.length.toString()],
438
+ historyHashes: historyHashes,
439
+ users: users,
440
+ bonds: bonds,
441
+ answers: answers
442
+ }
443
+ }];
444
+ }
445
+ });
446
+ });
447
+ };
448
+ Plugin.prototype.claimBond = function (web3, oracleAddress, questionId, claimParams) {
449
+ return __awaiter(this, void 0, void 0, function () {
450
+ var currentHistoryHash, tx_1, receipt_1, tx, receipt;
451
+ return __generator(this, function (_a) {
452
+ switch (_a.label) {
453
+ case 0: return [4 /*yield*/, utils_1.call(web3, OracleAbi, [
454
+ oracleAddress,
455
+ 'getHistoryHash',
456
+ [questionId]
457
+ ])];
458
+ case 1:
459
+ currentHistoryHash = _a.sent();
460
+ if (!bignumber_1.BigNumber.from(currentHistoryHash).eq(0)) return [3 /*break*/, 4];
461
+ return [4 /*yield*/, utils_1.sendTransaction(web3, oracleAddress, OracleAbi, 'withdraw', [])];
462
+ case 2:
463
+ tx_1 = _a.sent();
464
+ return [4 /*yield*/, tx_1.wait()];
465
+ case 3:
466
+ receipt_1 = _a.sent();
467
+ console.log('[Realitio] executed withdraw:', receipt_1);
468
+ return [2 /*return*/];
469
+ case 4: return [4 /*yield*/, utils_1.sendTransaction(web3, oracleAddress, OracleAbi, 'claimMultipleAndWithdrawBalance', __spreadArrays([[questionId]], claimParams))];
470
+ case 5:
471
+ tx = _a.sent();
472
+ return [4 /*yield*/, tx.wait()];
473
+ case 6:
474
+ receipt = _a.sent();
475
+ console.log('[Realitio] executed claimMultipleAndWithdrawBalance:', receipt);
476
+ return [2 /*return*/];
477
+ }
478
+ });
479
+ });
480
+ };
481
+ Plugin.prototype.executeProposal = function (web3, moduleAddress, proposalId, transactions, transactionIndex) {
482
+ return __awaiter(this, void 0, void 0, function () {
483
+ var txHashes, moduleTx, tx, receipt;
484
+ return __generator(this, function (_a) {
485
+ switch (_a.label) {
486
+ case 0: return [4 /*yield*/, this.calcTransactionHashes(web3.network.chainId, moduleAddress, transactions)];
487
+ case 1:
488
+ txHashes = _a.sent();
489
+ moduleTx = transactions[transactionIndex];
490
+ return [4 /*yield*/, utils_1.sendTransaction(web3, moduleAddress, ModuleAbi, 'executeProposalWithIndex', [
491
+ proposalId,
492
+ txHashes,
493
+ moduleTx.to,
494
+ moduleTx.value,
495
+ moduleTx.data || '0x',
496
+ moduleTx.operation,
497
+ transactionIndex
498
+ ])];
499
+ case 2:
500
+ tx = _a.sent();
501
+ return [4 /*yield*/, tx.wait()];
502
+ case 3:
503
+ receipt = _a.sent();
504
+ console.log('[DAO module] executed proposal:', receipt);
505
+ return [2 /*return*/];
506
+ }
507
+ });
508
+ });
509
+ };
510
+ Plugin.prototype.voteForQuestion = function (network, web3, oracleAddress, questionId, minimumBondInDaoModule, answer) {
511
+ return __awaiter(this, void 0, void 0, function () {
512
+ var currentBond, bond, methodName, txOverrides, parameters, currentBondIsZero, daoBondIsZero, token, _a, tokenDecimals, allowance, approveTx, e_3, tx, receipt;
513
+ return __generator(this, function (_b) {
514
+ switch (_b.label) {
515
+ case 0: return [4 /*yield*/, utils_1.call(web3, OracleAbi, [
516
+ oracleAddress,
517
+ 'getBond',
518
+ [questionId]
519
+ ])];
520
+ case 1:
521
+ currentBond = _b.sent();
522
+ txOverrides = {};
523
+ parameters = [
524
+ questionId,
525
+ "0x000000000000000000000000000000000000000000000000000000000000000" + answer
526
+ ];
527
+ currentBondIsZero = currentBond.eq(bignumber_1.BigNumber.from(0));
528
+ if (currentBondIsZero) {
529
+ daoBondIsZero = bignumber_1.BigNumber.from(minimumBondInDaoModule).eq(0);
530
+ bond = daoBondIsZero ? bignumber_1.BigNumber.from(10) : minimumBondInDaoModule;
531
+ }
532
+ else {
533
+ bond = currentBond.mul(2);
534
+ }
535
+ _b.label = 2;
536
+ case 2:
537
+ _b.trys.push([2, 8, , 9]);
538
+ return [4 /*yield*/, utils_1.call(web3, OracleAbi, [oracleAddress, 'token', []])];
539
+ case 3:
540
+ token = _b.sent();
541
+ return [4 /*yield*/, utils_1.multicall(network, web3, TokenAbi, [
542
+ [token, 'decimals', []],
543
+ [token, 'allowance', [web3.provider.selectedAddress, oracleAddress]]
544
+ ])];
545
+ case 4:
546
+ _a = _b.sent(), tokenDecimals = _a[0][0], allowance = _a[1][0];
547
+ if (bond.eq(10)) {
548
+ bond = bond.pow(tokenDecimals);
549
+ }
550
+ if (!allowance.lt(bond)) return [3 /*break*/, 7];
551
+ return [4 /*yield*/, utils_1.sendTransaction(web3, token, TokenAbi, 'approve', [oracleAddress, bond], {})];
552
+ case 5:
553
+ approveTx = _b.sent();
554
+ return [4 /*yield*/, approveTx.wait()];
555
+ case 6:
556
+ _b.sent();
557
+ _b.label = 7;
558
+ case 7:
559
+ parameters = __spreadArrays(parameters, [bond, bond]);
560
+ methodName = 'submitAnswerERC20';
561
+ return [3 /*break*/, 9];
562
+ case 8:
563
+ e_3 = _b.sent();
564
+ if (bond.eq(10)) {
565
+ bond = bond.pow(18);
566
+ }
567
+ parameters = __spreadArrays(parameters, [bond]);
568
+ txOverrides['value'] = bond.toString();
569
+ methodName = 'submitAnswer';
570
+ return [3 /*break*/, 9];
571
+ case 9: return [4 /*yield*/, utils_1.sendTransaction(web3, oracleAddress, OracleAbi, methodName, parameters, txOverrides)];
572
+ case 10:
573
+ tx = _b.sent();
574
+ return [4 /*yield*/, tx.wait()];
575
+ case 11:
576
+ receipt = _b.sent();
577
+ console.log('[DAO module] executed vote on oracle:', receipt);
578
+ return [2 /*return*/];
579
+ }
580
+ });
581
+ });
582
+ };
583
+ return Plugin;
584
+ }());
585
+ exports["default"] = Plugin;