@vue-solana/vue 2.6.1 → 3.0.1
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/README.md +6 -4
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +35 -55
- package/dist/shared/vue.1Qwco2kv.mjs +33 -0
- package/dist/shared/vue.BFSboXMB.mjs +17 -0
- package/dist/shared/vue.BGGixph-.d.mts +5 -0
- package/dist/shared/vue.BGGixph-.d.ts +5 -0
- package/dist/shared/{vue.CbJFnho-.mjs → vue.BNJTXSnQ.mjs} +17 -70
- package/dist/shared/{vue.BINkrA8h.mjs → vue.BwBqla_n.mjs} +16 -26
- package/dist/shared/vue.BxtOHzY_.mjs +27 -0
- package/dist/shared/vue.C1JbUTpJ.mjs +66 -0
- package/dist/shared/vue.C9OOmvkD.mjs +36 -0
- package/dist/shared/vue.CGv0ip3w.mjs +52 -0
- package/dist/shared/vue.CaAgH2Xt.mjs +51 -0
- package/dist/shared/{vue.Dyi1OCI1.mjs → vue.CjSw0Hh1.mjs} +3 -9
- package/dist/shared/vue.CsFY1mfz.mjs +29 -0
- package/dist/shared/vue.CvenSbZZ.mjs +27 -0
- package/dist/shared/{vue.BDNOyiGZ.mjs → vue.D5pqR5Fa.mjs} +9 -12
- package/dist/shared/vue.DNKD6jqM.mjs +22 -0
- package/dist/shared/vue.DlihC5GG.mjs +38 -0
- package/dist/shared/vue.XlfH_nkc.mjs +32 -0
- package/dist/shared/vue.hG_FieA3.mjs +37 -0
- package/dist/shared/vue.o98pAmDg.mjs +40 -0
- package/dist/swr.mjs +22 -79
- package/dist/useAccountInfo.d.mts +4 -4
- package/dist/useAccountInfo.d.ts +4 -4
- package/dist/useAccountInfo.mjs +1 -9
- package/dist/useAction.mjs +0 -2
- package/dist/useAirdrop.mjs +0 -7
- package/dist/useBalance.d.mts +4 -4
- package/dist/useBalance.d.ts +4 -4
- package/dist/useBalance.mjs +1 -8
- package/dist/useClientCapability.mjs +0 -4
- package/dist/useConnection.d.mts +6 -6
- package/dist/useConnection.d.ts +6 -6
- package/dist/useConnection.mjs +0 -4
- package/dist/useIdentity.mjs +0 -5
- package/dist/usePayer.mjs +0 -5
- package/dist/usePlanTransaction.d.mts +12 -13
- package/dist/usePlanTransaction.d.ts +12 -13
- package/dist/usePlanTransaction.mjs +1 -7
- package/dist/usePlanTransactions.d.mts +2 -1
- package/dist/usePlanTransactions.d.ts +2 -1
- package/dist/usePlanTransactions.mjs +1 -7
- package/dist/useProgramAccounts.d.mts +5 -15
- package/dist/useProgramAccounts.d.ts +5 -15
- package/dist/useProgramAccounts.mjs +1 -9
- package/dist/useRequest.mjs +0 -4
- package/dist/useRpc.d.mts +6 -6
- package/dist/useRpc.d.ts +6 -6
- package/dist/useRpc.mjs +0 -3
- package/dist/useSelectedWalletAccount.mjs +0 -2
- package/dist/useSendTransaction.d.mts +11 -12
- package/dist/useSendTransaction.d.ts +11 -12
- package/dist/useSendTransaction.mjs +1 -7
- package/dist/useSendTransactions.d.mts +2 -1
- package/dist/useSendTransactions.d.ts +2 -1
- package/dist/useSendTransactions.mjs +1 -7
- package/dist/useSignAndSendTransaction.d.mts +1 -1
- package/dist/useSignAndSendTransaction.d.ts +1 -1
- package/dist/useSignAndSendTransaction.mjs +1 -12
- package/dist/useSignAndSendTransactions.d.mts +2 -2
- package/dist/useSignAndSendTransactions.d.ts +2 -2
- package/dist/useSignAndSendTransactions.mjs +1 -8
- package/dist/useSignIn.d.mts +4 -4
- package/dist/useSignIn.d.ts +4 -4
- package/dist/useSignIn.mjs +1 -7
- package/dist/useSignMessage.d.mts +4 -4
- package/dist/useSignMessage.d.ts +4 -4
- package/dist/useSignMessage.mjs +1 -7
- package/dist/useSignTransactions.d.mts +4 -4
- package/dist/useSignTransactions.d.ts +4 -4
- package/dist/useSignTransactions.mjs +1 -7
- package/dist/useSignatureStatus.mjs +0 -7
- package/dist/useSolana.mjs +0 -2
- package/dist/useSolanaClient.d.mts +6 -6
- package/dist/useSolanaClient.d.ts +6 -6
- package/dist/useSolanaClient.mjs +0 -3
- package/dist/useSubscription.mjs +1 -3
- package/dist/useTokenAccounts.d.mts +4 -4
- package/dist/useTokenAccounts.d.ts +4 -4
- package/dist/useTokenAccounts.mjs +1 -9
- package/dist/useTokenBalance.d.mts +9 -7
- package/dist/useTokenBalance.d.ts +9 -7
- package/dist/useTokenBalance.mjs +1 -9
- package/dist/useTrackedData.mjs +1 -4
- package/dist/useTransaction.mjs +0 -4
- package/dist/useTransactionConfirmation.d.mts +4 -4
- package/dist/useTransactionConfirmation.d.ts +4 -4
- package/dist/useTransactionConfirmation.mjs +1 -8
- package/dist/useWallet.mjs +0 -5
- package/dist/useWallets.mjs +0 -3
- package/package.json +38 -75
- package/dist/buffer-polyfill.cjs +0 -8
- package/dist/buffer-polyfill.d.cts +0 -2
- package/dist/index.cjs +0 -452
- package/dist/index.d.cts +0 -62
- package/dist/kit.cjs +0 -16
- package/dist/kit.d.cts +0 -1
- package/dist/shared/vue.4C5kX4fE.cjs +0 -36
- package/dist/shared/vue.9TPxZPMf.cjs +0 -59
- package/dist/shared/vue.B4eMoJT2.cjs +0 -36
- package/dist/shared/vue.B6ainw2G.cjs +0 -63
- package/dist/shared/vue.BD6Gm1nl.mjs +0 -74
- package/dist/shared/vue.BGxz4dru.cjs +0 -98
- package/dist/shared/vue.BIxphCAq.cjs +0 -10
- package/dist/shared/vue.BOpgWr43.mjs +0 -70
- package/dist/shared/vue.BQRpjwKl.mjs +0 -80
- package/dist/shared/vue.BVaMoz9y.cjs +0 -9
- package/dist/shared/vue.Bk5xjlUx.cjs +0 -61
- package/dist/shared/vue.Bwd1sGAM.cjs +0 -72
- package/dist/shared/vue.ByxbBC3y.mjs +0 -57
- package/dist/shared/vue.C13umiQi.mjs +0 -85
- package/dist/shared/vue.CIs8QhCw.cjs +0 -132
- package/dist/shared/vue.CMohL_Cz.mjs +0 -58
- package/dist/shared/vue.CWZSMVnB.cjs +0 -84
- package/dist/shared/vue.Co5rj-I6.mjs +0 -118
- package/dist/shared/vue.CoaIWGPT.cjs +0 -38
- package/dist/shared/vue.CrkK_T15.cjs +0 -86
- package/dist/shared/vue.D-qi8PSL.cjs +0 -82
- package/dist/shared/vue.D3Y0PWbF.mjs +0 -71
- package/dist/shared/vue.D5U1yLG3.mjs +0 -83
- package/dist/shared/vue.DAg5wC1G.cjs +0 -76
- package/dist/shared/vue.DAthhH4D.mjs +0 -118
- package/dist/shared/vue.DDbVk0Zh.cjs +0 -180
- package/dist/shared/vue.DE3emjSF.cjs +0 -48
- package/dist/shared/vue.DEHxNvUX.cjs +0 -7
- package/dist/shared/vue.DFaMJLAQ.cjs +0 -60
- package/dist/shared/vue.DKoM8jIV.cjs +0 -121
- package/dist/shared/vue.DKyQ7J67.cjs +0 -15
- package/dist/shared/vue.DL3z5PxP.d.cts +0 -21
- package/dist/shared/vue.DNxOpDXz.cjs +0 -12
- package/dist/shared/vue.Di7yjJ-R.cjs +0 -87
- package/dist/shared/vue.Dn3KLJZH.cjs +0 -121
- package/dist/shared/vue.DxM45azl.cjs +0 -173
- package/dist/shared/vue.E_npPFoV.cjs +0 -67
- package/dist/shared/vue.FiMmnMHr.cjs +0 -20
- package/dist/shared/vue.JUWqu6kD.mjs +0 -61
- package/dist/shared/vue.Sbbm9JSu.cjs +0 -74
- package/dist/shared/vue.ZuUCEEab.cjs +0 -103
- package/dist/shared/vue.l3UCdN7z.cjs +0 -111
- package/dist/shared/vue.ldvmk9NM.cjs +0 -45
- package/dist/swr.cjs +0 -136
- package/dist/swr.d.cts +0 -41
- package/dist/useAccountInfo.cjs +0 -15
- package/dist/useAccountInfo.d.cts +0 -24
- package/dist/useAction.cjs +0 -9
- package/dist/useAction.d.cts +0 -45
- package/dist/useAirdrop.cjs +0 -14
- package/dist/useAirdrop.d.cts +0 -27
- package/dist/useBalance.cjs +0 -14
- package/dist/useBalance.d.cts +0 -15
- package/dist/useClientCapability.cjs +0 -12
- package/dist/useClientCapability.d.cts +0 -39
- package/dist/useConnection.cjs +0 -11
- package/dist/useConnection.d.cts +0 -46
- package/dist/useIdentity.cjs +0 -12
- package/dist/useIdentity.d.cts +0 -3
- package/dist/usePayer.cjs +0 -13
- package/dist/usePayer.d.cts +0 -18
- package/dist/usePlanTransaction.cjs +0 -14
- package/dist/usePlanTransaction.d.cts +0 -45
- package/dist/usePlanTransactions.cjs +0 -13
- package/dist/usePlanTransactions.d.cts +0 -4
- package/dist/useProgramAccounts.cjs +0 -15
- package/dist/useProgramAccounts.d.cts +0 -55
- package/dist/useRequest.cjs +0 -11
- package/dist/useRequest.d.cts +0 -73
- package/dist/useRpc.cjs +0 -10
- package/dist/useRpc.d.cts +0 -55
- package/dist/useSelectedWalletAccount.cjs +0 -13
- package/dist/useSelectedWalletAccount.d.cts +0 -117
- package/dist/useSendTransaction.cjs +0 -14
- package/dist/useSendTransaction.d.cts +0 -51
- package/dist/useSendTransactions.cjs +0 -13
- package/dist/useSendTransactions.d.cts +0 -4
- package/dist/useSignAndSendTransaction.cjs +0 -18
- package/dist/useSignAndSendTransaction.d.cts +0 -40
- package/dist/useSignAndSendTransactions.cjs +0 -15
- package/dist/useSignAndSendTransactions.d.cts +0 -35
- package/dist/useSignIn.cjs +0 -13
- package/dist/useSignIn.d.cts +0 -23
- package/dist/useSignMessage.cjs +0 -13
- package/dist/useSignMessage.d.cts +0 -236
- package/dist/useSignTransactions.cjs +0 -13
- package/dist/useSignTransactions.d.cts +0 -24
- package/dist/useSignatureStatus.cjs +0 -14
- package/dist/useSignatureStatus.d.cts +0 -26
- package/dist/useSolana.cjs +0 -10
- package/dist/useSolana.d.cts +0 -9
- package/dist/useSolanaClient.cjs +0 -10
- package/dist/useSolanaClient.d.cts +0 -45
- package/dist/useSubscription.cjs +0 -9
- package/dist/useSubscription.d.cts +0 -70
- package/dist/useTokenAccounts.cjs +0 -15
- package/dist/useTokenAccounts.d.cts +0 -19
- package/dist/useTokenBalance.cjs +0 -15
- package/dist/useTokenBalance.d.cts +0 -15
- package/dist/useTrackedData.cjs +0 -10
- package/dist/useTrackedData.d.cts +0 -98
- package/dist/useTransaction.cjs +0 -11
- package/dist/useTransaction.d.cts +0 -27
- package/dist/useTransactionConfirmation.cjs +0 -15
- package/dist/useTransactionConfirmation.d.cts +0 -38
- package/dist/useWallet.cjs +0 -12
- package/dist/useWallet.d.cts +0 -31
- package/dist/useWallets.cjs +0 -10
- package/dist/useWallets.d.cts +0 -11
package/dist/index.cjs
DELETED
|
@@ -1,452 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const useAccountInfo = require('./shared/vue.D-qi8PSL.cjs');
|
|
4
|
-
const useAction = require('./shared/vue.CoaIWGPT.cjs');
|
|
5
|
-
const useAirdrop = require('./shared/vue.B4eMoJT2.cjs');
|
|
6
|
-
const useBalance = require('./shared/vue.E_npPFoV.cjs');
|
|
7
|
-
const useClientCapability = require('./shared/vue.4C5kX4fE.cjs');
|
|
8
|
-
const useConnection = require('./shared/vue.BVaMoz9y.cjs');
|
|
9
|
-
const usePlanTransaction = require('./shared/vue.Dn3KLJZH.cjs');
|
|
10
|
-
const useProgramAccounts = require('./shared/vue.Di7yjJ-R.cjs');
|
|
11
|
-
const usePayer = require('./shared/vue.ldvmk9NM.cjs');
|
|
12
|
-
const useRequest = require('./shared/vue.ZuUCEEab.cjs');
|
|
13
|
-
const useRpc = require('./shared/vue.FiMmnMHr.cjs');
|
|
14
|
-
const SelectedWalletAccountProvider = require('./shared/vue.DDbVk0Zh.cjs');
|
|
15
|
-
const useSendTransaction = require('./shared/vue.DKoM8jIV.cjs');
|
|
16
|
-
const useSignMessage = require('./shared/vue.B6ainw2G.cjs');
|
|
17
|
-
const useSignAndSendTransaction = require('./shared/vue.CWZSMVnB.cjs');
|
|
18
|
-
const useSignTransactions = require('./shared/vue.DFaMJLAQ.cjs');
|
|
19
|
-
const useSignAndSendTransactions = require('./shared/vue.CrkK_T15.cjs');
|
|
20
|
-
const useSignatureStatus = require('./shared/vue.CIs8QhCw.cjs');
|
|
21
|
-
const useSignIn = require('./shared/vue.9TPxZPMf.cjs');
|
|
22
|
-
const useSolana = require('./shared/vue.DE3emjSF.cjs');
|
|
23
|
-
const useSolanaClient = require('./shared/vue.BIxphCAq.cjs');
|
|
24
|
-
const useSubscription = require('./shared/vue.l3UCdN7z.cjs');
|
|
25
|
-
const useTokenAccounts = require('./shared/vue.Bwd1sGAM.cjs');
|
|
26
|
-
const useTokenBalance = require('./shared/vue.DAg5wC1G.cjs');
|
|
27
|
-
const useTrackedData = require('./shared/vue.DxM45azl.cjs');
|
|
28
|
-
const useTransaction = require('./shared/vue.Bk5xjlUx.cjs');
|
|
29
|
-
const useTransactionConfirmation = require('./shared/vue.Sbbm9JSu.cjs');
|
|
30
|
-
const useWallet = require('./shared/vue.BGxz4dru.cjs');
|
|
31
|
-
const useWallets = require('./shared/vue.DKyQ7J67.cjs');
|
|
32
|
-
const injection = require('./shared/vue.DEHxNvUX.cjs');
|
|
33
|
-
const errors = require('@vue-solana/core/errors');
|
|
34
|
-
const rpc = require('@vue-solana/core/rpc');
|
|
35
|
-
const timeout = require('@vue-solana/core/timeout');
|
|
36
|
-
const walletStandard = require('@vue-solana/core/wallet-standard');
|
|
37
|
-
const vue = require('vue');
|
|
38
|
-
const iosWallet = require('@vue-solana/core/ios-wallet');
|
|
39
|
-
const types = require('@vue-solana/core/types');
|
|
40
|
-
const kit = require('@vue-solana/core/kit');
|
|
41
|
-
require('@vue-solana/core/address');
|
|
42
|
-
require('./shared/vue.DNxOpDXz.cjs');
|
|
43
|
-
require('@vue-solana/core/action');
|
|
44
|
-
require('@vue-solana/core/wallet');
|
|
45
|
-
require('@vue-solana/core/transaction');
|
|
46
|
-
require('bs58');
|
|
47
|
-
require('@vue-solana/core/token-accounts');
|
|
48
|
-
|
|
49
|
-
const SELECTED_WALLET_STORAGE_KEY = "vue-solana:selected-wallet";
|
|
50
|
-
function readSelectedWallet() {
|
|
51
|
-
const { storage, error } = getLocalStorage();
|
|
52
|
-
if (error || !storage) {
|
|
53
|
-
return { wallet: null, error };
|
|
54
|
-
}
|
|
55
|
-
try {
|
|
56
|
-
const value = storage.getItem(SELECTED_WALLET_STORAGE_KEY);
|
|
57
|
-
if (!value) {
|
|
58
|
-
return { wallet: null, error: null };
|
|
59
|
-
}
|
|
60
|
-
const wallet = JSON.parse(value);
|
|
61
|
-
return {
|
|
62
|
-
wallet: typeof wallet.name === "string" ? {
|
|
63
|
-
name: wallet.name,
|
|
64
|
-
platform: wallet.platform,
|
|
65
|
-
source: wallet.source
|
|
66
|
-
} : null,
|
|
67
|
-
error: null
|
|
68
|
-
};
|
|
69
|
-
} catch (cause) {
|
|
70
|
-
return {
|
|
71
|
-
wallet: null,
|
|
72
|
-
error: errors.createSolanaError("STORAGE_FAILURE", "Unable to read the selected Solana wallet", {
|
|
73
|
-
cause
|
|
74
|
-
})
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function writeSelectedWallet(wallet) {
|
|
79
|
-
const { storage, error } = getLocalStorage();
|
|
80
|
-
if (error || !storage) {
|
|
81
|
-
return error;
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
if (wallet) {
|
|
85
|
-
storage.setItem(SELECTED_WALLET_STORAGE_KEY, stringifySelectedWallet(wallet));
|
|
86
|
-
} else {
|
|
87
|
-
storage.removeItem(SELECTED_WALLET_STORAGE_KEY);
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
90
|
-
} catch (cause) {
|
|
91
|
-
return errors.createSolanaError("STORAGE_FAILURE", "Unable to persist the selected Solana wallet", {
|
|
92
|
-
cause
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
function stringifySelectedWallet(wallet) {
|
|
97
|
-
const value = { name: wallet.name };
|
|
98
|
-
if (wallet.platform) {
|
|
99
|
-
value.platform = wallet.platform;
|
|
100
|
-
}
|
|
101
|
-
if (wallet.source) {
|
|
102
|
-
value.source = wallet.source;
|
|
103
|
-
}
|
|
104
|
-
return JSON.stringify(value);
|
|
105
|
-
}
|
|
106
|
-
function getLocalStorage() {
|
|
107
|
-
if (typeof window === "undefined") {
|
|
108
|
-
return { storage: null, error: null };
|
|
109
|
-
}
|
|
110
|
-
try {
|
|
111
|
-
return { storage: window.localStorage, error: null };
|
|
112
|
-
} catch (cause) {
|
|
113
|
-
return {
|
|
114
|
-
storage: null,
|
|
115
|
-
error: errors.createSolanaError("STORAGE_FAILURE", "Unable to read the selected Solana wallet", {
|
|
116
|
-
cause
|
|
117
|
-
})
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function createSolanaWalletRegistry(options) {
|
|
123
|
-
const adaptedWallets = /* @__PURE__ */ new WeakMap();
|
|
124
|
-
function getAdaptedWallet(walletInfo) {
|
|
125
|
-
if (iosWallet.isSolanaIosWalletInfo(walletInfo)) {
|
|
126
|
-
return iosWallet.adaptSolanaIosWallet(walletInfo, {
|
|
127
|
-
chain: walletStandard.getSolanaChain(options.cluster),
|
|
128
|
-
cluster: options.cluster,
|
|
129
|
-
onChange: options.onWalletChange,
|
|
130
|
-
...options.iosWallet || {}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
if (!isObject(walletInfo.wallet)) {
|
|
134
|
-
return walletStandard.adaptSolanaStandardWallet(walletInfo, {
|
|
135
|
-
chain: walletStandard.getSolanaChain(options.cluster),
|
|
136
|
-
onChange: options.onWalletChange
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
const cachedWallet = adaptedWallets.get(walletInfo.wallet);
|
|
140
|
-
if (cachedWallet) {
|
|
141
|
-
return cachedWallet;
|
|
142
|
-
}
|
|
143
|
-
const adaptedWallet = walletStandard.adaptSolanaStandardWallet(walletInfo, {
|
|
144
|
-
chain: walletStandard.getSolanaChain(options.cluster),
|
|
145
|
-
onChange: options.onWalletChange
|
|
146
|
-
});
|
|
147
|
-
const cachedAdapter = {
|
|
148
|
-
platform: walletInfo.platform,
|
|
149
|
-
source: walletInfo.source,
|
|
150
|
-
get publicKey() {
|
|
151
|
-
return adaptedWallet.publicKey;
|
|
152
|
-
},
|
|
153
|
-
get connected() {
|
|
154
|
-
return adaptedWallet.connected;
|
|
155
|
-
},
|
|
156
|
-
get connecting() {
|
|
157
|
-
return adaptedWallet.connecting;
|
|
158
|
-
},
|
|
159
|
-
get disconnecting() {
|
|
160
|
-
return adaptedWallet.disconnecting;
|
|
161
|
-
},
|
|
162
|
-
async connect() {
|
|
163
|
-
await adaptedWallet.connect();
|
|
164
|
-
await Promise.all(
|
|
165
|
-
Array.from(getCachedWallets()).map(
|
|
166
|
-
(otherWallet) => otherWallet !== cachedAdapter && otherWallet.connected ? otherWallet.disconnect() : void 0
|
|
167
|
-
)
|
|
168
|
-
);
|
|
169
|
-
},
|
|
170
|
-
disconnect: () => adaptedWallet.disconnect(),
|
|
171
|
-
signMessage: adaptedWallet.signMessage?.bind(adaptedWallet),
|
|
172
|
-
signTransaction: adaptedWallet.signTransaction?.bind(adaptedWallet),
|
|
173
|
-
signAllTransactions: adaptedWallet.signAllTransactions?.bind(adaptedWallet),
|
|
174
|
-
signAndSendTransaction: adaptedWallet.signAndSendTransaction?.bind(adaptedWallet),
|
|
175
|
-
signIn: adaptedWallet.signIn?.bind(adaptedWallet),
|
|
176
|
-
signTransactions: adaptedWallet.signTransactions?.bind(adaptedWallet),
|
|
177
|
-
signAndSendTransactions: adaptedWallet.signAndSendTransactions?.bind(adaptedWallet)
|
|
178
|
-
};
|
|
179
|
-
adaptedWallets.set(walletInfo.wallet, cachedAdapter);
|
|
180
|
-
return cachedAdapter;
|
|
181
|
-
}
|
|
182
|
-
function getDiscoveredWallets() {
|
|
183
|
-
return [
|
|
184
|
-
...walletStandard.getRegisteredSolanaWallets(),
|
|
185
|
-
...options.iosWallet === false ? [] : iosWallet.getSolanaIosWallets({
|
|
186
|
-
chains: [walletStandard.getSolanaChain(options.cluster)],
|
|
187
|
-
cluster: options.cluster,
|
|
188
|
-
...options.iosWallet || {}
|
|
189
|
-
})
|
|
190
|
-
];
|
|
191
|
-
}
|
|
192
|
-
function handleIosWalletCallback() {
|
|
193
|
-
try {
|
|
194
|
-
iosWallet.handleSolanaIosWalletCallback({ clearUrl: true });
|
|
195
|
-
} catch (cause) {
|
|
196
|
-
console.error("[Vue Solana] iOS wallet callback failed", cause);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
function* getCachedWallets() {
|
|
200
|
-
for (const walletInfo of options.getWalletInfos()) {
|
|
201
|
-
if (isObject(walletInfo.wallet)) {
|
|
202
|
-
const cachedWallet = adaptedWallets.get(walletInfo.wallet);
|
|
203
|
-
if (cachedWallet) {
|
|
204
|
-
yield cachedWallet;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
return {
|
|
210
|
-
getAdaptedWallet,
|
|
211
|
-
getDiscoveredWallets,
|
|
212
|
-
handleIosWalletCallback
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
function isObject(value) {
|
|
216
|
-
return typeof value === "object" && value !== null || typeof value === "function";
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
const RPC_CHECK_TIMEOUT_MS = 1e4;
|
|
220
|
-
function createSolanaPlugin(options = {}) {
|
|
221
|
-
const plugin = {
|
|
222
|
-
context: null,
|
|
223
|
-
install(app) {
|
|
224
|
-
const context = rpc.createSolanaContext(options);
|
|
225
|
-
const wallet = vue.shallowRef(options.wallet ?? null);
|
|
226
|
-
const wallets = vue.shallowRef([]);
|
|
227
|
-
const selectedWallet = vue.shallowRef(null);
|
|
228
|
-
const status = vue.ref("idle");
|
|
229
|
-
const error = vue.ref(null);
|
|
230
|
-
const latestBlockhash = vue.ref(null);
|
|
231
|
-
const walletRegistry = createSolanaWalletRegistry({
|
|
232
|
-
cluster: context.cluster,
|
|
233
|
-
iosWallet: options.iosWallet,
|
|
234
|
-
getWalletInfos: () => wallets.value,
|
|
235
|
-
onWalletChange: () => vue.triggerRef(wallet)
|
|
236
|
-
});
|
|
237
|
-
let unsubscribeWallets = null;
|
|
238
|
-
let mobileWalletRegistrationPromise = null;
|
|
239
|
-
let attemptedAutoConnectWallet = null;
|
|
240
|
-
let rpcCheckId = 0;
|
|
241
|
-
async function checkConnection() {
|
|
242
|
-
const checkId = ++rpcCheckId;
|
|
243
|
-
status.value = "checking";
|
|
244
|
-
error.value = null;
|
|
245
|
-
console.info("[Vue Solana] Checking RPC connection", {
|
|
246
|
-
cluster: context.cluster,
|
|
247
|
-
endpoint: context.endpoint,
|
|
248
|
-
wsEndpoint: context.wsEndpoint
|
|
249
|
-
});
|
|
250
|
-
try {
|
|
251
|
-
const response = await timeout.withTimeout(
|
|
252
|
-
context.client.rpc.getLatestBlockhash().send(),
|
|
253
|
-
RPC_CHECK_TIMEOUT_MS,
|
|
254
|
-
() => new Error(
|
|
255
|
-
`RPC connection check timed out after ${RPC_CHECK_TIMEOUT_MS / 1e3} seconds.`
|
|
256
|
-
)
|
|
257
|
-
);
|
|
258
|
-
const blockhash = response.value;
|
|
259
|
-
if (checkId !== rpcCheckId) {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
latestBlockhash.value = blockhash.blockhash;
|
|
263
|
-
status.value = "connected";
|
|
264
|
-
console.info("[Vue Solana] Connected", {
|
|
265
|
-
cluster: context.cluster,
|
|
266
|
-
endpoint: context.endpoint,
|
|
267
|
-
wsEndpoint: context.wsEndpoint,
|
|
268
|
-
blockhash
|
|
269
|
-
});
|
|
270
|
-
} catch (cause) {
|
|
271
|
-
if (checkId !== rpcCheckId) {
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
status.value = "error";
|
|
275
|
-
error.value = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
276
|
-
console.error("[Vue Solana] Connection failed", cause);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
function refreshWallets() {
|
|
280
|
-
unsubscribeWallets ??= walletStandard.subscribeSolanaWallets(refreshWallets);
|
|
281
|
-
walletRegistry.handleIosWalletCallback();
|
|
282
|
-
wallets.value = walletRegistry.getDiscoveredWallets();
|
|
283
|
-
let restoredWallet = null;
|
|
284
|
-
if (selectedWallet.value) {
|
|
285
|
-
selectedWallet.value = wallets.value.find((nextWallet) => isSameWallet(nextWallet, selectedWallet.value)) ?? null;
|
|
286
|
-
if (!selectedWallet.value) {
|
|
287
|
-
wallet.value = options.wallet ?? null;
|
|
288
|
-
}
|
|
289
|
-
} else if (!options.wallet) {
|
|
290
|
-
const persistedWallet = readSelectedWallet();
|
|
291
|
-
if (persistedWallet.error) {
|
|
292
|
-
error.value = persistedWallet.error;
|
|
293
|
-
console.error("[Vue Solana] Selected wallet restoration failed", persistedWallet.error);
|
|
294
|
-
}
|
|
295
|
-
restoredWallet = persistedWallet.wallet ? wallets.value.find(
|
|
296
|
-
(nextWallet) => isSameWallet(nextWallet, persistedWallet.wallet)
|
|
297
|
-
) ?? null : null;
|
|
298
|
-
if (restoredWallet) {
|
|
299
|
-
selectedWallet.value = restoredWallet;
|
|
300
|
-
wallet.value = walletRegistry.getAdaptedWallet(restoredWallet);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
if (options.mobileWallet !== false) {
|
|
304
|
-
registerMobileWallets();
|
|
305
|
-
}
|
|
306
|
-
if (restoredWallet) {
|
|
307
|
-
autoConnectWallet(restoredWallet);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
function registerMobileWallets() {
|
|
311
|
-
mobileWalletRegistrationPromise ??= import('@vue-solana/core/mobile-wallet').then(({ registerSolanaMobileWallet }) => {
|
|
312
|
-
registerSolanaMobileWallet({
|
|
313
|
-
chains: [walletStandard.getSolanaChain(context.cluster)],
|
|
314
|
-
...options.mobileWallet || {}
|
|
315
|
-
});
|
|
316
|
-
refreshWallets();
|
|
317
|
-
}).catch((cause) => {
|
|
318
|
-
console.error("[Vue Solana] Mobile wallet registration failed", cause);
|
|
319
|
-
}).finally(() => {
|
|
320
|
-
mobileWalletRegistrationPromise = null;
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
|
-
function selectWallet(nextWallet) {
|
|
324
|
-
selectedWallet.value = nextWallet;
|
|
325
|
-
wallet.value = nextWallet ? walletRegistry.getAdaptedWallet(nextWallet) : options.wallet ?? null;
|
|
326
|
-
const storageError = writeSelectedWallet(nextWallet);
|
|
327
|
-
if (storageError) {
|
|
328
|
-
error.value = storageError;
|
|
329
|
-
console.error("[Vue Solana] Selected wallet persistence failed", storageError);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
function autoConnectWallet(walletInfo) {
|
|
333
|
-
if (!options.autoConnect) {
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
const activeWallet = wallet.value;
|
|
337
|
-
const storageValue = stringifySelectedWallet(walletInfo);
|
|
338
|
-
if (!activeWallet || activeWallet.connected || activeWallet.connecting || attemptedAutoConnectWallet === storageValue) {
|
|
339
|
-
return;
|
|
340
|
-
}
|
|
341
|
-
attemptedAutoConnectWallet = storageValue;
|
|
342
|
-
void activeWallet.connect().catch((cause) => {
|
|
343
|
-
console.error("[Vue Solana] Wallet auto-connect failed", cause);
|
|
344
|
-
}).finally(() => {
|
|
345
|
-
vue.triggerRef(wallet);
|
|
346
|
-
});
|
|
347
|
-
}
|
|
348
|
-
const vueContext = {
|
|
349
|
-
...context,
|
|
350
|
-
wallet,
|
|
351
|
-
status,
|
|
352
|
-
error,
|
|
353
|
-
latestBlockhash,
|
|
354
|
-
wallets,
|
|
355
|
-
selectedWallet,
|
|
356
|
-
checkConnection,
|
|
357
|
-
refreshWallets,
|
|
358
|
-
selectWallet,
|
|
359
|
-
setWallet(nextWallet) {
|
|
360
|
-
selectedWallet.value = null;
|
|
361
|
-
wallet.value = nextWallet;
|
|
362
|
-
const storageError = writeSelectedWallet(null);
|
|
363
|
-
if (storageError) {
|
|
364
|
-
error.value = storageError;
|
|
365
|
-
console.error("[Vue Solana] Selected wallet persistence failed", storageError);
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
app.provide(injection.solanaInjectionKey, vueContext);
|
|
370
|
-
plugin.context = vueContext;
|
|
371
|
-
if (typeof window !== "undefined") {
|
|
372
|
-
window.setTimeout(() => {
|
|
373
|
-
try {
|
|
374
|
-
refreshWallets();
|
|
375
|
-
} catch (cause) {
|
|
376
|
-
console.error("[Vue Solana] Wallet refresh failed", cause);
|
|
377
|
-
}
|
|
378
|
-
void checkConnection();
|
|
379
|
-
}, 0);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
return plugin;
|
|
384
|
-
}
|
|
385
|
-
function isSameWallet(wallet, selectedWallet) {
|
|
386
|
-
return wallet.name === selectedWallet?.name && wallet.source === selectedWallet.source && wallet.platform === selectedWallet.platform;
|
|
387
|
-
}
|
|
388
|
-
const VueSolana = createSolanaPlugin;
|
|
389
|
-
|
|
390
|
-
exports.useAccountInfo = useAccountInfo.useAccountInfo;
|
|
391
|
-
exports.useAction = useAction.useAction;
|
|
392
|
-
exports.useAirdrop = useAirdrop.useAirdrop;
|
|
393
|
-
exports.useBalance = useBalance.useBalance;
|
|
394
|
-
exports.MissingClientCapabilityError = useClientCapability.MissingClientCapabilityError;
|
|
395
|
-
exports.useClientCapability = useClientCapability.useClientCapability;
|
|
396
|
-
exports.useConnection = useConnection.useConnection;
|
|
397
|
-
exports.usePlanTransaction = usePlanTransaction.usePlanTransaction;
|
|
398
|
-
exports.usePlanTransactions = usePlanTransaction.usePlanTransactions;
|
|
399
|
-
exports.useProgramAccounts = useProgramAccounts.useProgramAccounts;
|
|
400
|
-
exports.useIdentity = usePayer.useIdentity;
|
|
401
|
-
exports.usePayer = usePayer.usePayer;
|
|
402
|
-
exports.useRequest = useRequest.useRequest;
|
|
403
|
-
exports.useRpc = useRpc.useRpc;
|
|
404
|
-
exports.SelectedWalletAccountProvider = SelectedWalletAccountProvider.SelectedWalletAccountProvider;
|
|
405
|
-
exports.createSelectedWalletAccountContext = SelectedWalletAccountProvider.createSelectedWalletAccountContext;
|
|
406
|
-
exports.provideSelectedWalletAccount = SelectedWalletAccountProvider.provideSelectedWalletAccount;
|
|
407
|
-
exports.selectedWalletAccountInjectionKey = SelectedWalletAccountProvider.selectedWalletAccountInjectionKey;
|
|
408
|
-
exports.useSelectedWalletAccount = SelectedWalletAccountProvider.useSelectedWalletAccount;
|
|
409
|
-
exports.useSendTransaction = useSendTransaction.useSendTransaction;
|
|
410
|
-
exports.useSendTransactions = useSendTransaction.useSendTransactions;
|
|
411
|
-
exports.useSignMessage = useSignMessage.useSignMessage;
|
|
412
|
-
exports.useSignAndSendTransaction = useSignAndSendTransaction.useSignAndSendTransaction;
|
|
413
|
-
exports.useSignTransactions = useSignTransactions.useSignTransactions;
|
|
414
|
-
exports.PartialSignAndSendError = useSignAndSendTransactions.PartialSignAndSendError;
|
|
415
|
-
exports.useSignAndSendTransactions = useSignAndSendTransactions.useSignAndSendTransactions;
|
|
416
|
-
exports.useSignatureStatus = useSignatureStatus.useSignatureStatus;
|
|
417
|
-
exports.useSignIn = useSignIn.useSignIn;
|
|
418
|
-
exports.tryUseSolana = useSolana.tryUseSolana;
|
|
419
|
-
exports.useSolana = useSolana.useSolana;
|
|
420
|
-
exports.useSolanaClient = useSolanaClient.useSolanaClient;
|
|
421
|
-
exports.useSubscription = useSubscription.useSubscription;
|
|
422
|
-
exports.useTokenAccounts = useTokenAccounts.useTokenAccounts;
|
|
423
|
-
exports.useTokenBalance = useTokenBalance.useTokenBalance;
|
|
424
|
-
exports.useTrackedData = useTrackedData.useTrackedData;
|
|
425
|
-
exports.useTransaction = useTransaction.useTransaction;
|
|
426
|
-
exports.getConfirmedTransactionStatus = useTransactionConfirmation.getConfirmedTransactionStatus;
|
|
427
|
-
exports.useTransactionConfirmation = useTransactionConfirmation.useTransactionConfirmation;
|
|
428
|
-
exports.useWallet = useWallet.useWallet;
|
|
429
|
-
exports.useWallets = useWallets.useWallets;
|
|
430
|
-
exports.solanaInjectionKey = injection.solanaInjectionKey;
|
|
431
|
-
exports.VueSolana = VueSolana;
|
|
432
|
-
exports.createSolanaPlugin = createSolanaPlugin;
|
|
433
|
-
Object.prototype.hasOwnProperty.call(types, '__proto__') &&
|
|
434
|
-
!Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
|
|
435
|
-
Object.defineProperty(exports, '__proto__', {
|
|
436
|
-
enumerable: true,
|
|
437
|
-
value: types['__proto__']
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
Object.keys(types).forEach(function (k) {
|
|
441
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = types[k];
|
|
442
|
-
});
|
|
443
|
-
Object.prototype.hasOwnProperty.call(kit, '__proto__') &&
|
|
444
|
-
!Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
|
|
445
|
-
Object.defineProperty(exports, '__proto__', {
|
|
446
|
-
enumerable: true,
|
|
447
|
-
value: kit['__proto__']
|
|
448
|
-
});
|
|
449
|
-
|
|
450
|
-
Object.keys(kit).forEach(function (k) {
|
|
451
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = kit[k];
|
|
452
|
-
});
|
package/dist/index.d.cts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export { AccountInfo, UseAccountInfoOptions, useAccountInfo } from './useAccountInfo.cjs';
|
|
2
|
-
export { UseActionOptions, UseActionReturn, UseActionStatus, useAction } from './useAction.cjs';
|
|
3
|
-
export { useAirdrop } from './useAirdrop.cjs';
|
|
4
|
-
export { BalanceInput, useBalance } from './useBalance.cjs';
|
|
5
|
-
export { MissingClientCapabilityError, UseClientCapabilityOptions, useClientCapability } from './useClientCapability.cjs';
|
|
6
|
-
export { useConnection } from './useConnection.cjs';
|
|
7
|
-
export { PlanTransactionConfig, PlanTransactionStatus, usePlanTransaction, usePlanTransactions } from './usePlanTransaction.cjs';
|
|
8
|
-
export { ProgramAccount, ProgramAccountDataSizeFilter, ProgramAccountDataSlice, ProgramAccountFilter, ProgramAccountMemcmpEncoding, ProgramAccountMemcmpFilter, UseProgramAccountsOptions, useProgramAccounts } from './useProgramAccounts.cjs';
|
|
9
|
-
export { useIdentity, usePayer } from './usePayer.cjs';
|
|
10
|
-
export { UseRequestOptions, UseRequestRefresherOptions, UseRequestReturn, UseRequestSource, UseRequestStatus, useRequest } from './useRequest.cjs';
|
|
11
|
-
export { useRpc } from './useRpc.cjs';
|
|
12
|
-
export { SelectedWalletAccount, SelectedWalletAccountContext, SelectedWalletAccountOptions, SelectedWalletAccountProvider, WalletAccountFilter, createSelectedWalletAccountContext, provideSelectedWalletAccount, selectedWalletAccountInjectionKey, useSelectedWalletAccount } from './useSelectedWalletAccount.cjs';
|
|
13
|
-
export { SendTransactionConfig, SendTransactionInput, SendTransactionStatus, SendTransactionsInput, useSendTransaction, useSendTransactions } from './useSendTransaction.cjs';
|
|
14
|
-
export { SignMessageStatus, useSignMessage } from './useSignMessage.cjs';
|
|
15
|
-
export { SignAndSendTransactionOptions, SignAndSendTransactionStatus, useSignAndSendTransaction } from './useSignAndSendTransaction.cjs';
|
|
16
|
-
export { SignTransactionsStatus, useSignTransactions } from './useSignTransactions.cjs';
|
|
17
|
-
export { PartialSignAndSendError, SignAndSendTransactionsStatus, useSignAndSendTransactions } from './useSignAndSendTransactions.cjs';
|
|
18
|
-
export { SignatureStatus, UseSignatureStatusOptions, useSignatureStatus } from './useSignatureStatus.cjs';
|
|
19
|
-
export { SignInStatus, useSignIn } from './useSignIn.cjs';
|
|
20
|
-
export { tryUseSolana, useSolana } from './useSolana.cjs';
|
|
21
|
-
export { useSolanaClient } from './useSolanaClient.cjs';
|
|
22
|
-
export { UseSubscriptionOptions, UseSubscriptionReconnectOptions, UseSubscriptionReturn, UseSubscriptionSource, UseSubscriptionStatus, useSubscription } from './useSubscription.cjs';
|
|
23
|
-
export { UseTokenAccountsOptions, useTokenAccounts } from './useTokenAccounts.cjs';
|
|
24
|
-
export { useTokenBalance } from './useTokenBalance.cjs';
|
|
25
|
-
export { UseTrackedDataInitialSource, UseTrackedDataOptions, UseTrackedDataRefresherOptions, UseTrackedDataReturn, UseTrackedDataSource, UseTrackedDataStatus, UseTrackedDataStreamSource, useTrackedData } from './useTrackedData.cjs';
|
|
26
|
-
export { UseTransactionOptions, useTransaction } from './useTransaction.cjs';
|
|
27
|
-
export { TransactionConfirmationStatus, getConfirmedTransactionStatus, useTransactionConfirmation } from './useTransactionConfirmation.cjs';
|
|
28
|
-
export { useWallet } from './useWallet.cjs';
|
|
29
|
-
export { useWallets } from './useWallets.cjs';
|
|
30
|
-
import { V as VueSolanaContext } from './shared/vue.DL3z5PxP.cjs';
|
|
31
|
-
export { S as SolanaConnectionStatus, s as solanaInjectionKey } from './shared/vue.DL3z5PxP.cjs';
|
|
32
|
-
import { GetSolanaIosWalletsOptions } from '@vue-solana/core/ios-wallet';
|
|
33
|
-
import { RegisterSolanaMobileWalletOptions } from '@vue-solana/core/mobile-wallet';
|
|
34
|
-
import { SolanaConfig, SolanaWallet } from '@vue-solana/core/types';
|
|
35
|
-
export * from '@vue-solana/core/types';
|
|
36
|
-
import { App } from 'vue';
|
|
37
|
-
export * from '@vue-solana/core/kit';
|
|
38
|
-
import '@vue-solana/core/errors';
|
|
39
|
-
import '@solana/kit-plugin-rpc';
|
|
40
|
-
import '@solana/kit';
|
|
41
|
-
import '@vue-solana/core/token-accounts';
|
|
42
|
-
|
|
43
|
-
interface VueSolanaPluginOptions extends SolanaConfig {
|
|
44
|
-
wallet?: SolanaWallet | null;
|
|
45
|
-
mobileWallet?: false | RegisterSolanaMobileWalletOptions;
|
|
46
|
-
iosWallet?: false | GetSolanaIosWalletsOptions;
|
|
47
|
-
}
|
|
48
|
-
interface VueSolanaPlugin {
|
|
49
|
-
/** Installs the plugin on a Vue app (called synchronously by `app.use`). */
|
|
50
|
-
install(app: App): void;
|
|
51
|
-
/**
|
|
52
|
-
* The app context built by `install`, available once `app.use(plugin)` has
|
|
53
|
-
* run. Lets framework integrations (e.g. the Nuxt module) hand the live
|
|
54
|
-
* context to consumers that run outside a component setup.
|
|
55
|
-
*/
|
|
56
|
-
context: VueSolanaContext | null;
|
|
57
|
-
}
|
|
58
|
-
declare function createSolanaPlugin(options?: VueSolanaPluginOptions): VueSolanaPlugin;
|
|
59
|
-
declare const VueSolana: typeof createSolanaPlugin;
|
|
60
|
-
|
|
61
|
-
export { VueSolana, VueSolanaContext, createSolanaPlugin };
|
|
62
|
-
export type { VueSolanaPlugin, VueSolanaPluginOptions };
|
package/dist/kit.cjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const kit = require('@vue-solana/core/kit');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.prototype.hasOwnProperty.call(kit, '__proto__') &&
|
|
8
|
-
!Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
|
|
9
|
-
Object.defineProperty(exports, '__proto__', {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
value: kit['__proto__']
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
Object.keys(kit).forEach(function (k) {
|
|
15
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = kit[k];
|
|
16
|
-
});
|
package/dist/kit.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@vue-solana/core/kit';
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const useSolanaClient = require('./vue.BIxphCAq.cjs');
|
|
4
|
-
|
|
5
|
-
class MissingClientCapabilityError extends Error {
|
|
6
|
-
/** Name of the hook that requested the capability, e.g. `usePayer`. */
|
|
7
|
-
hookName;
|
|
8
|
-
/** Human guidance for installing the capability on the client. */
|
|
9
|
-
providerHint;
|
|
10
|
-
/** The missing capability name(s). */
|
|
11
|
-
capabilities;
|
|
12
|
-
constructor(hookName, capabilities, providerHint) {
|
|
13
|
-
super(
|
|
14
|
-
`${hookName} requires the ${capabilities.map((capability) => `\`${capability}\``).join(" and ")} capabilit${capabilities.length === 1 ? "y" : "ies"} on the Solana client, but none ${capabilities.length === 1 ? "was" : "were"} found. ` + providerHint
|
|
15
|
-
);
|
|
16
|
-
this.name = "MissingClientCapabilityError";
|
|
17
|
-
this.hookName = hookName;
|
|
18
|
-
this.capabilities = capabilities;
|
|
19
|
-
this.providerHint = providerHint;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function useClientCapability(capability, options = {}) {
|
|
23
|
-
const capabilities = Array.isArray(capability) ? [...capability] : [capability];
|
|
24
|
-
const hookName = options.hookName ?? "useClientCapability";
|
|
25
|
-
const providerHint = options.providerHint ?? "Install it by adding the corresponding @solana/kit plugin with `createClient().use(...)`.";
|
|
26
|
-
const { client } = useSolanaClient.useSolanaClient();
|
|
27
|
-
for (const name of capabilities) {
|
|
28
|
-
const value = client[name];
|
|
29
|
-
if (value === null || typeof value !== "function" && typeof value !== "object") {
|
|
30
|
-
throw new MissingClientCapabilityError(hookName, [name], providerHint);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
exports.MissingClientCapabilityError = MissingClientCapabilityError;
|
|
36
|
-
exports.useClientCapability = useClientCapability;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const errors = require('@vue-solana/core/errors');
|
|
4
|
-
const wallet = require('@vue-solana/core/wallet');
|
|
5
|
-
const vue = require('vue');
|
|
6
|
-
const useWallet = require('./vue.BGxz4dru.cjs');
|
|
7
|
-
|
|
8
|
-
function useSignIn() {
|
|
9
|
-
const { wallet: wallet$1 } = useWallet.useWallet();
|
|
10
|
-
const signInResult = vue.shallowRef(null);
|
|
11
|
-
const status = vue.ref("idle");
|
|
12
|
-
const loading = vue.ref(false);
|
|
13
|
-
const error = vue.ref(null);
|
|
14
|
-
let executionId = 0;
|
|
15
|
-
async function signIn(input) {
|
|
16
|
-
const currentExecutionId = ++executionId;
|
|
17
|
-
status.value = "signing-in";
|
|
18
|
-
loading.value = true;
|
|
19
|
-
error.value = null;
|
|
20
|
-
signInResult.value = null;
|
|
21
|
-
const activeWallet = wallet$1.value;
|
|
22
|
-
if (!activeWallet) {
|
|
23
|
-
const normalizedError = wallet.createNoWalletSelectedError();
|
|
24
|
-
error.value = normalizedError;
|
|
25
|
-
status.value = "error";
|
|
26
|
-
loading.value = false;
|
|
27
|
-
throw normalizedError;
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
wallet.assertWalletCanSignIn(activeWallet);
|
|
31
|
-
const result = await activeWallet.signIn(input);
|
|
32
|
-
if (currentExecutionId === executionId) {
|
|
33
|
-
signInResult.value = result;
|
|
34
|
-
status.value = "signed-in";
|
|
35
|
-
}
|
|
36
|
-
return result;
|
|
37
|
-
} catch (cause) {
|
|
38
|
-
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
39
|
-
if (currentExecutionId === executionId) {
|
|
40
|
-
error.value = normalizedError;
|
|
41
|
-
status.value = "error";
|
|
42
|
-
}
|
|
43
|
-
throw normalizedError;
|
|
44
|
-
} finally {
|
|
45
|
-
if (currentExecutionId === executionId) {
|
|
46
|
-
loading.value = false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
signInResult,
|
|
52
|
-
status,
|
|
53
|
-
loading,
|
|
54
|
-
error,
|
|
55
|
-
signIn
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
exports.useSignIn = useSignIn;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const useAction = require('./vue.CoaIWGPT.cjs');
|
|
4
|
-
const useClientCapability = require('./vue.4C5kX4fE.cjs');
|
|
5
|
-
const useSolanaClient = require('./vue.BIxphCAq.cjs');
|
|
6
|
-
|
|
7
|
-
function toReadableAirdropError(error) {
|
|
8
|
-
if (error instanceof Error) {
|
|
9
|
-
const httpStatus = error.context?.statusCode;
|
|
10
|
-
const isThrottled = httpStatus === 429 || error.message.startsWith("JSON-RPC error: Internal JSON-RPC error (Internal error)");
|
|
11
|
-
if (!isThrottled) {
|
|
12
|
-
throw error;
|
|
13
|
-
}
|
|
14
|
-
throw new Error(
|
|
15
|
-
`${error.message} This likely means the network's airdrop faucet is rate-limited or out of test SOL. Retry later, use https://faucet.solana.com, or point the client at a local validator.`,
|
|
16
|
-
{ cause: error }
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
throw new Error(`Airdrop failed: ${String(error)}`);
|
|
20
|
-
}
|
|
21
|
-
function useAirdrop() {
|
|
22
|
-
useClientCapability.useClientCapability("airdrop", {
|
|
23
|
-
hookName: "useAirdrop",
|
|
24
|
-
providerHint: "Install it by adding the airdrop capability with `createClient().use(solanaRpc({ ... })).use(rpcAirdrop())` from `@solana/kit-plugin-rpc`, on a client that has a `payer` signer to sign the request."
|
|
25
|
-
});
|
|
26
|
-
const { client } = useSolanaClient.useSolanaClient();
|
|
27
|
-
return useAction.useAction((abortSignal, address, amount) => {
|
|
28
|
-
const airdrop = client.airdrop;
|
|
29
|
-
if (!airdrop) {
|
|
30
|
-
throw new Error("useAirdrop requires the `airdrop` capability on the Solana client.");
|
|
31
|
-
}
|
|
32
|
-
return airdrop(address, amount, abortSignal).catch(toReadableAirdropError);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
exports.useAirdrop = useAirdrop;
|