@vue-solana/vue 2.1.0 → 2.3.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/README.md +177 -0
- package/dist/index.cjs +9 -4
- package/dist/index.d.cts +5 -3
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.mjs +6 -4
- package/dist/shared/{vue.DImwKTwJ.mjs → vue.B8VvC8d2.mjs} +18 -20
- package/dist/shared/{vue.B8ub540p.mjs → vue.BDNOyiGZ.mjs} +7 -7
- package/dist/shared/vue.BFbIDI66.cjs +121 -0
- package/dist/shared/vue.BSfiHqwj.mjs +34 -0
- package/dist/shared/{vue.B4-LEdSE.cjs → vue.BfGt94sg.cjs} +20 -2
- package/dist/shared/{vue.C5FVoEZT.mjs → vue.C4hGlFC8.mjs} +21 -3
- package/dist/shared/vue.CTqPbvz3.cjs +36 -0
- package/dist/shared/{vue.CogzzQXM.mjs → vue.CbJFnho-.mjs} +4 -4
- package/dist/shared/vue.DT4vCUa6.mjs +118 -0
- package/dist/shared/{vue.DtCbCcPd.cjs → vue.DxM45azl.cjs} +4 -4
- package/dist/shared/{vue.B8pLQ8P4.cjs → vue.ZuUCEEab.cjs} +18 -20
- package/dist/shared/{vue.BVj9lWBK.cjs → vue.l3UCdN7z.cjs} +7 -7
- package/dist/swr.cjs +3 -3
- package/dist/swr.mjs +3 -3
- package/dist/useAirdrop.cjs +14 -0
- package/dist/useAirdrop.d.cts +25 -0
- package/dist/useAirdrop.d.mts +25 -0
- package/dist/useAirdrop.d.ts +25 -0
- package/dist/useAirdrop.mjs +8 -0
- package/dist/useConnection.d.cts +3 -2
- package/dist/useConnection.d.mts +3 -2
- package/dist/useConnection.d.ts +3 -2
- package/dist/usePlanTransaction.cjs +1 -1
- package/dist/usePlanTransaction.d.cts +4 -0
- package/dist/usePlanTransaction.d.mts +4 -0
- package/dist/usePlanTransaction.d.ts +4 -0
- package/dist/usePlanTransaction.mjs +1 -1
- package/dist/usePlanTransactions.cjs +1 -1
- package/dist/usePlanTransactions.mjs +1 -1
- package/dist/useRequest.cjs +1 -1
- package/dist/useRequest.d.cts +22 -6
- package/dist/useRequest.d.mts +22 -6
- package/dist/useRequest.d.ts +22 -6
- package/dist/useRequest.mjs +1 -1
- package/dist/useRpc.d.cts +3 -2
- package/dist/useRpc.d.mts +3 -2
- package/dist/useRpc.d.ts +3 -2
- package/dist/useSendTransaction.cjs +14 -0
- package/dist/useSendTransaction.d.cts +46 -0
- package/dist/useSendTransaction.d.mts +46 -0
- package/dist/useSendTransaction.d.ts +46 -0
- package/dist/useSendTransaction.mjs +7 -0
- package/dist/useSendTransactions.cjs +13 -0
- package/dist/useSendTransactions.d.cts +4 -0
- package/dist/useSendTransactions.d.mts +4 -0
- package/dist/useSendTransactions.d.ts +4 -0
- package/dist/useSendTransactions.mjs +7 -0
- package/dist/useSolanaClient.d.cts +3 -2
- package/dist/useSolanaClient.d.mts +3 -2
- package/dist/useSolanaClient.d.ts +3 -2
- package/dist/useSubscription.cjs +1 -1
- package/dist/useSubscription.d.cts +15 -3
- package/dist/useSubscription.d.mts +15 -3
- package/dist/useSubscription.d.ts +15 -3
- package/dist/useSubscription.mjs +1 -1
- package/dist/useTrackedData.cjs +1 -1
- package/dist/useTrackedData.d.cts +15 -3
- package/dist/useTrackedData.d.mts +15 -3
- package/dist/useTrackedData.d.ts +15 -3
- package/dist/useTrackedData.mjs +1 -1
- package/package.json +17 -2
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const errors = require('@vue-solana/core/errors');
|
|
4
|
+
const vue = require('vue');
|
|
5
|
+
const useClientCapability = require('./vue.BY0qpgYr.cjs');
|
|
6
|
+
const useSolanaClient = require('./vue.BIxphCAq.cjs');
|
|
7
|
+
|
|
8
|
+
const SENDING_PROVIDER_HINT = "Install a transaction planner and a transaction-sending executor plugin, e.g. `createClient().use(rpcTransactionPlanner()).use(rpcTransactionPlanSendingExecutor())` from `@solana/kit-plugin-rpc`.";
|
|
9
|
+
function useSendTransaction() {
|
|
10
|
+
useClientCapability.useClientCapability(["sendTransaction"], {
|
|
11
|
+
hookName: "useSendTransaction",
|
|
12
|
+
providerHint: SENDING_PROVIDER_HINT
|
|
13
|
+
});
|
|
14
|
+
const { client } = useSolanaClient.useSolanaClient();
|
|
15
|
+
const data = vue.shallowRef(null);
|
|
16
|
+
const status = vue.ref("idle");
|
|
17
|
+
const loading = vue.ref(false);
|
|
18
|
+
const error = vue.ref(null);
|
|
19
|
+
let executionId = 0;
|
|
20
|
+
let abortController;
|
|
21
|
+
vue.onScopeDispose(() => {
|
|
22
|
+
abortController?.abort();
|
|
23
|
+
executionId++;
|
|
24
|
+
});
|
|
25
|
+
async function execute(input, config) {
|
|
26
|
+
abortController?.abort();
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
abortController = controller;
|
|
29
|
+
const currentExecutionId = ++executionId;
|
|
30
|
+
const sender = client;
|
|
31
|
+
status.value = "sending";
|
|
32
|
+
loading.value = true;
|
|
33
|
+
error.value = null;
|
|
34
|
+
data.value = null;
|
|
35
|
+
try {
|
|
36
|
+
const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
|
|
37
|
+
const result = await sender.sendTransaction(input, { abortSignal });
|
|
38
|
+
if (currentExecutionId === executionId) {
|
|
39
|
+
data.value = result;
|
|
40
|
+
status.value = "sent";
|
|
41
|
+
}
|
|
42
|
+
return result;
|
|
43
|
+
} catch (cause) {
|
|
44
|
+
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
45
|
+
if (currentExecutionId === executionId) {
|
|
46
|
+
error.value = normalizedError;
|
|
47
|
+
status.value = "error";
|
|
48
|
+
}
|
|
49
|
+
throw normalizedError;
|
|
50
|
+
} finally {
|
|
51
|
+
if (currentExecutionId === executionId) {
|
|
52
|
+
loading.value = false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
data,
|
|
58
|
+
status,
|
|
59
|
+
loading,
|
|
60
|
+
error,
|
|
61
|
+
execute
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function useSendTransactions() {
|
|
65
|
+
useClientCapability.useClientCapability(["sendTransactions"], {
|
|
66
|
+
hookName: "useSendTransactions",
|
|
67
|
+
providerHint: SENDING_PROVIDER_HINT
|
|
68
|
+
});
|
|
69
|
+
const { client } = useSolanaClient.useSolanaClient();
|
|
70
|
+
const data = vue.shallowRef(null);
|
|
71
|
+
const status = vue.ref("idle");
|
|
72
|
+
const loading = vue.ref(false);
|
|
73
|
+
const error = vue.ref(null);
|
|
74
|
+
let executionId = 0;
|
|
75
|
+
let abortController;
|
|
76
|
+
vue.onScopeDispose(() => {
|
|
77
|
+
abortController?.abort();
|
|
78
|
+
executionId++;
|
|
79
|
+
});
|
|
80
|
+
async function execute(input, config) {
|
|
81
|
+
abortController?.abort();
|
|
82
|
+
const controller = new AbortController();
|
|
83
|
+
abortController = controller;
|
|
84
|
+
const currentExecutionId = ++executionId;
|
|
85
|
+
const sender = client;
|
|
86
|
+
status.value = "sending";
|
|
87
|
+
loading.value = true;
|
|
88
|
+
error.value = null;
|
|
89
|
+
data.value = null;
|
|
90
|
+
try {
|
|
91
|
+
const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
|
|
92
|
+
const result = await sender.sendTransactions(input, { abortSignal });
|
|
93
|
+
if (currentExecutionId === executionId) {
|
|
94
|
+
data.value = result;
|
|
95
|
+
status.value = "sent";
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
} catch (cause) {
|
|
99
|
+
const normalizedError = errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
100
|
+
if (currentExecutionId === executionId) {
|
|
101
|
+
error.value = normalizedError;
|
|
102
|
+
status.value = "error";
|
|
103
|
+
}
|
|
104
|
+
throw normalizedError;
|
|
105
|
+
} finally {
|
|
106
|
+
if (currentExecutionId === executionId) {
|
|
107
|
+
loading.value = false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
data,
|
|
113
|
+
status,
|
|
114
|
+
loading,
|
|
115
|
+
error,
|
|
116
|
+
execute
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
exports.useSendTransaction = useSendTransaction;
|
|
121
|
+
exports.useSendTransactions = useSendTransactions;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { u as useAction } from './vue.DYk0Xfr3.mjs';
|
|
2
|
+
import { u as useClientCapability } from './vue.B8LptjZP.mjs';
|
|
3
|
+
import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
|
|
4
|
+
|
|
5
|
+
function toReadableAirdropError(error) {
|
|
6
|
+
if (error instanceof Error) {
|
|
7
|
+
const httpStatus = error.context?.statusCode;
|
|
8
|
+
const isThrottled = httpStatus === 429 || error.message.startsWith("JSON-RPC error: Internal JSON-RPC error (Internal error)");
|
|
9
|
+
if (!isThrottled) {
|
|
10
|
+
throw error;
|
|
11
|
+
}
|
|
12
|
+
throw new Error(
|
|
13
|
+
`${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.`,
|
|
14
|
+
{ cause: error }
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
throw new Error(`Airdrop failed: ${String(error)}`);
|
|
18
|
+
}
|
|
19
|
+
function useAirdrop() {
|
|
20
|
+
useClientCapability("airdrop", {
|
|
21
|
+
hookName: "useAirdrop",
|
|
22
|
+
providerHint: "Install it by adding the airdrop capability with `createClient().use(solanaRpcConnection({ ... })).use(rpcAirdrop())` from `@solana/kit-plugin-rpc`."
|
|
23
|
+
});
|
|
24
|
+
const { client } = useSolanaClient();
|
|
25
|
+
return useAction((abortSignal, address, amount) => {
|
|
26
|
+
const airdrop = client.airdrop;
|
|
27
|
+
if (!airdrop) {
|
|
28
|
+
throw new Error("useAirdrop requires the `airdrop` capability on the Solana client.");
|
|
29
|
+
}
|
|
30
|
+
return airdrop(address, amount, abortSignal).catch(toReadableAirdropError);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { useAirdrop as u };
|
|
@@ -16,7 +16,15 @@ function usePlanTransaction() {
|
|
|
16
16
|
const loading = vue.ref(false);
|
|
17
17
|
const error = vue.ref(null);
|
|
18
18
|
let executionId = 0;
|
|
19
|
+
let abortController;
|
|
20
|
+
vue.onScopeDispose(() => {
|
|
21
|
+
abortController?.abort();
|
|
22
|
+
executionId++;
|
|
23
|
+
});
|
|
19
24
|
async function execute(input, config) {
|
|
25
|
+
abortController?.abort();
|
|
26
|
+
const controller = new AbortController();
|
|
27
|
+
abortController = controller;
|
|
20
28
|
const currentExecutionId = ++executionId;
|
|
21
29
|
const planner = client;
|
|
22
30
|
status.value = "planning";
|
|
@@ -24,7 +32,8 @@ function usePlanTransaction() {
|
|
|
24
32
|
error.value = null;
|
|
25
33
|
transactionMessage.value = null;
|
|
26
34
|
try {
|
|
27
|
-
const
|
|
35
|
+
const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
|
|
36
|
+
const message = await planner.planTransaction(input, { abortSignal });
|
|
28
37
|
if (currentExecutionId === executionId) {
|
|
29
38
|
transactionMessage.value = message;
|
|
30
39
|
status.value = "planned";
|
|
@@ -62,7 +71,15 @@ function usePlanTransactions() {
|
|
|
62
71
|
const loading = vue.ref(false);
|
|
63
72
|
const error = vue.ref(null);
|
|
64
73
|
let executionId = 0;
|
|
74
|
+
let abortController;
|
|
75
|
+
vue.onScopeDispose(() => {
|
|
76
|
+
abortController?.abort();
|
|
77
|
+
executionId++;
|
|
78
|
+
});
|
|
65
79
|
async function execute(input, config) {
|
|
80
|
+
abortController?.abort();
|
|
81
|
+
const controller = new AbortController();
|
|
82
|
+
abortController = controller;
|
|
66
83
|
const currentExecutionId = ++executionId;
|
|
67
84
|
const planner = client;
|
|
68
85
|
status.value = "planning";
|
|
@@ -70,7 +87,8 @@ function usePlanTransactions() {
|
|
|
70
87
|
error.value = null;
|
|
71
88
|
transactionPlan.value = null;
|
|
72
89
|
try {
|
|
73
|
-
const
|
|
90
|
+
const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
|
|
91
|
+
const plan = await planner.planTransactions(input, { abortSignal });
|
|
74
92
|
if (currentExecutionId === executionId) {
|
|
75
93
|
transactionPlan.value = plan;
|
|
76
94
|
status.value = "planned";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
-
import { shallowRef, ref } from 'vue';
|
|
2
|
+
import { shallowRef, ref, onScopeDispose } from 'vue';
|
|
3
3
|
import { u as useClientCapability } from './vue.B8LptjZP.mjs';
|
|
4
4
|
import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
|
|
5
5
|
|
|
@@ -14,7 +14,15 @@ function usePlanTransaction() {
|
|
|
14
14
|
const loading = ref(false);
|
|
15
15
|
const error = ref(null);
|
|
16
16
|
let executionId = 0;
|
|
17
|
+
let abortController;
|
|
18
|
+
onScopeDispose(() => {
|
|
19
|
+
abortController?.abort();
|
|
20
|
+
executionId++;
|
|
21
|
+
});
|
|
17
22
|
async function execute(input, config) {
|
|
23
|
+
abortController?.abort();
|
|
24
|
+
const controller = new AbortController();
|
|
25
|
+
abortController = controller;
|
|
18
26
|
const currentExecutionId = ++executionId;
|
|
19
27
|
const planner = client;
|
|
20
28
|
status.value = "planning";
|
|
@@ -22,7 +30,8 @@ function usePlanTransaction() {
|
|
|
22
30
|
error.value = null;
|
|
23
31
|
transactionMessage.value = null;
|
|
24
32
|
try {
|
|
25
|
-
const
|
|
33
|
+
const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
|
|
34
|
+
const message = await planner.planTransaction(input, { abortSignal });
|
|
26
35
|
if (currentExecutionId === executionId) {
|
|
27
36
|
transactionMessage.value = message;
|
|
28
37
|
status.value = "planned";
|
|
@@ -60,7 +69,15 @@ function usePlanTransactions() {
|
|
|
60
69
|
const loading = ref(false);
|
|
61
70
|
const error = ref(null);
|
|
62
71
|
let executionId = 0;
|
|
72
|
+
let abortController;
|
|
73
|
+
onScopeDispose(() => {
|
|
74
|
+
abortController?.abort();
|
|
75
|
+
executionId++;
|
|
76
|
+
});
|
|
63
77
|
async function execute(input, config) {
|
|
78
|
+
abortController?.abort();
|
|
79
|
+
const controller = new AbortController();
|
|
80
|
+
abortController = controller;
|
|
64
81
|
const currentExecutionId = ++executionId;
|
|
65
82
|
const planner = client;
|
|
66
83
|
status.value = "planning";
|
|
@@ -68,7 +85,8 @@ function usePlanTransactions() {
|
|
|
68
85
|
error.value = null;
|
|
69
86
|
transactionPlan.value = null;
|
|
70
87
|
try {
|
|
71
|
-
const
|
|
88
|
+
const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
|
|
89
|
+
const plan = await planner.planTransactions(input, { abortSignal });
|
|
72
90
|
if (currentExecutionId === executionId) {
|
|
73
91
|
transactionPlan.value = plan;
|
|
74
92
|
status.value = "planned";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const useAction = require('./vue.CoaIWGPT.cjs');
|
|
4
|
+
const useClientCapability = require('./vue.BY0qpgYr.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(solanaRpcConnection({ ... })).use(rpcAirdrop())` from `@solana/kit-plugin-rpc`."
|
|
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;
|
|
@@ -28,7 +28,7 @@ function useTrackedData(source, options = {}) {
|
|
|
28
28
|
error.value = null;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
function buildAndConnect() {
|
|
31
|
+
function buildAndConnect(override) {
|
|
32
32
|
if (disposed) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
@@ -104,7 +104,7 @@ function useTrackedData(source, options = {}) {
|
|
|
104
104
|
}
|
|
105
105
|
connectionCount += 1;
|
|
106
106
|
const connection = connectionCount;
|
|
107
|
-
const callerSignal = options.getAbortSignal?.(connection);
|
|
107
|
+
const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(connection);
|
|
108
108
|
const store = createReactiveStoreWithInitialValueAndSlotTracking({
|
|
109
109
|
initialValueMapper: source.rpcValueMapper,
|
|
110
110
|
initialValueSource: rpcRequest,
|
|
@@ -158,8 +158,8 @@ function useTrackedData(source, options = {}) {
|
|
|
158
158
|
return {
|
|
159
159
|
data: computed(() => data.value),
|
|
160
160
|
error: computed(() => error.value),
|
|
161
|
-
refresh: () => {
|
|
162
|
-
buildAndConnect();
|
|
161
|
+
refresh: (options2) => {
|
|
162
|
+
buildAndConnect(options2);
|
|
163
163
|
},
|
|
164
164
|
status: computed(() => status.value)
|
|
165
165
|
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { normalizeSolanaError } from '@vue-solana/core/errors';
|
|
2
|
+
import { shallowRef, ref, onScopeDispose } from 'vue';
|
|
3
|
+
import { u as useClientCapability } from './vue.B8LptjZP.mjs';
|
|
4
|
+
import { u as useSolanaClient } from './vue.Mxc8w6Qk.mjs';
|
|
5
|
+
|
|
6
|
+
const SENDING_PROVIDER_HINT = "Install a transaction planner and a transaction-sending executor plugin, e.g. `createClient().use(rpcTransactionPlanner()).use(rpcTransactionPlanSendingExecutor())` from `@solana/kit-plugin-rpc`.";
|
|
7
|
+
function useSendTransaction() {
|
|
8
|
+
useClientCapability(["sendTransaction"], {
|
|
9
|
+
hookName: "useSendTransaction",
|
|
10
|
+
providerHint: SENDING_PROVIDER_HINT
|
|
11
|
+
});
|
|
12
|
+
const { client } = useSolanaClient();
|
|
13
|
+
const data = shallowRef(null);
|
|
14
|
+
const status = ref("idle");
|
|
15
|
+
const loading = ref(false);
|
|
16
|
+
const error = ref(null);
|
|
17
|
+
let executionId = 0;
|
|
18
|
+
let abortController;
|
|
19
|
+
onScopeDispose(() => {
|
|
20
|
+
abortController?.abort();
|
|
21
|
+
executionId++;
|
|
22
|
+
});
|
|
23
|
+
async function execute(input, config) {
|
|
24
|
+
abortController?.abort();
|
|
25
|
+
const controller = new AbortController();
|
|
26
|
+
abortController = controller;
|
|
27
|
+
const currentExecutionId = ++executionId;
|
|
28
|
+
const sender = client;
|
|
29
|
+
status.value = "sending";
|
|
30
|
+
loading.value = true;
|
|
31
|
+
error.value = null;
|
|
32
|
+
data.value = null;
|
|
33
|
+
try {
|
|
34
|
+
const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
|
|
35
|
+
const result = await sender.sendTransaction(input, { abortSignal });
|
|
36
|
+
if (currentExecutionId === executionId) {
|
|
37
|
+
data.value = result;
|
|
38
|
+
status.value = "sent";
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
} catch (cause) {
|
|
42
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
43
|
+
if (currentExecutionId === executionId) {
|
|
44
|
+
error.value = normalizedError;
|
|
45
|
+
status.value = "error";
|
|
46
|
+
}
|
|
47
|
+
throw normalizedError;
|
|
48
|
+
} finally {
|
|
49
|
+
if (currentExecutionId === executionId) {
|
|
50
|
+
loading.value = false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
data,
|
|
56
|
+
status,
|
|
57
|
+
loading,
|
|
58
|
+
error,
|
|
59
|
+
execute
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function useSendTransactions() {
|
|
63
|
+
useClientCapability(["sendTransactions"], {
|
|
64
|
+
hookName: "useSendTransactions",
|
|
65
|
+
providerHint: SENDING_PROVIDER_HINT
|
|
66
|
+
});
|
|
67
|
+
const { client } = useSolanaClient();
|
|
68
|
+
const data = shallowRef(null);
|
|
69
|
+
const status = ref("idle");
|
|
70
|
+
const loading = ref(false);
|
|
71
|
+
const error = ref(null);
|
|
72
|
+
let executionId = 0;
|
|
73
|
+
let abortController;
|
|
74
|
+
onScopeDispose(() => {
|
|
75
|
+
abortController?.abort();
|
|
76
|
+
executionId++;
|
|
77
|
+
});
|
|
78
|
+
async function execute(input, config) {
|
|
79
|
+
abortController?.abort();
|
|
80
|
+
const controller = new AbortController();
|
|
81
|
+
abortController = controller;
|
|
82
|
+
const currentExecutionId = ++executionId;
|
|
83
|
+
const sender = client;
|
|
84
|
+
status.value = "sending";
|
|
85
|
+
loading.value = true;
|
|
86
|
+
error.value = null;
|
|
87
|
+
data.value = null;
|
|
88
|
+
try {
|
|
89
|
+
const abortSignal = config?.abortSignal ? AbortSignal.any([controller.signal, config.abortSignal]) : controller.signal;
|
|
90
|
+
const result = await sender.sendTransactions(input, { abortSignal });
|
|
91
|
+
if (currentExecutionId === executionId) {
|
|
92
|
+
data.value = result;
|
|
93
|
+
status.value = "sent";
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
} catch (cause) {
|
|
97
|
+
const normalizedError = normalizeSolanaError(cause, "RPC_FAILURE");
|
|
98
|
+
if (currentExecutionId === executionId) {
|
|
99
|
+
error.value = normalizedError;
|
|
100
|
+
status.value = "error";
|
|
101
|
+
}
|
|
102
|
+
throw normalizedError;
|
|
103
|
+
} finally {
|
|
104
|
+
if (currentExecutionId === executionId) {
|
|
105
|
+
loading.value = false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
data,
|
|
111
|
+
status,
|
|
112
|
+
loading,
|
|
113
|
+
error,
|
|
114
|
+
execute
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { useSendTransactions as a, useSendTransaction as u };
|
|
@@ -30,7 +30,7 @@ function useTrackedData(source, options = {}) {
|
|
|
30
30
|
error.value = null;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
function buildAndConnect() {
|
|
33
|
+
function buildAndConnect(override) {
|
|
34
34
|
if (disposed) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
@@ -106,7 +106,7 @@ function useTrackedData(source, options = {}) {
|
|
|
106
106
|
}
|
|
107
107
|
connectionCount += 1;
|
|
108
108
|
const connection = connectionCount;
|
|
109
|
-
const callerSignal = options.getAbortSignal?.(connection);
|
|
109
|
+
const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(connection);
|
|
110
110
|
const store = kit.createReactiveStoreWithInitialValueAndSlotTracking({
|
|
111
111
|
initialValueMapper: source.rpcValueMapper,
|
|
112
112
|
initialValueSource: rpcRequest,
|
|
@@ -160,8 +160,8 @@ function useTrackedData(source, options = {}) {
|
|
|
160
160
|
return {
|
|
161
161
|
data: vue.computed(() => data.value),
|
|
162
162
|
error: vue.computed(() => error.value),
|
|
163
|
-
refresh: () => {
|
|
164
|
-
buildAndConnect();
|
|
163
|
+
refresh: (options2) => {
|
|
164
|
+
buildAndConnect(options2);
|
|
165
165
|
},
|
|
166
166
|
status: vue.computed(() => status.value)
|
|
167
167
|
};
|
|
@@ -11,24 +11,22 @@ function useRequest(source, options = {}) {
|
|
|
11
11
|
const status = vue.shallowRef("fetching");
|
|
12
12
|
let disposed = false;
|
|
13
13
|
let attempt = 0;
|
|
14
|
-
const store = action.createSolanaActionStore(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
throw new Error("useRequest source did not resolve to a request function");
|
|
28
|
-
}
|
|
29
|
-
return kit.getAbortablePromise(pending, composedSignal);
|
|
14
|
+
const store = action.createSolanaActionStore(async (signal, resolved, override) => {
|
|
15
|
+
attempt += 1;
|
|
16
|
+
const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(attempt);
|
|
17
|
+
const composedSignal = callerSignal ? AbortSignal.any([signal, callerSignal]) : signal;
|
|
18
|
+
let pending;
|
|
19
|
+
if (isSendSource(resolved)) {
|
|
20
|
+
pending = Promise.resolve(resolved.send({ abortSignal: composedSignal }));
|
|
21
|
+
} else if (typeof resolved === "function") {
|
|
22
|
+
pending = Promise.resolve(resolved(composedSignal)).then(
|
|
23
|
+
(result) => isSendSource(result) ? result.send({ abortSignal: composedSignal }) : result
|
|
24
|
+
);
|
|
25
|
+
} else {
|
|
26
|
+
throw new Error("useRequest source did not resolve to a request function");
|
|
30
27
|
}
|
|
31
|
-
|
|
28
|
+
return kit.getAbortablePromise(pending, composedSignal);
|
|
29
|
+
});
|
|
32
30
|
const unsubscribe = store.subscribe(() => {
|
|
33
31
|
const next = store.getState();
|
|
34
32
|
if (next.status === "success") {
|
|
@@ -53,7 +51,7 @@ function useRequest(source, options = {}) {
|
|
|
53
51
|
}
|
|
54
52
|
return source;
|
|
55
53
|
}
|
|
56
|
-
async function run() {
|
|
54
|
+
async function run(override) {
|
|
57
55
|
if (disposed) {
|
|
58
56
|
return void 0;
|
|
59
57
|
}
|
|
@@ -67,7 +65,7 @@ function useRequest(source, options = {}) {
|
|
|
67
65
|
}
|
|
68
66
|
status.value = "fetching";
|
|
69
67
|
try {
|
|
70
|
-
return await store.dispatchAsync(resolved);
|
|
68
|
+
return await store.dispatchAsync(resolved, override);
|
|
71
69
|
} catch (cause) {
|
|
72
70
|
if (store.getState().status !== "error") {
|
|
73
71
|
return void 0;
|
|
@@ -75,7 +73,7 @@ function useRequest(source, options = {}) {
|
|
|
75
73
|
throw errors.normalizeSolanaError(cause, "RPC_FAILURE");
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
|
-
const refresh = () => run();
|
|
76
|
+
const refresh = (options2) => run(options2);
|
|
79
77
|
vue.watch(
|
|
80
78
|
() => vue.isRef(source) ? source.value : source,
|
|
81
79
|
() => {
|
|
@@ -29,11 +29,11 @@ function useSubscription(source, options = {}) {
|
|
|
29
29
|
status.value = "loading";
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
function openConnection(store) {
|
|
32
|
+
function openConnection(store, override) {
|
|
33
33
|
activeStore = store;
|
|
34
34
|
connectionCount += 1;
|
|
35
35
|
const connection = connectionCount;
|
|
36
|
-
const callerSignal = options.getAbortSignal?.(connection);
|
|
36
|
+
const callerSignal = override ? override.abortSignal : options.getAbortSignal?.(connection);
|
|
37
37
|
applyState(store.getState());
|
|
38
38
|
disposables.push(
|
|
39
39
|
store.subscribe(() => {
|
|
@@ -61,7 +61,7 @@ function useSubscription(source, options = {}) {
|
|
|
61
61
|
}
|
|
62
62
|
activeSource = void 0;
|
|
63
63
|
}
|
|
64
|
-
function connectCurrent() {
|
|
64
|
+
function connectCurrent(override) {
|
|
65
65
|
if (disposed) {
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
@@ -74,12 +74,12 @@ function useSubscription(source, options = {}) {
|
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
76
|
if (activeSource === resolved && activeStore) {
|
|
77
|
-
openConnection(activeStore);
|
|
77
|
+
openConnection(activeStore, override);
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
disconnect();
|
|
81
81
|
activeSource = resolved;
|
|
82
|
-
openConnection(resolved.reactiveStore());
|
|
82
|
+
openConnection(resolved.reactiveStore(), override);
|
|
83
83
|
}
|
|
84
84
|
vue.watch(
|
|
85
85
|
() => vue.isRef(source) ? source.value : source,
|
|
@@ -101,8 +101,8 @@ function useSubscription(source, options = {}) {
|
|
|
101
101
|
return {
|
|
102
102
|
data: vue.computed(() => data.value),
|
|
103
103
|
error: vue.computed(() => error.value),
|
|
104
|
-
reconnect: () => {
|
|
105
|
-
connectCurrent();
|
|
104
|
+
reconnect: (options2) => {
|
|
105
|
+
connectCurrent(options2);
|
|
106
106
|
},
|
|
107
107
|
status: vue.computed(() => status.value)
|
|
108
108
|
};
|
package/dist/swr.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const vue = require('vue');
|
|
4
|
-
const useRequest = require('./shared/vue.
|
|
5
|
-
const useSubscription = require('./shared/vue.
|
|
6
|
-
const useTrackedData = require('./shared/vue.
|
|
4
|
+
const useRequest = require('./shared/vue.ZuUCEEab.cjs');
|
|
5
|
+
const useSubscription = require('./shared/vue.l3UCdN7z.cjs');
|
|
6
|
+
const useTrackedData = require('./shared/vue.DxM45azl.cjs');
|
|
7
7
|
require('@vue-solana/core/action');
|
|
8
8
|
require('@vue-solana/core/kit');
|
|
9
9
|
require('@vue-solana/core/errors');
|
package/dist/swr.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { watch, computed } from 'vue';
|
|
2
|
-
import { u as useRequest } from './shared/vue.
|
|
3
|
-
import { u as useSubscription } from './shared/vue.
|
|
4
|
-
import { u as useTrackedData } from './shared/vue.
|
|
2
|
+
import { u as useRequest } from './shared/vue.B8VvC8d2.mjs';
|
|
3
|
+
import { u as useSubscription } from './shared/vue.BDNOyiGZ.mjs';
|
|
4
|
+
import { u as useTrackedData } from './shared/vue.CbJFnho-.mjs';
|
|
5
5
|
import '@vue-solana/core/action';
|
|
6
6
|
import '@vue-solana/core/kit';
|
|
7
7
|
import '@vue-solana/core/errors';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const useAirdrop = require('./shared/vue.CTqPbvz3.cjs');
|
|
4
|
+
require('./shared/vue.CoaIWGPT.cjs');
|
|
5
|
+
require('@vue-solana/core/action');
|
|
6
|
+
require('vue');
|
|
7
|
+
require('./shared/vue.BY0qpgYr.cjs');
|
|
8
|
+
require('./shared/vue.BIxphCAq.cjs');
|
|
9
|
+
require('./shared/vue.DE3emjSF.cjs');
|
|
10
|
+
require('./shared/vue.DEHxNvUX.cjs');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
exports.useAirdrop = useAirdrop.useAirdrop;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Address, Lamports, Signature } from '@vue-solana/core/kit';
|
|
2
|
+
import { UseActionReturn } from './useAction.cjs';
|
|
3
|
+
import 'vue';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Airdrops SOL into an account. Each `dispatch(address, amount)` runs the
|
|
7
|
+
* airdrop with a fresh `AbortSignal`; calling `dispatch` again while a call is
|
|
8
|
+
* in flight aborts the previous one.
|
|
9
|
+
*
|
|
10
|
+
* Requires the client to expose an `airdrop` capability, typically installed
|
|
11
|
+
* with the RPC airdrop plugin, e.g.
|
|
12
|
+
* `createClient().use(solanaRpcConnection({ ... })).use(rpcAirdrop())` from
|
|
13
|
+
* `@solana/kit-plugin-rpc`. The capability is commonly available on test
|
|
14
|
+
* networks (devnet, testnet) and local validators.
|
|
15
|
+
*
|
|
16
|
+
* Some implementations (e.g. LiteSVM) update balances directly without sending
|
|
17
|
+
* a transaction, in which case the resolved `data` is `undefined` rather than
|
|
18
|
+
* a {@link Signature}.
|
|
19
|
+
*/
|
|
20
|
+
declare function useAirdrop(): UseActionReturn<[
|
|
21
|
+
address: Address,
|
|
22
|
+
amount: Lamports
|
|
23
|
+
], Signature | undefined>;
|
|
24
|
+
|
|
25
|
+
export { useAirdrop };
|