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", diff --git a/packages/subgraph/schema.graphql b/packages/subgraph/schema.graphql index ca3c7ffa44..d66a1060da 100644 --- a/packages/subgraph/schema.graphql +++ b/packages/subgraph/schema.graphql @@ -2272,6 +2272,7 @@ type Token @entity { underlyingToken: Token """ + If `governanceConfig.id` is the zero address, the token uses the default governance config. """ governanceConfig: TokenGovernanceConfig } @@ -2303,6 +2304,8 @@ type AccountTokenSnapshot @entity { ID composed of: accountID-tokenID """ id: ID! + createdAtTimestamp: BigInt! + createdAtBlockNumber: BigInt! updatedAtTimestamp: BigInt! updatedAtBlockNumber: BigInt! # ---------------------------------- state ---------------------------------- diff --git a/packages/subgraph/src/addresses.template.ts b/packages/subgraph/src/addresses.template.ts index ad6559454c..4edf31d65b 100644 --- a/packages/subgraph/src/addresses.template.ts +++ b/packages/subgraph/src/addresses.template.ts @@ -15,3 +15,7 @@ export function getResolverAddress(): Address { export function getNativeAssetSuperTokenAddress(): Address { return Address.fromString("{{nativeAssetSuperTokenAddress}}"); } + +export function getIsLocalIntegrationTesting(): boolean { + return "{{testNetwork}}".length > 0; +} \ No newline at end of file diff --git a/packages/subgraph/src/mappingHelpers.ts b/packages/subgraph/src/mappingHelpers.ts index 2f206ffed6..261e168f14 100644 --- a/packages/subgraph/src/mappingHelpers.ts +++ b/packages/subgraph/src/mappingHelpers.ts @@ -1,4 +1,5 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; +import { FlowUpdated } from "../generated/ConstantFlowAgreementV1/IConstantFlowAgreementV1"; import { ISuperfluid as Superfluid } from "../generated/Host/ISuperfluid"; import { Account, @@ -10,7 +11,6 @@ import { Pool, PoolDistributor, PoolMember, - ResolverEntry, Stream, StreamRevision, Token, @@ -18,33 +18,33 @@ import { TokenStatistic, TokenStatisticLog, } from "../generated/schema"; +import { SuperToken as SuperTokenTemplate } from "../generated/templates"; +import { ISuperToken as SuperToken } from "../generated/templates/SuperToken/ISuperToken"; +import { + getHostAddress, + getNativeAssetSuperTokenAddress, + getResolverAddress, +} from "./addresses"; import { BIG_INT_ZERO, - createLogID, + ZERO_ADDRESS, calculateMaybeCriticalAtTimestamp, + createLogID, getAccountTokenSnapshotID, + getActiveStreamsDelta, getAmountStreamedSinceLastUpdatedAt, + getClosedStreamsDelta, getFlowOperatorID, getIndexID, + getIsTokenListed, getOrder, + getPoolDistributorID, + getPoolMemberID, getStreamID, getStreamRevisionID, getSubscriptionID, - ZERO_ADDRESS, - handleTokenRPCCalls, - getPoolMemberID, - getPoolDistributorID, - getActiveStreamsDelta, - getClosedStreamsDelta, + handleTokenRPCCalls } from "./utils"; -import { SuperToken as SuperTokenTemplate } from "../generated/templates"; -import { ISuperToken as SuperToken } from "../generated/templates/SuperToken/ISuperToken"; -import { - getHostAddress, - getNativeAssetSuperTokenAddress, - getResolverAddress, -} from "./addresses"; -import { FlowUpdated } from "../generated/ConstantFlowAgreementV1/IConstantFlowAgreementV1"; /************************************************************************** * HOL initializer functions @@ -117,10 +117,11 @@ export function getOrInitSuperToken( nativeAssetSuperTokenAddress ); - token = handleTokenRPCCalls(token, resolverAddress); - token.isListed = false; + token = handleTokenRPCCalls(token); + token.isListed = getIsTokenListed(token, resolverAddress); const underlyingAddress = token.underlyingAddress; token.underlyingToken = underlyingAddress.toHexString(); + token.governanceConfig = ZERO_ADDRESS.toHexString(); token.save(); @@ -147,12 +148,6 @@ export function getOrInitSuperToken( return token as Token; } - // @note - this is currently being called every single time to handle list/unlist of tokens - // because we don't have the Resolver Set event on some networks - // We can remove this once we have migrated data to a new resolver which emits this event on - // all networks. - token = handleTokenRPCCalls(token, resolverAddress); - token.save(); return token as Token; @@ -203,6 +198,12 @@ export function getOrInitTokenGovernanceConfig( governanceConfig.token = superTokenAddress.toHexString(); governanceConfig.save(); + + const superToken = Token.load(superTokenAddress.toHexString()); + if (superToken) { + superToken.governanceConfig = governanceConfig.id; + superToken.save(); + } } return governanceConfig; } @@ -233,7 +234,7 @@ export function getOrInitToken( token.isNativeAssetSuperToken = false; token.isListed = false; - token = handleTokenRPCCalls(token, resolverAddress); + token = handleTokenRPCCalls(token); token.save(); } @@ -456,30 +457,6 @@ export function getOrInitSubscription( return subscription as IndexSubscription; } -export function getOrInitResolverEntry( - id: string, - target: Address, - block: ethereum.Block -): ResolverEntry { - let resolverEntry = ResolverEntry.load(id); - - if (resolverEntry == null) { - resolverEntry = new ResolverEntry(id); - resolverEntry.createdAtBlockNumber = block.number; - resolverEntry.createdAtTimestamp = block.timestamp; - resolverEntry.targetAddress = target; - - const superToken = Token.load(target.toHex()); - resolverEntry.isToken = superToken != null; - } - resolverEntry.updatedAtBlockNumber = block.number; - resolverEntry.updatedAtTimestamp = block.timestamp; - resolverEntry.isListed = target.notEqual(ZERO_ADDRESS); - - resolverEntry.save(); - return resolverEntry as ResolverEntry; -} - export function getOrInitPool(event: ethereum.Event, poolId: string): Pool { // get existing pool let pool = Pool.load(poolId); @@ -643,6 +620,8 @@ export function getOrInitAccountTokenSnapshot( if (accountTokenSnapshot == null) { accountTokenSnapshot = new AccountTokenSnapshot(atsId); + accountTokenSnapshot.createdAtTimestamp = block.timestamp; + accountTokenSnapshot.createdAtBlockNumber = block.number; accountTokenSnapshot.updatedAtTimestamp = block.timestamp; accountTokenSnapshot.updatedAtBlockNumber = block.number; accountTokenSnapshot.totalNumberOfActiveStreams = 0; diff --git a/packages/subgraph/src/mappings/resolver.ts b/packages/subgraph/src/mappings/resolver.ts index 706647abc4..b66a68290a 100644 --- a/packages/subgraph/src/mappings/resolver.ts +++ b/packages/subgraph/src/mappings/resolver.ts @@ -1,18 +1,13 @@ -import { Bytes, ethereum } from "@graphprotocol/graph-ts"; -import { - RoleAdminChanged, - RoleGranted, - RoleRevoked, - Set, -} from "../../generated/ResolverV1/Resolver"; +import { Address, Bytes, ethereum } from "@graphprotocol/graph-ts"; +import { RoleAdminChanged, RoleGranted, RoleRevoked, Set } from "../../generated/ResolverV1/Resolver"; import { + ResolverEntry, RoleAdminChangedEvent, RoleGrantedEvent, RoleRevokedEvent, SetEvent, Token, } from "../../generated/schema"; -import { getOrInitResolverEntry } from "../mappingHelpers"; import { createEventID, initializeEventEntity, ZERO_ADDRESS } from "../utils"; export function handleRoleAdminChanged(event: RoleAdminChanged): void { @@ -47,14 +42,34 @@ export function handleRoleRevoked(event: RoleRevoked): void { ev.save(); } +function getOrInitResolverEntry(id: string, target: Address, block: ethereum.Block): ResolverEntry { + let resolverEntry = ResolverEntry.load(id); + + if (resolverEntry == null) { + resolverEntry = new ResolverEntry(id); + resolverEntry.createdAtBlockNumber = block.number; + resolverEntry.createdAtTimestamp = block.timestamp; + resolverEntry.targetAddress = target; + } + const isListed = target.notEqual(ZERO_ADDRESS); + + // we only update this if the target is not equal to the zero address + if (isListed) { + resolverEntry.isToken = Token.load(target.toHex()) != null; + } + resolverEntry.updatedAtBlockNumber = block.number; + resolverEntry.updatedAtTimestamp = block.timestamp; + resolverEntry.isListed = isListed; + + resolverEntry.save(); + + return resolverEntry as ResolverEntry; +} + export function handleSet(event: Set): void { _createSetEvent(event, event.params.target, event.params.name); - const resolverEntry = getOrInitResolverEntry( - event.params.name.toHex(), - event.params.target, - event.block - ); + const resolverEntry = getOrInitResolverEntry(event.params.name.toHex(), event.params.target, event.block); // upon initial setting, we will know if this address belongs to a token contract if (resolverEntry.isToken) { @@ -80,11 +95,7 @@ export function handleSet(event: Set): void { resolverEntry.save(); } -function _createSetEvent( - event: ethereum.Event, - target: Bytes, - name: Bytes -): void { +function _createSetEvent(event: ethereum.Event, target: Bytes, name: Bytes): void { const eventId = createEventID("Set", event); const ev = new SetEvent(eventId); initializeEventEntity(ev, event, [target]); diff --git a/packages/subgraph/src/mappings/superfluidPool.ts b/packages/subgraph/src/mappings/superfluidPool.ts index 12afde5e09..d4fcf1798e 100644 --- a/packages/subgraph/src/mappings/superfluidPool.ts +++ b/packages/subgraph/src/mappings/superfluidPool.ts @@ -61,8 +61,11 @@ export function handleMemberUnitsUpdated(event: MemberUnitsUpdated): void { pool = updatePoolTotalAmountFlowedAndDistributed(event, pool); settlePDPoolMemberMU(pool, poolMember, event.block); +<<<<<<< HEAD // @note TODO update the pool.perUnitFlowRate // @note TODO update the poolMember.perUnitFlowRate +======= +>>>>>>> origin/dev const existingPoolFlowRate = pool.perUnitFlowRate.times(pool.totalUnits); let newPerUnitFlowRate: BigInt; let remainderRate: BigInt; diff --git a/packages/subgraph/src/utils.ts b/packages/subgraph/src/utils.ts index ce7d5c1ed6..f7b84b85e7 100644 --- a/packages/subgraph/src/utils.ts +++ b/packages/subgraph/src/utils.ts @@ -8,12 +8,14 @@ import { log, Value, } from "@graphprotocol/graph-ts"; -import { ISuperToken as SuperToken } from "../generated/templates/SuperToken/ISuperToken"; import { IndexSubscription, - Token, PoolMember, + Token, } from "../generated/schema"; +import { ISuperToken as SuperToken } from "../generated/templates/SuperToken/ISuperToken"; +import { Resolver } from "../generated/templates/SuperToken/Resolver"; +import { getIsLocalIntegrationTesting } from "./addresses"; /************************************************************************** * Constants @@ -108,8 +110,7 @@ export function initializeEventEntity( *************************************************************************/ export function handleTokenRPCCalls( - token: Token, - resolverAddress: Address + token: Token ): Token { // we must handle the case when the native token hasn't been initialized // there is no name/symbol, but this may occur later @@ -119,6 +120,20 @@ export function handleTokenRPCCalls( return token; } +export function getIsTokenListed( + token: Token, + resolverAddress: Address +): boolean { + const resolverContract = Resolver.bind(resolverAddress); + const isLocalIntegrationTesting = getIsLocalIntegrationTesting(); + const version = isLocalIntegrationTesting ? "test" : "v1"; + const result = resolverContract.try_get( + "supertokens." + version + "." + token.symbol + ); + const superTokenAddress = result.reverted ? ZERO_ADDRESS : result.value; + return token.id == superTokenAddress.toHex(); +} + export function getTokenInfoAndReturn(token: Token): Token { const tokenAddress = Address.fromString(token.id); const tokenContract = SuperToken.bind(tokenAddress); diff --git a/packages/subgraph/tasks/deploy.sh b/packages/subgraph/tasks/deploy.sh index 6f294bc78d..77dab25502 100755 --- a/packages/subgraph/tasks/deploy.sh +++ b/packages/subgraph/tasks/deploy.sh @@ -78,7 +78,7 @@ deploy_to_graph() { "$subgraphName" \ --node https://api.thegraph.com/deploy/ \ --ipfs https://api.thegraph.com/ipfs \ - --access-token "$THE_GRAPH_ACCESS_TOKEN" + --deploy-key "$THE_GRAPH_ACCESS_TOKEN" } deploy_to_satsuma() { diff --git a/packages/subgraph/tests/bugs/2024-02-29-aleph-total-supply.test.ts b/packages/subgraph/tests/bugs/2024-02-29-aleph-total-supply.test.ts index 45d7a15c97..8bace6e860 100644 --- a/packages/subgraph/tests/bugs/2024-02-29-aleph-total-supply.test.ts +++ b/packages/subgraph/tests/bugs/2024-02-29-aleph-total-supply.test.ts @@ -3,7 +3,7 @@ import { assert, describe, test } from "matchstick-as"; import { handleMinted } from "../../src/mappings/superToken"; import { handleCustomSuperTokenCreated } from "../../src/mappings/superTokenFactory"; import { ZERO_ADDRESS } from "../../src/utils"; -import { bob, alice } from "../constants"; +import { bob, alice, resolverAddress } from "../constants"; import { stringToBytes } from "../converters"; import { mockedGetHost, @@ -12,6 +12,7 @@ import { mockedTokenSymbol, mockedTokenDecimals, mockedTokenTotalSupply, + mockedResolverGet, } from "../mockedFunctions"; import { createMintedEvent } from "../superToken/superToken.helper"; import { createCustomSuperTokenCreatedEvent } from "../superTokenFactory/superTokenFactory.helper"; @@ -30,6 +31,7 @@ describe("ALEPH Total Supply Bug", () => { mockedTokenName(superToken, "tokenName"); mockedTokenSymbol(superToken, "tokenSymbol"); mockedTokenDecimals(superToken, 18); + mockedResolverGet(resolverAddress, "supertokens.v1.tokenSymbol", ZERO_ADDRESS.toHexString()); // unused mocked function call after change in this commit (removing total supply RPC call in getOrInitSuperToken) mockedTokenTotalSupply(superToken, totalSupply); diff --git a/packages/subgraph/tests/constants.ts b/packages/subgraph/tests/constants.ts index 1c15feacfc..11358dc9e9 100644 --- a/packages/subgraph/tests/constants.ts +++ b/packages/subgraph/tests/constants.ts @@ -26,7 +26,7 @@ export const cfaV1Address = "0x6eee6060f715257b970700bc2656de21dedf074c"; export const idaV1Address = "0xb0aabba4b2783a72c52956cdef62d438eca2d7a1"; export const superTokenFactoryAddress = "0x2c90719f25b10fc5646c82da3240c76fa5bccf34"; export const superTokenLogicAddress = "0x1349b5f1006ef0366a7b6ae41fa9155c6cd91e4b"; -export const resolverAddress = "0xe0cc76334405ee8b39213e620587d815967af39c"; +export const resolverAddress = "0x8bDCb5613153f41B2856F71Bd7A7e0432F6dbe58"; // this is not the actual TOGA export const togaAddress = "0x6aeaee5fd4d05a741723d752d30ee4d72690a8f7"; export const maticXAddress = "0x3ad736904e9e65189c3000c7dd2c8ac8bb7cd4e3"; diff --git a/packages/subgraph/tests/idav1/event/idav1.event.test.ts b/packages/subgraph/tests/idav1/event/idav1.event.test.ts index 7bc6e08288..c343d17049 100644 --- a/packages/subgraph/tests/idav1/event/idav1.event.test.ts +++ b/packages/subgraph/tests/idav1/event/idav1.event.test.ts @@ -14,9 +14,9 @@ import { } from "../../../src/mappings/idav1"; import { BIG_INT_ZERO, getIndexID, ZERO_ADDRESS } from "../../../src/utils"; import { assertIDAEventBaseProperties, assertIDAIndexEventBaseProperties } from "../../assertionHelpers"; -import { alice, bob, DEFAULT_DECIMALS, FAKE_INITIAL_BALANCE, maticXAddress, maticXName, maticXSymbol } from "../../constants"; +import { alice, bob, DEFAULT_DECIMALS, FAKE_INITIAL_BALANCE, maticXAddress, maticXName, maticXSymbol, resolverAddress } from "../../constants"; import { stringToBytes } from "../../converters"; -import { mockedGetAppManifest, mockedGetHost, mockedHandleSuperTokenInitRPCCalls, mockedRealtimeBalanceOf } from "../../mockedFunctions"; +import { mockedGetAppManifest, mockedGetHost, mockedHandleSuperTokenInitRPCCalls, mockedRealtimeBalanceOf, mockedResolverGet } from "../../mockedFunctions"; import { createIndexCreatedEvent, createIndexDistributionClaimedEvent, @@ -267,6 +267,8 @@ describe("InstantDistributionV1 Event Entity Unit Tests", () => { userData ); + mockedResolverGet(resolverAddress, "supertokens.v1.MATICx", ZERO_ADDRESS.toHexString()); + mockedRealtimeBalanceOf( superToken, subscriber, diff --git a/packages/subgraph/tests/mockedFunctions.ts b/packages/subgraph/tests/mockedFunctions.ts index 7ef88761b5..ba9aa3e4b6 100644 --- a/packages/subgraph/tests/mockedFunctions.ts +++ b/packages/subgraph/tests/mockedFunctions.ts @@ -1,11 +1,12 @@ import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; import { createMockedFunction } from "matchstick-as/assembly/index"; import { FlowUpdated } from "../generated/ConstantFlowAgreementV1/IConstantFlowAgreementV1"; -import { BIG_INT_ZERO } from "../src/utils"; +import { BIG_INT_ZERO, ZERO_ADDRESS } from "../src/utils"; import { FAKE_INITIAL_BALANCE, FAKE_SUPER_TOKEN_TOTAL_SUPPLY, hostAddress, + resolverAddress, } from "./constants"; import { getETHAddress, @@ -46,6 +47,8 @@ export function mockedHandleSuperTokenInitRPCCalls( mockedTokenDecimals(superToken, decimals); // [END] getTokenInfoAndReturn + mockedResolverGet(resolverAddress, "supertokens.v1." + tokenSymbol, ZERO_ADDRESS.toHexString()); + // updateTotalSupplyForNativeSuperToken(token, tokenStatistic, tokenAddress) mockedTokenTotalSupply(superToken, FAKE_SUPER_TOKEN_TOTAL_SUPPLY); } @@ -95,7 +98,7 @@ export function mockedHandleFlowUpdatedRPCCalls( // getOrInitStream(event) => getOrInitAccount(receiver) => host.try_getAppManifest(receiver) mockedGetAppManifest(receiver, false, false, BIG_INT_ZERO); - // [START] getOrInitStream(event) => getOrInitSuperToken(token, block) => handleTokenRPCCalls(token, resolverAddress) + // [START] getOrInitStream(event) => getOrInitSuperToken(token, block) => handleTokenRPCCalls(token) mockedHandleSuperTokenInitRPCCalls( superToken, decimals, @@ -103,7 +106,9 @@ export function mockedHandleFlowUpdatedRPCCalls( tokenName, tokenSymbol ); - // [END] getOrInitStream(event) => getOrInitSuperToken(token, block) => handleTokenRPCCalls(token, resolverAddress) + // [END] getOrInitStream(event) => getOrInitSuperToken(token, block) => handleTokenRPCCalls(token) + + mockedResolverGet(resolverAddress, "supertokens.v1." + tokenSymbol, ZERO_ADDRESS.toHexString()); // updateATSStreamedAndBalanceUntilUpdatedAt => updateATSBalanceAndUpdatedAt => try_realtimeBalanceOf(sender) mockedRealtimeBalanceOf(