-
Notifications
You must be signed in to change notification settings - Fork 37
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
Conversation
@@ -106,6 +103,9 @@ export interface IBurnQuantityOutcome { | |||
burntQuantity: string; | |||
} | |||
|
|||
/** | |||
* @deprecated Use {@link TokenManagementTransactionsOutcomeParser} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo - here and below.
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo (and below).
There was a problem hiding this comment.
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({}); |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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({}); |
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed. Changed!
Implemented the transaction parser for Token Management Transactions. This is meant to be used together with the
TokenManagementTransactionsFactory
.