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

feat: added event handler for saving ibc channels #10

Merged
merged 8 commits into from
May 6, 2024

Conversation

frazarshad
Copy link
Collaborator

@frazarshad frazarshad commented Apr 30, 2024

This PR adds two new handlers that check for IBC send and recieve transactions.
On each IBC transaction, we save the data for the transaction as well as data about the channel the tranaction occurred on

It introduces two models for this purpose IBCChannel and IBCTransfer

IBCChannel
image

IBCTransfer
image

if (!packetSrcPortAttr || packetSrcPortAttr.value !== TRANSFER_PORT_VALUE) {
logger.warn("packet_src_port is not transfer");
return;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible that event attributes are not encoded? While working on indexing balances, I noticed that some events had attributes that were not encoded.

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 it is possible. in fact, packet_src_port is not encoded

schema.graphql Outdated
channel: IBCChannel!
srcAccount: Account!
destAccount: Account!
denomination: String!
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to denom

amount,
TransferType.SEND,
);
transferRecord.save();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should await on the returned value of .save() otherwise the record might not get saved.

amount,
TransferType.RECEIVE,
);
transferRecord.save();
Copy link
Contributor

Choose a reason for hiding this comment

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

Must await on .save().

const generatedEscrowAddress = getEscrowAddress(TRANSFER_PORT_VALUE, channelName);

const channelRecord = new IBCChannel(channelName, channelName, generatedEscrowAddress);
channelRecord.save();
Copy link
Contributor

Choose a reason for hiding this comment

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

await on .save() return value.

@toliaqat toliaqat merged commit f5e4ccb into main May 6, 2024
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