From 32d09760656915f8cdbebffcf3cee940442f4080 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Illodo=20Brea?= Date: Fri, 3 Jul 2020 12:57:25 +0200 Subject: [PATCH] fix: Types for `sequence` parameter (#274) --- docs/api-docs/classes/bncclient.md | 16 ++++++++-------- src/client/index.ts | 12 ++++++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/api-docs/classes/bncclient.md b/docs/api-docs/classes/bncclient.md index 82de23b8..78674051 100644 --- a/docs/api-docs/classes/bncclient.md +++ b/docs/api-docs/classes/bncclient.md @@ -458,7 +458,7 @@ ___ ### list -▸ **list**(`address`: string, `proposalId`: number, `baseAsset`: string, `quoteAsset`: string, `initPrice`: number, `sequence`: null): *Promise‹object›* +▸ **list**(`address`: string, `proposalId`: number, `baseAsset`: string, `quoteAsset`: string, `initPrice`: number, `sequence`: number | null): *Promise‹object›* **Parameters:** @@ -469,7 +469,7 @@ Name | Type | Default | Description | `baseAsset` | string | - | - | `quoteAsset` | string | - | - | `initPrice` | number | - | - | -`sequence` | null | null | optional sequence | +`sequence` | number | null | null | optional sequence | **Returns:** *Promise‹object›* @@ -501,7 +501,7 @@ ___ ### multiSend -▸ **multiSend**(`fromAddress`: string, `outputs`: Transfer[], `memo`: string, `sequence`: null): *Promise‹object›* +▸ **multiSend**(`fromAddress`: string, `outputs`: Transfer[], `memo`: string, `sequence`: number | null): *Promise‹object›* Create and sign a multi send tx @@ -535,7 +535,7 @@ Name | Type | Default | Description | `fromAddress` | string | - | - | `outputs` | Transfer[] | - | - | `memo` | string | "" | optional memo | -`sequence` | null | null | optional sequence | +`sequence` | number | null | null | optional sequence | **Returns:** *Promise‹object›* @@ -680,7 +680,7 @@ ___ ### setAccountFlags -▸ **setAccountFlags**(`address`: string, `flags`: number, `sequence`: null): *Promise‹object›* +▸ **setAccountFlags**(`address`: string, `flags`: number, `sequence`: number | null): *Promise‹object›* Set account flags @@ -690,7 +690,7 @@ Name | Type | Default | Description | ------ | ------ | ------ | ------ | `address` | string | - | - | `flags` | number | - | new value of account flags | -`sequence` | null | null | optional sequence | +`sequence` | number | null | null | optional sequence | **Returns:** *Promise‹object›* @@ -769,7 +769,7 @@ ___ ### transfer -▸ **transfer**(`fromAddress`: string, `toAddress`: string, `amount`: BigSource, `asset`: string, `memo`: string, `sequence`: null): *Promise‹object›* +▸ **transfer**(`fromAddress`: string, `toAddress`: string, `amount`: BigSource, `asset`: string, `memo`: string, `sequence`: number | null): *Promise‹object›* Transfer tokens from one address to another. @@ -782,7 +782,7 @@ Name | Type | Default | Description | `amount` | BigSource | - | - | `asset` | string | - | - | `memo` | string | "" | optional memo | -`sequence` | null | null | optional sequence | +`sequence` | number | null | null | optional sequence | **Returns:** *Promise‹object›* diff --git a/src/client/index.ts b/src/client/index.ts index b83bf0b5..48e13ec3 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -338,7 +338,7 @@ export class BncClient { amount: BigSource, asset: string, memo = "", - sequence = null + sequence: number | null = null ) { const accCode = crypto.decodeAddress(fromAddress) const toAccCode = crypto.decodeAddress(toAddress) @@ -438,7 +438,7 @@ export class BncClient { fromAddress: string, outputs: Transfer[], memo = "", - sequence = null + sequence: number | null = null ) { if (!fromAddress) { throw new Error("fromAddress should not be falsy") @@ -641,7 +641,7 @@ export class BncClient { baseAsset: string, quoteAsset: string, initPrice: number, - sequence = null + sequence: number | null = null ) { const accCode = crypto.decodeAddress(address) @@ -749,7 +749,11 @@ export class BncClient { * @param {Number} sequence optional sequence * @return {Promise} resolves with response (success or fail) */ - async setAccountFlags(address: string, flags: number, sequence = null) { + async setAccountFlags( + address: string, + flags: number, + sequence: number | null = null + ) { const accCode = crypto.decodeAddress(address) const msg = {