From 2e76a074b331f74d608b9c0d2cd121f03a99c740 Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:07:18 +0200 Subject: [PATCH 01/11] feat: support generic erc20votes --- src/config.json | 30 ++++++++++++++++++++++++++++-- src/writer.ts | 15 +++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/config.json b/src/config.json index 59c9f6d..afeca9d 100644 --- a/src/config.json +++ b/src/config.json @@ -41,6 +41,32 @@ "fn": "handleDelegateVotesChanged" } ] + }, + { + "contract": "0x302d332e9aceb184e5f301cb62c85181e7fc3b30559935c5736e987de579f6e", + "start": 17960, + "abi": "ContractFactory", + "events": [ + { + "name": "NewContractDeployed", + "fn": "handleSpaceDeployed" + } + ] + } + ], + "templates": { + "Space": { + "abi": "GenericERC20Votes", + "events": [ + { + "name": "DelegateChanged", + "fn": "handleDelegateChanged" + }, + { + "name": "DelegateVotesChanged", + "fn": "handleDelegateVotesChanged" + } + ] } - ] -} + } +} \ No newline at end of file diff --git a/src/writer.ts b/src/writer.ts index d2508bc..c17a833 100644 --- a/src/writer.ts +++ b/src/writer.ts @@ -4,6 +4,8 @@ import { formatUnits } from '@ethersproject/units'; import { Delegate, Governance } from '../.checkpoint/models'; import { BIGINT_ZERO, DECIMALS, getGovernance, getDelegate } from './utils'; +const ERC20VOTES_CLASS_HASH = '0x07e69a995a319a143683602b7a9f21bd94e1371a5b0636218e453a3e5ebaeb40'; + export const handleDelegateChanged: starknet.Writer = async ({ event, source }) => { if (!event) return; @@ -49,3 +51,16 @@ export const handleDelegateVotesChanged: starknet.Writer = async ({ event, sourc await governance.save(); }; + +export const handleContractDeployed: starknet.Writer = async ({ blockNumber, event, source, instance }) => { + const implem_address = source?.contract; + + if (!event) return; + + if (implem_address === ERC20VOTES_CLASS_HASH) { + await instance.executeTemplate('GenericERC20Votes', { + contract: event.contract_address, + start: blockNumber + }); + } +} \ No newline at end of file From f4a7ee629f5ff33863f9295b7a71587c224f7b18 Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:11:48 +0200 Subject: [PATCH 02/11] chore: update factory address and start blocknumber --- src/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config.json b/src/config.json index afeca9d..3208aa2 100644 --- a/src/config.json +++ b/src/config.json @@ -43,8 +43,8 @@ ] }, { - "contract": "0x302d332e9aceb184e5f301cb62c85181e7fc3b30559935c5736e987de579f6e", - "start": 17960, + "contract": "0x01aeabd202e7e36294fe71e9e79cae5f8feb8b4e581ef93d1879e8be579ae4be", + "start": 81640, "abi": "ContractFactory", "events": [ { From 292223c545d3360691f9c542ba8ace10b0bddaf3 Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Thu, 18 Jul 2024 15:14:16 +0200 Subject: [PATCH 03/11] chore: use Token as the ABI for the template --- src/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.json b/src/config.json index 3208aa2..b980b8b 100644 --- a/src/config.json +++ b/src/config.json @@ -56,7 +56,7 @@ ], "templates": { "Space": { - "abi": "GenericERC20Votes", + "abi": "Token", "events": [ { "name": "DelegateChanged", From a5b2f9a1c9d779b244a680bdc8284e0b23d3e138 Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:44:19 +0200 Subject: [PATCH 04/11] fix: update ContractFactory address --- src/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/config.json b/src/config.json index b980b8b..0d87a7e 100644 --- a/src/config.json +++ b/src/config.json @@ -43,7 +43,7 @@ ] }, { - "contract": "0x01aeabd202e7e36294fe71e9e79cae5f8feb8b4e581ef93d1879e8be579ae4be", + "contract": "0x029e5827d2e8720061863a9cef9356477b795482d4a4130d4e5588abcff286fb", "start": 81640, "abi": "ContractFactory", "events": [ From 3db3596b5fdceabe57bd5840c154b654be180275 Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Fri, 19 Jul 2024 13:00:48 +0200 Subject: [PATCH 05/11] correctly retrieve implem_address --- src/writer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/writer.ts b/src/writer.ts index c17a833..3d69298 100644 --- a/src/writer.ts +++ b/src/writer.ts @@ -53,9 +53,9 @@ export const handleDelegateVotesChanged: starknet.Writer = async ({ event, sourc }; export const handleContractDeployed: starknet.Writer = async ({ blockNumber, event, source, instance }) => { - const implem_address = source?.contract; if (!event) return; + const implem_address = event.implementation_address; if (implem_address === ERC20VOTES_CLASS_HASH) { await instance.executeTemplate('GenericERC20Votes', { From dea17a10f7710569b9f9d8f167832d6ae1ed58f6 Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Fri, 19 Jul 2024 13:02:36 +0200 Subject: [PATCH 06/11] use class_hash wording --- src/writer.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/writer.ts b/src/writer.ts index 3d69298..cdf2773 100644 --- a/src/writer.ts +++ b/src/writer.ts @@ -55,9 +55,9 @@ export const handleDelegateVotesChanged: starknet.Writer = async ({ event, sourc export const handleContractDeployed: starknet.Writer = async ({ blockNumber, event, source, instance }) => { if (!event) return; - const implem_address = event.implementation_address; + const classHash = event.class_hash; - if (implem_address === ERC20VOTES_CLASS_HASH) { + if (classHash === ERC20VOTES_CLASS_HASH) { await instance.executeTemplate('GenericERC20Votes', { contract: event.contract_address, start: blockNumber From c776c780732e504862279f21c32334e22bea324f Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Fri, 26 Jul 2024 10:54:18 +0200 Subject: [PATCH 07/11] chore: comment on erc20votes class hash --- src/writer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/writer.ts b/src/writer.ts index cdf2773..ca8d745 100644 --- a/src/writer.ts +++ b/src/writer.ts @@ -4,7 +4,7 @@ import { formatUnits } from '@ethersproject/units'; import { Delegate, Governance } from '../.checkpoint/models'; import { BIGINT_ZERO, DECIMALS, getGovernance, getDelegate } from './utils'; -const ERC20VOTES_CLASS_HASH = '0x07e69a995a319a143683602b7a9f21bd94e1371a5b0636218e453a3e5ebaeb40'; +const ERC20VOTES_CLASS_HASH = '0x07e69a995a319a143683602b7a9f21bd94e1371a5b0636218e453a3e5ebaeb40'; // Address on mainnet export const handleDelegateChanged: starknet.Writer = async ({ event, source }) => { if (!event) return; From 865fe3037c0573952112b73e43d4274881675c82 Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Mon, 5 Aug 2024 11:54:27 +0200 Subject: [PATCH 08/11] fix: parse class hash address --- src/writer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/writer.ts b/src/writer.ts index ca8d745..b5369f2 100644 --- a/src/writer.ts +++ b/src/writer.ts @@ -55,7 +55,7 @@ export const handleDelegateVotesChanged: starknet.Writer = async ({ event, sourc export const handleContractDeployed: starknet.Writer = async ({ blockNumber, event, source, instance }) => { if (!event) return; - const classHash = event.class_hash; + const classHash = validateAndParseAddress(event.class_hash); if (classHash === ERC20VOTES_CLASS_HASH) { await instance.executeTemplate('GenericERC20Votes', { From b2fedefce734b5600822ce6219dff95f6a52fb22 Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:42:27 +0200 Subject: [PATCH 09/11] add GenericERC20Votes abi; remove mentions to Space --- package.json | 2 +- src/abis/ContractFactory.json | 90 ++++++ src/abis/GenericERC20Votes.json | 558 ++++++++++++++++++++++++++++++++ src/config.json | 10 +- src/index.ts | 4 +- src/writer.ts | 15 +- yarn.lock | 6 +- 7 files changed, 669 insertions(+), 16 deletions(-) create mode 100644 src/abis/ContractFactory.json create mode 100644 src/abis/GenericERC20Votes.json diff --git a/package.json b/package.json index b3f917b..06a7159 100644 --- a/package.json +++ b/package.json @@ -36,4 +36,4 @@ "eslint": "^8.28.0", "prettier": "^2.8.0" } -} +} \ No newline at end of file diff --git a/src/abis/ContractFactory.json b/src/abis/ContractFactory.json new file mode 100644 index 0000000..75dd180 --- /dev/null +++ b/src/abis/ContractFactory.json @@ -0,0 +1,90 @@ +[ + { + "type": "impl", + "name": "Factory", + "interface_name": "sx::factory::factory::IFactory" + }, + { + "type": "struct", + "name": "core::array::Span::", + "members": [ + { + "name": "snapshot", + "type": "@core::array::Array::" + } + ] + }, + { + "type": "enum", + "name": "core::result::Result::>", + "variants": [ + { + "name": "Ok", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "Err", + "type": "core::array::Array::" + } + ] + }, + { + "type": "interface", + "name": "sx::factory::factory::IFactory", + "items": [ + { + "type": "function", + "name": "deploy", + "inputs": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash" + }, + { + "name": "initialize_calldata", + "type": "core::array::Span::" + }, + { + "name": "salt_nonce", + "type": "core::felt252" + } + ], + "outputs": [ + { + "type": "core::result::Result::>" + } + ], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "sx::factory::factory::Factory::NewContractDeployed", + "kind": "struct", + "members": [ + { + "name": "class_hash", + "type": "core::starknet::class_hash::ClassHash", + "kind": "data" + }, + { + "name": "contract_address", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "sx::factory::factory::Factory::Event", + "kind": "enum", + "variants": [ + { + "name": "NewContractDeployed", + "type": "sx::factory::factory::Factory::NewContractDeployed", + "kind": "nested" + } + ] + } +] \ No newline at end of file diff --git a/src/abis/GenericERC20Votes.json b/src/abis/GenericERC20Votes.json new file mode 100644 index 0000000..802790b --- /dev/null +++ b/src/abis/GenericERC20Votes.json @@ -0,0 +1,558 @@ +[ + { + "type": "impl", + "name": "InitToken", + "interface_name": "sn_periphery::generic_erc20_votes::IInitializable" + }, + { + "type": "struct", + "name": "core::byte_array::ByteArray", + "members": [ + { + "name": "data", + "type": "core::array::Array::" + }, + { + "name": "pending_word", + "type": "core::felt252" + }, + { + "name": "pending_word_len", + "type": "core::integer::u32" + } + ] + }, + { + "type": "struct", + "name": "core::integer::u256", + "members": [ + { + "name": "low", + "type": "core::integer::u128" + }, + { + "name": "high", + "type": "core::integer::u128" + } + ] + }, + { + "type": "interface", + "name": "sn_periphery::generic_erc20_votes::IInitializable", + "items": [ + { + "type": "function", + "name": "initialize", + "inputs": [ + { + "name": "name", + "type": "core::byte_array::ByteArray" + }, + { + "name": "symbol", + "type": "core::byte_array::ByteArray" + }, + { + "name": "initial_supply", + "type": "core::integer::u256" + }, + { + "name": "recipient", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "ERC20MixinImpl", + "interface_name": "openzeppelin::token::erc20::interface::ERC20ABI" + }, + { + "type": "enum", + "name": "core::bool", + "variants": [ + { + "name": "False", + "type": "()" + }, + { + "name": "True", + "type": "()" + } + ] + }, + { + "type": "interface", + "name": "openzeppelin::token::erc20::interface::ERC20ABI", + "items": [ + { + "type": "function", + "name": "total_supply", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "balance_of", + "inputs": [ + { + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "allowance", + "inputs": [ + { + "name": "owner", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "spender", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "transfer", + "inputs": [ + { + "name": "recipient", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "transfer_from", + "inputs": [ + { + "name": "sender", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "recipient", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "approve", + "inputs": [ + { + "name": "spender", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "external" + }, + { + "type": "function", + "name": "name", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "symbol", + "inputs": [], + "outputs": [ + { + "type": "core::byte_array::ByteArray" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "decimals", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u8" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "totalSupply", + "inputs": [], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "balanceOf", + "inputs": [ + { + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "transferFrom", + "inputs": [ + { + "name": "sender", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "recipient", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "amount", + "type": "core::integer::u256" + } + ], + "outputs": [ + { + "type": "core::bool" + } + ], + "state_mutability": "external" + } + ] + }, + { + "type": "impl", + "name": "ERC20VotesImpl", + "interface_name": "openzeppelin::governance::utils::interfaces::votes::IVotes" + }, + { + "type": "interface", + "name": "openzeppelin::governance::utils::interfaces::votes::IVotes", + "items": [ + { + "type": "function", + "name": "get_votes", + "inputs": [ + { + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "get_past_votes", + "inputs": [ + { + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "timepoint", + "type": "core::integer::u64" + } + ], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "get_past_total_supply", + "inputs": [ + { + "name": "timepoint", + "type": "core::integer::u64" + } + ], + "outputs": [ + { + "type": "core::integer::u256" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "delegates", + "inputs": [ + { + "name": "account", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [ + { + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "state_mutability": "view" + }, + { + "type": "function", + "name": "delegate", + "inputs": [ + { + "name": "delegatee", + "type": "core::starknet::contract_address::ContractAddress" + } + ], + "outputs": [], + "state_mutability": "external" + }, + { + "type": "function", + "name": "delegate_by_sig", + "inputs": [ + { + "name": "delegator", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "delegatee", + "type": "core::starknet::contract_address::ContractAddress" + }, + { + "name": "nonce", + "type": "core::felt252" + }, + { + "name": "expiry", + "type": "core::integer::u64" + }, + { + "name": "signature", + "type": "core::array::Array::" + } + ], + "outputs": [], + "state_mutability": "external" + } + ] + }, + { + "type": "event", + "name": "openzeppelin::token::erc20::erc20::ERC20Component::Transfer", + "kind": "struct", + "members": [ + { + "name": "from", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "to", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "value", + "type": "core::integer::u256", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "openzeppelin::token::erc20::erc20::ERC20Component::Approval", + "kind": "struct", + "members": [ + { + "name": "owner", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "spender", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "value", + "type": "core::integer::u256", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "openzeppelin::token::erc20::erc20::ERC20Component::Event", + "kind": "enum", + "variants": [ + { + "name": "Transfer", + "type": "openzeppelin::token::erc20::erc20::ERC20Component::Transfer", + "kind": "nested" + }, + { + "name": "Approval", + "type": "openzeppelin::token::erc20::erc20::ERC20Component::Approval", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "openzeppelin::token::erc20::extensions::erc20_votes::ERC20VotesComponent::DelegateChanged", + "kind": "struct", + "members": [ + { + "name": "delegator", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "from_delegate", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "to_delegate", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + } + ] + }, + { + "type": "event", + "name": "openzeppelin::token::erc20::extensions::erc20_votes::ERC20VotesComponent::DelegateVotesChanged", + "kind": "struct", + "members": [ + { + "name": "delegate", + "type": "core::starknet::contract_address::ContractAddress", + "kind": "key" + }, + { + "name": "previous_votes", + "type": "core::integer::u256", + "kind": "data" + }, + { + "name": "new_votes", + "type": "core::integer::u256", + "kind": "data" + } + ] + }, + { + "type": "event", + "name": "openzeppelin::token::erc20::extensions::erc20_votes::ERC20VotesComponent::Event", + "kind": "enum", + "variants": [ + { + "name": "DelegateChanged", + "type": "openzeppelin::token::erc20::extensions::erc20_votes::ERC20VotesComponent::DelegateChanged", + "kind": "nested" + }, + { + "name": "DelegateVotesChanged", + "type": "openzeppelin::token::erc20::extensions::erc20_votes::ERC20VotesComponent::DelegateVotesChanged", + "kind": "nested" + } + ] + }, + { + "type": "event", + "name": "openzeppelin::utils::cryptography::nonces::NoncesComponent::Event", + "kind": "enum", + "variants": [] + }, + { + "type": "event", + "name": "sn_periphery::generic_erc20_votes::GenericERC20Votes::Event", + "kind": "enum", + "variants": [ + { + "name": "ERC20Event", + "type": "openzeppelin::token::erc20::erc20::ERC20Component::Event", + "kind": "flat" + }, + { + "name": "ERC20VotesEvent", + "type": "openzeppelin::token::erc20::extensions::erc20_votes::ERC20VotesComponent::Event", + "kind": "flat" + }, + { + "name": "NoncesEvent", + "type": "openzeppelin::utils::cryptography::nonces::NoncesComponent::Event", + "kind": "flat" + } + ] + } +] \ No newline at end of file diff --git a/src/config.json b/src/config.json index 0d87a7e..d09c72e 100644 --- a/src/config.json +++ b/src/config.json @@ -43,20 +43,20 @@ ] }, { - "contract": "0x029e5827d2e8720061863a9cef9356477b795482d4a4130d4e5588abcff286fb", - "start": 81640, + "contract": "0x0250e28c97e729842190c3672f9fcf8db0fc78b8080e87a894831dc69e4f4439", + "start": 765532, "abi": "ContractFactory", "events": [ { "name": "NewContractDeployed", - "fn": "handleSpaceDeployed" + "fn": "handleContractDeployed" } ] } ], "templates": { - "Space": { - "abi": "Token", + "GenericERC20Votes": { + "abi": "GenericERC20Votes", "events": [ { "name": "DelegateChanged", diff --git a/src/index.ts b/src/index.ts index 570b66b..b55a050 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,6 +9,8 @@ import * as writer from './writer'; import config from './config.json'; import Token from './abis/Token.json'; import Token2 from './abis/Token2.json'; +import ContractFactory from './abis/ContractFactory.json'; +import GenericERC20Votes from './abis/GenericERC20Votes.json'; const dir = __dirname.endsWith('dist/src') ? '../' : ''; const schemaFile = path.join(__dirname, `${dir}../src/schema.gql`); @@ -28,7 +30,7 @@ const checkpoint = new Checkpoint(config, indexer, schema, { logLevel: LogLevel.Info, resetOnConfigChange: true, prettifyLogs: process.env.NODE_ENV !== 'production', - abis: { Token, Token2 } + abis: { Token, Token2, ContractFactory, GenericERC20Votes } }); const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)); diff --git a/src/writer.ts b/src/writer.ts index b5369f2..f190d9b 100644 --- a/src/writer.ts +++ b/src/writer.ts @@ -4,12 +4,12 @@ import { formatUnits } from '@ethersproject/units'; import { Delegate, Governance } from '../.checkpoint/models'; import { BIGINT_ZERO, DECIMALS, getGovernance, getDelegate } from './utils'; -const ERC20VOTES_CLASS_HASH = '0x07e69a995a319a143683602b7a9f21bd94e1371a5b0636218e453a3e5ebaeb40'; // Address on mainnet +const ERC20VOTES_CLASS_HASH = '0x0048b5c15aa3d4c5df35fda6d921d6e9bcb122f5f3c96c9c061931469ce6cd83'; // Address on mainnet export const handleDelegateChanged: starknet.Writer = async ({ event, source }) => { if (!event) return; - console.log('Handle delegate changed', event); + console.log('Handle delegate changed'); const governanceId = source?.contract || ''; const fromDelegate = validateAndParseAddress(event.from_delegate); @@ -27,7 +27,7 @@ export const handleDelegateChanged: starknet.Writer = async ({ event, source }) export const handleDelegateVotesChanged: starknet.Writer = async ({ event, source }) => { if (!event) return; - console.log('Handle delegate votes changed', event); + console.log('Handle delegate votes changed'); const governanceId = source?.contract || ''; const governance: Governance = await getGovernance(governanceId); @@ -52,15 +52,18 @@ export const handleDelegateVotesChanged: starknet.Writer = async ({ event, sourc await governance.save(); }; -export const handleContractDeployed: starknet.Writer = async ({ blockNumber, event, source, instance }) => { +export const handleContractDeployed: starknet.Writer = async ({ blockNumber, event, instance }) => { + console.log("Handle contract deployed"); if (!event) return; - const classHash = validateAndParseAddress(event.class_hash); + const paddedClassHash = validateAndParseAddress(event.class_hash); - if (classHash === ERC20VOTES_CLASS_HASH) { + if (paddedClassHash === ERC20VOTES_CLASS_HASH) { await instance.executeTemplate('GenericERC20Votes', { contract: event.contract_address, start: blockNumber }); + } else { + console.log('Unknown class hash', paddedClassHash); } } \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index b431a80..e8a7804 100644 --- a/yarn.lock +++ b/yarn.lock @@ -918,9 +918,9 @@ integrity sha512-yHSKYidqJMV9nADqg78GYA+cZ0hS1twANAjiFibQdXj9aGzD+s/IzIFEIi/U/OBLvWYg/SCw0QVozi2vTlKFDQ== "@snapshot-labs/checkpoint@^0.1.0-beta.38": - version "0.1.0-beta.38" - resolved "https://registry.yarnpkg.com/@snapshot-labs/checkpoint/-/checkpoint-0.1.0-beta.38.tgz#2d718caa9fd14d3ddea77024800ffd1265d70fd6" - integrity sha512-90Aqqp9KU8F15zuvYI7358Jh179Zw2n41HxgXURgAcRQkRdrrj5n7MMv4XCPHe5imTp6CFkwGry4Si/IgLM9Wg== + version "0.1.0-beta.40" + resolved "https://registry.yarnpkg.com/@snapshot-labs/checkpoint/-/checkpoint-0.1.0-beta.40.tgz#e3bee2bbae31b7a84504c52d22d742c7522b5bce" + integrity sha512-BBhvz4ZSTQDQVw8efBN2cHe0UfVUL+uXi225zb7wRAjMLS8NnhK/Wl0+LRzRpg9Wyxi0moF5zRdegFHgxiHSVA== dependencies: "@ethersproject/abi" "^5.7.0" "@ethersproject/address" "^5.7.0" From cc03c9fc65a558c63434d3664d366d2a2b9f7b8e Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:55:47 +0200 Subject: [PATCH 10/11] update yarn --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index e8a7804..b431a80 100644 --- a/yarn.lock +++ b/yarn.lock @@ -918,9 +918,9 @@ integrity sha512-yHSKYidqJMV9nADqg78GYA+cZ0hS1twANAjiFibQdXj9aGzD+s/IzIFEIi/U/OBLvWYg/SCw0QVozi2vTlKFDQ== "@snapshot-labs/checkpoint@^0.1.0-beta.38": - version "0.1.0-beta.40" - resolved "https://registry.yarnpkg.com/@snapshot-labs/checkpoint/-/checkpoint-0.1.0-beta.40.tgz#e3bee2bbae31b7a84504c52d22d742c7522b5bce" - integrity sha512-BBhvz4ZSTQDQVw8efBN2cHe0UfVUL+uXi225zb7wRAjMLS8NnhK/Wl0+LRzRpg9Wyxi0moF5zRdegFHgxiHSVA== + version "0.1.0-beta.38" + resolved "https://registry.yarnpkg.com/@snapshot-labs/checkpoint/-/checkpoint-0.1.0-beta.38.tgz#2d718caa9fd14d3ddea77024800ffd1265d70fd6" + integrity sha512-90Aqqp9KU8F15zuvYI7358Jh179Zw2n41HxgXURgAcRQkRdrrj5n7MMv4XCPHe5imTp6CFkwGry4Si/IgLM9Wg== dependencies: "@ethersproject/abi" "^5.7.0" "@ethersproject/address" "^5.7.0" From 2c447caa39b9149fac72587c84158fc24ebb81cf Mon Sep 17 00:00:00 2001 From: Scott Piriou <30843220+pscott@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:56:26 +0200 Subject: [PATCH 11/11] reset yarn --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index b431a80..3999b9c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3596,4 +3596,4 @@ yocto-queue@^0.1.0: zod@^3.21.4: version "3.22.2" resolved "https://registry.yarnpkg.com/zod/-/zod-3.22.2.tgz#3add8c682b7077c05ac6f979fea6998b573e157b" - integrity sha512-wvWkphh5WQsJbVk1tbx1l1Ly4yg+XecD+Mq280uBGt9wa5BKSWf4Mhp6GmrkPixhMxmabYY7RbzlwVP32pbGCg== + integrity sha512-wvWkphh5WQsJbVk1tbx1l1Ly4yg+XecD+Mq280uBGt9wa5BKSWf4Mhp6GmrkPixhMxmabYY7RbzlwVP32pbGCg== \ No newline at end of file