Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Pull balances /w block-height | fetch tokenPrice for native token #119

Merged
merged 30 commits into from
Dec 4, 2023
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ebc15e7
Pull balances|Add opt block height /w fetching native balance
abhidtu2014 Nov 20, 2023
ec75a58
Add commitment in solana getBlockHeight
abhidtu2014 Nov 20, 2023
1890c8c
Refactor appending token balances in usd
abhidtu2014 Nov 20, 2023
dccaca9
Fix minor issue | fix type issue
abhidtu2014 Nov 20, 2023
65fb052
Bump with beta version
abhidtu2014 Nov 21, 2023
fa02da4
Make sure to compute tokenBalance in bigint
abhidtu2014 Nov 21, 2023
f26d81e
Refactor | Add usd balance for native tokens
abhidtu2014 Nov 23, 2023
d8c9754
Update code for all the chains
abhidtu2014 Nov 23, 2023
2d0b57e
Fix type issue
abhidtu2014 Nov 23, 2023
ac1b75a
Use number instead of bigint to avoid conversion issues
abhidtu2014 Nov 24, 2023
99b731c
Fix cache invalidation of token prices
abhidtu2014 Nov 24, 2023
64ced96
Accept blockHeightByChain as option in pullBalances method
abhidtu2014 Nov 24, 2023
ae5b0a9
Sync client wallet manager with wallet-manager changes
abhidtu2014 Nov 24, 2023
ec1212b
Fix Injecting native tokens logic
abhidtu2014 Nov 24, 2023
607b308
Lift priceFeedOptions as walletOptions
abhidtu2014 Nov 24, 2023
9020fe0
Optimize price feed instance instantiation
abhidtu2014 Nov 24, 2023
e21a2e1
Bump version
abhidtu2014 Nov 24, 2023
85af2ac
Add comment for wallet balance config
abhidtu2014 Nov 24, 2023
7c90d2e
Add chainName in balances schema
abhidtu2014 Nov 28, 2023
afa0653
Bump version
abhidtu2014 Nov 28, 2023
92e4ce5
minor update
abhidtu2014 Nov 28, 2023
2386304
publish beta version for integration
abhidtu2014 Nov 28, 2023
ed0112a
Revert mandatory blockHeight
abhidtu2014 Nov 28, 2023
fe3b028
Expose blockHeightPerChain method|remove chainName from balance
abhidtu2014 Nov 29, 2023
ba555ff
Bump package to latest version w.r.t main branch
abhidtu2014 Nov 29, 2023
3081d0c
Merge main branch
abhidtu2014 Nov 29, 2023
b9c8262
Resolve PR review comment
abhidtu2014 Dec 4, 2023
5c36e3e
Merge main branch
abhidtu2014 Dec 4, 2023
77fd30c
Add coingeckoIds for cosm-wasm chains
abhidtu2014 Dec 4, 2023
8ca519b
Bump version
abhidtu2014 Dec 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add commitment in solana getBlockHeight
abhidtu2014 committed Nov 20, 2023
commit ec75a58c3194cebba28e7c37f79d8eed59ccb28c
6 changes: 4 additions & 2 deletions src/balances/solana.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import bs58 from 'bs58';
import { Connection, PublicKey, Keypair } from "@solana/web3.js";
import { Balance } from "./index";
import { SOLANA_DEFAULT_COMMITMENT } from '../wallets/solana/solana.config';

export async function pullSolanaNativeBalance(
connection: Connection,
address: string
address: string,
): Promise<Balance> {
const lamports = await connection.getBalance(new PublicKey(address))
// solana web3.js doesn't support passing exact slot(block number) only minSlot, while fetching balance
const lamports = await connection.getBalance(new PublicKey(address), SOLANA_DEFAULT_COMMITMENT)

return {
isNative: true,
2 changes: 2 additions & 0 deletions src/balances/sui.ts
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@ export interface SuiTransactionDetails {
export async function pullSuiNativeBalance(conn: Connection, address: string): Promise<WalletBalance> {
const provider = new JsonRpcProvider(conn);

// mysten SDK doesn't support passing checkpoint (block number) to getBalance
// https://github.com/MystenLabs/sui/issues/14137
const rawBalance = await provider.getBalance({ owner: address });

return {
4 changes: 2 additions & 2 deletions src/wallets/solana/index.ts
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ import {
RecentPrioritizationFees,
} from "@solana/web3.js";
import { decode } from "bs58";
import { SOLANA, SOLANA_CHAIN_CONFIG, SolanaNetworks } from "./solana.config";
import { SOLANA, SOLANA_CHAIN_CONFIG, SOLANA_DEFAULT_COMMITMENT, SolanaNetworks } from "./solana.config";
import { PYTHNET, PYTHNET_CHAIN_CONFIG } from "./pythnet.config";
import {
BaseWalletOptions,
@@ -304,6 +304,6 @@ export class SolanaWalletToolbox extends WalletToolbox {
}

public async getBlockHeight(): Promise<number> {
return this.connection.getBlockHeight();
return this.connection.getBlockHeight(SOLANA_DEFAULT_COMMITMENT);
}
}
1 change: 1 addition & 0 deletions src/wallets/solana/solana.config.ts
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ const SOLANA_TESTNET = 'solana-devnet';
const SOLANA_CURRENCY_SYMBOL = 'SOL';

export const SOLANA = 'solana';
export const SOLANA_DEFAULT_COMMITMENT = 'finalized';

export const SOLANA_NETWORKS = {
[SOLANA_MAINNET]: 1,