@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.cjs
CHANGED
|
@@ -2973,27 +2973,53 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
2973
2973
|
const entry = (0, import_vue47.shallowRef)(null);
|
|
2974
2974
|
const isLoading = (0, import_vue47.shallowRef)(false);
|
|
2975
2975
|
const isWatching = (0, import_vue47.shallowRef)(false);
|
|
2976
|
-
const
|
|
2976
|
+
const guard = useActionGuard();
|
|
2977
|
+
const error = guard.error;
|
|
2977
2978
|
let generation = 0;
|
|
2979
|
+
let refreshed = [];
|
|
2980
|
+
const currentInputs = () => [
|
|
2981
|
+
(0, import_vue47.toValue)(monitor),
|
|
2982
|
+
(0, import_vue47.toValue)(hash),
|
|
2983
|
+
(0, import_vue47.toValue)(chainId)
|
|
2984
|
+
];
|
|
2985
|
+
const sameInputs = (a, b) => a.every((value, i) => Object.is(value, b[i]));
|
|
2978
2986
|
const refresh = async () => {
|
|
2979
2987
|
const activeMonitor = (0, import_vue47.toValue)(monitor);
|
|
2980
2988
|
const activeHash = (0, import_vue47.toValue)(hash);
|
|
2981
2989
|
const activeChainId = (0, import_vue47.toValue)(chainId);
|
|
2982
2990
|
if (!activeMonitor || !activeHash) return;
|
|
2991
|
+
const started = [activeMonitor, activeHash, activeChainId];
|
|
2992
|
+
refreshed = started;
|
|
2983
2993
|
isLoading.value = true;
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2994
|
+
await guard.run(
|
|
2995
|
+
async (commit) => {
|
|
2996
|
+
try {
|
|
2997
|
+
await activeMonitor.refreshTx(
|
|
2998
|
+
activeHash,
|
|
2999
|
+
activeChainId ?? void 0
|
|
3000
|
+
);
|
|
3001
|
+
} catch (err) {
|
|
3002
|
+
if (!sameInputs(started, currentInputs())) return;
|
|
3003
|
+
throw err;
|
|
3004
|
+
}
|
|
3005
|
+
if (!sameInputs(started, currentInputs())) return;
|
|
3006
|
+
const current = activeMonitor.getTxStatus(
|
|
3007
|
+
activeHash,
|
|
3008
|
+
activeChainId ?? void 0
|
|
3009
|
+
);
|
|
3010
|
+
commit(() => {
|
|
3011
|
+
entry.value = current ?? null;
|
|
3012
|
+
});
|
|
3013
|
+
},
|
|
3014
|
+
"Failed to refresh transaction",
|
|
3015
|
+
void 0,
|
|
3016
|
+
{
|
|
3017
|
+
onSettled: () => {
|
|
3018
|
+
isLoading.value = false;
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
).catch(() => {
|
|
3022
|
+
});
|
|
2997
3023
|
};
|
|
2998
3024
|
const stopWatching = () => {
|
|
2999
3025
|
const activeMonitor = (0, import_vue47.toValue)(monitor);
|
|
@@ -3007,6 +3033,9 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
3007
3033
|
[() => (0, import_vue47.toValue)(monitor), () => (0, import_vue47.toValue)(hash), () => (0, import_vue47.toValue)(chainId)],
|
|
3008
3034
|
([activeMonitor, activeHash, activeChainId], _previous, onCleanup) => {
|
|
3009
3035
|
const mine = ++generation;
|
|
3036
|
+
if (!sameInputs([activeMonitor, activeHash, activeChainId], refreshed)) {
|
|
3037
|
+
guard.invalidate();
|
|
3038
|
+
}
|
|
3010
3039
|
if (!activeMonitor || !activeHash || !activeChainId) {
|
|
3011
3040
|
entry.value = null;
|
|
3012
3041
|
isLoading.value = false;
|
|
@@ -3028,8 +3057,7 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
3028
3057
|
isWatching.value = true;
|
|
3029
3058
|
isLoading.value = true;
|
|
3030
3059
|
error.value = null;
|
|
3031
|
-
|
|
3032
|
-
if (current) entry.value = current;
|
|
3060
|
+
entry.value = activeMonitor.getTxStatus(activeHash, activeChainId) ?? null;
|
|
3033
3061
|
activeMonitor.watchTx(activeHash, activeChainId, {}).then((initial) => {
|
|
3034
3062
|
if (cancelled || mine !== generation) return;
|
|
3035
3063
|
entry.value = initial;
|