From 3c7cf1726fbcb626a87f169c14e95dafe0a78992 Mon Sep 17 00:00:00 2001 From: Sahra <107348755+sahra-karakoc@users.noreply.github.com> Date: Wed, 1 Nov 2023 18:04:07 +0300 Subject: [PATCH] feat: subgraph and subgraph version entities feature parity (#62) --- abis/gns.json | 866 ++++--- proto/erc20.proto | 39 + schema.graphql | 22 + src/abi/gns.rs | 4903 ++++++++++++++++++++------------------ src/db.rs | 41 + src/modules/gns.rs | 92 + src/modules/graph_out.rs | 10 + src/modules/init_maps.rs | 99 +- src/modules/mod.rs | 7 +- src/pb/eth.erc20.v1.rs | 68 + src/utils.rs | 40 + substreams.yaml | 22 + 12 files changed, 3559 insertions(+), 2650 deletions(-) create mode 100644 src/modules/gns.rs diff --git a/abis/gns.json b/abis/gns.json index b2b06ef..e6824ce 100644 --- a/abis/gns.json +++ b/abis/gns.json @@ -4,33 +4,20 @@ "inputs": [ { "indexed": true, - "internalType": "bytes32", - "name": "nameHash", - "type": "bytes32" - }, - { - "indexed": false, "internalType": "address", - "name": "contractAddress", + "name": "graphAccount", "type": "address" - } - ], - "name": "ContractSynced", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ + }, { "indexed": true, "internalType": "uint256", - "name": "subgraphID", + "name": "subgraphNumber", "type": "uint256" }, { "indexed": true, "internalType": "address", - "name": "curator", + "name": "nameCurator", "type": "address" }, { @@ -59,144 +46,105 @@ "type": "address" }, { - "indexed": false, + "indexed": true, "internalType": "uint256", "name": "subgraphNumber", "type": "uint256" - } - ], - "name": "LegacySubgraphClaimed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "string", - "name": "param", - "type": "string" - } - ], - "name": "ParameterUpdated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "controller", - "type": "address" - } - ], - "name": "SetController", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ + }, { "indexed": true, "internalType": "address", - "name": "graphAccount", + "name": "nameCurator", "type": "address" }, { "indexed": false, "internalType": "uint256", - "name": "nameSystem", + "name": "nSignalBurnt", "type": "uint256" }, { "indexed": false, - "internalType": "bytes32", - "name": "nameIdentifier", - "type": "bytes32" + "internalType": "uint256", + "name": "vSignalBurnt", + "type": "uint256" }, { "indexed": false, - "internalType": "string", - "name": "name", - "type": "string" + "internalType": "uint256", + "name": "tokensReceived", + "type": "uint256" } ], - "name": "SetDefaultName", + "name": "NSignalBurned", "type": "event" }, { "anonymous": false, "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "graphAccount", + "type": "address" + }, { "indexed": true, "internalType": "uint256", - "name": "subgraphID", + "name": "subgraphNumber", "type": "uint256" }, { "indexed": true, "internalType": "address", - "name": "curator", + "name": "nameCurator", "type": "address" }, { "indexed": false, "internalType": "uint256", - "name": "nSignalBurnt", + "name": "nSignalCreated", "type": "uint256" }, { "indexed": false, "internalType": "uint256", - "name": "vSignalBurnt", + "name": "vSignalCreated", "type": "uint256" }, { "indexed": false, "internalType": "uint256", - "name": "tokensReceived", + "name": "tokensDeposited", "type": "uint256" } ], - "name": "SignalBurned", + "name": "NSignalMinted", "type": "event" }, { "anonymous": false, "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "subgraphID", - "type": "uint256" - }, { "indexed": true, "internalType": "address", - "name": "curator", + "name": "graphAccount", "type": "address" }, { - "indexed": false, - "internalType": "uint256", - "name": "nSignalCreated", - "type": "uint256" - }, - { - "indexed": false, + "indexed": true, "internalType": "uint256", - "name": "vSignalCreated", + "name": "subgraphNumber", "type": "uint256" }, { "indexed": false, "internalType": "uint256", - "name": "tokensDeposited", + "name": "withdrawableGRT", "type": "uint256" } ], - "name": "SignalMinted", + "name": "NameSignalDisabled", "type": "event" }, { @@ -204,68 +152,80 @@ "inputs": [ { "indexed": true, - "internalType": "uint256", - "name": "subgraphID", - "type": "uint256" + "internalType": "address", + "name": "graphAccount", + "type": "address" }, { "indexed": true, - "internalType": "address", - "name": "from", - "type": "address" + "internalType": "uint256", + "name": "subgraphNumber", + "type": "uint256" }, { "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" + "internalType": "bytes32", + "name": "subgraphDeploymentID", + "type": "bytes32" }, { "indexed": false, - "internalType": "uint256", - "name": "nSignalTransferred", - "type": "uint256" + "internalType": "uint32", + "name": "reserveRatio", + "type": "uint32" } ], - "name": "SignalTransferred", + "name": "NameSignalEnabled", "type": "event" }, { "anonymous": false, "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "graphAccount", + "type": "address" + }, { "indexed": true, "internalType": "uint256", - "name": "subgraphID", + "name": "subgraphNumber", "type": "uint256" }, { "indexed": false, "internalType": "uint256", - "name": "withdrawableGRT", + "name": "newVSignalCreated", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensSignalled", "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "subgraphDeploymentID", + "type": "bytes32" } ], - "name": "SubgraphDeprecated", + "name": "NameSignalUpgrade", "type": "event" }, { "anonymous": false, "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "subgraphID", - "type": "uint256" - }, { "indexed": false, - "internalType": "bytes32", - "name": "subgraphMetadata", - "type": "bytes32" + "internalType": "string", + "name": "param", + "type": "string" } ], - "name": "SubgraphMetadataUpdated", + "name": "ParameterUpdated", "type": "event" }, { @@ -274,11 +234,11 @@ { "indexed": false, "internalType": "address", - "name": "subgraphNFT", + "name": "controller", "type": "address" } ], - "name": "SubgraphNFTUpdated", + "name": "SetController", "type": "event" }, { @@ -286,24 +246,30 @@ "inputs": [ { "indexed": true, + "internalType": "address", + "name": "graphAccount", + "type": "address" + }, + { + "indexed": false, "internalType": "uint256", - "name": "subgraphID", + "name": "nameSystem", "type": "uint256" }, { - "indexed": true, + "indexed": false, "internalType": "bytes32", - "name": "subgraphDeploymentID", + "name": "nameIdentifier", "type": "bytes32" }, { "indexed": false, - "internalType": "uint32", - "name": "reserveRatio", - "type": "uint32" + "internalType": "string", + "name": "name", + "type": "string" } ], - "name": "SubgraphPublished", + "name": "SetDefaultName", "type": "event" }, { @@ -311,39 +277,58 @@ "inputs": [ { "indexed": true, - "internalType": "uint256", - "name": "subgraphID", - "type": "uint256" + "internalType": "address", + "name": "graphAccount", + "type": "address" }, { - "indexed": false, + "indexed": true, "internalType": "uint256", - "name": "vSignalCreated", + "name": "subgraphNumber", "type": "uint256" + } + ], + "name": "SubgraphDeprecated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "graphAccount", + "type": "address" }, { - "indexed": false, + "indexed": true, "internalType": "uint256", - "name": "tokensSignalled", + "name": "subgraphNumber", "type": "uint256" }, { - "indexed": true, + "indexed": false, "internalType": "bytes32", - "name": "subgraphDeploymentID", + "name": "subgraphMetadata", "type": "bytes32" } ], - "name": "SubgraphUpgraded", + "name": "SubgraphMetadataUpdated", "type": "event" }, { "anonymous": false, "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "graphAccount", + "type": "address" + }, { "indexed": true, "internalType": "uint256", - "name": "subgraphID", + "name": "subgraphNumber", "type": "uint256" }, { @@ -359,7 +344,7 @@ "type": "bytes32" } ], - "name": "SubgraphVersionUpdated", + "name": "SubgraphPublished", "type": "event" }, { @@ -393,6 +378,25 @@ "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "addressCache", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, { "inputs": [], "name": "approveAll", @@ -416,11 +420,16 @@ { "inputs": [ { - "internalType": "uint256", - "name": "_subgraphID", - "type": "uint256" - }, - { + "internalType": "address", + "name": "_graphAccount", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_subgraphNumber", + "type": "uint256" + }, + { "internalType": "uint256", "name": "_nSignal", "type": "uint256" @@ -431,7 +440,7 @@ "type": "uint256" } ], - "name": "burnSignal", + "name": "burnNSignal", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -451,9 +460,14 @@ }, { "inputs": [ + { + "internalType": "address", + "name": "_graphAccount", + "type": "address" + }, { "internalType": "uint256", - "name": "_subgraphID", + "name": "_subgraphNumber", "type": "uint256" } ], @@ -463,24 +477,13 @@ "type": "function" }, { - "inputs": [ - { - "internalType": "uint256", - "name": "_subgraphID", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_curator", - "type": "address" - } - ], - "name": "getCuratorSignal", + "inputs": [], + "name": "erc1056Registry", "outputs": [ { - "internalType": "uint256", + "internalType": "contract IEthereumDIDRegistry", "name": "", - "type": "uint256" + "type": "address" } ], "stateMutability": "view", @@ -490,39 +493,26 @@ "inputs": [ { "internalType": "address", - "name": "_controller", + "name": "_graphAccount", "type": "address" }, { - "internalType": "address", - "name": "_bondingCurve", - "type": "address" + "internalType": "uint256", + "name": "_subgraphNumber", + "type": "uint256" }, { "internalType": "address", - "name": "_subgraphNFT", + "name": "_curator", "type": "address" } ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "_subgraphID", - "type": "uint256" - } - ], - "name": "isPublished", + "name": "getCuratorNSignal", "outputs": [ { - "internalType": "bool", + "internalType": "uint256", "name": "", - "type": "bool" + "type": "uint256" } ], "stateMutability": "view", @@ -534,43 +524,13 @@ "internalType": "address", "name": "", "type": "address" - }, - { - "internalType": "uint256", - "name": "", - "type": "uint256" } ], - "name": "legacySubgraphData", + "name": "graphAccountSubgraphNumbers", "outputs": [ { "internalType": "uint256", - "name": "vSignal", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "nSignal", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "subgraphDeploymentID", - "type": "bytes32" - }, - { - "internalType": "uint32", - "name": "reserveRatio", - "type": "uint32" - }, - { - "internalType": "bool", - "name": "disabled", - "type": "bool" - }, - { - "internalType": "uint256", - "name": "withdrawableGRT", + "name": "", "type": "uint256" } ], @@ -580,25 +540,24 @@ { "inputs": [ { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "legacySubgraphKeys", - "outputs": [ + "internalType": "address", + "name": "_controller", + "type": "address" + }, { "internalType": "address", - "name": "account", + "name": "_bondingCurve", "type": "address" }, { - "internalType": "uint256", - "name": "accountSeqID", - "type": "uint256" + "internalType": "address", + "name": "_didRegistry", + "type": "address" } ], - "stateMutability": "view", + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", "type": "function" }, { @@ -612,23 +571,29 @@ "internalType": "uint256", "name": "_subgraphNumber", "type": "uint256" - }, + } + ], + "name": "isPublished", + "outputs": [ { - "internalType": "bytes32", - "name": "_subgraphMetadata", - "type": "bytes32" + "internalType": "bool", + "name": "", + "type": "bool" } ], - "name": "migrateLegacySubgraph", - "outputs": [], - "stateMutability": "nonpayable", + "stateMutability": "view", "type": "function" }, { "inputs": [ + { + "internalType": "address", + "name": "_graphAccount", + "type": "address" + }, { "internalType": "uint256", - "name": "_subgraphID", + "name": "_subgraphNumber", "type": "uint256" }, { @@ -642,7 +607,7 @@ "type": "uint256" } ], - "name": "mintSignal", + "name": "mintNSignal", "outputs": [], "stateMutability": "nonpayable", "type": "function" @@ -650,27 +615,13 @@ { "inputs": [ { - "internalType": "bytes[]", - "name": "data", - "type": "bytes[]" - } - ], - "name": "multicall", - "outputs": [ - { - "internalType": "bytes[]", - "name": "results", - "type": "bytes[]" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ + "internalType": "address", + "name": "_graphAccount", + "type": "address" + }, { "internalType": "uint256", - "name": "_subgraphID", + "name": "_subgraphNumber", "type": "uint256" }, { @@ -697,9 +648,14 @@ }, { "inputs": [ + { + "internalType": "address", + "name": "_graphAccount", + "type": "address" + }, { "internalType": "uint256", - "name": "_subgraphID", + "name": "_subgraphNumber", "type": "uint256" }, { @@ -725,33 +681,44 @@ "internalType": "address", "name": "", "type": "address" - } - ], - "name": "nextAccountSeqID", - "outputs": [ + }, { "internalType": "uint256", "name": "", "type": "uint256" } ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ + "name": "nameSignals", + "outputs": [ { "internalType": "uint256", - "name": "_tokenID", + "name": "vSignal", "type": "uint256" - } - ], - "name": "ownerOf", - "outputs": [ + }, { - "internalType": "address", - "name": "", - "type": "address" + "internalType": "uint256", + "name": "nSignal", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "subgraphDeploymentID", + "type": "bytes32" + }, + { + "internalType": "uint32", + "name": "reserveRatio", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "disabled", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "withdrawableGRT", + "type": "uint256" } ], "stateMutability": "view", @@ -772,6 +739,11 @@ }, { "inputs": [ + { + "internalType": "address", + "name": "_graphAccount", + "type": "address" + }, { "internalType": "bytes32", "name": "_subgraphDeploymentID", @@ -795,9 +767,14 @@ }, { "inputs": [ + { + "internalType": "address", + "name": "_graphAccount", + "type": "address" + }, { "internalType": "uint256", - "name": "_subgraphID", + "name": "_subgraphNumber", "type": "uint256" }, { @@ -874,23 +851,21 @@ "inputs": [ { "internalType": "address", - "name": "_subgraphNFT", + "name": "", "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" } ], - "name": "setSubgraphNFT", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "subgraphNFT", + "name": "subgraphs", "outputs": [ { - "internalType": "contract ISubgraphNFT", + "internalType": "bytes32", "name": "", - "type": "address" + "type": "bytes32" } ], "stateMutability": "view", @@ -898,33 +873,34 @@ }, { "inputs": [ + { + "internalType": "address", + "name": "_graphAccount", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_subgraphNumber", + "type": "uint256" + }, { "internalType": "uint256", - "name": "_subgraphID", + "name": "_tokensIn", "type": "uint256" } ], - "name": "subgraphSignal", + "name": "tokensToNSignal", "outputs": [ { "internalType": "uint256", "name": "", "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ + }, { "internalType": "uint256", - "name": "_subgraphID", + "name": "", "type": "uint256" - } - ], - "name": "subgraphTokens", - "outputs": [ + }, { "internalType": "uint256", "name": "", @@ -937,41 +913,49 @@ { "inputs": [ { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "name": "subgraphs", - "outputs": [ + "internalType": "address", + "name": "_graphAccount", + "type": "address" + }, { "internalType": "uint256", - "name": "vSignal", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "nSignal", + "name": "_subgraphNumber", "type": "uint256" }, { "internalType": "bytes32", - "name": "subgraphDeploymentID", + "name": "_subgraphMetadata", "type": "bytes32" - }, + } + ], + "name": "updateSubgraphMetadata", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ { - "internalType": "uint32", - "name": "reserveRatio", - "type": "uint32" + "internalType": "address", + "name": "_graphAccount", + "type": "address" }, { - "internalType": "bool", - "name": "disabled", - "type": "bool" + "internalType": "uint256", + "name": "_subgraphNumber", + "type": "uint256" }, { "internalType": "uint256", - "name": "withdrawableGRT", + "name": "_vSignalIn", + "type": "uint256" + } + ], + "name": "vSignalToNSignal", + "outputs": [ + { + "internalType": "uint256", + "name": "", "type": "uint256" } ], @@ -979,122 +963,308 @@ "type": "function" }, { - "inputs": [], - "name": "syncAllContracts", + "inputs": [ + { + "internalType": "address", + "name": "_graphAccount", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_subgraphNumber", + "type": "uint256" + } + ], + "name": "withdraw", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { + "anonymous": false, "inputs": [ { + "indexed": true, + "internalType": "bytes32", + "name": "nameHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "contractAddress", + "type": "address" + } + ], + "name": "ContractSynced", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "subgraphID", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "curator", + "type": "address" + }, + { + "indexed": false, "internalType": "uint256", - "name": "_subgraphID", + "name": "nSignalBurnt", "type": "uint256" }, { + "indexed": false, "internalType": "uint256", - "name": "_tokensIn", + "name": "withdrawnGRT", "type": "uint256" } ], - "name": "tokensToNSignal", - "outputs": [ + "name": "GRTWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "graphAccount", + "type": "address" + }, { + "indexed": false, "internalType": "uint256", - "name": "", + "name": "subgraphNumber", "type": "uint256" + } + ], + "name": "LegacySubgraphClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "subgraphID", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "curator", + "type": "address" }, { + "indexed": false, "internalType": "uint256", - "name": "", + "name": "nSignalBurnt", "type": "uint256" }, { + "indexed": false, "internalType": "uint256", - "name": "", + "name": "vSignalBurnt", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensReceived", "type": "uint256" } ], - "stateMutability": "view", - "type": "function" + "name": "SignalBurned", + "type": "event" }, { + "anonymous": false, "inputs": [ { + "indexed": true, "internalType": "uint256", - "name": "_subgraphID", + "name": "subgraphID", "type": "uint256" }, { + "indexed": true, "internalType": "address", - "name": "_recipient", + "name": "curator", "type": "address" }, { + "indexed": false, + "internalType": "uint256", + "name": "nSignalCreated", + "type": "uint256" + }, + { + "indexed": false, "internalType": "uint256", - "name": "_amount", + "name": "vSignalCreated", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensDeposited", "type": "uint256" } ], - "name": "transferSignal", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" + "name": "SignalMinted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "subgraphID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "withdrawableGRT", + "type": "uint256" + } + ], + "name": "SubgraphDeprecated", + "type": "event" }, { + "anonymous": false, "inputs": [ { + "indexed": true, "internalType": "uint256", - "name": "_subgraphID", + "name": "subgraphID", "type": "uint256" }, { + "indexed": false, "internalType": "bytes32", - "name": "_subgraphMetadata", + "name": "subgraphMetadata", "type": "bytes32" } ], - "name": "updateSubgraphMetadata", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" + "name": "SubgraphMetadataUpdated", + "type": "event" }, { + "anonymous": false, "inputs": [ { + "indexed": true, "internalType": "uint256", - "name": "_subgraphID", + "name": "subgraphID", "type": "uint256" }, { + "indexed": true, + "internalType": "bytes32", + "name": "subgraphDeploymentID", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint32", + "name": "reserveRatio", + "type": "uint32" + } + ], + "name": "SubgraphPublished", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, "internalType": "uint256", - "name": "_vSignalIn", + "name": "subgraphID", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "vSignalCreated", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "tokensSignalled", "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "subgraphDeploymentID", + "type": "bytes32" } ], - "name": "vSignalToNSignal", - "outputs": [ + "name": "SubgraphUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ { + "indexed": true, "internalType": "uint256", - "name": "", + "name": "subgraphID", "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "subgraphDeploymentID", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "versionMetadata", + "type": "bytes32" } ], - "stateMutability": "view", - "type": "function" + "name": "SubgraphVersionUpdated", + "type": "event" }, { + "anonymous": false, "inputs": [ { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, "internalType": "uint256", - "name": "_subgraphID", + "name": "tokenId", "type": "uint256" } ], - "name": "withdraw", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" + "name": "Transfer", + "type": "event" } ] diff --git a/proto/erc20.proto b/proto/erc20.proto index baf849a..66549b6 100644 --- a/proto/erc20.proto +++ b/proto/erc20.proto @@ -74,6 +74,17 @@ message RewardsDenyListUpdatedEvents { repeated RewardsDenyListUpdated rewards_deny_list_updated_events = 1; } +message SubgraphPublished1Events { + repeated SubgraphPublished1 subgraph_published1_events = 1; +} +message SubgraphPublished2Events { + repeated SubgraphPublished2 subgraph_published2_events = 1; +} + +message SubgraphVersionUpdatedEvents { + repeated SubgraphVersionUpdated subgraph_version_updated_events = 1; +} + message IndexerStakes { repeated IndexerStake indexer_stakes = 1; } @@ -124,6 +135,9 @@ message Events { PartialPauseChangedEvents partial_pause_changed_events = 15; EpochLengthUpdatedEvents epoch_length_updated_events = 16; RewardsDenyListUpdatedEvents rewards_deny_list_updated_events = 17; + SubgraphPublished1Events subgraph_published1_events = 18; + SubgraphPublished2Events subgraph_published2_events = 19; + SubgraphVersionUpdatedEvents subgraph_version_updated_events = 20; } message Transfer { @@ -287,6 +301,31 @@ message RewardsDenyListUpdated { uint64 ordinal = 3; } +message SubgraphPublished1 { + string id = 1; + bytes graph_account = 2; + string subgraph_number = 3; + bytes subgraph_deployment_id = 4; + bytes version_metadata = 5; + uint64 ordinal = 6; +} + +message SubgraphPublished2 { + string id = 1; + string subgraph_id = 2; + bytes subgraph_deployment_id = 3; + string reserve_ratio = 4; + uint64 ordinal = 5; +} + +message SubgraphVersionUpdated { + string id = 1; + string subgraph_id = 2; + bytes subgraph_deployment_id = 3; + bytes version_metadata = 4; + uint64 ordinal = 5; +} + message IndexerStake { string id = 1; bytes indexer = 2; diff --git a/schema.graphql b/schema.graphql index 67ad387..bae272f 100644 --- a/schema.graphql +++ b/schema.graphql @@ -208,3 +208,25 @@ type Epoch @entity { "Total indexing rewards earned in this epoch by delegators" totalDelegatorRewards: BigInt! } + +type Subgraph @entity { + "Subgraph ID - which is derived from the Organization/Individual graph accountID" + id: ID! + "List of all the subgraph versions included the current one" + versions: [SubgraphVersion!]! @derivedFrom(field: "subgraph") + "Version counter" + versionCount: BigInt! +} + +type SubgraphVersion @entity { + "Concatenation of subgraph, subgraph deployment, and version ID" + id: ID! + "Subgraph of this version" + subgraph: Subgraph! + "Subgraph deployment of this version" + subgraphDeployment: SubgraphDeployment! + "Version number" + version: Int! + "Creation timestamp" + createdAt: Int! +} diff --git a/src/abi/gns.rs b/src/abi/gns.rs index 337a8e1..3d9e92d 100644 --- a/src/abi/gns.rs +++ b/src/abi/gns.rs @@ -131,6 +131,120 @@ } } #[derive(Debug, Clone, PartialEq)] + pub struct AddressCache { + pub param0: [u8; 32usize], + } + impl AddressCache { + const METHOD_ID: [u8; 4] = [220u8, 103u8, 90u8, 101u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + param0: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::FixedBytes(self.param0.as_ref().to_vec())], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for AddressCache { + const NAME: &'static str = "addressCache"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for AddressCache { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] pub struct ApproveAll {} impl ApproveAll { const METHOD_ID: [u8; 4] = [56u8, 13u8, 12u8, 8u8]; @@ -257,13 +371,14 @@ } } #[derive(Debug, Clone, PartialEq)] - pub struct BurnSignal { - pub subgraph_id: substreams::scalar::BigInt, + pub struct BurnNSignal { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, pub n_signal: substreams::scalar::BigInt, pub tokens_out_min: substreams::scalar::BigInt, } - impl BurnSignal { - const METHOD_ID: [u8; 4] = [123u8, 209u8, 176u8, 191u8]; + impl BurnNSignal { + const METHOD_ID: [u8; 4] = [25u8, 182u8, 195u8, 54u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -273,6 +388,7 @@ } let mut values = ethabi::decode( &[ + ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), @@ -282,7 +398,14 @@ .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_id: { + graph_account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { let mut v = [0 as u8; 32]; values .pop() @@ -317,9 +440,12 @@ pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.graph_account), + ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { + match self.subgraph_number.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { @@ -367,8 +493,8 @@ } } } - impl substreams_ethereum::Function for BurnSignal { - const NAME: &'static str = "burnSignal"; + impl substreams_ethereum::Function for BurnNSignal { + const NAME: &'static str = "burnNSignal"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -472,10 +598,11 @@ } #[derive(Debug, Clone, PartialEq)] pub struct DeprecateSubgraph { - pub subgraph_id: substreams::scalar::BigInt, + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, } impl DeprecateSubgraph { - const METHOD_ID: [u8; 4] = [86u8, 238u8, 10u8, 133u8]; + const METHOD_ID: [u8; 4] = [79u8, 177u8, 248u8, 108u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -484,13 +611,20 @@ return Err("no data to decode".to_string()); } let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_id: { + graph_account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { let mut v = [0 as u8; 32]; values .pop() @@ -505,9 +639,12 @@ pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.graph_account), + ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { + match self.subgraph_number.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { @@ -546,12 +683,102 @@ } } #[derive(Debug, Clone, PartialEq)] - pub struct GetCuratorSignal { - pub subgraph_id: substreams::scalar::BigInt, + pub struct Erc1056Registry {} + impl Erc1056Registry { + const METHOD_ID: [u8; 4] = [38u8, 46u8, 228u8, 39u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Ok(Self {}) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode(&[]); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result, String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result, String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::Address], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok( + values + .pop() + .expect("one output data should have existed") + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + ) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for Erc1056Registry { + const NAME: &'static str = "erc1056Registry"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable> for Erc1056Registry { + fn output(data: &[u8]) -> Result, String> { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct GetCuratorNSignal { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, pub curator: Vec, } - impl GetCuratorSignal { - const METHOD_ID: [u8; 4] = [24u8, 103u8, 34u8, 250u8]; + impl GetCuratorNSignal { + const METHOD_ID: [u8; 4] = [14u8, 18u8, 193u8, 70u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -560,13 +787,24 @@ return Err("no data to decode".to_string()); } let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize), ethabi::ParamType::Address], + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_id: { + graph_account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { let mut v = [0 as u8; 32]; values .pop() @@ -588,9 +826,12 @@ pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.graph_account), + ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { + match self.subgraph_number.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { @@ -665,8 +906,8 @@ } } } - impl substreams_ethereum::Function for GetCuratorSignal { - const NAME: &'static str = "getCuratorSignal"; + impl substreams_ethereum::Function for GetCuratorNSignal { + const NAME: &'static str = "getCuratorNSignal"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -680,19 +921,17 @@ } } impl substreams_ethereum::rpc::RPCDecodable - for GetCuratorSignal { + for GetCuratorNSignal { fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] - pub struct Initialize { - pub controller: Vec, - pub bonding_curve: Vec, - pub subgraph_nft: Vec, + pub struct GraphAccountSubgraphNumbers { + pub param0: Vec, } - impl Initialize { - const METHOD_ID: [u8; 4] = [192u8, 197u8, 59u8, 139u8]; + impl GraphAccountSubgraphNumbers { + const METHOD_ID: [u8; 4] = [242u8, 240u8, 228u8, 143u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -701,11 +940,126 @@ return Err("no data to decode".to_string()); } let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ethabi::ParamType::Address, - ], + &[ethabi::ParamType::Address], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + param0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ethabi::Token::Address(ethabi::Address::from_slice(&self.param0))], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut v = [0 as u8; 32]; + values + .pop() + .expect("one output data should have existed") + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) + } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + pub fn call(&self, address: Vec) -> Option { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } + } + impl substreams_ethereum::Function for GraphAccountSubgraphNumbers { + const NAME: &'static str = "graphAccountSubgraphNumbers"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::decode(call) + } + fn encode(&self) -> Vec { + self.encode() + } + } + impl substreams_ethereum::rpc::RPCDecodable + for GraphAccountSubgraphNumbers { + fn output(data: &[u8]) -> Result { + Self::output(data) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct Initialize { + pub controller: Vec, + pub bonding_curve: Vec, + pub did_registry: Vec, + } + impl Initialize { + const METHOD_ID: [u8; 4] = [192u8, 197u8, 59u8, 139u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ethabi::ParamType::Address, + ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; @@ -725,7 +1079,7 @@ .expect(INTERNAL_ERR) .as_bytes() .to_vec(), - subgraph_nft: values + did_registry: values .pop() .expect(INTERNAL_ERR) .into_address() @@ -744,7 +1098,7 @@ ethabi::Address::from_slice(&self.bonding_curve), ), ethabi::Token::Address( - ethabi::Address::from_slice(&self.subgraph_nft), + ethabi::Address::from_slice(&self.did_registry), ), ], ); @@ -776,10 +1130,11 @@ } #[derive(Debug, Clone, PartialEq)] pub struct IsPublished { - pub subgraph_id: substreams::scalar::BigInt, + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, } impl IsPublished { - const METHOD_ID: [u8; 4] = [123u8, 21u8, 111u8, 181u8]; + const METHOD_ID: [u8; 4] = [175u8, 196u8, 63u8, 146u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -788,13 +1143,20 @@ return Err("no data to decode".to_string()); } let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_id: { + graph_account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { let mut v = [0 as u8; 32]; values .pop() @@ -809,9 +1171,12 @@ pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.graph_account), + ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { + match self.subgraph_number.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { @@ -900,12 +1265,14 @@ } } #[derive(Debug, Clone, PartialEq)] - pub struct LegacySubgraphData { - pub param0: Vec, - pub param1: substreams::scalar::BigInt, + pub struct MintNSignal { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, + pub tokens_in: substreams::scalar::BigInt, + pub n_signal_out_min: substreams::scalar::BigInt, } - impl LegacySubgraphData { - const METHOD_ID: [u8; 4] = [55u8, 16u8, 101u8, 44u8]; + impl MintNSignal { + const METHOD_ID: [u8; 4] = [91u8, 250u8, 212u8, 218u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -914,20 +1281,45 @@ return Err("no data to decode".to_string()); } let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - param0: values + graph_account: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), - param1: { + subgraph_number: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tokens_in: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + n_signal_out_min: { let mut v = [0 as u8; 32]; values .pop() @@ -943,11 +1335,35 @@ let data = ethabi::encode( &[ ethabi::Token::Address( - ethabi::Address::from_slice(&self.param0), + ethabi::Address::from_slice(&self.graph_account), ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( - match self.param1.clone().to_bytes_be() { + match self.subgraph_number.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.tokens_in.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.n_signal_out_min.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { @@ -964,49 +1380,61 @@ encoded.extend(data); encoded } - pub fn output_call( + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } + } + } + impl substreams_ethereum::Function for MintNSignal { + const NAME: &'static str = "mintNSignal"; + fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + Self::match_call(call) + } + fn decode( call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - [u8; 32usize], - substreams::scalar::BigInt, - bool, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(call.return_data.as_ref()) + ) -> Result { + Self::decode(call) } - pub fn output( - data: &[u8], - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - [u8; 32usize], - substreams::scalar::BigInt, - bool, - substreams::scalar::BigInt, - ), - String, - > { + fn encode(&self) -> Vec { + self.encode() + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct NSignalToTokens { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, + pub n_signal_in: substreams::scalar::BigInt, + } + impl NSignalToTokens { + const METHOD_ID: [u8; 4] = [30u8, 209u8, 56u8, 6u8]; + pub fn decode( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } let mut values = ethabi::decode( &[ + ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), - ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::Uint(32usize), - ethabi::ParamType::Bool, - ethabi::ParamType::Uint(256usize), ], - data.as_ref(), + maybe_data.unwrap(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); - Ok(( - { + Ok(Self { + graph_account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { let mut v = [0 as u8; 32]; values .pop() @@ -1016,7 +1444,7 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - { + n_signal_in: { let mut v = [0 as u8; 32]; values .pop() @@ -1026,16 +1454,69 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, + }) + } + pub fn encode(&self) -> Vec { + let data = ethabi::encode( + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.graph_account), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.subgraph_number.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.n_signal_in.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); + let mut encoded = Vec::with_capacity(4 + data.len()); + encoded.extend(Self::METHOD_ID); + encoded.extend(data); + encoded + } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result< + (substreams::scalar::BigInt, substreams::scalar::BigInt), + String, + > { + Self::output(call.return_data.as_ref()) + } + pub fn output( + data: &[u8], + ) -> Result< + (substreams::scalar::BigInt, substreams::scalar::BigInt), + String, + > { + let mut values = ethabi::decode( + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + values.reverse(); + Ok(( { let mut v = [0 as u8; 32]; values @@ -1046,7 +1527,6 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - values.pop().expect(INTERNAL_ERR).into_bool().expect(INTERNAL_ERR), { let mut v = [0 as u8; 32]; values @@ -1068,16 +1548,7 @@ pub fn call( &self, address: Vec, - ) -> Option< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - [u8; 32usize], - substreams::scalar::BigInt, - bool, - substreams::scalar::BigInt, - ), - > { + ) -> Option<(substreams::scalar::BigInt, substreams::scalar::BigInt)> { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ @@ -1104,8 +1575,8 @@ } } } - impl substreams_ethereum::Function for LegacySubgraphData { - const NAME: &'static str = "legacySubgraphData"; + impl substreams_ethereum::Function for NSignalToTokens { + const NAME: &'static str = "nSignalToTokens"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -1119,37 +1590,25 @@ } } impl substreams_ethereum::rpc::RPCDecodable< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - [u8; 32usize], - substreams::scalar::BigInt, - bool, - substreams::scalar::BigInt, - ), - > for LegacySubgraphData { + (substreams::scalar::BigInt, substreams::scalar::BigInt), + > for NSignalToTokens { fn output( data: &[u8], ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - [u8; 32usize], - substreams::scalar::BigInt, - bool, - substreams::scalar::BigInt, - ), + (substreams::scalar::BigInt, substreams::scalar::BigInt), String, > { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] - pub struct LegacySubgraphKeys { - pub param0: substreams::scalar::BigInt, + pub struct NSignalToVSignal { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, + pub n_signal_in: substreams::scalar::BigInt, } - impl LegacySubgraphKeys { - const METHOD_ID: [u8; 4] = [76u8, 169u8, 78u8, 213u8]; + impl NSignalToVSignal { + const METHOD_ID: [u8; 4] = [212u8, 148u8, 240u8, 222u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -1158,13 +1617,34 @@ return Err("no data to decode".to_string()); } let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - param0: { + graph_account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + n_signal_in: { let mut v = [0 as u8; 32]; values .pop() @@ -1179,9 +1659,24 @@ pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.graph_account), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.subgraph_number.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( - match self.param0.clone().to_bytes_be() { + match self.n_signal_in.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { @@ -1200,37 +1695,25 @@ } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result<(Vec, substreams::scalar::BigInt), String> { + ) -> Result { Self::output(call.return_data.as_ref()) } - pub fn output( - data: &[u8], - ) -> Result<(Vec, substreams::scalar::BigInt), String> { + pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( - &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], + &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; - values.reverse(); - Ok(( + Ok({ + let mut v = [0 as u8; 32]; values .pop() + .expect("one output data should have existed") + .into_uint() .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - )) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { @@ -1238,10 +1721,7 @@ None => false, } } - pub fn call( - &self, - address: Vec, - ) -> Option<(Vec, substreams::scalar::BigInt)> { + pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ @@ -1268,8 +1748,8 @@ } } } - impl substreams_ethereum::Function for LegacySubgraphKeys { - const NAME: &'static str = "legacySubgraphKeys"; + impl substreams_ethereum::Function for NSignalToVSignal { + const NAME: &'static str = "nSignalToVSignal"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -1282,23 +1762,19 @@ self.encode() } } - impl substreams_ethereum::rpc::RPCDecodable< - (Vec, substreams::scalar::BigInt), - > for LegacySubgraphKeys { - fn output( - data: &[u8], - ) -> Result<(Vec, substreams::scalar::BigInt), String> { + impl substreams_ethereum::rpc::RPCDecodable + for NSignalToVSignal { + fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] - pub struct MigrateLegacySubgraph { - pub graph_account: Vec, - pub subgraph_number: substreams::scalar::BigInt, - pub subgraph_metadata: [u8; 32usize], + pub struct NameSignals { + pub param0: Vec, + pub param1: substreams::scalar::BigInt, } - impl MigrateLegacySubgraph { - const METHOD_ID: [u8; 4] = [178u8, 47u8, 244u8, 232u8]; + impl NameSignals { + const METHOD_ID: [u8; 4] = [233u8, 248u8, 163u8, 231u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -1307,24 +1783,20 @@ return Err("no data to decode".to_string()); } let mut values = ethabi::decode( - &[ - ethabi::ParamType::Address, - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::FixedBytes(32usize), - ], + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - graph_account: values + param0: values .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), - subgraph_number: { + param1: { let mut v = [0 as u8; 32]; values .pop() @@ -1334,27 +1806,17 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - subgraph_metadata: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ ethabi::Token::Address( - ethabi::Address::from_slice(&self.graph_account), + ethabi::Address::from_slice(&self.param0), ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( - match self.subgraph_number.clone().to_bytes_be() { + match self.param1.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { @@ -1364,9 +1826,6 @@ .as_slice(), ), ), - ethabi::Token::FixedBytes( - self.subgraph_metadata.as_ref().to_vec(), - ), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); @@ -1374,54 +1833,49 @@ encoded.extend(data); encoded } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - } - impl substreams_ethereum::Function for MigrateLegacySubgraph { - const NAME: &'static str = "migrateLegacySubgraph"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( + pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + [u8; 32usize], + substreams::scalar::BigInt, + bool, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(call.return_data.as_ref()) } - } - #[derive(Debug, Clone, PartialEq)] - pub struct MintSignal { - pub subgraph_id: substreams::scalar::BigInt, - pub tokens_in: substreams::scalar::BigInt, - pub n_signal_out_min: substreams::scalar::BigInt, - } - impl MintSignal { - const METHOD_ID: [u8; 4] = [216u8, 130u8, 83u8, 134u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } + pub fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + [u8; 32usize], + substreams::scalar::BigInt, + bool, + substreams::scalar::BigInt, + ), + String, + > { let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::Uint(32usize), + ethabi::ParamType::Bool, ethabi::ParamType::Uint(256usize), ], - maybe_data.unwrap(), + data.as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + .map_err(|e| format!("unable to decode output data: {:?}", e))?; values.reverse(); - Ok(Self { - subgraph_id: { + Ok(( + { let mut v = [0 as u8; 32]; values .pop() @@ -1431,7 +1885,7 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - tokens_in: { + { let mut v = [0 as u8; 32]; values .pop() @@ -1441,7 +1895,17 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - n_signal_out_min: { + { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + { let mut v = [0 as u8; 32]; values .pop() @@ -1451,53 +1915,18 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.tokens_in.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.n_signal_out_min.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + values.pop().expect(INTERNAL_ERR).into_bool().expect(INTERNAL_ERR), + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + )) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { @@ -1505,9 +1934,47 @@ None => false, } } + pub fn call( + &self, + address: Vec, + ) -> Option< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + [u8; 32usize], + substreams::scalar::BigInt, + bool, + substreams::scalar::BigInt, + ), + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } } - impl substreams_ethereum::Function for MintSignal { - const NAME: &'static str = "mintSignal"; + impl substreams_ethereum::Function for NameSignals { + const NAME: &'static str = "nameSignals"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -1520,49 +1987,43 @@ self.encode() } } - #[derive(Debug, Clone, PartialEq)] - pub struct Multicall { - pub data: Vec>, + impl substreams_ethereum::rpc::RPCDecodable< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + [u8; 32usize], + substreams::scalar::BigInt, + bool, + substreams::scalar::BigInt, + ), + > for NameSignals { + fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + [u8; 32usize], + substreams::scalar::BigInt, + bool, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(data) + } } - impl Multicall { - const METHOD_ID: [u8; 4] = [172u8, 150u8, 80u8, 216u8]; + #[derive(Debug, Clone, PartialEq)] + pub struct OwnerTaxPercentage {} + impl OwnerTaxPercentage { + const METHOD_ID: [u8; 4] = [66u8, 142u8, 89u8, 54u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Array(Box::new(ethabi::ParamType::Bytes))], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - data: values - .pop() - .expect(INTERNAL_ERR) - .into_array() - .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| inner.into_bytes().expect(INTERNAL_ERR)) - .collect(), - }) + Ok(Self {}) } pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - { - let v = self - .data - .iter() - .map(|inner| ethabi::Token::Bytes(inner.clone())) - .collect(); - ethabi::Token::Array(v) - }, - ], - ); + let data = ethabi::encode(&[]); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); @@ -1570,25 +2031,25 @@ } pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result>, String> { + ) -> Result { Self::output(call.return_data.as_ref()) } - pub fn output(data: &[u8]) -> Result>, String> { + pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( - &[ethabi::ParamType::Array(Box::new(ethabi::ParamType::Bytes))], + &[ethabi::ParamType::Uint(32usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + Ok({ + let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") - .into_array() + .into_uint() .expect(INTERNAL_ERR) - .into_iter() - .map(|inner| inner.into_bytes().expect(INTERNAL_ERR)) - .collect(), - ) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { @@ -1596,7 +2057,7 @@ None => false, } } - pub fn call(&self, address: Vec) -> Option>> { + pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ @@ -1623,8 +2084,8 @@ } } } - impl substreams_ethereum::Function for Multicall { - const NAME: &'static str = "multicall"; + impl substreams_ethereum::Function for OwnerTaxPercentage { + const NAME: &'static str = "ownerTaxPercentage"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -1637,18 +2098,21 @@ self.encode() } } - impl substreams_ethereum::rpc::RPCDecodable>> for Multicall { - fn output(data: &[u8]) -> Result>, String> { + impl substreams_ethereum::rpc::RPCDecodable + for OwnerTaxPercentage { + fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] - pub struct NSignalToTokens { - pub subgraph_id: substreams::scalar::BigInt, - pub n_signal_in: substreams::scalar::BigInt, + pub struct PublishNewSubgraph { + pub graph_account: Vec, + pub subgraph_deployment_id: [u8; 32usize], + pub version_metadata: [u8; 32usize], + pub subgraph_metadata: [u8; 32usize], } - impl NSignalToTokens { - const METHOD_ID: [u8; 4] = [180u8, 63u8, 106u8, 2u8]; + impl PublishNewSubgraph { + const METHOD_ID: [u8; 4] = [22u8, 158u8, 53u8, 164u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -1658,62 +2122,69 @@ } let mut values = ethabi::decode( &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Address, + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::FixedBytes(32usize), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_id: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() + graph_account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_deployment_id: { + let mut result = [0u8; 32]; + let v = values + .pop() .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result }, - n_signal_in: { - let mut v = [0 as u8; 32]; - values + version_metadata: { + let mut result = [0u8; 32]; + let v = values .pop() .expect(INTERNAL_ERR) - .into_uint() + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + subgraph_metadata: { + let mut result = [0u8; 32]; + let v = values + .pop() .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.graph_account), ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.n_signal_in.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::Token::FixedBytes( + self.subgraph_deployment_id.as_ref().to_vec(), + ), + ethabi::Token::FixedBytes( + self.version_metadata.as_ref().to_vec(), + ), + ethabi::Token::FixedBytes( + self.subgraph_metadata.as_ref().to_vec(), ), ], ); @@ -1722,90 +2193,15 @@ encoded.extend(data); encoded } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - values.reverse(); - Ok(( - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - )) - } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } - pub fn call( - &self, - address: Vec, - ) -> Option<(substreams::scalar::BigInt, substreams::scalar::BigInt)> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } } - impl substreams_ethereum::Function for NSignalToTokens { - const NAME: &'static str = "nSignalToTokens"; + impl substreams_ethereum::Function for PublishNewSubgraph { + const NAME: &'static str = "publishNewSubgraph"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -1818,25 +2214,15 @@ self.encode() } } - impl substreams_ethereum::rpc::RPCDecodable< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - > for NSignalToTokens { - fn output( - data: &[u8], - ) -> Result< - (substreams::scalar::BigInt, substreams::scalar::BigInt), - String, - > { - Self::output(data) - } - } #[derive(Debug, Clone, PartialEq)] - pub struct NSignalToVSignal { - pub subgraph_id: substreams::scalar::BigInt, - pub n_signal_in: substreams::scalar::BigInt, + pub struct PublishNewVersion { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, + pub subgraph_deployment_id: [u8; 32usize], + pub version_metadata: [u8; 32usize], } - impl NSignalToVSignal { - const METHOD_ID: [u8; 4] = [212u8, 149u8, 249u8, 167u8]; + impl PublishNewVersion { + const METHOD_ID: [u8; 4] = [210u8, 73u8, 230u8, 30u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -1846,15 +2232,24 @@ } let mut values = ethabi::decode( &[ + ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::FixedBytes(32usize), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_id: { + graph_account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { let mut v = [0 as u8; 32]; values .pop() @@ -1864,36 +2259,37 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - n_signal_in: { - let mut v = [0 as u8; 32]; - values + subgraph_deployment_id: { + let mut result = [0u8; 32]; + let v = values .pop() .expect(INTERNAL_ERR) - .into_uint() + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + version_metadata: { + let mut result = [0u8; 32]; + let v = values + .pop() .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.graph_account), ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( - match self.n_signal_in.clone().to_bytes_be() { + match self.subgraph_number.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { @@ -1903,6 +2299,12 @@ .as_slice(), ), ), + ethabi::Token::FixedBytes( + self.subgraph_deployment_id.as_ref().to_vec(), + ), + ethabi::Token::FixedBytes( + self.version_metadata.as_ref().to_vec(), + ), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); @@ -1910,63 +2312,15 @@ encoded.extend(data); encoded } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut v = [0 as u8; 32]; - values - .pop() - .expect("one output data should have existed") - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }) - } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } } - impl substreams_ethereum::Function for NSignalToVSignal { - const NAME: &'static str = "nSignalToVSignal"; + impl substreams_ethereum::Function for PublishNewVersion { + const NAME: &'static str = "publishNewVersion"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -1979,18 +2333,12 @@ self.encode() } } - impl substreams_ethereum::rpc::RPCDecodable - for NSignalToVSignal { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } #[derive(Debug, Clone, PartialEq)] - pub struct NextAccountSeqId { - pub param0: Vec, + pub struct SetController { + pub controller: Vec, } - impl NextAccountSeqId { - const METHOD_ID: [u8; 4] = [178u8, 35u8, 80u8, 86u8]; + impl SetController { + const METHOD_ID: [u8; 4] = [146u8, 238u8, 254u8, 155u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -2005,7 +2353,7 @@ .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - param0: values + controller: values .pop() .expect(INTERNAL_ERR) .into_address() @@ -2016,70 +2364,26 @@ } pub fn encode(&self) -> Vec { let data = ethabi::encode( - &[ethabi::Token::Address(ethabi::Address::from_slice(&self.param0))], + &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.controller), + ), + ], ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut v = [0 as u8; 32]; - values - .pop() - .expect("one output data should have existed") - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }) - } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } } - impl substreams_ethereum::Function for NextAccountSeqId { - const NAME: &'static str = "nextAccountSeqID"; + impl substreams_ethereum::Function for SetController { + const NAME: &'static str = "setController"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -2092,18 +2396,15 @@ self.encode() } } - impl substreams_ethereum::rpc::RPCDecodable - for NextAccountSeqId { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } #[derive(Debug, Clone, PartialEq)] - pub struct OwnerOf { - pub token_id: substreams::scalar::BigInt, + pub struct SetDefaultName { + pub graph_account: Vec, + pub name_system: substreams::scalar::BigInt, + pub name_identifier: [u8; 32usize], + pub name: String, } - impl OwnerOf { - const METHOD_ID: [u8; 4] = [99u8, 82u8, 33u8, 30u8]; + impl SetDefaultName { + const METHOD_ID: [u8; 4] = [204u8, 45u8, 35u8, 199u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -2112,13 +2413,25 @@ return Err("no data to decode".to_string()); } let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Uint(8usize), + ethabi::ParamType::FixedBytes(32usize), + ethabi::ParamType::String, + ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - token_id: { + graph_account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + name_system: { let mut v = [0 as u8; 32]; values .pop() @@ -2128,14 +2441,32 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, + name_identifier: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + name: values + .pop() + .expect(INTERNAL_ERR) + .into_string() + .expect(INTERNAL_ERR), }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.graph_account), + ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( - match self.token_id.clone().to_bytes_be() { + match self.name_system.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { @@ -2145,6 +2476,10 @@ .as_slice(), ), ), + ethabi::Token::FixedBytes( + self.name_identifier.as_ref().to_vec(), + ), + ethabi::Token::String(self.name.clone()), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); @@ -2152,62 +2487,15 @@ encoded.extend(data); encoded } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( - values - .pop() - .expect("one output data should have existed") - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) - } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } - pub fn call(&self, address: Vec) -> Option> { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } } - impl substreams_ethereum::Function for OwnerOf { - const NAME: &'static str = "ownerOf"; + impl substreams_ethereum::Function for SetDefaultName { + const NAME: &'static str = "setDefaultName"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -2220,84 +2508,69 @@ self.encode() } } - impl substreams_ethereum::rpc::RPCDecodable> for OwnerOf { - fn output(data: &[u8]) -> Result, String> { - Self::output(data) - } - } #[derive(Debug, Clone, PartialEq)] - pub struct OwnerTaxPercentage {} - impl OwnerTaxPercentage { - const METHOD_ID: [u8; 4] = [66u8, 142u8, 89u8, 54u8]; + pub struct SetOwnerTaxPercentage { + pub owner_tax_percentage: substreams::scalar::BigInt, + } + impl SetOwnerTaxPercentage { + const METHOD_ID: [u8; 4] = [183u8, 142u8, 223u8, 112u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { - Ok(Self {}) + let maybe_data = call.input.get(4..); + if maybe_data.is_none() { + return Err("no data to decode".to_string()); + } + let mut values = ethabi::decode( + &[ethabi::ParamType::Uint(32usize)], + maybe_data.unwrap(), + ) + .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + values.reverse(); + Ok(Self { + owner_tax_percentage: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); + let data = ethabi::encode( + &[ + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.owner_tax_percentage.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ], + ); let mut encoded = Vec::with_capacity(4 + data.len()); encoded.extend(Self::METHOD_ID); encoded.extend(data); encoded } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(32usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut v = [0 as u8; 32]; - values - .pop() - .expect("one output data should have existed") - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { + match call.input.get(0..4) { + Some(signature) => Self::METHOD_ID == signature, + None => false, + } } } - impl substreams_ethereum::Function for OwnerTaxPercentage { - const NAME: &'static str = "ownerTaxPercentage"; + impl substreams_ethereum::Function for SetOwnerTaxPercentage { + const NAME: &'static str = "setOwnerTaxPercentage"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -2310,20 +2583,13 @@ self.encode() } } - impl substreams_ethereum::rpc::RPCDecodable - for OwnerTaxPercentage { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } #[derive(Debug, Clone, PartialEq)] - pub struct PublishNewSubgraph { - pub subgraph_deployment_id: [u8; 32usize], - pub version_metadata: [u8; 32usize], - pub subgraph_metadata: [u8; 32usize], + pub struct Subgraphs { + pub param0: Vec, + pub param1: substreams::scalar::BigInt, } - impl PublishNewSubgraph { - const METHOD_ID: [u8; 4] = [123u8, 169u8, 88u8, 98u8]; + impl Subgraphs { + const METHOD_ID: [u8; 4] = [151u8, 95u8, 134u8, 205u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -2332,59 +2598,48 @@ return Err("no data to decode".to_string()); } let mut values = ethabi::decode( - &[ - ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::FixedBytes(32usize), - ], + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_deployment_id: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - version_metadata: { - let mut result = [0u8; 32]; - let v = values + param0: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + param1: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - subgraph_metadata: { - let mut result = [0u8; 32]; - let v = values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ - ethabi::Token::FixedBytes( - self.subgraph_deployment_id.as_ref().to_vec(), - ), - ethabi::Token::FixedBytes( - self.version_metadata.as_ref().to_vec(), + ethabi::Token::Address( + ethabi::Address::from_slice(&self.param0), ), - ethabi::Token::FixedBytes( - self.subgraph_metadata.as_ref().to_vec(), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.param1.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), ), ], ); @@ -2393,15 +2648,63 @@ encoded.extend(data); encoded } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result<[u8; 32usize], String> { + Self::output(call.return_data.as_ref()) + } + pub fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + data.as_ref(), + ) + .map_err(|e| format!("unable to decode output data: {:?}", e))?; + Ok({ + let mut result = [0u8; 32]; + let v = values + .pop() + .expect("one output data should have existed") + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }) + } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } + pub fn call(&self, address: Vec) -> Option<[u8; 32usize]> { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } } - impl substreams_ethereum::Function for PublishNewSubgraph { - const NAME: &'static str = "publishNewSubgraph"; + impl substreams_ethereum::Function for Subgraphs { + const NAME: &'static str = "subgraphs"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -2414,14 +2717,19 @@ self.encode() } } + impl substreams_ethereum::rpc::RPCDecodable<[u8; 32usize]> for Subgraphs { + fn output(data: &[u8]) -> Result<[u8; 32usize], String> { + Self::output(data) + } + } #[derive(Debug, Clone, PartialEq)] - pub struct PublishNewVersion { - pub subgraph_id: substreams::scalar::BigInt, - pub subgraph_deployment_id: [u8; 32usize], - pub version_metadata: [u8; 32usize], + pub struct TokensToNSignal { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, + pub tokens_in: substreams::scalar::BigInt, } - impl PublishNewVersion { - const METHOD_ID: [u8; 4] = [225u8, 50u8, 151u8, 50u8]; + impl TokensToNSignal { + const METHOD_ID: [u8; 4] = [85u8, 164u8, 251u8, 115u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -2431,16 +2739,23 @@ } let mut values = ethabi::decode( &[ + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), - ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::FixedBytes(32usize), ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_id: { + graph_account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { let mut v = [0 as u8; 32]; values .pop() @@ -2450,34 +2765,27 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - subgraph_deployment_id: { - let mut result = [0u8; 32]; - let v = values + tokens_in: { + let mut v = [0 as u8; 32]; + values .pop() .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - version_metadata: { - let mut result = [0u8; 32]; - let v = values - .pop() + .into_uint() .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, }) } pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.graph_account), + ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { + match self.subgraph_number.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { @@ -2487,11 +2795,17 @@ .as_slice(), ), ), - ethabi::Token::FixedBytes( - self.subgraph_deployment_id.as_ref().to_vec(), - ), - ethabi::Token::FixedBytes( - self.version_metadata.as_ref().to_vec(), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.tokens_in.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), ), ], ); @@ -2500,68 +2814,70 @@ encoded.extend(data); encoded } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - } - impl substreams_ethereum::Function for PublishNewVersion { - const NAME: &'static str = "publishNewVersion"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( + pub fn output_call( call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(call.return_data.as_ref()) } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SetController { - pub controller: Vec, - } - impl SetController { - const METHOD_ID: [u8; 4] = [146u8, 238u8, 254u8, 155u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } + pub fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + data.as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + .map_err(|e| format!("unable to decode output data: {:?}", e))?; values.reverse(); - Ok(Self { - controller: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.controller), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + Ok(( + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + )) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { @@ -2569,9 +2885,44 @@ None => false, } } + pub fn call( + &self, + address: Vec, + ) -> Option< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > { + use substreams_ethereum::pb::eth::rpc; + let rpc_calls = rpc::RpcCalls { + calls: vec![ + rpc::RpcCall { to_addr : address, data : self.encode(), } + ], + }; + let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; + let response = responses + .get(0) + .expect("one response should have existed"); + if response.failed { + return None; + } + match Self::output(response.raw.as_ref()) { + Ok(data) => Some(data), + Err(err) => { + use substreams_ethereum::Function; + substreams::log::info!( + "Call output for function `{}` failed to decode with error: {}", + Self::NAME, err + ); + None + } + } + } } - impl substreams_ethereum::Function for SetController { - const NAME: &'static str = "setController"; + impl substreams_ethereum::Function for TokensToNSignal { + const NAME: &'static str = "tokensToNSignal"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -2584,15 +2935,34 @@ self.encode() } } + impl substreams_ethereum::rpc::RPCDecodable< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + > for TokensToNSignal { + fn output( + data: &[u8], + ) -> Result< + ( + substreams::scalar::BigInt, + substreams::scalar::BigInt, + substreams::scalar::BigInt, + ), + String, + > { + Self::output(data) + } + } #[derive(Debug, Clone, PartialEq)] - pub struct SetDefaultName { + pub struct UpdateSubgraphMetadata { pub graph_account: Vec, - pub name_system: substreams::scalar::BigInt, - pub name_identifier: [u8; 32usize], - pub name: String, + pub subgraph_number: substreams::scalar::BigInt, + pub subgraph_metadata: [u8; 32usize], } - impl SetDefaultName { - const METHOD_ID: [u8; 4] = [204u8, 45u8, 35u8, 199u8]; + impl UpdateSubgraphMetadata { + const METHOD_ID: [u8; 4] = [150u8, 22u8, 176u8, 53u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -2603,9 +2973,8 @@ let mut values = ethabi::decode( &[ ethabi::ParamType::Address, - ethabi::ParamType::Uint(8usize), + ethabi::ParamType::Uint(256usize), ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::String, ], maybe_data.unwrap(), ) @@ -2619,7 +2988,7 @@ .expect(INTERNAL_ERR) .as_bytes() .to_vec(), - name_system: { + subgraph_number: { let mut v = [0 as u8; 32]; values .pop() @@ -2629,7 +2998,7 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - name_identifier: { + subgraph_metadata: { let mut result = [0u8; 32]; let v = values .pop() @@ -2639,11 +3008,6 @@ result.copy_from_slice(&v); result }, - name: values - .pop() - .expect(INTERNAL_ERR) - .into_string() - .expect(INTERNAL_ERR), }) } pub fn encode(&self) -> Vec { @@ -2654,7 +3018,7 @@ ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( - match self.name_system.clone().to_bytes_be() { + match self.subgraph_number.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { @@ -2665,9 +3029,8 @@ ), ), ethabi::Token::FixedBytes( - self.name_identifier.as_ref().to_vec(), + self.subgraph_metadata.as_ref().to_vec(), ), - ethabi::Token::String(self.name.clone()), ], ); let mut encoded = Vec::with_capacity(4 + data.len()); @@ -2682,8 +3045,8 @@ } } } - impl substreams_ethereum::Function for SetDefaultName { - const NAME: &'static str = "setDefaultName"; + impl substreams_ethereum::Function for UpdateSubgraphMetadata { + const NAME: &'static str = "updateSubgraphMetadata"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -2697,11 +3060,13 @@ } } #[derive(Debug, Clone, PartialEq)] - pub struct SetOwnerTaxPercentage { - pub owner_tax_percentage: substreams::scalar::BigInt, + pub struct VSignalToNSignal { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, + pub v_signal_in: substreams::scalar::BigInt, } - impl SetOwnerTaxPercentage { - const METHOD_ID: [u8; 4] = [183u8, 142u8, 223u8, 112u8]; + impl VSignalToNSignal { + const METHOD_ID: [u8; 4] = [112u8, 154u8, 125u8, 17u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -2710,13 +3075,34 @@ return Err("no data to decode".to_string()); } let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(32usize)], + &[ + ethabi::ParamType::Address, + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - owner_tax_percentage: { + graph_account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + v_signal_in: { let mut v = [0 as u8; 32]; values .pop() @@ -2731,9 +3117,24 @@ pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.graph_account), + ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( - match self.owner_tax_percentage.clone().to_bytes_be() { + match self.subgraph_number.clone().to_bytes_be() { + (num_bigint::Sign::Plus, bytes) => bytes, + (num_bigint::Sign::NoSign, bytes) => bytes, + (num_bigint::Sign::Minus, _) => { + panic!("negative numbers are not supported") + } + } + .as_slice(), + ), + ), + ethabi::Token::Uint( + ethabi::Uint::from_big_endian( + match self.v_signal_in.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { @@ -2750,126 +3151,27 @@ encoded.extend(data); encoded } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } + pub fn output_call( + call: &substreams_ethereum::pb::eth::v2::Call, + ) -> Result { + Self::output(call.return_data.as_ref()) } - } - impl substreams_ethereum::Function for SetOwnerTaxPercentage { - const NAME: &'static str = "setOwnerTaxPercentage"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SetSubgraphNft { - pub subgraph_nft: Vec, - } - impl SetSubgraphNft { - const METHOD_ID: [u8; 4] = [165u8, 20u8, 63u8, 2u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Address], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - subgraph_nft: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Address( - ethabi::Address::from_slice(&self.subgraph_nft), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - } - impl substreams_ethereum::Function for SetSubgraphNft { - const NAME: &'static str = "setSubgraphNFT"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SubgraphNft {} - impl SubgraphNft { - const METHOD_ID: [u8; 4] = [238u8, 193u8, 107u8, 14u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result, String> { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result, String> { + pub fn output(data: &[u8]) -> Result { let mut values = ethabi::decode( - &[ethabi::ParamType::Address], + &[ethabi::ParamType::Uint(256usize)], data.as_ref(), ) .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok( + Ok({ + let mut v = [0 as u8; 32]; values .pop() .expect("one output data should have existed") - .into_address() + .into_uint() .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - ) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }) } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { @@ -2877,7 +3179,7 @@ None => false, } } - pub fn call(&self, address: Vec) -> Option> { + pub fn call(&self, address: Vec) -> Option { use substreams_ethereum::pb::eth::rpc; let rpc_calls = rpc::RpcCalls { calls: vec![ @@ -2904,8 +3206,8 @@ } } } - impl substreams_ethereum::Function for SubgraphNft { - const NAME: &'static str = "subgraphNFT"; + impl substreams_ethereum::Function for VSignalToNSignal { + const NAME: &'static str = "vSignalToNSignal"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -2918,17 +3220,19 @@ self.encode() } } - impl substreams_ethereum::rpc::RPCDecodable> for SubgraphNft { - fn output(data: &[u8]) -> Result, String> { + impl substreams_ethereum::rpc::RPCDecodable + for VSignalToNSignal { + fn output(data: &[u8]) -> Result { Self::output(data) } } #[derive(Debug, Clone, PartialEq)] - pub struct SubgraphSignal { - pub subgraph_id: substreams::scalar::BigInt, + pub struct Withdraw { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, } - impl SubgraphSignal { - const METHOD_ID: [u8; 4] = [190u8, 143u8, 73u8, 32u8]; + impl Withdraw { + const METHOD_ID: [u8; 4] = [243u8, 254u8, 243u8, 163u8]; pub fn decode( call: &substreams_ethereum::pb::eth::v2::Call, ) -> Result { @@ -2937,13 +3241,20 @@ return Err("no data to decode".to_string()); } let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], + &[ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize)], maybe_data.unwrap(), ) .map_err(|e| format!("unable to decode call.input: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_id: { + graph_account: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { let mut v = [0 as u8; 32]; values .pop() @@ -2958,9 +3269,12 @@ pub fn encode(&self) -> Vec { let data = ethabi::encode( &[ + ethabi::Token::Address( + ethabi::Address::from_slice(&self.graph_account), + ), ethabi::Token::Uint( ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { + match self.subgraph_number.clone().to_bytes_be() { (num_bigint::Sign::Plus, bytes) => bytes, (num_bigint::Sign::NoSign, bytes) => bytes, (num_bigint::Sign::Minus, _) => { @@ -2977,63 +3291,15 @@ encoded.extend(data); encoded } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut v = [0 as u8; 32]; - values - .pop() - .expect("one output data should have existed") - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }) - } pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { match call.input.get(0..4) { Some(signature) => Self::METHOD_ID == signature, None => false, } } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } } - impl substreams_ethereum::Function for SubgraphSignal { - const NAME: &'static str = "subgraphSignal"; + impl substreams_ethereum::Function for Withdraw { + const NAME: &'static str = "withdraw"; fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { Self::match_call(call) } @@ -3046,260 +3312,83 @@ self.encode() } } - impl substreams_ethereum::rpc::RPCDecodable - for SubgraphSignal { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } + } + /// Contract's events. + #[allow(dead_code, unused_imports, unused_variables)] + pub mod events { + use super::INTERNAL_ERR; #[derive(Debug, Clone, PartialEq)] - pub struct SubgraphTokens { - pub subgraph_id: substreams::scalar::BigInt, + pub struct ContractSynced { + pub name_hash: [u8; 32usize], + pub contract_address: Vec, } - impl SubgraphTokens { - const METHOD_ID: [u8; 4] = [77u8, 190u8, 207u8, 47u8]; + impl ContractSynced { + const TOPIC_ID: [u8; 32] = [ + 208u8, + 231u8, + 169u8, + 66u8, + 177u8, + 252u8, + 56u8, + 196u8, + 17u8, + 196u8, + 245u8, + 61u8, + 21u8, + 59u8, + 161u8, + 79u8, + 210u8, + 69u8, + 66u8, + 166u8, + 163u8, + 94u8, + 186u8, + 205u8, + 155u8, + 106u8, + 252u8, + 161u8, + 161u8, + 84u8, + 226u8, + 6u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, + log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), + &[ethabi::ParamType::Address], + log.data.as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_id: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut v = [0 as u8; 32]; - values - .pop() - .expect("one output data should have existed") - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for SubgraphTokens { - const NAME: &'static str = "subgraphTokens"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for SubgraphTokens { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Subgraphs { - pub param0: substreams::scalar::BigInt, - } - impl Subgraphs { - const METHOD_ID: [u8; 4] = [106u8, 70u8, 74u8, 194u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - param0: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.param0.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - [u8; 32usize], - substreams::scalar::BigInt, - bool, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(call.return_data.as_ref()) - } - pub fn output( - data: &[u8], - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - [u8; 32usize], - substreams::scalar::BigInt, - bool, - substreams::scalar::BigInt, - ), - String, - > { - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::FixedBytes(32usize), - ethabi::ParamType::Uint(32usize), - ethabi::ParamType::Bool, - ethabi::ParamType::Uint(256usize), - ], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - values.reverse(); - Ok(( - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - { + name_hash: { let mut result = [0u8; 32]; - let v = values + let v = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'name_hash' from topic of type 'bytes32': {:?}", + e + ) + })? .pop() .expect(INTERNAL_ERR) .into_fixed_bytes() @@ -3307,267 +3396,121 @@ result.copy_from_slice(&v); result }, - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - values.pop().expect(INTERNAL_ERR).into_bool().expect(INTERNAL_ERR), - { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call( - &self, - address: Vec, - ) -> Option< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - [u8; 32usize], - substreams::scalar::BigInt, - bool, - substreams::scalar::BigInt, - ), - > { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } - } - } - impl substreams_ethereum::Function for Subgraphs { - const NAME: &'static str = "subgraphs"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - [u8; 32usize], - substreams::scalar::BigInt, - bool, - substreams::scalar::BigInt, - ), - > for Subgraphs { - fn output( - data: &[u8], - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - [u8; 32usize], - substreams::scalar::BigInt, - bool, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct SyncAllContracts {} - impl SyncAllContracts { - const METHOD_ID: [u8; 4] = [214u8, 134u8, 110u8, 165u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Ok(Self {}) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode(&[]); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - } - impl substreams_ethereum::Function for SyncAllContracts { - const NAME: &'static str = "syncAllContracts"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TokensToNSignal { - pub subgraph_id: substreams::scalar::BigInt, - pub tokens_in: substreams::scalar::BigInt, - } - impl TokensToNSignal { - const METHOD_ID: [u8; 4] = [83u8, 246u8, 21u8, 201u8]; - pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } - let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], - maybe_data.unwrap(), - ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; - values.reverse(); - Ok(Self { - subgraph_id: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - tokens_in: { - let mut v = [0 as u8; 32]; - values - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, + contract_address: values + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.tokens_in.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded + } + impl substreams_ethereum::Event for ContractSynced { + const NAME: &'static str = "ContractSynced"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(call.return_data.as_ref()) + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) } - pub fn output( - data: &[u8], - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { + } + #[derive(Debug, Clone, PartialEq)] + pub struct GrtWithdrawn1 { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, + pub name_curator: Vec, + pub n_signal_burnt: substreams::scalar::BigInt, + pub withdrawn_grt: substreams::scalar::BigInt, + } + impl GrtWithdrawn1 { + const TOPIC_ID: [u8; 32] = [ + 82u8, + 206u8, + 162u8, + 88u8, + 86u8, + 64u8, + 215u8, + 217u8, + 187u8, + 107u8, + 249u8, + 112u8, + 216u8, + 109u8, + 93u8, + 246u8, + 158u8, + 179u8, + 57u8, + 170u8, + 157u8, + 82u8, + 252u8, + 145u8, + 203u8, + 10u8, + 193u8, + 169u8, + 41u8, + 252u8, + 67u8, + 240u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 4usize { + return false; + } + if log.data.len() != 64usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), ], - data.as_ref(), + log.data.as_ref(), ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); - Ok(( - { + Ok(Self { + graph_account: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'graph_account' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { let mut v = [0 as u8; 32]; - values + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'subgraph_number' from topic of type 'uint256': {:?}", + e + ) + })? .pop() .expect(INTERNAL_ERR) .into_uint() @@ -3575,7 +3518,23 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - { + name_curator: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[3usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'name_curator' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + n_signal_burnt: { let mut v = [0 as u8; 32]; values .pop() @@ -3585,7 +3544,7 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - { + withdrawn_grt: { let mut v = [0 as u8; 32]; values .pop() @@ -3595,113 +3554,97 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - )) - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } - pub fn call( - &self, - address: Vec, - ) -> Option< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - > { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } - } + }) } } - impl substreams_ethereum::Function for TokensToNSignal { - const NAME: &'static str = "tokensToNSignal"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + impl substreams_ethereum::Event for GrtWithdrawn1 { + const NAME: &'static str = "GRTWithdrawn1"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, + log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + Self::decode(log) } } - impl substreams_ethereum::rpc::RPCDecodable< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - > for TokensToNSignal { - fn output( - data: &[u8], - ) -> Result< - ( - substreams::scalar::BigInt, - substreams::scalar::BigInt, - substreams::scalar::BigInt, - ), - String, - > { - Self::output(data) + #[derive(Debug, Clone, PartialEq)] + pub struct GrtWithdrawn2 { + pub subgraph_id: substreams::scalar::BigInt, + pub curator: Vec, + pub n_signal_burnt: substreams::scalar::BigInt, + pub withdrawn_grt: substreams::scalar::BigInt, + } + impl GrtWithdrawn2 { + const TOPIC_ID: [u8; 32] = [ + 112u8, + 30u8, + 125u8, + 200u8, + 108u8, + 89u8, + 52u8, + 19u8, + 123u8, + 69u8, + 104u8, + 250u8, + 201u8, + 64u8, + 11u8, + 223u8, + 34u8, + 241u8, + 59u8, + 94u8, + 194u8, + 242u8, + 40u8, + 182u8, + 83u8, + 83u8, + 197u8, + 217u8, + 227u8, + 250u8, + 237u8, + 154u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 64usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; } - } - #[derive(Debug, Clone, PartialEq)] - pub struct TransferSignal { - pub subgraph_id: substreams::scalar::BigInt, - pub recipient: Vec, - pub amount: substreams::scalar::BigInt, - } - impl TransferSignal { - const METHOD_ID: [u8; 4] = [99u8, 189u8, 58u8, 190u8]; pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, + log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Address, ethabi::ParamType::Uint(256usize), ], - maybe_data.unwrap(), + log.data.as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { subgraph_id: { let mut v = [0 as u8; 32]; - values + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'subgraph_id' from topic of type 'uint256': {:?}", + e + ) + })? .pop() .expect(INTERNAL_ERR) .into_uint() @@ -3709,14 +3652,33 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - recipient: values + curator: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'curator' from topic of type 'address': {:?}", + e + ) + })? .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), - amount: { + n_signal_burnt: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + withdrawn_grt: { let mut v = [0 as u8; 32]; values .pop() @@ -3728,89 +3690,95 @@ }, }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Address( - ethabi::Address::from_slice(&self.recipient), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.amount.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } } - impl substreams_ethereum::Function for TransferSignal { - const NAME: &'static str = "transferSignal"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + impl substreams_ethereum::Event for GrtWithdrawn2 { + const NAME: &'static str = "GRTWithdrawn2"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, + log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + Self::decode(log) } } #[derive(Debug, Clone, PartialEq)] - pub struct UpdateSubgraphMetadata { - pub subgraph_id: substreams::scalar::BigInt, - pub subgraph_metadata: [u8; 32usize], + pub struct LegacySubgraphClaimed { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, } - impl UpdateSubgraphMetadata { - const METHOD_ID: [u8; 4] = [217u8, 22u8, 242u8, 119u8]; + impl LegacySubgraphClaimed { + const TOPIC_ID: [u8; 32] = [ + 21u8, + 144u8, + 236u8, + 146u8, + 213u8, + 174u8, + 139u8, + 248u8, + 14u8, + 24u8, + 159u8, + 114u8, + 240u8, + 70u8, + 243u8, + 33u8, + 253u8, + 27u8, + 112u8, + 228u8, + 94u8, + 144u8, + 209u8, + 50u8, + 239u8, + 190u8, + 202u8, + 140u8, + 206u8, + 166u8, + 181u8, + 135u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 2usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, + log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::FixedBytes(32usize), - ], - maybe_data.unwrap(), + &[ethabi::ParamType::Uint(256usize)], + log.data.as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_id: { + graph_account: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'graph_account' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { let mut v = [0 as u8; 32]; values .pop() @@ -3818,91 +3786,142 @@ .into_uint() .expect(INTERNAL_ERR) .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - subgraph_metadata: { - let mut result = [0u8; 32]; - let v = values - .pop() - .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result - }, - }) - } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::FixedBytes( - self.subgraph_metadata.as_ref().to_vec(), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) } } - impl substreams_ethereum::Function for UpdateSubgraphMetadata { - const NAME: &'static str = "updateSubgraphMetadata"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + impl substreams_ethereum::Event for LegacySubgraphClaimed { + const NAME: &'static str = "LegacySubgraphClaimed"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, + log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + Self::decode(log) } } #[derive(Debug, Clone, PartialEq)] - pub struct VSignalToNSignal { - pub subgraph_id: substreams::scalar::BigInt, - pub v_signal_in: substreams::scalar::BigInt, + pub struct NSignalBurned { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, + pub name_curator: Vec, + pub n_signal_burnt: substreams::scalar::BigInt, + pub v_signal_burnt: substreams::scalar::BigInt, + pub tokens_received: substreams::scalar::BigInt, } - impl VSignalToNSignal { - const METHOD_ID: [u8; 4] = [164u8, 154u8, 21u8, 241u8]; + impl NSignalBurned { + const TOPIC_ID: [u8; 32] = [ + 87u8, + 205u8, + 120u8, + 112u8, + 195u8, + 46u8, + 253u8, + 154u8, + 3u8, + 75u8, + 94u8, + 19u8, + 158u8, + 144u8, + 171u8, + 226u8, + 228u8, + 85u8, + 106u8, + 40u8, + 170u8, + 167u8, + 128u8, + 196u8, + 239u8, + 229u8, + 48u8, + 118u8, + 81u8, + 245u8, + 2u8, + 195u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 4usize { + return false; + } + if log.data.len() != 96usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, + log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } let mut values = ethabi::decode( &[ ethabi::ParamType::Uint(256usize), ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), ], - maybe_data.unwrap(), + log.data.as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_id: { + graph_account: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'graph_account' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { + let mut v = [0 as u8; 32]; + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'subgraph_number' from topic of type 'uint256': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + name_curator: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[3usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'name_curator' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + n_signal_burnt: { let mut v = [0 as u8; 32]; values .pop() @@ -3912,7 +3931,17 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - v_signal_in: { + v_signal_burnt: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tokens_received: { let mut v = [0 as u8; 32]; values .pop() @@ -3924,136 +3953,158 @@ }, }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.v_signal_in.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn output_call( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::output(call.return_data.as_ref()) - } - pub fn output(data: &[u8]) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - data.as_ref(), - ) - .map_err(|e| format!("unable to decode output data: {:?}", e))?; - Ok({ - let mut v = [0 as u8; 32]; - values - .pop() - .expect("one output data should have existed") - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }) + } + impl substreams_ethereum::Event for NSignalBurned { + const NAME: &'static str = "NSignalBurned"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) } - pub fn call(&self, address: Vec) -> Option { - use substreams_ethereum::pb::eth::rpc; - let rpc_calls = rpc::RpcCalls { - calls: vec![ - rpc::RpcCall { to_addr : address, data : self.encode(), } - ], - }; - let responses = substreams_ethereum::rpc::eth_call(&rpc_calls).responses; - let response = responses - .get(0) - .expect("one response should have existed"); - if response.failed { - return None; - } - match Self::output(response.raw.as_ref()) { - Ok(data) => Some(data), - Err(err) => { - use substreams_ethereum::Function; - substreams::log::info!( - "Call output for function `{}` failed to decode with error: {}", - Self::NAME, err - ); - None - } + } + #[derive(Debug, Clone, PartialEq)] + pub struct NSignalMinted { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, + pub name_curator: Vec, + pub n_signal_created: substreams::scalar::BigInt, + pub v_signal_created: substreams::scalar::BigInt, + pub tokens_deposited: substreams::scalar::BigInt, + } + impl NSignalMinted { + const TOPIC_ID: [u8; 32] = [ + 168u8, + 70u8, + 139u8, + 77u8, + 215u8, + 49u8, + 227u8, + 17u8, + 171u8, + 87u8, + 194u8, + 54u8, + 1u8, + 77u8, + 39u8, + 164u8, + 40u8, + 14u8, + 212u8, + 76u8, + 250u8, + 89u8, + 8u8, + 189u8, + 133u8, + 91u8, + 179u8, + 71u8, + 133u8, + 153u8, + 85u8, + 239u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 4usize { + return false; } + if log.data.len() != 96usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; } - } - impl substreams_ethereum::Function for VSignalToNSignal { - const NAME: &'static str = "vSignalToNSignal"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) - } - fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, - ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() - } - } - impl substreams_ethereum::rpc::RPCDecodable - for VSignalToNSignal { - fn output(data: &[u8]) -> Result { - Self::output(data) - } - } - #[derive(Debug, Clone, PartialEq)] - pub struct Withdraw { - pub subgraph_id: substreams::scalar::BigInt, - } - impl Withdraw { - const METHOD_ID: [u8; 4] = [46u8, 26u8, 125u8, 77u8]; pub fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, + log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { - let maybe_data = call.input.get(4..); - if maybe_data.is_none() { - return Err("no data to decode".to_string()); - } let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - maybe_data.unwrap(), + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], + log.data.as_ref(), ) - .map_err(|e| format!("unable to decode call.input: {:?}", e))?; + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_id: { + graph_account: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'graph_account' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { + let mut v = [0 as u8; 32]; + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'subgraph_number' from topic of type 'uint256': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + name_curator: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[3usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'name_curator' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + n_signal_created: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + v_signal_created: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tokens_deposited: { let mut v = [0 as u8; 32]; values .pop() @@ -4065,96 +4116,61 @@ }, }) } - pub fn encode(&self) -> Vec { - let data = ethabi::encode( - &[ - ethabi::Token::Uint( - ethabi::Uint::from_big_endian( - match self.subgraph_id.clone().to_bytes_be() { - (num_bigint::Sign::Plus, bytes) => bytes, - (num_bigint::Sign::NoSign, bytes) => bytes, - (num_bigint::Sign::Minus, _) => { - panic!("negative numbers are not supported") - } - } - .as_slice(), - ), - ), - ], - ); - let mut encoded = Vec::with_capacity(4 + data.len()); - encoded.extend(Self::METHOD_ID); - encoded.extend(data); - encoded - } - pub fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - match call.input.get(0..4) { - Some(signature) => Self::METHOD_ID == signature, - None => false, - } - } } - impl substreams_ethereum::Function for Withdraw { - const NAME: &'static str = "withdraw"; - fn match_call(call: &substreams_ethereum::pb::eth::v2::Call) -> bool { - Self::match_call(call) + impl substreams_ethereum::Event for NSignalMinted { + const NAME: &'static str = "NSignalMinted"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) } fn decode( - call: &substreams_ethereum::pb::eth::v2::Call, + log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { - Self::decode(call) - } - fn encode(&self) -> Vec { - self.encode() + Self::decode(log) } } - } - /// Contract's events. - #[allow(dead_code, unused_imports, unused_variables)] - pub mod events { - use super::INTERNAL_ERR; #[derive(Debug, Clone, PartialEq)] - pub struct ContractSynced { - pub name_hash: [u8; 32usize], - pub contract_address: Vec, + pub struct NameSignalDisabled { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, + pub withdrawable_grt: substreams::scalar::BigInt, } - impl ContractSynced { + impl NameSignalDisabled { const TOPIC_ID: [u8; 32] = [ - 208u8, - 231u8, - 169u8, - 66u8, - 177u8, - 252u8, - 56u8, - 196u8, - 17u8, - 196u8, - 245u8, - 61u8, - 21u8, - 59u8, - 161u8, - 79u8, - 210u8, - 69u8, - 66u8, - 166u8, - 163u8, - 94u8, - 186u8, - 205u8, - 155u8, - 106u8, + 70u8, + 2u8, + 154u8, + 215u8, + 47u8, + 134u8, + 41u8, + 234u8, + 41u8, + 68u8, + 65u8, + 138u8, + 151u8, + 99u8, + 152u8, + 122u8, + 225u8, + 105u8, + 164u8, + 109u8, + 220u8, + 171u8, + 113u8, + 191u8, + 220u8, + 222u8, 252u8, - 161u8, - 161u8, - 84u8, - 226u8, - 6u8, + 42u8, + 134u8, + 255u8, + 60u8, + 183u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { + if log.topics.len() != 3usize { return false; } if log.data.len() != 32usize { @@ -4167,43 +4183,62 @@ log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( - &[ethabi::ParamType::Address], + &[ethabi::ParamType::Uint(256usize)], log.data.as_ref(), ) .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { - name_hash: { - let mut result = [0u8; 32]; - let v = ethabi::decode( - &[ethabi::ParamType::FixedBytes(32usize)], - log.topics[1usize].as_ref(), + graph_account: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'graph_account' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { + let mut v = [0 as u8; 32]; + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[2usize].as_ref(), ) .map_err(|e| { format!( - "unable to decode param 'name_hash' from topic of type 'bytes32': {:?}", + "unable to decode param 'subgraph_number' from topic of type 'uint256': {:?}", e ) })? .pop() .expect(INTERNAL_ERR) - .into_fixed_bytes() - .expect(INTERNAL_ERR); - result.copy_from_slice(&v); - result + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + withdrawable_grt: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - contract_address: values - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), }) } } - impl substreams_ethereum::Event for ContractSynced { - const NAME: &'static str = "ContractSynced"; + impl substreams_ethereum::Event for NameSignalDisabled { + const NAME: &'static str = "NameSignalDisabled"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } @@ -4214,52 +4249,52 @@ } } #[derive(Debug, Clone, PartialEq)] - pub struct GrtWithdrawn { - pub subgraph_id: substreams::scalar::BigInt, - pub curator: Vec, - pub n_signal_burnt: substreams::scalar::BigInt, - pub withdrawn_grt: substreams::scalar::BigInt, + pub struct NameSignalEnabled { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, + pub subgraph_deployment_id: [u8; 32usize], + pub reserve_ratio: substreams::scalar::BigInt, } - impl GrtWithdrawn { + impl NameSignalEnabled { const TOPIC_ID: [u8; 32] = [ - 112u8, - 30u8, - 125u8, - 200u8, - 108u8, - 89u8, - 52u8, - 19u8, - 123u8, - 69u8, - 104u8, - 250u8, + 98u8, + 57u8, + 75u8, + 254u8, + 82u8, 201u8, - 64u8, - 11u8, - 223u8, - 34u8, - 241u8, - 59u8, - 94u8, - 194u8, - 242u8, - 40u8, - 182u8, - 83u8, - 83u8, - 197u8, - 217u8, - 227u8, - 250u8, + 33u8, + 87u8, 237u8, - 154u8, + 114u8, + 69u8, + 119u8, + 100u8, + 80u8, + 213u8, + 206u8, + 21u8, + 212u8, + 195u8, + 214u8, + 247u8, + 162u8, + 255u8, + 221u8, + 110u8, + 187u8, + 137u8, + 95u8, + 161u8, + 147u8, + 246u8, + 181u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 3usize { + if log.topics.len() != 4usize { return false; } - if log.data.len() != 64usize { + if log.data.len() != 32usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() @@ -4269,41 +4304,19 @@ log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( - &[ - ethabi::ParamType::Uint(256usize), - ethabi::ParamType::Uint(256usize), - ], + &[ethabi::ParamType::Uint(32usize)], log.data.as_ref(), ) .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_id: { - let mut v = [0 as u8; 32]; - ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'subgraph_id' from topic of type 'uint256': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - curator: ethabi::decode( + graph_account: ethabi::decode( &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), + log.topics[1usize].as_ref(), ) .map_err(|e| { format!( - "unable to decode param 'curator' from topic of type 'address': {:?}", + "unable to decode param 'graph_account' from topic of type 'address': {:?}", e ) })? @@ -4313,9 +4326,18 @@ .expect(INTERNAL_ERR) .as_bytes() .to_vec(), - n_signal_burnt: { + subgraph_number: { let mut v = [0 as u8; 32]; - values + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'subgraph_number' from topic of type 'uint256': {:?}", + e + ) + })? .pop() .expect(INTERNAL_ERR) .into_uint() @@ -4323,7 +4345,26 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - withdrawn_grt: { + subgraph_deployment_id: { + let mut result = [0u8; 32]; + let v = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + log.topics[3usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'subgraph_deployment_id' from topic of type 'bytes32': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + reserve_ratio: { let mut v = [0 as u8; 32]; values .pop() @@ -4336,8 +4377,8 @@ }) } } - impl substreams_ethereum::Event for GrtWithdrawn { - const NAME: &'static str = "GRTWithdrawn"; + impl substreams_ethereum::Event for NameSignalEnabled { + const NAME: &'static str = "NameSignalEnabled"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } @@ -4348,50 +4389,53 @@ } } #[derive(Debug, Clone, PartialEq)] - pub struct LegacySubgraphClaimed { + pub struct NameSignalUpgrade { pub graph_account: Vec, pub subgraph_number: substreams::scalar::BigInt, + pub new_v_signal_created: substreams::scalar::BigInt, + pub tokens_signalled: substreams::scalar::BigInt, + pub subgraph_deployment_id: [u8; 32usize], } - impl LegacySubgraphClaimed { + impl NameSignalUpgrade { const TOPIC_ID: [u8; 32] = [ - 21u8, - 144u8, - 236u8, - 146u8, - 213u8, - 174u8, - 139u8, - 248u8, + 59u8, + 89u8, + 112u8, + 35u8, + 131u8, + 250u8, + 148u8, + 165u8, + 115u8, + 36u8, + 32u8, + 211u8, + 86u8, + 132u8, + 124u8, 14u8, - 24u8, - 159u8, - 114u8, - 240u8, + 150u8, + 143u8, + 179u8, + 179u8, + 35u8, 70u8, - 243u8, - 33u8, - 253u8, - 27u8, - 112u8, - 228u8, - 94u8, - 144u8, - 209u8, - 50u8, - 239u8, - 190u8, - 202u8, - 140u8, 206u8, - 166u8, - 181u8, - 135u8, + 124u8, + 38u8, + 28u8, + 81u8, + 245u8, + 23u8, + 139u8, + 157u8, + 150u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 2usize { + if log.topics.len() != 4usize { return false; } - if log.data.len() != 32usize { + if log.data.len() != 64usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() @@ -4401,7 +4445,10 @@ log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], + &[ + ethabi::ParamType::Uint(256usize), + ethabi::ParamType::Uint(256usize), + ], log.data.as_ref(), ) .map_err(|e| format!("unable to decode log.data: {:?}", e))?; @@ -4416,14 +4463,62 @@ "unable to decode param 'graph_account' from topic of type 'address': {:?}", e ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - subgraph_number: { + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { + let mut v = [0 as u8; 32]; + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'subgraph_number' from topic of type 'uint256': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + subgraph_deployment_id: { + let mut result = [0u8; 32]; + let v = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + log.topics[3usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'subgraph_deployment_id' from topic of type 'bytes32': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + new_v_signal_created: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + tokens_signalled: { let mut v = [0 as u8; 32]; values .pop() @@ -4436,8 +4531,8 @@ }) } } - impl substreams_ethereum::Event for LegacySubgraphClaimed { - const NAME: &'static str = "LegacySubgraphClaimed"; + impl substreams_ethereum::Event for NameSignalUpgrade { + const NAME: &'static str = "NameSignalUpgrade"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } @@ -5019,52 +5114,50 @@ } } #[derive(Debug, Clone, PartialEq)] - pub struct SignalTransferred { - pub subgraph_id: substreams::scalar::BigInt, - pub from: Vec, - pub to: Vec, - pub n_signal_transferred: substreams::scalar::BigInt, + pub struct SubgraphDeprecated1 { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, } - impl SignalTransferred { + impl SubgraphDeprecated1 { const TOPIC_ID: [u8; 32] = [ - 209u8, - 156u8, - 64u8, + 205u8, + 22u8, + 220u8, + 141u8, + 142u8, + 188u8, + 245u8, + 81u8, + 26u8, 91u8, - 192u8, - 76u8, - 70u8, - 152u8, - 148u8, - 244u8, - 119u8, + 50u8, + 64u8, + 71u8, 214u8, - 67u8, - 24u8, - 195u8, - 143u8, - 80u8, - 32u8, - 169u8, - 129u8, - 178u8, - 143u8, - 128u8, - 123u8, - 130u8, - 106u8, - 135u8, - 14u8, - 147u8, - 100u8, - 211u8, - 132u8, + 172u8, + 81u8, + 51u8, + 107u8, + 36u8, + 222u8, + 166u8, + 156u8, + 82u8, + 71u8, + 18u8, + 60u8, + 109u8, + 35u8, + 216u8, + 17u8, + 34u8, + 203u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 4usize { + if log.topics.len() != 3usize { return false; } - if log.data.len() != 32usize { + if log.data.len() != 0usize { return false; } return log.topics.get(0).expect("bounds already checked").as_ref() @@ -5073,55 +5166,14 @@ pub fn decode( log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { - let mut values = ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.data.as_ref(), - ) - .map_err(|e| format!("unable to decode log.data: {:?}", e))?; - values.reverse(); Ok(Self { - subgraph_id: { - let mut v = [0 as u8; 32]; - ethabi::decode( - &[ethabi::ParamType::Uint(256usize)], - log.topics[1usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'subgraph_id' from topic of type 'uint256': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) - }, - from: ethabi::decode( - &[ethabi::ParamType::Address], - log.topics[2usize].as_ref(), - ) - .map_err(|e| { - format!( - "unable to decode param 'from' from topic of type 'address': {:?}", - e - ) - })? - .pop() - .expect(INTERNAL_ERR) - .into_address() - .expect(INTERNAL_ERR) - .as_bytes() - .to_vec(), - to: ethabi::decode( + graph_account: ethabi::decode( &[ethabi::ParamType::Address], - log.topics[3usize].as_ref(), + log.topics[1usize].as_ref(), ) .map_err(|e| { format!( - "unable to decode param 'to' from topic of type 'address': {:?}", + "unable to decode param 'graph_account' from topic of type 'address': {:?}", e ) })? @@ -5131,9 +5183,18 @@ .expect(INTERNAL_ERR) .as_bytes() .to_vec(), - n_signal_transferred: { + subgraph_number: { let mut v = [0 as u8; 32]; - values + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'subgraph_number' from topic of type 'uint256': {:?}", + e + ) + })? .pop() .expect(INTERNAL_ERR) .into_uint() @@ -5144,8 +5205,8 @@ }) } } - impl substreams_ethereum::Event for SignalTransferred { - const NAME: &'static str = "SignalTransferred"; + impl substreams_ethereum::Event for SubgraphDeprecated1 { + const NAME: &'static str = "SubgraphDeprecated1"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } @@ -5156,11 +5217,11 @@ } } #[derive(Debug, Clone, PartialEq)] - pub struct SubgraphDeprecated { + pub struct SubgraphDeprecated2 { pub subgraph_id: substreams::scalar::BigInt, pub withdrawable_grt: substreams::scalar::BigInt, } - impl SubgraphDeprecated { + impl SubgraphDeprecated2 { const TOPIC_ID: [u8; 32] = [ 144u8, 93u8, @@ -5219,11 +5280,131 @@ let mut v = [0 as u8; 32]; ethabi::decode( &[ethabi::ParamType::Uint(256usize)], - log.topics[1usize].as_ref(), + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'subgraph_id' from topic of type 'uint256': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + withdrawable_grt: { + let mut v = [0 as u8; 32]; + values + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for SubgraphDeprecated2 { + const NAME: &'static str = "SubgraphDeprecated2"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } + #[derive(Debug, Clone, PartialEq)] + pub struct SubgraphMetadataUpdated1 { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, + pub subgraph_metadata: [u8; 32usize], + } + impl SubgraphMetadataUpdated1 { + const TOPIC_ID: [u8; 32] = [ + 24u8, + 182u8, + 136u8, + 232u8, + 206u8, + 199u8, + 119u8, + 5u8, + 184u8, + 190u8, + 43u8, + 145u8, + 46u8, + 39u8, + 75u8, + 105u8, + 183u8, + 24u8, + 152u8, + 0u8, + 156u8, + 181u8, + 157u8, + 135u8, + 183u8, + 95u8, + 201u8, + 240u8, + 156u8, + 156u8, + 23u8, + 62u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 3usize { + return false; + } + if log.data.len() != 32usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + let mut values = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + log.data.as_ref(), + ) + .map_err(|e| format!("unable to decode log.data: {:?}", e))?; + values.reverse(); + Ok(Self { + graph_account: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'graph_account' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + subgraph_number: { + let mut v = [0 as u8; 32]; + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[2usize].as_ref(), ) .map_err(|e| { format!( - "unable to decode param 'subgraph_id' from topic of type 'uint256': {:?}", + "unable to decode param 'subgraph_number' from topic of type 'uint256': {:?}", e ) })? @@ -5234,21 +5415,21 @@ .to_big_endian(v.as_mut_slice()); substreams::scalar::BigInt::from_unsigned_bytes_be(&v) }, - withdrawable_grt: { - let mut v = [0 as u8; 32]; - values + subgraph_metadata: { + let mut result = [0u8; 32]; + let v = values .pop() .expect(INTERNAL_ERR) - .into_uint() - .expect(INTERNAL_ERR) - .to_big_endian(v.as_mut_slice()); - substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result }, }) } } - impl substreams_ethereum::Event for SubgraphDeprecated { - const NAME: &'static str = "SubgraphDeprecated"; + impl substreams_ethereum::Event for SubgraphMetadataUpdated1 { + const NAME: &'static str = "SubgraphMetadataUpdated1"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } @@ -5259,11 +5440,11 @@ } } #[derive(Debug, Clone, PartialEq)] - pub struct SubgraphMetadataUpdated { + pub struct SubgraphMetadataUpdated2 { pub subgraph_id: substreams::scalar::BigInt, pub subgraph_metadata: [u8; 32usize], } - impl SubgraphMetadataUpdated { + impl SubgraphMetadataUpdated2 { const TOPIC_ID: [u8; 32] = [ 208u8, 52u8, @@ -5350,8 +5531,8 @@ }) } } - impl substreams_ethereum::Event for SubgraphMetadataUpdated { - const NAME: &'static str = "SubgraphMetadataUpdated"; + impl substreams_ethereum::Event for SubgraphMetadataUpdated2 { + const NAME: &'static str = "SubgraphMetadataUpdated2"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } @@ -5362,46 +5543,49 @@ } } #[derive(Debug, Clone, PartialEq)] - pub struct SubgraphNftUpdated { - pub subgraph_nft: Vec, + pub struct SubgraphPublished1 { + pub graph_account: Vec, + pub subgraph_number: substreams::scalar::BigInt, + pub subgraph_deployment_id: [u8; 32usize], + pub version_metadata: [u8; 32usize], } - impl SubgraphNftUpdated { + impl SubgraphPublished1 { const TOPIC_ID: [u8; 32] = [ - 3u8, - 44u8, - 45u8, - 126u8, - 177u8, - 163u8, - 149u8, - 229u8, - 230u8, - 95u8, - 245u8, - 107u8, - 120u8, - 200u8, - 183u8, - 95u8, - 57u8, - 37u8, - 210u8, - 192u8, - 163u8, - 12u8, - 106u8, - 145u8, - 52u8, - 244u8, + 62u8, + 141u8, + 51u8, + 134u8, + 190u8, + 39u8, + 41u8, + 167u8, 249u8, - 246u8, - 67u8, - 226u8, - 35u8, - 238u8, + 190u8, + 204u8, + 138u8, + 99u8, + 25u8, + 127u8, + 232u8, + 118u8, + 114u8, + 244u8, + 183u8, + 25u8, + 166u8, + 133u8, + 181u8, + 17u8, + 215u8, + 208u8, + 173u8, + 110u8, + 22u8, + 165u8, + 114u8, ]; pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { - if log.topics.len() != 1usize { + if log.topics.len() != 4usize { return false; } if log.data.len() != 32usize { @@ -5414,24 +5598,81 @@ log: &substreams_ethereum::pb::eth::v2::Log, ) -> Result { let mut values = ethabi::decode( - &[ethabi::ParamType::Address], + &[ethabi::ParamType::FixedBytes(32usize)], log.data.as_ref(), ) .map_err(|e| format!("unable to decode log.data: {:?}", e))?; values.reverse(); Ok(Self { - subgraph_nft: values + graph_account: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'graph_account' from topic of type 'address': {:?}", + e + ) + })? .pop() .expect(INTERNAL_ERR) .into_address() .expect(INTERNAL_ERR) .as_bytes() .to_vec(), + subgraph_number: { + let mut v = [0 as u8; 32]; + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'subgraph_number' from topic of type 'uint256': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + subgraph_deployment_id: { + let mut result = [0u8; 32]; + let v = ethabi::decode( + &[ethabi::ParamType::FixedBytes(32usize)], + log.topics[3usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'subgraph_deployment_id' from topic of type 'bytes32': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, + version_metadata: { + let mut result = [0u8; 32]; + let v = values + .pop() + .expect(INTERNAL_ERR) + .into_fixed_bytes() + .expect(INTERNAL_ERR); + result.copy_from_slice(&v); + result + }, }) } } - impl substreams_ethereum::Event for SubgraphNftUpdated { - const NAME: &'static str = "SubgraphNFTUpdated"; + impl substreams_ethereum::Event for SubgraphPublished1 { + const NAME: &'static str = "SubgraphPublished1"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } @@ -5442,12 +5683,12 @@ } } #[derive(Debug, Clone, PartialEq)] - pub struct SubgraphPublished { + pub struct SubgraphPublished2 { pub subgraph_id: substreams::scalar::BigInt, pub subgraph_deployment_id: [u8; 32usize], pub reserve_ratio: substreams::scalar::BigInt, } - impl SubgraphPublished { + impl SubgraphPublished2 { const TOPIC_ID: [u8; 32] = [ 66u8, 165u8, @@ -5553,8 +5794,8 @@ }) } } - impl substreams_ethereum::Event for SubgraphPublished { - const NAME: &'static str = "SubgraphPublished"; + impl substreams_ethereum::Event for SubgraphPublished2 { + const NAME: &'static str = "SubgraphPublished2"; fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { Self::match_log(log) } @@ -5824,4 +6065,124 @@ Self::decode(log) } } + #[derive(Debug, Clone, PartialEq)] + pub struct Transfer { + pub from: Vec, + pub to: Vec, + pub token_id: substreams::scalar::BigInt, + } + impl Transfer { + const TOPIC_ID: [u8; 32] = [ + 221u8, + 242u8, + 82u8, + 173u8, + 27u8, + 226u8, + 200u8, + 155u8, + 105u8, + 194u8, + 176u8, + 104u8, + 252u8, + 55u8, + 141u8, + 170u8, + 149u8, + 43u8, + 167u8, + 241u8, + 99u8, + 196u8, + 161u8, + 22u8, + 40u8, + 245u8, + 90u8, + 77u8, + 245u8, + 35u8, + 179u8, + 239u8, + ]; + pub fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + if log.topics.len() != 4usize { + return false; + } + if log.data.len() != 0usize { + return false; + } + return log.topics.get(0).expect("bounds already checked").as_ref() + == Self::TOPIC_ID; + } + pub fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Ok(Self { + from: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[1usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'from' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + to: ethabi::decode( + &[ethabi::ParamType::Address], + log.topics[2usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'to' from topic of type 'address': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_address() + .expect(INTERNAL_ERR) + .as_bytes() + .to_vec(), + token_id: { + let mut v = [0 as u8; 32]; + ethabi::decode( + &[ethabi::ParamType::Uint(256usize)], + log.topics[3usize].as_ref(), + ) + .map_err(|e| { + format!( + "unable to decode param 'token_id' from topic of type 'uint256': {:?}", + e + ) + })? + .pop() + .expect(INTERNAL_ERR) + .into_uint() + .expect(INTERNAL_ERR) + .to_big_endian(v.as_mut_slice()); + substreams::scalar::BigInt::from_unsigned_bytes_be(&v) + }, + }) + } + } + impl substreams_ethereum::Event for Transfer { + const NAME: &'static str = "Transfer"; + fn match_log(log: &substreams_ethereum::pb::eth::v2::Log) -> bool { + Self::match_log(log) + } + fn decode( + log: &substreams_ethereum::pb::eth::v2::Log, + ) -> Result { + Self::decode(log) + } + } } \ No newline at end of file diff --git a/src/db.rs b/src/db.rs index be6b34e..ace8cd1 100644 --- a/src/db.rs +++ b/src/db.rs @@ -611,3 +611,44 @@ pub fn epoch_change( .change(name, delta.new_value.to_string()); } } + +pub fn subgraph_change( + version_count_deltas: Deltas, + entity_changes: &mut EntityChanges, +) { + for delta in version_count_deltas.deltas { + entity_changes + .push_change( + "Subgraph", + &delta.key, + delta.ordinal, + Operation::Update, // Update will create the entity if it does not exist + ) + .change("versionCount", delta); + } +} + +pub fn version_change(version_deltas: Deltas, entity_changes: &mut EntityChanges) { + for delta in version_deltas.deltas { + entity_changes + .push_change( + "Subgraph", + &delta.key, + delta.ordinal, + Operation::Update, // Update will create the entity if it does not exist + ) + .change( + "subgraph", + &delta.key.as_str().split(":").nth(0).unwrap().to_string(), + ) + .change( + "subgraphDeployment", + &delta.key.as_str().split(":").nth(1).unwrap().to_string(), + ) + .change( + "version", + &delta.key.as_str().split(":").nth(2).unwrap().to_string(), + ) + .change("createdAt", delta); + } +} diff --git a/src/modules/gns.rs b/src/modules/gns.rs new file mode 100644 index 0000000..d3821a2 --- /dev/null +++ b/src/modules/gns.rs @@ -0,0 +1,92 @@ +use crate::pb::erc20::*; +use crate::utils; +use substreams::pb::substreams::Clock; +use substreams::prelude::*; +use substreams::scalar::BigInt; +use substreams::store::StoreAddBigInt; +use substreams::Hex; + +#[substreams::handlers::store] +fn store_version_count(events: Events, s: StoreAddBigInt) { + let subgraph_version_updated_events = events.subgraph_version_updated_events.unwrap(); + let subgraph_published1_events = events.subgraph_published1_events.unwrap(); + let subgraph_published2_events = events.subgraph_published2_events.unwrap(); + for subgraph_published1 in subgraph_published1_events.subgraph_published1_events { + s.add( + subgraph_published1.ordinal, + utils::get_subgraph_id( + &Hex(&subgraph_published1.graph_account).to_string(), + &subgraph_published1.subgraph_number, + ), + BigInt::one(), + ); + } + for subgraph_published2 in subgraph_published2_events.subgraph_published2_events { + s.add( + subgraph_published2.ordinal, + &subgraph_published2.subgraph_id, + BigInt::one(), + ); + } + for subgraph_version_updated in subgraph_version_updated_events.subgraph_version_updated_events + { + s.add( + subgraph_version_updated.ordinal, + &subgraph_version_updated.subgraph_id, + BigInt::one(), + ); + } +} +#[substreams::handlers::store] +fn store_version(events: Events, version_count: StoreGetBigInt, clock: Clock, s: StoreSetString) { + let subgraph_version_updated_events = events.subgraph_version_updated_events.unwrap(); + let subgraph_published1_events = events.subgraph_published1_events.unwrap(); + let subgraph_published2_events = events.subgraph_published2_events.unwrap(); + for subgraph_published1 in subgraph_published1_events.subgraph_published1_events { + let subgraph_id = utils::get_subgraph_id( + &Hex(&subgraph_published1.graph_account).to_string(), + &subgraph_published1.subgraph_number, + ); + let version_count = version_count.get_at(subgraph_published1.ordinal, &subgraph_id); + s.set( + subgraph_published1.ordinal, + utils::generate_version_id( + subgraph_id, + Hex(&subgraph_published1.subgraph_deployment_id).to_string(), + (&version_count.unwrap()).into(), + ), + &clock.timestamp.clone().unwrap().to_string(), + ); + } + for subgraph_published2 in subgraph_published2_events.subgraph_published2_events { + let version_count = version_count.get_at( + subgraph_published2.ordinal, + &subgraph_published2.subgraph_id, + ); + s.set( + subgraph_published2.ordinal, + utils::generate_version_id( + Hex(&subgraph_published2.subgraph_id).to_string(), + Hex(&subgraph_published2.subgraph_deployment_id).to_string(), + (&version_count.unwrap()).into(), + ), + &clock.timestamp.clone().unwrap().to_string(), + ); + } + for subgraph_version_updated in subgraph_version_updated_events.subgraph_version_updated_events + { + let version_count = version_count.get_at( + subgraph_version_updated.ordinal, + &subgraph_version_updated.subgraph_id, + ); + s.set( + subgraph_version_updated.ordinal, + utils::generate_version_id( + Hex(&subgraph_version_updated.subgraph_id).to_string(), + Hex(&subgraph_version_updated.subgraph_deployment_id).to_string(), + (&version_count.unwrap()).into(), + ), + &clock.timestamp.clone().unwrap().to_string(), + ); + } +} diff --git a/src/modules/graph_out.rs b/src/modules/graph_out.rs index ca990c6..abd82c3 100644 --- a/src/modules/graph_out.rs +++ b/src/modules/graph_out.rs @@ -41,6 +41,8 @@ pub fn graph_out( subgraph_deployment_rewards_deltas: Deltas, subgraph_deployment_ipfs_hash_deltas: Deltas, indexing_rewards: IndexingRewards, + version_count_deltas: Deltas, + version_deltas: Deltas, ) -> Result { let mut graph_network_entity_changes: EntityChanges = Default::default(); db::graph_network_change( @@ -127,6 +129,12 @@ pub fn graph_out( &mut epoch_changes, ); + let mut subgraph_changes: EntityChanges = Default::default(); + db::subgraph_change(version_count_deltas, &mut subgraph_changes); + + let mut version_changes: EntityChanges = Default::default(); + db::version_change(version_deltas, &mut version_changes); + Ok(EntityChanges { entity_changes: [ graph_network_entity_changes.entity_changes, @@ -139,6 +147,8 @@ pub fn graph_out( query_fee_rebate_changes.entity_changes, query_fee_changes.entity_changes, epoch_changes.entity_changes, + subgraph_changes.entity_changes, + version_changes.entity_changes, ] .concat(), }) diff --git a/src/modules/init_maps.rs b/src/modules/init_maps.rs index 00f1ecd..410fa08 100644 --- a/src/modules/init_maps.rs +++ b/src/modules/init_maps.rs @@ -240,7 +240,7 @@ fn map_storage_changes(blk: eth::Block) -> Result { } } } - if let Some(event) = abi::gns::events::SubgraphPublished::match_and_decode(&log) { + if let Some(event) = abi::gns::events::SubgraphPublished2::match_and_decode(&log) { for storage_change in &call_view.call.storage_changes { if storage_change.address.eq(&STAKING_CONTRACT) { if storage_change.key @@ -327,10 +327,13 @@ fn map_events(blk: eth::Block) -> Result { let mut allocation_created_events = vec![]; let mut allocation_closed_events = vec![]; let mut allocation_collected_events = vec![]; - let mut pause_changed_events = vec![]; - let mut partial_pause_changed_events = vec![]; + let mut paused_changed_events = vec![]; + let mut partial_paused_changed_events = vec![]; let mut epoch_length_updated_events = vec![]; let mut rewards_deny_list_updated_events = vec![]; + let mut subgraph_published1_events = vec![]; + let mut subgraph_published2_events = vec![]; + let mut subgraph_version_updated_events = vec![]; // Potentially consider adding log.index() to the IDs, to have them be truly unique in // transactions with potentially more than 1 of these messages @@ -495,7 +498,7 @@ fn map_events(blk: eth::Block) -> Result { ordinal: log.ordinal() as u64, }); } else if let Some(event) = abi::controller::events::PauseChanged::match_and_decode(log) { - pause_changed_events.push(PauseChanged { + paused_changed_events.push(PauseChanged { id: Hex(&log.receipt.transaction.hash).to_string(), is_paused: event.is_paused, ordinal: log.ordinal() as u64, @@ -503,7 +506,7 @@ fn map_events(blk: eth::Block) -> Result { } else if let Some(event) = abi::controller::events::PartialPauseChanged::match_and_decode(log) { - partial_pause_changed_events.push(PartialPauseChanged { + partial_paused_changed_events.push(PartialPauseChanged { id: Hex(&log.receipt.transaction.hash).to_string(), is_paused: event.is_paused, ordinal: log.ordinal() as u64, @@ -517,6 +520,43 @@ fn map_events(blk: eth::Block) -> Result { epoch_length: event.epoch_length.to_string(), ordinal: log.ordinal() as u64, }) + } else if let Some(event) = abi::gns::events::SubgraphPublished1::match_and_decode(log) { + subgraph_published1_events.push(SubgraphPublished1 { + id: Hex(&log.receipt.transaction.hash).to_string(), + graph_account: event.graph_account.to_vec(), + subgraph_number: event.subgraph_number.to_string(), + subgraph_deployment_id: event.subgraph_deployment_id.to_vec(), + version_metadata: event.version_metadata.to_vec(), + ordinal: log.ordinal() as u64, + }) + } + } + + for trx in blk.transactions() { + let mut transaction_hash = String::default(); + for (log, call_view) in trx.logs_with_calls() { + if let Some(event) = abi::gns::events::SubgraphPublished2::match_and_decode(log) { + subgraph_published2_events.push(SubgraphPublished2 { + id: Hex(&call_view.transaction.hash).to_string(), + subgraph_id: event.subgraph_id.to_string(), + subgraph_deployment_id: event.subgraph_deployment_id.to_vec(), + reserve_ratio: event.reserve_ratio.to_string(), + ordinal: log.ordinal as u64, + }); + transaction_hash = Hex(&call_view.transaction.hash).to_string(); + } else if let Some(event) = + abi::gns::events::SubgraphVersionUpdated::match_and_decode(log) + { + if transaction_hash != Hex(&call_view.transaction.hash).to_string() { + subgraph_version_updated_events.push(SubgraphVersionUpdated { + id: Hex(&call_view.transaction.hash).to_string(), + subgraph_id: event.subgraph_id.to_string(), + subgraph_deployment_id: event.subgraph_deployment_id.to_vec(), + version_metadata: event.version_metadata.to_vec(), + ordinal: log.ordinal as u64, + }) + } + } } } @@ -524,56 +564,59 @@ fn map_events(blk: eth::Block) -> Result { // due to the subgraph ID change/migration from address+index to nft id // Might be a bit tricky to support them. - events.transfers = Some(Transfers { - transfers: transfers, - }); + events.transfers = Some(Transfers { transfers }); events.stake_deposited_events = Some(StakeDepositedEvents { - stake_deposited_events: stake_deposited_events, + stake_deposited_events, }); events.stake_withdrawn_events = Some(StakeWithdrawnEvents { - stake_withdrawn_events: stake_withdrawn_events, + stake_withdrawn_events, }); events.stake_delegated_events = Some(StakeDelegatedEvents { - stake_delegated_events: stake_delegated_events, + stake_delegated_events, }); events.stake_delegated_locked_events = Some(StakeDelegatedLockedEvents { - stake_delegated_locked_events: stake_delegated_locked_events, + stake_delegated_locked_events, }); events.rebate_claimed_events = Some(RebateClaimedEvents { - rebate_claimed_events: rebate_claimed_events, + rebate_claimed_events, }); events.delegation_parameters_updated_events = Some(DelegationParametersUpdatedEvents { - delegation_parameters_updated_events: delegation_parameters_updated_events, + delegation_parameters_updated_events, }); events.rewards_assigned_events = Some(RewardsAssignedEvents { - rewards_assigned_events: rewards_assigned_events, - }); - events.signalled_events = Some(SignalledEvents { - signalled_events: signalled_events, - }); - events.burned_events = Some(BurnedEvents { - burned_events: burned_events, + rewards_assigned_events, }); + events.signalled_events = Some(SignalledEvents { signalled_events }); + events.burned_events = Some(BurnedEvents { burned_events }); events.allocation_created_events = Some(AllocationCreatedEvents { - allocation_created_events: allocation_created_events, + allocation_created_events, }); events.allocation_closed_events = Some(AllocationClosedEvents { - allocation_closed_events: allocation_closed_events, + allocation_closed_events, }); events.allocation_collected_events = Some(AllocationCollectedEvents { - allocation_collected_events: allocation_collected_events, + allocation_collected_events, }); events.pause_changed_events = Some(PauseChangedEvents { - paused_changed_events: pause_changed_events, + paused_changed_events, }); events.partial_pause_changed_events = Some(PartialPauseChangedEvents { - partial_paused_changed_events: partial_pause_changed_events, + partial_paused_changed_events, }); events.epoch_length_updated_events = Some(EpochLengthUpdatedEvents { - epoch_length_updated_events: epoch_length_updated_events, + epoch_length_updated_events, }); events.rewards_deny_list_updated_events = Some(RewardsDenyListUpdatedEvents { - rewards_deny_list_updated_events: rewards_deny_list_updated_events, + rewards_deny_list_updated_events, + }); + events.subgraph_published1_events = Some(SubgraphPublished1Events { + subgraph_published1_events, + }); + events.subgraph_published2_events = Some(SubgraphPublished2Events { + subgraph_published2_events, + }); + events.subgraph_version_updated_events = Some(SubgraphVersionUpdatedEvents { + subgraph_version_updated_events, }); Ok(events) } diff --git a/src/modules/mod.rs b/src/modules/mod.rs index c5808fb..55dcc17 100644 --- a/src/modules/mod.rs +++ b/src/modules/mod.rs @@ -1,6 +1,7 @@ -mod init_maps; -mod graph_token; -mod staking; mod curation; mod epoch_manager; +mod gns; mod graph_out; +mod graph_token; +mod init_maps; +mod staking; diff --git a/src/pb/eth.erc20.v1.rs b/src/pb/eth.erc20.v1.rs index cba29c8..12cb0cb 100644 --- a/src/pb/eth.erc20.v1.rs +++ b/src/pb/eth.erc20.v1.rs @@ -109,6 +109,24 @@ pub struct RewardsDenyListUpdatedEvents { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct SubgraphPublished1Events { + #[prost(message, repeated, tag="1")] + pub subgraph_published1_events: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SubgraphPublished2Events { + #[prost(message, repeated, tag="1")] + pub subgraph_published2_events: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SubgraphVersionUpdatedEvents { + #[prost(message, repeated, tag="1")] + pub subgraph_version_updated_events: ::prost::alloc::vec::Vec, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct IndexerStakes { #[prost(message, repeated, tag="1")] pub indexer_stakes: ::prost::alloc::vec::Vec, @@ -194,6 +212,12 @@ pub struct Events { pub epoch_length_updated_events: ::core::option::Option, #[prost(message, optional, tag="17")] pub rewards_deny_list_updated_events: ::core::option::Option, + #[prost(message, optional, tag="18")] + pub subgraph_published1_events: ::core::option::Option, + #[prost(message, optional, tag="19")] + pub subgraph_published2_events: ::core::option::Option, + #[prost(message, optional, tag="20")] + pub subgraph_version_updated_events: ::core::option::Option, } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] @@ -483,6 +507,50 @@ pub struct RewardsDenyListUpdated { } #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] +pub struct SubgraphPublished1 { + #[prost(string, tag="1")] + pub id: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="2")] + pub graph_account: ::prost::alloc::vec::Vec, + #[prost(string, tag="3")] + pub subgraph_number: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="4")] + pub subgraph_deployment_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="5")] + pub version_metadata: ::prost::alloc::vec::Vec, + #[prost(uint64, tag="6")] + pub ordinal: u64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SubgraphPublished2 { + #[prost(string, tag="1")] + pub id: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub subgraph_id: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="3")] + pub subgraph_deployment_id: ::prost::alloc::vec::Vec, + #[prost(string, tag="4")] + pub reserve_ratio: ::prost::alloc::string::String, + #[prost(uint64, tag="5")] + pub ordinal: u64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] +pub struct SubgraphVersionUpdated { + #[prost(string, tag="1")] + pub id: ::prost::alloc::string::String, + #[prost(string, tag="2")] + pub subgraph_id: ::prost::alloc::string::String, + #[prost(bytes="vec", tag="3")] + pub subgraph_deployment_id: ::prost::alloc::vec::Vec, + #[prost(bytes="vec", tag="4")] + pub version_metadata: ::prost::alloc::vec::Vec, + #[prost(uint64, tag="5")] + pub ordinal: u64, +} +#[allow(clippy::derive_partial_eq_without_eq)] +#[derive(Clone, PartialEq, ::prost::Message)] pub struct IndexerStake { #[prost(string, tag="1")] pub id: ::prost::alloc::string::String, diff --git a/src/utils.rs b/src/utils.rs index e71cfa7..3af05bc 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,4 +1,5 @@ use base58::ToBase58; +use bigdecimal::Num; use hex::FromHex; use substreams::Hex; use tiny_keccak::{Hasher, Keccak}; @@ -81,3 +82,42 @@ pub fn generate_ipfs_hash(subgraph_id: String) -> String { .to_base58() .to_string(); } + +pub fn generate_version_id( + subgraph_id: String, + subgraph_deployment_id: String, + version_count: String, +) -> String { + return concat(concat(subgraph_id, subgraph_deployment_id), version_count); +} + +extern crate num_bigint; +extern crate tiny_keccak; + +use num_bigint::BigUint; + +pub fn get_subgraph_id(graph_account: &str, subgraph_number: &str) -> String { + // Convert graph account to string and remove '0x' prefix if exists + let graph_account_str = graph_account.trim_start_matches("0x"); + + // Convert subgraph_number (string) to BigUint + let subgraph_num = BigUint::from_str_radix(subgraph_number.trim_start_matches("0x"), 16) + .expect("Failed to convert subgraph_number to BigUint"); + + // Convert subgraph number to hexadecimal string, ensure it's 64 chars long + let subgraph_number_str = format!("{:064x}", subgraph_num); + + // Concatenate the strings + let unhashed_subgraph_id = format!("{}{}", graph_account_str, subgraph_number_str); + + // Hash using Keccak256 + let mut keccak = Keccak::v256(); + let mut output = [0u8; 32]; + keccak.update(unhashed_subgraph_id.as_bytes()); + keccak.finalize(&mut output); + + // Convert result to BigUint + let big_int_representation = BigUint::from_bytes_be(&output); + + format!("{:x}", big_int_representation) +} diff --git a/substreams.yaml b/substreams.yaml index 887a9c9..01506b8 100644 --- a/substreams.yaml +++ b/substreams.yaml @@ -283,6 +283,24 @@ modules: - map: map_indexing_rewards - store: store_epoch_count + - name: store_version_count + kind: store + initialBlock: 11446764 + updatePolicy: add + valueType: bigint + inputs: + - map: map_events + + - name: store_version + kind: store + initialBlock: 11446764 + updatePolicy: set + valueType: string + inputs: + - map: map_events + - store: store_version_count + - source: sf.substreams.v1.Clock + - name: graph_out kind: map initialBlock: 11446764 @@ -339,5 +357,9 @@ modules: - store: store_subgraph_deployment_ipfs_hash mode: deltas - map: map_indexing_rewards + - store: store_version_count + mode: deltas + - store: store_version + mode: deltas output: type: proto:sf.substreams.sink.entity.v1.EntityChanges