From 4d33de1691528eca4a34064066667d2c6c809132 Mon Sep 17 00:00:00 2001 From: Dmitryii Osipov Date: Tue, 23 Jan 2024 15:23:23 +0400 Subject: [PATCH] [api] Update voucher details. Release `0.36.1` (#1476) --- api/CHANGELOG.md | 8 ++++++++ api/package.json | 2 +- api/src/Voucher.ts | 5 +++-- api/src/types/interfaces/voucher.ts | 8 ++++++-- api/test/Voucher.test.ts | 4 +++- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/api/CHANGELOG.md b/api/CHANGELOG.md index 160c27f69f..10c865aaf4 100644 --- a/api/CHANGELOG.md +++ b/api/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.36.1 + +_01/23/2024_ + +### Changes +https://github.com/gear-tech/gear-js/pull/1476 +- Add `codeUploadin` field to `VoucherDetails` + ## 0.36.0 _01/23/2024_ diff --git a/api/package.json b/api/package.json index c927179027..439fe6fa57 100644 --- a/api/package.json +++ b/api/package.json @@ -1,6 +1,6 @@ { "name": "@gear-js/api", - "version": "0.36.0", + "version": "0.36.1", "description": "A JavaScript library that provides functionality to connect GEAR Component APIs.", "main": "cjs/index.js", "module": "index.js", diff --git a/api/src/Voucher.ts b/api/src/Voucher.ts index 007ea50140..edfa753519 100644 --- a/api/src/Voucher.ts +++ b/api/src/Voucher.ts @@ -32,7 +32,7 @@ export class GearVoucher extends GearTransaction { */ async issue( spender: HexString, - value: number | bigint | BalanceOf, + value: number | bigint | BalanceOf | string, duration?: number, programs?: HexString[], codeUploading = false, @@ -290,12 +290,13 @@ export class GearVoucher extends GearTransaction { return null; } - const { owner, programs, expiry } = voucher.unwrap(); + const { owner, programs, expiry, codeUploading } = voucher.unwrap(); return { owner: owner.toHex(), programs: programs.unwrapOrDefault().toJSON() as string[], expiry: expiry.toNumber(), + codeUploading: codeUploading.isTrue, }; } diff --git a/api/src/types/interfaces/voucher.ts b/api/src/types/interfaces/voucher.ts index 3ead837628..e0642e20a6 100644 --- a/api/src/types/interfaces/voucher.ts +++ b/api/src/types/interfaces/voucher.ts @@ -37,11 +37,15 @@ export interface IVoucherDetails { */ owner: HexString; /** - * The voucher validity. + * The block number at and after which voucher couldn't be used and can be revoked by owner. */ expiry: number; /** - * The voucher programs. + * Set of programs this voucher could be used to interact with. */ programs: string[]; + /** + * Flag if this voucher's covers uploading codes as prepaid call. + */ + codeUploading: boolean; } diff --git a/api/test/Voucher.test.ts b/api/test/Voucher.test.ts index b7318557a5..ef2a946259 100644 --- a/api/test/Voucher.test.ts +++ b/api/test/Voucher.test.ts @@ -131,11 +131,13 @@ describe('Voucher', () => { expect(details).toHaveProperty('programs'); expect(details).toHaveProperty('owner'); expect(details).toHaveProperty('expiry'); - expect(Object.keys(details)).toHaveLength(3); + expect(details).toHaveProperty('codeUploading'); + expect(Object.keys(details)).toHaveLength(4); expect(details.programs).toHaveLength(1); expect(details.programs[0]).toBe(programId); expect(details.owner).toBe(decodeAddress(alice.address)); expect(details.expiry).toBe(validUpTo); + expect(details.codeUploading).toBeTruthy(); }); test('Send msg with voucher', async () => {