@vue-solana/core 1.0.0 → 1.2.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/address.d.cts +6 -0
- package/dist/address.d.mts +6 -0
- package/dist/address.d.ts +6 -0
- package/dist/clusters.d.cts +2 -1
- package/dist/clusters.d.mts +2 -1
- package/dist/clusters.d.ts +2 -1
- package/dist/index.cjs +18 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +6 -1
- package/dist/ios-wallet.d.cts +2 -1
- package/dist/ios-wallet.d.mts +2 -1
- package/dist/ios-wallet.d.ts +2 -1
- package/dist/kit.cjs +21 -0
- package/dist/kit.d.cts +5 -0
- package/dist/kit.d.mts +5 -0
- package/dist/kit.d.ts +5 -0
- package/dist/kit.mjs +18 -0
- package/dist/mobile-wallet.d.cts +2 -1
- package/dist/mobile-wallet.d.mts +2 -1
- package/dist/mobile-wallet.d.ts +2 -1
- package/dist/rpc.cjs +5 -1
- package/dist/rpc.d.cts +7 -1
- package/dist/rpc.d.mts +7 -1
- package/dist/rpc.d.ts +7 -1
- package/dist/rpc.mjs +5 -1
- package/dist/shared/{core.BU9rgxEj.cjs → core.BQoh-5Wu.cjs} +3 -0
- package/dist/shared/core.DAUuCWrr.d.cts +98 -0
- package/dist/shared/core.DAUuCWrr.d.mts +98 -0
- package/dist/shared/core.DAUuCWrr.d.ts +98 -0
- package/dist/shared/{core.BBMCTQpw.mjs → core.DjbtrJWl.mjs} +3 -0
- package/dist/spl-token.cjs +12 -0
- package/dist/spl-token.d.cts +4 -0
- package/dist/spl-token.d.mts +4 -0
- package/dist/spl-token.d.ts +4 -0
- package/dist/spl-token.mjs +1 -0
- package/dist/token-accounts.cjs +56 -0
- package/dist/token-accounts.d.cts +35 -0
- package/dist/token-accounts.d.mts +35 -0
- package/dist/token-accounts.d.ts +35 -0
- package/dist/token-accounts.mjs +52 -0
- package/dist/transaction.d.cts +15 -1
- package/dist/transaction.d.mts +15 -1
- package/dist/transaction.d.ts +15 -1
- package/dist/types.d.cts +3 -78
- package/dist/types.d.mts +3 -78
- package/dist/types.d.ts +3 -78
- package/dist/wallet-standard.cjs +1 -1
- package/dist/wallet-standard.d.cts +2 -1
- package/dist/wallet-standard.d.mts +2 -1
- package/dist/wallet-standard.d.ts +2 -1
- package/dist/wallet-standard.mjs +1 -1
- package/dist/wallet.d.cts +2 -1
- package/dist/wallet.d.mts +2 -1
- package/dist/wallet.d.ts +2 -1
- package/package.json +20 -2
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/// <reference path="../../types/web3-compat.d.ts" />
|
|
2
|
+
/// <reference path="../../types/buffer.d.ts" />
|
|
3
|
+
import { Commitment, SendOptions, Connection, Transaction, VersionedTransaction, PublicKey, TransactionSignature, RpcResponseAndContext, SignatureResult } from '@solana/web3-compat';
|
|
4
|
+
import * as _solana_kit from '@solana/kit';
|
|
5
|
+
import { Address } from '@solana/kit';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Create a @solana/kit client for the given Solana configuration.
|
|
9
|
+
*
|
|
10
|
+
* The returned client exposes read-only `rpc` and `rpcSubscriptions`; use
|
|
11
|
+
* `client.rpc.getSlot().send()` and friends instead of the legacy
|
|
12
|
+
* `connection` APIs.
|
|
13
|
+
*/
|
|
14
|
+
declare function createSolanaClient(config?: SolanaConfig): _solana_kit.Client<_solana_kit.ExtendedClient<object, {
|
|
15
|
+
rpc: _solana_kit.Rpc<_solana_kit.RequestAirdropApi & _solana_kit.GetAccountInfoApi & _solana_kit.GetAgGenesisCertApi & _solana_kit.GetBalanceApi & _solana_kit.GetBlockApi & _solana_kit.GetBlockCommitmentApi & _solana_kit.GetBlockHeightApi & _solana_kit.GetBlockProductionApi & _solana_kit.GetBlocksApi & _solana_kit.GetBlocksWithLimitApi & _solana_kit.GetBlockTimeApi & _solana_kit.GetClusterNodesApi & _solana_kit.GetEpochInfoApi & _solana_kit.GetEpochScheduleApi & _solana_kit.GetFeeForMessageApi & _solana_kit.GetFirstAvailableBlockApi & _solana_kit.GetGenesisHashApi & _solana_kit.GetHealthApi & _solana_kit.GetHighestSnapshotSlotApi & _solana_kit.GetIdentityApi & _solana_kit.GetInflationGovernorApi & _solana_kit.GetInflationRateApi & _solana_kit.GetInflationRewardApi & _solana_kit.GetLargestAccountsApi & _solana_kit.GetLatestBlockhashApi & _solana_kit.GetLeaderScheduleApi & _solana_kit.GetMaxRetransmitSlotApi & _solana_kit.GetMaxShredInsertSlotApi & _solana_kit.GetMinimumBalanceForRentExemptionApi & _solana_kit.GetMultipleAccountsApi & _solana_kit.GetProgramAccountsApi & _solana_kit.GetRecentPerformanceSamplesApi & _solana_kit.GetRecentPrioritizationFeesApi & _solana_kit.GetSignaturesForAddressApi & _solana_kit.GetSignatureStatusesApi & _solana_kit.GetSlotApi & _solana_kit.GetSlotLeaderApi & _solana_kit.GetSlotLeadersApi & _solana_kit.GetStakeMinimumDelegationApi & _solana_kit.GetSupplyApi & _solana_kit.GetTokenAccountBalanceApi & _solana_kit.GetTokenAccountsByDelegateApi & _solana_kit.GetTokenAccountsByOwnerApi & _solana_kit.GetTokenLargestAccountsApi & _solana_kit.GetTokenSupplyApi & _solana_kit.GetTransactionApi & _solana_kit.GetTransactionCountApi & _solana_kit.GetTransactionsForAddressApi & _solana_kit.GetVersionApi & _solana_kit.GetVoteAccountsApi & _solana_kit.IsBlockhashValidApi & _solana_kit.MinimumLedgerSlotApi & _solana_kit.SendTransactionApi & _solana_kit.SimulateTransactionApi>;
|
|
16
|
+
rpcSubscriptions: _solana_kit.RpcSubscriptions<_solana_kit.SolanaRpcSubscriptionsApi>;
|
|
17
|
+
}>>;
|
|
18
|
+
type SolanaClient = ReturnType<typeof createSolanaClient>;
|
|
19
|
+
|
|
20
|
+
type SolanaCluster = "mainnet-beta" | "testnet" | "devnet" | "localnet";
|
|
21
|
+
type SolanaChain = "solana:mainnet" | "solana:testnet" | "solana:devnet" | "solana:localnet";
|
|
22
|
+
interface SolanaConfig {
|
|
23
|
+
cluster?: SolanaCluster;
|
|
24
|
+
endpoint?: string;
|
|
25
|
+
wsEndpoint?: string;
|
|
26
|
+
commitment?: Commitment;
|
|
27
|
+
autoConnect?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface SolanaContext {
|
|
30
|
+
cluster: SolanaCluster;
|
|
31
|
+
endpoint: string;
|
|
32
|
+
wsEndpoint: string;
|
|
33
|
+
connection: Connection;
|
|
34
|
+
client: SolanaClient;
|
|
35
|
+
}
|
|
36
|
+
type SolanaTransaction = Transaction | VersionedTransaction;
|
|
37
|
+
interface SolanaSignMessageResult {
|
|
38
|
+
signedMessage: Uint8Array;
|
|
39
|
+
signature: Uint8Array;
|
|
40
|
+
}
|
|
41
|
+
interface SolanaWallet {
|
|
42
|
+
publicKey: PublicKey | null;
|
|
43
|
+
address?: Address;
|
|
44
|
+
connected: boolean;
|
|
45
|
+
connecting?: boolean;
|
|
46
|
+
disconnecting?: boolean;
|
|
47
|
+
platform?: SolanaWalletInfo["platform"];
|
|
48
|
+
source?: SolanaWalletInfo["source"];
|
|
49
|
+
connect: () => Promise<void>;
|
|
50
|
+
disconnect: () => Promise<void>;
|
|
51
|
+
signMessage?: (message: Uint8Array) => Promise<SolanaSignMessageResult>;
|
|
52
|
+
signTransaction?: <T extends SolanaTransaction>(transaction: T) => Promise<T>;
|
|
53
|
+
signAllTransactions?: <T extends SolanaTransaction>(transactions: T[]) => Promise<T[]>;
|
|
54
|
+
signAndSendTransaction?: (transaction: SolanaTransaction, options?: SendOptions) => Promise<{
|
|
55
|
+
signature: TransactionSignature;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
interface SolanaWalletInfo {
|
|
59
|
+
name: string;
|
|
60
|
+
icon: string;
|
|
61
|
+
chains: readonly string[];
|
|
62
|
+
platform?: "browser" | "mobile" | "desktop";
|
|
63
|
+
source?: "wallet-standard" | "mobile-wallet-adapter" | "deep-link" | "protocol-link";
|
|
64
|
+
appUrl?: string;
|
|
65
|
+
installUrl?: string;
|
|
66
|
+
callbackUrl?: string;
|
|
67
|
+
capabilities?: {
|
|
68
|
+
connect?: boolean;
|
|
69
|
+
disconnect?: boolean;
|
|
70
|
+
signMessage?: boolean;
|
|
71
|
+
signTransaction?: boolean;
|
|
72
|
+
signAllTransactions?: boolean;
|
|
73
|
+
signAndSendTransaction?: boolean;
|
|
74
|
+
};
|
|
75
|
+
accounts: readonly {
|
|
76
|
+
address: string;
|
|
77
|
+
publicKey: Uint8Array;
|
|
78
|
+
chains: readonly string[];
|
|
79
|
+
label?: string;
|
|
80
|
+
icon?: string;
|
|
81
|
+
}[];
|
|
82
|
+
wallet: unknown;
|
|
83
|
+
}
|
|
84
|
+
interface SendTransactionOptions extends SendOptions {
|
|
85
|
+
skipPreflight?: boolean;
|
|
86
|
+
}
|
|
87
|
+
interface ConfirmTransactionOptions {
|
|
88
|
+
commitment?: Commitment;
|
|
89
|
+
timeoutMs?: number;
|
|
90
|
+
}
|
|
91
|
+
interface TransactionConfirmation {
|
|
92
|
+
signature: TransactionSignature;
|
|
93
|
+
commitment: Commitment;
|
|
94
|
+
result: RpcResponseAndContext<SignatureResult>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { createSolanaClient as j };
|
|
98
|
+
export type { ConfirmTransactionOptions as C, SendTransactionOptions as S, TransactionConfirmation as T, SolanaChain as a, SolanaClient as b, SolanaCluster as c, SolanaConfig as d, SolanaContext as e, SolanaSignMessageResult as f, SolanaTransaction as g, SolanaWallet as h, SolanaWalletInfo as i };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/// <reference path="../../types/web3-compat.d.ts" />
|
|
2
|
+
/// <reference path="../../types/buffer.d.ts" />
|
|
3
|
+
import { Commitment, SendOptions, Connection, Transaction, VersionedTransaction, PublicKey, TransactionSignature, RpcResponseAndContext, SignatureResult } from '@solana/web3-compat';
|
|
4
|
+
import * as _solana_kit from '@solana/kit';
|
|
5
|
+
import { Address } from '@solana/kit';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Create a @solana/kit client for the given Solana configuration.
|
|
9
|
+
*
|
|
10
|
+
* The returned client exposes read-only `rpc` and `rpcSubscriptions`; use
|
|
11
|
+
* `client.rpc.getSlot().send()` and friends instead of the legacy
|
|
12
|
+
* `connection` APIs.
|
|
13
|
+
*/
|
|
14
|
+
declare function createSolanaClient(config?: SolanaConfig): _solana_kit.Client<_solana_kit.ExtendedClient<object, {
|
|
15
|
+
rpc: _solana_kit.Rpc<_solana_kit.RequestAirdropApi & _solana_kit.GetAccountInfoApi & _solana_kit.GetAgGenesisCertApi & _solana_kit.GetBalanceApi & _solana_kit.GetBlockApi & _solana_kit.GetBlockCommitmentApi & _solana_kit.GetBlockHeightApi & _solana_kit.GetBlockProductionApi & _solana_kit.GetBlocksApi & _solana_kit.GetBlocksWithLimitApi & _solana_kit.GetBlockTimeApi & _solana_kit.GetClusterNodesApi & _solana_kit.GetEpochInfoApi & _solana_kit.GetEpochScheduleApi & _solana_kit.GetFeeForMessageApi & _solana_kit.GetFirstAvailableBlockApi & _solana_kit.GetGenesisHashApi & _solana_kit.GetHealthApi & _solana_kit.GetHighestSnapshotSlotApi & _solana_kit.GetIdentityApi & _solana_kit.GetInflationGovernorApi & _solana_kit.GetInflationRateApi & _solana_kit.GetInflationRewardApi & _solana_kit.GetLargestAccountsApi & _solana_kit.GetLatestBlockhashApi & _solana_kit.GetLeaderScheduleApi & _solana_kit.GetMaxRetransmitSlotApi & _solana_kit.GetMaxShredInsertSlotApi & _solana_kit.GetMinimumBalanceForRentExemptionApi & _solana_kit.GetMultipleAccountsApi & _solana_kit.GetProgramAccountsApi & _solana_kit.GetRecentPerformanceSamplesApi & _solana_kit.GetRecentPrioritizationFeesApi & _solana_kit.GetSignaturesForAddressApi & _solana_kit.GetSignatureStatusesApi & _solana_kit.GetSlotApi & _solana_kit.GetSlotLeaderApi & _solana_kit.GetSlotLeadersApi & _solana_kit.GetStakeMinimumDelegationApi & _solana_kit.GetSupplyApi & _solana_kit.GetTokenAccountBalanceApi & _solana_kit.GetTokenAccountsByDelegateApi & _solana_kit.GetTokenAccountsByOwnerApi & _solana_kit.GetTokenLargestAccountsApi & _solana_kit.GetTokenSupplyApi & _solana_kit.GetTransactionApi & _solana_kit.GetTransactionCountApi & _solana_kit.GetTransactionsForAddressApi & _solana_kit.GetVersionApi & _solana_kit.GetVoteAccountsApi & _solana_kit.IsBlockhashValidApi & _solana_kit.MinimumLedgerSlotApi & _solana_kit.SendTransactionApi & _solana_kit.SimulateTransactionApi>;
|
|
16
|
+
rpcSubscriptions: _solana_kit.RpcSubscriptions<_solana_kit.SolanaRpcSubscriptionsApi>;
|
|
17
|
+
}>>;
|
|
18
|
+
type SolanaClient = ReturnType<typeof createSolanaClient>;
|
|
19
|
+
|
|
20
|
+
type SolanaCluster = "mainnet-beta" | "testnet" | "devnet" | "localnet";
|
|
21
|
+
type SolanaChain = "solana:mainnet" | "solana:testnet" | "solana:devnet" | "solana:localnet";
|
|
22
|
+
interface SolanaConfig {
|
|
23
|
+
cluster?: SolanaCluster;
|
|
24
|
+
endpoint?: string;
|
|
25
|
+
wsEndpoint?: string;
|
|
26
|
+
commitment?: Commitment;
|
|
27
|
+
autoConnect?: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface SolanaContext {
|
|
30
|
+
cluster: SolanaCluster;
|
|
31
|
+
endpoint: string;
|
|
32
|
+
wsEndpoint: string;
|
|
33
|
+
connection: Connection;
|
|
34
|
+
client: SolanaClient;
|
|
35
|
+
}
|
|
36
|
+
type SolanaTransaction = Transaction | VersionedTransaction;
|
|
37
|
+
interface SolanaSignMessageResult {
|
|
38
|
+
signedMessage: Uint8Array;
|
|
39
|
+
signature: Uint8Array;
|
|
40
|
+
}
|
|
41
|
+
interface SolanaWallet {
|
|
42
|
+
publicKey: PublicKey | null;
|
|
43
|
+
address?: Address;
|
|
44
|
+
connected: boolean;
|
|
45
|
+
connecting?: boolean;
|
|
46
|
+
disconnecting?: boolean;
|
|
47
|
+
platform?: SolanaWalletInfo["platform"];
|
|
48
|
+
source?: SolanaWalletInfo["source"];
|
|
49
|
+
connect: () => Promise<void>;
|
|
50
|
+
disconnect: () => Promise<void>;
|
|
51
|
+
signMessage?: (message: Uint8Array) => Promise<SolanaSignMessageResult>;
|
|
52
|
+
signTransaction?: <T extends SolanaTransaction>(transaction: T) => Promise<T>;
|
|
53
|
+
signAllTransactions?: <T extends SolanaTransaction>(transactions: T[]) => Promise<T[]>;
|
|
54
|
+
signAndSendTransaction?: (transaction: SolanaTransaction, options?: SendOptions) => Promise<{
|
|
55
|
+
signature: TransactionSignature;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
interface SolanaWalletInfo {
|
|
59
|
+
name: string;
|
|
60
|
+
icon: string;
|
|
61
|
+
chains: readonly string[];
|
|
62
|
+
platform?: "browser" | "mobile" | "desktop";
|
|
63
|
+
source?: "wallet-standard" | "mobile-wallet-adapter" | "deep-link" | "protocol-link";
|
|
64
|
+
appUrl?: string;
|
|
65
|
+
installUrl?: string;
|
|
66
|
+
callbackUrl?: string;
|
|
67
|
+
capabilities?: {
|
|
68
|
+
connect?: boolean;
|
|
69
|
+
disconnect?: boolean;
|
|
70
|
+
signMessage?: boolean;
|
|
71
|
+
signTransaction?: boolean;
|
|
72
|
+
signAllTransactions?: boolean;
|
|
73
|
+
signAndSendTransaction?: boolean;
|
|
74
|
+
};
|
|
75
|
+
accounts: readonly {
|
|
76
|
+
address: string;
|
|
77
|
+
publicKey: Uint8Array;
|
|
78
|
+
chains: readonly string[];
|
|
79
|
+
label?: string;
|
|
80
|
+
icon?: string;
|
|
81
|
+
}[];
|
|
82
|
+
wallet: unknown;
|
|
83
|
+
}
|
|
84
|
+
interface SendTransactionOptions extends SendOptions {
|
|
85
|
+
skipPreflight?: boolean;
|
|
86
|
+
}
|
|
87
|
+
interface ConfirmTransactionOptions {
|
|
88
|
+
commitment?: Commitment;
|
|
89
|
+
timeoutMs?: number;
|
|
90
|
+
}
|
|
91
|
+
interface TransactionConfirmation {
|
|
92
|
+
signature: TransactionSignature;
|
|
93
|
+
commitment: Commitment;
|
|
94
|
+
result: RpcResponseAndContext<SignatureResult>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export { createSolanaClient as j };
|
|
98
|
+
export type { ConfirmTransactionOptions as C, SendTransactionOptions as S, TransactionConfirmation as T, SolanaChain as a, SolanaClient as b, SolanaCluster as c, SolanaConfig as d, SolanaContext as e, SolanaSignMessageResult as f, SolanaTransaction as g, SolanaWallet as h, SolanaWalletInfo as i };
|
|
@@ -63,6 +63,9 @@ function adaptSolanaStandardWallet(walletInfo, options = {}) {
|
|
|
63
63
|
get publicKey() {
|
|
64
64
|
return account ? new PublicKey(account.publicKey) : null;
|
|
65
65
|
},
|
|
66
|
+
get address() {
|
|
67
|
+
return account ? account.address : void 0;
|
|
68
|
+
},
|
|
66
69
|
get connected() {
|
|
67
70
|
return Boolean(account);
|
|
68
71
|
},
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const splToken = require('@solana/spl-token');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.AccountState = splToken.AccountState;
|
|
8
|
+
exports.TOKEN_2022_PROGRAM_ID = splToken.TOKEN_2022_PROGRAM_ID;
|
|
9
|
+
exports.TOKEN_PROGRAM_ID = splToken.TOKEN_PROGRAM_ID;
|
|
10
|
+
exports.getAssociatedTokenAddressSync = splToken.getAssociatedTokenAddressSync;
|
|
11
|
+
exports.unpackAccount = splToken.unpackAccount;
|
|
12
|
+
exports.unpackMint = splToken.unpackMint;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference path="../types/web3-compat.d.ts" />
|
|
2
|
+
/// <reference path="../types/buffer.d.ts" />
|
|
3
|
+
export { AccountState, Mint, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, Account as TokenAccount, getAssociatedTokenAddressSync, unpackAccount, unpackMint } from '@solana/spl-token';
|
|
4
|
+
import '@solana/web3-compat';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference path="../types/web3-compat.d.ts" />
|
|
2
|
+
/// <reference path="../types/buffer.d.ts" />
|
|
3
|
+
export { AccountState, Mint, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, Account as TokenAccount, getAssociatedTokenAddressSync, unpackAccount, unpackMint } from '@solana/spl-token';
|
|
4
|
+
import '@solana/web3-compat';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference path="../types/web3-compat.d.ts" />
|
|
2
|
+
/// <reference path="../types/buffer.d.ts" />
|
|
3
|
+
export { AccountState, Mint, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, Account as TokenAccount, getAssociatedTokenAddressSync, unpackAccount, unpackMint } from '@solana/spl-token';
|
|
4
|
+
import '@solana/web3-compat';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AccountState, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, unpackAccount, unpackMint } from '@solana/spl-token';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const splToken = require('@solana/spl-token');
|
|
4
|
+
const errors = require('./errors.cjs');
|
|
5
|
+
|
|
6
|
+
async function getTokenAccountsByOwner(connection, owner, options) {
|
|
7
|
+
const commitment = options?.commitment ?? "confirmed";
|
|
8
|
+
const programId = options?.programId;
|
|
9
|
+
const programIds = programId ? [programId] : [splToken.TOKEN_PROGRAM_ID, splToken.TOKEN_2022_PROGRAM_ID];
|
|
10
|
+
try {
|
|
11
|
+
const responses = await Promise.all(
|
|
12
|
+
programIds.map(async (pid) => {
|
|
13
|
+
const resp = await connection.getTokenAccountsByOwner(owner, { programId: pid }, commitment);
|
|
14
|
+
return resp.value.map(
|
|
15
|
+
(info) => splToken.unpackAccount(info.pubkey, { data: info.account.data })
|
|
16
|
+
);
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
return responses.flat();
|
|
20
|
+
} catch (cause) {
|
|
21
|
+
throw errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function getTokenAccount(connection, address) {
|
|
25
|
+
try {
|
|
26
|
+
const accountInfo = await connection.getAccountInfo(address);
|
|
27
|
+
if (!accountInfo) {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return splToken.unpackAccount(address, accountInfo);
|
|
31
|
+
} catch (cause) {
|
|
32
|
+
throw errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function getTokenBalance(connection, mint, owner) {
|
|
36
|
+
try {
|
|
37
|
+
const ata = splToken.getAssociatedTokenAddressSync(mint, owner, true);
|
|
38
|
+
const accountInfo = await connection.getAccountInfo(ata);
|
|
39
|
+
if (!accountInfo) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const tokenAccount = splToken.unpackAccount(ata, accountInfo);
|
|
43
|
+
const mintAccountInfo = await connection.getAccountInfo(mint);
|
|
44
|
+
if (!mintAccountInfo) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const mintAccount = splToken.unpackMint(mint, mintAccountInfo);
|
|
48
|
+
return { amount: tokenAccount.amount, decimals: mintAccount.decimals };
|
|
49
|
+
} catch (cause) {
|
|
50
|
+
throw errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
exports.getTokenAccount = getTokenAccount;
|
|
55
|
+
exports.getTokenAccountsByOwner = getTokenAccountsByOwner;
|
|
56
|
+
exports.getTokenBalance = getTokenBalance;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PublicKey, Connection } from '@vue-solana/core/web3';
|
|
2
|
+
import { Account } from '@solana/spl-token';
|
|
3
|
+
|
|
4
|
+
interface TokenAccountsByOwnerOptions {
|
|
5
|
+
commitment?: "processed" | "confirmed" | "finalized";
|
|
6
|
+
programId?: PublicKey;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get all SPL token accounts for an owner using the legacy `Connection` API.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Prefer `@solana-program/token` reads against `client.rpc` from
|
|
12
|
+
* `@vue-solana/core/kit`.
|
|
13
|
+
*/
|
|
14
|
+
declare function getTokenAccountsByOwner(connection: Connection, owner: PublicKey, options?: TokenAccountsByOwnerOptions): Promise<Account[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Get a single token account using the legacy `Connection` API.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Prefer `@solana-program/token` reads against `client.rpc` from
|
|
19
|
+
* `@vue-solana/core/kit`.
|
|
20
|
+
*/
|
|
21
|
+
declare function getTokenAccount(connection: Connection, address: PublicKey): Promise<Account | null>;
|
|
22
|
+
interface TokenBalanceResult {
|
|
23
|
+
amount: bigint;
|
|
24
|
+
decimals: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Read the token balance of the associated token account for an owner.
|
|
28
|
+
*
|
|
29
|
+
* @deprecated Prefer `@solana-program/token` reads against `client.rpc` from
|
|
30
|
+
* `@vue-solana/core/kit`.
|
|
31
|
+
*/
|
|
32
|
+
declare function getTokenBalance(connection: Connection, mint: PublicKey, owner: PublicKey): Promise<TokenBalanceResult | null>;
|
|
33
|
+
|
|
34
|
+
export { getTokenAccount, getTokenAccountsByOwner, getTokenBalance };
|
|
35
|
+
export type { TokenAccountsByOwnerOptions, TokenBalanceResult };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PublicKey, Connection } from '@vue-solana/core/web3';
|
|
2
|
+
import { Account } from '@solana/spl-token';
|
|
3
|
+
|
|
4
|
+
interface TokenAccountsByOwnerOptions {
|
|
5
|
+
commitment?: "processed" | "confirmed" | "finalized";
|
|
6
|
+
programId?: PublicKey;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get all SPL token accounts for an owner using the legacy `Connection` API.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Prefer `@solana-program/token` reads against `client.rpc` from
|
|
12
|
+
* `@vue-solana/core/kit`.
|
|
13
|
+
*/
|
|
14
|
+
declare function getTokenAccountsByOwner(connection: Connection, owner: PublicKey, options?: TokenAccountsByOwnerOptions): Promise<Account[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Get a single token account using the legacy `Connection` API.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Prefer `@solana-program/token` reads against `client.rpc` from
|
|
19
|
+
* `@vue-solana/core/kit`.
|
|
20
|
+
*/
|
|
21
|
+
declare function getTokenAccount(connection: Connection, address: PublicKey): Promise<Account | null>;
|
|
22
|
+
interface TokenBalanceResult {
|
|
23
|
+
amount: bigint;
|
|
24
|
+
decimals: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Read the token balance of the associated token account for an owner.
|
|
28
|
+
*
|
|
29
|
+
* @deprecated Prefer `@solana-program/token` reads against `client.rpc` from
|
|
30
|
+
* `@vue-solana/core/kit`.
|
|
31
|
+
*/
|
|
32
|
+
declare function getTokenBalance(connection: Connection, mint: PublicKey, owner: PublicKey): Promise<TokenBalanceResult | null>;
|
|
33
|
+
|
|
34
|
+
export { getTokenAccount, getTokenAccountsByOwner, getTokenBalance };
|
|
35
|
+
export type { TokenAccountsByOwnerOptions, TokenBalanceResult };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { PublicKey, Connection } from '@vue-solana/core/web3';
|
|
2
|
+
import { Account } from '@solana/spl-token';
|
|
3
|
+
|
|
4
|
+
interface TokenAccountsByOwnerOptions {
|
|
5
|
+
commitment?: "processed" | "confirmed" | "finalized";
|
|
6
|
+
programId?: PublicKey;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Get all SPL token accounts for an owner using the legacy `Connection` API.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Prefer `@solana-program/token` reads against `client.rpc` from
|
|
12
|
+
* `@vue-solana/core/kit`.
|
|
13
|
+
*/
|
|
14
|
+
declare function getTokenAccountsByOwner(connection: Connection, owner: PublicKey, options?: TokenAccountsByOwnerOptions): Promise<Account[]>;
|
|
15
|
+
/**
|
|
16
|
+
* Get a single token account using the legacy `Connection` API.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Prefer `@solana-program/token` reads against `client.rpc` from
|
|
19
|
+
* `@vue-solana/core/kit`.
|
|
20
|
+
*/
|
|
21
|
+
declare function getTokenAccount(connection: Connection, address: PublicKey): Promise<Account | null>;
|
|
22
|
+
interface TokenBalanceResult {
|
|
23
|
+
amount: bigint;
|
|
24
|
+
decimals: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Read the token balance of the associated token account for an owner.
|
|
28
|
+
*
|
|
29
|
+
* @deprecated Prefer `@solana-program/token` reads against `client.rpc` from
|
|
30
|
+
* `@vue-solana/core/kit`.
|
|
31
|
+
*/
|
|
32
|
+
declare function getTokenBalance(connection: Connection, mint: PublicKey, owner: PublicKey): Promise<TokenBalanceResult | null>;
|
|
33
|
+
|
|
34
|
+
export { getTokenAccount, getTokenAccountsByOwner, getTokenBalance };
|
|
35
|
+
export type { TokenAccountsByOwnerOptions, TokenBalanceResult };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { unpackAccount, TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, getAssociatedTokenAddressSync, unpackMint } from '@solana/spl-token';
|
|
2
|
+
import { normalizeSolanaError } from './errors.mjs';
|
|
3
|
+
|
|
4
|
+
async function getTokenAccountsByOwner(connection, owner, options) {
|
|
5
|
+
const commitment = options?.commitment ?? "confirmed";
|
|
6
|
+
const programId = options?.programId;
|
|
7
|
+
const programIds = programId ? [programId] : [TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID];
|
|
8
|
+
try {
|
|
9
|
+
const responses = await Promise.all(
|
|
10
|
+
programIds.map(async (pid) => {
|
|
11
|
+
const resp = await connection.getTokenAccountsByOwner(owner, { programId: pid }, commitment);
|
|
12
|
+
return resp.value.map(
|
|
13
|
+
(info) => unpackAccount(info.pubkey, { data: info.account.data })
|
|
14
|
+
);
|
|
15
|
+
})
|
|
16
|
+
);
|
|
17
|
+
return responses.flat();
|
|
18
|
+
} catch (cause) {
|
|
19
|
+
throw normalizeSolanaError(cause, "RPC_FAILURE");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async function getTokenAccount(connection, address) {
|
|
23
|
+
try {
|
|
24
|
+
const accountInfo = await connection.getAccountInfo(address);
|
|
25
|
+
if (!accountInfo) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return unpackAccount(address, accountInfo);
|
|
29
|
+
} catch (cause) {
|
|
30
|
+
throw normalizeSolanaError(cause, "RPC_FAILURE");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
async function getTokenBalance(connection, mint, owner) {
|
|
34
|
+
try {
|
|
35
|
+
const ata = getAssociatedTokenAddressSync(mint, owner, true);
|
|
36
|
+
const accountInfo = await connection.getAccountInfo(ata);
|
|
37
|
+
if (!accountInfo) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const tokenAccount = unpackAccount(ata, accountInfo);
|
|
41
|
+
const mintAccountInfo = await connection.getAccountInfo(mint);
|
|
42
|
+
if (!mintAccountInfo) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const mintAccount = unpackMint(mint, mintAccountInfo);
|
|
46
|
+
return { amount: tokenAccount.amount, decimals: mintAccount.decimals };
|
|
47
|
+
} catch (cause) {
|
|
48
|
+
throw normalizeSolanaError(cause, "RPC_FAILURE");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { getTokenAccount, getTokenAccountsByOwner, getTokenBalance };
|
package/dist/transaction.d.cts
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
/// <reference path="../types/web3-compat.d.ts" />
|
|
2
2
|
/// <reference path="../types/buffer.d.ts" />
|
|
3
3
|
import { Connection, TransactionSignature } from '@solana/web3-compat';
|
|
4
|
-
import { ConfirmTransactionOptions, TransactionConfirmation, SolanaWallet, SolanaTransaction, SendTransactionOptions } from './
|
|
4
|
+
import { C as ConfirmTransactionOptions, T as TransactionConfirmation, h as SolanaWallet, g as SolanaTransaction, S as SendTransactionOptions } from './shared/core.DAUuCWrr.cjs';
|
|
5
|
+
import '@solana/kit';
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Sign and send a transaction through a connected wallet using the legacy
|
|
9
|
+
* web3-compat `Connection` API.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Kit transactions are sent with `client.sendTransaction([...])`
|
|
12
|
+
* once the client has a payer; see `@vue-solana/core/kit`.
|
|
13
|
+
*/
|
|
6
14
|
declare function signAndSendTransaction(connection: Connection, wallet: SolanaWallet, transaction: SolanaTransaction, options?: SendTransactionOptions): Promise<TransactionSignature>;
|
|
15
|
+
/**
|
|
16
|
+
* Confirm a transaction signature using the legacy `Connection` API.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Use `client.rpc.getSignatureStatuses([...]).send()` from
|
|
19
|
+
* `@vue-solana/core/kit` instead.
|
|
20
|
+
*/
|
|
7
21
|
declare function confirmTransactionSignature(connection: Connection, signature: TransactionSignature, options?: ConfirmTransactionOptions): Promise<TransactionConfirmation>;
|
|
8
22
|
|
|
9
23
|
export { confirmTransactionSignature, signAndSendTransaction };
|
package/dist/transaction.d.mts
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
/// <reference path="../types/web3-compat.d.ts" />
|
|
2
2
|
/// <reference path="../types/buffer.d.ts" />
|
|
3
3
|
import { Connection, TransactionSignature } from '@solana/web3-compat';
|
|
4
|
-
import { ConfirmTransactionOptions, TransactionConfirmation, SolanaWallet, SolanaTransaction, SendTransactionOptions } from './
|
|
4
|
+
import { C as ConfirmTransactionOptions, T as TransactionConfirmation, h as SolanaWallet, g as SolanaTransaction, S as SendTransactionOptions } from './shared/core.DAUuCWrr.mjs';
|
|
5
|
+
import '@solana/kit';
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Sign and send a transaction through a connected wallet using the legacy
|
|
9
|
+
* web3-compat `Connection` API.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Kit transactions are sent with `client.sendTransaction([...])`
|
|
12
|
+
* once the client has a payer; see `@vue-solana/core/kit`.
|
|
13
|
+
*/
|
|
6
14
|
declare function signAndSendTransaction(connection: Connection, wallet: SolanaWallet, transaction: SolanaTransaction, options?: SendTransactionOptions): Promise<TransactionSignature>;
|
|
15
|
+
/**
|
|
16
|
+
* Confirm a transaction signature using the legacy `Connection` API.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Use `client.rpc.getSignatureStatuses([...]).send()` from
|
|
19
|
+
* `@vue-solana/core/kit` instead.
|
|
20
|
+
*/
|
|
7
21
|
declare function confirmTransactionSignature(connection: Connection, signature: TransactionSignature, options?: ConfirmTransactionOptions): Promise<TransactionConfirmation>;
|
|
8
22
|
|
|
9
23
|
export { confirmTransactionSignature, signAndSendTransaction };
|
package/dist/transaction.d.ts
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
/// <reference path="../types/web3-compat.d.ts" />
|
|
2
2
|
/// <reference path="../types/buffer.d.ts" />
|
|
3
3
|
import { Connection, TransactionSignature } from '@solana/web3-compat';
|
|
4
|
-
import { ConfirmTransactionOptions, TransactionConfirmation, SolanaWallet, SolanaTransaction, SendTransactionOptions } from './
|
|
4
|
+
import { C as ConfirmTransactionOptions, T as TransactionConfirmation, h as SolanaWallet, g as SolanaTransaction, S as SendTransactionOptions } from './shared/core.DAUuCWrr.js';
|
|
5
|
+
import '@solana/kit';
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Sign and send a transaction through a connected wallet using the legacy
|
|
9
|
+
* web3-compat `Connection` API.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Kit transactions are sent with `client.sendTransaction([...])`
|
|
12
|
+
* once the client has a payer; see `@vue-solana/core/kit`.
|
|
13
|
+
*/
|
|
6
14
|
declare function signAndSendTransaction(connection: Connection, wallet: SolanaWallet, transaction: SolanaTransaction, options?: SendTransactionOptions): Promise<TransactionSignature>;
|
|
15
|
+
/**
|
|
16
|
+
* Confirm a transaction signature using the legacy `Connection` API.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Use `client.rpc.getSignatureStatuses([...]).send()` from
|
|
19
|
+
* `@vue-solana/core/kit` instead.
|
|
20
|
+
*/
|
|
7
21
|
declare function confirmTransactionSignature(connection: Connection, signature: TransactionSignature, options?: ConfirmTransactionOptions): Promise<TransactionConfirmation>;
|
|
8
22
|
|
|
9
23
|
export { confirmTransactionSignature, signAndSendTransaction };
|
package/dist/types.d.cts
CHANGED
|
@@ -1,80 +1,5 @@
|
|
|
1
1
|
/// <reference path="../types/web3-compat.d.ts" />
|
|
2
2
|
/// <reference path="../types/buffer.d.ts" />
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
type SolanaChain = "solana:mainnet" | "solana:testnet" | "solana:devnet" | "solana:localnet";
|
|
7
|
-
interface SolanaConfig {
|
|
8
|
-
cluster?: SolanaCluster;
|
|
9
|
-
endpoint?: string;
|
|
10
|
-
wsEndpoint?: string;
|
|
11
|
-
commitment?: Commitment;
|
|
12
|
-
autoConnect?: boolean;
|
|
13
|
-
}
|
|
14
|
-
interface SolanaContext {
|
|
15
|
-
cluster: SolanaCluster;
|
|
16
|
-
endpoint: string;
|
|
17
|
-
wsEndpoint: string;
|
|
18
|
-
connection: Connection;
|
|
19
|
-
}
|
|
20
|
-
type SolanaTransaction = Transaction | VersionedTransaction;
|
|
21
|
-
interface SolanaSignMessageResult {
|
|
22
|
-
signedMessage: Uint8Array;
|
|
23
|
-
signature: Uint8Array;
|
|
24
|
-
}
|
|
25
|
-
interface SolanaWallet {
|
|
26
|
-
publicKey: PublicKey | null;
|
|
27
|
-
connected: boolean;
|
|
28
|
-
connecting?: boolean;
|
|
29
|
-
disconnecting?: boolean;
|
|
30
|
-
platform?: SolanaWalletInfo["platform"];
|
|
31
|
-
source?: SolanaWalletInfo["source"];
|
|
32
|
-
connect: () => Promise<void>;
|
|
33
|
-
disconnect: () => Promise<void>;
|
|
34
|
-
signMessage?: (message: Uint8Array) => Promise<SolanaSignMessageResult>;
|
|
35
|
-
signTransaction?: <T extends SolanaTransaction>(transaction: T) => Promise<T>;
|
|
36
|
-
signAllTransactions?: <T extends SolanaTransaction>(transactions: T[]) => Promise<T[]>;
|
|
37
|
-
signAndSendTransaction?: (transaction: SolanaTransaction, options?: SendOptions) => Promise<{
|
|
38
|
-
signature: TransactionSignature;
|
|
39
|
-
}>;
|
|
40
|
-
}
|
|
41
|
-
interface SolanaWalletInfo {
|
|
42
|
-
name: string;
|
|
43
|
-
icon: string;
|
|
44
|
-
chains: readonly string[];
|
|
45
|
-
platform?: "browser" | "mobile" | "desktop";
|
|
46
|
-
source?: "wallet-standard" | "mobile-wallet-adapter" | "deep-link" | "protocol-link";
|
|
47
|
-
appUrl?: string;
|
|
48
|
-
installUrl?: string;
|
|
49
|
-
callbackUrl?: string;
|
|
50
|
-
capabilities?: {
|
|
51
|
-
connect?: boolean;
|
|
52
|
-
disconnect?: boolean;
|
|
53
|
-
signMessage?: boolean;
|
|
54
|
-
signTransaction?: boolean;
|
|
55
|
-
signAllTransactions?: boolean;
|
|
56
|
-
signAndSendTransaction?: boolean;
|
|
57
|
-
};
|
|
58
|
-
accounts: readonly {
|
|
59
|
-
address: string;
|
|
60
|
-
publicKey: Uint8Array;
|
|
61
|
-
chains: readonly string[];
|
|
62
|
-
label?: string;
|
|
63
|
-
icon?: string;
|
|
64
|
-
}[];
|
|
65
|
-
wallet: unknown;
|
|
66
|
-
}
|
|
67
|
-
interface SendTransactionOptions extends SendOptions {
|
|
68
|
-
skipPreflight?: boolean;
|
|
69
|
-
}
|
|
70
|
-
interface ConfirmTransactionOptions {
|
|
71
|
-
commitment?: Commitment;
|
|
72
|
-
timeoutMs?: number;
|
|
73
|
-
}
|
|
74
|
-
interface TransactionConfirmation {
|
|
75
|
-
signature: TransactionSignature;
|
|
76
|
-
commitment: Commitment;
|
|
77
|
-
result: RpcResponseAndContext<SignatureResult>;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export type { ConfirmTransactionOptions, SendTransactionOptions, SolanaChain, SolanaCluster, SolanaConfig, SolanaContext, SolanaSignMessageResult, SolanaTransaction, SolanaWallet, SolanaWalletInfo, TransactionConfirmation };
|
|
3
|
+
import '@solana/web3-compat';
|
|
4
|
+
export { C as ConfirmTransactionOptions, S as SendTransactionOptions, a as SolanaChain, c as SolanaCluster, d as SolanaConfig, e as SolanaContext, f as SolanaSignMessageResult, g as SolanaTransaction, h as SolanaWallet, i as SolanaWalletInfo, T as TransactionConfirmation } from './shared/core.DAUuCWrr.cjs';
|
|
5
|
+
import '@solana/kit';
|