Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Refactoring v2 #5

Merged
merged 12 commits into from
Jul 13, 2023
Merged

Refactoring v2 #5

merged 12 commits into from
Jul 13, 2023

Conversation

SovereignAndrey
Copy link
Contributor

@SovereignAndrey SovereignAndrey commented Jul 6, 2023

First stab at refactoring the SubGraph schema and mappings to allow for processing and tracking more relevant info from the contracts.

@SovereignAndrey SovereignAndrey added bug Something isn't working enhancement New feature or request WIP labels Jul 6, 2023
@SovereignAndrey SovereignAndrey self-assigned this Jul 6, 2023
} from "../generated/schema"

export function handleAllowanceRemoved(event: AllowanceRemovedEvent): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many compilation errors in /src/* files:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No sure about this one tbh. It compiles and builds fine for me. Does yarn build not work for you or is this a VS Code linter thing?

Copy link
Contributor

@0xNeshi 0xNeshi Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting 🤔 This may be something that VS Code finds an issue with, while your editor doesn't (you're using NeoVim I think). It seems that the visibility of these errors is environment-specific, see https://stackoverflow.com/a/60688789/21983222

Anyway, the reason for the errors seems to be described in this GH issue in the official TS repo microsoft/TypeScript#2361

Nevertheless, it seems that these errors should not affect our code, because BigInt overloads the + operator to allow for adding to BigInts (see source).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does yarn build not work for you...?

The command fails because I'm missing some ABIs, one of which is abis/EndowmentMultiSigEmitter.json. Would it be possible to either:

  • add ABIs used to build the graph to the source code
    or
  • remove dependence on ABI files and pull them from Etherscan (assuming the contracts are verified, which they should always be anyway)
    ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mappings code is written in AssemblyScript, a more strict subset of TypeScript that compiles to WASM, so that might account for the errors?

You're right on the += & -= stuff. Will scan through the mappings and fix those to be more explicit.

Copy link
Contributor Author

@SovereignAndrey SovereignAndrey Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The command fails because I'm missing some ABIs

Simply copy the relevant JSON files from the evm-smart-contracts repo into the abi folder in this repo. Examples (adjust to fit your dir/folder structure ofc):

cp ../evm-smart-contracts/artifacts/contracts/multisigs/APTeamMultiSig.sol/APTeamMultiSig.json ./abis/
cp ../evm-smart-contracts/artifacts/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol/EndowmentMultiSig.json ./abis/
cp ../evm-smart-contracts/artifacts/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSigEmitter.sol/EndowmentMultiSigEmitter.json ./abis/
cp ../evm-smart-contracts/artifacts/contracts/multisigs/CharityApplications.sol/CharityApplications.json ./abis/
cp ../evm-smart-contracts/artifacts/contracts/core/accounts/interfaces/IAccounts.sol/IAccounts.json ./abis/

UPDATE: You could try to symbolically link them as well, so as to not need to re-copy them with every contract code change / recompile cycle. 💡

Copy link
Contributor Author

@SovereignAndrey SovereignAndrey Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the += & -= to use BigInt.plus() [ie. x.plux(y)] and BigInt.minus() [ie. x.minus(y)] respectively in d87f00b.

Copy link
Contributor

@0xNeshi 0xNeshi Jul 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right on the += & -= stuff

When I said "these errors should not affect our code", what I meant to say was "these errors should not affect the execution of our code", meaning we could technically leave things as-is 😅

Anyways, now that you've updated everything to use .plus() & .minus() & ... operations, it could even be a good thing, if nothing else then just to be safe (and to avoid seeing error warnings)

src/accounts.ts Outdated Show resolved Hide resolved
src/accounts.ts Outdated Show resolved Hide resolved
src/accounts.ts Show resolved Hide resolved
@SovereignAndrey SovereignAndrey changed the title [WIP] Refactoring v2 Refactoring v2 Jul 11, 2023
@SovereignAndrey SovereignAndrey requested a review from 0xNeshi July 12, 2023 08:36
@0xNeshi
Copy link
Contributor

0xNeshi commented Jul 13, 2023

@SovereignAndrey

UPDATE: You could try to symbolically link them as well, so as to not need to re-copy them with every contract code change / recompile cycle.

This seems a bit fragile, as it would mean that we wouldn't be able to graph build the code unless the symlinked ABI files are the exact version that was used when the current subgraph configuration was being created.
For example, after symlinking ABIs from evm-smart-contracts, I'm unable to build the subgraph code (using yarn build) from this branch because ABIs on my current evm-smart-contracts branch do not contain certain events expected in subgraph.yaml or the events have different signatures (tried on evm-smart-contracts > master branch as well and the same thing occurred).

The contracts we deploy should always be verified, so it should be safe to depend on ABIs downloaded from Etherscan and not on actual ABI files.

Nevertheless, merging this branch as the code within satisfies the requirements, we can address the ABI issue separately.

@0xNeshi 0xNeshi merged commit cf89e3c into main Jul 13, 2023
@0xNeshi 0xNeshi deleted the refactoring-v2 branch July 13, 2023 06:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working enhancement New feature or request
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants