@vue-solana/vue 0.4.1 → 0.4.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/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/{vue.DJqRk8z_.mjs → vue.DQhHHVu6.mjs} +19 -8
- package/dist/shared/{vue.DONKZzIb.cjs → vue.D_AM1Nl8.cjs} +18 -7
- package/dist/useBalance.cjs +1 -1
- package/dist/useBalance.d.cts +4 -4
- package/dist/useBalance.d.mts +4 -4
- package/dist/useBalance.d.ts +4 -4
- package/dist/useBalance.mjs +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const useBalance = require('./shared/vue.
|
|
3
|
+
const useBalance = require('./shared/vue.D_AM1Nl8.cjs');
|
|
4
4
|
const useConnection = require('./shared/vue.CwhEmATP.cjs');
|
|
5
5
|
const useRpc = require('./shared/vue.COyyrsQU.cjs');
|
|
6
6
|
const useSignAndSendTransaction = require('./shared/vue.BwrQMPty.cjs');
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { u as useBalance } from './shared/vue.
|
|
1
|
+
export { u as useBalance } from './shared/vue.DQhHHVu6.mjs';
|
|
2
2
|
export { u as useConnection } from './shared/vue.DlEAL2G8.mjs';
|
|
3
3
|
export { u as useRpc } from './shared/vue.BqDzSepb.mjs';
|
|
4
4
|
export { u as useSignAndSendTransaction } from './shared/vue.BfF-kOvb.mjs';
|
|
@@ -1,31 +1,42 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3-compat';
|
|
2
|
-
import {
|
|
2
|
+
import { shallowRef, onMounted, watch, toValue } from 'vue';
|
|
3
3
|
import { u as useConnection } from './vue.DlEAL2G8.mjs';
|
|
4
4
|
import { t as tryUseSolana } from './vue.1M_c5FWA.mjs';
|
|
5
5
|
|
|
6
6
|
function useBalance(address, commitment) {
|
|
7
7
|
const solana = tryUseSolana();
|
|
8
8
|
const connection = solana?.connection ?? useConnection();
|
|
9
|
-
const balance =
|
|
10
|
-
const loading =
|
|
11
|
-
const error =
|
|
9
|
+
const balance = shallowRef(null);
|
|
10
|
+
const loading = shallowRef(false);
|
|
11
|
+
const error = shallowRef(null);
|
|
12
|
+
let refreshId = 0;
|
|
12
13
|
async function refresh() {
|
|
14
|
+
const requestId = ++refreshId;
|
|
13
15
|
const value = toValue(address);
|
|
14
16
|
if (!value || !solana) {
|
|
15
17
|
balance.value = null;
|
|
18
|
+
loading.value = false;
|
|
19
|
+
error.value = null;
|
|
16
20
|
return null;
|
|
17
21
|
}
|
|
18
22
|
loading.value = true;
|
|
19
23
|
error.value = null;
|
|
20
24
|
try {
|
|
21
25
|
const publicKey = typeof value === "string" ? new PublicKey(value) : value;
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
const nextBalance = await connection.getBalance(publicKey, commitment);
|
|
27
|
+
if (requestId === refreshId) {
|
|
28
|
+
balance.value = nextBalance;
|
|
29
|
+
}
|
|
30
|
+
return nextBalance;
|
|
24
31
|
} catch (cause) {
|
|
25
|
-
|
|
32
|
+
if (requestId === refreshId) {
|
|
33
|
+
error.value = cause;
|
|
34
|
+
}
|
|
26
35
|
throw cause;
|
|
27
36
|
} finally {
|
|
28
|
-
|
|
37
|
+
if (requestId === refreshId) {
|
|
38
|
+
loading.value = false;
|
|
39
|
+
}
|
|
29
40
|
}
|
|
30
41
|
}
|
|
31
42
|
onMounted(() => {
|
|
@@ -8,26 +8,37 @@ const useSolana = require('./vue.C4tLiG3R.cjs');
|
|
|
8
8
|
function useBalance(address, commitment) {
|
|
9
9
|
const solana = useSolana.tryUseSolana();
|
|
10
10
|
const connection = solana?.connection ?? useConnection.useConnection();
|
|
11
|
-
const balance = vue.
|
|
12
|
-
const loading = vue.
|
|
13
|
-
const error = vue.
|
|
11
|
+
const balance = vue.shallowRef(null);
|
|
12
|
+
const loading = vue.shallowRef(false);
|
|
13
|
+
const error = vue.shallowRef(null);
|
|
14
|
+
let refreshId = 0;
|
|
14
15
|
async function refresh() {
|
|
16
|
+
const requestId = ++refreshId;
|
|
15
17
|
const value = vue.toValue(address);
|
|
16
18
|
if (!value || !solana) {
|
|
17
19
|
balance.value = null;
|
|
20
|
+
loading.value = false;
|
|
21
|
+
error.value = null;
|
|
18
22
|
return null;
|
|
19
23
|
}
|
|
20
24
|
loading.value = true;
|
|
21
25
|
error.value = null;
|
|
22
26
|
try {
|
|
23
27
|
const publicKey = typeof value === "string" ? new web3Compat.PublicKey(value) : value;
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
const nextBalance = await connection.getBalance(publicKey, commitment);
|
|
29
|
+
if (requestId === refreshId) {
|
|
30
|
+
balance.value = nextBalance;
|
|
31
|
+
}
|
|
32
|
+
return nextBalance;
|
|
26
33
|
} catch (cause) {
|
|
27
|
-
|
|
34
|
+
if (requestId === refreshId) {
|
|
35
|
+
error.value = cause;
|
|
36
|
+
}
|
|
28
37
|
throw cause;
|
|
29
38
|
} finally {
|
|
30
|
-
|
|
39
|
+
if (requestId === refreshId) {
|
|
40
|
+
loading.value = false;
|
|
41
|
+
}
|
|
31
42
|
}
|
|
32
43
|
}
|
|
33
44
|
vue.onMounted(() => {
|
package/dist/useBalance.cjs
CHANGED
package/dist/useBalance.d.cts
CHANGED
|
@@ -3,10 +3,10 @@ import { MaybeRefOrGetter } from 'vue';
|
|
|
3
3
|
import { PublicKey, Commitment } from '@solana/web3-compat';
|
|
4
4
|
|
|
5
5
|
declare function useBalance(address: MaybeRefOrGetter<PublicKey | string | null | undefined>, commitment?: Commitment): {
|
|
6
|
-
balance: vue.
|
|
7
|
-
loading: vue.
|
|
8
|
-
error: vue.
|
|
9
|
-
refresh: () => Promise<
|
|
6
|
+
balance: vue.ShallowRef<number | null, number | null>;
|
|
7
|
+
loading: vue.ShallowRef<boolean, boolean>;
|
|
8
|
+
error: vue.ShallowRef<unknown, unknown>;
|
|
9
|
+
refresh: () => Promise<any>;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export { useBalance };
|
package/dist/useBalance.d.mts
CHANGED
|
@@ -3,10 +3,10 @@ import { MaybeRefOrGetter } from 'vue';
|
|
|
3
3
|
import { PublicKey, Commitment } from '@solana/web3-compat';
|
|
4
4
|
|
|
5
5
|
declare function useBalance(address: MaybeRefOrGetter<PublicKey | string | null | undefined>, commitment?: Commitment): {
|
|
6
|
-
balance: vue.
|
|
7
|
-
loading: vue.
|
|
8
|
-
error: vue.
|
|
9
|
-
refresh: () => Promise<
|
|
6
|
+
balance: vue.ShallowRef<number | null, number | null>;
|
|
7
|
+
loading: vue.ShallowRef<boolean, boolean>;
|
|
8
|
+
error: vue.ShallowRef<unknown, unknown>;
|
|
9
|
+
refresh: () => Promise<any>;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export { useBalance };
|
package/dist/useBalance.d.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { MaybeRefOrGetter } from 'vue';
|
|
|
3
3
|
import { PublicKey, Commitment } from '@solana/web3-compat';
|
|
4
4
|
|
|
5
5
|
declare function useBalance(address: MaybeRefOrGetter<PublicKey | string | null | undefined>, commitment?: Commitment): {
|
|
6
|
-
balance: vue.
|
|
7
|
-
loading: vue.
|
|
8
|
-
error: vue.
|
|
9
|
-
refresh: () => Promise<
|
|
6
|
+
balance: vue.ShallowRef<number | null, number | null>;
|
|
7
|
+
loading: vue.ShallowRef<boolean, boolean>;
|
|
8
|
+
error: vue.ShallowRef<unknown, unknown>;
|
|
9
|
+
refresh: () => Promise<any>;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export { useBalance };
|
package/dist/useBalance.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-solana/vue",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.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.4.
|
|
81
|
+
"@vue-solana/core": "0.4.2"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
84
|
"@solana/web3-compat": "^0.0.21",
|