@vue-solana/vue 0.4.0 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const useBalance = require('./shared/vue.DONKZzIb.cjs');
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.DJqRk8z_.mjs';
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 { ref, onMounted, watch, toValue } from 'vue';
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 = ref(null);
10
- const loading = ref(false);
11
- const error = ref(null);
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
- balance.value = await connection.getBalance(publicKey, commitment);
23
- return balance.value;
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
- error.value = cause;
32
+ if (requestId === refreshId) {
33
+ error.value = cause;
34
+ }
26
35
  throw cause;
27
36
  } finally {
28
- loading.value = false;
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.ref(null);
12
- const loading = vue.ref(false);
13
- const error = vue.ref(null);
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
- balance.value = await connection.getBalance(publicKey, commitment);
25
- return balance.value;
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
- error.value = cause;
34
+ if (requestId === refreshId) {
35
+ error.value = cause;
36
+ }
28
37
  throw cause;
29
38
  } finally {
30
- loading.value = false;
39
+ if (requestId === refreshId) {
40
+ loading.value = false;
41
+ }
31
42
  }
32
43
  }
33
44
  vue.onMounted(() => {
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const useBalance = require('./shared/vue.DONKZzIb.cjs');
3
+ const useBalance = require('./shared/vue.D_AM1Nl8.cjs');
4
4
  require('@solana/web3-compat');
5
5
  require('vue');
6
6
  require('./shared/vue.CwhEmATP.cjs');
@@ -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.Ref<number | null, number | null>;
7
- loading: vue.Ref<boolean, boolean>;
8
- error: vue.Ref<unknown, unknown>;
9
- refresh: () => Promise<number | null>;
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 };
@@ -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.Ref<number | null, number | null>;
7
- loading: vue.Ref<boolean, boolean>;
8
- error: vue.Ref<unknown, unknown>;
9
- refresh: () => Promise<number | null>;
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 };
@@ -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.Ref<number | null, number | null>;
7
- loading: vue.Ref<boolean, boolean>;
8
- error: vue.Ref<unknown, unknown>;
9
- refresh: () => Promise<number | null>;
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 };
@@ -1,4 +1,4 @@
1
- export { u as useBalance } from './shared/vue.DJqRk8z_.mjs';
1
+ export { u as useBalance } from './shared/vue.DQhHHVu6.mjs';
2
2
  import '@solana/web3-compat';
3
3
  import 'vue';
4
4
  import './shared/vue.DlEAL2G8.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-solana/vue",
3
- "version": "0.4.0",
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.0"
81
+ "@vue-solana/core": "0.4.2"
82
82
  },
83
83
  "peerDependencies": {
84
84
  "@solana/web3-compat": "^0.0.21",