From f5dcb7fdfc38e867856fb40695328a4119715854 Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Thu, 14 Nov 2024 15:46:56 +0000 Subject: [PATCH 1/3] expose global balance --- client/ts/src/global.ts | 11 +++++++++++ client/ts/src/index.ts | 1 + 2 files changed, 12 insertions(+) diff --git a/client/ts/src/global.ts b/client/ts/src/global.ts index 2de617d3f..a8642e737 100644 --- a/client/ts/src/global.ts +++ b/client/ts/src/global.ts @@ -107,6 +107,17 @@ export class Global { return toNum(deposit.balanceAtoms) / 10 ** decimals; } + getGlobalBalanceTokensWithDecimals(trader: PublicKey, decimals: number): number { + const deposit: GlobalDeposit | undefined = this.data.globalDeposits.find( + (seat) => seat.trader.equals(trader), + ); + if (!deposit) { + return 0; + } else { + return toNum(deposit.balanceAtoms) / 10 ** decimals; + } + } + tokenMint(): PublicKey { return this.data.mint; } diff --git a/client/ts/src/index.ts b/client/ts/src/index.ts index 446ad8383..2781efb33 100644 --- a/client/ts/src/index.ts +++ b/client/ts/src/index.ts @@ -1,5 +1,6 @@ export * from './client'; export * from './market'; +export * from './global'; export * from './types'; export * as manifest from './manifest'; export * as utils from './utils'; From 97c1e58a3576b1bc87a716e8f5bde4dc5a92cb8a Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Thu, 14 Nov 2024 15:47:29 +0000 Subject: [PATCH 2/3] ts client version bump to 0.1.68 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4a76b8a22..6d5898c7e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cks-systems/manifest-sdk", - "version": "0.1.67", + "version": "0.1.68", "files": [ "dist/", "README.md", From 57ff95e333c3184acb44a7b835d510ca78f284fd Mon Sep 17 00:00:00 2001 From: Maximilian Schneider Date: Thu, 14 Nov 2024 15:48:46 +0000 Subject: [PATCH 3/3] format --- client/ts/src/global.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/ts/src/global.ts b/client/ts/src/global.ts index a8642e737..3f5947027 100644 --- a/client/ts/src/global.ts +++ b/client/ts/src/global.ts @@ -107,7 +107,10 @@ export class Global { return toNum(deposit.balanceAtoms) / 10 ** decimals; } - getGlobalBalanceTokensWithDecimals(trader: PublicKey, decimals: number): number { + getGlobalBalanceTokensWithDecimals( + trader: PublicKey, + decimals: number, + ): number { const deposit: GlobalDeposit | undefined = this.data.globalDeposits.find( (seat) => seat.trader.equals(trader), );