Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement multicall #1631

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Implement multicall #1631

wants to merge 7 commits into from

Conversation

jakehein
Copy link
Contributor

All Submissions

  • Can you post a screenshot of your changes (if applicable)?

New Feature Submissions

  • Does this relate to an existing issue, or has it been talked about prior to being done (if a major change)?

Notes

Please note, your code must pass all tests and lint checks before it can be merged.

PR Description

adding multiCall functionality used in CB Marketplace to store.ts in CB

Testing

Has the code been tested, or does it need double checking?

@jakehein jakehein self-assigned this Sep 14, 2022
@github-actions github-actions bot added the pr-frontend Frontend pull request label Sep 14, 2022
@@ -368,6 +369,10 @@ export async function setUpContracts(web3: Web3): Promise<Contracts> {
const treasuryContractAddr = getConfigValue('VUE_APP_TREASURY_CONTRACT_ADDRESS') || (treasuryNetworks as Networks)[networkId]!.address;
const Treasury = new web3.eth.Contract(treasuryAbi as Abi, treasuryContractAddr);

const multicallAddr = getConfigValue('VUE_APP_MULTICALL_CONTRACT_ADDRESS');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we want to keep line 109
if(process.env.NODE_ENV === 'development') return '';
This was originally commented out, and it isn't in CB-Marketplace, which is the only reason this would work in a dev environment.

Copy link
Member

Choose a reason for hiding this comment

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

We need to leave it, as it's in place for taking the address from generated abi files (as the addresses change every time you setup a dev env). I don't think we have multicall in our migrations, so it won't load it correctly. We somehow need to address this issue,

@jakehein jakehein linked an issue Sep 26, 2022 that may be closed by this pull request
@@ -368,6 +369,10 @@ export async function setUpContracts(web3: Web3): Promise<Contracts> {
const treasuryContractAddr = getConfigValue('VUE_APP_TREASURY_CONTRACT_ADDRESS') || (treasuryNetworks as Networks)[networkId]!.address;
const Treasury = new web3.eth.Contract(treasuryAbi as Abi, treasuryContractAddr);

const multicallAddr = getConfigValue('VUE_APP_MULTICALL_CONTRACT_ADDRESS');
Copy link
Member

Choose a reason for hiding this comment

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

We need to leave it, as it's in place for taking the address from generated abi files (as the addresses change every time you setup a dev env). I don't think we have multicall in our migrations, so it won't load it correctly. We somehow need to address this issue,

const { Characters } = state.contracts();
if (!Characters) return;

console.log('fetch 1');
Copy link
Member

Choose a reason for hiding this comment

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

A reminder comment to delete console.logs after the code is in a desired shape.

console.log('getNFTCall: ', getNFTCall(charactersAbi, Characters?.options.address, 'get', characterIds.map(characterId => [characterId])));
const multiCharacterDatas: string[] = await dispatch(
'multicall',
getNFTCall(charactersAbi, Characters?.options.address, 'get', characterIds.map(characterId => [characterId])));
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need optional chaining operator "?", as at the start we have if (!Characters) return;


const multiWeaponDatas: string[] = await dispatch(
'multicall',
getNFTCall(weaponsAbi, Weapons?.options.address, 'get', weaponIds.map(weaponId => [weaponId])));
Copy link
Member

Choose a reason for hiding this comment

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

Same here, "?" not needed


const multiShieldDatas: string[] = await dispatch(
'multicall',
getNFTCall(shieldsAbi, Shields?.options.address, 'get', shieldIds.map(shieldId => [shieldId])));
Copy link
Member

Choose a reason for hiding this comment

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

Same here, "?" not needed


const multiTrinketDatas: string[] = await dispatch(
'multicall',
getNFTCall(raidTrinketsAbi, RaidTrinket?.options.address, 'get', trinketIds.map(trinketId => [trinketId])));
Copy link
Member

Choose a reason for hiding this comment

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

Same here, "?" not needed


const multiJunkDatas = await dispatch(
'multicall',
getNFTCall(junkAbi, Junk?.options.address, 'get', junkIds.map(junkId => [junkId])));
Copy link
Member

Choose a reason for hiding this comment

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

Same here, "?" not needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-frontend Frontend pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement multicall
2 participants