@b3dotfun/sdk 0.0.26-alpha.4 → 0.0.26-alpha.5
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.
|
@@ -40,9 +40,14 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
40
40
|
if (!signer) {
|
|
41
41
|
throw new Error("No account connected");
|
|
42
42
|
}
|
|
43
|
+
// Get the target chain configuration instead of using potentially stale walletClient.chain
|
|
44
|
+
const targetChain = supported_1.supportedChains.find(chain => chain.id === targetChainId);
|
|
45
|
+
if (!targetChain) {
|
|
46
|
+
throw new Error(`Chain ${targetChainId} is not supported`);
|
|
47
|
+
}
|
|
43
48
|
const hash = await walletClient.sendTransaction({
|
|
44
49
|
account: signer,
|
|
45
|
-
chain:
|
|
50
|
+
chain: targetChain,
|
|
46
51
|
to: params.to,
|
|
47
52
|
data: params.data,
|
|
48
53
|
value: params.value,
|
|
@@ -55,7 +60,7 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
55
60
|
if (onCorrectChain) {
|
|
56
61
|
return await executeTransaction();
|
|
57
62
|
}
|
|
58
|
-
sonner_1.toast.info(`Switching to ${(0, anyspend_1.getChainName)(targetChainId)}…`);
|
|
63
|
+
const switchingToastId = sonner_1.toast.info(`Switching to ${(0, anyspend_1.getChainName)(targetChainId)}…`);
|
|
59
64
|
const targetChain = supported_1.supportedChains.find(chain => chain.id === targetChainId);
|
|
60
65
|
if (!targetChain) {
|
|
61
66
|
sonner_1.toast.error(`Chain ${targetChainId} is not supported`);
|
|
@@ -77,6 +82,7 @@ function useUnifiedChainSwitchAndExecute() {
|
|
|
77
82
|
},
|
|
78
83
|
},
|
|
79
84
|
});
|
|
85
|
+
sonner_1.toast.dismiss(switchingToastId);
|
|
80
86
|
return await executeTransaction();
|
|
81
87
|
}
|
|
82
88
|
catch (e) {
|
|
@@ -34,9 +34,14 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
34
34
|
if (!signer) {
|
|
35
35
|
throw new Error("No account connected");
|
|
36
36
|
}
|
|
37
|
+
// Get the target chain configuration instead of using potentially stale walletClient.chain
|
|
38
|
+
const targetChain = supportedChains.find(chain => chain.id === targetChainId);
|
|
39
|
+
if (!targetChain) {
|
|
40
|
+
throw new Error(`Chain ${targetChainId} is not supported`);
|
|
41
|
+
}
|
|
37
42
|
const hash = await walletClient.sendTransaction({
|
|
38
43
|
account: signer,
|
|
39
|
-
chain:
|
|
44
|
+
chain: targetChain,
|
|
40
45
|
to: params.to,
|
|
41
46
|
data: params.data,
|
|
42
47
|
value: params.value,
|
|
@@ -49,7 +54,7 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
49
54
|
if (onCorrectChain) {
|
|
50
55
|
return await executeTransaction();
|
|
51
56
|
}
|
|
52
|
-
toast.info(`Switching to ${getChainName(targetChainId)}…`);
|
|
57
|
+
const switchingToastId = toast.info(`Switching to ${getChainName(targetChainId)}…`);
|
|
53
58
|
const targetChain = supportedChains.find(chain => chain.id === targetChainId);
|
|
54
59
|
if (!targetChain) {
|
|
55
60
|
toast.error(`Chain ${targetChainId} is not supported`);
|
|
@@ -71,6 +76,7 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
71
76
|
},
|
|
72
77
|
},
|
|
73
78
|
});
|
|
79
|
+
toast.dismiss(switchingToastId);
|
|
74
80
|
return await executeTransaction();
|
|
75
81
|
}
|
|
76
82
|
catch (e) {
|
package/package.json
CHANGED
|
@@ -50,9 +50,15 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
50
50
|
throw new Error("No account connected");
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
// Get the target chain configuration instead of using potentially stale walletClient.chain
|
|
54
|
+
const targetChain = supportedChains.find(chain => chain.id === targetChainId);
|
|
55
|
+
if (!targetChain) {
|
|
56
|
+
throw new Error(`Chain ${targetChainId} is not supported`);
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
const hash = await walletClient.sendTransaction({
|
|
54
60
|
account: signer,
|
|
55
|
-
chain:
|
|
61
|
+
chain: targetChain,
|
|
56
62
|
to: params.to,
|
|
57
63
|
data: params.data as `0x${string}`,
|
|
58
64
|
value: params.value,
|
|
@@ -69,7 +75,7 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
69
75
|
return await executeTransaction();
|
|
70
76
|
}
|
|
71
77
|
|
|
72
|
-
toast.info(`Switching to ${getChainName(targetChainId)}…`);
|
|
78
|
+
const switchingToastId = toast.info(`Switching to ${getChainName(targetChainId)}…`);
|
|
73
79
|
|
|
74
80
|
const targetChain = supportedChains.find(chain => chain.id === targetChainId);
|
|
75
81
|
if (!targetChain) {
|
|
@@ -95,6 +101,7 @@ export function useUnifiedChainSwitchAndExecute() {
|
|
|
95
101
|
},
|
|
96
102
|
});
|
|
97
103
|
|
|
104
|
+
toast.dismiss(switchingToastId);
|
|
98
105
|
return await executeTransaction();
|
|
99
106
|
} catch (e: any) {
|
|
100
107
|
if (e?.code === -32603 || e?.message?.includes("f is not a function")) {
|