From cf71141bbf89f6cc823b86b40c633f06ba91fad2 Mon Sep 17 00:00:00 2001 From: Artem Kovalchuk Date: Tue, 13 Feb 2024 17:05:02 +0200 Subject: [PATCH 1/3] add deploy actions --- ...aph.yml => deploy-subgraph-theGraph-a.yml} | 8 ++--- .../workflows/deploy-subgraph-theGraph-b.yml | 33 +++++++++++++++++++ subgraph/package.json | 3 +- 3 files changed, 39 insertions(+), 5 deletions(-) rename .github/workflows/{deploy-subgraph-theGraph.yml => deploy-subgraph-theGraph-a.yml} (87%) create mode 100644 .github/workflows/deploy-subgraph-theGraph-b.yml diff --git a/.github/workflows/deploy-subgraph-theGraph.yml b/.github/workflows/deploy-subgraph-theGraph-a.yml similarity index 87% rename from .github/workflows/deploy-subgraph-theGraph.yml rename to .github/workflows/deploy-subgraph-theGraph-a.yml index ba1f9107..432679c3 100644 --- a/.github/workflows/deploy-subgraph-theGraph.yml +++ b/.github/workflows/deploy-subgraph-theGraph-a.yml @@ -1,4 +1,4 @@ -name: Prod Deploy Subgraph +name: Prod Deploy Subgraph to TheGraph A on: workflow_dispatch: jobs: @@ -12,7 +12,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: "16" - + - name: Install the graph cli run: npm install @graphprotocol/graph-cli @@ -28,6 +28,6 @@ jobs: working-directory: ./subgraph run: npm run prepare - - name: Deploy subgraph + - name: Deploy subgraph working-directory: ./subgraph - run: npm run deploy-theGraph + run: npm run deploy-theGraph-a diff --git a/.github/workflows/deploy-subgraph-theGraph-b.yml b/.github/workflows/deploy-subgraph-theGraph-b.yml new file mode 100644 index 00000000..0d190fa6 --- /dev/null +++ b/.github/workflows/deploy-subgraph-theGraph-b.yml @@ -0,0 +1,33 @@ +name: Prod Deploy Subgraph to TheGraph B +on: + workflow_dispatch: +jobs: + deploy-subgraph: + name: Deploy subgraph workflow + runs-on: ubuntu-latest + environment: production + steps: + - uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: "16" + + - name: Install the graph cli + run: npm install @graphprotocol/graph-cli + + - name: Authenticate with prod subgraph + run: | + npx graph auth --product hosted-service ${{ secrets.PROD_SUBGRAPH_API_KEY }} + + - name: Install subgraph dependencies + working-directory: ./subgraph + run: npm install + + - name: Prepare for subgraph deployment + working-directory: ./subgraph + run: npm run prepare + + - name: Deploy subgraph + working-directory: ./subgraph + run: npm run deploy-theGraph-b diff --git a/subgraph/package.json b/subgraph/package.json index a7025431..919d5e15 100644 --- a/subgraph/package.json +++ b/subgraph/package.json @@ -10,7 +10,8 @@ "prepare-dev": "yarn prepare-dev:codegen && yarn prepare-dev:compile", "deploy-dev": "graph deploy --node https://api.graph-eu.p2pify.com/765768b776199f59bb7f1bf37253e73f/deploy --ipfs https://api.graph-eu.p2pify.com/765768b776199f59bb7f1bf37253e73f/ipfs forta-dev", "deploy": "graph deploy -l v0.0.1 --node https://api.graph-eu.p2pify.com/3e3485fa2703678549290ce52f45ef9c/deploy --ipfs https://api.graph-eu.p2pify.com/3e3485fa2703678549290ce52f45ef9c/ipfs forta-b", - "deploy-theGraph": "graph deploy --network matic --node https://api.thegraph.com/deploy/ forta-network/forta-network", + "deploy-theGraph-a": "graph deploy --network matic --node https://api.thegraph.com/deploy/ forta-network/forta-network-a", + "deploy-theGraph-b": "graph deploy --network matic --node https://api.thegraph.com/deploy/ forta-network/forta-network-b", "create-local": "graph create --node http://localhost:8020/ forta-network/forta-network", "remove-local": "graph remove --node http://localhost:8020/ forta-network/forta-network", "deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 forta-network/forta-network", From d3cc65a672eb854cd9c82b086308b770ad170cae Mon Sep 17 00:00:00 2001 From: Artem Kovalchuk Date: Tue, 13 Feb 2024 17:12:08 +0200 Subject: [PATCH 2/3] fix deploy actions --- .github/workflows/deploy-subgraph-theGraph-a.yml | 6 +++--- .github/workflows/deploy-subgraph-theGraph-b.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-subgraph-theGraph-a.yml b/.github/workflows/deploy-subgraph-theGraph-a.yml index 432679c3..24d85529 100644 --- a/.github/workflows/deploy-subgraph-theGraph-a.yml +++ b/.github/workflows/deploy-subgraph-theGraph-a.yml @@ -22,12 +22,12 @@ jobs: - name: Install subgraph dependencies working-directory: ./subgraph - run: npm install + run: yarn install - name: Prepare for subgraph deployment working-directory: ./subgraph - run: npm run prepare + run: yarn run prepare - name: Deploy subgraph working-directory: ./subgraph - run: npm run deploy-theGraph-a + run: yarn run deploy-theGraph-a diff --git a/.github/workflows/deploy-subgraph-theGraph-b.yml b/.github/workflows/deploy-subgraph-theGraph-b.yml index 0d190fa6..59e47392 100644 --- a/.github/workflows/deploy-subgraph-theGraph-b.yml +++ b/.github/workflows/deploy-subgraph-theGraph-b.yml @@ -22,12 +22,12 @@ jobs: - name: Install subgraph dependencies working-directory: ./subgraph - run: npm install + run: yarn install - name: Prepare for subgraph deployment working-directory: ./subgraph - run: npm run prepare + run: yarn run prepare - name: Deploy subgraph working-directory: ./subgraph - run: npm run deploy-theGraph-b + run: yarn run deploy-theGraph-b From bbc5a45ab4ea45026d44b4f4898593a56343caa7 Mon Sep 17 00:00:00 2001 From: Artem Kovalchuk Date: Mon, 27 May 2024 19:02:13 +0300 Subject: [PATCH 3/3] Migrate subgraph to base-sepolia --- subgraph/README.md | 4 +- subgraph/networks.json | 104 +++++---- subgraph/package.json | 7 +- subgraph/src/datasources/ScannerRegistry.ts | 221 -------------------- subgraph/src/tests/.latest.json | 4 +- subgraph/src/tests/scannerregistry.test.ts | 121 ----------- subgraph/subgraph.yaml | 66 ++---- subgraph/yarn.lock | 9 +- 8 files changed, 96 insertions(+), 440 deletions(-) delete mode 100644 subgraph/src/datasources/ScannerRegistry.ts delete mode 100644 subgraph/src/tests/scannerregistry.test.ts diff --git a/subgraph/README.md b/subgraph/README.md index 1f0f6534..04b17764 100644 --- a/subgraph/README.md +++ b/subgraph/README.md @@ -1,5 +1,5 @@ # Forta Subgraph -The Forta subgraph is currently hosted on chainstack (both dev and production enviornments) and provides visibility to on-chain events around the forta protocol such as staking, rewards, node pools, etc. +The Forta subgraph is currently hosted on TheGraph and Chainstack and provides visibility to on-chain events around the forta protocol such as staking, rewards, node pools, etc. ## Deployment @@ -17,4 +17,4 @@ There are two production subgraphs which we follow a [blue/green deployment patt Forta-a subgraph url: `https://polygon-mainnet.graph-eu.p2pify.com/49e5eba171ac70bd41578331e4d65cfc/forta-a` -Forta-b subgraph url: `https://polygon-mainnet.graph-eu.p2pify.com/62563b45923ea9d259c5c16d1f73f804/forta-b` \ No newline at end of file +Forta-b subgraph url: `https://polygon-mainnet.graph-eu.p2pify.com/62563b45923ea9d259c5c16d1f73f804/forta-b` diff --git a/subgraph/networks.json b/subgraph/networks.json index 119b0dd5..64ea0734 100644 --- a/subgraph/networks.json +++ b/subgraph/networks.json @@ -1,62 +1,80 @@ { "matic": { - "ScannerRegistry": { - "address": "0xbF2920129f83d75DeC95D97A879942cCe3DcD387", - "startBlock": 20187154 - }, - "AgentRegistry": { - "address": "0x61447385B019187daa48e91c55c02AF1F1f3F863", - "startBlock": 20187154 - }, - "Dispatcher": { - "address": "0xd46832F3f8EA8bDEFe5316696c0364F01b31a573", - "startBlock": 20187154 - }, - "FortaStaking": { - "address": "0xd2863157539b1D11F39ce23fC4834B62082F6874", - "startBlock": 20187154 - }, - "ScannerPoolRegistry": { - "address": "0x90ff9c193d6714e0e7a923b2bd481fb73fec731d", - "startBlock": 20187154 - }, - "RewardsDistributor": { - "address": "0xf7239f26b79145297737166b0c66f4919af9c507", - "startBlock": 20187154 - }, - "StakeAllocator": { - "address": "0x5B73756e637A77Fa52e5Ce71EC6189A4C775c6FA", - "startBlock": 20187154 - } + "AgentRegistry": { + "address": "0x61447385B019187daa48e91c55c02AF1F1f3F863", + "startBlock": 20187154 + }, + "Dispatcher": { + "address": "0xd46832F3f8EA8bDEFe5316696c0364F01b31a573", + "startBlock": 20187154 + }, + "FortaStaking": { + "address": "0xd2863157539b1D11F39ce23fC4834B62082F6874", + "startBlock": 20187154 + }, + "ScannerPoolRegistry": { + "address": "0x90ff9c193d6714e0e7a923b2bd481fb73fec731d", + "startBlock": 20187154 + }, + "RewardsDistributor": { + "address": "0xf7239f26b79145297737166b0c66f4919af9c507", + "startBlock": 20187154 + }, + "StakeAllocator": { + "address": "0x5B73756e637A77Fa52e5Ce71EC6189A4C775c6FA", + "startBlock": 20187154 + } }, "mumbai": { - "ScannerRegistry": { - "address": "0x569c785b4744E582c65A12827726FC03C8D08A4a", + "AgentRegistry": { + "address": "0x4519Eaeb9A5c1a9d870Fe35452E54AD04E6e8428", + "startBlock": 21300000 + }, + "Dispatcher": { + "address": "0x485F9c35d90E639f5B591DA5281199Ae59A9794F", + "startBlock": 21300000 + }, + "FortaStaking": { + "address": "0x64d5192F03bD98dB1De2AA8B4abAC5419eaC32CE", + "startBlock": 21300000 + }, + "ScannerPoolRegistry": { + "address": "0x9BBEBf9CB94666464D8a5978363B4943D36A05E4", + "startBlock": 29281360 + }, + "RewardsDistributor": { + "address": "0x404afc59Cacd74A28d0D5651460Cc950b42FAf08", "startBlock": 21300000 }, + "StakeAllocator": { + "address": "0x698A6400dE3865fC9E8A6dB22302AAb3372Cebd9", + "startBlock": 21300000 + } + }, + "base-sepolia": { "AgentRegistry": { - "address": "0x4519Eaeb9A5c1a9d870Fe35452E54AD04E6e8428", - "startBlock": 21300000 + "address": "0x0C8B8DeC21Aa72179e8C4703a9B55d9Db061D423", + "startBlock": 8150713 }, "Dispatcher": { - "address": "0x485F9c35d90E639f5B591DA5281199Ae59A9794F", - "startBlock": 21300000 + "address": "0x452C7044B9977de45ed7621ba0Bb77E312663157", + "startBlock": 8150713 }, "FortaStaking": { - "address": "0x64d5192F03bD98dB1De2AA8B4abAC5419eaC32CE", - "startBlock": 21300000 + "address": "0x1ed86971E4C4f3d13b6b8030D80C7D609de7139c", + "startBlock": 8150713 }, "ScannerPoolRegistry": { - "address": "0x9BBEBf9CB94666464D8a5978363B4943D36A05E4", - "startBlock": 29281360 + "address": "0x786e4446bB39F5480310FE98c48d2d5e6129A4cC", + "startBlock": 8150713 }, "RewardsDistributor": { - "address": "0x404afc59Cacd74A28d0D5651460Cc950b42FAf08", - "startBlock": 21300000 + "address": "0x414E8777Df3e3Af4Ed3e4bA9A2266779F86558e4", + "startBlock": 8150713 }, "StakeAllocator": { - "address": "0x698A6400dE3865fC9E8A6dB22302AAb3372Cebd9", - "startBlock": 21300000 + "address": "0xc054a3DABfFEb0279E62669FB699a33D4cC5fC62", + "startBlock": 8150713 } } -} \ No newline at end of file +} diff --git a/subgraph/package.json b/subgraph/package.json index 919d5e15..11d32163 100644 --- a/subgraph/package.json +++ b/subgraph/package.json @@ -5,10 +5,10 @@ "prepare:codegen": "graph codegen subgraph.yaml", "prepare:compile": "graph build subgraph.yaml --network matic", "prepare-dev:codegen": "graph codegen subgraph.yaml", - "prepare-dev:compile": "graph build subgraph.yaml --network mumbai", + "prepare-dev:compile": "graph build subgraph.yaml --network base-sepolia", "prepare": "yarn prepare:codegen && yarn prepare:compile", "prepare-dev": "yarn prepare-dev:codegen && yarn prepare-dev:compile", - "deploy-dev": "graph deploy --node https://api.graph-eu.p2pify.com/765768b776199f59bb7f1bf37253e73f/deploy --ipfs https://api.graph-eu.p2pify.com/765768b776199f59bb7f1bf37253e73f/ipfs forta-dev", + "deploy-dev": "graph build subgraph.yaml --network base-sepolia", "deploy": "graph deploy -l v0.0.1 --node https://api.graph-eu.p2pify.com/3e3485fa2703678549290ce52f45ef9c/deploy --ipfs https://api.graph-eu.p2pify.com/3e3485fa2703678549290ce52f45ef9c/ipfs forta-b", "deploy-theGraph-a": "graph deploy --network matic --node https://api.thegraph.com/deploy/ forta-network/forta-network-a", "deploy-theGraph-b": "graph deploy --network matic --node https://api.thegraph.com/deploy/ forta-network/forta-network-b", @@ -22,7 +22,8 @@ "@graphprotocol/graph-cli": "0.49.0", "@graphprotocol/graph-ts": "0.27.0", "matchstick-as": "^0.5.0", - "source-map-support": "^0.5.21" + "source-map-support": "^0.5.21", + "yaml": "^2.4.1" }, "devDependencies": { "typescript": "^4.9.5" diff --git a/subgraph/src/datasources/ScannerRegistry.ts b/subgraph/src/datasources/ScannerRegistry.ts deleted file mode 100644 index 17d6dec2..00000000 --- a/subgraph/src/datasources/ScannerRegistry.ts +++ /dev/null @@ -1,221 +0,0 @@ -import { events, transactions } from "@amxx/graphprotocol-utils/"; -import { - ScannerUpdated as ScannerUpdatedEvent, - Transfer as TransferEvent, - ScannerEnabled as ScannerEnabledEvent, - ManagerEnabled as ManagerEnabledEvent, -} from "../../generated/ScannerRegistry/ScannerRegistry"; -import { - ScannerEnabled, - ScannerManager, - ScannerManagerEnabled, - ScannerTransfer, - ScannerUpdated, -} from "../../generated/schema"; -import { fetchAccount } from "../fetch/account"; -import { fetchScanner } from "../fetch/scanner"; -import { newMockEvent } from "matchstick-as"; -import { Address, BigInt, ethereum } from "@graphprotocol/graph-ts"; - -export function handleScannerUpdated(event: ScannerUpdatedEvent): void { - let scanner = fetchScanner(event.params.scannerId); - scanner.metadata = event.params.metadata; - scanner.chainId = event.params.chainId; - scanner.save(); - - const ev = new ScannerUpdated(events.id(event)); - ev.transaction = transactions.log(event).id; - ev.timestamp = event.block.timestamp; - ev.scanner = scanner.id; - ev.metadata = event.params.metadata; - ev.chainId = event.params.chainId; - ev.save(); -} - -export function handleTransfer(event: TransferEvent): void { - let scanner = fetchScanner(event.params.tokenId); - let from = fetchAccount(event.params.from); - let to = fetchAccount(event.params.to); - scanner.owner = to.id; - scanner.save(); - - const ev = new ScannerTransfer(events.id(event)); - ev.transaction = transactions.log(event).id; - ev.timestamp = event.block.timestamp; - ev.scanner = scanner.id; - ev.from = from.id; - ev.to = to.id; - ev.save(); -} - -export function handleManagerEnabled(event: ManagerEnabledEvent): void { - let scanner = fetchScanner(event.params.scannerId); - let account = fetchAccount(event.params.manager); - - let scannerManager = new ScannerManager( - scanner.id.concat("/").concat(account.id) - ); - - scannerManager.scanner = scanner.id; - scannerManager.account = account.id; - scannerManager.active = event.params.enabled; - scannerManager.save(); - - const ev = new ScannerManagerEnabled(events.id(event)); - ev.transaction = transactions.log(event).id; - ev.timestamp = event.block.timestamp; - ev.scanner = scanner.id; - ev.manager = account.id; - ev.scannermanager = scannerManager.id; - ev.enabled = event.params.enabled; - ev.save(); -} - -export function handleScannerEnabled(event: ScannerEnabledEvent): void { - let scanner = fetchScanner(event.params.scannerId); - let mask = 1 << event.params.permission; - - scanner.disableFlags = event.params.value - ? scanner.disableFlags || mask - : scanner.disableFlags && ~mask; - - scanner.enabled = event.params.enabled; - scanner.save(); - - const ev = new ScannerEnabled(events.id(event)); - ev.transaction = transactions.log(event).id; - ev.timestamp = event.block.timestamp; - ev.scanner = scanner.id; - ev.enabled = event.params.enabled; - ev.permission = event.params.permission; - ev.value = event.params.value; - ev.save(); -} - -export function createTransferEvent( - from: Address, - to: Address, - tokenId: BigInt -): TransferEvent { - const mockTransferEvent = changetype(newMockEvent()); - - mockTransferEvent.parameters = []; - - const fromParam = new ethereum.EventParam( - "from", - ethereum.Value.fromAddress(from) - ); - - const toParam = new ethereum.EventParam("to", ethereum.Value.fromAddress(to)); - - const tokenIdParam = new ethereum.EventParam( - "tokenId", - ethereum.Value.fromSignedBigInt(tokenId) - ); - - mockTransferEvent.parameters.push(fromParam); - mockTransferEvent.parameters.push(toParam); - mockTransferEvent.parameters.push(tokenIdParam); - - return mockTransferEvent; -} - -export function createScannerUpdatedEvent( - scannerId: BigInt, - chainId: BigInt, - metadata: string -): ScannerUpdatedEvent { - const mockUpdatedEvent = changetype(newMockEvent()); - mockUpdatedEvent.parameters = []; - - const scannerIdParam = new ethereum.EventParam( - "scannerId", - ethereum.Value.fromSignedBigInt(scannerId) - ); - - const chainIdParam = new ethereum.EventParam( - "chainId", - ethereum.Value.fromSignedBigInt(chainId) - ); - - const metadataParam = new ethereum.EventParam( - "metadata", - ethereum.Value.fromString(metadata) - ); - - mockUpdatedEvent.parameters.push(scannerIdParam); - mockUpdatedEvent.parameters.push(chainIdParam); - mockUpdatedEvent.parameters.push(metadataParam); - - return mockUpdatedEvent; -} - -export function createManagerEnabledEvent( - scannerId: BigInt, - manager: Address, - enabled: boolean -): ManagerEnabledEvent { - const mockManagerEnabledEvent = changetype( - newMockEvent() - ); - - mockManagerEnabledEvent.parameters = []; - - const scannerIdParam = new ethereum.EventParam( - "scannerId", - ethereum.Value.fromSignedBigInt(scannerId) - ); - - const managerParam = new ethereum.EventParam( - "manager", - ethereum.Value.fromAddress(manager) - ); - - const enabledParam = new ethereum.EventParam( - "enabled", - ethereum.Value.fromBoolean(enabled) - ); - - mockManagerEnabledEvent.parameters.push(scannerIdParam); - mockManagerEnabledEvent.parameters.push(managerParam); - mockManagerEnabledEvent.parameters.push(enabledParam); - - return mockManagerEnabledEvent; -} - -export function createScannerEnabledEvent( - scannerId: BigInt, - enabled: boolean, - permission: i32, - value: boolean -): ScannerEnabledEvent { - const mockScannerEnabled = changetype(newMockEvent()); - - mockScannerEnabled.parameters = []; - const scannerIdParam = new ethereum.EventParam( - "scannerId", - ethereum.Value.fromSignedBigInt(scannerId) - ); - - const permissionParam = new ethereum.EventParam( - "permission", - ethereum.Value.fromI32(permission) - ); - - const valueParam = new ethereum.EventParam( - "value", - ethereum.Value.fromBoolean(value) - ); - - const enabledParam = new ethereum.EventParam( - "enabled", - ethereum.Value.fromBoolean(enabled) - ); - - mockScannerEnabled.parameters.push(scannerIdParam); - mockScannerEnabled.parameters.push(enabledParam); - mockScannerEnabled.parameters.push(permissionParam); - mockScannerEnabled.parameters.push(valueParam); - - return mockScannerEnabled; -} diff --git a/subgraph/src/tests/.latest.json b/subgraph/src/tests/.latest.json index af7433e2..cf0fe23e 100644 --- a/subgraph/src/tests/.latest.json +++ b/subgraph/src/tests/.latest.json @@ -1,4 +1,4 @@ { - "version": "0.5.0", - "timestamp": 1655722304335 + "version": "0.6.0", + "timestamp": 1707758824876 } \ No newline at end of file diff --git a/subgraph/src/tests/scannerregistry.test.ts b/subgraph/src/tests/scannerregistry.test.ts deleted file mode 100644 index 8fd5d7db..00000000 --- a/subgraph/src/tests/scannerregistry.test.ts +++ /dev/null @@ -1,121 +0,0 @@ -import { Address, BigInt } from "@graphprotocol/graph-ts"; -import { clearStore, test, assert } from "matchstick-as"; -import { Scanner } from "../../generated/schema"; -import { - createManagerEnabledEvent, - createScannerEnabledEvent, - createScannerUpdatedEvent, - createTransferEvent, - handleManagerEnabled, - handleScannerEnabled, - handleScannerUpdated, - handleTransfer, -} from "../datasources/ScannerRegistry"; - -test("Scanner is successfully created on transfer event", () => { - const mockScannerTransferEvent = createTransferEvent( - Address.zero(), - Address.zero(), - BigInt.fromString("92602676983101940350471475877918459195971018380") - ); - - handleTransfer(mockScannerTransferEvent); - - assert.fieldEquals( - "Scanner", - BigInt.fromString( - "92602676983101940350471475877918459195971018380" - ).toHex(), - "id", - BigInt.fromString("92602676983101940350471475877918459195971018380").toHex() - ); - clearStore(); -}); - -test("Scanner is successfully updated on update event", () => { - const scanner = new Scanner( - BigInt.fromString("92602676983101940350471475877918459195971018380").toHex() - ); - scanner.chainId = BigInt.fromI32(1); - scanner.enabled = true; - scanner.disableFlags = 0; - scanner.owner = Address.zero().toHex(); - scanner.metadata = ""; - scanner.save(); - - const mockScannerUpdateEvent = createScannerUpdatedEvent( - BigInt.fromString("92602676983101940350471475877918459195971018380"), - BigInt.fromI32(1), - "Test" - ); - - handleScannerUpdated(mockScannerUpdateEvent); - - assert.fieldEquals("Scanner", scanner.id, "metadata", "Test"); - clearStore(); -}); - -test("Scanner manager is successfully created", () => { - const scanner = new Scanner( - BigInt.fromString("92602676983101940350471475877918459195971018380").toHex() - ); - scanner.chainId = BigInt.fromI32(1); - scanner.enabled = true; - scanner.disableFlags = 0; - scanner.owner = Address.zero().toHex(); - scanner.metadata = ""; - scanner.save(); - - const mockManagerEvent = createManagerEnabledEvent( - BigInt.fromString("92602676983101940350471475877918459195971018380"), - Address.zero(), - true - ); - - handleManagerEnabled(mockManagerEvent); - - assert.fieldEquals( - "ScannerManager", - BigInt.fromString("92602676983101940350471475877918459195971018380") - .toHex() - .concat("/") - .concat(Address.zero().toHex()), - "id", - BigInt.fromString("92602676983101940350471475877918459195971018380") - .toHex() - .concat("/") - .concat(Address.zero().toHex()) - ); - clearStore(); -}); - -test("Scanner is successfully enabled on update event", () => { - const scanner = new Scanner( - BigInt.fromString("92602676983101940350471475877918459195971018380").toHex() - ); - scanner.chainId = BigInt.fromI32(1); - scanner.enabled = false; - scanner.disableFlags = 0; - scanner.owner = Address.zero().toHex(); - scanner.metadata = ""; - scanner.save(); - - const mockScannerEnabledEvent = createScannerEnabledEvent( - BigInt.fromString("92602676983101940350471475877918459195971018380"), - true, - 1, - true - ); - - handleScannerEnabled(mockScannerEnabledEvent); - - assert.fieldEquals( - "Scanner", - BigInt.fromString( - "92602676983101940350471475877918459195971018380" - ).toHex(), - "enabled", - "true" - ); - clearStore(); -}); diff --git a/subgraph/subgraph.yaml b/subgraph/subgraph.yaml index 81dd6f39..d976e4e2 100644 --- a/subgraph/subgraph.yaml +++ b/subgraph/subgraph.yaml @@ -2,40 +2,13 @@ specVersion: 0.0.5 schema: file: ./src/schema.graphql dataSources: - - kind: ethereum - name: ScannerRegistry - network: mumbai - source: - abi: ScannerRegistry - address: "0x569c785b4744E582c65A12827726FC03C8D08A4a" - startBlock: 21300000 - mapping: - kind: ethereum/events - apiVersion: 0.0.6 - language: wasm/assemblyscript - entities: - - Scanner - - StakeThreshold - abis: - - name: ScannerRegistry - file: ./abis/ScannerRegistry.json - eventHandlers: - - event: ScannerUpdated(indexed uint256,indexed uint256,string) - handler: handleScannerUpdated - - event: ScannerEnabled(indexed uint256,indexed bool,uint8,bool) - handler: handleScannerEnabled - - event: Transfer(indexed address,indexed address,indexed uint256) - handler: handleTransfer - - event: ManagerEnabled(indexed uint256,indexed address,bool) - handler: handleManagerEnabled - file: ./src/datasources/ScannerRegistry.ts - kind: ethereum name: AgentRegistry - network: mumbai + network: matic source: abi: AgentRegistry - address: "0x4519Eaeb9A5c1a9d870Fe35452E54AD04E6e8428" - startBlock: 21300000 + address: "0x61447385B019187daa48e91c55c02AF1F1f3F863" + startBlock: 20187154 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -55,11 +28,11 @@ dataSources: file: ./src/datasources/AgentRegistry.ts - kind: ethereum name: Dispatcher - network: mumbai + network: matic source: abi: Dispatcher - address: "0x485F9c35d90E639f5B591DA5281199Ae59A9794F" - startBlock: 21300000 + address: "0xd46832F3f8EA8bDEFe5316696c0364F01b31a573" + startBlock: 20187154 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -76,11 +49,11 @@ dataSources: file: ./src/datasources/Dispatcher.ts - kind: ethereum name: FortaStaking - network: mumbai + network: matic source: abi: FortaStaking - address: "0x64d5192F03bD98dB1De2AA8B4abAC5419eaC32CE" - startBlock: 21300000 + address: "0xd2863157539b1D11F39ce23fC4834B62082F6874" + startBlock: 20187154 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -109,11 +82,11 @@ dataSources: file: ./src/datasources/FortaStaking.ts - kind: ethereum name: ScannerPoolRegistry - network: mumbai + network: matic source: abi: ScannerPoolRegistry - address: "0x9BBEBf9CB94666464D8a5978363B4943D36A05E4" - startBlock: 29281360 + address: "0x90ff9c193d6714e0e7a923b2bd481fb73fec731d" + startBlock: 20187154 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -136,11 +109,11 @@ dataSources: file: ./src/datasources/ScannerPoolRegistry.ts - kind: ethereum name: RewardsDistributor - network: mumbai + network: matic source: abi: RewardsDistributor - address: "0x404afc59Cacd74A28d0D5651460Cc950b42FAf08" - startBlock: 21300000 + address: "0xf7239f26b79145297737166b0c66f4919af9c507" + startBlock: 20187154 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -155,16 +128,17 @@ dataSources: handler: handleSetDelegationFee - event: Rewarded(indexed uint8,indexed uint256,uint256,uint256) handler: handleRewardEvent - - event: ClaimedRewards(indexed uint8,indexed uint256,indexed address,uint256,uint256) + - event: ClaimedRewards(indexed uint8,indexed uint256,indexed + address,uint256,uint256) handler: handleClaimedRewards file: ./src/datasources/RewardsDistributor.ts - kind: ethereum name: StakeAllocator - network: mumbai + network: matic source: abi: StakeAllocator - address: "0x698A6400dE3865fC9E8A6dB22302AAb3372Cebd9" - startBlock: 21300000 + address: "0x5B73756e637A77Fa52e5Ce71EC6189A4C775c6FA" + startBlock: 20187154 mapping: kind: ethereum/events apiVersion: 0.0.6 diff --git a/subgraph/yarn.lock b/subgraph/yarn.lock index ff9dc8e7..5262cfab 100644 --- a/subgraph/yarn.lock +++ b/subgraph/yarn.lock @@ -1771,9 +1771,9 @@ globby@^11.1.0: merge2 "^1.4.1" slash "^3.0.0" -"gluegun@git+https://github.com/edgeandnode/gluegun.git#v4.3.1-pin-colors-dep": +"gluegun@https://github.com/edgeandnode/gluegun#v4.3.1-pin-colors-dep": version "4.3.1" - resolved "git+https://github.com/edgeandnode/gluegun.git#b34b9003d7bf556836da41b57ef36eb21570620a" + resolved "https://github.com/edgeandnode/gluegun#b34b9003d7bf556836da41b57ef36eb21570620a" dependencies: apisauce "^1.0.1" app-module-path "^2.2.0" @@ -3713,6 +3713,11 @@ yaml@1.10.2, yaml@^1.10.2, yaml@^1.7.2: resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== +yaml@^2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.4.1.tgz#2e57e0b5e995292c25c75d2658f0664765210eed" + integrity sha512-pIXzoImaqmfOrL7teGUBt/T7ZDnyeGBWyXQBvOVhLkWLN37GXv8NMLK406UY6dS51JfcQHsmcW5cJ441bHg6Lg== + yargs-parser@^16.1.0: version "16.1.0" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-16.1.0.tgz#73747d53ae187e7b8dbe333f95714c76ea00ecf1"