@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.
- package/artifacts/contracts/apps/SuperfluidLoaderLibrary.sol/SuperfluidLoaderLibrary.json +2 -2
- package/build/contracts/AccessControl.json +1 -1
- package/build/contracts/AccessControlEnumerable.json +1 -1
- package/build/contracts/Address.json +1 -1
- package/build/contracts/AgreementBase.json +18 -18
- package/build/contracts/AgreementLibrary.json +165 -165
- package/build/contracts/BaseRelayRecipient.json +57 -57
- package/build/contracts/BatchLiquidator.json +382 -382
- package/build/contracts/BatchOperation.json +614 -614
- package/build/contracts/CFAv1Forwarder.json +1250 -1250
- package/build/contracts/CFAv1ForwarderDeployerLibrary.json +2384 -2384
- package/build/contracts/CFAv1Library.json +389 -389
- package/build/contracts/CallUtils.json +198 -198
- package/build/contracts/ClosingOnUpdateFlowTestApp.json +1525 -1525
- package/build/contracts/ConstantFlowAgreementV1.json +1087 -1087
- package/build/contracts/ConstantInflowNFT.json +402 -402
- package/build/contracts/ConstantOutflowNFT.json +661 -661
- package/build/contracts/Context.json +1 -1
- package/build/contracts/ContextDefinitions.json +614 -614
- package/build/contracts/CustomSuperTokenBase.json +19 -19
- package/build/contracts/ERC165.json +1 -1
- package/build/contracts/ERC1820Implementer.json +1 -1
- package/build/contracts/ERC1820RegistryCompiled.json +22 -22
- package/build/contracts/ERC20.json +1 -1
- package/build/contracts/ERC20WithTokenInfo.json +23 -23
- package/build/contracts/ERC777Helper.json +384 -384
- package/build/contracts/ERC777RecipientDrainingGas.json +863 -863
- package/build/contracts/ERC777RecipientReverting.json +863 -863
- package/build/contracts/EnumerableSet.json +1 -1
- package/build/contracts/EventsEmitter.json +43 -43
- package/build/contracts/ExclusiveInflowTestApp.json +1525 -1525
- package/build/contracts/FixedSizeData.json +200 -200
- package/build/contracts/FlowExchangeTestApp.json +1526 -1526
- package/build/contracts/FlowNFTBase.json +1280 -1280
- package/build/contracts/FlowOperatorDefinitions.json +614 -614
- package/build/contracts/ForwarderBase.json +190 -190
- package/build/contracts/FullUpgradableSuperTokenProxy.json +116 -116
- package/build/contracts/IAccessControl.json +1 -1
- package/build/contracts/IAccessControlEnumerable.json +1 -1
- package/build/contracts/IConstantFlowAgreementV1.json +677 -677
- package/build/contracts/IConstantInflowNFT.json +54 -54
- package/build/contracts/IConstantOutflowNFT.json +107 -107
- package/build/contracts/IDAv1Forwarder.json +912 -912
- package/build/contracts/IDAv1ForwarderDeployerLibrary.json +2384 -2384
- package/build/contracts/IDAv1Library.json +430 -430
- package/build/contracts/IERC165.json +1 -1
- package/build/contracts/IERC1820Implementer.json +1 -1
- package/build/contracts/IERC1820Registry.json +1 -1
- package/build/contracts/IERC20.json +1 -1
- package/build/contracts/IERC20Metadata.json +1 -1
- package/build/contracts/IERC20Permit.json +1 -1
- package/build/contracts/IERC721.json +1 -1
- package/build/contracts/IERC721Metadata.json +1 -1
- package/build/contracts/IERC777.json +1 -1
- package/build/contracts/IERC777Recipient.json +1 -1
- package/build/contracts/IERC777Sender.json +1 -1
- package/build/contracts/IFlowNFTBase.json +115 -115
- package/build/contracts/IInstantDistributionAgreementV1.json +667 -667
- package/build/contracts/IMultiSigWallet.json +31 -31
- package/build/contracts/IPoolAdminNFT.json +7 -7
- package/build/contracts/IPoolMemberNFT.json +7 -7
- package/build/contracts/IPureSuperToken.json +62 -62
- package/build/contracts/IPureSuperTokenCustom.json +62 -62
- package/build/contracts/IRelayRecipient.json +27 -27
- package/build/contracts/IResolver.json +38 -38
- package/build/contracts/ISETH.json +67 -67
- package/build/contracts/ISETHCustom.json +67 -67
- package/build/contracts/ISuperAgreement.json +50 -50
- package/build/contracts/ISuperApp.json +191 -191
- package/build/contracts/ISuperToken.json +695 -695
- package/build/contracts/ISuperTokenFactory.json +225 -225
- package/build/contracts/ISuperfluid.json +904 -904
- package/build/contracts/ISuperfluidGovernance.json +251 -251
- package/build/contracts/ISuperfluidToken.json +407 -407
- package/build/contracts/ITOGAv1.json +1346 -1346
- package/build/contracts/ITOGAv2.json +1346 -1346
- package/build/contracts/ITOGAv3.json +1346 -1346
- package/build/contracts/Initializable.json +1 -1
- package/build/contracts/InstantDistributionAgreementV1.json +594 -594
- package/build/contracts/Math.json +1 -1
- package/build/contracts/NonClosableOutflowTestApp.json +1526 -1526
- package/build/contracts/Ownable.json +1 -1
- package/build/contracts/Proxy.json +1 -1
- package/build/contracts/ProxyDeployerLibrary.json +2382 -2382
- package/build/contracts/PureSuperToken.json +106 -106
- package/build/contracts/Resolver.json +98 -98
- package/build/contracts/SETHProxy.json +224 -224
- package/build/contracts/SafeCast.json +1 -1
- package/build/contracts/SafeERC20.json +1 -1
- package/build/contracts/SafeGasLibrary.json +51 -51
- package/build/contracts/SafeMath.json +1 -1
- package/build/contracts/SelfDeletingFlowTestApp.json +1525 -1525
- package/build/contracts/SlotsBitmapLibrary.json +457 -457
- package/build/contracts/StreamRedirector.json +704 -704
- package/build/contracts/Strings.json +1 -1
- package/build/contracts/SuperAppBase.json +42 -42
- package/build/contracts/SuperAppBaseFlow.json +138 -138
- package/build/contracts/SuperAppDefinitions.json +614 -614
- package/build/contracts/SuperToken.json +2714 -2714
- package/build/contracts/SuperTokenDeployerLibrary.json +2383 -2383
- package/build/contracts/SuperTokenFactory.json +1347 -1347
- package/build/contracts/SuperTokenFactoryBase.json +1329 -1329
- package/build/contracts/SuperTokenV1Library.json +1483 -1483
- package/build/contracts/SuperUpgrader.json +439 -439
- package/build/contracts/Superfluid.json +5196 -5196
- package/build/contracts/SuperfluidCFAv1DeployerLibrary.json +2383 -2383
- package/build/contracts/SuperfluidFrameworkDeployer.json +1260 -1260
- package/build/contracts/SuperfluidFrameworkDeploymentSteps.json +2382 -2382
- package/build/contracts/SuperfluidGovDeployerLibrary.json +2383 -2383
- package/build/contracts/SuperfluidGovernanceBase.json +2449 -2449
- package/build/contracts/SuperfluidGovernanceConfigs.json +614 -614
- package/build/contracts/SuperfluidGovernanceII.json +155 -155
- package/build/contracts/SuperfluidGovernanceIIProxy.json +135 -135
- package/build/contracts/SuperfluidHostDeployerLibrary.json +2382 -2382
- package/build/contracts/SuperfluidIDAv1DeployerLibrary.json +2383 -2383
- package/build/contracts/SuperfluidLoader.json +207 -207
- package/build/contracts/SuperfluidLoaderDeployerLibrary.json +2384 -2384
- package/build/contracts/SuperfluidLoaderLibrary.json +485 -351
- package/build/contracts/SuperfluidNFTLogicDeployerLibrary.json +2387 -2387
- package/build/contracts/SuperfluidPeripheryDeployerLibrary.json +2385 -2385
- package/build/contracts/SuperfluidToken.json +1423 -1423
- package/build/contracts/TOGA.json +1360 -1360
- package/build/contracts/TestGovernance.json +250 -250
- package/build/contracts/TestResolver.json +47 -47
- package/build/contracts/TestToken.json +102 -102
- package/build/contracts/TokenDeployerLibrary.json +2384 -2384
- package/build/contracts/TokenInfo.json +32 -32
- package/build/contracts/UUPSProxiable.json +139 -139
- package/build/contracts/UUPSProxy.json +81 -81
- package/build/contracts/UUPSUtils.json +37 -37
- package/build/contracts-sizes.txt +15 -15
- package/build/typechain/factories/contracts/apps/SuperfluidLoaderLibrary__factory.d.ts +1 -1
- package/build/typechain/factories/contracts/apps/SuperfluidLoaderLibrary__factory.d.ts.map +1 -1
- package/build/typechain/factories/contracts/apps/SuperfluidLoaderLibrary__factory.js +1 -1
- package/build/typechain/factories/contracts/apps/SuperfluidLoaderLibrary__factory.js.map +1 -1
- package/contracts/apps/SuperfluidLoaderLibrary.sol +4 -1
- package/package.json +4 -5
- package/ops-scripts/.eslintrc.js +0 -15
- package/ops-scripts/artifacts/ERC1820Registry.json +0 -5
- package/ops-scripts/deploy-aux-contracts.js +0 -99
- package/ops-scripts/deploy-deterministically.js +0 -169
- package/ops-scripts/deploy-erc1820.js +0 -83
- package/ops-scripts/deploy-framework.js +0 -895
- package/ops-scripts/deploy-mfa.ts +0 -27
- package/ops-scripts/deploy-super-token.js +0 -206
- package/ops-scripts/deploy-test-environment.js +0 -98
- package/ops-scripts/deploy-test-token.js +0 -86
- package/ops-scripts/deploy-unlisted-pure-super-token.js +0 -69
- package/ops-scripts/deploy-unlisted-super-token.js +0 -68
- package/ops-scripts/gov-create-new-app-registration-key.js +0 -75
- package/ops-scripts/gov-create-new-factory-registration.js +0 -49
- package/ops-scripts/gov-set-3Ps-config.js +0 -67
- package/ops-scripts/gov-set-reward-address.js +0 -60
- package/ops-scripts/gov-set-token-min-deposit.js +0 -53
- package/ops-scripts/gov-set-trusted-forwarder.js +0 -80
- package/ops-scripts/gov-transfer-framework-ownership.js +0 -90
- package/ops-scripts/gov-upgrade-governance.js +0 -87
- package/ops-scripts/gov-upgrade-super-token-logic.js +0 -193
- package/ops-scripts/info-inspect-account.js +0 -118
- package/ops-scripts/info-list-apps.js +0 -55
- package/ops-scripts/info-print-contract-addresses.js +0 -136
- package/ops-scripts/info-scan-deployments.js +0 -63
- package/ops-scripts/info-show-protocol.js +0 -400
- package/ops-scripts/libs/common.js +0 -436
- package/ops-scripts/libs/getConfig.js +0 -289
- package/ops-scripts/libs/truffleScriptRunnerFactory.js +0 -97
- package/ops-scripts/resolver-list-super-token.js +0 -73
- package/ops-scripts/resolver-register-token.js +0 -72
- package/ops-scripts/resolver-reset-deployment.js +0 -54
- package/ops-scripts/resolver-set-key-value.js +0 -69
- package/ops-scripts/resolver-unlist-super-token.js +0 -61
- package/ops-scripts/tmp-trigger-token-transfer.js +0 -33
- 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
|
-
};
|