@vue-solana/vue 0.3.0 → 0.3.2
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 +1 -1
- package/dist/index.cjs +23 -10
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +24 -11
- package/dist/shared/vue.BfF-kOvb.mjs +24 -0
- package/dist/shared/vue.BwrQMPty.cjs +26 -0
- package/dist/shared/vue.CNhelr8H.cjs +59 -0
- package/dist/shared/vue.CuhLIeDx.mjs +57 -0
- package/dist/shared/{vue.CgR3nGpz.mjs → vue.DJqRk8z_.mjs} +2 -1
- package/dist/shared/{vue.CNkyBND6.cjs → vue.DONKZzIb.cjs} +2 -1
- package/dist/useBalance.cjs +2 -1
- package/dist/useBalance.mjs +2 -1
- package/dist/useSignAndSendTransaction.cjs +2 -2
- package/dist/useSignAndSendTransaction.d.cts +1 -1
- package/dist/useSignAndSendTransaction.d.mts +1 -1
- package/dist/useSignAndSendTransaction.d.ts +1 -1
- package/dist/useSignAndSendTransaction.mjs +2 -2
- package/dist/useTransaction.cjs +1 -1
- package/dist/useTransaction.d.cts +7 -2
- package/dist/useTransaction.d.mts +7 -2
- package/dist/useTransaction.d.ts +7 -2
- package/dist/useTransaction.mjs +1 -1
- package/package.json +2 -2
- package/dist/shared/vue.BMUEDN2t.mjs +0 -28
- package/dist/shared/vue.BSVxQ9Yi.cjs +0 -30
- package/dist/shared/vue.CTM6XQ47.cjs +0 -19
- package/dist/shared/vue.PoQ8Vpmy.mjs +0 -17
package/README.md
CHANGED
|
@@ -169,7 +169,7 @@ await execute(transaction, {
|
|
|
169
169
|
});
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
-
The current wallet must be connected and support either `signAndSendTransaction` or `signTransaction`.
|
|
172
|
+
The current wallet must be connected and support either `signAndSendTransaction` or `signTransaction`. Android Mobile Wallet Adapter wallets prefer `signTransaction` plus app-side RPC submission when available. `loading` is also cleared if a wallet adapter never returns a result; in that stale case, check the wallet or an explorer before retrying because chain status may be unknown.
|
|
173
173
|
|
|
174
174
|
## Example App
|
|
175
175
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const useBalance = require('./shared/vue.
|
|
3
|
+
const useBalance = require('./shared/vue.DONKZzIb.cjs');
|
|
4
4
|
const useConnection = require('./shared/vue.CwhEmATP.cjs');
|
|
5
5
|
const useRpc = require('./shared/vue.COyyrsQU.cjs');
|
|
6
|
-
const useSignAndSendTransaction = require('./shared/vue.
|
|
6
|
+
const useSignAndSendTransaction = require('./shared/vue.BwrQMPty.cjs');
|
|
7
7
|
const useSolana = require('./shared/vue.C4tLiG3R.cjs');
|
|
8
|
-
const useTransaction = require('./shared/vue.
|
|
8
|
+
const useTransaction = require('./shared/vue.CNhelr8H.cjs');
|
|
9
9
|
const useWallet = require('./shared/vue.CwPjPFN6.cjs');
|
|
10
10
|
const useWallets = require('./shared/vue.P9tgeC5S.cjs');
|
|
11
11
|
const walletStandard = require('@vue-solana/core/wallet-standard');
|
|
12
|
-
const mobileWallet = require('@vue-solana/core/mobile-wallet');
|
|
13
12
|
const rpc = require('@vue-solana/core/rpc');
|
|
14
13
|
const vue = require('vue');
|
|
14
|
+
require('@solana/web3-compat');
|
|
15
15
|
require('@vue-solana/core/transaction');
|
|
16
16
|
|
|
17
17
|
const RPC_CHECK_TIMEOUT_MS = 1e4;
|
|
@@ -27,6 +27,7 @@ function createSolanaPlugin(options = {}) {
|
|
|
27
27
|
const latestBlockhash = vue.ref(null);
|
|
28
28
|
const adaptedWallets = /* @__PURE__ */ new WeakMap();
|
|
29
29
|
let unsubscribeWallets = null;
|
|
30
|
+
let mobileWalletRegistrationPromise = null;
|
|
30
31
|
let rpcCheckId = 0;
|
|
31
32
|
async function checkConnection() {
|
|
32
33
|
const checkId = ++rpcCheckId;
|
|
@@ -64,12 +65,6 @@ function createSolanaPlugin(options = {}) {
|
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
function refreshWallets() {
|
|
67
|
-
if (options.mobileWallet !== false) {
|
|
68
|
-
mobileWallet.registerSolanaMobileWallet({
|
|
69
|
-
chains: [walletStandard.getSolanaChain(context.cluster)],
|
|
70
|
-
...options.mobileWallet || {}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
68
|
unsubscribeWallets ??= walletStandard.subscribeSolanaWallets(refreshWallets);
|
|
74
69
|
wallets.value = walletStandard.getRegisteredSolanaWallets();
|
|
75
70
|
if (selectedWallet.value) {
|
|
@@ -78,6 +73,22 @@ function createSolanaPlugin(options = {}) {
|
|
|
78
73
|
wallet.value = options.wallet ?? null;
|
|
79
74
|
}
|
|
80
75
|
}
|
|
76
|
+
if (options.mobileWallet !== false) {
|
|
77
|
+
registerMobileWallets();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function registerMobileWallets() {
|
|
81
|
+
mobileWalletRegistrationPromise ??= import('@vue-solana/core/mobile-wallet').then(({ registerSolanaMobileWallet }) => {
|
|
82
|
+
registerSolanaMobileWallet({
|
|
83
|
+
chains: [walletStandard.getSolanaChain(context.cluster)],
|
|
84
|
+
...options.mobileWallet || {}
|
|
85
|
+
});
|
|
86
|
+
wallets.value = walletStandard.getRegisteredSolanaWallets();
|
|
87
|
+
}).catch((cause) => {
|
|
88
|
+
console.error("[Vue Solana] Mobile wallet registration failed", cause);
|
|
89
|
+
}).finally(() => {
|
|
90
|
+
mobileWalletRegistrationPromise = null;
|
|
91
|
+
});
|
|
81
92
|
}
|
|
82
93
|
function selectWallet(nextWallet) {
|
|
83
94
|
selectedWallet.value = nextWallet;
|
|
@@ -99,6 +110,8 @@ function createSolanaPlugin(options = {}) {
|
|
|
99
110
|
onChange: () => vue.triggerRef(wallet)
|
|
100
111
|
});
|
|
101
112
|
const cachedAdapter = {
|
|
113
|
+
platform: walletInfo.platform,
|
|
114
|
+
source: walletInfo.source,
|
|
102
115
|
get publicKey() {
|
|
103
116
|
return adaptedWallet.publicKey;
|
|
104
117
|
},
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ export { useConnection } from './useConnection.cjs';
|
|
|
3
3
|
export { useRpc } from './useRpc.cjs';
|
|
4
4
|
export { useSignAndSendTransaction } from './useSignAndSendTransaction.cjs';
|
|
5
5
|
export { tryUseSolana, useSolana } from './useSolana.cjs';
|
|
6
|
-
export { useTransaction } from './useTransaction.cjs';
|
|
6
|
+
export { UseTransactionOptions, useTransaction } from './useTransaction.cjs';
|
|
7
7
|
export { useWallet } from './useWallet.cjs';
|
|
8
8
|
export { useWallets } from './useWallets.cjs';
|
|
9
9
|
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.cjs';
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ export { useConnection } from './useConnection.mjs';
|
|
|
3
3
|
export { useRpc } from './useRpc.mjs';
|
|
4
4
|
export { useSignAndSendTransaction } from './useSignAndSendTransaction.mjs';
|
|
5
5
|
export { tryUseSolana, useSolana } from './useSolana.mjs';
|
|
6
|
-
export { useTransaction } from './useTransaction.mjs';
|
|
6
|
+
export { UseTransactionOptions, useTransaction } from './useTransaction.mjs';
|
|
7
7
|
export { useWallet } from './useWallet.mjs';
|
|
8
8
|
export { useWallets } from './useWallets.mjs';
|
|
9
9
|
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { useConnection } from './useConnection.js';
|
|
|
3
3
|
export { useRpc } from './useRpc.js';
|
|
4
4
|
export { useSignAndSendTransaction } from './useSignAndSendTransaction.js';
|
|
5
5
|
export { tryUseSolana, useSolana } from './useSolana.js';
|
|
6
|
-
export { useTransaction } from './useTransaction.js';
|
|
6
|
+
export { UseTransactionOptions, useTransaction } from './useTransaction.js';
|
|
7
7
|
export { useWallet } from './useWallet.js';
|
|
8
8
|
export { useWallets } from './useWallets.js';
|
|
9
9
|
export { S as SolanaConnectionStatus, V as VueSolanaContext, s as solanaInjectionKey } from './shared/vue.DGhodYJh.js';
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
export { u as useBalance } from './shared/vue.
|
|
1
|
+
export { u as useBalance } from './shared/vue.DJqRk8z_.mjs';
|
|
2
2
|
export { u as useConnection } from './shared/vue.DlEAL2G8.mjs';
|
|
3
3
|
export { u as useRpc } from './shared/vue.BqDzSepb.mjs';
|
|
4
|
-
export { u as useSignAndSendTransaction } from './shared/vue.
|
|
4
|
+
export { u as useSignAndSendTransaction } from './shared/vue.BfF-kOvb.mjs';
|
|
5
5
|
import { s as solanaInjectionKey } from './shared/vue.1M_c5FWA.mjs';
|
|
6
6
|
export { t as tryUseSolana, u as useSolana } from './shared/vue.1M_c5FWA.mjs';
|
|
7
|
-
export { u as useTransaction } from './shared/vue.
|
|
7
|
+
export { u as useTransaction } from './shared/vue.CuhLIeDx.mjs';
|
|
8
8
|
export { u as useWallet } from './shared/vue.DYf_CRDv.mjs';
|
|
9
9
|
export { u as useWallets } from './shared/vue.h-uS8MXN.mjs';
|
|
10
|
-
import {
|
|
11
|
-
import { registerSolanaMobileWallet } from '@vue-solana/core/mobile-wallet';
|
|
10
|
+
import { subscribeSolanaWallets, getRegisteredSolanaWallets, adaptSolanaStandardWallet, getSolanaChain } from '@vue-solana/core/wallet-standard';
|
|
12
11
|
import { createSolanaContext } from '@vue-solana/core/rpc';
|
|
13
12
|
import { shallowRef, ref, triggerRef } from 'vue';
|
|
13
|
+
import '@solana/web3-compat';
|
|
14
14
|
import '@vue-solana/core/transaction';
|
|
15
15
|
|
|
16
16
|
const RPC_CHECK_TIMEOUT_MS = 1e4;
|
|
@@ -26,6 +26,7 @@ function createSolanaPlugin(options = {}) {
|
|
|
26
26
|
const latestBlockhash = ref(null);
|
|
27
27
|
const adaptedWallets = /* @__PURE__ */ new WeakMap();
|
|
28
28
|
let unsubscribeWallets = null;
|
|
29
|
+
let mobileWalletRegistrationPromise = null;
|
|
29
30
|
let rpcCheckId = 0;
|
|
30
31
|
async function checkConnection() {
|
|
31
32
|
const checkId = ++rpcCheckId;
|
|
@@ -63,12 +64,6 @@ function createSolanaPlugin(options = {}) {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
function refreshWallets() {
|
|
66
|
-
if (options.mobileWallet !== false) {
|
|
67
|
-
registerSolanaMobileWallet({
|
|
68
|
-
chains: [getSolanaChain(context.cluster)],
|
|
69
|
-
...options.mobileWallet || {}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
67
|
unsubscribeWallets ??= subscribeSolanaWallets(refreshWallets);
|
|
73
68
|
wallets.value = getRegisteredSolanaWallets();
|
|
74
69
|
if (selectedWallet.value) {
|
|
@@ -77,6 +72,22 @@ function createSolanaPlugin(options = {}) {
|
|
|
77
72
|
wallet.value = options.wallet ?? null;
|
|
78
73
|
}
|
|
79
74
|
}
|
|
75
|
+
if (options.mobileWallet !== false) {
|
|
76
|
+
registerMobileWallets();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
function registerMobileWallets() {
|
|
80
|
+
mobileWalletRegistrationPromise ??= import('@vue-solana/core/mobile-wallet').then(({ registerSolanaMobileWallet }) => {
|
|
81
|
+
registerSolanaMobileWallet({
|
|
82
|
+
chains: [getSolanaChain(context.cluster)],
|
|
83
|
+
...options.mobileWallet || {}
|
|
84
|
+
});
|
|
85
|
+
wallets.value = getRegisteredSolanaWallets();
|
|
86
|
+
}).catch((cause) => {
|
|
87
|
+
console.error("[Vue Solana] Mobile wallet registration failed", cause);
|
|
88
|
+
}).finally(() => {
|
|
89
|
+
mobileWalletRegistrationPromise = null;
|
|
90
|
+
});
|
|
80
91
|
}
|
|
81
92
|
function selectWallet(nextWallet) {
|
|
82
93
|
selectedWallet.value = nextWallet;
|
|
@@ -98,6 +109,8 @@ function createSolanaPlugin(options = {}) {
|
|
|
98
109
|
onChange: () => triggerRef(wallet)
|
|
99
110
|
});
|
|
100
111
|
const cachedAdapter = {
|
|
112
|
+
platform: walletInfo.platform,
|
|
113
|
+
source: walletInfo.source,
|
|
101
114
|
get publicKey() {
|
|
102
115
|
return adaptedWallet.publicKey;
|
|
103
116
|
},
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { signAndSendTransaction } from '@vue-solana/core/transaction';
|
|
2
|
+
import { u as useConnection } from './vue.DlEAL2G8.mjs';
|
|
3
|
+
import { u as useWallet } from './vue.DYf_CRDv.mjs';
|
|
4
|
+
import { u as useTransaction } from './vue.CuhLIeDx.mjs';
|
|
5
|
+
|
|
6
|
+
const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
|
|
7
|
+
function useSignAndSendTransaction() {
|
|
8
|
+
const connection = useConnection();
|
|
9
|
+
const { wallet } = useWallet();
|
|
10
|
+
return useTransaction(
|
|
11
|
+
(transaction, options) => {
|
|
12
|
+
if (!wallet.value) {
|
|
13
|
+
return Promise.reject(new Error("No Solana wallet is configured"));
|
|
14
|
+
}
|
|
15
|
+
return signAndSendTransaction(connection, wallet.value, transaction, options);
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
timeoutMs: SIGN_AND_SEND_TIMEOUT_MS,
|
|
19
|
+
timeoutMessage: "Wallet transaction did not return a result. Check your wallet or explorer for the final status."
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { useSignAndSendTransaction as u };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const transaction = require('@vue-solana/core/transaction');
|
|
4
|
+
const useConnection = require('./vue.CwhEmATP.cjs');
|
|
5
|
+
const useWallet = require('./vue.CwPjPFN6.cjs');
|
|
6
|
+
const useTransaction = require('./vue.CNhelr8H.cjs');
|
|
7
|
+
|
|
8
|
+
const SIGN_AND_SEND_TIMEOUT_MS = 12e4;
|
|
9
|
+
function useSignAndSendTransaction() {
|
|
10
|
+
const connection = useConnection.useConnection();
|
|
11
|
+
const { wallet } = useWallet.useWallet();
|
|
12
|
+
return useTransaction.useTransaction(
|
|
13
|
+
(transaction$1, options) => {
|
|
14
|
+
if (!wallet.value) {
|
|
15
|
+
return Promise.reject(new Error("No Solana wallet is configured"));
|
|
16
|
+
}
|
|
17
|
+
return transaction.signAndSendTransaction(connection, wallet.value, transaction$1, options);
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
timeoutMs: SIGN_AND_SEND_TIMEOUT_MS,
|
|
21
|
+
timeoutMessage: "Wallet transaction did not return a result. Check your wallet or explorer for the final status."
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
exports.useSignAndSendTransaction = useSignAndSendTransaction;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const vue = require('vue');
|
|
4
|
+
|
|
5
|
+
function useTransaction(handler, options = {}) {
|
|
6
|
+
const signature = vue.ref(null);
|
|
7
|
+
const loading = vue.ref(false);
|
|
8
|
+
const error = vue.ref(null);
|
|
9
|
+
let executionId = 0;
|
|
10
|
+
async function execute(...args) {
|
|
11
|
+
const currentExecutionId = ++executionId;
|
|
12
|
+
loading.value = true;
|
|
13
|
+
error.value = null;
|
|
14
|
+
try {
|
|
15
|
+
const nextSignature = await withTimeout(
|
|
16
|
+
handler(...args),
|
|
17
|
+
options.timeoutMs,
|
|
18
|
+
options.timeoutMessage ?? "Transaction did not return a result before timing out."
|
|
19
|
+
);
|
|
20
|
+
if (currentExecutionId === executionId) {
|
|
21
|
+
signature.value = nextSignature;
|
|
22
|
+
}
|
|
23
|
+
return nextSignature;
|
|
24
|
+
} catch (cause) {
|
|
25
|
+
if (currentExecutionId === executionId) {
|
|
26
|
+
error.value = cause;
|
|
27
|
+
}
|
|
28
|
+
throw cause;
|
|
29
|
+
} finally {
|
|
30
|
+
if (currentExecutionId === executionId) {
|
|
31
|
+
loading.value = false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
signature,
|
|
37
|
+
loading,
|
|
38
|
+
error,
|
|
39
|
+
execute
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function withTimeout(promise, timeoutMs, message) {
|
|
43
|
+
if (!timeoutMs) {
|
|
44
|
+
return promise;
|
|
45
|
+
}
|
|
46
|
+
let timeoutId;
|
|
47
|
+
const timeout = new Promise((_, reject) => {
|
|
48
|
+
timeoutId = setTimeout(() => {
|
|
49
|
+
reject(new Error(message));
|
|
50
|
+
}, timeoutMs);
|
|
51
|
+
});
|
|
52
|
+
return Promise.race([promise, timeout]).finally(() => {
|
|
53
|
+
if (timeoutId) {
|
|
54
|
+
clearTimeout(timeoutId);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
exports.useTransaction = useTransaction;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
function useTransaction(handler, options = {}) {
|
|
4
|
+
const signature = ref(null);
|
|
5
|
+
const loading = ref(false);
|
|
6
|
+
const error = ref(null);
|
|
7
|
+
let executionId = 0;
|
|
8
|
+
async function execute(...args) {
|
|
9
|
+
const currentExecutionId = ++executionId;
|
|
10
|
+
loading.value = true;
|
|
11
|
+
error.value = null;
|
|
12
|
+
try {
|
|
13
|
+
const nextSignature = await withTimeout(
|
|
14
|
+
handler(...args),
|
|
15
|
+
options.timeoutMs,
|
|
16
|
+
options.timeoutMessage ?? "Transaction did not return a result before timing out."
|
|
17
|
+
);
|
|
18
|
+
if (currentExecutionId === executionId) {
|
|
19
|
+
signature.value = nextSignature;
|
|
20
|
+
}
|
|
21
|
+
return nextSignature;
|
|
22
|
+
} catch (cause) {
|
|
23
|
+
if (currentExecutionId === executionId) {
|
|
24
|
+
error.value = cause;
|
|
25
|
+
}
|
|
26
|
+
throw cause;
|
|
27
|
+
} finally {
|
|
28
|
+
if (currentExecutionId === executionId) {
|
|
29
|
+
loading.value = false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
signature,
|
|
35
|
+
loading,
|
|
36
|
+
error,
|
|
37
|
+
execute
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function withTimeout(promise, timeoutMs, message) {
|
|
41
|
+
if (!timeoutMs) {
|
|
42
|
+
return promise;
|
|
43
|
+
}
|
|
44
|
+
let timeoutId;
|
|
45
|
+
const timeout = new Promise((_, reject) => {
|
|
46
|
+
timeoutId = setTimeout(() => {
|
|
47
|
+
reject(new Error(message));
|
|
48
|
+
}, timeoutMs);
|
|
49
|
+
});
|
|
50
|
+
return Promise.race([promise, timeout]).finally(() => {
|
|
51
|
+
if (timeoutId) {
|
|
52
|
+
clearTimeout(timeoutId);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { useTransaction as u };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3-compat';
|
|
1
2
|
import { ref, onMounted, watch, toValue } from 'vue';
|
|
2
3
|
import { u as useConnection } from './vue.DlEAL2G8.mjs';
|
|
3
4
|
import { t as tryUseSolana } from './vue.1M_c5FWA.mjs';
|
|
@@ -17,7 +18,7 @@ function useBalance(address, commitment) {
|
|
|
17
18
|
loading.value = true;
|
|
18
19
|
error.value = null;
|
|
19
20
|
try {
|
|
20
|
-
const publicKey = typeof value === "string" ? new
|
|
21
|
+
const publicKey = typeof value === "string" ? new PublicKey(value) : value;
|
|
21
22
|
balance.value = await connection.getBalance(publicKey, commitment);
|
|
22
23
|
return balance.value;
|
|
23
24
|
} catch (cause) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const web3Compat = require('@solana/web3-compat');
|
|
3
4
|
const vue = require('vue');
|
|
4
5
|
const useConnection = require('./vue.CwhEmATP.cjs');
|
|
5
6
|
const useSolana = require('./vue.C4tLiG3R.cjs');
|
|
@@ -19,7 +20,7 @@ function useBalance(address, commitment) {
|
|
|
19
20
|
loading.value = true;
|
|
20
21
|
error.value = null;
|
|
21
22
|
try {
|
|
22
|
-
const publicKey = typeof value === "string" ? new
|
|
23
|
+
const publicKey = typeof value === "string" ? new web3Compat.PublicKey(value) : value;
|
|
23
24
|
balance.value = await connection.getBalance(publicKey, commitment);
|
|
24
25
|
return balance.value;
|
|
25
26
|
} catch (cause) {
|
package/dist/useBalance.cjs
CHANGED
package/dist/useBalance.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const useSignAndSendTransaction = require('./shared/vue.
|
|
3
|
+
const useSignAndSendTransaction = require('./shared/vue.BwrQMPty.cjs');
|
|
4
4
|
require('@vue-solana/core/transaction');
|
|
5
5
|
require('./shared/vue.CwhEmATP.cjs');
|
|
6
6
|
require('./shared/vue.COyyrsQU.cjs');
|
|
7
7
|
require('vue');
|
|
8
8
|
require('./shared/vue.C4tLiG3R.cjs');
|
|
9
9
|
require('./shared/vue.CwPjPFN6.cjs');
|
|
10
|
-
require('./shared/vue.
|
|
10
|
+
require('./shared/vue.CNhelr8H.cjs');
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -5,7 +5,7 @@ declare function useSignAndSendTransaction(): {
|
|
|
5
5
|
signature: any;
|
|
6
6
|
loading: vue.Ref<boolean, boolean>;
|
|
7
7
|
error: vue.Ref<unknown, unknown>;
|
|
8
|
-
execute: (transaction: any, options?: SendTransactionOptions | undefined) => Promise<
|
|
8
|
+
execute: (transaction: any, options?: SendTransactionOptions | undefined) => Promise<TransactionSignature>;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export { useSignAndSendTransaction };
|
|
@@ -5,7 +5,7 @@ declare function useSignAndSendTransaction(): {
|
|
|
5
5
|
signature: any;
|
|
6
6
|
loading: vue.Ref<boolean, boolean>;
|
|
7
7
|
error: vue.Ref<unknown, unknown>;
|
|
8
|
-
execute: (transaction: any, options?: SendTransactionOptions | undefined) => Promise<
|
|
8
|
+
execute: (transaction: any, options?: SendTransactionOptions | undefined) => Promise<TransactionSignature>;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export { useSignAndSendTransaction };
|
|
@@ -5,7 +5,7 @@ declare function useSignAndSendTransaction(): {
|
|
|
5
5
|
signature: any;
|
|
6
6
|
loading: vue.Ref<boolean, boolean>;
|
|
7
7
|
error: vue.Ref<unknown, unknown>;
|
|
8
|
-
execute: (transaction: any, options?: SendTransactionOptions | undefined) => Promise<
|
|
8
|
+
execute: (transaction: any, options?: SendTransactionOptions | undefined) => Promise<TransactionSignature>;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export { useSignAndSendTransaction };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { u as useSignAndSendTransaction } from './shared/vue.
|
|
1
|
+
export { u as useSignAndSendTransaction } from './shared/vue.BfF-kOvb.mjs';
|
|
2
2
|
import '@vue-solana/core/transaction';
|
|
3
3
|
import './shared/vue.DlEAL2G8.mjs';
|
|
4
4
|
import './shared/vue.BqDzSepb.mjs';
|
|
5
5
|
import 'vue';
|
|
6
6
|
import './shared/vue.1M_c5FWA.mjs';
|
|
7
7
|
import './shared/vue.DYf_CRDv.mjs';
|
|
8
|
-
import './shared/vue.
|
|
8
|
+
import './shared/vue.CuhLIeDx.mjs';
|
package/dist/useTransaction.cjs
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { TransactionSignature } from '@solana/web3-compat';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface UseTransactionOptions {
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
timeoutMessage?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function useTransaction<TArgs extends unknown[]>(handler: (...args: TArgs) => Promise<TransactionSignature>, options?: UseTransactionOptions): {
|
|
5
9
|
signature: any;
|
|
6
10
|
loading: vue.Ref<boolean, boolean>;
|
|
7
11
|
error: vue.Ref<unknown, unknown>;
|
|
8
|
-
execute: (...args: TArgs) => Promise<
|
|
12
|
+
execute: (...args: TArgs) => Promise<TransactionSignature>;
|
|
9
13
|
};
|
|
10
14
|
|
|
11
15
|
export { useTransaction };
|
|
16
|
+
export type { UseTransactionOptions };
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { TransactionSignature } from '@solana/web3-compat';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface UseTransactionOptions {
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
timeoutMessage?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function useTransaction<TArgs extends unknown[]>(handler: (...args: TArgs) => Promise<TransactionSignature>, options?: UseTransactionOptions): {
|
|
5
9
|
signature: any;
|
|
6
10
|
loading: vue.Ref<boolean, boolean>;
|
|
7
11
|
error: vue.Ref<unknown, unknown>;
|
|
8
|
-
execute: (...args: TArgs) => Promise<
|
|
12
|
+
execute: (...args: TArgs) => Promise<TransactionSignature>;
|
|
9
13
|
};
|
|
10
14
|
|
|
11
15
|
export { useTransaction };
|
|
16
|
+
export type { UseTransactionOptions };
|
package/dist/useTransaction.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import * as vue from 'vue';
|
|
2
2
|
import { TransactionSignature } from '@solana/web3-compat';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface UseTransactionOptions {
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
timeoutMessage?: string;
|
|
7
|
+
}
|
|
8
|
+
declare function useTransaction<TArgs extends unknown[]>(handler: (...args: TArgs) => Promise<TransactionSignature>, options?: UseTransactionOptions): {
|
|
5
9
|
signature: any;
|
|
6
10
|
loading: vue.Ref<boolean, boolean>;
|
|
7
11
|
error: vue.Ref<unknown, unknown>;
|
|
8
|
-
execute: (...args: TArgs) => Promise<
|
|
12
|
+
execute: (...args: TArgs) => Promise<TransactionSignature>;
|
|
9
13
|
};
|
|
10
14
|
|
|
11
15
|
export { useTransaction };
|
|
16
|
+
export type { UseTransactionOptions };
|
package/dist/useTransaction.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { u as useTransaction } from './shared/vue.
|
|
1
|
+
export { u as useTransaction } from './shared/vue.CuhLIeDx.mjs';
|
|
2
2
|
import 'vue';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-solana/vue",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Vue plugin and composables for Solana applications.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"access": "public"
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@vue-solana/core": "0.3.
|
|
81
|
+
"@vue-solana/core": "0.3.2"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
84
|
"@solana/web3-compat": "^0.0.21",
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ref } from 'vue';
|
|
2
|
-
|
|
3
|
-
function useTransaction(handler) {
|
|
4
|
-
const signature = ref(null);
|
|
5
|
-
const loading = ref(false);
|
|
6
|
-
const error = ref(null);
|
|
7
|
-
async function execute(...args) {
|
|
8
|
-
loading.value = true;
|
|
9
|
-
error.value = null;
|
|
10
|
-
try {
|
|
11
|
-
signature.value = await handler(...args);
|
|
12
|
-
return signature.value;
|
|
13
|
-
} catch (cause) {
|
|
14
|
-
error.value = cause;
|
|
15
|
-
throw cause;
|
|
16
|
-
} finally {
|
|
17
|
-
loading.value = false;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
signature,
|
|
22
|
-
loading,
|
|
23
|
-
error,
|
|
24
|
-
execute
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export { useTransaction as u };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const vue = require('vue');
|
|
4
|
-
|
|
5
|
-
function useTransaction(handler) {
|
|
6
|
-
const signature = vue.ref(null);
|
|
7
|
-
const loading = vue.ref(false);
|
|
8
|
-
const error = vue.ref(null);
|
|
9
|
-
async function execute(...args) {
|
|
10
|
-
loading.value = true;
|
|
11
|
-
error.value = null;
|
|
12
|
-
try {
|
|
13
|
-
signature.value = await handler(...args);
|
|
14
|
-
return signature.value;
|
|
15
|
-
} catch (cause) {
|
|
16
|
-
error.value = cause;
|
|
17
|
-
throw cause;
|
|
18
|
-
} finally {
|
|
19
|
-
loading.value = false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
signature,
|
|
24
|
-
loading,
|
|
25
|
-
error,
|
|
26
|
-
execute
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
exports.useTransaction = useTransaction;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const transaction = require('@vue-solana/core/transaction');
|
|
4
|
-
const useConnection = require('./vue.CwhEmATP.cjs');
|
|
5
|
-
const useWallet = require('./vue.CwPjPFN6.cjs');
|
|
6
|
-
const useTransaction = require('./vue.BSVxQ9Yi.cjs');
|
|
7
|
-
|
|
8
|
-
function useSignAndSendTransaction() {
|
|
9
|
-
const connection = useConnection.useConnection();
|
|
10
|
-
const { wallet } = useWallet.useWallet();
|
|
11
|
-
return useTransaction.useTransaction((transaction$1, options) => {
|
|
12
|
-
if (!wallet.value) {
|
|
13
|
-
return Promise.reject(new Error("No Solana wallet is configured"));
|
|
14
|
-
}
|
|
15
|
-
return transaction.signAndSendTransaction(connection, wallet.value, transaction$1, options);
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
exports.useSignAndSendTransaction = useSignAndSendTransaction;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { signAndSendTransaction } from '@vue-solana/core/transaction';
|
|
2
|
-
import { u as useConnection } from './vue.DlEAL2G8.mjs';
|
|
3
|
-
import { u as useWallet } from './vue.DYf_CRDv.mjs';
|
|
4
|
-
import { u as useTransaction } from './vue.BMUEDN2t.mjs';
|
|
5
|
-
|
|
6
|
-
function useSignAndSendTransaction() {
|
|
7
|
-
const connection = useConnection();
|
|
8
|
-
const { wallet } = useWallet();
|
|
9
|
-
return useTransaction((transaction, options) => {
|
|
10
|
-
if (!wallet.value) {
|
|
11
|
-
return Promise.reject(new Error("No Solana wallet is configured"));
|
|
12
|
-
}
|
|
13
|
-
return signAndSendTransaction(connection, wallet.value, transaction, options);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { useSignAndSendTransaction as u };
|