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

Implemented Token Management Transactions Outcome Parser #381

Merged
merged 5 commits into from
Feb 20, 2024

Conversation

popenta
Copy link
Contributor

@popenta popenta commented Feb 15, 2024

Implemented the transaction parser for Token Management Transactions. This is meant to be used together with the TokenManagementTransactionsFactory.

@popenta popenta self-assigned this Feb 15, 2024
@@ -106,6 +103,9 @@ export interface IBurnQuantityOutcome {
burntQuantity: string;
}

/**
* @deprecated Use {@link TokenManagementTransactionsOutcomeParser}
Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, we are deprecating this 👍

CC: @arhtudormorar

@@ -0,0 +1,55 @@
export class TransactionEvent {
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can apply this pattern on TransactionNext, as well (Partial & Object.assign).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

this.ensureNoError(transactionOutcome.transactionLogs.events);

const event = this.findSingleEventByIdentifier(transactionOutcome, "issue");
const identifer = this.extractTokenIdentifier(event);
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo - here and below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed


let roles: string[] = [];
for (const role of encodedRoles) {
const decodedRole = Buffer.from(role, "base64");
Copy link
Contributor

Choose a reason for hiding this comment

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

Decoding from base64 is used in several places - perhaps extract it to decodeTopicAsString() or something similar? Optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

parseNftCreate(transactionOutcome: TransactionOutcome): {
tokenIdentifier: string;
nonce: bigint;
initialQuantity: bigint;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice 👍

});

it("should test parse issue fungible", () => {
const identifer = "ZZZ-9ee87d";
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo (and below).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

});

const logs = new TransactionLogs({ events: [event] });
const scResult = new SmartContractResult({});
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the test work if we don't pass smartContractResults? If so, let's simplify it (better for advertising the parsers).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does work. Will remove empty objects.

events: [event],
});

const scResult = new SmartContractResult({});
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here (and below), if possible to not pass scResult (if not needed), let's do that. On the other hand, it's worth to emphasize that the parser is able to gather logs from the contract results, as well - and you have an example for that below 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed. Changed!

andreibancioiu
andreibancioiu previously approved these changes Feb 16, 2024
@popenta popenta merged commit f325af9 into feat/next Feb 20, 2024
1 check passed
@popenta popenta deleted the token-management-tx-parser branch February 20, 2024 12:11
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