@talken/talkenkit 2.3.5 → 2.3.7
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/components/ChainIndicator/ChainIndicator.css.d.ts +4 -0
- package/dist/components/ChainIndicator/ChainIndicator.d.ts +53 -0
- package/dist/components/ChainIndicator/index.d.ts +2 -0
- package/dist/components/ChainSelector/ChainSelector.css.d.ts +5 -0
- package/dist/components/ChainSelector/ChainSelector.d.ts +38 -0
- package/dist/components/ChainSelector/index.d.ts +2 -0
- package/dist/components/ConnectButton/ConnectButtonRenderer.d.ts +9 -0
- package/dist/components/ConnectOptions/DesktopOptions.d.ts +5 -1
- package/dist/components/ConnectOptions/MultiChainConnectOptions.d.ts +31 -0
- package/dist/components/ConnectOptions/index.d.ts +3 -0
- package/dist/components/ModalSelection/ModalSelection.d.ts +2 -1
- package/dist/components/ProfileDetails/ProfileDetails.d.ts +1 -2
- package/dist/components/RainbowKitProvider/RainbowKitProvider.d.ts +8 -1
- package/dist/components/SolanaWalletList/SolanaWalletList.css.d.ts +7 -0
- package/dist/components/SolanaWalletList/SolanaWalletList.d.ts +32 -0
- package/dist/components/SolanaWalletList/index.d.ts +2 -0
- package/dist/contexts/MultiChainContext.d.ts +68 -0
- package/dist/contexts/index.d.ts +7 -0
- package/dist/index.css +105 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1445 -899
- package/dist/solana/SolanaWalletProvider.d.ts +38 -0
- package/dist/solana/config.d.ts +57 -0
- package/dist/solana/index.d.ts +11 -0
- package/dist/solana/utils/detection.d.ts +27 -0
- package/dist/solana/wallets/backpackWallet.d.ts +19 -0
- package/dist/solana/wallets/index.d.ts +8 -0
- package/dist/solana/wallets/phantomSolanaWallet.d.ts +17 -0
- package/dist/solana/wallets/solflareWallet.d.ts +17 -0
- package/dist/types/solana.d.ts +97 -0
- package/dist/wallets/recentSolanaWalletIds.d.ts +16 -0
- package/dist/wallets/walletConnectors/abcWallet/abcApi.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaWallet.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/index.js +4 -4
- package/dist/wallets/walletConnectors/chunk-3SVPZCA6.js +71 -0
- package/dist/wallets/walletConnectors/chunk-5QEUEPNY.js +94 -0
- package/dist/wallets/walletConnectors/chunk-B6JLYR3I.js +66 -0
- package/dist/wallets/walletConnectors/{chunk-6JKWIEGA.js → chunk-BHMMHU7Y.js} +1 -1
- package/dist/wallets/walletConnectors/chunk-HKWBR5B7.js +102 -0
- package/dist/wallets/walletConnectors/chunk-K4APJ4PE.js +96 -0
- package/dist/wallets/walletConnectors/chunk-LJ2B47VF.js +108 -0
- package/dist/wallets/walletConnectors/chunk-LXINMUQC.js +186 -0
- package/dist/wallets/walletConnectors/chunk-MORUEOYX.js +76 -0
- package/dist/wallets/walletConnectors/chunk-MQTXA63X.js +27 -0
- package/dist/wallets/walletConnectors/{chunk-G2IHR6PW.js → chunk-NLKL4KD2.js} +11 -11
- package/dist/wallets/walletConnectors/{chunk-KOT7JYJR.js → chunk-OEB7MRS5.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-RWIZ25FJ.js → chunk-P2E4LSYH.js} +17 -23
- package/dist/wallets/walletConnectors/chunk-PMZJGS7X.js +73 -0
- package/dist/wallets/walletConnectors/{chunk-BRM4ZVXZ.js → chunk-RSZS2RMC.js} +1 -1
- package/dist/wallets/walletConnectors/chunk-WZZVA3LW.js +101 -0
- package/dist/wallets/walletConnectors/chunk-XEIKWKH7.js +63 -0
- package/dist/wallets/walletConnectors/chunk-XOQNQKZE.js +98 -0
- package/dist/wallets/walletConnectors/chunk-ZAGAF6PO.js +63 -0
- package/dist/wallets/walletConnectors/chunk-ZJ6OFFD5.js +95 -0
- package/dist/wallets/walletConnectors/index.js +24 -24
- package/package.json +17 -11
- package/LICENSE +0 -9
- package/dist/wallets/walletConnectors/chunk-2J66VMY5.js +0 -152
- package/dist/wallets/walletConnectors/chunk-2ZPGPZCP.js +0 -228
- package/dist/wallets/walletConnectors/chunk-3DPCIDW6.js +0 -1730
- package/dist/wallets/walletConnectors/chunk-4HKJ53H3.js +0 -1742
- package/dist/wallets/walletConnectors/chunk-5EARL7FN.js +0 -39
- package/dist/wallets/walletConnectors/chunk-7SXCH5TL.js +0 -1752
- package/dist/wallets/walletConnectors/chunk-7UZBDZZZ.js +0 -599
- package/dist/wallets/walletConnectors/chunk-BUDWZAL7.js +0 -44
- package/dist/wallets/walletConnectors/chunk-CSWWNAYR.js +0 -44
- package/dist/wallets/walletConnectors/chunk-E4N7SPPU.js +0 -39
- package/dist/wallets/walletConnectors/chunk-ENU7XLF5.js +0 -44
- package/dist/wallets/walletConnectors/chunk-ESRU5KCF.js +0 -151
- package/dist/wallets/walletConnectors/chunk-FF7ZIXKD.js +0 -39
- package/dist/wallets/walletConnectors/chunk-FJCL2YPU.js +0 -1737
- package/dist/wallets/walletConnectors/chunk-FSU3WBH3.js +0 -63
- package/dist/wallets/walletConnectors/chunk-HD6YCICR.js +0 -228
- package/dist/wallets/walletConnectors/chunk-HDYBRMYW.js +0 -194
- package/dist/wallets/walletConnectors/chunk-HIZCIW5L.js +0 -228
- package/dist/wallets/walletConnectors/chunk-JRNBDHFL.js +0 -44
- package/dist/wallets/walletConnectors/chunk-KIQDE4N6.js +0 -39
- package/dist/wallets/walletConnectors/chunk-KZOSE2PI.js +0 -228
- package/dist/wallets/walletConnectors/chunk-LNZJLKFB.js +0 -39
- package/dist/wallets/walletConnectors/chunk-LV765WZL.js +0 -1748
- package/dist/wallets/walletConnectors/chunk-MSI2BPP5.js +0 -1722
- package/dist/wallets/walletConnectors/chunk-MX2IY5CD.js +0 -44
- package/dist/wallets/walletConnectors/chunk-NLX2EV7O.js +0 -44
- package/dist/wallets/walletConnectors/chunk-NVAZ3B3V.js +0 -228
- package/dist/wallets/walletConnectors/chunk-OEWU3ZMN.js +0 -39
- package/dist/wallets/walletConnectors/chunk-P2MTINFI.js +0 -280
- package/dist/wallets/walletConnectors/chunk-PNMSIVVT.js +0 -44
- package/dist/wallets/walletConnectors/chunk-PZNYT2HC.js +0 -1722
- package/dist/wallets/walletConnectors/chunk-QPAE4SDS.js +0 -39
- package/dist/wallets/walletConnectors/chunk-QZRNNI3E.js +0 -39
- package/dist/wallets/walletConnectors/chunk-R4UYVU5X.js +0 -1721
- package/dist/wallets/walletConnectors/chunk-RLBGBBIO.js +0 -309
- package/dist/wallets/walletConnectors/chunk-TUUNSVKZ.js +0 -345
- package/dist/wallets/walletConnectors/chunk-U2CUEL35.js +0 -240
- package/dist/wallets/walletConnectors/chunk-V6NRLREB.js +0 -44
- package/dist/wallets/walletConnectors/chunk-VM7AEC7H.js +0 -39
- package/dist/wallets/walletConnectors/chunk-W2VDZD74.js +0 -478
- package/dist/wallets/walletConnectors/chunk-WAO3KL5U.js +0 -285
- package/dist/wallets/walletConnectors/chunk-WPHTIILX.js +0 -228
- package/dist/wallets/walletConnectors/chunk-WSCJY2QD.js +0 -228
- package/dist/wallets/walletConnectors/chunk-X3JQB5QL.js +0 -44
- package/dist/wallets/walletConnectors/chunk-X4CDP7L7.js +0 -228
- package/dist/wallets/walletConnectors/chunk-XETOVXYM.js +0 -228
- package/dist/wallets/walletConnectors/chunk-XYPR4BAF.js +0 -436
- package/dist/wallets/walletConnectors/chunk-Z2ZRPTPX.js +0 -1726
- package/dist/wallets/walletConnectors/{chunk-VCBVYFLJ.js → chunk-6TLWAEJV.js} +7 -7
- package/dist/wallets/walletConnectors/{chunk-47TQ23J4.js → chunk-74ALNZG4.js} +8 -8
- package/dist/wallets/walletConnectors/{chunk-66SCJ77O.js → chunk-CM5OGUJV.js} +6 -6
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
WalletApi
|
|
4
|
-
} from "./chunk-ESRU5KCF.js";
|
|
5
|
-
import {
|
|
6
|
-
TransactionApi
|
|
7
|
-
} from "./chunk-HDYBRMYW.js";
|
|
8
|
-
import {
|
|
9
|
-
AuthApi
|
|
10
|
-
} from "./chunk-RLBGBBIO.js";
|
|
11
|
-
import {
|
|
12
|
-
SigningApi
|
|
13
|
-
} from "./chunk-TUUNSVKZ.js";
|
|
14
|
-
import {
|
|
15
|
-
BitcoinApi
|
|
16
|
-
} from "./chunk-7UZBDZZZ.js";
|
|
17
|
-
import {
|
|
18
|
-
SolanaApi
|
|
19
|
-
} from "./chunk-2J66VMY5.js";
|
|
20
|
-
|
|
21
|
-
// src/wallets/walletConnectors/abcWallet/api/index.ts
|
|
22
|
-
var AbcWaasApiClient = class {
|
|
23
|
-
constructor(config) {
|
|
24
|
-
this.auth = new AuthApi(config);
|
|
25
|
-
this.wallet = new WalletApi(config);
|
|
26
|
-
this.transaction = new TransactionApi(config);
|
|
27
|
-
this.signing = new SigningApi(config);
|
|
28
|
-
this.solana = new SolanaApi(config);
|
|
29
|
-
this.bitcoin = new BitcoinApi(config);
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Check if user is authenticated
|
|
33
|
-
*/
|
|
34
|
-
isAuthenticated() {
|
|
35
|
-
return this.auth.isAuthenticated();
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Check if access token is expired
|
|
39
|
-
*/
|
|
40
|
-
isTokenExpired() {
|
|
41
|
-
return this.auth.isTokenExpired();
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Get current access token
|
|
45
|
-
*/
|
|
46
|
-
getAccessToken() {
|
|
47
|
-
return this.auth.getAccessToken();
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Logout (clear tokens)
|
|
51
|
-
*/
|
|
52
|
-
async logout() {
|
|
53
|
-
await this.auth.logout();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
function createAbcWaasApiClient(config) {
|
|
57
|
-
return new AbcWaasApiClient(config);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export {
|
|
61
|
-
AbcWaasApiClient,
|
|
62
|
-
createAbcWaasApiClient
|
|
63
|
-
};
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
createAbcWaasClient
|
|
4
|
-
} from "./chunk-RWIZ25FJ.js";
|
|
5
|
-
import {
|
|
6
|
-
createAbcEvmProvider
|
|
7
|
-
} from "./chunk-73B7HWCT.js";
|
|
8
|
-
import {
|
|
9
|
-
clearAuthState,
|
|
10
|
-
clearEncryptedTokens,
|
|
11
|
-
loadAuthState,
|
|
12
|
-
saveAuthState
|
|
13
|
-
} from "./chunk-W23N7VC4.js";
|
|
14
|
-
|
|
15
|
-
// src/wallets/walletConnectors/abcWallet/abcConnector.ts
|
|
16
|
-
import { createConnector } from "wagmi";
|
|
17
|
-
function abcConnector(options) {
|
|
18
|
-
const { config } = options;
|
|
19
|
-
return createConnector((wagmiConfig) => {
|
|
20
|
-
const client = createAbcWaasClient(config);
|
|
21
|
-
const provider = createAbcEvmProvider(client);
|
|
22
|
-
let accountsChangedHandler;
|
|
23
|
-
let chainChangedHandler;
|
|
24
|
-
let disconnectHandler;
|
|
25
|
-
return {
|
|
26
|
-
id: "abc",
|
|
27
|
-
name: "ABC Wallet",
|
|
28
|
-
type: "abc",
|
|
29
|
-
/**
|
|
30
|
-
* Connect wallet
|
|
31
|
-
*/
|
|
32
|
-
async connect() {
|
|
33
|
-
try {
|
|
34
|
-
const authState = loadAuthState();
|
|
35
|
-
console.log("\u{1F527} ABC Connector connect() called:", {
|
|
36
|
-
hasAuthState: !!authState,
|
|
37
|
-
isAuthenticated: authState?.isAuthenticated,
|
|
38
|
-
hasWallet: !!authState?.wallet,
|
|
39
|
-
walletAddress: authState?.wallet?.address
|
|
40
|
-
});
|
|
41
|
-
if (!authState || !authState.isAuthenticated || !authState.wallet) {
|
|
42
|
-
throw new Error("ABC_LOGIN_REQUIRED");
|
|
43
|
-
}
|
|
44
|
-
provider.setWallet(authState.wallet);
|
|
45
|
-
console.log("\u2705 Provider wallet set:", {
|
|
46
|
-
address: authState.wallet.address,
|
|
47
|
-
hasPIN: !!authState.pin
|
|
48
|
-
});
|
|
49
|
-
const accounts = await provider.request({
|
|
50
|
-
method: "eth_requestAccounts"
|
|
51
|
-
});
|
|
52
|
-
const currentChainId = await provider.request({
|
|
53
|
-
method: "eth_chainId"
|
|
54
|
-
});
|
|
55
|
-
if (accountsChangedHandler) {
|
|
56
|
-
provider.removeListener("accountsChanged", accountsChangedHandler);
|
|
57
|
-
}
|
|
58
|
-
accountsChangedHandler = (accounts2) => {
|
|
59
|
-
wagmiConfig.emitter.emit("change", {
|
|
60
|
-
accounts: accounts2
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
provider.on("accountsChanged", accountsChangedHandler);
|
|
64
|
-
if (chainChangedHandler) {
|
|
65
|
-
provider.removeListener("chainChanged", chainChangedHandler);
|
|
66
|
-
}
|
|
67
|
-
chainChangedHandler = (chainId) => {
|
|
68
|
-
wagmiConfig.emitter.emit("change", {
|
|
69
|
-
chainId: Number(chainId)
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
provider.on("chainChanged", chainChangedHandler);
|
|
73
|
-
if (disconnectHandler) {
|
|
74
|
-
provider.removeListener("disconnect", disconnectHandler);
|
|
75
|
-
}
|
|
76
|
-
disconnectHandler = () => {
|
|
77
|
-
wagmiConfig.emitter.emit("disconnect");
|
|
78
|
-
this.onDisconnect();
|
|
79
|
-
};
|
|
80
|
-
provider.on("disconnect", disconnectHandler);
|
|
81
|
-
return {
|
|
82
|
-
accounts,
|
|
83
|
-
chainId: Number(currentChainId)
|
|
84
|
-
};
|
|
85
|
-
} catch (error) {
|
|
86
|
-
if (error.message === "ABC_LOGIN_REQUIRED") {
|
|
87
|
-
throw error;
|
|
88
|
-
}
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
/**
|
|
93
|
-
* Disconnect wallet
|
|
94
|
-
*/
|
|
95
|
-
async disconnect() {
|
|
96
|
-
if (accountsChangedHandler) {
|
|
97
|
-
provider.removeListener("accountsChanged", accountsChangedHandler);
|
|
98
|
-
accountsChangedHandler = void 0;
|
|
99
|
-
}
|
|
100
|
-
if (chainChangedHandler) {
|
|
101
|
-
provider.removeListener("chainChanged", chainChangedHandler);
|
|
102
|
-
chainChangedHandler = void 0;
|
|
103
|
-
}
|
|
104
|
-
if (disconnectHandler) {
|
|
105
|
-
provider.removeListener("disconnect", disconnectHandler);
|
|
106
|
-
disconnectHandler = void 0;
|
|
107
|
-
}
|
|
108
|
-
provider.clearWallet();
|
|
109
|
-
await client.logout();
|
|
110
|
-
let savedPinHash = null;
|
|
111
|
-
let savedEmail = null;
|
|
112
|
-
if (typeof window !== "undefined") {
|
|
113
|
-
savedPinHash = localStorage.getItem("talkenkit_abc_pin_hash");
|
|
114
|
-
savedEmail = localStorage.getItem("talkenkit_abc_saved_email");
|
|
115
|
-
}
|
|
116
|
-
clearAuthState();
|
|
117
|
-
clearEncryptedTokens();
|
|
118
|
-
if (typeof window !== "undefined") {
|
|
119
|
-
localStorage.removeItem("talkenkit_abc_enc_salt");
|
|
120
|
-
localStorage.removeItem("talkenkit_abc_enc_tokens");
|
|
121
|
-
if (savedPinHash) {
|
|
122
|
-
localStorage.setItem("talkenkit_abc_pin_hash", savedPinHash);
|
|
123
|
-
}
|
|
124
|
-
if (savedEmail) {
|
|
125
|
-
localStorage.setItem("talkenkit_abc_saved_email", savedEmail);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
console.log("\u2705 ABC Wallet disconnected (PIN preserved)");
|
|
129
|
-
},
|
|
130
|
-
/**
|
|
131
|
-
* Get accounts
|
|
132
|
-
*/
|
|
133
|
-
async getAccounts() {
|
|
134
|
-
const accounts = await provider.request({
|
|
135
|
-
method: "eth_accounts"
|
|
136
|
-
});
|
|
137
|
-
return accounts.map((account) => account);
|
|
138
|
-
},
|
|
139
|
-
/**
|
|
140
|
-
* Get chain ID
|
|
141
|
-
*/
|
|
142
|
-
async getChainId() {
|
|
143
|
-
const chainId = await provider.request({
|
|
144
|
-
method: "eth_chainId"
|
|
145
|
-
});
|
|
146
|
-
return Number(chainId);
|
|
147
|
-
},
|
|
148
|
-
/**
|
|
149
|
-
* Get provider
|
|
150
|
-
*/
|
|
151
|
-
async getProvider() {
|
|
152
|
-
return provider;
|
|
153
|
-
},
|
|
154
|
-
/**
|
|
155
|
-
* Check if authorized (has valid session)
|
|
156
|
-
*/
|
|
157
|
-
async isAuthorized() {
|
|
158
|
-
try {
|
|
159
|
-
const authState = loadAuthState();
|
|
160
|
-
if (!authState || !authState.isAuthenticated) {
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
return client.isAuthenticated();
|
|
164
|
-
} catch {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
/**
|
|
169
|
-
* Switch chain
|
|
170
|
-
*/
|
|
171
|
-
async switchChain({ chainId }) {
|
|
172
|
-
await provider.request({
|
|
173
|
-
method: "wallet_switchEthereumChain",
|
|
174
|
-
params: [{ chainId: `0x${chainId.toString(16)}` }]
|
|
175
|
-
});
|
|
176
|
-
const newChainId = await this.getChainId();
|
|
177
|
-
const authState = loadAuthState();
|
|
178
|
-
if (authState?.wallet) {
|
|
179
|
-
authState.wallet.chainId = newChainId;
|
|
180
|
-
saveAuthState(authState);
|
|
181
|
-
}
|
|
182
|
-
return wagmiConfig.chains.find((x) => x.id === chainId) ?? {
|
|
183
|
-
id: chainId,
|
|
184
|
-
name: `Chain ${chainId}`,
|
|
185
|
-
nativeCurrency: {
|
|
186
|
-
name: "Ether",
|
|
187
|
-
decimals: 18,
|
|
188
|
-
symbol: "ETH"
|
|
189
|
-
},
|
|
190
|
-
rpcUrls: {
|
|
191
|
-
default: { http: [""] }
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
},
|
|
195
|
-
/**
|
|
196
|
-
* Handle accounts changed
|
|
197
|
-
*/
|
|
198
|
-
onAccountsChanged(accounts) {
|
|
199
|
-
if (accounts.length === 0) {
|
|
200
|
-
this.onDisconnect();
|
|
201
|
-
} else {
|
|
202
|
-
wagmiConfig.emitter.emit("change", {
|
|
203
|
-
accounts
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
/**
|
|
208
|
-
* Handle chain changed
|
|
209
|
-
*/
|
|
210
|
-
onChainChanged(chain) {
|
|
211
|
-
const chainId = Number(chain);
|
|
212
|
-
wagmiConfig.emitter.emit("change", { chainId });
|
|
213
|
-
},
|
|
214
|
-
/**
|
|
215
|
-
* Handle disconnect
|
|
216
|
-
*/
|
|
217
|
-
onDisconnect(_error) {
|
|
218
|
-
provider.clearWallet();
|
|
219
|
-
clearAuthState();
|
|
220
|
-
wagmiConfig.emitter.emit("disconnect");
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export {
|
|
227
|
-
abcConnector
|
|
228
|
-
};
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
BaseApiClient
|
|
4
|
-
} from "./chunk-WAO3KL5U.js";
|
|
5
|
-
import {
|
|
6
|
-
createAbcError
|
|
7
|
-
} from "./chunk-W2VDZD74.js";
|
|
8
|
-
|
|
9
|
-
// src/wallets/walletConnectors/abcWallet/api/TransactionApi.ts
|
|
10
|
-
var TransactionApi = class extends BaseApiClient {
|
|
11
|
-
/**
|
|
12
|
-
* Send raw transaction
|
|
13
|
-
*/
|
|
14
|
-
async sendRawTransaction(chainId, signedTransaction) {
|
|
15
|
-
const network = this.getNetworkName(chainId);
|
|
16
|
-
const secureChannelId = await this.secure.getSecureChannelId();
|
|
17
|
-
const bodyData = {
|
|
18
|
-
signedSerializeTx: signedTransaction,
|
|
19
|
-
network
|
|
20
|
-
};
|
|
21
|
-
const bodyString = new URLSearchParams(bodyData).toString();
|
|
22
|
-
const url = "${this.baseURL}${ABC_ENDPOINTS.SEND_RAW_TX}";
|
|
23
|
-
const response = await fetch(url, {
|
|
24
|
-
method: "POST",
|
|
25
|
-
headers: {
|
|
26
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
27
|
-
"Secure-Channel": secureChannelId,
|
|
28
|
-
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
29
|
-
},
|
|
30
|
-
body: bodyString
|
|
31
|
-
});
|
|
32
|
-
const text = await response.text();
|
|
33
|
-
if (!text) {
|
|
34
|
-
throw createAbcError(
|
|
35
|
-
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
36
|
-
"Empty response from sendRawTx API (status: ${response.status})",
|
|
37
|
-
{ status: response.status }
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
const res = JSON.parse(text);
|
|
41
|
-
if (response.status === 401 && this.refreshToken) {
|
|
42
|
-
try {
|
|
43
|
-
await this.refreshAccessToken();
|
|
44
|
-
const retryResponse = await fetch(url, {
|
|
45
|
-
method: "POST",
|
|
46
|
-
headers: {
|
|
47
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
48
|
-
"Secure-Channel": secureChannelId,
|
|
49
|
-
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
50
|
-
},
|
|
51
|
-
body: bodyString
|
|
52
|
-
});
|
|
53
|
-
const retryText = await retryResponse.text();
|
|
54
|
-
if (!retryText) {
|
|
55
|
-
throw createAbcError(
|
|
56
|
-
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
57
|
-
"Empty response after retry (status: ${retryResponse.status})",
|
|
58
|
-
{ status: retryResponse.status }
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
const retryRes = JSON.parse(retryText);
|
|
62
|
-
if (retryRes.item || retryRes.txHash || retryRes.result?.txHash) {
|
|
63
|
-
const txHash = retryRes.item || retryRes.txHash || retryRes.result.txHash;
|
|
64
|
-
return { txHash };
|
|
65
|
-
}
|
|
66
|
-
throw createAbcError(
|
|
67
|
-
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
68
|
-
"Failed to send transaction after token refresh",
|
|
69
|
-
retryRes
|
|
70
|
-
);
|
|
71
|
-
} catch (refreshError) {
|
|
72
|
-
console.error(
|
|
73
|
-
"Token refresh failed in sendRawTransaction:",
|
|
74
|
-
refreshError
|
|
75
|
-
);
|
|
76
|
-
throw refreshError;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (res.result) {
|
|
80
|
-
if (typeof res.result === "string") {
|
|
81
|
-
return { txHash: res.result };
|
|
82
|
-
}
|
|
83
|
-
if (res.result.txHash) {
|
|
84
|
-
return { txHash: res.result.txHash };
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (res.item) {
|
|
88
|
-
return { txHash: res.item };
|
|
89
|
-
}
|
|
90
|
-
if (res.txHash) {
|
|
91
|
-
return { txHash: res.txHash };
|
|
92
|
-
}
|
|
93
|
-
throw createAbcError(
|
|
94
|
-
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
95
|
-
"Failed to send transaction",
|
|
96
|
-
res
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Get transaction count (nonce)
|
|
101
|
-
*/
|
|
102
|
-
async getTransactionCount(_address, _network, _block = "latest") {
|
|
103
|
-
const nonceUrl = "${this.baseURL}${ABC_ENDPOINTS.TRANSACTION_COUNT}?address=${address}&network=${network}&block=${block}";
|
|
104
|
-
const response = await fetch(nonceUrl, {
|
|
105
|
-
method: "GET",
|
|
106
|
-
headers: {
|
|
107
|
-
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
if (response.ok) {
|
|
111
|
-
const data = await response.json();
|
|
112
|
-
return Number.parseInt(data.result, 16);
|
|
113
|
-
}
|
|
114
|
-
throw createAbcError(
|
|
115
|
-
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
116
|
-
"Failed to get transaction count"
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Get suggested gas fees for EIP-1559
|
|
121
|
-
*/
|
|
122
|
-
async getSuggestedGasFees(_network) {
|
|
123
|
-
const url = "${this.baseURL}${ABC_ENDPOINTS.GAS_SUGGESTED_FEES}?network=${network}";
|
|
124
|
-
const response = await fetch(url, {
|
|
125
|
-
method: "GET",
|
|
126
|
-
headers: {
|
|
127
|
-
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
if (response.ok) {
|
|
131
|
-
const data = await response.json();
|
|
132
|
-
return data;
|
|
133
|
-
}
|
|
134
|
-
throw createAbcError(
|
|
135
|
-
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
136
|
-
"Failed to get suggested gas fees"
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Estimate gas limit for EIP-1559 transaction
|
|
141
|
-
*/
|
|
142
|
-
async estimateGas(params) {
|
|
143
|
-
const estimateBody = new URLSearchParams({
|
|
144
|
-
network: params.network,
|
|
145
|
-
to: params.to || "0x",
|
|
146
|
-
...params.from ? { from: params.from } : {},
|
|
147
|
-
...params.value ? { value: params.value } : {},
|
|
148
|
-
...params.data && params.data !== "0x" ? { data: params.data } : {},
|
|
149
|
-
...params.maxFeePerGas ? { maxFeePerGas: params.maxFeePerGas } : {},
|
|
150
|
-
...params.maxPriorityFeePerGas ? { maxPriorityFeePerGas: params.maxPriorityFeePerGas } : {}
|
|
151
|
-
});
|
|
152
|
-
const url = "${this.baseURL}${ABC_ENDPOINTS.GAS_ESTIMATE_EIP1559}";
|
|
153
|
-
const response = await fetch(url, {
|
|
154
|
-
method: "POST",
|
|
155
|
-
headers: {
|
|
156
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
157
|
-
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
158
|
-
},
|
|
159
|
-
body: estimateBody.toString()
|
|
160
|
-
});
|
|
161
|
-
const data = await response.json();
|
|
162
|
-
if (response.ok && data.result) {
|
|
163
|
-
return data.result;
|
|
164
|
-
}
|
|
165
|
-
const fallbackGasLimit = "0x2dc6c0";
|
|
166
|
-
console.warn("\u26A0\uFE0F Gas estimate failed, using fallback:", {
|
|
167
|
-
error: data.errorMessage || data.msg,
|
|
168
|
-
fallbackGasLimit
|
|
169
|
-
});
|
|
170
|
-
return fallbackGasLimit;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Convert chainId to network name
|
|
174
|
-
*/
|
|
175
|
-
getNetworkName(chainId) {
|
|
176
|
-
const networkMap = {
|
|
177
|
-
1: "ethereum",
|
|
178
|
-
11155111: "ethereum_sepolia",
|
|
179
|
-
8217: "klaytn",
|
|
180
|
-
1001: "klaytn_baobab",
|
|
181
|
-
137: "polygon",
|
|
182
|
-
80002: "polygon_amoy",
|
|
183
|
-
42161: "arbitrum",
|
|
184
|
-
421614: "arbitrum_sepolia",
|
|
185
|
-
5e3: "mantle",
|
|
186
|
-
5003: "mantle_testnet"
|
|
187
|
-
};
|
|
188
|
-
return networkMap[chainId] || "ethereum";
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
export {
|
|
193
|
-
TransactionApi
|
|
194
|
-
};
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import {
|
|
3
|
-
createAbcWaasClient
|
|
4
|
-
} from "./chunk-MSI2BPP5.js";
|
|
5
|
-
import {
|
|
6
|
-
createAbcEvmProvider
|
|
7
|
-
} from "./chunk-73B7HWCT.js";
|
|
8
|
-
import {
|
|
9
|
-
clearAuthState,
|
|
10
|
-
clearEncryptedTokens,
|
|
11
|
-
loadAuthState,
|
|
12
|
-
saveAuthState
|
|
13
|
-
} from "./chunk-W23N7VC4.js";
|
|
14
|
-
|
|
15
|
-
// src/wallets/walletConnectors/abcWallet/abcConnector.ts
|
|
16
|
-
import { createConnector } from "wagmi";
|
|
17
|
-
function abcConnector(options) {
|
|
18
|
-
const { config } = options;
|
|
19
|
-
return createConnector((wagmiConfig) => {
|
|
20
|
-
const client = createAbcWaasClient(config);
|
|
21
|
-
const provider = createAbcEvmProvider(client);
|
|
22
|
-
let accountsChangedHandler;
|
|
23
|
-
let chainChangedHandler;
|
|
24
|
-
let disconnectHandler;
|
|
25
|
-
return {
|
|
26
|
-
id: "abc",
|
|
27
|
-
name: "ABC Wallet",
|
|
28
|
-
type: "abc",
|
|
29
|
-
/**
|
|
30
|
-
* Connect wallet
|
|
31
|
-
*/
|
|
32
|
-
async connect() {
|
|
33
|
-
try {
|
|
34
|
-
const authState = loadAuthState();
|
|
35
|
-
console.log("\u{1F527} ABC Connector connect() called:", {
|
|
36
|
-
hasAuthState: !!authState,
|
|
37
|
-
isAuthenticated: authState?.isAuthenticated,
|
|
38
|
-
hasWallet: !!authState?.wallet,
|
|
39
|
-
walletAddress: authState?.wallet?.address
|
|
40
|
-
});
|
|
41
|
-
if (!authState || !authState.isAuthenticated || !authState.wallet) {
|
|
42
|
-
throw new Error("ABC_LOGIN_REQUIRED");
|
|
43
|
-
}
|
|
44
|
-
provider.setWallet(authState.wallet);
|
|
45
|
-
console.log("\u2705 Provider wallet set:", {
|
|
46
|
-
address: authState.wallet.address,
|
|
47
|
-
hasPIN: !!authState.pin
|
|
48
|
-
});
|
|
49
|
-
const accounts = await provider.request({
|
|
50
|
-
method: "eth_requestAccounts"
|
|
51
|
-
});
|
|
52
|
-
const currentChainId = await provider.request({
|
|
53
|
-
method: "eth_chainId"
|
|
54
|
-
});
|
|
55
|
-
if (accountsChangedHandler) {
|
|
56
|
-
provider.removeListener("accountsChanged", accountsChangedHandler);
|
|
57
|
-
}
|
|
58
|
-
accountsChangedHandler = (accounts2) => {
|
|
59
|
-
wagmiConfig.emitter.emit("change", {
|
|
60
|
-
accounts: accounts2
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
provider.on("accountsChanged", accountsChangedHandler);
|
|
64
|
-
if (chainChangedHandler) {
|
|
65
|
-
provider.removeListener("chainChanged", chainChangedHandler);
|
|
66
|
-
}
|
|
67
|
-
chainChangedHandler = (chainId) => {
|
|
68
|
-
wagmiConfig.emitter.emit("change", {
|
|
69
|
-
chainId: Number(chainId)
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
provider.on("chainChanged", chainChangedHandler);
|
|
73
|
-
if (disconnectHandler) {
|
|
74
|
-
provider.removeListener("disconnect", disconnectHandler);
|
|
75
|
-
}
|
|
76
|
-
disconnectHandler = () => {
|
|
77
|
-
wagmiConfig.emitter.emit("disconnect");
|
|
78
|
-
this.onDisconnect();
|
|
79
|
-
};
|
|
80
|
-
provider.on("disconnect", disconnectHandler);
|
|
81
|
-
return {
|
|
82
|
-
accounts,
|
|
83
|
-
chainId: Number(currentChainId)
|
|
84
|
-
};
|
|
85
|
-
} catch (error) {
|
|
86
|
-
if (error.message === "ABC_LOGIN_REQUIRED") {
|
|
87
|
-
throw error;
|
|
88
|
-
}
|
|
89
|
-
throw error;
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
/**
|
|
93
|
-
* Disconnect wallet
|
|
94
|
-
*/
|
|
95
|
-
async disconnect() {
|
|
96
|
-
if (accountsChangedHandler) {
|
|
97
|
-
provider.removeListener("accountsChanged", accountsChangedHandler);
|
|
98
|
-
accountsChangedHandler = void 0;
|
|
99
|
-
}
|
|
100
|
-
if (chainChangedHandler) {
|
|
101
|
-
provider.removeListener("chainChanged", chainChangedHandler);
|
|
102
|
-
chainChangedHandler = void 0;
|
|
103
|
-
}
|
|
104
|
-
if (disconnectHandler) {
|
|
105
|
-
provider.removeListener("disconnect", disconnectHandler);
|
|
106
|
-
disconnectHandler = void 0;
|
|
107
|
-
}
|
|
108
|
-
provider.clearWallet();
|
|
109
|
-
await client.logout();
|
|
110
|
-
let savedPinHash = null;
|
|
111
|
-
let savedEmail = null;
|
|
112
|
-
if (typeof window !== "undefined") {
|
|
113
|
-
savedPinHash = localStorage.getItem("talkenkit_abc_pin_hash");
|
|
114
|
-
savedEmail = localStorage.getItem("talkenkit_abc_saved_email");
|
|
115
|
-
}
|
|
116
|
-
clearAuthState();
|
|
117
|
-
clearEncryptedTokens();
|
|
118
|
-
if (typeof window !== "undefined") {
|
|
119
|
-
localStorage.removeItem("talkenkit_abc_enc_salt");
|
|
120
|
-
localStorage.removeItem("talkenkit_abc_enc_tokens");
|
|
121
|
-
if (savedPinHash) {
|
|
122
|
-
localStorage.setItem("talkenkit_abc_pin_hash", savedPinHash);
|
|
123
|
-
}
|
|
124
|
-
if (savedEmail) {
|
|
125
|
-
localStorage.setItem("talkenkit_abc_saved_email", savedEmail);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
console.log("\u2705 ABC Wallet disconnected (PIN preserved)");
|
|
129
|
-
},
|
|
130
|
-
/**
|
|
131
|
-
* Get accounts
|
|
132
|
-
*/
|
|
133
|
-
async getAccounts() {
|
|
134
|
-
const accounts = await provider.request({
|
|
135
|
-
method: "eth_accounts"
|
|
136
|
-
});
|
|
137
|
-
return accounts.map((account) => account);
|
|
138
|
-
},
|
|
139
|
-
/**
|
|
140
|
-
* Get chain ID
|
|
141
|
-
*/
|
|
142
|
-
async getChainId() {
|
|
143
|
-
const chainId = await provider.request({
|
|
144
|
-
method: "eth_chainId"
|
|
145
|
-
});
|
|
146
|
-
return Number(chainId);
|
|
147
|
-
},
|
|
148
|
-
/**
|
|
149
|
-
* Get provider
|
|
150
|
-
*/
|
|
151
|
-
async getProvider() {
|
|
152
|
-
return provider;
|
|
153
|
-
},
|
|
154
|
-
/**
|
|
155
|
-
* Check if authorized (has valid session)
|
|
156
|
-
*/
|
|
157
|
-
async isAuthorized() {
|
|
158
|
-
try {
|
|
159
|
-
const authState = loadAuthState();
|
|
160
|
-
if (!authState || !authState.isAuthenticated) {
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
return client.isAuthenticated();
|
|
164
|
-
} catch {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
/**
|
|
169
|
-
* Switch chain
|
|
170
|
-
*/
|
|
171
|
-
async switchChain({ chainId }) {
|
|
172
|
-
await provider.request({
|
|
173
|
-
method: "wallet_switchEthereumChain",
|
|
174
|
-
params: [{ chainId: `0x${chainId.toString(16)}` }]
|
|
175
|
-
});
|
|
176
|
-
const newChainId = await this.getChainId();
|
|
177
|
-
const authState = loadAuthState();
|
|
178
|
-
if (authState?.wallet) {
|
|
179
|
-
authState.wallet.chainId = newChainId;
|
|
180
|
-
saveAuthState(authState);
|
|
181
|
-
}
|
|
182
|
-
return wagmiConfig.chains.find((x) => x.id === chainId) ?? {
|
|
183
|
-
id: chainId,
|
|
184
|
-
name: `Chain ${chainId}`,
|
|
185
|
-
nativeCurrency: {
|
|
186
|
-
name: "Ether",
|
|
187
|
-
decimals: 18,
|
|
188
|
-
symbol: "ETH"
|
|
189
|
-
},
|
|
190
|
-
rpcUrls: {
|
|
191
|
-
default: { http: [""] }
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
},
|
|
195
|
-
/**
|
|
196
|
-
* Handle accounts changed
|
|
197
|
-
*/
|
|
198
|
-
onAccountsChanged(accounts) {
|
|
199
|
-
if (accounts.length === 0) {
|
|
200
|
-
this.onDisconnect();
|
|
201
|
-
} else {
|
|
202
|
-
wagmiConfig.emitter.emit("change", {
|
|
203
|
-
accounts
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
/**
|
|
208
|
-
* Handle chain changed
|
|
209
|
-
*/
|
|
210
|
-
onChainChanged(chain) {
|
|
211
|
-
const chainId = Number(chain);
|
|
212
|
-
wagmiConfig.emitter.emit("change", { chainId });
|
|
213
|
-
},
|
|
214
|
-
/**
|
|
215
|
-
* Handle disconnect
|
|
216
|
-
*/
|
|
217
|
-
onDisconnect(_error) {
|
|
218
|
-
provider.clearWallet();
|
|
219
|
-
clearAuthState();
|
|
220
|
-
wagmiConfig.emitter.emit("disconnect");
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export {
|
|
227
|
-
abcConnector
|
|
228
|
-
};
|