@stabbleorg/anchor-contrib
Advanced tools
Comparing version 1.4.4 to 1.4.5
@@ -12,8 +12,4 @@ export declare const SMART_TRANSACTION_TIMEOUT = 60000; | ||
}; | ||
type NativeBalance = { | ||
lamports?: number; | ||
}; | ||
type SearchAssetsResponse = { | ||
items: TokenBalance[]; | ||
nativeBalance: NativeBalance; | ||
}; | ||
@@ -20,0 +16,0 @@ } |
@@ -81,2 +81,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const lamports = yield this.provider.connection.getBalance(this.walletAddress); | ||
const response = yield fetch(this.provider.connection.rpcEndpoint, { | ||
@@ -95,5 +96,5 @@ method: "POST", | ||
showGrandTotal: false, | ||
showNativeBalance: true, | ||
showNativeBalance: false, | ||
showInscription: false, | ||
showZeroBalance: true, | ||
showZeroBalance: false, | ||
}, | ||
@@ -118,8 +119,8 @@ }, | ||
}); | ||
if (result.nativeBalance.lamports) { | ||
if (lamports) { | ||
const wrappedSOL = balances.find((balance) => balance.address.equals(spl_token_1.NATIVE_MINT)); | ||
const uiAmountString = utils_1.SafeAmount.toNanoString(result.nativeBalance.lamports); | ||
const uiAmountString = utils_1.SafeAmount.toNanoString(lamports); | ||
if (wrappedSOL) { | ||
const newUiAmount = new decimal_js_1.default(wrappedSOL.uiAmountString).add(new decimal_js_1.default(uiAmountString)).toDP(9); | ||
wrappedSOL.amount = new decimal_js_1.default(wrappedSOL.amount).add(new decimal_js_1.default(result.nativeBalance.lamports)).toFixed(); | ||
wrappedSOL.amount = new decimal_js_1.default(wrappedSOL.amount).add(new decimal_js_1.default(lamports)).toFixed(); | ||
wrappedSOL.uiAmountString = newUiAmount.toFixed(); | ||
@@ -131,3 +132,3 @@ wrappedSOL.uiAmount = newUiAmount.toNumber(); | ||
address: spl_token_1.NATIVE_MINT, | ||
amount: result.nativeBalance.lamports.toString(), | ||
amount: lamports.toString(), | ||
decimals: 9, | ||
@@ -134,0 +135,0 @@ uiAmountString, |
{ | ||
"name": "@stabbleorg/anchor-contrib", | ||
"version": "1.4.4", | ||
"version": "1.4.5", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -17,9 +17,4 @@ // The transaction will be routed through Helius's staked | ||
export type NativeBalance = { | ||
lamports?: number; | ||
}; | ||
export type SearchAssetsResponse = { | ||
items: TokenBalance[]; | ||
nativeBalance: NativeBalance; | ||
}; | ||
@@ -26,0 +21,0 @@ } |
@@ -118,2 +118,4 @@ import bs58 from "bs58"; | ||
async getTokenBalances(): Promise<TokenAccountBalancePair[]> { | ||
const lamports = await this.provider.connection.getBalance(this.walletAddress); | ||
const response = await fetch(this.provider.connection.rpcEndpoint, { | ||
@@ -132,5 +134,5 @@ method: "POST", | ||
showGrandTotal: false, | ||
showNativeBalance: true, | ||
showNativeBalance: false, | ||
showInscription: false, | ||
showZeroBalance: true, | ||
showZeroBalance: false, | ||
}, | ||
@@ -158,9 +160,9 @@ }, | ||
if (result.nativeBalance.lamports) { | ||
if (lamports) { | ||
const wrappedSOL = balances.find((balance) => balance.address.equals(NATIVE_MINT)); | ||
const uiAmountString = SafeAmount.toNanoString(result.nativeBalance.lamports); | ||
const uiAmountString = SafeAmount.toNanoString(lamports); | ||
if (wrappedSOL) { | ||
const newUiAmount = new Decimal(wrappedSOL.uiAmountString!).add(new Decimal(uiAmountString)).toDP(9); | ||
wrappedSOL.amount = new Decimal(wrappedSOL.amount).add(new Decimal(result.nativeBalance.lamports)).toFixed(); | ||
wrappedSOL.amount = new Decimal(wrappedSOL.amount).add(new Decimal(lamports)).toFixed(); | ||
wrappedSOL.uiAmountString = newUiAmount.toFixed(); | ||
@@ -171,3 +173,3 @@ wrappedSOL.uiAmount = newUiAmount.toNumber(); | ||
address: NATIVE_MINT, | ||
amount: result.nativeBalance.lamports.toString(), | ||
amount: lamports.toString(), | ||
decimals: 9, | ||
@@ -174,0 +176,0 @@ uiAmountString, |
Sorry, the diff of this file is not supported yet
48094
884