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

Make Provider.getMessageByNonce return parsed data #3070

Closed
LuizAsFight opened this issue Sep 1, 2024 · 1 comment · Fixed by #3098
Closed

Make Provider.getMessageByNonce return parsed data #3070

LuizAsFight opened this issue Sep 1, 2024 · 1 comment · Fixed by #3098
Assignees
Labels
feat Issue is a feature

Comments

@LuizAsFight
Copy link
Contributor

LuizAsFight commented Sep 1, 2024

The method Provider.getMessages returns the data parsed

async getMessages(
address: string | AbstractAddress,
paginationArgs?: CursorPaginationArgs
): Promise<GetMessagesResponse> {
const {
messages: { edges, pageInfo },
} = await this.operations.getMessages({
...this.validatePaginationArgs({
inputArgs: paginationArgs,
paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
}),
owner: Address.fromAddressOrString(address).toB256(),
});
const messages = edges.map(({ node }) => ({
messageId: InputMessageCoder.getMessageId({
sender: node.sender,
recipient: node.recipient,
nonce: node.nonce,
amount: bn(node.amount),
data: node.data,
}),
sender: Address.fromAddressOrString(node.sender),
recipient: Address.fromAddressOrString(node.recipient),
nonce: node.nonce,
amount: bn(node.amount),
data: InputMessageCoder.decodeData(node.data),
daHeight: bn(node.daHeight),
}));
return {
messages,
pageInfo,
};
}

while the Provider.getMessageByNonce returns directly the graphql response, I think they should return the same

* @returns A promise that resolves to the Message object or null.
*/
async getMessageByNonce(nonce: string): Promise<GqlMessage | null> {
const { message } = await this.operations.getMessageByNonce({ nonce });
if (!message) {
return null;
}
return message;
}

@arboleya arboleya added the feat Issue is a feature label Sep 1, 2024
@arboleya
Copy link
Member

arboleya commented Sep 3, 2024

Also, provider.getMessages() returns the full messages with all the fields, including messageId while provider.getMessageByNonce() skips the messageId field.

cc @DefiCake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Issue is a feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants