diff --git a/packages/ethereum-contracts/ops-scripts/deploy-framework.js b/packages/ethereum-contracts/ops-scripts/deploy-framework.js index e29715ffea..305a6f424d 100644 --- a/packages/ethereum-contracts/ops-scripts/deploy-framework.js +++ b/packages/ethereum-contracts/ops-scripts/deploy-framework.js @@ -835,16 +835,15 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function ( agreementsToUpdate.push(idaNewLogicAddress); } // deploy new GDA logic - const gdaAddr = await (await UUPSProxiable.at( - await superfluid.getAgreementClass.call(GDAv1_TYPE) - )).getCodeAddress(); + const gdaProxyAddr = await superfluid.getAgreementClass.call(GDAv1_TYPE); + const gdaLogicAddr = await (await UUPSProxiable.at(gdaProxyAddr)).getCodeAddress(); const superfluidPoolBeaconAddr = await ( - await GeneralDistributionAgreementV1.at(gdaAddr) + await GeneralDistributionAgreementV1.at(gdaProxyAddr) ).superfluidPoolBeacon.call(); const gdaNewLogicAddress = await deployContractIfCodeChanged( web3, GeneralDistributionAgreementV1, - gdaAddr, + gdaLogicAddr, async () => (await deployGDAv1(superfluidPoolBeaconAddr)).address, [ superfluidConstructorParam, @@ -1095,13 +1094,13 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function ( const constantOutflowNFTLogic = await deployNFTContract( ConstantOutflowNFT, "ConstantOutflowNFT", - "CONSTANT_OUTFLOW_NFT", + "CONSTANT_OUTFLOW_NFT_LOGIC", [superfluid.address, cfaAddr, gdaAddr, constantInflowNFTProxy.address] ); const constantInflowNFTLogic = await deployNFTContract( ConstantInflowNFT, "ConstantInflowNFT", - "CONSTANT_INFLOW_NFT", + "CONSTANT_INFLOW_NFT_LOGIC", [superfluid.address, cfaAddr, gdaAddr, constantOutflowNFTProxy.address] ); @@ -1149,7 +1148,7 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function ( const cofNFTLogic = await deployNFTContract( ConstantOutflowNFT, "ConstantOutflowNFT", - "CONSTANT_OUTFLOW_NFT", + "CONSTANT_OUTFLOW_NFT_LOGIC", [superfluid.address, cfaAddr, gdaAddr, cifNFTProxyAddress] ); // @note we set the cofNFTLogicAddress to be passed to SuperTokenFactoryLogic here @@ -1168,7 +1167,7 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function ( const cifNFTLogic = await deployNFTContract( ConstantInflowNFT, "ConstantInflowNFT", - "CONSTANT_INFLOW_NFT", + "CONSTANT_INFLOW_NFT_LOGIC", [superfluid.address, cfaAddr, gdaAddr, cofNFTProxyAddress] ); // @note we set the cifNFTLogicAddress to be passed to SuperTokenFactoryLogic here @@ -1207,13 +1206,13 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function ( const poolAdminNFTLogic = await deployNFTContract( PoolAdminNFT, "PoolAdminNFT", - "POOL_ADMIN_NFT", + "POOL_ADMIN_NFT_LOGIC", [superfluid.address, gdaAddr] ); const poolMemberNFTLogic = await deployNFTContract( PoolMemberNFT, "PoolMemberNFT", - "POOL_MEMBER_NFT", + "POOL_MEMBER_NFT_LOGIC", [superfluid.address, gdaAddr] ); @@ -1258,7 +1257,7 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function ( const poolAdminNFTLogic = await deployNFTContract( PoolAdminNFT, "PoolAdminNFT", - "POOL_ADMIN_NFT", + "POOL_ADMIN_NFT_LOGIC", [superfluid.address, gdaAddr] ); // @note we set the poolAdminNFTLogicAddress to be passed to SuperTokenFactoryLogic here @@ -1276,7 +1275,7 @@ module.exports = eval(`(${S.toString()})({skipArgv: true})`)(async function ( const poolMemberNFTLogic = await deployNFTContract( PoolMemberNFT, "PoolMemberNFT", - "POOL_MEMBER_NFT", + "POOL_MEMBER_NFT_LOGIC", [superfluid.address, gdaAddr] ); // @note we set the poolMemberNFTLogicAddress to be passed to SuperTokenFactoryLogic here diff --git a/packages/ethereum-contracts/ops-scripts/gov-upgrade-super-token-logic.js b/packages/ethereum-contracts/ops-scripts/gov-upgrade-super-token-logic.js index d1c4e40764..2393da2e01 100644 --- a/packages/ethereum-contracts/ops-scripts/gov-upgrade-super-token-logic.js +++ b/packages/ethereum-contracts/ops-scripts/gov-upgrade-super-token-logic.js @@ -73,6 +73,7 @@ module.exports = eval(`(${S.toString()})()`)(async function ( additionalContracts: [ "Ownable", "IMultiSigWallet", + "ISafe", "SuperfluidGovernanceBase", "Resolver", "UUPSProxiable", @@ -85,17 +86,18 @@ module.exports = eval(`(${S.toString()})()`)(async function ( const canonicalSuperTokenLogic = await getCanonicalSuperTokenLogic(sf); console.log(`current canonical super token logic: ${canonicalSuperTokenLogic}`); + const newSuperTokenLogic = superTokenLogic !== undefined ? + superTokenLogic : + canonicalSuperTokenLogic; + + console.log("SuperToken logic to update to:", newSuperTokenLogic); + let tokensToBeUpgraded = (args.length === 1 && args[0] === "ALL") ? - await getTokensToBeUpgraded(sf, canonicalSuperTokenLogic, skipTokens) : + await getTokensToBeUpgraded(sf, newSuperTokenLogic, skipTokens) : Array.from(args); console.log(`${tokensToBeUpgraded.length} tokens to be upgraded`); - const superTokenLogicAddr = superTokenLogic !== undefined ? - superTokenLogic : - canonicalSuperTokenLogic; - - console.log("SuperToken logic to update to:", superTokenLogicAddr); if (tokensToBeUpgraded.length > 0) { console.log(`${tokensToBeUpgraded.length} tokens to be upgraded`); @@ -117,7 +119,7 @@ module.exports = eval(`(${S.toString()})()`)(async function ( if (!dryRun) { // a non-canonical logic address can be provided in an extra array (batchUpdateSuperTokenLogic is overloaded) const govAction = superTokenLogic !== undefined ? - (gov) => gov.batchUpdateSuperTokenLogic(sf.host.address, batch, [...new Array(batch.length)].map(e => superTokenLogicAddr)) : + (gov) => gov.batchUpdateSuperTokenLogic(sf.host.address, batch, [...new Array(batch.length)].map(e => newSuperTokenLogic)) : (gov) => gov.batchUpdateSuperTokenLogic(sf.host.address, batch) await sendGovernanceAction(sf, govAction); @@ -159,7 +161,7 @@ async function getCanonicalSuperTokenLogic(sf) { // - not being a proxy or not having a logic address // - already pointing to the latest logic // - in the skip list (e.g. because not managed by SF gov) -async function getTokensToBeUpgraded(sf, canonicalSuperTokenLogic, skipList) { +async function getTokensToBeUpgraded(sf, newSuperTokenLogic, skipList) { const maxItems = parseInt(process.env.MAX_ITEMS) || 1000; const skipItems = parseInt(process.env.SKIP_ITEMS) || 0; @@ -211,7 +213,7 @@ async function getTokensToBeUpgraded(sf, canonicalSuperTokenLogic, skipList) { console.log( `[SKIP] SuperToken@${superToken.address} (${symbol}) is likely an uninitalized proxy` ); - } else if (canonicalSuperTokenLogic !== superTokenLogic) { + } else if (newSuperTokenLogic !== superTokenLogic) { if (!pastSuperTokenLogics.map(e => e.toLowerCase()).includes(superTokenLogic.toLowerCase())) { // if the previous logic isn't in our list of past canonical supertoken logics, we skip it // it likely means we don't have upgradability ownership @@ -219,10 +221,21 @@ async function getTokensToBeUpgraded(sf, canonicalSuperTokenLogic, skipList) { `!!! [SKIP] SuperToken@${superToken.address} (${symbol}) alien previous logic ${superTokenLogic} - please manually check!` ); } else { - console.log( - `SuperToken@${superToken.address} (${symbol}) logic needs upgrade from ${superTokenLogic}` - ); - return superTokenAddress; + try { + const adminAddr = await superToken.getAdmin(); + if (adminAddr !== ZERO_ADDRESS) { + console.warn( + `!!! [SKIP] SuperToken@${superToken.address} admin override set to ${adminAddr}` + ); + } else { + console.log( + `SuperToken@${superToken.address} (${symbol}) logic needs upgrade from ${superTokenLogic}` + ); + return superTokenAddress; + } + } catch(err) { + console.log("### failed to get admin addr:", err.message); + } } } else { console.log( @@ -234,19 +247,7 @@ async function getTokensToBeUpgraded(sf, canonicalSuperTokenLogic, skipList) { `??? [SKIP] SuperToken@${superToken.address} failed to be queried, probably not UUPSProxiable` ); } - - try { - const adminAddr = await superToken.getAdmin(); - if (adminAddr !== ZERO_ADDRESS) { - console.warn( - `!!! [SKIP] SuperToken@${superToken.address} admin override set to ${adminAddr}` - ); - } - } catch(err) { - // TODO: enable logging once we expect this to exist - //console.log("### failed to get admin addr:", err.message); - } } )).filter((i) => typeof i !== "undefined") .filter((item) => !skipList.map(e => e.toLowerCase()).includes(item.toLowerCase())); -} \ No newline at end of file +} diff --git a/packages/js-sdk/src/Framework.js b/packages/js-sdk/src/Framework.js index 1d183dd592..772c902f7d 100644 --- a/packages/js-sdk/src/Framework.js +++ b/packages/js-sdk/src/Framework.js @@ -95,7 +95,7 @@ module.exports = class Framework { contractLoader: this._options.contractLoader, networkId: this.networkId, // copy of ethereum-contracts/ops-scripts/libs/common.js:getGasConfig() - gasConfig: (networkId) => { + gasConfig: ((networkId) => { let gasConfig = {}; const networkConfig = Object.values(truffleConfig.networks) @@ -123,7 +123,7 @@ module.exports = class Framework { } return gasConfig; - }, + })(this.networkId), }); const resolverAddress = diff --git a/packages/sdk-core/package.json b/packages/sdk-core/package.json index 9a4316747b..baa16975a2 100644 --- a/packages/sdk-core/package.json +++ b/packages/sdk-core/package.json @@ -31,6 +31,7 @@ "pretest": "yarn testenv:start", "test": "hardhat test --tsconfig \"tsconfig.test.json\"", "dev": "nodemon -e ts -x yarn test", + "clean": "rm -rf node_modules; rm -rf dist; rm -rf src/typechain-types; rm -rf src/typechain; rm -rf src/abi; find . -type f -name '*.generated.ts' -exec rm {} +", "test-coverage": "nyc --reporter=html --reporter=lcov --reporter=json yarn test", "posttest": "yarn testenv:stop", "check-updates": "ncu --target minor --dep prod,dev",