@superfluid-finance/ethereum-contracts 1.7.2-dev.09f3be3.0 → 1.7.2-dev.2cebc84.0

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 (173) hide show
  1. package/artifacts/contracts/apps/SuperfluidLoaderLibrary.sol/SuperfluidLoaderLibrary.json +2 -2
  2. package/build/contracts/AccessControl.json +1 -1
  3. package/build/contracts/AccessControlEnumerable.json +1 -1
  4. package/build/contracts/Address.json +1 -1
  5. package/build/contracts/AgreementBase.json +18 -18
  6. package/build/contracts/AgreementLibrary.json +165 -165
  7. package/build/contracts/BaseRelayRecipient.json +57 -57
  8. package/build/contracts/BatchLiquidator.json +382 -382
  9. package/build/contracts/BatchOperation.json +614 -614
  10. package/build/contracts/CFAv1Forwarder.json +1250 -1250
  11. package/build/contracts/CFAv1ForwarderDeployerLibrary.json +2384 -2384
  12. package/build/contracts/CFAv1Library.json +389 -389
  13. package/build/contracts/CallUtils.json +198 -198
  14. package/build/contracts/ClosingOnUpdateFlowTestApp.json +1525 -1525
  15. package/build/contracts/ConstantFlowAgreementV1.json +1087 -1087
  16. package/build/contracts/ConstantInflowNFT.json +402 -402
  17. package/build/contracts/ConstantOutflowNFT.json +661 -661
  18. package/build/contracts/Context.json +1 -1
  19. package/build/contracts/ContextDefinitions.json +614 -614
  20. package/build/contracts/CustomSuperTokenBase.json +19 -19
  21. package/build/contracts/ERC165.json +1 -1
  22. package/build/contracts/ERC1820Implementer.json +1 -1
  23. package/build/contracts/ERC1820RegistryCompiled.json +22 -22
  24. package/build/contracts/ERC20.json +1 -1
  25. package/build/contracts/ERC20WithTokenInfo.json +23 -23
  26. package/build/contracts/ERC777Helper.json +384 -384
  27. package/build/contracts/ERC777RecipientDrainingGas.json +863 -863
  28. package/build/contracts/ERC777RecipientReverting.json +863 -863
  29. package/build/contracts/EnumerableSet.json +1 -1
  30. package/build/contracts/EventsEmitter.json +43 -43
  31. package/build/contracts/ExclusiveInflowTestApp.json +1525 -1525
  32. package/build/contracts/FixedSizeData.json +200 -200
  33. package/build/contracts/FlowExchangeTestApp.json +1526 -1526
  34. package/build/contracts/FlowNFTBase.json +1280 -1280
  35. package/build/contracts/FlowOperatorDefinitions.json +614 -614
  36. package/build/contracts/ForwarderBase.json +190 -190
  37. package/build/contracts/FullUpgradableSuperTokenProxy.json +116 -116
  38. package/build/contracts/IAccessControl.json +1 -1
  39. package/build/contracts/IAccessControlEnumerable.json +1 -1
  40. package/build/contracts/IConstantFlowAgreementV1.json +677 -677
  41. package/build/contracts/IConstantInflowNFT.json +54 -54
  42. package/build/contracts/IConstantOutflowNFT.json +107 -107
  43. package/build/contracts/IDAv1Forwarder.json +912 -912
  44. package/build/contracts/IDAv1ForwarderDeployerLibrary.json +2384 -2384
  45. package/build/contracts/IDAv1Library.json +430 -430
  46. package/build/contracts/IERC165.json +1 -1
  47. package/build/contracts/IERC1820Implementer.json +1 -1
  48. package/build/contracts/IERC1820Registry.json +1 -1
  49. package/build/contracts/IERC20.json +1 -1
  50. package/build/contracts/IERC20Metadata.json +1 -1
  51. package/build/contracts/IERC20Permit.json +1 -1
  52. package/build/contracts/IERC721.json +1 -1
  53. package/build/contracts/IERC721Metadata.json +1 -1
  54. package/build/contracts/IERC777.json +1 -1
  55. package/build/contracts/IERC777Recipient.json +1 -1
  56. package/build/contracts/IERC777Sender.json +1 -1
  57. package/build/contracts/IFlowNFTBase.json +115 -115
  58. package/build/contracts/IInstantDistributionAgreementV1.json +667 -667
  59. package/build/contracts/IMultiSigWallet.json +31 -31
  60. package/build/contracts/IPoolAdminNFT.json +7 -7
  61. package/build/contracts/IPoolMemberNFT.json +7 -7
  62. package/build/contracts/IPureSuperToken.json +62 -62
  63. package/build/contracts/IPureSuperTokenCustom.json +62 -62
  64. package/build/contracts/IRelayRecipient.json +27 -27
  65. package/build/contracts/IResolver.json +38 -38
  66. package/build/contracts/ISETH.json +67 -67
  67. package/build/contracts/ISETHCustom.json +67 -67
  68. package/build/contracts/ISuperAgreement.json +50 -50
  69. package/build/contracts/ISuperApp.json +191 -191
  70. package/build/contracts/ISuperToken.json +695 -695
  71. package/build/contracts/ISuperTokenFactory.json +225 -225
  72. package/build/contracts/ISuperfluid.json +904 -904
  73. package/build/contracts/ISuperfluidGovernance.json +251 -251
  74. package/build/contracts/ISuperfluidToken.json +407 -407
  75. package/build/contracts/ITOGAv1.json +1346 -1346
  76. package/build/contracts/ITOGAv2.json +1346 -1346
  77. package/build/contracts/ITOGAv3.json +1346 -1346
  78. package/build/contracts/Initializable.json +1 -1
  79. package/build/contracts/InstantDistributionAgreementV1.json +594 -594
  80. package/build/contracts/Math.json +1 -1
  81. package/build/contracts/NonClosableOutflowTestApp.json +1526 -1526
  82. package/build/contracts/Ownable.json +1 -1
  83. package/build/contracts/Proxy.json +1 -1
  84. package/build/contracts/ProxyDeployerLibrary.json +2382 -2382
  85. package/build/contracts/PureSuperToken.json +106 -106
  86. package/build/contracts/Resolver.json +98 -98
  87. package/build/contracts/SETHProxy.json +224 -224
  88. package/build/contracts/SafeCast.json +1 -1
  89. package/build/contracts/SafeERC20.json +1 -1
  90. package/build/contracts/SafeGasLibrary.json +51 -51
  91. package/build/contracts/SafeMath.json +1 -1
  92. package/build/contracts/SelfDeletingFlowTestApp.json +1525 -1525
  93. package/build/contracts/SlotsBitmapLibrary.json +457 -457
  94. package/build/contracts/StreamRedirector.json +704 -704
  95. package/build/contracts/Strings.json +1 -1
  96. package/build/contracts/SuperAppBase.json +42 -42
  97. package/build/contracts/SuperAppBaseFlow.json +138 -138
  98. package/build/contracts/SuperAppDefinitions.json +614 -614
  99. package/build/contracts/SuperToken.json +2714 -2714
  100. package/build/contracts/SuperTokenDeployerLibrary.json +2383 -2383
  101. package/build/contracts/SuperTokenFactory.json +1347 -1347
  102. package/build/contracts/SuperTokenFactoryBase.json +1329 -1329
  103. package/build/contracts/SuperTokenV1Library.json +1483 -1483
  104. package/build/contracts/SuperUpgrader.json +439 -439
  105. package/build/contracts/Superfluid.json +5196 -5196
  106. package/build/contracts/SuperfluidCFAv1DeployerLibrary.json +2383 -2383
  107. package/build/contracts/SuperfluidFrameworkDeployer.json +1260 -1260
  108. package/build/contracts/SuperfluidFrameworkDeploymentSteps.json +2382 -2382
  109. package/build/contracts/SuperfluidGovDeployerLibrary.json +2383 -2383
  110. package/build/contracts/SuperfluidGovernanceBase.json +2449 -2449
  111. package/build/contracts/SuperfluidGovernanceConfigs.json +614 -614
  112. package/build/contracts/SuperfluidGovernanceII.json +155 -155
  113. package/build/contracts/SuperfluidGovernanceIIProxy.json +135 -135
  114. package/build/contracts/SuperfluidHostDeployerLibrary.json +2382 -2382
  115. package/build/contracts/SuperfluidIDAv1DeployerLibrary.json +2383 -2383
  116. package/build/contracts/SuperfluidLoader.json +207 -207
  117. package/build/contracts/SuperfluidLoaderDeployerLibrary.json +2384 -2384
  118. package/build/contracts/SuperfluidLoaderLibrary.json +485 -351
  119. package/build/contracts/SuperfluidNFTLogicDeployerLibrary.json +2387 -2387
  120. package/build/contracts/SuperfluidPeripheryDeployerLibrary.json +2385 -2385
  121. package/build/contracts/SuperfluidToken.json +1423 -1423
  122. package/build/contracts/TOGA.json +1360 -1360
  123. package/build/contracts/TestGovernance.json +250 -250
  124. package/build/contracts/TestResolver.json +47 -47
  125. package/build/contracts/TestToken.json +102 -102
  126. package/build/contracts/TokenDeployerLibrary.json +2384 -2384
  127. package/build/contracts/TokenInfo.json +32 -32
  128. package/build/contracts/UUPSProxiable.json +139 -139
  129. package/build/contracts/UUPSProxy.json +81 -81
  130. package/build/contracts/UUPSUtils.json +37 -37
  131. package/build/contracts-sizes.txt +15 -15
  132. package/build/typechain/factories/contracts/apps/SuperfluidLoaderLibrary__factory.d.ts +1 -1
  133. package/build/typechain/factories/contracts/apps/SuperfluidLoaderLibrary__factory.d.ts.map +1 -1
  134. package/build/typechain/factories/contracts/apps/SuperfluidLoaderLibrary__factory.js +1 -1
  135. package/build/typechain/factories/contracts/apps/SuperfluidLoaderLibrary__factory.js.map +1 -1
  136. package/contracts/apps/SuperfluidLoaderLibrary.sol +4 -1
  137. package/package.json +4 -5
  138. package/ops-scripts/.eslintrc.js +0 -15
  139. package/ops-scripts/artifacts/ERC1820Registry.json +0 -5
  140. package/ops-scripts/deploy-aux-contracts.js +0 -99
  141. package/ops-scripts/deploy-deterministically.js +0 -169
  142. package/ops-scripts/deploy-erc1820.js +0 -83
  143. package/ops-scripts/deploy-framework.js +0 -895
  144. package/ops-scripts/deploy-mfa.ts +0 -27
  145. package/ops-scripts/deploy-super-token.js +0 -206
  146. package/ops-scripts/deploy-test-environment.js +0 -98
  147. package/ops-scripts/deploy-test-token.js +0 -86
  148. package/ops-scripts/deploy-unlisted-pure-super-token.js +0 -69
  149. package/ops-scripts/deploy-unlisted-super-token.js +0 -68
  150. package/ops-scripts/gov-create-new-app-registration-key.js +0 -75
  151. package/ops-scripts/gov-create-new-factory-registration.js +0 -49
  152. package/ops-scripts/gov-set-3Ps-config.js +0 -67
  153. package/ops-scripts/gov-set-reward-address.js +0 -60
  154. package/ops-scripts/gov-set-token-min-deposit.js +0 -53
  155. package/ops-scripts/gov-set-trusted-forwarder.js +0 -80
  156. package/ops-scripts/gov-transfer-framework-ownership.js +0 -90
  157. package/ops-scripts/gov-upgrade-governance.js +0 -87
  158. package/ops-scripts/gov-upgrade-super-token-logic.js +0 -193
  159. package/ops-scripts/info-inspect-account.js +0 -118
  160. package/ops-scripts/info-list-apps.js +0 -55
  161. package/ops-scripts/info-print-contract-addresses.js +0 -136
  162. package/ops-scripts/info-scan-deployments.js +0 -63
  163. package/ops-scripts/info-show-protocol.js +0 -400
  164. package/ops-scripts/libs/common.js +0 -436
  165. package/ops-scripts/libs/getConfig.js +0 -289
  166. package/ops-scripts/libs/truffleScriptRunnerFactory.js +0 -97
  167. package/ops-scripts/resolver-list-super-token.js +0 -73
  168. package/ops-scripts/resolver-register-token.js +0 -72
  169. package/ops-scripts/resolver-reset-deployment.js +0 -54
  170. package/ops-scripts/resolver-set-key-value.js +0 -69
  171. package/ops-scripts/resolver-unlist-super-token.js +0 -61
  172. package/ops-scripts/tmp-trigger-token-transfer.js +0 -33
  173. package/ops-scripts/validate-nft-addresses.ts +0 -49
@@ -1,436 +0,0 @@
1
- const path = require("path");
2
- const async = require("async");
3
- const {promisify} = require("util");
4
- const readline = require("readline");
5
-
6
- const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
7
-
8
- /****************************************************************
9
- * Truffle scripts utilities
10
- ****************************************************************/
11
- /**
12
- * @dev Promisified readline question utility
13
- */
14
- async function rl() {
15
- // promisify the readline
16
- const rl = readline.createInterface({
17
- input: process.stdin,
18
- output: process.stdout,
19
- });
20
- // Prepare readline.question for promisification
21
- rl.question[promisify.custom] = (question) => {
22
- return new Promise((resolve) => {
23
- rl.question(question, resolve);
24
- });
25
- };
26
-
27
- const answer = await promisify(rl.question).apply(null, arguments);
28
-
29
- rl.close();
30
-
31
- return answer;
32
- }
33
-
34
- /// @dev Extract the web3 options used to initialize the SDK
35
- function extractWeb3Options({isTruffle, web3, ethers, from}) {
36
- return {isTruffle, web3, ethers, from};
37
- }
38
-
39
- /// @dev Load contract from truffle built artifacts
40
- function builtTruffleContractLoader(name) {
41
- try {
42
- const directoryPath = path.join(__dirname, "../../build/contracts");
43
- const builtContract = require(path.join(directoryPath, name + ".json"));
44
- return builtContract;
45
- } catch (e) {
46
- throw new Error(
47
- `Cannot load built truffle contract ${name}. Have you built?`
48
- );
49
- }
50
- }
51
-
52
- //
53
- // Detect truffle environment
54
- //
55
- function detectTruffle() {
56
- const stackTrace = require("stack-trace");
57
- const trace = stackTrace.get();
58
- //trace.forEach((callSite) => console.debug(callSite.getFileName()));
59
- const truffleDetected =
60
- trace.filter((callSite) =>
61
- (callSite.getFileName() || "").match(
62
- /node_modules\/truffle\/build\/[^/]+\.bundled\.js/
63
- )
64
- ).length > 0;
65
- console.log("truffle detected", truffleDetected);
66
- return truffleDetected;
67
- }
68
-
69
- /****************************************************************
70
- * Contracts upgradability utilities
71
- ****************************************************************/
72
-
73
- /**
74
- * @dev Is the address a contract (it has code, not an EOA)
75
- */
76
- async function hasCode(web3, address) {
77
- const code = await web3.eth.getCode(address);
78
- return code.length > 3;
79
- }
80
-
81
- /**
82
- * @dev Check if the code at the address differs from the contract object provided
83
- * TODO: this isn't always working as intended, see https://github.com/superfluid-finance/protocol-monorepo/issues/1448
84
- */
85
- async function codeChanged(
86
- web3,
87
- contract,
88
- address,
89
- replacements = [],
90
- debug = false
91
- ) {
92
- // use .binary instead of .bytecode
93
- // since .binary will have the linked library addresses
94
- const binaryFromCompiler = contract.binary;
95
- const code = await web3.eth.getCode(address);
96
-
97
- // no code
98
- if (code.length <= 3) return true;
99
-
100
- // SEE: https://github.com/ConsenSys/bytecode-verifier/blob/master/src/verifier.js
101
- // find the second occurance of the init code
102
- let codeTrimed = code.slice(code.lastIndexOf("6080604052")).toLowerCase();
103
- const binaryTrimed = binaryFromCompiler
104
- .slice(binaryFromCompiler.lastIndexOf("6080604052"))
105
- .toLowerCase();
106
-
107
- // extra replacements usually for constructor parameters
108
- replacements.forEach((r) => {
109
- codeTrimed = codeTrimed.replace(
110
- new RegExp(r, "g"),
111
- "0".repeat(r.length)
112
- );
113
- });
114
-
115
- if (debug) {
116
- console.debug(codeTrimed);
117
- console.debug(binaryTrimed);
118
- }
119
- // console.log(code);
120
- // console.log(bytecodeFromCompiler);
121
- // console.log(bytecodeFromCompiler.indexOf(code.slice(2)));
122
- return binaryTrimed !== codeTrimed;
123
- }
124
-
125
- /**
126
- * @dev Check if the address is a UUPS proxiable
127
- */
128
- async function isProxiable(UUPSProxiable, address) {
129
- const p = await UUPSProxiable.at(address);
130
- const codeAddress = await p.getCodeAddress.call();
131
- return codeAddress !== ZERO_ADDRESS;
132
- }
133
-
134
- /**
135
- * @dev Get code address from an UUPS proxiable
136
- */
137
- async function getCodeAddress(UUPSProxiable, proxyAddress) {
138
- const proxiable = await UUPSProxiable.at(proxyAddress);
139
- return await proxiable.getCodeAddress();
140
- }
141
-
142
- /****************************************************************
143
- * Admin (resolver and governance) utilities
144
- ****************************************************************/
145
-
146
- /**
147
- * @dev Set resolver key-value
148
- *
149
- * process.env.RESOLVER_ADMIN_TYPE:
150
- * - MULTISIG
151
- * - (default) ownable
152
- */
153
- async function setResolver(sf, key, value) {
154
- console.log(`Setting resolver ${key} -> ${value} ...`);
155
- const resolver = await sf.contracts.Resolver.at(sf.resolver.address);
156
- switch (process.env.RESOLVER_ADMIN_TYPE) {
157
- case "MULTISIG": {
158
- console.log("Resolver Admin type: MultiSig");
159
- const ADMIN_ROLE = "0x" + "0".repeat(64);
160
- const ac = await sf.contracts.IAccessControlEnumerable.at(
161
- sf.resolver.address
162
- );
163
- const rmCnt = (await ac.getRoleMemberCount(ADMIN_ROLE)).toNumber();
164
- // always picks the last admin set (could be more than one)
165
- const resolverAdmin = await ac.getRoleMember(ADMIN_ROLE, rmCnt - 1);
166
- const multis = await sf.contracts.IMultiSigWallet.at(resolverAdmin);
167
- console.log("MultiSig address: ", multis.address);
168
- const data = resolver.contract.methods.set(key, value).encodeABI();
169
- console.log("MultiSig data", data);
170
- console.log("Sending admin action to multisig...");
171
- await multis.submitTransaction(resolver.address, 0, data);
172
- console.log(
173
- "Admin action sent, but it may still need confirmation(s)."
174
- );
175
- break;
176
- }
177
- default: {
178
- console.log("Resolver Admin type: Direct Ownership (default)");
179
- console.log("Executing admin action...");
180
- await resolver.set(key, value);
181
- console.log("Admin action executed.");
182
- }
183
- }
184
- }
185
-
186
- /**
187
- * @dev Send governance action
188
- *
189
- * process.env.GOVERNANCE_ADMIN_TYPE:
190
- * - MULTISIG
191
- * - OWNABLE
192
- * - SAFE
193
- * - (default) auto-detect (doesn't yet detect Safe)
194
- */
195
- async function sendGovernanceAction(sf, actionFn) {
196
- const gov = await sf.contracts.SuperfluidGovernanceBase.at(
197
- await sf.host.getGovernance.call()
198
- );
199
- console.log("Governance address:", gov.address);
200
- const govOwner = await (await sf.contracts.Ownable.at(gov.address)).owner();
201
- console.log("Governance owner:", govOwner);
202
-
203
- const adminType = process.env.GOVERNANCE_ADMIN_TYPE
204
- || await autodetectGovAdminType(sf, govOwner);
205
-
206
- switch (adminType) {
207
- case "MULTISIG": {
208
- console.log("Governance Admin Type: MultiSig");
209
- const multis = await sf.contracts.IMultiSigWallet.at(
210
- await (await sf.contracts.Ownable.at(gov.address)).owner()
211
- );
212
- console.log("MultiSig address:", multis.address);
213
- const data = actionFn(gov.contract.methods).encodeABI();
214
- console.log("MultiSig data", data);
215
- console.log("Sending governance action to multisig...");
216
- await multis.submitTransaction(gov.address, 0, data);
217
- console.log(
218
- "Governance action sent, but it may still need confirmation(s)."
219
- );
220
- break;
221
- }
222
- case "OWNABLE": {
223
- console.log("Governance Admin Type: Direct Ownership (default)");
224
- console.log("Executing governance action...");
225
- await actionFn(gov);
226
- console.log("Governance action executed.");
227
- break;
228
- }
229
- case "SAFE": {
230
- const Web3Adapter = require('@safe-global/safe-web3-lib').default;
231
- const Safe = require('@safe-global/safe-core-sdk').default;
232
- const SafeServiceClient = require('@safe-global/safe-service-client').default;
233
-
234
- const safeOwner = (await web3.eth.getAccounts())[0]; // tx sender
235
- console.log("Address used as Safe owner (1st signer):", safeOwner);
236
- const safeAddress = govOwner;
237
-
238
- const ethAdapterOwner1 = new Web3Adapter({
239
- web3,
240
- signerAddress: safeOwner
241
- });
242
-
243
- const safeSdk = await Safe.create({ ethAdapter: ethAdapterOwner1, safeAddress });
244
- const safeService = new SafeServiceClient({
245
- txServiceUrl: getSafeTxServiceUrl(await web3.eth.getChainId()),
246
- ethAdapter: ethAdapterOwner1
247
- });
248
-
249
- const data = actionFn(gov.contract.methods).encodeABI();
250
- const nextNonce = await safeService.getNextNonce(safeAddress);
251
- const safeTransactionData = {
252
- to: gov.address,
253
- value: 0,
254
- data: data,
255
- nonce: process.env.SAFE_REPLACE_LAST_TX ? nextNonce-1 : nextNonce
256
- };
257
- const safeTransaction = await safeSdk.createTransaction({ safeTransactionData });
258
- console.log("Safe tx:", safeTransaction);
259
-
260
- const safeTxHash = await safeSdk.getTransactionHash(safeTransaction);
261
- console.log("Safe tx hash:", safeTxHash);
262
- const signature = await safeSdk.signTransactionHash(safeTxHash);
263
- console.log("Signature:", signature);
264
-
265
- const transactionConfig = {
266
- safeAddress,
267
- safeTxHash,
268
- safeTransactionData: safeTransaction.data,
269
- senderAddress: safeOwner,
270
- senderSignature: signature.data,
271
- origin: "ops-scripts"
272
- };
273
-
274
- const pendingTxsBefore = await safeService.getPendingTransactions(safeAddress);
275
-
276
- // according to the docs this should return the tx hash, but always returns undefined although succeeding
277
- const ret = await safeService.proposeTransaction(transactionConfig);
278
- console.log("returned:", ret);
279
-
280
- const pendingTxsAfter = await safeService.getPendingTransactions(safeAddress);
281
- console.log(`pending txs before ${pendingTxsBefore.count}, after ${pendingTxsAfter.count}`);
282
-
283
- // workaround for verifying that the proposal was added
284
- if (!pendingTxsAfter.count > pendingTxsBefore.count) {
285
- throw new Error("Safe pending transactions count didn't increase, propose may have failed!");
286
- }
287
- break;
288
- }
289
- default: {
290
- throw new Error("No known admin type specified and autodetect failed");
291
- }
292
- }
293
- }
294
-
295
- // Probes the given account to see what kind of admin it is.
296
- // Possible return values: "MULTISIG", "OWNABLE".
297
- // Throws when encountering an unknown contract.
298
- // TODO: add support for detecting SAFE
299
- async function autodetectGovAdminType(sf, account) {
300
- if (!await hasCode(web3, account)) {
301
- console.log("account has no code");
302
- return "OWNABLE";
303
- }
304
- const multis = await sf.contracts.IMultiSigWallet.at(account);
305
- // this will throw if not exists
306
- const moc = await multis.required();
307
- return "MULTISIG";
308
- }
309
-
310
- // returns the Safe Tx Service URL or throws if none available
311
- // source: https://github.com/safe-global/safe-docs/blob/main/learn/safe-core/safe-core-api/available-services.md
312
- function getSafeTxServiceUrl(chainId) {
313
- const safeChainNames = {
314
- // mainnets
315
- 1: "mainnet",
316
- 10: "optimism",
317
- 56: "bsc",
318
- 100: "gnosis-chain",
319
- 137: "polygon",
320
- 42161: "arbitrum",
321
- 43114: "avalanche",
322
- // testnets
323
- 5: "goerli",
324
- 84531: "base-testnet"
325
- };
326
- if (safeChainNames[chainId] === undefined) {
327
- throw new Error(`no Safe tx service url known for chainId ${chainId}`);
328
- }
329
- return `https://safe-transaction-${safeChainNames[chainId]}.safe.global`;
330
- }
331
-
332
- /****************************************************************
333
- * Event queries
334
- ****************************************************************/
335
-
336
- function _toHex(n) {
337
- return "0x" + n.toString(16);
338
- }
339
-
340
- async function getPastEvents({config, contract, eventName, filter, topics}) {
341
- const initialBlockNumber = config.data.initialBlockNumber || 0;
342
- const latestBlock = await web3.eth.getBlock("latest");
343
- let blockRanges = [];
344
- if (!config.data.getLogsRange) {
345
- blockRanges.push([
346
- _toHex(initialBlockNumber),
347
- _toHex(latestBlock.number),
348
- ]);
349
- } else {
350
- let i = initialBlockNumber;
351
- do {
352
- blockRanges.push([_toHex(i), _toHex(i + config.data.getLogsRange)]);
353
- } while ((i += config.data.getLogsRange) <= latestBlock.number);
354
- console.debug(
355
- "blockRanges",
356
- blockRanges.length,
357
- initialBlockNumber,
358
- latestBlock.number
359
- );
360
- }
361
- const result = await async.concatSeries(blockRanges, async (r) => {
362
- if (blockRanges.length > 1) process.stdout.write(".");
363
- let ret;
364
- if (contract) {
365
- ret = contract.getPastEvents(eventName, {
366
- fromBlock: r[0],
367
- toBlock: r[1],
368
- filter,
369
- });
370
- } else {
371
- ret = web3.eth.getPastLogs({
372
- fromBlock: r[0],
373
- toBlock: r[1],
374
- topics,
375
- });
376
- }
377
- if (blockRanges.length > 1 && ret.length > 0)
378
- process.stdout.write(ret.length.toString());
379
- return ret;
380
- });
381
- if (blockRanges.length > 1) process.stdout.write("\n");
382
- return result;
383
- }
384
-
385
- /****************************************************************
386
- * Script Runner helpers
387
- ****************************************************************/
388
-
389
- /**
390
- * @dev Get script runner factory
391
- *
392
- * NOTE:
393
- * Due tue truffle only injecting web3, artifacts, etc. in node execution context,
394
- * it is required that the script can access this context within the same
395
- * script file. Hence you would need to do something like this:
396
- * ```
397
- * eval(`(${getScriptRunnerFactory.toString()})()`)
398
- * ```
399
- * Crazy stuff.
400
- */
401
- function getScriptRunnerFactory(runnerOpts = {}) {
402
- return (logicFn) => {
403
- const {detectTruffle} = require("./libs/common");
404
- return require("./libs/truffleScriptRunnerFactory")(
405
- () => ({
406
- artifacts:
407
- typeof artifacts !== "undefined" ? artifacts : undefined,
408
- web3: typeof web3 !== "undefined" ? web3 : undefined,
409
- truffleDetected: detectTruffle(),
410
- }),
411
- logicFn,
412
- runnerOpts
413
- );
414
- };
415
- }
416
-
417
- module.exports = {
418
- ZERO_ADDRESS,
419
-
420
- rl,
421
- extractWeb3Options,
422
- builtTruffleContractLoader,
423
- detectTruffle,
424
-
425
- hasCode,
426
- codeChanged,
427
- getCodeAddress,
428
- isProxiable,
429
-
430
- setResolver,
431
- sendGovernanceAction,
432
-
433
- getPastEvents,
434
-
435
- getScriptRunnerFactory,
436
- };