@talken/talkenkit 2.4.30 → 2.5.1
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/{AbcCredentialManager-DDHLW2IH.js → AbcCredentialManager-5W3B7GI4.js} +1 -1
- package/dist/{abcWallet-TLGPQAMU.js → abcWallet-O5IRLUXL.js} +2 -2
- package/dist/{chunk-ALBABQ53.js → chunk-PN6K4CMZ.js} +4 -1
- package/dist/{chunk-MI7TNBED.js → chunk-UHZL3WSM.js} +709 -86
- package/dist/components/TransactionResultModal/TransactionResultModal.css.d.ts +17 -0
- package/dist/components/TransactionResultModal/TransactionResultModal.d.ts +9 -0
- package/dist/index.css +138 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1344 -980
- package/dist/providers/TransactionResultProvider/TransactionResultContext.d.ts +6 -0
- package/dist/providers/TransactionResultProvider/TransactionResultProvider.d.ts +7 -0
- package/dist/providers/TransactionResultProvider/TransactionResultSingleton.d.ts +16 -0
- package/dist/providers/TransactionResultProvider/index.d.ts +4 -0
- package/dist/providers/TransactionResultProvider/types.d.ts +14 -0
- package/dist/wallets/walletConnectors/abcWallet/AbcCredentialManager.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/AbcEvmAutoConnector.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/abcAccessKeyProvider.d.ts +69 -0
- package/dist/wallets/walletConnectors/abcWallet/abcAccessKeyProvider.js +11 -0
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +8 -6
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.d.ts +8 -0
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +5 -4
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +8 -8
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.d.ts +7 -0
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +9 -7
- package/dist/wallets/walletConnectors/abcWallet/api/ConfigApi.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.d.ts +25 -0
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/api/TokenApi.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/api/WalletscanApi.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/api/index.js +9 -9
- package/dist/wallets/walletConnectors/abcWallet/constants.d.ts +3 -0
- package/dist/wallets/walletConnectors/abcWallet/constants.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/index.d.ts +1 -1
- package/dist/wallets/walletConnectors/abcWallet/index.js +35 -33
- package/dist/wallets/walletConnectors/abcWallet/sessionUtils.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/types.d.ts +11 -0
- package/dist/wallets/walletConnectors/abcWallet/utils.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/walletGeneration.js +3 -3
- package/dist/wallets/walletConnectors/{chunk-VDWJ3NQ5.js → chunk-25ZDAJ3L.js} +1 -1
- package/dist/wallets/walletConnectors/chunk-4JZPP3S7.js +380 -0
- package/dist/wallets/walletConnectors/{chunk-HHZ3JZRH.js → chunk-4YEALKXG.js} +74 -14
- package/dist/wallets/walletConnectors/{chunk-IN3HEGZM.js → chunk-645DT4TS.js} +46 -5
- package/dist/wallets/walletConnectors/{chunk-XNA5NIFE.js → chunk-6TAU7OQK.js} +7 -4
- package/dist/wallets/walletConnectors/{chunk-MO2AXXLI.js → chunk-FKI5AZVH.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-JADQLTFW.js → chunk-H2AZTZMM.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-NULM3THX.js → chunk-HWRZGGGN.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-BHEVY4QY.js → chunk-KIYXONNH.js} +35 -2
- package/dist/wallets/walletConnectors/{chunk-NU3ITJNK.js → chunk-L6FCF3FH.js} +94 -736
- package/dist/wallets/walletConnectors/{chunk-ACLPF2UW.js → chunk-LIGH2LEU.js} +1 -1
- package/dist/wallets/walletConnectors/chunk-OASBABPG.js +746 -0
- package/dist/wallets/walletConnectors/{chunk-A66MTFML.js → chunk-PF65YS3T.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-6WF4SXLB.js → chunk-QKK3OPQA.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-3LF7FVL6.js → chunk-RGYZNNB6.js} +1 -1
- package/dist/wallets/walletConnectors/{chunk-DPTDOCWL.js → chunk-RX2VOIUB.js} +4 -1
- package/dist/wallets/walletConnectors/{chunk-YV6IZWGE.js → chunk-URS2KVYK.js} +45 -2
- package/dist/wallets/walletConnectors/{chunk-BXH3GDX5.js → chunk-YKFI6ZGM.js} +1 -1
- package/dist/wallets/walletConnectors/index.js +47 -45
- package/package.json +1 -1
- package/dist/wallets/walletConnectors/chunk-CABLJOMU.js +0 -194
- package/dist/wallets/walletConnectors/chunk-J3YPHDHM.js +0 -827
- package/dist/wallets/walletConnectors/chunk-J566FC7T.js +0 -54
- package/dist/wallets/walletConnectors/chunk-OHQXPSR6.js +0 -300
- package/dist/wallets/walletConnectors/chunk-OMOYFHBT.js +0 -1485
|
@@ -5,54 +5,59 @@ import {
|
|
|
5
5
|
fetchWithSessionCheck,
|
|
6
6
|
handleUnauthorizedResponse,
|
|
7
7
|
refreshAccessToken
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-LIGH2LEU.js";
|
|
9
9
|
import {
|
|
10
10
|
generateMpcWallets,
|
|
11
11
|
recoverMpcWallets,
|
|
12
12
|
validateMpcWallets
|
|
13
|
-
} from "../chunk-
|
|
14
|
-
import {
|
|
15
|
-
AbcTronProvider,
|
|
16
|
-
TRON_NETWORKS,
|
|
17
|
-
TronProviderError
|
|
18
|
-
} from "../chunk-YV6IZWGE.js";
|
|
19
|
-
import {
|
|
20
|
-
AbcBitcoinConnector,
|
|
21
|
-
createAbcBitcoinConnector
|
|
22
|
-
} from "../chunk-BXH3GDX5.js";
|
|
23
|
-
import {
|
|
24
|
-
AbcBitcoinProvider,
|
|
25
|
-
BITCOIN_NETWORKS,
|
|
26
|
-
BitcoinProviderError
|
|
27
|
-
} from "../chunk-3LF7FVL6.js";
|
|
13
|
+
} from "../chunk-H2AZTZMM.js";
|
|
28
14
|
import {
|
|
29
15
|
AbcSolanaProvider,
|
|
30
16
|
SolanaProviderError
|
|
31
|
-
} from "../chunk-
|
|
17
|
+
} from "../chunk-645DT4TS.js";
|
|
32
18
|
import "../chunk-JGXJY3SB.js";
|
|
19
|
+
import {
|
|
20
|
+
GasApi
|
|
21
|
+
} from "../chunk-YPM7FC4M.js";
|
|
33
22
|
import {
|
|
34
23
|
SolanaApi
|
|
35
24
|
} from "../chunk-OTLZVWY7.js";
|
|
36
25
|
import {
|
|
37
26
|
WalletscanApi
|
|
38
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-HWRZGGGN.js";
|
|
39
28
|
import {
|
|
40
29
|
TokenApi
|
|
41
|
-
} from "../chunk-
|
|
42
|
-
import {
|
|
43
|
-
GasApi
|
|
44
|
-
} from "../chunk-YPM7FC4M.js";
|
|
30
|
+
} from "../chunk-FKI5AZVH.js";
|
|
45
31
|
import {
|
|
46
32
|
ConfigApi
|
|
47
|
-
} from "../chunk-
|
|
33
|
+
} from "../chunk-25ZDAJ3L.js";
|
|
34
|
+
import {
|
|
35
|
+
AbcTronProvider,
|
|
36
|
+
TRON_NETWORKS,
|
|
37
|
+
TronProviderError
|
|
38
|
+
} from "../chunk-URS2KVYK.js";
|
|
39
|
+
import {
|
|
40
|
+
AbcBitcoinConnector,
|
|
41
|
+
createAbcBitcoinConnector
|
|
42
|
+
} from "../chunk-YKFI6ZGM.js";
|
|
43
|
+
import {
|
|
44
|
+
AbcBitcoinProvider,
|
|
45
|
+
BITCOIN_NETWORKS,
|
|
46
|
+
BitcoinProviderError
|
|
47
|
+
} from "../chunk-RGYZNNB6.js";
|
|
48
48
|
import {
|
|
49
49
|
abcWallet
|
|
50
|
-
} from "../chunk-
|
|
50
|
+
} from "../chunk-6TAU7OQK.js";
|
|
51
51
|
import {
|
|
52
52
|
abcConnector
|
|
53
|
-
} from "../chunk-
|
|
53
|
+
} from "../chunk-4YEALKXG.js";
|
|
54
54
|
import "../chunk-R6ZE7JAZ.js";
|
|
55
55
|
import "../chunk-GFWUFYT2.js";
|
|
56
|
+
import {
|
|
57
|
+
TalkenApiClient,
|
|
58
|
+
createTalkenApiClient
|
|
59
|
+
} from "../chunk-KIYXONNH.js";
|
|
60
|
+
import "../chunk-4JZPP3S7.js";
|
|
56
61
|
import {
|
|
57
62
|
BitcoinNetwork,
|
|
58
63
|
SolanaNetwork,
|
|
@@ -66,7 +71,8 @@ import {
|
|
|
66
71
|
AbcEvmProvider,
|
|
67
72
|
createAbcEvmProvider,
|
|
68
73
|
createAbcProvider
|
|
69
|
-
} from "../chunk-
|
|
74
|
+
} from "../chunk-L6FCF3FH.js";
|
|
75
|
+
import "../chunk-OASBABPG.js";
|
|
70
76
|
import {
|
|
71
77
|
calculateExpiryTimestamp,
|
|
72
78
|
clearAuthState,
|
|
@@ -84,11 +90,7 @@ import {
|
|
|
84
90
|
saveToStorage,
|
|
85
91
|
validateEmail,
|
|
86
92
|
validatePin
|
|
87
|
-
} from "../chunk-
|
|
88
|
-
import {
|
|
89
|
-
TalkenApiClient,
|
|
90
|
-
createTalkenApiClient
|
|
91
|
-
} from "../chunk-BHEVY4QY.js";
|
|
93
|
+
} from "../chunk-PF65YS3T.js";
|
|
92
94
|
import {
|
|
93
95
|
AbcError,
|
|
94
96
|
AbcErrorCode,
|
|
@@ -96,7 +98,7 @@ import {
|
|
|
96
98
|
} from "../chunk-4P3SPC44.js";
|
|
97
99
|
import {
|
|
98
100
|
getCredentialManager
|
|
99
|
-
} from "../chunk-
|
|
101
|
+
} from "../chunk-QKK3OPQA.js";
|
|
100
102
|
import {
|
|
101
103
|
ABC_EVENTS,
|
|
102
104
|
ABC_FEATURES,
|
|
@@ -118,7 +120,7 @@ import {
|
|
|
118
120
|
STORAGE_VERSION,
|
|
119
121
|
SUCCESS_MESSAGES,
|
|
120
122
|
TOKEN_EXPIRY
|
|
121
|
-
} from "../chunk-
|
|
123
|
+
} from "../chunk-RX2VOIUB.js";
|
|
122
124
|
export {
|
|
123
125
|
ABC_EVENTS,
|
|
124
126
|
ABC_FEATURES,
|
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
fetchWithSessionCheck,
|
|
6
6
|
handleUnauthorizedResponse,
|
|
7
7
|
refreshAccessToken
|
|
8
|
-
} from "../chunk-
|
|
9
|
-
import "../chunk-
|
|
8
|
+
} from "../chunk-LIGH2LEU.js";
|
|
9
|
+
import "../chunk-RX2VOIUB.js";
|
|
10
10
|
export {
|
|
11
11
|
SessionExpiredError,
|
|
12
12
|
dispatchSessionExpired,
|
|
@@ -40,6 +40,8 @@ export interface AbcWalletConfig {
|
|
|
40
40
|
defaultBitcoinNetwork?: BitcoinNetwork;
|
|
41
41
|
/** Project identifier */
|
|
42
42
|
projectId?: string;
|
|
43
|
+
/** Access-key for server-side signing (no PIN, used in TG Mini App) */
|
|
44
|
+
accessKey?: string;
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
45
47
|
* Authentication provider types
|
|
@@ -885,6 +887,7 @@ export interface TalkenTxEvmRequest {
|
|
|
885
887
|
maxFeePerGas?: string;
|
|
886
888
|
maxPriorityFeePerGas?: string;
|
|
887
889
|
email?: string;
|
|
890
|
+
waitForReceipt?: boolean;
|
|
888
891
|
}
|
|
889
892
|
export interface TalkenTxSvmRequest {
|
|
890
893
|
toAddress: string;
|
|
@@ -895,6 +898,7 @@ export interface TalkenTxSvmRequest {
|
|
|
895
898
|
mintAddress?: string;
|
|
896
899
|
amount?: string;
|
|
897
900
|
decimals?: number;
|
|
901
|
+
waitForConfirmation?: boolean;
|
|
898
902
|
}
|
|
899
903
|
export type TalkenBtcNetwork = 'bitcoin' | 'bitcoin_testnet';
|
|
900
904
|
export type TalkenBtcAction = 'transfer' | 'generate' | 'signHash' | 'finalize';
|
|
@@ -956,9 +960,16 @@ export interface TalkenTxTvmRequest {
|
|
|
956
960
|
confirmMaxAttempts?: number;
|
|
957
961
|
email?: string;
|
|
958
962
|
}
|
|
963
|
+
export interface TalkenTxReceipt {
|
|
964
|
+
status: number | null;
|
|
965
|
+
blockNumber: number | null;
|
|
966
|
+
gasUsed: string | null;
|
|
967
|
+
}
|
|
959
968
|
export interface TalkenTxResponse {
|
|
960
969
|
txHash: string;
|
|
961
970
|
rawTransaction?: string;
|
|
971
|
+
receipt?: TalkenTxReceipt;
|
|
972
|
+
confirmation?: any;
|
|
962
973
|
}
|
|
963
974
|
export interface TalkenGasEstimateRequest {
|
|
964
975
|
network: string;
|
|
@@ -16,9 +16,9 @@ import {
|
|
|
16
16
|
saveToStorage,
|
|
17
17
|
validateEmail,
|
|
18
18
|
validatePin
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-PF65YS3T.js";
|
|
20
20
|
import "../chunk-4P3SPC44.js";
|
|
21
|
-
import "../chunk-
|
|
21
|
+
import "../chunk-RX2VOIUB.js";
|
|
22
22
|
export {
|
|
23
23
|
calculateExpiryTimestamp,
|
|
24
24
|
clearAuthState,
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
generateMpcWallets,
|
|
4
4
|
recoverMpcWallets,
|
|
5
5
|
validateMpcWallets
|
|
6
|
-
} from "../chunk-
|
|
6
|
+
} from "../chunk-H2AZTZMM.js";
|
|
7
7
|
import "../chunk-O4AU63LK.js";
|
|
8
8
|
import "../chunk-4P3SPC44.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-QKK3OPQA.js";
|
|
10
|
+
import "../chunk-RX2VOIUB.js";
|
|
11
11
|
export {
|
|
12
12
|
generateMpcWallets,
|
|
13
13
|
recoverMpcWallets,
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
getChainKey,
|
|
4
|
+
getNetworkName
|
|
5
|
+
} from "./chunk-OASBABPG.js";
|
|
6
|
+
import {
|
|
7
|
+
hexToNumber,
|
|
8
|
+
numberToHex
|
|
9
|
+
} from "./chunk-PF65YS3T.js";
|
|
10
|
+
|
|
11
|
+
// src/wallets/walletConnectors/abcWallet/abcAccessKeyProvider.ts
|
|
12
|
+
var EventEmitter = class {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.events = /* @__PURE__ */ new Map();
|
|
15
|
+
}
|
|
16
|
+
on(event, listener) {
|
|
17
|
+
if (!this.events.has(event))
|
|
18
|
+
this.events.set(event, []);
|
|
19
|
+
this.events.get(event).push(listener);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
off(event, listener) {
|
|
23
|
+
const listeners = this.events.get(event);
|
|
24
|
+
if (listeners) {
|
|
25
|
+
const idx = listeners.indexOf(listener);
|
|
26
|
+
if (idx !== -1)
|
|
27
|
+
listeners.splice(idx, 1);
|
|
28
|
+
}
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
removeListener(event, listener) {
|
|
32
|
+
return this.off(event, listener);
|
|
33
|
+
}
|
|
34
|
+
emit(event, ...args) {
|
|
35
|
+
const listeners = this.events.get(event);
|
|
36
|
+
if (listeners) {
|
|
37
|
+
for (const listener of listeners)
|
|
38
|
+
listener(...args);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
removeAllListeners(event) {
|
|
44
|
+
if (event)
|
|
45
|
+
this.events.delete(event);
|
|
46
|
+
else
|
|
47
|
+
this.events.clear();
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var ErrorCode = {
|
|
52
|
+
USER_REJECTED: 4001,
|
|
53
|
+
UNAUTHORIZED: 4100,
|
|
54
|
+
UNSUPPORTED_METHOD: 4200,
|
|
55
|
+
DISCONNECTED: 4900,
|
|
56
|
+
INVALID_PARAMS: -32602,
|
|
57
|
+
INTERNAL_ERROR: -32603
|
|
58
|
+
};
|
|
59
|
+
var ProviderRpcError = class extends Error {
|
|
60
|
+
constructor(code, message, data) {
|
|
61
|
+
super(message);
|
|
62
|
+
this.code = code;
|
|
63
|
+
this.data = data;
|
|
64
|
+
this.name = "ProviderRpcError";
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
var AbcAccessKeyProvider = class extends EventEmitter {
|
|
68
|
+
constructor(accessKey, apiBaseUrl) {
|
|
69
|
+
super();
|
|
70
|
+
this.wallet = null;
|
|
71
|
+
this.chainId = 1;
|
|
72
|
+
this.connected = false;
|
|
73
|
+
this.accessKey = accessKey;
|
|
74
|
+
this.apiBaseUrl = apiBaseUrl || (typeof window !== "undefined" ? window.__TALKEN_API_URL__ || "" : "");
|
|
75
|
+
}
|
|
76
|
+
// ── Wallet management ─────────────────────────────────────
|
|
77
|
+
setWallet(wallet) {
|
|
78
|
+
this.wallet = wallet;
|
|
79
|
+
this.chainId = wallet.chainId || 1;
|
|
80
|
+
this.connected = true;
|
|
81
|
+
}
|
|
82
|
+
clearWallet() {
|
|
83
|
+
this.wallet = null;
|
|
84
|
+
this.connected = false;
|
|
85
|
+
}
|
|
86
|
+
isConnected() {
|
|
87
|
+
return this.connected && !!this.wallet;
|
|
88
|
+
}
|
|
89
|
+
getWallet() {
|
|
90
|
+
return this.wallet;
|
|
91
|
+
}
|
|
92
|
+
getChainId() {
|
|
93
|
+
return this.chainId;
|
|
94
|
+
}
|
|
95
|
+
setAccessKey(key) {
|
|
96
|
+
this.accessKey = key;
|
|
97
|
+
}
|
|
98
|
+
// ── EIP-1193 request ──────────────────────────────────────
|
|
99
|
+
async request(args) {
|
|
100
|
+
const { method, params } = args;
|
|
101
|
+
switch (method) {
|
|
102
|
+
case "eth_requestAccounts":
|
|
103
|
+
case "eth_accounts":
|
|
104
|
+
return this.wallet ? [this.wallet.address] : [];
|
|
105
|
+
case "eth_chainId":
|
|
106
|
+
return numberToHex(this.chainId);
|
|
107
|
+
case "wallet_switchEthereumChain": {
|
|
108
|
+
const p = params?.[0];
|
|
109
|
+
if (p?.chainId) {
|
|
110
|
+
this.chainId = hexToNumber(p.chainId);
|
|
111
|
+
this.emit("chainChanged", numberToHex(this.chainId));
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
case "eth_sendTransaction":
|
|
116
|
+
return this.sendTransaction(params);
|
|
117
|
+
case "personal_sign":
|
|
118
|
+
return this.personalSign(params);
|
|
119
|
+
case "eth_signTypedData":
|
|
120
|
+
case "eth_signTypedData_v4":
|
|
121
|
+
return this.signTypedData(params);
|
|
122
|
+
case "eth_signAuthorization":
|
|
123
|
+
return this.signAuthorization(params);
|
|
124
|
+
case "eth_estimateGas":
|
|
125
|
+
return this.estimateGas(params);
|
|
126
|
+
case "eth_getTransactionCount":
|
|
127
|
+
return this.getTransactionCount(params);
|
|
128
|
+
case "eth_call":
|
|
129
|
+
return this.ethCall(params);
|
|
130
|
+
case "eth_getBalance":
|
|
131
|
+
return this.getBalance(params);
|
|
132
|
+
case "wallet_getCapabilities":
|
|
133
|
+
return {
|
|
134
|
+
supportsTypedDataV4: true,
|
|
135
|
+
supports7702Authorization: true,
|
|
136
|
+
supports5792Batch: false,
|
|
137
|
+
supportsPaymasterService: false,
|
|
138
|
+
supportsPermit2RelayHints: true,
|
|
139
|
+
walletType: "abc-embedded"
|
|
140
|
+
};
|
|
141
|
+
default:
|
|
142
|
+
throw new ProviderRpcError(
|
|
143
|
+
ErrorCode.UNSUPPORTED_METHOD,
|
|
144
|
+
`Method not supported: ${method}`
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// ── Signing (same endpoints as AbcEvmProvider, no PIN) ────
|
|
149
|
+
/**
|
|
150
|
+
* Send transaction via POST /wallet/tx/evm
|
|
151
|
+
* PIN/email auto-injected server-side from access-key delegated credentials.
|
|
152
|
+
*/
|
|
153
|
+
async sendTransaction(params) {
|
|
154
|
+
this.ensureWallet();
|
|
155
|
+
const tx = params?.[0];
|
|
156
|
+
if (!tx) {
|
|
157
|
+
throw new ProviderRpcError(
|
|
158
|
+
ErrorCode.INVALID_PARAMS,
|
|
159
|
+
"Missing transaction params"
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (!tx.to) {
|
|
163
|
+
throw new ProviderRpcError(
|
|
164
|
+
ErrorCode.INVALID_PARAMS,
|
|
165
|
+
"Contract deployment (missing `to`) is not supported in access-key mode"
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
const chainKey = getChainKey(this.chainId);
|
|
169
|
+
const hexValue = tx.value || "0x0";
|
|
170
|
+
const amountWei = BigInt(hexValue).toString();
|
|
171
|
+
const result = await this.apiPost("/wallet/tx/evm", {
|
|
172
|
+
chainKey,
|
|
173
|
+
to: tx.to,
|
|
174
|
+
amountWei,
|
|
175
|
+
data: tx.data || "0x",
|
|
176
|
+
...tx.gas && { gasLimit: tx.gas },
|
|
177
|
+
...tx.gasLimit && { gasLimit: tx.gasLimit },
|
|
178
|
+
...tx.maxFeePerGas && { maxFeePerGas: tx.maxFeePerGas },
|
|
179
|
+
...tx.maxPriorityFeePerGas && {
|
|
180
|
+
maxPriorityFeePerGas: tx.maxPriorityFeePerGas
|
|
181
|
+
}
|
|
182
|
+
// No pin, no email — auto-injected by enrichWithDelegatedCredentials
|
|
183
|
+
});
|
|
184
|
+
return result?.txHash || result?.hash;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Personal sign via POST /wallet/sign/evm/personal
|
|
188
|
+
*/
|
|
189
|
+
async personalSign(params) {
|
|
190
|
+
const wallet = this.ensureWallet();
|
|
191
|
+
const p = params;
|
|
192
|
+
if (!Array.isArray(p) || p.length < 2) {
|
|
193
|
+
throw new ProviderRpcError(
|
|
194
|
+
ErrorCode.INVALID_PARAMS,
|
|
195
|
+
"Invalid personal_sign params"
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
const [message, address] = p;
|
|
199
|
+
if (address && address.toLowerCase() !== wallet.address.toLowerCase()) {
|
|
200
|
+
throw new ProviderRpcError(
|
|
201
|
+
ErrorCode.UNAUTHORIZED,
|
|
202
|
+
`Address mismatch: requested ${address}, connected ${wallet.address}`
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
const network = getNetworkName(this.chainId);
|
|
206
|
+
const result = await this.apiPost("/wallet/sign/evm/personal", {
|
|
207
|
+
network,
|
|
208
|
+
message,
|
|
209
|
+
address: wallet.address
|
|
210
|
+
// No pin — auto-injected
|
|
211
|
+
});
|
|
212
|
+
return result?.signature ?? result?.serializedTx ?? "";
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Sign typed data via POST /wallet/sign/evm/typed
|
|
216
|
+
*/
|
|
217
|
+
async signTypedData(params) {
|
|
218
|
+
const wallet = this.ensureWallet();
|
|
219
|
+
const p = params;
|
|
220
|
+
if (!Array.isArray(p) || p.length < 2) {
|
|
221
|
+
throw new ProviderRpcError(
|
|
222
|
+
ErrorCode.INVALID_PARAMS,
|
|
223
|
+
"Invalid signTypedData params"
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
const [address, typedData] = p;
|
|
227
|
+
if (address && address.toLowerCase() !== wallet.address.toLowerCase()) {
|
|
228
|
+
throw new ProviderRpcError(
|
|
229
|
+
ErrorCode.UNAUTHORIZED,
|
|
230
|
+
`Address mismatch: requested ${address}, connected ${wallet.address}`
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
const network = getNetworkName(this.chainId);
|
|
234
|
+
const result = await this.apiPost("/wallet/sign/evm/typed", {
|
|
235
|
+
network,
|
|
236
|
+
typedData: typeof typedData === "string" ? typedData : JSON.stringify(typedData)
|
|
237
|
+
// No pin — auto-injected
|
|
238
|
+
});
|
|
239
|
+
return result?.signature;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Sign EIP-7702 authorization via POST /wallet/sign/authorization
|
|
243
|
+
* Params: [address, authorization] — matches PIN mode (abcProvider.ts)
|
|
244
|
+
*/
|
|
245
|
+
async signAuthorization(params) {
|
|
246
|
+
const wallet = this.ensureWallet();
|
|
247
|
+
const p = params;
|
|
248
|
+
if (!Array.isArray(p) || p.length < 2) {
|
|
249
|
+
throw new ProviderRpcError(
|
|
250
|
+
ErrorCode.INVALID_PARAMS,
|
|
251
|
+
"Expected [address, authorization]"
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
const [address, auth] = p;
|
|
255
|
+
if (address && address.toLowerCase() !== wallet.address.toLowerCase()) {
|
|
256
|
+
throw new ProviderRpcError(
|
|
257
|
+
ErrorCode.UNAUTHORIZED,
|
|
258
|
+
`Address mismatch: requested ${address}, connected ${wallet.address}`
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
if (!auth) {
|
|
262
|
+
throw new ProviderRpcError(
|
|
263
|
+
ErrorCode.INVALID_PARAMS,
|
|
264
|
+
"Missing authorization object"
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
const network = getNetworkName(this.chainId);
|
|
268
|
+
const result = await this.apiPost("/wallet/sign/authorization", {
|
|
269
|
+
network,
|
|
270
|
+
authorization: {
|
|
271
|
+
chainId: auth.chainId,
|
|
272
|
+
address: auth.address,
|
|
273
|
+
nonce: auth.nonce?.toString()
|
|
274
|
+
}
|
|
275
|
+
// No pin — auto-injected
|
|
276
|
+
});
|
|
277
|
+
return result?.authorization || result;
|
|
278
|
+
}
|
|
279
|
+
// ── Helpers ───────────────────────────────────────────────
|
|
280
|
+
ensureWallet() {
|
|
281
|
+
if (!this.wallet) {
|
|
282
|
+
throw new ProviderRpcError(
|
|
283
|
+
ErrorCode.UNAUTHORIZED,
|
|
284
|
+
"Wallet not connected"
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
return this.wallet;
|
|
288
|
+
}
|
|
289
|
+
/** GET /wallet/address/balance — API uses `network` param (WaaS network name) */
|
|
290
|
+
async getBalance(params) {
|
|
291
|
+
const p = params;
|
|
292
|
+
const address = p?.[0] || this.wallet?.address;
|
|
293
|
+
const network = getNetworkName(this.chainId);
|
|
294
|
+
const result = await this.apiGet(
|
|
295
|
+
`/wallet/address/balance?network=${network}&address=${address}`
|
|
296
|
+
);
|
|
297
|
+
return result?.balance ?? "0x0";
|
|
298
|
+
}
|
|
299
|
+
/** GET /wallet/nonce — API uses `network` param (WaaS network name) */
|
|
300
|
+
async getTransactionCount(params) {
|
|
301
|
+
const p = params;
|
|
302
|
+
const address = p?.[0] || this.wallet?.address;
|
|
303
|
+
const network = getNetworkName(this.chainId);
|
|
304
|
+
const result = await this.apiGet(
|
|
305
|
+
`/wallet/nonce?network=${network}&address=${address}`
|
|
306
|
+
);
|
|
307
|
+
const nonce = result?.nonce ?? 0;
|
|
308
|
+
return `0x${Number(nonce).toString(16)}`;
|
|
309
|
+
}
|
|
310
|
+
/** POST /wallet/contract/eth-call */
|
|
311
|
+
async ethCall(params) {
|
|
312
|
+
const p = params;
|
|
313
|
+
const tx = p?.[0];
|
|
314
|
+
const network = getNetworkName(this.chainId);
|
|
315
|
+
const result = await this.apiPost("/wallet/contract/eth-call", {
|
|
316
|
+
network,
|
|
317
|
+
to: tx?.to,
|
|
318
|
+
data: tx?.data,
|
|
319
|
+
from: tx?.from || this.wallet?.address
|
|
320
|
+
});
|
|
321
|
+
return result?.result ?? result?.data ?? "0x";
|
|
322
|
+
}
|
|
323
|
+
/** POST /wallet/tx/evm with dry-run for gas estimation */
|
|
324
|
+
async estimateGas(params) {
|
|
325
|
+
const p = params;
|
|
326
|
+
const tx = p?.[0];
|
|
327
|
+
try {
|
|
328
|
+
const result = await this.apiPost("/wallet/contract/eth-call", {
|
|
329
|
+
network: getNetworkName(this.chainId),
|
|
330
|
+
to: tx?.to,
|
|
331
|
+
data: tx?.data,
|
|
332
|
+
from: tx?.from || this.wallet?.address,
|
|
333
|
+
value: tx?.value,
|
|
334
|
+
estimateGas: true
|
|
335
|
+
});
|
|
336
|
+
return result?.gasEstimate ?? result?.gas ?? "0x5208";
|
|
337
|
+
} catch {
|
|
338
|
+
return "0x5208";
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
async apiGet(path) {
|
|
342
|
+
const url = `${this.apiBaseUrl}${path}`;
|
|
343
|
+
const res = await fetch(url, {
|
|
344
|
+
headers: { "X-Access-Key": this.accessKey }
|
|
345
|
+
});
|
|
346
|
+
if (!res.ok) {
|
|
347
|
+
const err = await res.json().catch(() => ({ message: res.statusText }));
|
|
348
|
+
throw new ProviderRpcError(
|
|
349
|
+
ErrorCode.INTERNAL_ERROR,
|
|
350
|
+
err?.error?.message || err?.message || `API error: ${res.status}`
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
const json = await res.json();
|
|
354
|
+
return json?.data || json;
|
|
355
|
+
}
|
|
356
|
+
async apiPost(path, body) {
|
|
357
|
+
const url = `${this.apiBaseUrl}${path}`;
|
|
358
|
+
const res = await fetch(url, {
|
|
359
|
+
method: "POST",
|
|
360
|
+
headers: {
|
|
361
|
+
"Content-Type": "application/json",
|
|
362
|
+
"X-Access-Key": this.accessKey
|
|
363
|
+
},
|
|
364
|
+
body: JSON.stringify(body)
|
|
365
|
+
});
|
|
366
|
+
if (!res.ok) {
|
|
367
|
+
const err = await res.json().catch(() => ({ message: res.statusText }));
|
|
368
|
+
throw new ProviderRpcError(
|
|
369
|
+
ErrorCode.INTERNAL_ERROR,
|
|
370
|
+
err?.error?.message || err?.message || `API error: ${res.status}`
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
const json = await res.json();
|
|
374
|
+
return json?.data || json;
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
export {
|
|
379
|
+
AbcAccessKeyProvider
|
|
380
|
+
};
|