@talken/talkenkit 2.4.4 → 2.4.6
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/Arc-YV22FANA.js +8 -0
- package/dist/Brave-VWDHFYI5.js +8 -0
- package/dist/Browser-2ZOVSFMK.js +8 -0
- package/dist/Chrome-VL7CYHGL.js +8 -0
- package/dist/Edge-6GQGEL5X.js +8 -0
- package/dist/Firefox-SY6PCZK3.js +8 -0
- package/dist/Linux-OP3H6PHU.js +8 -0
- package/dist/Macos-ZENZDYKP.js +8 -0
- package/dist/Opera-H2VDEHSS.js +8 -0
- package/dist/Safari-5BYQNFM3.js +8 -0
- package/dist/Windows-PHGTMIC7.js +8 -0
- package/dist/abcWallet-3CKLCZZC.js +184 -0
- package/dist/abcWallet-6M2KDUY5.js +184 -0
- package/dist/abcWallet-BUUIREII.js +184 -0
- package/dist/abcWallet-H4S47MXU.js +184 -0
- package/dist/abcWallet-KBANX52Y.js +8 -0
- package/dist/abcWallet-KWKFWA2B.js +184 -0
- package/dist/abcWallet-LSRIJG4P.js +184 -0
- package/dist/abcWallet-UHMZ3SBV.js +184 -0
- package/dist/abcWallet-VSM7O7LO.js +184 -0
- package/dist/abcWallet-X2GWIVEI.js +184 -0
- package/dist/abcWallet-X7NZ6VBW.js +180 -0
- package/dist/ar_AR-MAB4J7H2.js +8 -0
- package/dist/arbitrum-27LBECSN.js +8 -0
- package/dist/argentWallet-GX5VSJWF.js +8 -0
- package/dist/assets-GIFIMHMU.js +8 -0
- package/dist/avalanche-KSIA64PC.js +8 -0
- package/dist/base-SIBF7BBU.js +8 -0
- package/dist/berasigWallet-JO4Q4MSU.js +8 -0
- package/dist/bestWallet-LTW5DIP4.js +8 -0
- package/dist/bifrostWallet-JL6ZAC3C.js +8 -0
- package/dist/binanceWallet-ZNNDYS5Q.js +8 -0
- package/dist/bitgetWallet-A4DL5PUY.js +8 -0
- package/dist/bitskiWallet-274FSC74.js +8 -0
- package/dist/bitverseWallet-7DVG7NHE.js +8 -0
- package/dist/blast-RE46OGNS.js +8 -0
- package/dist/bloomWallet-DOYLILHG.js +8 -0
- package/dist/braveWallet-YZYG53SC.js +8 -0
- package/dist/bsc-LKNCKWB7.js +8 -0
- package/dist/bybitWallet-SZ7ZIJOM.js +8 -0
- package/dist/celo-3UGAQ3FA.js +8 -0
- package/dist/chunk-5524HDQP.js +6817 -0
- package/dist/chunk-A73PPSQU.js +6842 -0
- package/dist/chunk-AIBVBASK.js +35 -0
- package/dist/chunk-DFWCI4QG.js +326 -0
- package/dist/chunk-EGN5IX3Q.js +6817 -0
- package/dist/chunk-HSRSDVH7.js +6817 -0
- package/dist/chunk-IAY4522B.js +6894 -0
- package/dist/chunk-J6OAJTP7.js +6818 -0
- package/dist/chunk-JSDMSWIV.js +6631 -0
- package/dist/chunk-JSDVJD3R.js +6834 -0
- package/dist/chunk-L46ONWXN.js +6880 -0
- package/dist/chunk-OJUAVARC.js +6880 -0
- package/dist/clvWallet-AW3FLKWV.js +8 -0
- package/dist/coin98Wallet-O6REX7DQ.js +8 -0
- package/dist/coinbaseWallet-LVQLZHBK.js +8 -0
- package/dist/compassWallet-65OSMTR2.js +8 -0
- package/dist/config/networks.d.ts +15 -0
- package/dist/connect-CICKFS4L.js +8 -0
- package/dist/coreWallet-YSDA53EY.js +8 -0
- package/dist/create-5SJIEM24.js +8 -0
- package/dist/cronos-ZQWFYR7X.js +8 -0
- package/dist/dawnWallet-J36CF4FH.js +8 -0
- package/dist/de_DE-EG7KMNLA.js +8 -0
- package/dist/desigWallet-XGQ7234L.js +8 -0
- package/dist/en_US-FB5NGCIS.js +8 -0
- package/dist/enkryptWallet-ROHOLP4S.js +8 -0
- package/dist/es_419-3B34TR7B.js +8 -0
- package/dist/ethereum-EQ5JF37Q.js +8 -0
- package/dist/flow-SZDAO7RI.js +8 -0
- package/dist/foxWallet-3N4ERZ2Y.js +8 -0
- package/dist/fr_FR-R75UI3J6.js +1356 -0
- package/dist/frameWallet-AIE2VFHW.js +8 -0
- package/dist/frontierWallet-VZSDJHLV.js +8 -0
- package/dist/gateWallet-T2EK3VMK.js +8 -0
- package/dist/gnosis-JNLUBWJA.js +8 -0
- package/dist/hardhat-ZXHXXZ4F.js +8 -0
- package/dist/hi_IN-UE2ZBDLM.js +8 -0
- package/dist/hooks/useBitcoinWallet.d.ts +64 -0
- package/dist/hooks/useSolanaWallet.d.ts +86 -0
- package/dist/id_ID-WQSMTXEJ.js +8 -0
- package/dist/imTokenWallet-EZIOYBYU.js +8 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +10411 -14542
- package/dist/injectedWallet-AKTBXQHX.js +8 -0
- package/dist/iopayWallet-W7H23ECM.js +8 -0
- package/dist/ja_JP-O4XT7PNY.js +8 -0
- package/dist/kaia-LDZMGDTS.js +8 -0
- package/dist/kaiaWallet-IIGUMKV2.js +8 -0
- package/dist/kaikasWallet-XFICIF6T.js +8 -0
- package/dist/ko_KR-7DRM32ZL.js +8 -0
- package/dist/krakenWallet-JQX7ML3V.js +8 -0
- package/dist/kresusWallet-X76YOSCS.js +8 -0
- package/dist/ledgerWallet-LUOIK2NO.js +8 -0
- package/dist/login-L2V76XPP.js +8 -0
- package/dist/magicEden-PNA2N7LE.js +8 -0
- package/dist/manta-AXWSHRGV.js +8 -0
- package/dist/mantle-I27DZFXF.js +8 -0
- package/dist/metaMaskWallet-ZOW7SFN3.js +8 -0
- package/dist/mewWallet-NNOKYJGO.js +8 -0
- package/dist/ms_MY-QJAJAMMS.js +8 -0
- package/dist/nestWallet-PJ4UAPAM.js +8 -0
- package/dist/oktoWallet-IPI4NUPS.js +8 -0
- package/dist/okxWallet-BKIE62N5.js +8 -0
- package/dist/omniWallet-5MXTZQTD.js +8 -0
- package/dist/oneInchWallet-SUMUIBDE.js +8 -0
- package/dist/oneKeyWallet-W7XOJBFP.js +8 -0
- package/dist/optimism-7KW4YXCD.js +8 -0
- package/dist/paraSwapWallet-O7YFTXSA.js +8 -0
- package/dist/phantomWallet-JL7CK5LT.js +8 -0
- package/dist/polygon-O6VNIW2F.js +8 -0
- package/dist/pt_BR-CUVZKVMO.js +8 -0
- package/dist/rabbyWallet-QZAAFNR5.js +8 -0
- package/dist/rainbowWallet-3H5RIOTG.js +8 -0
- package/dist/ramperWallet-PADEB35A.js +8 -0
- package/dist/refresh-HBSYGKAX.js +8 -0
- package/dist/ronin-NIBR3M4Q.js +8 -0
- package/dist/roninWallet-VBWRYBSY.js +8 -0
- package/dist/ru_RU-DLZ46RWL.js +1356 -0
- package/dist/safeWallet-5S6VLRXL.js +8 -0
- package/dist/safeheronWallet-PK6H4FAC.js +8 -0
- package/dist/safepalWallet-OG53AE3J.js +8 -0
- package/dist/scan-QFKMQ54Z.js +8 -0
- package/dist/scroll-7LCBO5E3.js +8 -0
- package/dist/secure-4HM7LOQ7.js +8 -0
- package/dist/secure-I6UQYL5P.js +8 -0
- package/dist/seifWallet-W5POSWSQ.js +8 -0
- package/dist/sign-TGZ6C3LW.js +8 -0
- package/dist/solana/AbcSolanaAutoConnector.d.ts +6 -3
- package/dist/solana/index.d.ts +1 -0
- package/dist/solana/recentSolanaWalletIds.d.ts +22 -0
- package/dist/subWallet-EMI73DDU.js +8 -0
- package/dist/tahoWallet-BI5WGGIE.js +8 -0
- package/dist/talismanWallet-FSJ7PIII.js +8 -0
- package/dist/th_TH-AXZSCUYS.js +1356 -0
- package/dist/tokenPocketWallet-24CJ7CMD.js +8 -0
- package/dist/tokenaryWallet-253RCSOV.js +8 -0
- package/dist/tr_TR-WUMEEWNJ.js +1356 -0
- package/dist/trustWallet-2I5U2KE2.js +8 -0
- package/dist/uk_UA-BVWUMQ6Z.js +1356 -0
- package/dist/uniswapWallet-G4F52I6Y.js +8 -0
- package/dist/valoraWallet-JEACHQB4.js +8 -0
- package/dist/vi_VN-AI2OTA4F.js +8 -0
- package/dist/walletConnectWallet-NRHPTNNN.js +8 -0
- package/dist/wallets/walletConnectors/abcWallet/abcApi.js +4 -3
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +6 -5
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.d.ts +83 -0
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +9 -0
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.js +6 -5
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +7 -6
- package/dist/wallets/walletConnectors/abcWallet/api/AuthApi.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/BaseApiClient.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/api/BitcoinApi.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/SigningApi.d.ts +0 -4
- package/dist/wallets/walletConnectors/abcWallet/api/SigningApi.js +5 -4
- package/dist/wallets/walletConnectors/abcWallet/api/SolanaApi.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/TransactionApi.d.ts +0 -4
- package/dist/wallets/walletConnectors/abcWallet/api/TransactionApi.js +5 -4
- package/dist/wallets/walletConnectors/abcWallet/api/WalletApi.js +4 -4
- package/dist/wallets/walletConnectors/abcWallet/api/index.js +13 -12
- package/dist/wallets/walletConnectors/abcWallet/index.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/index.js +26 -19
- package/dist/wallets/walletConnectors/abcWallet/utils.js +2 -2
- package/dist/wallets/walletConnectors/chunk-2HAU36T2.js +330 -0
- package/dist/wallets/walletConnectors/chunk-2QBCWLD2.js +207 -0
- package/dist/wallets/walletConnectors/chunk-3SVPZCA6.js +71 -0
- package/dist/wallets/walletConnectors/chunk-4PCVQBFZ.js +667 -0
- package/dist/wallets/walletConnectors/chunk-4RMNGZR2.js +253 -0
- package/dist/wallets/walletConnectors/chunk-4SAGH6IS.js +63 -0
- package/dist/wallets/walletConnectors/chunk-57YTMSPW.js +63 -0
- package/dist/wallets/walletConnectors/chunk-5QEUEPNY.js +94 -0
- package/dist/wallets/walletConnectors/chunk-664WS6CQ.js +267 -0
- package/dist/wallets/walletConnectors/chunk-6MSXHRIK.js +47 -0
- package/dist/wallets/walletConnectors/chunk-7VZDITAJ.js +330 -0
- package/dist/wallets/walletConnectors/chunk-AGC7JS5M.js +47 -0
- package/dist/wallets/walletConnectors/chunk-B56IHEUP.js +179 -0
- package/dist/wallets/walletConnectors/chunk-B6JLYR3I.js +66 -0
- package/dist/wallets/walletConnectors/chunk-CMJ4DIIQ.js +63 -0
- package/dist/wallets/walletConnectors/chunk-DCW43Y5T.js +190 -0
- package/dist/wallets/walletConnectors/chunk-DJKN2MCI.js +179 -0
- package/dist/wallets/walletConnectors/chunk-F5BORFRG.js +63 -0
- package/dist/wallets/walletConnectors/chunk-FEUW4SKR.js +63 -0
- package/dist/wallets/walletConnectors/chunk-FKPSLKA7.js +63 -0
- package/dist/wallets/walletConnectors/chunk-FTGER5ZB.js +196 -0
- package/dist/wallets/walletConnectors/chunk-GYJYTYIG.js +63 -0
- package/dist/wallets/walletConnectors/chunk-GZFBNALD.js +47 -0
- package/dist/wallets/walletConnectors/chunk-HJFZF4V3.js +276 -0
- package/dist/wallets/walletConnectors/chunk-HKWBR5B7.js +102 -0
- package/dist/wallets/walletConnectors/chunk-IKAN72JZ.js +253 -0
- package/dist/wallets/walletConnectors/chunk-JH2SJPEY.js +63 -0
- package/dist/wallets/walletConnectors/chunk-K4APJ4PE.js +96 -0
- package/dist/wallets/walletConnectors/chunk-KKCRCQNN.js +276 -0
- package/dist/wallets/walletConnectors/chunk-KLQJJI76.js +215 -0
- package/dist/wallets/walletConnectors/chunk-LJ2B47VF.js +108 -0
- package/dist/wallets/walletConnectors/chunk-LQWC2NEM.js +63 -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-NUAZNCMH.js +1590 -0
- package/dist/wallets/walletConnectors/chunk-ODL6WVZK.js +63 -0
- package/dist/wallets/walletConnectors/chunk-OJMVWBYG.js +191 -0
- package/dist/wallets/walletConnectors/chunk-PGMVGAXJ.js +63 -0
- package/dist/wallets/walletConnectors/chunk-PMZJGS7X.js +73 -0
- package/dist/wallets/walletConnectors/chunk-QELXKYHW.js +196 -0
- package/dist/wallets/walletConnectors/chunk-T3KJ4NFX.js +276 -0
- package/dist/wallets/walletConnectors/chunk-URJDAG63.js +190 -0
- package/dist/wallets/walletConnectors/chunk-WZZVA3LW.js +101 -0
- package/dist/wallets/walletConnectors/chunk-XOQNQKZE.js +98 -0
- package/dist/wallets/walletConnectors/chunk-YX4O33NC.js +1590 -0
- package/dist/wallets/walletConnectors/chunk-ZG4ZZVOW.js +63 -0
- package/dist/wallets/walletConnectors/chunk-ZJ6OFFD5.js +95 -0
- package/dist/wallets/walletConnectors/index.js +31 -30
- package/dist/wigwamWallet-R4AVGQ5E.js +8 -0
- package/dist/xdc-KO37AHY2.js +8 -0
- package/dist/xdefiWallet-Y273RRLT.js +8 -0
- package/dist/zealWallet-CQHZEJUT.js +8 -0
- package/dist/zerionWallet-67WXXHBG.js +8 -0
- package/dist/zetachain-CULDO7MF.js +8 -0
- package/dist/zh_CN-HBK3E2T5.js +8 -0
- package/dist/zh_HK-ZQP4TGHU.js +8 -0
- package/dist/zh_TW-DSHZXVLV.js +8 -0
- package/dist/zkSync-VZ5E5WP6.js +8 -0
- package/dist/zora-GXTHZKII.js +8 -0
- package/package.json +2 -1
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
BaseApiClient
|
|
4
|
+
} from "./chunk-LQ2U33WM.js";
|
|
5
|
+
import {
|
|
6
|
+
getNetworkName
|
|
7
|
+
} from "./chunk-4PCVQBFZ.js";
|
|
8
|
+
import {
|
|
9
|
+
createAbcError
|
|
10
|
+
} from "./chunk-TYUEB4VT.js";
|
|
11
|
+
|
|
12
|
+
// src/wallets/walletConnectors/abcWallet/api/TransactionApi.ts
|
|
13
|
+
var TransactionApi = class extends BaseApiClient {
|
|
14
|
+
/**
|
|
15
|
+
* Send raw transaction
|
|
16
|
+
*/
|
|
17
|
+
async sendRawTransaction(chainId, signedTransaction) {
|
|
18
|
+
const network = getNetworkName(chainId);
|
|
19
|
+
const secureChannelId = await this.secure.getSecureChannelId();
|
|
20
|
+
const bodyData = {
|
|
21
|
+
signedSerializeTx: signedTransaction,
|
|
22
|
+
network
|
|
23
|
+
};
|
|
24
|
+
const bodyString = new URLSearchParams(bodyData).toString();
|
|
25
|
+
const url = "${this.baseURL}${ABC_ENDPOINTS.SEND_RAW_TX}";
|
|
26
|
+
const response = await fetch(url, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: {
|
|
29
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
30
|
+
"Secure-Channel": secureChannelId,
|
|
31
|
+
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
32
|
+
},
|
|
33
|
+
body: bodyString
|
|
34
|
+
});
|
|
35
|
+
const text = await response.text();
|
|
36
|
+
if (!text) {
|
|
37
|
+
throw createAbcError(
|
|
38
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
39
|
+
"Empty response from sendRawTx API (status: ${response.status})",
|
|
40
|
+
{ status: response.status }
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
const res = JSON.parse(text);
|
|
44
|
+
if (response.status === 401 && this.refreshToken) {
|
|
45
|
+
try {
|
|
46
|
+
await this.refreshAccessToken();
|
|
47
|
+
const retryResponse = await fetch(url, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: {
|
|
50
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
51
|
+
"Secure-Channel": secureChannelId,
|
|
52
|
+
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
53
|
+
},
|
|
54
|
+
body: bodyString
|
|
55
|
+
});
|
|
56
|
+
const retryText = await retryResponse.text();
|
|
57
|
+
if (!retryText) {
|
|
58
|
+
throw createAbcError(
|
|
59
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
60
|
+
"Empty response after retry (status: ${retryResponse.status})",
|
|
61
|
+
{ status: retryResponse.status }
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const retryRes = JSON.parse(retryText);
|
|
65
|
+
if (retryRes.item || retryRes.txHash || retryRes.result?.txHash) {
|
|
66
|
+
const txHash = retryRes.item || retryRes.txHash || retryRes.result.txHash;
|
|
67
|
+
return { txHash };
|
|
68
|
+
}
|
|
69
|
+
throw createAbcError(
|
|
70
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
71
|
+
"Failed to send transaction after token refresh",
|
|
72
|
+
retryRes
|
|
73
|
+
);
|
|
74
|
+
} catch (refreshError) {
|
|
75
|
+
console.error(
|
|
76
|
+
"Token refresh failed in sendRawTransaction:",
|
|
77
|
+
refreshError
|
|
78
|
+
);
|
|
79
|
+
throw refreshError;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (res.result) {
|
|
83
|
+
if (typeof res.result === "string") {
|
|
84
|
+
return { txHash: res.result };
|
|
85
|
+
}
|
|
86
|
+
if (res.result.txHash) {
|
|
87
|
+
return { txHash: res.result.txHash };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (res.item) {
|
|
91
|
+
return { txHash: res.item };
|
|
92
|
+
}
|
|
93
|
+
if (res.txHash) {
|
|
94
|
+
return { txHash: res.txHash };
|
|
95
|
+
}
|
|
96
|
+
throw createAbcError(
|
|
97
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
98
|
+
"Failed to send transaction",
|
|
99
|
+
res
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get transaction count (nonce)
|
|
104
|
+
*/
|
|
105
|
+
async getTransactionCount(_address, _network, _block = "latest") {
|
|
106
|
+
const nonceUrl = "${this.baseURL}${ABC_ENDPOINTS.TRANSACTION_COUNT}?address=${address}&network=${network}&block=${block}";
|
|
107
|
+
const response = await fetch(nonceUrl, {
|
|
108
|
+
method: "GET",
|
|
109
|
+
headers: {
|
|
110
|
+
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
if (response.ok) {
|
|
114
|
+
const data = await response.json();
|
|
115
|
+
return Number.parseInt(data.result, 16);
|
|
116
|
+
}
|
|
117
|
+
throw createAbcError(
|
|
118
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
119
|
+
"Failed to get transaction count"
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get suggested gas fees for EIP-1559
|
|
124
|
+
*/
|
|
125
|
+
async getSuggestedGasFees(_network) {
|
|
126
|
+
const url = "${this.baseURL}${ABC_ENDPOINTS.GAS_SUGGESTED_FEES}?network=${network}";
|
|
127
|
+
const response = await fetch(url, {
|
|
128
|
+
method: "GET",
|
|
129
|
+
headers: {
|
|
130
|
+
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
if (response.ok) {
|
|
134
|
+
const data = await response.json();
|
|
135
|
+
return data;
|
|
136
|
+
}
|
|
137
|
+
throw createAbcError(
|
|
138
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
139
|
+
"Failed to get suggested gas fees"
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Estimate gas limit for EIP-1559 transaction
|
|
144
|
+
*/
|
|
145
|
+
async estimateGas(params) {
|
|
146
|
+
const estimateBody = new URLSearchParams({
|
|
147
|
+
network: params.network,
|
|
148
|
+
to: params.to || "0x",
|
|
149
|
+
...params.from ? { from: params.from } : {},
|
|
150
|
+
...params.value ? { value: params.value } : {},
|
|
151
|
+
...params.data && params.data !== "0x" ? { data: params.data } : {},
|
|
152
|
+
...params.maxFeePerGas ? { maxFeePerGas: params.maxFeePerGas } : {},
|
|
153
|
+
...params.maxPriorityFeePerGas ? { maxPriorityFeePerGas: params.maxPriorityFeePerGas } : {}
|
|
154
|
+
});
|
|
155
|
+
const url = "${this.baseURL}${ABC_ENDPOINTS.GAS_ESTIMATE_EIP1559}";
|
|
156
|
+
const response = await fetch(url, {
|
|
157
|
+
method: "POST",
|
|
158
|
+
headers: {
|
|
159
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
160
|
+
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
161
|
+
},
|
|
162
|
+
body: estimateBody.toString()
|
|
163
|
+
});
|
|
164
|
+
const data = await response.json();
|
|
165
|
+
if (response.ok && data.result) {
|
|
166
|
+
return data.result;
|
|
167
|
+
}
|
|
168
|
+
const fallbackGasLimit = "0x2dc6c0";
|
|
169
|
+
console.warn("\u26A0\uFE0F Gas estimate failed, using fallback:", {
|
|
170
|
+
error: data.errorMessage || data.msg,
|
|
171
|
+
fallbackGasLimit
|
|
172
|
+
});
|
|
173
|
+
return fallbackGasLimit;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export {
|
|
178
|
+
TransactionApi
|
|
179
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
getInjectedConnector
|
|
4
|
+
} from "./chunk-MBBGZGXF.js";
|
|
5
|
+
import {
|
|
6
|
+
isAndroid
|
|
7
|
+
} from "./chunk-RETKWSKD.js";
|
|
8
|
+
import {
|
|
9
|
+
getWalletConnectConnector
|
|
10
|
+
} from "./chunk-PODFK4OS.js";
|
|
11
|
+
|
|
12
|
+
// src/wallets/walletConnectors/iopayWallet/iopayWallet.ts
|
|
13
|
+
function isIoPayMobile() {
|
|
14
|
+
return typeof navigator !== "undefined" && typeof navigator.userAgent !== "undefined" && (navigator?.userAgent.includes("IoPayAndroid") || navigator?.userAgent.includes("IoPayiOs"));
|
|
15
|
+
}
|
|
16
|
+
var iopayWallet = ({
|
|
17
|
+
projectId,
|
|
18
|
+
walletConnectParameters
|
|
19
|
+
}) => ({
|
|
20
|
+
id: "iopay",
|
|
21
|
+
name: "ioPay Wallet",
|
|
22
|
+
iconUrl: async () => (await import("./iopayWallet-IJHJ7NYT.js")).default,
|
|
23
|
+
iconBackground: "#fff",
|
|
24
|
+
downloadUrls: {
|
|
25
|
+
android: "https://play.google.com/store/apps/details?id=io.iotex.iopay.gp&pli=1",
|
|
26
|
+
ios: "https://apps.apple.com/us/app/iopay-multichain-crypto-wallet/id1478086371",
|
|
27
|
+
qrCode: "https://iopay.me/",
|
|
28
|
+
browserExtension: "https://iopay.me/"
|
|
29
|
+
},
|
|
30
|
+
mobile: {
|
|
31
|
+
getUri: (uri) => {
|
|
32
|
+
return isAndroid() ? uri : `iopay://wc?uri=${encodeURIComponent(uri)}`;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
qrCode: {
|
|
36
|
+
getUri: (uri) => uri,
|
|
37
|
+
instructions: {
|
|
38
|
+
learnMoreUrl: "https://iopay.me/",
|
|
39
|
+
steps: [
|
|
40
|
+
{
|
|
41
|
+
description: "wallet_connectors.iopay.qr_code.step1.description",
|
|
42
|
+
step: "install",
|
|
43
|
+
title: "wallet_connectors.iopay.qr_code.step1.title"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
description: "wallet_connectors.iopay.qr_code.step2.description",
|
|
47
|
+
step: "create",
|
|
48
|
+
title: "wallet_connectors.iopay.qr_code.step2.title"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
description: "wallet_connectors.iopay.qr_code.step3.description",
|
|
52
|
+
step: "scan",
|
|
53
|
+
title: "wallet_connectors.iopay.qr_code.step3.title"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
createConnector: isIoPayMobile() ? getInjectedConnector({}) : getWalletConnectConnector({
|
|
59
|
+
projectId,
|
|
60
|
+
walletConnectParameters
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export {
|
|
65
|
+
iopayWallet
|
|
66
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
AuthApi
|
|
4
|
+
} from "./chunk-ZNBWRE3K.js";
|
|
5
|
+
import {
|
|
6
|
+
BitcoinApi
|
|
7
|
+
} from "./chunk-V4Q3GNBX.js";
|
|
8
|
+
import {
|
|
9
|
+
SigningApi
|
|
10
|
+
} from "./chunk-7VZDITAJ.js";
|
|
11
|
+
import {
|
|
12
|
+
TransactionApi
|
|
13
|
+
} from "./chunk-DJKN2MCI.js";
|
|
14
|
+
import {
|
|
15
|
+
WalletApi
|
|
16
|
+
} from "./chunk-V33I7JGZ.js";
|
|
17
|
+
import {
|
|
18
|
+
SolanaApi
|
|
19
|
+
} from "./chunk-KXEAFXAA.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
|
+
};
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/wallets/walletConnectors/abcWallet/abcSolanaProvider.ts
|
|
4
|
+
var EventEmitter = class {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.events = /* @__PURE__ */ new Map();
|
|
7
|
+
}
|
|
8
|
+
on(event, listener) {
|
|
9
|
+
if (!this.events.has(event)) {
|
|
10
|
+
this.events.set(event, []);
|
|
11
|
+
}
|
|
12
|
+
this.events.get(event).push(listener);
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
off(event, listener) {
|
|
16
|
+
const listeners = this.events.get(event);
|
|
17
|
+
if (listeners) {
|
|
18
|
+
const index = listeners.indexOf(listener);
|
|
19
|
+
if (index !== -1) {
|
|
20
|
+
listeners.splice(index, 1);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
removeListener(event, listener) {
|
|
26
|
+
return this.off(event, listener);
|
|
27
|
+
}
|
|
28
|
+
emit(event, ...args) {
|
|
29
|
+
const listeners = this.events.get(event);
|
|
30
|
+
if (listeners) {
|
|
31
|
+
for (const listener of listeners) {
|
|
32
|
+
listener(...args);
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
removeAllListeners(event) {
|
|
39
|
+
if (event) {
|
|
40
|
+
this.events.delete(event);
|
|
41
|
+
} else {
|
|
42
|
+
this.events.clear();
|
|
43
|
+
}
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var SolanaErrorCode = {
|
|
48
|
+
USER_REJECTED: 4001,
|
|
49
|
+
UNAUTHORIZED: 4100,
|
|
50
|
+
UNSUPPORTED_METHOD: 4200,
|
|
51
|
+
DISCONNECTED: 4900,
|
|
52
|
+
INVALID_PARAMS: -32602,
|
|
53
|
+
INTERNAL_ERROR: -32603
|
|
54
|
+
};
|
|
55
|
+
var SolanaProviderError = class extends Error {
|
|
56
|
+
constructor(code, message, data) {
|
|
57
|
+
super(message);
|
|
58
|
+
this.code = code;
|
|
59
|
+
this.data = data;
|
|
60
|
+
this.name = "SolanaProviderError";
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var AbcSolanaProvider = class extends EventEmitter {
|
|
64
|
+
constructor(client) {
|
|
65
|
+
super();
|
|
66
|
+
this.wallet = null;
|
|
67
|
+
this.connected = false;
|
|
68
|
+
this.client = client;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Set wallet information
|
|
72
|
+
*/
|
|
73
|
+
setWallet(wallet) {
|
|
74
|
+
const previousAddress = this.wallet?.address;
|
|
75
|
+
this.wallet = wallet;
|
|
76
|
+
this.connected = true;
|
|
77
|
+
if (previousAddress !== wallet.address) {
|
|
78
|
+
this.emit("accountsChanged", [wallet.address]);
|
|
79
|
+
}
|
|
80
|
+
this.emit("connect", {
|
|
81
|
+
address: wallet.address,
|
|
82
|
+
network: wallet.network
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Clear wallet (disconnect)
|
|
87
|
+
*/
|
|
88
|
+
clearWallet() {
|
|
89
|
+
this.wallet = null;
|
|
90
|
+
this.connected = false;
|
|
91
|
+
this.emit("disconnect");
|
|
92
|
+
this.emit("accountsChanged", []);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Set PIN request callback for transaction signing (not used - kept for API compatibility)
|
|
96
|
+
*/
|
|
97
|
+
setRequestPinCallback(_callback) {
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Check if connected
|
|
101
|
+
*/
|
|
102
|
+
isConnected() {
|
|
103
|
+
return this.connected && this.wallet !== null;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get Solana address
|
|
107
|
+
*/
|
|
108
|
+
async getAddress() {
|
|
109
|
+
if (!this.wallet) {
|
|
110
|
+
throw new SolanaProviderError(
|
|
111
|
+
SolanaErrorCode.DISCONNECTED,
|
|
112
|
+
"Wallet not connected"
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
return this.wallet.address;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get public key
|
|
119
|
+
*/
|
|
120
|
+
async getPublicKey() {
|
|
121
|
+
if (!this.wallet) {
|
|
122
|
+
throw new SolanaProviderError(
|
|
123
|
+
SolanaErrorCode.DISCONNECTED,
|
|
124
|
+
"Wallet not connected"
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return this.wallet.publicKey;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Sign Solana message (no PIN required)
|
|
131
|
+
* Uses encrypted_share which doesn't require PIN
|
|
132
|
+
*/
|
|
133
|
+
async signMessage(encodedMessage, _display) {
|
|
134
|
+
if (!this.wallet) {
|
|
135
|
+
throw new SolanaProviderError(
|
|
136
|
+
SolanaErrorCode.DISCONNECTED,
|
|
137
|
+
"Wallet not connected"
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
const messageHex = "0x" + Array.from(encodedMessage).map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
142
|
+
const result = await this.client.solana.signSolanaMessage({
|
|
143
|
+
message: messageHex,
|
|
144
|
+
encryptedShare: this.wallet.encryptedShare,
|
|
145
|
+
keyId: this.wallet.keyId,
|
|
146
|
+
secretStore: this.wallet.secretStore || ""
|
|
147
|
+
});
|
|
148
|
+
const signatureHex = result.signature.startsWith("0x") ? result.signature.slice(2) : result.signature;
|
|
149
|
+
const signatureBytes = new Uint8Array(
|
|
150
|
+
signatureHex.match(/.{1,2}/g)?.map((byte) => parseInt(byte, 16)) || []
|
|
151
|
+
);
|
|
152
|
+
return { signature: signatureBytes };
|
|
153
|
+
} catch (error) {
|
|
154
|
+
this.emit("error", error);
|
|
155
|
+
throw new SolanaProviderError(
|
|
156
|
+
SolanaErrorCode.INTERNAL_ERROR,
|
|
157
|
+
"Failed to sign message",
|
|
158
|
+
error
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Sign Solana transaction (not used - ABC WaaS handles signing server-side)
|
|
164
|
+
* This method is kept for compatibility but not recommended for direct use
|
|
165
|
+
* Use the high-level sendTransaction() flow instead
|
|
166
|
+
*/
|
|
167
|
+
async signTransaction(_transaction, _params) {
|
|
168
|
+
throw new SolanaProviderError(
|
|
169
|
+
SolanaErrorCode.UNSUPPORTED_METHOD,
|
|
170
|
+
"Direct transaction signing not supported. Use useSolanaWallet.sendTransaction() which handles the full flow via ABC WaaS API."
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Get wallet info
|
|
175
|
+
*/
|
|
176
|
+
getWalletInfo() {
|
|
177
|
+
if (!this.wallet)
|
|
178
|
+
return null;
|
|
179
|
+
return {
|
|
180
|
+
address: this.wallet.address,
|
|
181
|
+
publicKey: this.wallet.publicKey,
|
|
182
|
+
network: this.wallet.network
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export {
|
|
188
|
+
SolanaProviderError,
|
|
189
|
+
AbcSolanaProvider
|
|
190
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
BaseApiClient
|
|
4
|
+
} from "./chunk-MPFE6GP2.js";
|
|
5
|
+
import {
|
|
6
|
+
getNetworkName
|
|
7
|
+
} from "./chunk-4PCVQBFZ.js";
|
|
8
|
+
import {
|
|
9
|
+
createAbcError
|
|
10
|
+
} from "./chunk-5RSS3SRV.js";
|
|
11
|
+
|
|
12
|
+
// src/wallets/walletConnectors/abcWallet/api/TransactionApi.ts
|
|
13
|
+
var TransactionApi = class extends BaseApiClient {
|
|
14
|
+
/**
|
|
15
|
+
* Send raw transaction
|
|
16
|
+
*/
|
|
17
|
+
async sendRawTransaction(chainId, signedTransaction) {
|
|
18
|
+
const network = getNetworkName(chainId);
|
|
19
|
+
const secureChannelId = await this.secure.getSecureChannelId();
|
|
20
|
+
const bodyData = {
|
|
21
|
+
signedSerializeTx: signedTransaction,
|
|
22
|
+
network
|
|
23
|
+
};
|
|
24
|
+
const bodyString = new URLSearchParams(bodyData).toString();
|
|
25
|
+
const url = "${this.baseURL}${ABC_ENDPOINTS.SEND_RAW_TX}";
|
|
26
|
+
const response = await fetch(url, {
|
|
27
|
+
method: "POST",
|
|
28
|
+
headers: {
|
|
29
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
30
|
+
"Secure-Channel": secureChannelId,
|
|
31
|
+
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
32
|
+
},
|
|
33
|
+
body: bodyString
|
|
34
|
+
});
|
|
35
|
+
const text = await response.text();
|
|
36
|
+
if (!text) {
|
|
37
|
+
throw createAbcError(
|
|
38
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
39
|
+
"Empty response from sendRawTx API (status: ${response.status})",
|
|
40
|
+
{ status: response.status }
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
const res = JSON.parse(text);
|
|
44
|
+
if (response.status === 401 && this.refreshToken) {
|
|
45
|
+
try {
|
|
46
|
+
await this.refreshAccessToken();
|
|
47
|
+
const retryResponse = await fetch(url, {
|
|
48
|
+
method: "POST",
|
|
49
|
+
headers: {
|
|
50
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
51
|
+
"Secure-Channel": secureChannelId,
|
|
52
|
+
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
53
|
+
},
|
|
54
|
+
body: bodyString
|
|
55
|
+
});
|
|
56
|
+
const retryText = await retryResponse.text();
|
|
57
|
+
if (!retryText) {
|
|
58
|
+
throw createAbcError(
|
|
59
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
60
|
+
"Empty response after retry (status: ${retryResponse.status})",
|
|
61
|
+
{ status: retryResponse.status }
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const retryRes = JSON.parse(retryText);
|
|
65
|
+
if (retryRes.item || retryRes.txHash || retryRes.result?.txHash) {
|
|
66
|
+
const txHash = retryRes.item || retryRes.txHash || retryRes.result.txHash;
|
|
67
|
+
return { txHash };
|
|
68
|
+
}
|
|
69
|
+
throw createAbcError(
|
|
70
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
71
|
+
"Failed to send transaction after token refresh",
|
|
72
|
+
retryRes
|
|
73
|
+
);
|
|
74
|
+
} catch (refreshError) {
|
|
75
|
+
console.error(
|
|
76
|
+
"Token refresh failed in sendRawTransaction:",
|
|
77
|
+
refreshError
|
|
78
|
+
);
|
|
79
|
+
throw refreshError;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (res.result) {
|
|
83
|
+
if (typeof res.result === "string") {
|
|
84
|
+
return { txHash: res.result };
|
|
85
|
+
}
|
|
86
|
+
if (res.result.txHash) {
|
|
87
|
+
return { txHash: res.result.txHash };
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (res.item) {
|
|
91
|
+
return { txHash: res.item };
|
|
92
|
+
}
|
|
93
|
+
if (res.txHash) {
|
|
94
|
+
return { txHash: res.txHash };
|
|
95
|
+
}
|
|
96
|
+
throw createAbcError(
|
|
97
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
98
|
+
"Failed to send transaction",
|
|
99
|
+
res
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get transaction count (nonce)
|
|
104
|
+
*/
|
|
105
|
+
async getTransactionCount(_address, _network, _block = "latest") {
|
|
106
|
+
const nonceUrl = "${this.baseURL}${ABC_ENDPOINTS.TRANSACTION_COUNT}?address=${address}&network=${network}&block=${block}";
|
|
107
|
+
const response = await fetch(nonceUrl, {
|
|
108
|
+
method: "GET",
|
|
109
|
+
headers: {
|
|
110
|
+
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
if (response.ok) {
|
|
114
|
+
const data = await response.json();
|
|
115
|
+
return Number.parseInt(data.result, 16);
|
|
116
|
+
}
|
|
117
|
+
throw createAbcError(
|
|
118
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
119
|
+
"Failed to get transaction count"
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get suggested gas fees for EIP-1559
|
|
124
|
+
*/
|
|
125
|
+
async getSuggestedGasFees(_network) {
|
|
126
|
+
const url = "${this.baseURL}${ABC_ENDPOINTS.GAS_SUGGESTED_FEES}?network=${network}";
|
|
127
|
+
const response = await fetch(url, {
|
|
128
|
+
method: "GET",
|
|
129
|
+
headers: {
|
|
130
|
+
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
if (response.ok) {
|
|
134
|
+
const data = await response.json();
|
|
135
|
+
return data;
|
|
136
|
+
}
|
|
137
|
+
throw createAbcError(
|
|
138
|
+
"NETWORK_ERROR" /* NETWORK_ERROR */,
|
|
139
|
+
"Failed to get suggested gas fees"
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Estimate gas limit for EIP-1559 transaction
|
|
144
|
+
*/
|
|
145
|
+
async estimateGas(params) {
|
|
146
|
+
const estimateBody = new URLSearchParams({
|
|
147
|
+
network: params.network,
|
|
148
|
+
to: params.to || "0x",
|
|
149
|
+
...params.from ? { from: params.from } : {},
|
|
150
|
+
...params.value ? { value: params.value } : {},
|
|
151
|
+
...params.data && params.data !== "0x" ? { data: params.data } : {},
|
|
152
|
+
...params.maxFeePerGas ? { maxFeePerGas: params.maxFeePerGas } : {},
|
|
153
|
+
...params.maxPriorityFeePerGas ? { maxPriorityFeePerGas: params.maxPriorityFeePerGas } : {}
|
|
154
|
+
});
|
|
155
|
+
const url = "${this.baseURL}${ABC_ENDPOINTS.GAS_ESTIMATE_EIP1559}";
|
|
156
|
+
const response = await fetch(url, {
|
|
157
|
+
method: "POST",
|
|
158
|
+
headers: {
|
|
159
|
+
"Content-Type": "application/x-www-form-urlencoded",
|
|
160
|
+
...this.accessToken ? { Authorization: "Bearer ${this.accessToken}" } : {}
|
|
161
|
+
},
|
|
162
|
+
body: estimateBody.toString()
|
|
163
|
+
});
|
|
164
|
+
const data = await response.json();
|
|
165
|
+
if (response.ok && data.result) {
|
|
166
|
+
return data.result;
|
|
167
|
+
}
|
|
168
|
+
const fallbackGasLimit = "0x2dc6c0";
|
|
169
|
+
console.warn("\u26A0\uFE0F Gas estimate failed, using fallback:", {
|
|
170
|
+
error: data.errorMessage || data.msg,
|
|
171
|
+
fallbackGasLimit
|
|
172
|
+
});
|
|
173
|
+
return fallbackGasLimit;
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export {
|
|
178
|
+
TransactionApi
|
|
179
|
+
};
|