From 38023496ad7f20cf4b574837542008dc0e19a890 Mon Sep 17 00:00:00 2001 From: knikos Date: Thu, 27 Apr 2023 14:17:36 +0300 Subject: [PATCH] [PVM] Added getters in claimtx --- src/apis/platformvm/claimtx.ts | 13 +++++++++++++ tests/apis/platformvm/claimtx.test.ts | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/src/apis/platformvm/claimtx.ts b/src/apis/platformvm/claimtx.ts index 0455f9916..179734bff 100644 --- a/src/apis/platformvm/claimtx.ts +++ b/src/apis/platformvm/claimtx.ts @@ -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 + } } /** @@ -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. * diff --git a/tests/apis/platformvm/claimtx.test.ts b/tests/apis/platformvm/claimtx.test.ts index d3400bb96..ab3a24db0 100644 --- a/tests/apis/platformvm/claimtx.test.ts +++ b/tests/apis/platformvm/claimtx.test.ts @@ -105,6 +105,13 @@ describe("ClaimTx", (): void => { expect(claimTxTypeID).toBe(PlatformVMConstants.CLAIMTX) }) + test("getClaimAmounts", async (): Promise => { + const claimAmounts: ClaimAmount[] = claimTx.getClaimAmounts() + expect(claimAmounts).toStrictEqual([ + new ClaimAmount(ownerID, ClaimType.EXPIRED_DEPOSIT_REWARD, new BN(1)) + ]) + }) + test("toBuffer and fromBuffer", async (): Promise => { const buf: Buffer = claimTx.toBuffer() const asvTx: ClaimTx = new ClaimTx()