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

fix: create account estimate fees #22

Merged
merged 6 commits into from
May 29, 2024
Merged

Conversation

palace22
Copy link
Collaborator

No description provided.

@palace22 palace22 requested a review from stefanofa May 29, 2024 13:50
Copy link
Member

@gidonkatten gidonkatten left a comment

Choose a reason for hiding this comment

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

I think overall the approach is sound, left some comments though

Comment on lines 115 to 118
convertToGenericAddress<ChainType.EVM>(
data.addressToInvite,
ChainType.EVM,
),
Copy link
Member

Choose a reason for hiding this comment

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

The address to invite should already by generic. You are inviting an address on folksChainIdToInvite which may not neccessarily be EVM

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated b11a478

Comment on lines +130 to +138
export function getAdapterAddress(
folksChainId: FolksChainId,
network: NetworkType,
adapterType: AdapterType,
) {
if (isHubChain(folksChainId, network))
return getHubChainAdapterAddress(network, adapterType);
return getSpokeChainAdapterAddress(folksChainId, network, adapterType);
}
Copy link
Member

Choose a reason for hiding this comment

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

When calling getAdapterAddress with Avalanche, you may still be calling from the context of being a spoke in which case you should be calling getSpokeChainAdapterAddress. Therefore it may be best to delete this function entirely and then call getHubChainAdapterAddress / getSpokeChainAdapterAddress directly depending on the context.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

export function buildEvmMessageToSend(
messageToSendBuilderParams: MessageToSendBuilderParams,
messageToSendBuilderParams: MessageBuilderParams,
feeParams: OptionalMessageParams,
Copy link
Member

Choose a reason for hiding this comment

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

You are naming this feeParams but technically it could be any of the message params which is being overrided

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the type is: type OptionalMessageParams = Partial<MessageParams>; so related to the fees plus the adapters, I think calling it params or messageParams can be misleading

Copy link
Member

Choose a reason for hiding this comment

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

Someone may mistakenly pass in feeParams which overrides the adapters. I think the type of feeParams should be changed to only include the params related to fees. Alternatively you ignore the non-fee params of feeParams by not using the spread operator ...feeParams

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the type of feeParams should be changed to only include the params related to fees.

I think this option makes sense. It might be useful to use Pick @palace22.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created the FeeParams type instead 53d21c1

buildMessagePayload(
messageBuilderParams.action,
messageBuilderParams.accountId,
getRandomGenericAddress(),
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 a random address works here in place of the user address. The transaction will likely revert when trying to estimate gas because the address is not registered to the account id.

You probably want to include the user address in MessageBuilderParams.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines 144 to 154
export function getSignerGenericAddress(
folksChainSigner: FolksChainSigner,
): GenericAddress {
const chainType = folksChainSigner.chainType;
switch (chainType) {
case ChainType.EVM:
return getEvmSignerAddress(folksChainSigner.signer);
default:
return exhaustiveCheck(chainType);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This isn't returning the generic address?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes thanks 86989f5

@palace22 palace22 requested a review from gidonkatten May 29, 2024 16:26
Copy link
Member

@gidonkatten gidonkatten left a comment

Choose a reason for hiding this comment

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

Checked all fixes and seem good

@palace22 palace22 changed the title fix: account module estimate fees fix: create account estimate fees May 29, 2024
@palace22 palace22 merged commit 4368c62 into main May 29, 2024
2 checks passed
@palace22 palace22 deleted the fix/account-module-estimate-fees branch May 29, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants