From f2ce5f6c821f09b10f83d0dbd68900c05303165d Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Fri, 5 Mar 2021 11:53:45 -0700 Subject: [PATCH] fix: add TokenAccountBalancePair.uiAmountString (#15741) --- web3.js/module.d.ts | 3 ++- web3.js/module.flow.js | 3 ++- web3.js/src/connection.js | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/web3.js/module.d.ts b/web3.js/module.d.ts index 831231647..59113a01c 100644 --- a/web3.js/module.d.ts +++ b/web3.js/module.d.ts @@ -295,7 +295,8 @@ declare module '@solana/web3.js' { address: PublicKey; amount: string; decimals: number; - uiAmount: number; + uiAmount: number | null; + uiAmountString?: string; }; export type AccountChangeCallback = ( diff --git a/web3.js/module.flow.js b/web3.js/module.flow.js index c93d9453e..24498912c 100644 --- a/web3.js/module.flow.js +++ b/web3.js/module.flow.js @@ -308,7 +308,8 @@ declare module '@solana/web3.js' { address: PublicKey, amount: string, decimals: number, - uiAmount: number, + uiAmount: number | null, + uiAmountString?: string, }; declare type AccountChangeCallback = ( diff --git a/web3.js/src/connection.js b/web3.js/src/connection.js index 894ac863a..32ea54bd7 100644 --- a/web3.js/src/connection.js +++ b/web3.js/src/connection.js @@ -760,7 +760,8 @@ const GetSupplyRpcResult = jsonRpcResultAndContext( * @typedef {Object} TokenAmount * @property {string} amount Raw amount of tokens as string ignoring decimals * @property {number} decimals Number of decimals configured for token's mint - * @property {number} uiAmount Token account as float, accounts for decimals + * @property {number | null} uiAmount Token amount as float, accounts for decimals + * @property {string | undefined} uiAmountString Token amount as string, accounts for decimals */ type TokenAmount = { amount: string, @@ -786,13 +787,15 @@ const TokenAmountResult = pick({ * @property {PublicKey} address Address of the token account * @property {string} amount Raw amount of tokens as string ignoring decimals * @property {number} decimals Number of decimals configured for token's mint - * @property {number} uiAmount Token account as float, accounts for decimals + * @property {number | null} uiAmount Token amount as float, accounts for decimals + * @property {string | undefined} uiAmountString Token amount as string, accounts for decimals */ type TokenAccountBalancePair = { address: PublicKey, amount: string, decimals: number, uiAmount: number, + uiAmountString?: string, }; /** @@ -803,8 +806,9 @@ const GetTokenLargestAccountsResult = jsonRpcResultAndContext( pick({ address: PublicKeyFromString, amount: string(), - uiAmount: number(), + uiAmount: nullable(number()), decimals: number(), + uiAmountString: optional(nullable(string())), }), ), );