@naculus/connect-appkit-vue 0.5.0 → 0.6.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/dist/index.cjs +44 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +44 -16
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.cts
CHANGED
|
@@ -1148,7 +1148,7 @@ interface TxMonitorLike {
|
|
|
1148
1148
|
on(event: "statusChange", listener: (entry: TxStatusEntry) => void): this;
|
|
1149
1149
|
on(event: "confirmed", listener: (entry: TxStatusEntry) => void): this;
|
|
1150
1150
|
on(event: "failed", listener: (entry: TxStatusEntry) => void): this;
|
|
1151
|
-
off(event: string, listener:
|
|
1151
|
+
off(event: string, listener: (entry: TxStatusEntry) => void): this;
|
|
1152
1152
|
}
|
|
1153
1153
|
interface UseTxMonitorReturn {
|
|
1154
1154
|
entry: ShallowRef<TxStatusEntry | null>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1148,7 +1148,7 @@ interface TxMonitorLike {
|
|
|
1148
1148
|
on(event: "statusChange", listener: (entry: TxStatusEntry) => void): this;
|
|
1149
1149
|
on(event: "confirmed", listener: (entry: TxStatusEntry) => void): this;
|
|
1150
1150
|
on(event: "failed", listener: (entry: TxStatusEntry) => void): this;
|
|
1151
|
-
off(event: string, listener:
|
|
1151
|
+
off(event: string, listener: (entry: TxStatusEntry) => void): this;
|
|
1152
1152
|
}
|
|
1153
1153
|
interface UseTxMonitorReturn {
|
|
1154
1154
|
entry: ShallowRef<TxStatusEntry | null>;
|
package/dist/index.js
CHANGED
|
@@ -2962,27 +2962,53 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
2962
2962
|
const entry = shallowRef33(null);
|
|
2963
2963
|
const isLoading = shallowRef33(false);
|
|
2964
2964
|
const isWatching = shallowRef33(false);
|
|
2965
|
-
const
|
|
2965
|
+
const guard = useActionGuard();
|
|
2966
|
+
const error = guard.error;
|
|
2966
2967
|
let generation = 0;
|
|
2968
|
+
let refreshed = [];
|
|
2969
|
+
const currentInputs = () => [
|
|
2970
|
+
toValue36(monitor),
|
|
2971
|
+
toValue36(hash),
|
|
2972
|
+
toValue36(chainId)
|
|
2973
|
+
];
|
|
2974
|
+
const sameInputs = (a, b) => a.every((value, i) => Object.is(value, b[i]));
|
|
2967
2975
|
const refresh = async () => {
|
|
2968
2976
|
const activeMonitor = toValue36(monitor);
|
|
2969
2977
|
const activeHash = toValue36(hash);
|
|
2970
2978
|
const activeChainId = toValue36(chainId);
|
|
2971
2979
|
if (!activeMonitor || !activeHash) return;
|
|
2980
|
+
const started = [activeMonitor, activeHash, activeChainId];
|
|
2981
|
+
refreshed = started;
|
|
2972
2982
|
isLoading.value = true;
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2983
|
+
await guard.run(
|
|
2984
|
+
async (commit) => {
|
|
2985
|
+
try {
|
|
2986
|
+
await activeMonitor.refreshTx(
|
|
2987
|
+
activeHash,
|
|
2988
|
+
activeChainId ?? void 0
|
|
2989
|
+
);
|
|
2990
|
+
} catch (err) {
|
|
2991
|
+
if (!sameInputs(started, currentInputs())) return;
|
|
2992
|
+
throw err;
|
|
2993
|
+
}
|
|
2994
|
+
if (!sameInputs(started, currentInputs())) return;
|
|
2995
|
+
const current = activeMonitor.getTxStatus(
|
|
2996
|
+
activeHash,
|
|
2997
|
+
activeChainId ?? void 0
|
|
2998
|
+
);
|
|
2999
|
+
commit(() => {
|
|
3000
|
+
entry.value = current ?? null;
|
|
3001
|
+
});
|
|
3002
|
+
},
|
|
3003
|
+
"Failed to refresh transaction",
|
|
3004
|
+
void 0,
|
|
3005
|
+
{
|
|
3006
|
+
onSettled: () => {
|
|
3007
|
+
isLoading.value = false;
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
).catch(() => {
|
|
3011
|
+
});
|
|
2986
3012
|
};
|
|
2987
3013
|
const stopWatching = () => {
|
|
2988
3014
|
const activeMonitor = toValue36(monitor);
|
|
@@ -2996,6 +3022,9 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
2996
3022
|
[() => toValue36(monitor), () => toValue36(hash), () => toValue36(chainId)],
|
|
2997
3023
|
([activeMonitor, activeHash, activeChainId], _previous, onCleanup) => {
|
|
2998
3024
|
const mine = ++generation;
|
|
3025
|
+
if (!sameInputs([activeMonitor, activeHash, activeChainId], refreshed)) {
|
|
3026
|
+
guard.invalidate();
|
|
3027
|
+
}
|
|
2999
3028
|
if (!activeMonitor || !activeHash || !activeChainId) {
|
|
3000
3029
|
entry.value = null;
|
|
3001
3030
|
isLoading.value = false;
|
|
@@ -3017,8 +3046,7 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
3017
3046
|
isWatching.value = true;
|
|
3018
3047
|
isLoading.value = true;
|
|
3019
3048
|
error.value = null;
|
|
3020
|
-
|
|
3021
|
-
if (current) entry.value = current;
|
|
3049
|
+
entry.value = activeMonitor.getTxStatus(activeHash, activeChainId) ?? null;
|
|
3022
3050
|
activeMonitor.watchTx(activeHash, activeChainId, {}).then((initial) => {
|
|
3023
3051
|
if (cancelled || mine !== generation) return;
|
|
3024
3052
|
entry.value = initial;
|