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

[PVM] Added getters in claimtx #72

Merged
merged 1 commit into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/apis/platformvm/claimtx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ export class ClaimAmount {
this.amount = bintools.fromBNToBuffer(amount, 8)
if (typeof auth != "undefined") this.auth.setAddressIndices(auth)
}

getID(): Buffer {
return this.id
}
getType(): Buffer {
return this.type
}
getAmount(): Buffer {
return this.amount
}
}

/**
Expand Down Expand Up @@ -151,6 +161,9 @@ export class ClaimTx extends BaseTx {
return this._typeID
}

getClaimAmounts(): ClaimAmount[] {
return this.claimAmounts
}
/**
* Takes a {@link https://github.com/feross/buffer|Buffer} containing a [[ClaimTx]], parses it, populates the class, and returns the length of the [[ClaimTx]] in bytes.
*
Expand Down
7 changes: 7 additions & 0 deletions tests/apis/platformvm/claimtx.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ describe("ClaimTx", (): void => {
expect(claimTxTypeID).toBe(PlatformVMConstants.CLAIMTX)
})

test("getClaimAmounts", async (): Promise<void> => {
const claimAmounts: ClaimAmount[] = claimTx.getClaimAmounts()
expect(claimAmounts).toStrictEqual([
new ClaimAmount(ownerID, ClaimType.EXPIRED_DEPOSIT_REWARD, new BN(1))
])
})

test("toBuffer and fromBuffer", async (): Promise<void> => {
const buf: Buffer = claimTx.toBuffer()
const asvTx: ClaimTx = new ClaimTx()
Expand Down