@naculus/connect-appkit-vue 0.2.6 → 0.2.8
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 +379 -452
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +58 -4
- package/dist/index.d.ts +58 -4
- package/dist/index.js +408 -477
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -817,10 +817,14 @@ function useSession(manager) {
|
|
|
817
817
|
current.on("sessionConnected", update);
|
|
818
818
|
current.on("sessionDisconnected", update);
|
|
819
819
|
current.on("chainChanged", update);
|
|
820
|
+
current.on("sessionScopeChanged", update);
|
|
821
|
+
current.on("sessionRevoked", update);
|
|
820
822
|
onCleanup(() => {
|
|
821
823
|
current.off("sessionConnected", update);
|
|
822
824
|
current.off("sessionDisconnected", update);
|
|
823
825
|
current.off("chainChanged", update);
|
|
826
|
+
current.off("sessionScopeChanged", update);
|
|
827
|
+
current.off("sessionRevoked", update);
|
|
824
828
|
});
|
|
825
829
|
},
|
|
826
830
|
{ immediate: true }
|
|
@@ -836,261 +840,223 @@ function useSession(manager) {
|
|
|
836
840
|
|
|
837
841
|
// src/useConnect.ts
|
|
838
842
|
import { WalletError as WalletError4 } from "@naculus/connect-core";
|
|
839
|
-
import { computed as computed7,
|
|
840
|
-
|
|
841
|
-
|
|
843
|
+
import { computed as computed7, toValue as toValue8, unref as unref6 } from "vue";
|
|
844
|
+
|
|
845
|
+
// src/internal/action-guard.ts
|
|
846
|
+
import { onScopeDispose as onScopeDispose6, shallowRef as shallowRef7 } from "vue";
|
|
847
|
+
function useActionGuard() {
|
|
848
|
+
const busy = shallowRef7(false);
|
|
842
849
|
const error = shallowRef7(null);
|
|
850
|
+
let active = 0;
|
|
851
|
+
let generation = 0;
|
|
843
852
|
let disposed = false;
|
|
853
|
+
const run = async (action, fallbackMessage, normalizeError) => {
|
|
854
|
+
const own = ++generation;
|
|
855
|
+
const commit = (write) => {
|
|
856
|
+
if (!disposed && own === generation) write();
|
|
857
|
+
};
|
|
858
|
+
active++;
|
|
859
|
+
busy.value = true;
|
|
860
|
+
error.value = null;
|
|
861
|
+
try {
|
|
862
|
+
return await action(commit);
|
|
863
|
+
} catch (cause) {
|
|
864
|
+
const normalized = normalizeError ? normalizeError(cause) : cause instanceof Error ? cause : new Error(fallbackMessage);
|
|
865
|
+
if (!disposed && own === generation) error.value = normalized;
|
|
866
|
+
throw normalized;
|
|
867
|
+
} finally {
|
|
868
|
+
active--;
|
|
869
|
+
if (!disposed) busy.value = active > 0;
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
const reset = () => {
|
|
873
|
+
generation++;
|
|
874
|
+
error.value = null;
|
|
875
|
+
};
|
|
876
|
+
const clearError = () => {
|
|
877
|
+
error.value = null;
|
|
878
|
+
};
|
|
879
|
+
const dispose = () => {
|
|
880
|
+
disposed = true;
|
|
881
|
+
generation++;
|
|
882
|
+
};
|
|
883
|
+
onScopeDispose6(dispose);
|
|
884
|
+
return { busy, error, run, clearError, reset, dispose };
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
// src/useConnect.ts
|
|
888
|
+
function useConnect(action, status) {
|
|
889
|
+
const guard = useActionGuard();
|
|
844
890
|
let inFlight = null;
|
|
845
891
|
const connect = () => {
|
|
846
892
|
if (inFlight) return inFlight;
|
|
847
893
|
const invoke = unref6(action);
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
894
|
+
const pending = guard.run(
|
|
895
|
+
() => Promise.resolve().then(() => invoke()),
|
|
896
|
+
"Connection failed",
|
|
897
|
+
(cause) => {
|
|
898
|
+
const message = cause instanceof Error ? cause.message : "Connection failed";
|
|
899
|
+
return cause instanceof WalletError4 ? cause : new Error(message);
|
|
900
|
+
}
|
|
901
|
+
).catch(() => {
|
|
854
902
|
}).finally(() => {
|
|
855
903
|
if (inFlight === pending) inFlight = null;
|
|
856
|
-
if (!disposed) isLoading.value = false;
|
|
857
904
|
});
|
|
858
905
|
inFlight = pending;
|
|
859
906
|
return pending;
|
|
860
907
|
};
|
|
861
|
-
onScopeDispose6(() => {
|
|
862
|
-
disposed = true;
|
|
863
|
-
});
|
|
864
908
|
return {
|
|
865
909
|
connect,
|
|
866
910
|
isConnecting: computed7(
|
|
867
|
-
() =>
|
|
911
|
+
() => guard.busy.value || toValue8(status) === "connecting"
|
|
868
912
|
),
|
|
869
|
-
error
|
|
913
|
+
error: guard.error
|
|
870
914
|
};
|
|
871
915
|
}
|
|
872
916
|
|
|
873
917
|
// src/useDisconnect.ts
|
|
874
|
-
import {
|
|
918
|
+
import { toValue as toValue9, unref as unref7 } from "vue";
|
|
875
919
|
function useDisconnect(action, status) {
|
|
876
|
-
const
|
|
877
|
-
const error = shallowRef8(null);
|
|
878
|
-
let disposed = false;
|
|
920
|
+
const guard = useActionGuard();
|
|
879
921
|
let inFlight = null;
|
|
880
922
|
const disconnect = () => {
|
|
881
923
|
if (inFlight) return inFlight;
|
|
882
924
|
if (toValue9(status) === "disconnected") return Promise.resolve();
|
|
883
925
|
const invoke = unref7(action);
|
|
884
|
-
|
|
885
|
-
error.value = null;
|
|
886
|
-
const pending = Promise.resolve().then(() => invoke()).catch((cause) => {
|
|
887
|
-
if (!disposed) {
|
|
888
|
-
error.value = cause instanceof Error ? cause : new Error("Disconnect failed");
|
|
889
|
-
}
|
|
926
|
+
const pending = guard.run(() => Promise.resolve().then(() => invoke()), "Disconnect failed").catch(() => {
|
|
890
927
|
}).finally(() => {
|
|
891
928
|
if (inFlight === pending) inFlight = null;
|
|
892
|
-
if (!disposed) isDisconnecting.value = false;
|
|
893
929
|
});
|
|
894
930
|
inFlight = pending;
|
|
895
931
|
return pending;
|
|
896
932
|
};
|
|
897
933
|
const cleanup = () => {
|
|
898
|
-
|
|
934
|
+
guard.dispose();
|
|
935
|
+
};
|
|
936
|
+
return {
|
|
937
|
+
disconnect,
|
|
938
|
+
isDisconnecting: guard.busy,
|
|
939
|
+
error: guard.error,
|
|
940
|
+
cleanup
|
|
899
941
|
};
|
|
900
|
-
onScopeDispose7(cleanup);
|
|
901
|
-
return { disconnect, isDisconnecting, error, cleanup };
|
|
902
942
|
}
|
|
903
943
|
|
|
904
944
|
// src/useSwitchChain.ts
|
|
905
945
|
import { toChainSwitchError } from "@naculus/connect-appkit-core";
|
|
906
|
-
import { computed as computed8,
|
|
946
|
+
import { computed as computed8, toValue as toValue10, unref as unref8 } from "vue";
|
|
907
947
|
function useSwitchChain(action, chainId) {
|
|
908
|
-
const
|
|
909
|
-
const
|
|
910
|
-
let generation = 0;
|
|
911
|
-
let active = 0;
|
|
912
|
-
let disposed = false;
|
|
913
|
-
const switchChain = async (targetChainId) => {
|
|
948
|
+
const guard = useActionGuard();
|
|
949
|
+
const switchChain = (targetChainId) => {
|
|
914
950
|
const invoke = unref8(action);
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
}
|
|
922
|
-
const walletError = toChainSwitchError(cause);
|
|
923
|
-
if (!disposed && mine === generation) error.value = walletError;
|
|
924
|
-
throw walletError;
|
|
925
|
-
} finally {
|
|
926
|
-
active--;
|
|
927
|
-
if (!disposed) isSwitching.value = active > 0;
|
|
928
|
-
}
|
|
951
|
+
return guard.run(async () => {
|
|
952
|
+
try {
|
|
953
|
+
await invoke(targetChainId);
|
|
954
|
+
} catch (cause) {
|
|
955
|
+
throw toChainSwitchError(cause);
|
|
956
|
+
}
|
|
957
|
+
}, "Failed to switch chain");
|
|
929
958
|
};
|
|
930
|
-
onScopeDispose8(() => {
|
|
931
|
-
disposed = true;
|
|
932
|
-
generation++;
|
|
933
|
-
});
|
|
934
959
|
return {
|
|
935
960
|
switchChain,
|
|
936
|
-
isSwitching,
|
|
961
|
+
isSwitching: guard.busy,
|
|
937
962
|
currentChainId: computed8(() => toValue10(chainId) ?? null),
|
|
938
|
-
error,
|
|
939
|
-
clearError:
|
|
940
|
-
error.value = null;
|
|
941
|
-
}
|
|
963
|
+
error: guard.error,
|
|
964
|
+
clearError: guard.clearError
|
|
942
965
|
};
|
|
943
966
|
}
|
|
944
967
|
|
|
945
968
|
// src/useSignMessage.ts
|
|
946
|
-
import {
|
|
969
|
+
import { unref as unref9 } from "vue";
|
|
947
970
|
function useSignMessage(action) {
|
|
948
|
-
const
|
|
949
|
-
const
|
|
950
|
-
let active = 0;
|
|
951
|
-
let generation = 0;
|
|
952
|
-
let disposed = false;
|
|
953
|
-
const signMessage = async (message) => {
|
|
971
|
+
const guard = useActionGuard();
|
|
972
|
+
const signMessage = (message) => {
|
|
954
973
|
const invoke = unref9(action);
|
|
955
|
-
|
|
956
|
-
active++;
|
|
957
|
-
isSigning.value = true;
|
|
958
|
-
error.value = null;
|
|
959
|
-
try {
|
|
960
|
-
return await invoke(message);
|
|
961
|
-
} catch (cause) {
|
|
962
|
-
const normalized = cause instanceof Error ? cause : new Error("Signing failed");
|
|
963
|
-
if (!disposed && own === generation) error.value = normalized;
|
|
964
|
-
throw normalized;
|
|
965
|
-
} finally {
|
|
966
|
-
active--;
|
|
967
|
-
if (!disposed) isSigning.value = active > 0;
|
|
968
|
-
}
|
|
974
|
+
return guard.run(() => invoke(message), "Signing failed");
|
|
969
975
|
};
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
976
|
+
return {
|
|
977
|
+
signMessage,
|
|
978
|
+
isSigning: guard.busy,
|
|
979
|
+
error: guard.error,
|
|
980
|
+
reset: guard.reset
|
|
973
981
|
};
|
|
974
|
-
onScopeDispose9(() => {
|
|
975
|
-
disposed = true;
|
|
976
|
-
generation++;
|
|
977
|
-
});
|
|
978
|
-
return { signMessage, isSigning, error, reset };
|
|
979
982
|
}
|
|
980
983
|
|
|
981
984
|
// src/useSendTransaction.ts
|
|
982
|
-
import { computed as computed9,
|
|
985
|
+
import { computed as computed9, shallowRef as shallowRef8, unref as unref10 } from "vue";
|
|
983
986
|
function useSendTransaction(action) {
|
|
984
|
-
const
|
|
985
|
-
const
|
|
986
|
-
|
|
987
|
-
let disposed = false;
|
|
988
|
-
const sendTransaction = async (transaction) => {
|
|
987
|
+
const guard = useActionGuard();
|
|
988
|
+
const status = shallowRef8("idle");
|
|
989
|
+
const sendTransaction = (transaction) => {
|
|
989
990
|
const invoke = unref10(action);
|
|
990
|
-
const own = ++generation;
|
|
991
991
|
status.value = "awaiting_approval";
|
|
992
|
-
|
|
993
|
-
try {
|
|
992
|
+
return guard.run(async (commit) => {
|
|
994
993
|
const hash = await invoke(transaction);
|
|
995
|
-
|
|
994
|
+
commit(() => {
|
|
995
|
+
status.value = "submitted";
|
|
996
|
+
});
|
|
996
997
|
return hash;
|
|
997
|
-
} catch
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
error.value = normalized;
|
|
1002
|
-
}
|
|
1003
|
-
throw normalized;
|
|
1004
|
-
}
|
|
998
|
+
}, "Transaction failed").catch((cause) => {
|
|
999
|
+
if (guard.error.value === cause) status.value = "failed";
|
|
1000
|
+
throw cause;
|
|
1001
|
+
});
|
|
1005
1002
|
};
|
|
1006
1003
|
const reset = () => {
|
|
1007
|
-
|
|
1004
|
+
guard.reset();
|
|
1008
1005
|
status.value = "idle";
|
|
1009
|
-
error.value = null;
|
|
1010
1006
|
};
|
|
1011
|
-
onScopeDispose10(() => {
|
|
1012
|
-
disposed = true;
|
|
1013
|
-
generation++;
|
|
1014
|
-
});
|
|
1015
1007
|
return {
|
|
1016
1008
|
sendTransaction,
|
|
1017
1009
|
status,
|
|
1018
|
-
error,
|
|
1010
|
+
error: guard.error,
|
|
1019
1011
|
reset,
|
|
1020
1012
|
isSending: computed9(() => status.value === "awaiting_approval")
|
|
1021
1013
|
};
|
|
1022
1014
|
}
|
|
1023
1015
|
|
|
1024
1016
|
// src/useSolanaTransaction.ts
|
|
1025
|
-
import {
|
|
1017
|
+
import { shallowRef as shallowRef9, unref as unref11 } from "vue";
|
|
1026
1018
|
function useSolanaTransaction(options) {
|
|
1027
|
-
const
|
|
1028
|
-
const
|
|
1029
|
-
const
|
|
1019
|
+
const guard = useActionGuard();
|
|
1020
|
+
const isSigning = shallowRef9(false);
|
|
1021
|
+
const isSending = shallowRef9(false);
|
|
1030
1022
|
let signing = 0;
|
|
1031
1023
|
let sending = 0;
|
|
1032
|
-
|
|
1033
|
-
let disposed = false;
|
|
1034
|
-
const signTransaction = async (transaction) => {
|
|
1024
|
+
const signTransaction = (transaction) => {
|
|
1035
1025
|
const invoke = unref11(options.signTransaction);
|
|
1036
|
-
const own = ++generation;
|
|
1037
1026
|
signing++;
|
|
1038
1027
|
isSigning.value = true;
|
|
1039
|
-
|
|
1040
|
-
try {
|
|
1041
|
-
return await invoke(transaction);
|
|
1042
|
-
} catch (cause) {
|
|
1043
|
-
const normalized = cause instanceof Error ? cause : new Error("Signing failed");
|
|
1044
|
-
if (!disposed && own === generation) error.value = normalized;
|
|
1045
|
-
throw normalized;
|
|
1046
|
-
} finally {
|
|
1028
|
+
return guard.run(() => invoke(transaction), "Signing failed").finally(() => {
|
|
1047
1029
|
signing--;
|
|
1048
|
-
|
|
1049
|
-
}
|
|
1030
|
+
isSigning.value = signing > 0;
|
|
1031
|
+
});
|
|
1050
1032
|
};
|
|
1051
|
-
const sendTransaction =
|
|
1033
|
+
const sendTransaction = (transaction) => {
|
|
1052
1034
|
const invoke = unref11(options.sendTransaction);
|
|
1053
|
-
const own = ++generation;
|
|
1054
1035
|
sending++;
|
|
1055
1036
|
isSending.value = true;
|
|
1056
|
-
|
|
1057
|
-
try {
|
|
1058
|
-
return await invoke(transaction);
|
|
1059
|
-
} catch (cause) {
|
|
1060
|
-
const normalized = cause instanceof Error ? cause : new Error("Send failed");
|
|
1061
|
-
if (!disposed && own === generation) error.value = normalized;
|
|
1062
|
-
throw normalized;
|
|
1063
|
-
} finally {
|
|
1037
|
+
return guard.run(() => invoke(transaction), "Send failed").finally(() => {
|
|
1064
1038
|
sending--;
|
|
1065
|
-
|
|
1066
|
-
}
|
|
1039
|
+
isSending.value = sending > 0;
|
|
1040
|
+
});
|
|
1067
1041
|
};
|
|
1068
1042
|
const getStatus = (signature) => unref11(options.getStatus)(signature);
|
|
1069
|
-
const reset = () => {
|
|
1070
|
-
generation++;
|
|
1071
|
-
error.value = null;
|
|
1072
|
-
};
|
|
1073
|
-
onScopeDispose11(() => {
|
|
1074
|
-
disposed = true;
|
|
1075
|
-
generation++;
|
|
1076
|
-
});
|
|
1077
1043
|
return {
|
|
1078
1044
|
signTransaction,
|
|
1079
1045
|
sendTransaction,
|
|
1080
1046
|
getStatus,
|
|
1081
1047
|
isSigning,
|
|
1082
1048
|
isSending,
|
|
1083
|
-
error,
|
|
1084
|
-
reset
|
|
1049
|
+
error: guard.error,
|
|
1050
|
+
reset: guard.reset
|
|
1085
1051
|
};
|
|
1086
1052
|
}
|
|
1087
1053
|
|
|
1088
1054
|
// src/useSignInWithX.ts
|
|
1089
|
-
import { onScopeDispose as
|
|
1055
|
+
import { onScopeDispose as onScopeDispose7, shallowRef as shallowRef10, unref as unref12 } from "vue";
|
|
1090
1056
|
function useSignInWithX(action) {
|
|
1091
|
-
const isSigningIn =
|
|
1092
|
-
const result =
|
|
1093
|
-
const error =
|
|
1057
|
+
const isSigningIn = shallowRef10(false);
|
|
1058
|
+
const result = shallowRef10(null);
|
|
1059
|
+
const error = shallowRef10(null);
|
|
1094
1060
|
let generation = 0;
|
|
1095
1061
|
let active = 0;
|
|
1096
1062
|
let disposed = false;
|
|
@@ -1121,7 +1087,7 @@ function useSignInWithX(action) {
|
|
|
1121
1087
|
result.value = null;
|
|
1122
1088
|
error.value = null;
|
|
1123
1089
|
};
|
|
1124
|
-
|
|
1090
|
+
onScopeDispose7(() => {
|
|
1125
1091
|
disposed = true;
|
|
1126
1092
|
generation++;
|
|
1127
1093
|
});
|
|
@@ -1134,45 +1100,23 @@ function useSignInWithEthereum(action) {
|
|
|
1134
1100
|
}
|
|
1135
1101
|
|
|
1136
1102
|
// src/useExecuteCalls.ts
|
|
1137
|
-
import { computed as computed10,
|
|
1103
|
+
import { computed as computed10, toValue as toValue11, unref as unref13 } from "vue";
|
|
1138
1104
|
function useExecuteCalls(options) {
|
|
1139
|
-
const
|
|
1140
|
-
const error = shallowRef14(null);
|
|
1141
|
-
let generation = 0;
|
|
1142
|
-
let active = 0;
|
|
1143
|
-
let disposed = false;
|
|
1105
|
+
const guard = useActionGuard();
|
|
1144
1106
|
const preview = (callCount, atomicity) => unref13(options.preview)(callCount, atomicity);
|
|
1145
|
-
const execute =
|
|
1107
|
+
const execute = (calls, atomicity) => {
|
|
1146
1108
|
const invoke = unref13(options.execute);
|
|
1147
|
-
|
|
1148
|
-
active++;
|
|
1149
|
-
isExecuting.value = true;
|
|
1150
|
-
error.value = null;
|
|
1151
|
-
try {
|
|
1152
|
-
return await invoke(calls, atomicity);
|
|
1153
|
-
} catch (cause) {
|
|
1154
|
-
const normalized = cause instanceof Error ? cause : new Error("Execution failed");
|
|
1155
|
-
if (!disposed && own === generation) error.value = normalized;
|
|
1156
|
-
throw normalized;
|
|
1157
|
-
} finally {
|
|
1158
|
-
active--;
|
|
1159
|
-
if (!disposed) isExecuting.value = active > 0;
|
|
1160
|
-
}
|
|
1109
|
+
return guard.run(() => invoke(calls, atomicity), "Execution failed");
|
|
1161
1110
|
};
|
|
1162
1111
|
const reset = () => {
|
|
1163
|
-
|
|
1164
|
-
error.value = null;
|
|
1112
|
+
guard.reset();
|
|
1165
1113
|
unref13(options.reset)();
|
|
1166
1114
|
};
|
|
1167
|
-
onScopeDispose13(() => {
|
|
1168
|
-
disposed = true;
|
|
1169
|
-
generation++;
|
|
1170
|
-
});
|
|
1171
1115
|
return {
|
|
1172
1116
|
preview,
|
|
1173
1117
|
execute,
|
|
1174
|
-
isExecuting,
|
|
1175
|
-
error,
|
|
1118
|
+
isExecuting: guard.busy,
|
|
1119
|
+
error: guard.error,
|
|
1176
1120
|
lastRoute: computed10(() => toValue11(options.lastRoute)),
|
|
1177
1121
|
reset
|
|
1178
1122
|
};
|
|
@@ -1187,59 +1131,24 @@ import {
|
|
|
1187
1131
|
} from "@naculus/connect-appkit-core";
|
|
1188
1132
|
import {
|
|
1189
1133
|
computed as computed12,
|
|
1190
|
-
onScopeDispose as
|
|
1191
|
-
shallowRef as
|
|
1134
|
+
onScopeDispose as onScopeDispose9,
|
|
1135
|
+
shallowRef as shallowRef12,
|
|
1192
1136
|
toValue as toValue13,
|
|
1193
1137
|
unref as unref14,
|
|
1194
1138
|
watch as watch6
|
|
1195
1139
|
} from "vue";
|
|
1196
1140
|
|
|
1197
|
-
// src/internal/action-guard.ts
|
|
1198
|
-
import { onScopeDispose as onScopeDispose14, shallowRef as shallowRef15 } from "vue";
|
|
1199
|
-
function useActionGuard() {
|
|
1200
|
-
const busy = shallowRef15(false);
|
|
1201
|
-
const error = shallowRef15(null);
|
|
1202
|
-
let active = 0;
|
|
1203
|
-
let generation = 0;
|
|
1204
|
-
let disposed = false;
|
|
1205
|
-
const run = async (action, fallbackMessage) => {
|
|
1206
|
-
const own = ++generation;
|
|
1207
|
-
active++;
|
|
1208
|
-
busy.value = true;
|
|
1209
|
-
error.value = null;
|
|
1210
|
-
try {
|
|
1211
|
-
return await action();
|
|
1212
|
-
} catch (cause) {
|
|
1213
|
-
const normalized = cause instanceof Error ? cause : new Error(fallbackMessage);
|
|
1214
|
-
if (!disposed && own === generation) error.value = normalized;
|
|
1215
|
-
throw normalized;
|
|
1216
|
-
} finally {
|
|
1217
|
-
active--;
|
|
1218
|
-
if (!disposed) busy.value = active > 0;
|
|
1219
|
-
}
|
|
1220
|
-
};
|
|
1221
|
-
const reset = () => {
|
|
1222
|
-
generation++;
|
|
1223
|
-
error.value = null;
|
|
1224
|
-
};
|
|
1225
|
-
onScopeDispose14(() => {
|
|
1226
|
-
disposed = true;
|
|
1227
|
-
generation++;
|
|
1228
|
-
});
|
|
1229
|
-
return { busy, error, run, reset };
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
1141
|
// src/useSessionKeys.ts
|
|
1233
1142
|
import { getSharedSessionKeyManager } from "@naculus/connect-appkit-core";
|
|
1234
|
-
import { computed as computed11, onScopeDispose as
|
|
1143
|
+
import { computed as computed11, onScopeDispose as onScopeDispose8, shallowRef as shallowRef11, toValue as toValue12, watch as watch5 } from "vue";
|
|
1235
1144
|
function resolveManager(config, options) {
|
|
1236
1145
|
return options.manager ?? getSharedSessionKeyManager(config);
|
|
1237
1146
|
}
|
|
1238
1147
|
function useSessionKeys(connected, config, options = {}) {
|
|
1239
1148
|
const manager = resolveManager(config, options);
|
|
1240
|
-
const sessions =
|
|
1241
|
-
const loading =
|
|
1242
|
-
const error =
|
|
1149
|
+
const sessions = shallowRef11([]);
|
|
1150
|
+
const loading = shallowRef11(false);
|
|
1151
|
+
const error = shallowRef11(null);
|
|
1243
1152
|
let generation = 0;
|
|
1244
1153
|
let disposed = false;
|
|
1245
1154
|
const refresh = async () => {
|
|
@@ -1268,7 +1177,7 @@ function useSessionKeys(connected, config, options = {}) {
|
|
|
1268
1177
|
},
|
|
1269
1178
|
{ immediate: true }
|
|
1270
1179
|
);
|
|
1271
|
-
|
|
1180
|
+
onScopeDispose8(() => {
|
|
1272
1181
|
disposed = true;
|
|
1273
1182
|
generation++;
|
|
1274
1183
|
});
|
|
@@ -1289,7 +1198,7 @@ function useSessionKeys(connected, config, options = {}) {
|
|
|
1289
1198
|
function useCreateSessionKey(config, options = {}) {
|
|
1290
1199
|
const manager = resolveManager(config, options);
|
|
1291
1200
|
const guard = useActionGuard();
|
|
1292
|
-
const lastCreated =
|
|
1201
|
+
const lastCreated = shallowRef11(null);
|
|
1293
1202
|
return {
|
|
1294
1203
|
createSessionKey: (scope, signerAddress) => guard.run(async () => {
|
|
1295
1204
|
const info = await manager.createSessionKey(scope, signerAddress);
|
|
@@ -1340,9 +1249,9 @@ function useDelegationPolicy(options) {
|
|
|
1340
1249
|
manager
|
|
1341
1250
|
});
|
|
1342
1251
|
const guard = useActionGuard();
|
|
1343
|
-
const verifiedIds =
|
|
1344
|
-
const isVerifying =
|
|
1345
|
-
const verifyError =
|
|
1252
|
+
const verifiedIds = shallowRef12(/* @__PURE__ */ new Set());
|
|
1253
|
+
const isVerifying = shallowRef12(false);
|
|
1254
|
+
const verifyError = shallowRef12(null);
|
|
1346
1255
|
let verifyGeneration = 0;
|
|
1347
1256
|
let disposed = false;
|
|
1348
1257
|
const origin = options.origin ?? (typeof window !== "undefined" ? window.location.origin : "unknown");
|
|
@@ -1390,7 +1299,7 @@ function useDelegationPolicy(options) {
|
|
|
1390
1299
|
},
|
|
1391
1300
|
{ immediate: true }
|
|
1392
1301
|
);
|
|
1393
|
-
|
|
1302
|
+
onScopeDispose9(() => {
|
|
1394
1303
|
disposed = true;
|
|
1395
1304
|
verifyGeneration++;
|
|
1396
1305
|
});
|
|
@@ -1433,18 +1342,18 @@ import {
|
|
|
1433
1342
|
import { WalletError as WalletError5 } from "@naculus/connect-core";
|
|
1434
1343
|
import {
|
|
1435
1344
|
computed as computed13,
|
|
1436
|
-
onScopeDispose as
|
|
1437
|
-
shallowRef as
|
|
1345
|
+
onScopeDispose as onScopeDispose10,
|
|
1346
|
+
shallowRef as shallowRef13,
|
|
1438
1347
|
toValue as toValue14,
|
|
1439
1348
|
unref as unref15,
|
|
1440
1349
|
watch as watch7
|
|
1441
1350
|
} from "vue";
|
|
1442
1351
|
function useSmartAccount(options) {
|
|
1443
|
-
const address =
|
|
1444
|
-
const isDeployed =
|
|
1445
|
-
const accountInfo =
|
|
1352
|
+
const address = shallowRef13(null);
|
|
1353
|
+
const isDeployed = shallowRef13(false);
|
|
1354
|
+
const accountInfo = shallowRef13(null);
|
|
1446
1355
|
const guard = useActionGuard();
|
|
1447
|
-
const managerRef =
|
|
1356
|
+
const managerRef = shallowRef13(null);
|
|
1448
1357
|
let generation = 0;
|
|
1449
1358
|
let inFlight = false;
|
|
1450
1359
|
let disposed = false;
|
|
@@ -1564,7 +1473,7 @@ function useSmartAccount(options) {
|
|
|
1564
1473
|
});
|
|
1565
1474
|
return addr;
|
|
1566
1475
|
}, "Failed to get smart account address");
|
|
1567
|
-
|
|
1476
|
+
onScopeDispose10(() => {
|
|
1568
1477
|
disposed = true;
|
|
1569
1478
|
generation++;
|
|
1570
1479
|
});
|
|
@@ -1588,13 +1497,13 @@ import {
|
|
|
1588
1497
|
resolveUserOpChain
|
|
1589
1498
|
} from "@naculus/connect-appkit-core";
|
|
1590
1499
|
import { WalletError as WalletError6 } from "@naculus/connect-core";
|
|
1591
|
-
import { onScopeDispose as
|
|
1500
|
+
import { onScopeDispose as onScopeDispose11, shallowRef as shallowRef14, toValue as toValue15, unref as unref16 } from "vue";
|
|
1592
1501
|
function useSendUserOperation(options) {
|
|
1593
|
-
const userOpHash =
|
|
1594
|
-
const receipt =
|
|
1595
|
-
const isPending =
|
|
1596
|
-
const isEstimating =
|
|
1597
|
-
const error =
|
|
1502
|
+
const userOpHash = shallowRef14(null);
|
|
1503
|
+
const receipt = shallowRef14(null);
|
|
1504
|
+
const isPending = shallowRef14(false);
|
|
1505
|
+
const isEstimating = shallowRef14(false);
|
|
1506
|
+
const error = shallowRef14(null);
|
|
1598
1507
|
let requestId = 0;
|
|
1599
1508
|
let inFlight = false;
|
|
1600
1509
|
let disposed = false;
|
|
@@ -1679,7 +1588,7 @@ function useSendUserOperation(options) {
|
|
|
1679
1588
|
isEstimating.value = false;
|
|
1680
1589
|
error.value = null;
|
|
1681
1590
|
};
|
|
1682
|
-
|
|
1591
|
+
onScopeDispose11(() => {
|
|
1683
1592
|
disposed = true;
|
|
1684
1593
|
requestId++;
|
|
1685
1594
|
});
|
|
@@ -1699,15 +1608,15 @@ import {
|
|
|
1699
1608
|
fetchUserOperationReceipt,
|
|
1700
1609
|
InvalidUserOperationReceiptError
|
|
1701
1610
|
} from "@naculus/connect-appkit-core";
|
|
1702
|
-
import { onScopeDispose as
|
|
1611
|
+
import { onScopeDispose as onScopeDispose12, shallowRef as shallowRef15, toValue as toValue16 } from "vue";
|
|
1703
1612
|
function useUserOpStatus(options) {
|
|
1704
|
-
const status =
|
|
1705
|
-
const receipt =
|
|
1706
|
-
const userOpHash =
|
|
1707
|
-
const error =
|
|
1708
|
-
const isPolling =
|
|
1709
|
-
const elapsedMs =
|
|
1710
|
-
const attempts =
|
|
1613
|
+
const status = shallowRef15("idle");
|
|
1614
|
+
const receipt = shallowRef15(null);
|
|
1615
|
+
const userOpHash = shallowRef15(null);
|
|
1616
|
+
const error = shallowRef15(null);
|
|
1617
|
+
const isPolling = shallowRef15(false);
|
|
1618
|
+
const elapsedMs = shallowRef15(0);
|
|
1619
|
+
const attempts = shallowRef15(0);
|
|
1711
1620
|
const pollInterval = options.pollInterval ?? 2e3;
|
|
1712
1621
|
const maxRetries = options.maxRetries ?? 30;
|
|
1713
1622
|
let generation = 0;
|
|
@@ -1813,7 +1722,7 @@ function useUserOpStatus(options) {
|
|
|
1813
1722
|
attempts.value = 0;
|
|
1814
1723
|
elapsedMs.value = 0;
|
|
1815
1724
|
};
|
|
1816
|
-
|
|
1725
|
+
onScopeDispose12(stop);
|
|
1817
1726
|
return {
|
|
1818
1727
|
status,
|
|
1819
1728
|
receipt,
|
|
@@ -1829,12 +1738,12 @@ function useUserOpStatus(options) {
|
|
|
1829
1738
|
}
|
|
1830
1739
|
|
|
1831
1740
|
// src/useSendCalls.ts
|
|
1832
|
-
import { computed as computed14, onScopeDispose as
|
|
1741
|
+
import { computed as computed14, onScopeDispose as onScopeDispose13, shallowRef as shallowRef16, toValue as toValue17, unref as unref17 } from "vue";
|
|
1833
1742
|
function useSendCalls(options) {
|
|
1834
|
-
const status =
|
|
1835
|
-
const error =
|
|
1836
|
-
const batchHash =
|
|
1837
|
-
const callsStatus =
|
|
1743
|
+
const status = shallowRef16("idle");
|
|
1744
|
+
const error = shallowRef16(null);
|
|
1745
|
+
const batchHash = shallowRef16(null);
|
|
1746
|
+
const callsStatus = shallowRef16(null);
|
|
1838
1747
|
let sendGeneration = 0;
|
|
1839
1748
|
let statusGeneration = 0;
|
|
1840
1749
|
let disposed = false;
|
|
@@ -1876,7 +1785,7 @@ function useSendCalls(options) {
|
|
|
1876
1785
|
batchHash.value = null;
|
|
1877
1786
|
callsStatus.value = null;
|
|
1878
1787
|
};
|
|
1879
|
-
|
|
1788
|
+
onScopeDispose13(() => {
|
|
1880
1789
|
disposed = true;
|
|
1881
1790
|
sendGeneration++;
|
|
1882
1791
|
statusGeneration++;
|
|
@@ -1896,34 +1805,11 @@ function useSendCalls(options) {
|
|
|
1896
1805
|
}
|
|
1897
1806
|
|
|
1898
1807
|
// src/useEmbeddedWallet.ts
|
|
1899
|
-
import { computed as computed15,
|
|
1808
|
+
import { computed as computed15, toValue as toValue18, unref as unref18 } from "vue";
|
|
1900
1809
|
function useEmbeddedWallet(options) {
|
|
1901
|
-
const
|
|
1902
|
-
const
|
|
1903
|
-
let active = 0;
|
|
1904
|
-
let generation = 0;
|
|
1905
|
-
let disposed = false;
|
|
1906
|
-
const run = async (action) => {
|
|
1907
|
-
const own = ++generation;
|
|
1908
|
-
active++;
|
|
1909
|
-
isBusy.value = true;
|
|
1910
|
-
error.value = null;
|
|
1911
|
-
try {
|
|
1912
|
-
return await action();
|
|
1913
|
-
} catch (cause) {
|
|
1914
|
-
const normalized = cause instanceof Error ? cause : new Error("Embedded wallet action failed");
|
|
1915
|
-
if (!disposed && own === generation) error.value = normalized;
|
|
1916
|
-
throw normalized;
|
|
1917
|
-
} finally {
|
|
1918
|
-
active--;
|
|
1919
|
-
if (!disposed) isBusy.value = active > 0;
|
|
1920
|
-
}
|
|
1921
|
-
};
|
|
1810
|
+
const guard = useActionGuard();
|
|
1811
|
+
const run = (action) => guard.run(action, "Embedded wallet action failed");
|
|
1922
1812
|
const wallet = computed15(() => toValue18(options.wallet));
|
|
1923
|
-
onScopeDispose21(() => {
|
|
1924
|
-
disposed = true;
|
|
1925
|
-
generation++;
|
|
1926
|
-
});
|
|
1927
1813
|
return {
|
|
1928
1814
|
wallet,
|
|
1929
1815
|
hasWallet: computed15(() => wallet.value !== null),
|
|
@@ -1944,11 +1830,9 @@ function useEmbeddedWallet(options) {
|
|
|
1944
1830
|
getSeedPhrase: () => unref18(options.getSeedPhrase)(),
|
|
1945
1831
|
getPrivateKey: () => unref18(options.getPrivateKey)(),
|
|
1946
1832
|
confirmBackup: () => unref18(options.confirmBackup)(),
|
|
1947
|
-
isBusy,
|
|
1948
|
-
error,
|
|
1949
|
-
clearError:
|
|
1950
|
-
error.value = null;
|
|
1951
|
-
}
|
|
1833
|
+
isBusy: guard.busy,
|
|
1834
|
+
error: guard.error,
|
|
1835
|
+
clearError: guard.clearError
|
|
1952
1836
|
};
|
|
1953
1837
|
}
|
|
1954
1838
|
|
|
@@ -1964,111 +1848,60 @@ function useSIWxLogin(action) {
|
|
|
1964
1848
|
}
|
|
1965
1849
|
|
|
1966
1850
|
// src/useSIWxSession.ts
|
|
1967
|
-
import { computed as computed16,
|
|
1851
|
+
import { computed as computed16, toValue as toValue19, unref as unref19 } from "vue";
|
|
1968
1852
|
function useSIWxSession(options) {
|
|
1969
|
-
const
|
|
1970
|
-
const error = shallowRef23(null);
|
|
1971
|
-
let generation = 0;
|
|
1972
|
-
let active = 0;
|
|
1973
|
-
let disposed = false;
|
|
1974
|
-
const run = async (action, message) => {
|
|
1975
|
-
const own = ++generation;
|
|
1976
|
-
active++;
|
|
1977
|
-
isSigningIn.value = true;
|
|
1978
|
-
error.value = null;
|
|
1979
|
-
try {
|
|
1980
|
-
return await action();
|
|
1981
|
-
} catch (cause) {
|
|
1982
|
-
const normalized = cause instanceof Error ? cause : new Error(message);
|
|
1983
|
-
if (!disposed && own === generation) error.value = normalized;
|
|
1984
|
-
throw normalized;
|
|
1985
|
-
} finally {
|
|
1986
|
-
active--;
|
|
1987
|
-
if (!disposed) isSigningIn.value = active > 0;
|
|
1988
|
-
}
|
|
1989
|
-
};
|
|
1990
|
-
onScopeDispose22(() => {
|
|
1991
|
-
disposed = true;
|
|
1992
|
-
generation++;
|
|
1993
|
-
});
|
|
1853
|
+
const guard = useActionGuard();
|
|
1994
1854
|
return {
|
|
1995
1855
|
session: computed16(() => toValue19(options.session)),
|
|
1996
1856
|
isAuthenticated: computed16(
|
|
1997
1857
|
() => toValue19(options.session) !== null && !toValue19(options.isExpired)
|
|
1998
1858
|
),
|
|
1999
1859
|
isRestoring: computed16(() => toValue19(options.isRestoring)),
|
|
2000
|
-
isSigningIn,
|
|
1860
|
+
isSigningIn: guard.busy,
|
|
2001
1861
|
isExpired: computed16(() => toValue19(options.isExpired)),
|
|
2002
1862
|
timeUntilExpiry: computed16(() => toValue19(options.timeUntilExpiry)),
|
|
2003
|
-
signIn: (input) => run(() => unref19(options.signIn)(input), "SIWX sign-in failed"),
|
|
1863
|
+
signIn: (input) => guard.run(() => unref19(options.signIn)(input), "SIWX sign-in failed"),
|
|
2004
1864
|
signOut: async () => {
|
|
2005
1865
|
await unref19(options.signOut)();
|
|
2006
|
-
|
|
1866
|
+
guard.clearError();
|
|
2007
1867
|
},
|
|
2008
|
-
refresh: () => run(() => unref19(options.refresh)(), "Session refresh failed"),
|
|
2009
|
-
error,
|
|
2010
|
-
clearError:
|
|
2011
|
-
error.value = null;
|
|
2012
|
-
}
|
|
1868
|
+
refresh: () => guard.run(() => unref19(options.refresh)(), "Session refresh failed"),
|
|
1869
|
+
error: guard.error,
|
|
1870
|
+
clearError: guard.clearError
|
|
2013
1871
|
};
|
|
2014
1872
|
}
|
|
2015
1873
|
|
|
2016
1874
|
// src/useSiwxAuthSession.ts
|
|
2017
|
-
import { computed as computed17,
|
|
1875
|
+
import { computed as computed17, toValue as toValue20, unref as unref20 } from "vue";
|
|
2018
1876
|
function useSiwxAuthSession(options) {
|
|
2019
|
-
const
|
|
2020
|
-
const
|
|
2021
|
-
let generation = 0;
|
|
2022
|
-
let disposed = false;
|
|
2023
|
-
const signIn = async (input) => {
|
|
2024
|
-
const own = ++generation;
|
|
2025
|
-
isSigningIn.value = true;
|
|
2026
|
-
error.value = null;
|
|
2027
|
-
try {
|
|
2028
|
-
return await unref20(options.signIn)(input);
|
|
2029
|
-
} catch (cause) {
|
|
2030
|
-
const normalized = cause instanceof Error ? cause : new Error("SIWX sign-in failed");
|
|
2031
|
-
if (!disposed && own === generation) error.value = normalized;
|
|
2032
|
-
throw normalized;
|
|
2033
|
-
} finally {
|
|
2034
|
-
if (!disposed && own === generation) isSigningIn.value = false;
|
|
2035
|
-
}
|
|
2036
|
-
};
|
|
1877
|
+
const guard = useActionGuard();
|
|
1878
|
+
const signIn = (input) => guard.run(() => unref20(options.signIn)(input), "SIWX sign-in failed");
|
|
2037
1879
|
const signOut = async () => {
|
|
2038
|
-
|
|
1880
|
+
guard.reset();
|
|
2039
1881
|
await unref20(options.signOut)();
|
|
2040
|
-
|
|
2041
|
-
isSigningIn.value = false;
|
|
2042
|
-
error.value = null;
|
|
2043
|
-
}
|
|
1882
|
+
guard.clearError();
|
|
2044
1883
|
};
|
|
2045
|
-
onScopeDispose23(() => {
|
|
2046
|
-
disposed = true;
|
|
2047
|
-
generation++;
|
|
2048
|
-
});
|
|
2049
1884
|
const siwxResult = computed17(() => toValue20(options.result));
|
|
2050
1885
|
return {
|
|
2051
1886
|
isSignedIn: computed17(() => siwxResult.value !== null),
|
|
2052
1887
|
isRestoring: computed17(() => toValue20(options.isRestoring)),
|
|
2053
1888
|
siwxResult,
|
|
2054
|
-
isSigningIn,
|
|
2055
|
-
error,
|
|
1889
|
+
isSigningIn: guard.busy,
|
|
1890
|
+
error: guard.error,
|
|
2056
1891
|
signIn,
|
|
2057
1892
|
signOut,
|
|
2058
|
-
clearError:
|
|
2059
|
-
error.value = null;
|
|
2060
|
-
}
|
|
1893
|
+
clearError: guard.clearError
|
|
2061
1894
|
};
|
|
2062
1895
|
}
|
|
2063
1896
|
|
|
2064
1897
|
// src/useBalance.ts
|
|
2065
1898
|
import { bareEvmAddress as bareEvmAddress5 } from "@naculus/connect-appkit-core";
|
|
2066
1899
|
import { formatUnits as formatUnits2 } from "@naculus/connect-core";
|
|
2067
|
-
import { computed as computed18, onScopeDispose as
|
|
1900
|
+
import { computed as computed18, onScopeDispose as onScopeDispose14, shallowRef as shallowRef17, toValue as toValue21, watch as watch8 } from "vue";
|
|
2068
1901
|
function useBalance(account, client, options = {}) {
|
|
2069
|
-
const balance =
|
|
2070
|
-
const isFetching =
|
|
2071
|
-
const error =
|
|
1902
|
+
const balance = shallowRef17(null);
|
|
1903
|
+
const isFetching = shallowRef17(false);
|
|
1904
|
+
const error = shallowRef17(null);
|
|
2072
1905
|
let generation = 0;
|
|
2073
1906
|
let disposed = false;
|
|
2074
1907
|
let timer = null;
|
|
@@ -2113,7 +1946,7 @@ function useBalance(account, client, options = {}) {
|
|
|
2113
1946
|
},
|
|
2114
1947
|
{ immediate: true }
|
|
2115
1948
|
);
|
|
2116
|
-
|
|
1949
|
+
onScopeDispose14(() => {
|
|
2117
1950
|
disposed = true;
|
|
2118
1951
|
generation++;
|
|
2119
1952
|
stopTimer();
|
|
@@ -2134,11 +1967,11 @@ function useBalance(account, client, options = {}) {
|
|
|
2134
1967
|
import {
|
|
2135
1968
|
isQuotableInput
|
|
2136
1969
|
} from "@naculus/connect-appkit-core";
|
|
2137
|
-
import { onScopeDispose as
|
|
1970
|
+
import { onScopeDispose as onScopeDispose15, shallowRef as shallowRef18, toValue as toValue22, unref as unref21, watch as watch9 } from "vue";
|
|
2138
1971
|
function useRouteQuote(input, getQuotes, options = {}) {
|
|
2139
|
-
const quotes =
|
|
2140
|
-
const loading =
|
|
2141
|
-
const error =
|
|
1972
|
+
const quotes = shallowRef18([]);
|
|
1973
|
+
const loading = shallowRef18(false);
|
|
1974
|
+
const error = shallowRef18(null);
|
|
2142
1975
|
let generation = 0;
|
|
2143
1976
|
let disposed = false;
|
|
2144
1977
|
let timer = null;
|
|
@@ -2198,7 +2031,7 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
2198
2031
|
},
|
|
2199
2032
|
{ immediate: true }
|
|
2200
2033
|
);
|
|
2201
|
-
|
|
2034
|
+
onScopeDispose15(() => {
|
|
2202
2035
|
disposed = true;
|
|
2203
2036
|
generation++;
|
|
2204
2037
|
clearTimer();
|
|
@@ -2222,11 +2055,11 @@ function useRouteQuote(input, getQuotes, options = {}) {
|
|
|
2222
2055
|
import {
|
|
2223
2056
|
compareCostsKey
|
|
2224
2057
|
} from "@naculus/connect-appkit-core";
|
|
2225
|
-
import { onScopeDispose as
|
|
2058
|
+
import { onScopeDispose as onScopeDispose16, shallowRef as shallowRef19, toValue as toValue23, unref as unref22, watch as watch10 } from "vue";
|
|
2226
2059
|
function useCompareCosts(input, compareCosts) {
|
|
2227
|
-
const comparisons =
|
|
2228
|
-
const loading =
|
|
2229
|
-
const error =
|
|
2060
|
+
const comparisons = shallowRef19([]);
|
|
2061
|
+
const loading = shallowRef19(false);
|
|
2062
|
+
const error = shallowRef19(null);
|
|
2230
2063
|
let generation = 0;
|
|
2231
2064
|
let disposed = false;
|
|
2232
2065
|
const fetchComparisons = async () => {
|
|
@@ -2259,7 +2092,7 @@ function useCompareCosts(input, compareCosts) {
|
|
|
2259
2092
|
},
|
|
2260
2093
|
{ immediate: true }
|
|
2261
2094
|
);
|
|
2262
|
-
|
|
2095
|
+
onScopeDispose16(() => {
|
|
2263
2096
|
disposed = true;
|
|
2264
2097
|
generation++;
|
|
2265
2098
|
});
|
|
@@ -2271,11 +2104,11 @@ import {
|
|
|
2271
2104
|
toExecuteRouteError,
|
|
2272
2105
|
validateRouteRecipient
|
|
2273
2106
|
} from "@naculus/connect-appkit-core";
|
|
2274
|
-
import { onScopeDispose as
|
|
2107
|
+
import { onScopeDispose as onScopeDispose17, shallowRef as shallowRef20, unref as unref23 } from "vue";
|
|
2275
2108
|
function useExecuteRoute(executeRoute) {
|
|
2276
|
-
const executing =
|
|
2277
|
-
const result =
|
|
2278
|
-
const error =
|
|
2109
|
+
const executing = shallowRef20(false);
|
|
2110
|
+
const result = shallowRef20(null);
|
|
2111
|
+
const error = shallowRef20(null);
|
|
2279
2112
|
let inFlight = false;
|
|
2280
2113
|
let disposed = false;
|
|
2281
2114
|
const execute = async (quote, recipient, options) => {
|
|
@@ -2317,7 +2150,7 @@ function useExecuteRoute(executeRoute) {
|
|
|
2317
2150
|
if (!disposed) executing.value = false;
|
|
2318
2151
|
}
|
|
2319
2152
|
};
|
|
2320
|
-
|
|
2153
|
+
onScopeDispose17(() => {
|
|
2321
2154
|
disposed = true;
|
|
2322
2155
|
});
|
|
2323
2156
|
return {
|
|
@@ -2338,15 +2171,15 @@ import { eip155ChainIdToNumber } from "@naculus/connect-appkit-core";
|
|
|
2338
2171
|
import {
|
|
2339
2172
|
TokenListManager
|
|
2340
2173
|
} from "@naculus/connect-core";
|
|
2341
|
-
import { onScopeDispose as
|
|
2174
|
+
import { onScopeDispose as onScopeDispose18, shallowRef as shallowRef21, toValue as toValue24, watch as watch11 } from "vue";
|
|
2342
2175
|
function useTokenList(chainId, options = {}) {
|
|
2343
2176
|
const config = {};
|
|
2344
2177
|
if (options.sources) config.sources = options.sources;
|
|
2345
2178
|
const manager = options.manager ?? new TokenListManager(config);
|
|
2346
|
-
const tokens =
|
|
2347
|
-
const isLoading =
|
|
2348
|
-
const isLoaded =
|
|
2349
|
-
const error =
|
|
2179
|
+
const tokens = shallowRef21([]);
|
|
2180
|
+
const isLoading = shallowRef21(options.autoLoad !== false);
|
|
2181
|
+
const isLoaded = shallowRef21(false);
|
|
2182
|
+
const error = shallowRef21(null);
|
|
2350
2183
|
let generation = 0;
|
|
2351
2184
|
let disposed = false;
|
|
2352
2185
|
const select = () => {
|
|
@@ -2379,7 +2212,7 @@ function useTokenList(chainId, options = {}) {
|
|
|
2379
2212
|
},
|
|
2380
2213
|
{ immediate: true }
|
|
2381
2214
|
);
|
|
2382
|
-
|
|
2215
|
+
onScopeDispose18(() => {
|
|
2383
2216
|
disposed = true;
|
|
2384
2217
|
generation++;
|
|
2385
2218
|
});
|
|
@@ -2397,7 +2230,7 @@ import { eip155ChainIdToNumber as eip155ChainIdToNumber2 } from "@naculus/connec
|
|
|
2397
2230
|
import {
|
|
2398
2231
|
TokenListManager as TokenListManager2
|
|
2399
2232
|
} from "@naculus/connect-core";
|
|
2400
|
-
import { onScopeDispose as
|
|
2233
|
+
import { onScopeDispose as onScopeDispose19, shallowRef as shallowRef22, toValue as toValue25, watch as watch12 } from "vue";
|
|
2401
2234
|
var DEBOUNCE_MS = 300;
|
|
2402
2235
|
var EMPTY = { exact: [], fuzzy: [], hasMore: false };
|
|
2403
2236
|
var sharedManager = null;
|
|
@@ -2410,8 +2243,8 @@ function getSharedManager() {
|
|
|
2410
2243
|
return sharedManager;
|
|
2411
2244
|
}
|
|
2412
2245
|
function useTokenSearch(query, chainId, options = {}) {
|
|
2413
|
-
const results =
|
|
2414
|
-
const isSearching =
|
|
2246
|
+
const results = shallowRef22(EMPTY);
|
|
2247
|
+
const isSearching = shallowRef22(false);
|
|
2415
2248
|
let timer = null;
|
|
2416
2249
|
const clear = () => {
|
|
2417
2250
|
if (timer) clearTimeout(timer);
|
|
@@ -2440,7 +2273,7 @@ function useTokenSearch(query, chainId, options = {}) {
|
|
|
2440
2273
|
},
|
|
2441
2274
|
{ immediate: true }
|
|
2442
2275
|
);
|
|
2443
|
-
|
|
2276
|
+
onScopeDispose19(clear);
|
|
2444
2277
|
return { results, isSearching };
|
|
2445
2278
|
}
|
|
2446
2279
|
|
|
@@ -2458,14 +2291,14 @@ function useValidateDestination(address) {
|
|
|
2458
2291
|
// src/useTokenBalance.ts
|
|
2459
2292
|
import { bareEvmAddress as bareEvmAddress6 } from "@naculus/connect-appkit-core";
|
|
2460
2293
|
import { ERC20_MIN_ABI as ERC20_MIN_ABI3, formatUnits as formatUnits3 } from "@naculus/connect-core";
|
|
2461
|
-
import { onScopeDispose as
|
|
2294
|
+
import { onScopeDispose as onScopeDispose20, shallowRef as shallowRef23, toValue as toValue27, watch as watch13 } from "vue";
|
|
2462
2295
|
function tokensKey(tokens) {
|
|
2463
2296
|
return tokens.map((t) => `${t.address.toLowerCase()}|${t.decimals}|${t.symbol}`).join(",");
|
|
2464
2297
|
}
|
|
2465
2298
|
function useTokenBalance(account, client, tokens, options = {}) {
|
|
2466
|
-
const tokenBalances =
|
|
2467
|
-
const isFetching =
|
|
2468
|
-
const error =
|
|
2299
|
+
const tokenBalances = shallowRef23([]);
|
|
2300
|
+
const isFetching = shallowRef23(false);
|
|
2301
|
+
const error = shallowRef23(null);
|
|
2469
2302
|
let generation = 0;
|
|
2470
2303
|
let disposed = false;
|
|
2471
2304
|
let timer = null;
|
|
@@ -2531,7 +2364,7 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
2531
2364
|
},
|
|
2532
2365
|
{ immediate: true }
|
|
2533
2366
|
);
|
|
2534
|
-
|
|
2367
|
+
onScopeDispose20(() => {
|
|
2535
2368
|
disposed = true;
|
|
2536
2369
|
generation++;
|
|
2537
2370
|
stopTimer();
|
|
@@ -2547,23 +2380,120 @@ function useTokenBalance(account, client, tokens, options = {}) {
|
|
|
2547
2380
|
};
|
|
2548
2381
|
}
|
|
2549
2382
|
|
|
2550
|
-
// src/
|
|
2383
|
+
// src/useDelegate.ts
|
|
2551
2384
|
import { bareEvmAddress as bareEvmAddress7 } from "@naculus/connect-appkit-core";
|
|
2385
|
+
import {
|
|
2386
|
+
delegateAccount,
|
|
2387
|
+
eip155Reference,
|
|
2388
|
+
REVOKE_DELEGATE,
|
|
2389
|
+
WalletError as WalletError7
|
|
2390
|
+
} from "@naculus/connect-core";
|
|
2391
|
+
import { onScopeDispose as onScopeDispose21, shallowRef as shallowRef24, toValue as toValue28, watch as watch14 } from "vue";
|
|
2392
|
+
function useDelegate(options) {
|
|
2393
|
+
const result = shallowRef24(null);
|
|
2394
|
+
const isPending = shallowRef24(false);
|
|
2395
|
+
const error = shallowRef24(null);
|
|
2396
|
+
let requestId = 0;
|
|
2397
|
+
let inFlight = false;
|
|
2398
|
+
let disposed = false;
|
|
2399
|
+
const fail = (cause) => {
|
|
2400
|
+
error.value = cause;
|
|
2401
|
+
return null;
|
|
2402
|
+
};
|
|
2403
|
+
const run = async (target, allowlist) => {
|
|
2404
|
+
if (inFlight) return fail(new Error("A delegation is already in progress"));
|
|
2405
|
+
const session = toValue28(options.session);
|
|
2406
|
+
const account = bareEvmAddress7(toValue28(options.account));
|
|
2407
|
+
const chainId = toValue28(options.chainId);
|
|
2408
|
+
if (!session || !account || !chainId) {
|
|
2409
|
+
return fail(
|
|
2410
|
+
new WalletError7("wallet_unavailable", "No connected EVM account")
|
|
2411
|
+
);
|
|
2412
|
+
}
|
|
2413
|
+
const reader = toValue28(options.client);
|
|
2414
|
+
if (!reader || reader.chain?.id !== eip155Reference(chainId)) {
|
|
2415
|
+
return fail(
|
|
2416
|
+
new WalletError7(
|
|
2417
|
+
"chain_mismatch",
|
|
2418
|
+
`No RPC client for ${chainId}; refusing to read the nonce elsewhere.`
|
|
2419
|
+
)
|
|
2420
|
+
);
|
|
2421
|
+
}
|
|
2422
|
+
const connector = toValue28(options.connector) ?? {};
|
|
2423
|
+
const own = ++requestId;
|
|
2424
|
+
inFlight = true;
|
|
2425
|
+
isPending.value = true;
|
|
2426
|
+
error.value = null;
|
|
2427
|
+
result.value = null;
|
|
2428
|
+
try {
|
|
2429
|
+
const sent = await delegateAccount({
|
|
2430
|
+
connector,
|
|
2431
|
+
session,
|
|
2432
|
+
account,
|
|
2433
|
+
chainId,
|
|
2434
|
+
delegate: target,
|
|
2435
|
+
allowlist,
|
|
2436
|
+
getTransactionCount: (address, blockTag) => reader.getTransactionCount({ address, blockTag })
|
|
2437
|
+
});
|
|
2438
|
+
if (disposed || own !== requestId) return null;
|
|
2439
|
+
result.value = sent;
|
|
2440
|
+
return sent;
|
|
2441
|
+
} catch (cause) {
|
|
2442
|
+
if (disposed || own !== requestId) return null;
|
|
2443
|
+
return fail(
|
|
2444
|
+
cause instanceof Error ? cause : new Error("Failed to send delegation")
|
|
2445
|
+
);
|
|
2446
|
+
} finally {
|
|
2447
|
+
inFlight = false;
|
|
2448
|
+
if (!disposed && own === requestId) isPending.value = false;
|
|
2449
|
+
}
|
|
2450
|
+
};
|
|
2451
|
+
const reset = () => {
|
|
2452
|
+
requestId++;
|
|
2453
|
+
result.value = null;
|
|
2454
|
+
isPending.value = false;
|
|
2455
|
+
error.value = null;
|
|
2456
|
+
};
|
|
2457
|
+
watch14(
|
|
2458
|
+
[
|
|
2459
|
+
() => toValue28(options.session),
|
|
2460
|
+
() => toValue28(options.account),
|
|
2461
|
+
() => toValue28(options.chainId)
|
|
2462
|
+
],
|
|
2463
|
+
reset,
|
|
2464
|
+
{ flush: "sync" }
|
|
2465
|
+
);
|
|
2466
|
+
onScopeDispose21(() => {
|
|
2467
|
+
disposed = true;
|
|
2468
|
+
requestId++;
|
|
2469
|
+
});
|
|
2470
|
+
return {
|
|
2471
|
+
delegate: (target) => run(target, toValue28(options.allowlist)),
|
|
2472
|
+
revoke: () => run(REVOKE_DELEGATE, []),
|
|
2473
|
+
result,
|
|
2474
|
+
isPending,
|
|
2475
|
+
error,
|
|
2476
|
+
reset
|
|
2477
|
+
};
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
// src/useDelegation.ts
|
|
2481
|
+
import { bareEvmAddress as bareEvmAddress8 } from "@naculus/connect-appkit-core";
|
|
2552
2482
|
import {
|
|
2553
2483
|
readDelegation,
|
|
2554
2484
|
UNKNOWN_DELEGATION
|
|
2555
2485
|
} from "@naculus/connect-core";
|
|
2556
|
-
import { computed as computed20, onScopeDispose as
|
|
2486
|
+
import { computed as computed20, onScopeDispose as onScopeDispose22, shallowRef as shallowRef25, toValue as toValue29, watch as watch15 } from "vue";
|
|
2557
2487
|
function useDelegation(account, client, chainId) {
|
|
2558
|
-
const status =
|
|
2559
|
-
const isFetching =
|
|
2560
|
-
const error =
|
|
2488
|
+
const status = shallowRef25(UNKNOWN_DELEGATION);
|
|
2489
|
+
const isFetching = shallowRef25(false);
|
|
2490
|
+
const error = shallowRef25(null);
|
|
2561
2491
|
let generation = 0;
|
|
2562
2492
|
let disposed = false;
|
|
2563
2493
|
const refetch = async () => {
|
|
2564
2494
|
const mine = ++generation;
|
|
2565
|
-
const reader =
|
|
2566
|
-
const address =
|
|
2495
|
+
const reader = toValue29(client);
|
|
2496
|
+
const address = bareEvmAddress8(toValue29(account));
|
|
2567
2497
|
status.value = UNKNOWN_DELEGATION;
|
|
2568
2498
|
error.value = null;
|
|
2569
2499
|
if (!reader || !address) {
|
|
@@ -2585,14 +2515,14 @@ function useDelegation(account, client, chainId) {
|
|
|
2585
2515
|
if (!disposed && mine === generation) isFetching.value = false;
|
|
2586
2516
|
}
|
|
2587
2517
|
};
|
|
2588
|
-
|
|
2589
|
-
[() =>
|
|
2518
|
+
watch15(
|
|
2519
|
+
[() => toValue29(account), () => toValue29(client), () => toValue29(chainId)],
|
|
2590
2520
|
() => {
|
|
2591
2521
|
void refetch();
|
|
2592
2522
|
},
|
|
2593
2523
|
{ immediate: true, flush: "sync" }
|
|
2594
2524
|
);
|
|
2595
|
-
|
|
2525
|
+
onScopeDispose22(() => {
|
|
2596
2526
|
disposed = true;
|
|
2597
2527
|
generation++;
|
|
2598
2528
|
});
|
|
@@ -2607,18 +2537,18 @@ function useDelegation(account, client, chainId) {
|
|
|
2607
2537
|
|
|
2608
2538
|
// src/name-lookup.ts
|
|
2609
2539
|
import { getResolver } from "@naculus/connect-appkit-core";
|
|
2610
|
-
import { computed as computed21, onScopeDispose as
|
|
2540
|
+
import { computed as computed21, onScopeDispose as onScopeDispose23, shallowRef as shallowRef26, toValue as toValue30, watch as watch16 } from "vue";
|
|
2611
2541
|
function useNameLookup(options) {
|
|
2612
|
-
const data =
|
|
2613
|
-
const loading =
|
|
2614
|
-
const error =
|
|
2542
|
+
const data = shallowRef26(null);
|
|
2543
|
+
const loading = shallowRef26(false);
|
|
2544
|
+
const error = shallowRef26(null);
|
|
2615
2545
|
let generation = 0;
|
|
2616
2546
|
let disposed = false;
|
|
2617
2547
|
const run = () => {
|
|
2618
|
-
const input =
|
|
2619
|
-
const skip =
|
|
2620
|
-
const scope =
|
|
2621
|
-
const config =
|
|
2548
|
+
const input = toValue30(options.input).trim();
|
|
2549
|
+
const skip = toValue30(options.skip) ?? false;
|
|
2550
|
+
const scope = toValue30(options.scope);
|
|
2551
|
+
const config = toValue30(options.resolverConfig);
|
|
2622
2552
|
const mine = ++generation;
|
|
2623
2553
|
if (!input || skip) {
|
|
2624
2554
|
data.value = null;
|
|
@@ -2640,17 +2570,17 @@ function useNameLookup(options) {
|
|
|
2640
2570
|
loading.value = false;
|
|
2641
2571
|
});
|
|
2642
2572
|
};
|
|
2643
|
-
|
|
2573
|
+
watch16(
|
|
2644
2574
|
() => [
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2575
|
+
toValue30(options.input),
|
|
2576
|
+
toValue30(options.skip),
|
|
2577
|
+
toValue30(options.scope),
|
|
2578
|
+
toValue30(options.resolverConfig)
|
|
2649
2579
|
],
|
|
2650
2580
|
run,
|
|
2651
2581
|
{ immediate: true, flush: "sync", deep: true }
|
|
2652
2582
|
);
|
|
2653
|
-
|
|
2583
|
+
onScopeDispose23(() => {
|
|
2654
2584
|
disposed = true;
|
|
2655
2585
|
generation++;
|
|
2656
2586
|
});
|
|
@@ -2684,11 +2614,11 @@ function useLookupAddress(address, options) {
|
|
|
2684
2614
|
}
|
|
2685
2615
|
|
|
2686
2616
|
// src/useSolanaAccount.ts
|
|
2687
|
-
import { computed as computed22, toValue as
|
|
2617
|
+
import { computed as computed22, toValue as toValue31 } from "vue";
|
|
2688
2618
|
function useSolanaAccount(accounts, connected) {
|
|
2689
|
-
const isConnected = computed22(() =>
|
|
2619
|
+
const isConnected = computed22(() => toValue31(connected));
|
|
2690
2620
|
const caip10 = computed22(
|
|
2691
|
-
() => isConnected.value ? (
|
|
2621
|
+
() => isConnected.value ? (toValue31(accounts) ?? []).find(
|
|
2692
2622
|
(account) => account.startsWith("solana:")
|
|
2693
2623
|
) ?? null : null
|
|
2694
2624
|
);
|
|
@@ -2713,10 +2643,10 @@ import {
|
|
|
2713
2643
|
describeChain,
|
|
2714
2644
|
resolveChain
|
|
2715
2645
|
} from "@naculus/connect-appkit-core";
|
|
2716
|
-
import { computed as computed23, toValue as
|
|
2646
|
+
import { computed as computed23, toValue as toValue32 } from "vue";
|
|
2717
2647
|
function useChain(chains, chainId) {
|
|
2718
|
-
const list = computed23(() =>
|
|
2719
|
-
const id = computed23(() =>
|
|
2648
|
+
const list = computed23(() => toValue32(chains) ?? []);
|
|
2649
|
+
const id = computed23(() => toValue32(chainId) ?? null);
|
|
2720
2650
|
const currentChain = computed23(() => resolveChain(list.value, id.value));
|
|
2721
2651
|
return {
|
|
2722
2652
|
currentChain,
|
|
@@ -2732,13 +2662,13 @@ function useChain(chains, chainId) {
|
|
|
2732
2662
|
}
|
|
2733
2663
|
|
|
2734
2664
|
// src/usePassphraseGate.ts
|
|
2735
|
-
import { onScopeDispose as
|
|
2665
|
+
import { onScopeDispose as onScopeDispose24, readonly, shallowRef as shallowRef27 } from "vue";
|
|
2736
2666
|
function usePassphraseGate(gate) {
|
|
2737
|
-
const request =
|
|
2667
|
+
const request = shallowRef27(gate.getSnapshot());
|
|
2738
2668
|
const unsubscribe = gate.subscribe(() => {
|
|
2739
2669
|
request.value = gate.getSnapshot();
|
|
2740
2670
|
});
|
|
2741
|
-
|
|
2671
|
+
onScopeDispose24(unsubscribe);
|
|
2742
2672
|
return {
|
|
2743
2673
|
request: readonly(request),
|
|
2744
2674
|
submit: (passphrase) => gate.submit(passphrase),
|
|
@@ -2751,16 +2681,16 @@ function usePassphraseGate(gate) {
|
|
|
2751
2681
|
import {
|
|
2752
2682
|
getSolanaBalance
|
|
2753
2683
|
} from "@naculus/connect-core";
|
|
2754
|
-
import { onScopeDispose as
|
|
2684
|
+
import { onScopeDispose as onScopeDispose25, ref, shallowRef as shallowRef28, toValue as toValue33, watchEffect } from "vue";
|
|
2755
2685
|
function useSolanaBalance(address, rpcUrl) {
|
|
2756
|
-
const balance =
|
|
2686
|
+
const balance = shallowRef28(null);
|
|
2757
2687
|
const isFetching = ref(false);
|
|
2758
|
-
const error =
|
|
2688
|
+
const error = shallowRef28(null);
|
|
2759
2689
|
let generation = 0;
|
|
2760
2690
|
let disposed = false;
|
|
2761
2691
|
const refetch = async () => {
|
|
2762
|
-
const addr =
|
|
2763
|
-
const url =
|
|
2692
|
+
const addr = toValue33(address);
|
|
2693
|
+
const url = toValue33(rpcUrl);
|
|
2764
2694
|
if (!addr || !url) {
|
|
2765
2695
|
balance.value = null;
|
|
2766
2696
|
return;
|
|
@@ -2781,24 +2711,24 @@ function useSolanaBalance(address, rpcUrl) {
|
|
|
2781
2711
|
}
|
|
2782
2712
|
};
|
|
2783
2713
|
watchEffect(() => {
|
|
2784
|
-
|
|
2785
|
-
|
|
2714
|
+
toValue33(address);
|
|
2715
|
+
toValue33(rpcUrl);
|
|
2786
2716
|
void refetch();
|
|
2787
2717
|
});
|
|
2788
|
-
|
|
2718
|
+
onScopeDispose25(() => {
|
|
2789
2719
|
disposed = true;
|
|
2790
2720
|
});
|
|
2791
2721
|
return { balance, isFetching, error, refetch };
|
|
2792
2722
|
}
|
|
2793
2723
|
|
|
2794
2724
|
// src/useLastTx.ts
|
|
2795
|
-
import { shallowRef as
|
|
2725
|
+
import { shallowRef as shallowRef29, toValue as toValue34, watch as watch17 } from "vue";
|
|
2796
2726
|
function useLastTx(monitor) {
|
|
2797
|
-
const lastTx =
|
|
2798
|
-
const lastConfirmedTx =
|
|
2799
|
-
const lastFailedTx =
|
|
2800
|
-
|
|
2801
|
-
() =>
|
|
2727
|
+
const lastTx = shallowRef29(null);
|
|
2728
|
+
const lastConfirmedTx = shallowRef29(null);
|
|
2729
|
+
const lastFailedTx = shallowRef29(null);
|
|
2730
|
+
watch17(
|
|
2731
|
+
() => toValue34(monitor),
|
|
2802
2732
|
(activeMonitor, _previous, onCleanup) => {
|
|
2803
2733
|
if (!activeMonitor) return;
|
|
2804
2734
|
const recordLatest = (entry) => {
|
|
@@ -2836,15 +2766,15 @@ function useLastTx(monitor) {
|
|
|
2836
2766
|
}
|
|
2837
2767
|
|
|
2838
2768
|
// src/useTxHistory.ts
|
|
2839
|
-
import { computed as computed24, shallowRef as
|
|
2769
|
+
import { computed as computed24, shallowRef as shallowRef30, toValue as toValue35, watch as watch18 } from "vue";
|
|
2840
2770
|
function useTxHistory(address, chainId, monitor) {
|
|
2841
|
-
const entries =
|
|
2842
|
-
const isLoading =
|
|
2843
|
-
const error =
|
|
2771
|
+
const entries = shallowRef30([]);
|
|
2772
|
+
const isLoading = shallowRef30(false);
|
|
2773
|
+
const error = shallowRef30(null);
|
|
2844
2774
|
let generation = 0;
|
|
2845
2775
|
const refresh = async () => {
|
|
2846
2776
|
const mine = ++generation;
|
|
2847
|
-
const activeMonitor =
|
|
2777
|
+
const activeMonitor = toValue35(monitor);
|
|
2848
2778
|
if (!activeMonitor) {
|
|
2849
2779
|
entries.value = [];
|
|
2850
2780
|
isLoading.value = false;
|
|
@@ -2855,8 +2785,8 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
2855
2785
|
error.value = null;
|
|
2856
2786
|
try {
|
|
2857
2787
|
const result = await activeMonitor.getTxHistory(
|
|
2858
|
-
|
|
2859
|
-
|
|
2788
|
+
toValue35(address) ?? void 0,
|
|
2789
|
+
toValue35(chainId) ?? void 0
|
|
2860
2790
|
);
|
|
2861
2791
|
if (mine === generation) entries.value = result;
|
|
2862
2792
|
} catch (err) {
|
|
@@ -2866,8 +2796,8 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
2866
2796
|
if (mine === generation) isLoading.value = false;
|
|
2867
2797
|
}
|
|
2868
2798
|
};
|
|
2869
|
-
|
|
2870
|
-
[() =>
|
|
2799
|
+
watch18(
|
|
2800
|
+
[() => toValue35(monitor), () => toValue35(address), () => toValue35(chainId)],
|
|
2871
2801
|
([activeMonitor], _previous, onCleanup) => {
|
|
2872
2802
|
if (!activeMonitor) {
|
|
2873
2803
|
void refresh();
|
|
@@ -2896,17 +2826,17 @@ function useTxHistory(address, chainId, monitor) {
|
|
|
2896
2826
|
}
|
|
2897
2827
|
|
|
2898
2828
|
// src/useTxMonitor.ts
|
|
2899
|
-
import { computed as computed25, shallowRef as
|
|
2829
|
+
import { computed as computed25, shallowRef as shallowRef31, toValue as toValue36, watch as watch19 } from "vue";
|
|
2900
2830
|
function useTxMonitor(hash, chainId, monitor) {
|
|
2901
|
-
const entry =
|
|
2902
|
-
const isLoading =
|
|
2903
|
-
const isWatching =
|
|
2904
|
-
const error =
|
|
2831
|
+
const entry = shallowRef31(null);
|
|
2832
|
+
const isLoading = shallowRef31(false);
|
|
2833
|
+
const isWatching = shallowRef31(false);
|
|
2834
|
+
const error = shallowRef31(null);
|
|
2905
2835
|
let generation = 0;
|
|
2906
2836
|
const refresh = async () => {
|
|
2907
|
-
const activeMonitor =
|
|
2908
|
-
const activeHash =
|
|
2909
|
-
const activeChainId =
|
|
2837
|
+
const activeMonitor = toValue36(monitor);
|
|
2838
|
+
const activeHash = toValue36(hash);
|
|
2839
|
+
const activeChainId = toValue36(chainId);
|
|
2910
2840
|
if (!activeMonitor || !activeHash) return;
|
|
2911
2841
|
isLoading.value = true;
|
|
2912
2842
|
error.value = null;
|
|
@@ -2924,15 +2854,15 @@ function useTxMonitor(hash, chainId, monitor) {
|
|
|
2924
2854
|
}
|
|
2925
2855
|
};
|
|
2926
2856
|
const stopWatching = () => {
|
|
2927
|
-
const activeMonitor =
|
|
2928
|
-
const activeHash =
|
|
2929
|
-
const activeChainId =
|
|
2857
|
+
const activeMonitor = toValue36(monitor);
|
|
2858
|
+
const activeHash = toValue36(hash);
|
|
2859
|
+
const activeChainId = toValue36(chainId);
|
|
2930
2860
|
if (!activeMonitor || !activeHash) return;
|
|
2931
2861
|
activeMonitor.stopWatching(activeHash, activeChainId ?? void 0);
|
|
2932
2862
|
isWatching.value = false;
|
|
2933
2863
|
};
|
|
2934
|
-
|
|
2935
|
-
[() =>
|
|
2864
|
+
watch19(
|
|
2865
|
+
[() => toValue36(monitor), () => toValue36(hash), () => toValue36(chainId)],
|
|
2936
2866
|
([activeMonitor, activeHash, activeChainId], _previous, onCleanup) => {
|
|
2937
2867
|
const mine = ++generation;
|
|
2938
2868
|
if (!activeMonitor || !activeHash || !activeChainId) {
|
|
@@ -2987,18 +2917,18 @@ import {
|
|
|
2987
2917
|
normalizeCapabilities,
|
|
2988
2918
|
selectChainCapabilities
|
|
2989
2919
|
} from "@naculus/connect-appkit-core";
|
|
2990
|
-
import { computed as computed26, shallowRef as
|
|
2920
|
+
import { computed as computed26, shallowRef as shallowRef32, toValue as toValue37, watchEffect as watchEffect2 } from "vue";
|
|
2991
2921
|
function useCapabilities(client, session, chainId) {
|
|
2992
|
-
const capabilities =
|
|
2922
|
+
const capabilities = shallowRef32(
|
|
2993
2923
|
null
|
|
2994
2924
|
);
|
|
2995
|
-
const isFetching =
|
|
2996
|
-
const error =
|
|
2925
|
+
const isFetching = shallowRef32(false);
|
|
2926
|
+
const error = shallowRef32(null);
|
|
2997
2927
|
let generation = 0;
|
|
2998
2928
|
const refetch = async () => {
|
|
2999
2929
|
const mine = ++generation;
|
|
3000
|
-
const activeClient =
|
|
3001
|
-
const activeSession =
|
|
2930
|
+
const activeClient = toValue37(client);
|
|
2931
|
+
const activeSession = toValue37(session);
|
|
3002
2932
|
if (!activeClient?.getCapabilities || !activeSession) {
|
|
3003
2933
|
capabilities.value = null;
|
|
3004
2934
|
isFetching.value = false;
|
|
@@ -3020,17 +2950,17 @@ function useCapabilities(client, session, chainId) {
|
|
|
3020
2950
|
}
|
|
3021
2951
|
};
|
|
3022
2952
|
watchEffect2(() => {
|
|
3023
|
-
void
|
|
3024
|
-
void
|
|
2953
|
+
void toValue37(client);
|
|
2954
|
+
void toValue37(session);
|
|
3025
2955
|
void refetch();
|
|
3026
2956
|
});
|
|
3027
2957
|
return {
|
|
3028
2958
|
capabilities,
|
|
3029
2959
|
current: computed26(
|
|
3030
|
-
() => selectChainCapabilities(capabilities.value,
|
|
2960
|
+
() => selectChainCapabilities(capabilities.value, toValue37(chainId))
|
|
3031
2961
|
),
|
|
3032
2962
|
atomic: computed26(
|
|
3033
|
-
() => atomicSupportFor(capabilities.value,
|
|
2963
|
+
() => atomicSupportFor(capabilities.value, toValue37(chainId))
|
|
3034
2964
|
),
|
|
3035
2965
|
isFetching,
|
|
3036
2966
|
error,
|
|
@@ -3042,10 +2972,10 @@ function useCapabilities(client, session, chainId) {
|
|
|
3042
2972
|
import {
|
|
3043
2973
|
readSolanaRoles
|
|
3044
2974
|
} from "@naculus/connect-appkit-core";
|
|
3045
|
-
import { computed as computed27, toValue as
|
|
2975
|
+
import { computed as computed27, toValue as toValue38 } from "vue";
|
|
3046
2976
|
function useSolanaRoles(connector, session) {
|
|
3047
2977
|
const state = computed27(
|
|
3048
|
-
() => readSolanaRoles(
|
|
2978
|
+
() => readSolanaRoles(toValue38(connector), toValue38(session))
|
|
3049
2979
|
);
|
|
3050
2980
|
return {
|
|
3051
2981
|
roles: computed27(() => state.value.roles),
|
|
@@ -3092,6 +3022,7 @@ export {
|
|
|
3092
3022
|
useCompareCosts,
|
|
3093
3023
|
useConnect,
|
|
3094
3024
|
useCreateSessionKey,
|
|
3025
|
+
useDelegate,
|
|
3095
3026
|
useDelegation,
|
|
3096
3027
|
useDelegationPolicy,
|
|
3097
3028
|
useDisconnect,
|