@debridge-finance/solana-utils 5.5.1 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +1771 -135
- package/dist/browser/index.js.map +1 -1
- package/dist/cjs/accounts.js +1 -8
- package/dist/cjs/accounts.js.map +1 -1
- package/dist/cjs/spl.js +175 -119
- package/dist/cjs/spl.js.map +1 -1
- package/dist/esm/accounts.js +1 -7
- package/dist/esm/accounts.js.map +1 -1
- package/dist/esm/spl.js +177 -124
- package/dist/esm/spl.js.map +1 -1
- package/dist/types/accounts.d.ts +1 -5
- package/dist/types/accounts.d.ts.map +1 -1
- package/dist/types/spl.d.ts +27 -28
- package/dist/types/spl.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/types/spl.d.ts
CHANGED
|
@@ -8,14 +8,16 @@ declare enum AccountState {
|
|
|
8
8
|
Initialized = 1,
|
|
9
9
|
Frozen = 2
|
|
10
10
|
}
|
|
11
|
-
type
|
|
11
|
+
export type ExistingAccountBalance = {
|
|
12
12
|
balance: number;
|
|
13
13
|
spl?: {
|
|
14
14
|
mint: PublicKey;
|
|
15
15
|
owner: PublicKey;
|
|
16
16
|
balance: bigint;
|
|
17
|
+
isToken22: boolean;
|
|
17
18
|
};
|
|
18
19
|
};
|
|
20
|
+
export type AccountBalance = ExistingAccountBalance | null;
|
|
19
21
|
type SplDiff = {
|
|
20
22
|
mint: PublicKey;
|
|
21
23
|
owner: PublicKey;
|
|
@@ -67,19 +69,29 @@ export interface WalletInfo {
|
|
|
67
69
|
/** True if the account is a token 2022 */
|
|
68
70
|
isToken22: boolean;
|
|
69
71
|
}
|
|
72
|
+
export interface TokenInfo {
|
|
73
|
+
/** Address of the token mint */
|
|
74
|
+
address: PublicKey;
|
|
75
|
+
/** Number of decimals in the token */
|
|
76
|
+
decimals: number;
|
|
77
|
+
/** Name of the token */
|
|
78
|
+
name: string;
|
|
79
|
+
/** Symbol of the token */
|
|
80
|
+
symbol: string;
|
|
81
|
+
/** URI with more info about the token (usually link to json with image, description, etc) */
|
|
82
|
+
json: string;
|
|
83
|
+
/**
|
|
84
|
+
* Address of the token program (can be TOKEN_PROGRAM_ID or TOKEN_2022_PROGRAM_ID). Used to distinguish between token 2022 and legacy token, and to create correct associated accounts
|
|
85
|
+
*/
|
|
86
|
+
tokenProgram: PublicKey;
|
|
87
|
+
}
|
|
70
88
|
/**
|
|
71
89
|
* Get name, symbol and decimals for provided token
|
|
72
90
|
* @param connection solana web3 connection
|
|
73
91
|
* @param tokenAddress address to get metaplex info for
|
|
74
92
|
* @returns
|
|
75
93
|
*/
|
|
76
|
-
export declare function getTokenInfo(connection: Connection, tokenAddress: PublicKey): Promise<
|
|
77
|
-
address: PublicKey;
|
|
78
|
-
decimals: number;
|
|
79
|
-
name: string;
|
|
80
|
-
symbol: string;
|
|
81
|
-
json: string;
|
|
82
|
-
} | null>;
|
|
94
|
+
export declare function getTokenInfo(connection: Connection, tokenAddress: PublicKey, useCache?: boolean): Promise<TokenInfo | null>;
|
|
83
95
|
/**
|
|
84
96
|
* Builds instruction for creation of associated wallet for specified token
|
|
85
97
|
* @param tokenMint mint account of SPL-token
|
|
@@ -89,10 +101,9 @@ export declare function getTokenInfo(connection: Connection, tokenAddress: Publi
|
|
|
89
101
|
* @param isToken2022
|
|
90
102
|
* @param associatedTokenProgramId
|
|
91
103
|
*/
|
|
92
|
-
export declare function createAssociatedWalletInstruction(tokenMint: SolanaPubkey, associatedAccount: PublicKey, owner: SolanaPubkey, payer: SolanaPubkey, isToken2022
|
|
104
|
+
export declare function createAssociatedWalletInstruction(tokenMint: SolanaPubkey, associatedAccount: PublicKey, owner: SolanaPubkey, payer: SolanaPubkey, isToken2022: boolean, associatedTokenProgramId?: PublicKey): TransactionInstruction;
|
|
93
105
|
export declare function parseSplAccount(info: AccountInfo<Buffer> | null): null | RawAccount;
|
|
94
106
|
export declare function parseSplAccount(data: Buffer): null | RawAccount;
|
|
95
|
-
export declare function isWalletCorrectATA(walletAddress: SolanaPubkey, data: Buffer): boolean;
|
|
96
107
|
/**
|
|
97
108
|
* Requests account from blockchain and returns result with account type
|
|
98
109
|
* @param account address of account
|
|
@@ -100,21 +111,16 @@ export declare function isWalletCorrectATA(walletAddress: SolanaPubkey, data: Bu
|
|
|
100
111
|
*/
|
|
101
112
|
export declare function getAccountWithType(connection: Connection, account: SolanaPubkey): Promise<[AccountInfo<Buffer> | null, AccountType]>;
|
|
102
113
|
/**
|
|
103
|
-
* Returns balance of
|
|
104
|
-
* @param wallet wallet to inspect
|
|
105
|
-
*/
|
|
106
|
-
export declare function getNativeWalletBalance(connection: Connection, wallet: SolanaPubkey): Promise<BN>;
|
|
107
|
-
/**
|
|
108
|
-
* Returns balance of associated wallet in SPL-tokens
|
|
114
|
+
* Returns balance of associated wallet in SPL-tokens (finds correct ata (token/token22))
|
|
109
115
|
* @param originalWallet native tokens wallet address
|
|
110
116
|
* @param tokenMint mint of SPL-Token
|
|
111
117
|
*/
|
|
112
|
-
export declare function getAssocSPLWalletBalance(connection: Connection, originalWallet: SolanaPubkey, tokenMint: SolanaPubkey): Promise<
|
|
118
|
+
export declare function getAssocSPLWalletBalance(connection: Connection, originalWallet: SolanaPubkey, tokenMint: SolanaPubkey): Promise<AccountBalance>;
|
|
113
119
|
/**
|
|
114
|
-
* Returns balance of specified
|
|
120
|
+
* Returns balance of specified wallets. null if account doesn't exist
|
|
115
121
|
* @param wallet spl-tokens wallet address
|
|
116
122
|
*/
|
|
117
|
-
export declare function
|
|
123
|
+
export declare function getWalletsBalances(connection: Connection, wallets: SolanaPubkey[]): Promise<AccountBalance[]>;
|
|
118
124
|
/**
|
|
119
125
|
* Gets list of user's SPL-token accounts
|
|
120
126
|
* @param owner owner of the SPL wallets
|
|
@@ -142,16 +148,9 @@ export declare function buildReplenishWsolBalanceTransaction(amount: AmountType,
|
|
|
142
148
|
* @param owner owner of created wallet
|
|
143
149
|
*/
|
|
144
150
|
export declare function updateWsolBalance(connection: Connection, amount: AmountType, owner: SolanaPubkey): Promise<Transaction | null>;
|
|
145
|
-
/**
|
|
146
|
-
* Checks existance of associated wallet for specified token
|
|
147
|
-
* @param mintAccount mint account of SPL-token
|
|
148
|
-
* @param originalWallet account of solana wallet
|
|
149
|
-
* @returns true if account exists
|
|
150
|
-
*/
|
|
151
|
-
export declare function checkIfAssociatedWalletExists(connection: Connection, mintAccount: PublicKey, originalWallet: PublicKey): Promise<boolean>;
|
|
152
151
|
export declare function getTransactionAccountsForSimulationDiff(connection: Connection, tx: VersionedTransaction | Transaction): Promise<string[]>;
|
|
153
|
-
export declare function parseMultipleAccounts(accounts: (AccountInfo<Buffer> | null)[] | (SimulatedTransactionAccountInfo | null)[]): AccountBalance
|
|
154
|
-
export declare function getSplDiff(pre:
|
|
152
|
+
export declare function parseMultipleAccounts(accounts: (AccountInfo<Buffer> | null)[] | (SimulatedTransactionAccountInfo | null)[]): Array<AccountBalance>;
|
|
153
|
+
export declare function getSplDiff(pre: ExistingAccountBalance["spl"], post: ExistingAccountBalance["spl"]): SplDiff;
|
|
155
154
|
export declare function getTransactionDiff(connection: Connection, tx: VersionedTransaction, txAccounts?: PublicKey[]): Promise<Map<string, AccountBalanceDiff>>;
|
|
156
155
|
export {};
|
|
157
156
|
//# sourceMappingURL=spl.d.ts.map
|
package/dist/types/spl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spl.d.ts","sourceRoot":"","sources":["../../src/spl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,UAAU,EACV,SAAS,EACT,+BAA+B,EAE/B,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAWzB,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"spl.d.ts","sourceRoot":"","sources":["../../src/spl.ts"],"names":[],"mappings":"AAAA,OAA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BAAiB,CACrC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,YAAY,GAClB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAoC7B;AAED,wBAAsB,uCAAuC,CAC3D,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,oBAAoB,GAAG,WAAW,GACrC,OAAO,CAAC,MAAM,EAAE,CAAC,CAyCnB;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EACJ,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,GAC9B,CAAC,+BAA+B,GAAG,IAAI,CAAC,EAAE,GAC7C,KAAK,CAAC,cAAc,CAAC,CAsCvB;AAED,wBAAgB,UAAU,CACxB,GAAG,EAAE,sBAAsB,CAAC,KAAK,CAAC,EAClC,IAAI,EAAE,sBAAsB,CAAC,KAAK,CAAC,GAK3B,OAAO,CAOhB;AAED,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,oBAAoB,EACxB,UAAU,CAAC,EAAE,SAAS,EAAE,GACvB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CA8D1C"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@debridge-finance/solana-utils",
|
|
3
3
|
"description": "Common utils package to power communication with Solana contracts at deBridge",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.1.0",
|
|
5
5
|
"author": "deBridge",
|
|
6
6
|
"license": "BUSL-1.1",
|
|
7
7
|
"homepage": "https://debridge.finance",
|