@portal-hq/web 3.2.3 → 3.3.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/README.md +1 -1
- package/lib/commonjs/index.js +147 -19
- package/lib/commonjs/index.test.js +548 -0
- package/lib/commonjs/mpc/errors/index.js +1 -1
- package/lib/commonjs/mpc/index.js +145 -2
- package/lib/commonjs/mpc/index.test.js +1414 -0
- package/lib/commonjs/provider/index.js +172 -39
- package/lib/commonjs/provider/index.test.js +1222 -0
- package/lib/esm/index.js +122 -18
- package/lib/esm/index.test.js +520 -0
- package/lib/esm/mpc/errors/index.js +1 -1
- package/lib/esm/mpc/index.js +145 -2
- package/lib/esm/mpc/index.test.js +1409 -0
- package/lib/esm/provider/index.js +171 -39
- package/lib/esm/provider/index.test.js +1217 -0
- package/package.json +5 -5
- package/src/__mocks/constants.ts +771 -0
- package/src/__mocks/portal/mpc.ts +27 -0
- package/src/__mocks/portal/portal.ts +14 -0
- package/src/__mocks/portal/provider.ts +7 -0
- package/src/index.test.ts +820 -0
- package/src/index.ts +183 -44
- package/src/mpc/errors/index.ts +1 -1
- package/src/mpc/index.test.ts +1716 -0
- package/src/mpc/index.ts +182 -2
- package/src/provider/index.test.ts +1570 -0
- package/src/provider/index.ts +184 -39
- package/types.d.ts +298 -33
package/src/provider/index.ts
CHANGED
|
@@ -10,26 +10,149 @@ import type {
|
|
|
10
10
|
RpcErrorOptions,
|
|
11
11
|
} from '../../types'
|
|
12
12
|
|
|
13
|
+
export enum RequestMethod {
|
|
14
|
+
eth_accounts = 'eth_accounts',
|
|
15
|
+
eth_blockNumber = 'eth_blockNumber',
|
|
16
|
+
eth_call = 'eth_call',
|
|
17
|
+
eth_chainId = 'eth_chainId',
|
|
18
|
+
eth_coinbase = 'eth_coinbase',
|
|
19
|
+
eth_compileSolidity = 'eth_compileSolidity',
|
|
20
|
+
eth_compileLLL = 'eth_compileLLL',
|
|
21
|
+
eth_compileSerpent = 'eth_compileSerpent',
|
|
22
|
+
eth_estimateGas = 'eth_estimateGas',
|
|
23
|
+
eth_gasPrice = 'eth_gasPrice',
|
|
24
|
+
eth_getBalance = 'eth_getBalance',
|
|
25
|
+
eth_getBlockByHash = 'eth_getBlockByHash',
|
|
26
|
+
eth_getBlockByNumber = 'eth_getBlockByNumber',
|
|
27
|
+
eth_getBlockTransactionCountByHash = 'eth_getBlockTransactionCountByHash',
|
|
28
|
+
eth_getBlockTransactionCountByNumber = 'eth_getBlockTransactionCountByNumber',
|
|
29
|
+
eth_getCode = 'eth_getCode',
|
|
30
|
+
eth_getCompilers = 'eth_getCompilers',
|
|
31
|
+
eth_getFilterChange = 'eth_getFilterChange',
|
|
32
|
+
eth_getFilterLogs = 'eth_getFilterLogs',
|
|
33
|
+
eth_getLogs = 'eth_getLogs',
|
|
34
|
+
eth_getStorageAt = 'eth_getStorageAt',
|
|
35
|
+
eth_getTransactionByHash = 'eth_getTransactionByHash',
|
|
36
|
+
eth_getTransactionByBlockHashAndIndex = 'eth_getTransactionByBlockHashAndIndex',
|
|
37
|
+
eth_getTransactionByBlockNumberAndIndex = 'eth_getTransactionByBlockNumberAndIndex',
|
|
38
|
+
eth_getTransactionCount = 'eth_getTransactionCount',
|
|
39
|
+
eth_getTransactionReceipt = 'eth_getTransactionReceipt',
|
|
40
|
+
eth_getUncleByBlockHashAndIndex = 'eth_getUncleByBlockHashAndIndex',
|
|
41
|
+
eth_getUncleByBlockNumberAndIndex = 'eth_getUncleByBlockNumberAndIndex',
|
|
42
|
+
eth_getUncleCountByBlockHash = 'eth_getUncleCountByBlockHash',
|
|
43
|
+
eth_getUncleCountByBlockNumber = 'eth_getUncleCountByBlockNumber',
|
|
44
|
+
eth_getWork = 'eth_getWork',
|
|
45
|
+
eth_hashrate = 'eth_hashrate',
|
|
46
|
+
eth_mining = 'eth_mining',
|
|
47
|
+
eth_newBlockFilter = 'eth_newBlockFilter',
|
|
48
|
+
eth_newFilter = 'eth_newFilter',
|
|
49
|
+
eth_newPendingTransactionFilter = 'eth_newPendingTransactionFilter',
|
|
50
|
+
personal_sign = 'personal_sign',
|
|
51
|
+
eth_protocolVersion = 'eth_protocolVersion',
|
|
52
|
+
eth_requestAccounts = 'eth_requestAccounts',
|
|
53
|
+
eth_sendRawTransaction = 'eth_sendRawTransaction',
|
|
54
|
+
eth_sendTransaction = 'eth_sendTransaction',
|
|
55
|
+
eth_sign = 'eth_sign',
|
|
56
|
+
eth_signTransaction = 'eth_signTransaction',
|
|
57
|
+
eth_signTypedData = 'eth_signTypedData',
|
|
58
|
+
eth_signTypedData_v3 = 'eth_signTypedData_v3',
|
|
59
|
+
eth_signTypedData_v4 = 'eth_signTypedData_v4',
|
|
60
|
+
eth_submitHashrate = 'eth_submitHashrate',
|
|
61
|
+
eth_submitWork = 'eth_submitWork',
|
|
62
|
+
eth_syncing = 'eth_syncing',
|
|
63
|
+
eth_uninstallFilter = 'eth_uninstallFilter',
|
|
64
|
+
|
|
65
|
+
// Net Methods
|
|
66
|
+
net_listening = 'net_listening',
|
|
67
|
+
net_peerCount = 'net_peerCount',
|
|
68
|
+
net_version = 'net_version',
|
|
69
|
+
|
|
70
|
+
// Web3 Methods
|
|
71
|
+
web3_clientVersion = 'web3_clientVersion',
|
|
72
|
+
web3_sha3 = 'web3_sha3',
|
|
73
|
+
|
|
74
|
+
// Solana RPC Methods
|
|
75
|
+
sol_getAccountInfo = 'getAccountInfo',
|
|
76
|
+
sol_getBalance = 'getBalance',
|
|
77
|
+
sol_getBlock = 'getBlock',
|
|
78
|
+
sol_getBlockCommitment = 'getBlockCommitment',
|
|
79
|
+
sol_getBlockHeight = 'getBlockHeight',
|
|
80
|
+
sol_getBlockProduction = 'getBlockProduction',
|
|
81
|
+
sol_getBlockTime = 'getBlockTime',
|
|
82
|
+
sol_getBlocks = 'getBlocks',
|
|
83
|
+
sol_getBlocksWithLimit = 'getBlocksWithLimit',
|
|
84
|
+
sol_getClusterNodes = 'getClusterNodes',
|
|
85
|
+
sol_getEpochInfo = 'getEpochInfo',
|
|
86
|
+
sol_getEpochSchedule = 'getEpochSchedule',
|
|
87
|
+
sol_getFeeForMessage = 'getFeeForMessage',
|
|
88
|
+
sol_getFirstAvailableBlock = 'getFirstAvailableBlock',
|
|
89
|
+
sol_getGenesisHash = 'getGenesisHash',
|
|
90
|
+
sol_getHealth = 'getHealth',
|
|
91
|
+
sol_getHighestSnapshotSlot = 'getHighestSnapshotSlot',
|
|
92
|
+
sol_getIdentity = 'getIdentity',
|
|
93
|
+
sol_getInflationGovernor = 'getInflationGovernor',
|
|
94
|
+
sol_getInflationRate = 'getInflationRate',
|
|
95
|
+
sol_getInflationReward = 'getInflationReward',
|
|
96
|
+
sol_getLargestAccounts = 'getLargestAccounts',
|
|
97
|
+
sol_getLatestBlockhash = 'getLatestBlockhash',
|
|
98
|
+
sol_getLeaderSchedule = 'getLeaderSchedule',
|
|
99
|
+
sol_getMaxRetransmitSlot = 'getMaxRetransmitSlot',
|
|
100
|
+
sol_getMaxShredInsertSlot = 'getMaxShredInsertSlot',
|
|
101
|
+
sol_getMinimumBalanceForRentExemption = 'getMinimumBalanceForRentExemption',
|
|
102
|
+
sol_getMultipleAccounts = 'getMultipleAccounts',
|
|
103
|
+
sol_getProgramAccounts = 'getProgramAccounts',
|
|
104
|
+
sol_getRecentPerformanceSamples = 'getRecentPerformanceSamples',
|
|
105
|
+
sol_getRecentPrioritizationFees = 'getRecentPrioritizationFees',
|
|
106
|
+
sol_getSignatureStatuses = 'getSignatureStatuses',
|
|
107
|
+
sol_getSignaturesForAddress = 'getSignaturesForAddress',
|
|
108
|
+
sol_getSlot = 'getSlot',
|
|
109
|
+
sol_getSlotLeader = 'getSlotLeader',
|
|
110
|
+
sol_getSlotLeaders = 'getSlotLeaders',
|
|
111
|
+
sol_getStakeActivation = 'getStakeActivation',
|
|
112
|
+
sol_getStakeMinimumDelegation = 'getStakeMinimumDelegation',
|
|
113
|
+
sol_getSupply = 'getSupply',
|
|
114
|
+
sol_getTokenAccountBalance = 'getTokenAccountBalance',
|
|
115
|
+
sol_getTokenAccountsByDelegate = 'getTokenAccountsByDelegate',
|
|
116
|
+
sol_getTokenAccountsByOwner = 'getTokenAccountsByOwner',
|
|
117
|
+
sol_getTokenLargestAccounts = 'getTokenLargestAccounts',
|
|
118
|
+
sol_getTokenSupply = 'getTokenSupply',
|
|
119
|
+
sol_getTransaction = 'getTransaction',
|
|
120
|
+
sol_getTransactionCount = 'getTransactionCount',
|
|
121
|
+
sol_getVersion = 'getVersion',
|
|
122
|
+
sol_getVoteAccounts = 'getVoteAccounts',
|
|
123
|
+
sol_isBlockhashValid = 'isBlockhashValid',
|
|
124
|
+
sol_minimumLedgerSlot = 'minimumLedgerSlot',
|
|
125
|
+
sol_requestAirdrop = 'requestAirdrop',
|
|
126
|
+
sol_sendTransaction = 'sendTransaction',
|
|
127
|
+
sol_simulateTransaction = 'simulateTransaction',
|
|
128
|
+
|
|
129
|
+
// Solana Wallet Methods
|
|
130
|
+
sol_signAndConfirmTransaction = 'sol_signAndConfirmTransaction',
|
|
131
|
+
sol_signAndSendTransaction = 'sol_signAndSendTransaction',
|
|
132
|
+
sol_signMessage = 'sol_signMessage',
|
|
133
|
+
sol_signTransaction = 'sol_signTransaction',
|
|
134
|
+
}
|
|
135
|
+
|
|
13
136
|
const passiveSignerMethods = [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
137
|
+
RequestMethod.eth_accounts,
|
|
138
|
+
RequestMethod.eth_chainId,
|
|
139
|
+
RequestMethod.eth_requestAccounts,
|
|
17
140
|
]
|
|
18
141
|
|
|
19
142
|
const signerMethods = [
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
143
|
+
RequestMethod.eth_accounts,
|
|
144
|
+
RequestMethod.eth_chainId,
|
|
145
|
+
RequestMethod.eth_requestAccounts,
|
|
146
|
+
RequestMethod.eth_sendTransaction,
|
|
147
|
+
RequestMethod.eth_sign,
|
|
148
|
+
RequestMethod.eth_signTransaction,
|
|
149
|
+
RequestMethod.eth_signTypedData_v3,
|
|
150
|
+
RequestMethod.eth_signTypedData_v4,
|
|
151
|
+
RequestMethod.personal_sign,
|
|
152
|
+
RequestMethod.sol_signAndConfirmTransaction,
|
|
153
|
+
RequestMethod.sol_signAndSendTransaction,
|
|
154
|
+
RequestMethod.sol_signMessage,
|
|
155
|
+
RequestMethod.sol_signTransaction,
|
|
33
156
|
]
|
|
34
157
|
|
|
35
158
|
class Provider {
|
|
@@ -37,9 +160,13 @@ class Provider {
|
|
|
37
160
|
|
|
38
161
|
private portal: Portal
|
|
39
162
|
|
|
40
|
-
|
|
163
|
+
// eip155 chain reference ID
|
|
164
|
+
private chainReferenceId?: number
|
|
165
|
+
|
|
166
|
+
constructor({ portal, chainId }: ProviderOptions) {
|
|
41
167
|
this.events = {}
|
|
42
168
|
this.portal = portal
|
|
169
|
+
this.chainReferenceId = chainId
|
|
43
170
|
}
|
|
44
171
|
|
|
45
172
|
/**
|
|
@@ -118,11 +245,12 @@ class Provider {
|
|
|
118
245
|
* @returns Promise<any>
|
|
119
246
|
*/
|
|
120
247
|
public async request({
|
|
121
|
-
chainId,
|
|
248
|
+
chainId: requestChainId,
|
|
122
249
|
method,
|
|
123
250
|
params,
|
|
124
251
|
}: RequestArguments): Promise<any> {
|
|
125
252
|
const isSignerMethod = signerMethods.includes(method)
|
|
253
|
+
const chainId = this.getCAIP2ChainId(requestChainId)
|
|
126
254
|
|
|
127
255
|
if (!isSignerMethod && !method.startsWith('wallet_')) {
|
|
128
256
|
// Send to Gateway for RPC calls
|
|
@@ -174,6 +302,16 @@ class Provider {
|
|
|
174
302
|
}
|
|
175
303
|
}
|
|
176
304
|
|
|
305
|
+
public setChainId(chainId: number) {
|
|
306
|
+
if (!Number.isInteger(chainId))
|
|
307
|
+
throw new Error(
|
|
308
|
+
`[PortalProvider] Chain ID must be an integer, got ${chainId}`,
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
this.chainReferenceId = chainId
|
|
312
|
+
this.emit('chainChanged', { chainId })
|
|
313
|
+
}
|
|
314
|
+
|
|
177
315
|
/************************
|
|
178
316
|
* Private Methods
|
|
179
317
|
************************/
|
|
@@ -307,22 +445,22 @@ class Provider {
|
|
|
307
445
|
}
|
|
308
446
|
|
|
309
447
|
switch (method) {
|
|
310
|
-
case
|
|
448
|
+
case RequestMethod.eth_chainId: {
|
|
311
449
|
this.enforceEip155ChainId(chainId)
|
|
312
450
|
const chainReferenceId = parseInt((chainId as string).split(':')[1])
|
|
313
451
|
return `0x${chainReferenceId.toString(16)}`
|
|
314
452
|
}
|
|
315
|
-
case
|
|
316
|
-
case
|
|
453
|
+
case RequestMethod.eth_accounts:
|
|
454
|
+
case RequestMethod.eth_requestAccounts: {
|
|
317
455
|
this.enforceEip155ChainId(chainId)
|
|
318
456
|
return [this.portal.address]
|
|
319
457
|
}
|
|
320
|
-
case
|
|
321
|
-
case
|
|
322
|
-
case
|
|
323
|
-
case
|
|
324
|
-
case
|
|
325
|
-
case
|
|
458
|
+
case RequestMethod.eth_sendTransaction:
|
|
459
|
+
case RequestMethod.eth_sign:
|
|
460
|
+
case RequestMethod.eth_signTransaction:
|
|
461
|
+
case RequestMethod.eth_signTypedData_v3:
|
|
462
|
+
case RequestMethod.eth_signTypedData_v4:
|
|
463
|
+
case RequestMethod.personal_sign: {
|
|
326
464
|
this.enforceEip155ChainId(chainId)
|
|
327
465
|
const result = await this.portal.mpc.sign({
|
|
328
466
|
chainId: chainId as string,
|
|
@@ -332,10 +470,10 @@ class Provider {
|
|
|
332
470
|
})
|
|
333
471
|
return result
|
|
334
472
|
}
|
|
335
|
-
case
|
|
336
|
-
case
|
|
337
|
-
case
|
|
338
|
-
case
|
|
473
|
+
case RequestMethod.sol_signAndConfirmTransaction:
|
|
474
|
+
case RequestMethod.sol_signAndSendTransaction:
|
|
475
|
+
case RequestMethod.sol_signMessage:
|
|
476
|
+
case RequestMethod.sol_signTransaction: {
|
|
339
477
|
this.enforceSolanaChainId(chainId)
|
|
340
478
|
const result = await this.portal.mpc.sign({
|
|
341
479
|
chainId: chainId as string,
|
|
@@ -380,14 +518,14 @@ class Provider {
|
|
|
380
518
|
let params = txParams
|
|
381
519
|
|
|
382
520
|
switch (method) {
|
|
383
|
-
case
|
|
384
|
-
case
|
|
385
|
-
case
|
|
386
|
-
case
|
|
387
|
-
case
|
|
388
|
-
case
|
|
389
|
-
case
|
|
390
|
-
case
|
|
521
|
+
case RequestMethod.eth_sign:
|
|
522
|
+
case RequestMethod.personal_sign:
|
|
523
|
+
case RequestMethod.eth_signTypedData_v3:
|
|
524
|
+
case RequestMethod.eth_signTypedData_v4:
|
|
525
|
+
case RequestMethod.sol_signAndConfirmTransaction:
|
|
526
|
+
case RequestMethod.sol_signAndSendTransaction:
|
|
527
|
+
case RequestMethod.sol_signMessage:
|
|
528
|
+
case RequestMethod.sol_signTransaction:
|
|
391
529
|
if (!Array.isArray(txParams)) {
|
|
392
530
|
params = [txParams]
|
|
393
531
|
}
|
|
@@ -400,6 +538,13 @@ class Provider {
|
|
|
400
538
|
|
|
401
539
|
return params
|
|
402
540
|
}
|
|
541
|
+
|
|
542
|
+
private getCAIP2ChainId = (chainId?: string) => {
|
|
543
|
+
if (!chainId && !this.chainReferenceId)
|
|
544
|
+
throw new Error('[PortalProvider] Chain ID is required for the operation')
|
|
545
|
+
|
|
546
|
+
return chainId || `eip155:${this.chainReferenceId}`
|
|
547
|
+
}
|
|
403
548
|
}
|
|
404
549
|
|
|
405
550
|
export default Provider
|
package/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type DkgData, PortalError } from '@portal-hq/utils'
|
|
2
|
-
import type { MpcErrorCodes } from './src/mpc/errors'
|
|
3
2
|
|
|
4
|
-
import
|
|
3
|
+
import type { MpcErrorCodes } from './src/mpc/errors'
|
|
4
|
+
import Portal, { BackupMethods, PortalCurve } from './src/index'
|
|
5
5
|
|
|
6
6
|
export type EventHandler = (event: Event<any>) => void | Promise<void>
|
|
7
7
|
export type EthereumTransaction = EIP1559Transaction | LegacyTransaction
|
|
@@ -14,6 +14,7 @@ export type MessageData =
|
|
|
14
14
|
| SignArgs
|
|
15
15
|
export type ProgressCallback = (status: MpcStatus) => void | Promise<void>
|
|
16
16
|
export type ValidRpcErrorCodes = 4001 | 4100 | 4200 | 4900 | 4901
|
|
17
|
+
|
|
17
18
|
// Interfaces
|
|
18
19
|
|
|
19
20
|
export interface FeatureFlags {
|
|
@@ -47,11 +48,6 @@ export interface BackupResult {
|
|
|
47
48
|
cipherText: string
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
export interface Bk {
|
|
51
|
-
X: string
|
|
52
|
-
Rank: number
|
|
53
|
-
}
|
|
54
|
-
|
|
55
51
|
export interface Address {
|
|
56
52
|
id: string
|
|
57
53
|
network: Network
|
|
@@ -97,11 +93,12 @@ interface ClientResponseEnvironment {
|
|
|
97
93
|
}
|
|
98
94
|
|
|
99
95
|
interface ClientResponseMetadata {
|
|
100
|
-
namespaces:
|
|
96
|
+
namespaces: Record<ChainNamespace, NamespaceMetadataItem>
|
|
101
97
|
}
|
|
102
98
|
|
|
103
|
-
interface
|
|
104
|
-
|
|
99
|
+
interface NamespaceMetadataItem {
|
|
100
|
+
curve: PortalCurve
|
|
101
|
+
address: string
|
|
105
102
|
}
|
|
106
103
|
|
|
107
104
|
interface ClientResponseSharePair {
|
|
@@ -119,10 +116,10 @@ export interface ClientResponseWallet {
|
|
|
119
116
|
createdAt: string
|
|
120
117
|
|
|
121
118
|
backupSharePairs: ClientResponseBackupSharePair[]
|
|
122
|
-
curve:
|
|
119
|
+
curve: PortalCurve
|
|
123
120
|
ejectableUntil?: string
|
|
124
121
|
publicKey: string
|
|
125
|
-
signingSharePairs:
|
|
122
|
+
signingSharePairs: ClientResponseSharePair[]
|
|
126
123
|
}
|
|
127
124
|
|
|
128
125
|
export interface DappOnNetwork {
|
|
@@ -153,16 +150,9 @@ export interface DecryptArgs {
|
|
|
153
150
|
}
|
|
154
151
|
|
|
155
152
|
export interface DkgData {
|
|
156
|
-
|
|
157
|
-
bks: Bk[]
|
|
158
|
-
p: string
|
|
159
|
-
partialPubKey: Pubkey[]
|
|
160
|
-
pederson: PedersonParams[]
|
|
161
|
-
pubkey: Pubkey
|
|
162
|
-
q: string
|
|
153
|
+
backupSharePairId?: string
|
|
163
154
|
share: string
|
|
164
155
|
signingSharePairId?: string
|
|
165
|
-
ssid: string
|
|
166
156
|
}
|
|
167
157
|
|
|
168
158
|
export interface EIP1559Transaction {
|
|
@@ -348,12 +338,6 @@ export interface PasskeyStatusResponse {
|
|
|
348
338
|
status: PasskeyStatus
|
|
349
339
|
}
|
|
350
340
|
|
|
351
|
-
export interface PedersonParams {
|
|
352
|
-
n: string
|
|
353
|
-
s: string
|
|
354
|
-
t: string
|
|
355
|
-
}
|
|
356
|
-
|
|
357
341
|
export interface PortalApiOptions {
|
|
358
342
|
apiKey: string
|
|
359
343
|
baseUrl: string
|
|
@@ -383,16 +367,15 @@ export interface PortalOptions {
|
|
|
383
367
|
keychain?: KeychainAdapter
|
|
384
368
|
mpcVersion?: string
|
|
385
369
|
featureFlags?: FeatureFlags
|
|
370
|
+
chainId?: string
|
|
386
371
|
}
|
|
387
372
|
|
|
388
373
|
export interface ProviderOptions {
|
|
389
374
|
// Required options
|
|
390
375
|
portal: Portal
|
|
391
|
-
}
|
|
392
376
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
Y: string
|
|
377
|
+
// Optional
|
|
378
|
+
chainId?: number
|
|
396
379
|
}
|
|
397
380
|
|
|
398
381
|
export interface QuoteArgs {
|
|
@@ -427,14 +410,14 @@ export interface RegisteredEventHandler {
|
|
|
427
410
|
|
|
428
411
|
export interface RequestArguments {
|
|
429
412
|
chainId?: string
|
|
430
|
-
method:
|
|
413
|
+
method: RequestMethod
|
|
431
414
|
params?: unknown[] | SigningRequestParams
|
|
432
415
|
}
|
|
433
416
|
|
|
434
417
|
export interface RecoverArgs extends MpcOperationArgs {
|
|
435
|
-
cipherText: string
|
|
436
|
-
backupMethod: BackupMethods
|
|
437
418
|
backupConfigs: BackupConfigs
|
|
419
|
+
backupMethod: BackupMethods
|
|
420
|
+
cipherText: string
|
|
438
421
|
featureFlags?: FeatureFlags // TODO: Remove this
|
|
439
422
|
}
|
|
440
423
|
|
|
@@ -514,6 +497,109 @@ export interface SimulatedTransaction {
|
|
|
514
497
|
requestError?: SimulatedTransactionError
|
|
515
498
|
}
|
|
516
499
|
|
|
500
|
+
export type EvaluateTransactionParam =
|
|
501
|
+
| {
|
|
502
|
+
to: string
|
|
503
|
+
value?: string
|
|
504
|
+
data?: string
|
|
505
|
+
gas?: string
|
|
506
|
+
gasPrice?: string
|
|
507
|
+
maxFeePerGas?: string
|
|
508
|
+
maxPriorityFeePerGas?: string
|
|
509
|
+
}
|
|
510
|
+
| {
|
|
511
|
+
transactions: string[]
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
type EvaluateTransactionOperationType = 'validation' | 'simulation' | 'all'
|
|
515
|
+
|
|
516
|
+
export interface EvaluatedTransaction {
|
|
517
|
+
validation?: Validation
|
|
518
|
+
simulation?: Simulation
|
|
519
|
+
block?: number
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
interface AssetMovement {
|
|
523
|
+
summary: string
|
|
524
|
+
value: string
|
|
525
|
+
usdPrice?: string
|
|
526
|
+
rawValue: string
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
interface AssetDiff {
|
|
530
|
+
asset: Record<
|
|
531
|
+
string,
|
|
532
|
+
{
|
|
533
|
+
type: string
|
|
534
|
+
decimals: number
|
|
535
|
+
chainName?: string
|
|
536
|
+
chainId?: number
|
|
537
|
+
logoUrl?: string
|
|
538
|
+
name?: string
|
|
539
|
+
symbol?: string
|
|
540
|
+
}
|
|
541
|
+
>
|
|
542
|
+
in: Record<string, AssetMovement>[]
|
|
543
|
+
out: Record<string, AssetMovement>[]
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
interface AccountSummary {
|
|
547
|
+
assetsDiffs: Record<string, AssetDiff>[]
|
|
548
|
+
[k: string]: any
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
type Simulation = SuccessfulSimulation | UnsuccessfulSimulation
|
|
552
|
+
|
|
553
|
+
interface SuccessfulSimulation {
|
|
554
|
+
accountAddress: string
|
|
555
|
+
accountSummary: AccountSummary
|
|
556
|
+
addressDetails: Record<string, any>
|
|
557
|
+
assetsDiffs: Record<string, AssetDiff[]>
|
|
558
|
+
status: string
|
|
559
|
+
exposures?: Record<string, any>
|
|
560
|
+
totalUsdDiff?: Record<string, any>
|
|
561
|
+
totalUsdExposure?: Record<string, any>
|
|
562
|
+
solana?: {
|
|
563
|
+
delegations: Record<string, Record<string, any>[]>
|
|
564
|
+
assetsOwnershipDiff: Record<string, Record<string, any>[]>
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
interface UnsuccessfulSimulation {
|
|
568
|
+
status: 'Error'
|
|
569
|
+
error: string
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
type Validation = SuccessfulValidation | UnsuccessfulValidation
|
|
573
|
+
|
|
574
|
+
interface SuccessfulValidation {
|
|
575
|
+
classification?: string | null
|
|
576
|
+
description?: string | null
|
|
577
|
+
features: {
|
|
578
|
+
type?: 'Malicious' | 'Warning' | 'Benign' | 'Info'
|
|
579
|
+
featureId?: string
|
|
580
|
+
description: string
|
|
581
|
+
address?: string | null
|
|
582
|
+
}[]
|
|
583
|
+
reason?: string | null
|
|
584
|
+
resultType: 'Benign' | 'Warning' | 'Malicious'
|
|
585
|
+
status: string
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
interface UnsuccessfulValidation {
|
|
589
|
+
error: string
|
|
590
|
+
classification?: string | null
|
|
591
|
+
description?: string | null
|
|
592
|
+
features: {
|
|
593
|
+
type?: 'Malicious' | 'Warning' | 'Benign' | 'Info'
|
|
594
|
+
featureId?: string
|
|
595
|
+
description: string
|
|
596
|
+
address?: string | null
|
|
597
|
+
}[]
|
|
598
|
+
reason?: string | null
|
|
599
|
+
resultType: 'Error'
|
|
600
|
+
status: 'Error'
|
|
601
|
+
}
|
|
602
|
+
|
|
517
603
|
export interface Transaction {
|
|
518
604
|
asset: string
|
|
519
605
|
blockNum: string
|
|
@@ -537,6 +623,185 @@ export interface Transaction {
|
|
|
537
623
|
value: number
|
|
538
624
|
}
|
|
539
625
|
|
|
626
|
+
export interface Asset {
|
|
627
|
+
nativeBalance: {
|
|
628
|
+
balance: string
|
|
629
|
+
decimals: number
|
|
630
|
+
name: string
|
|
631
|
+
rawBalance: string
|
|
632
|
+
symbol: string
|
|
633
|
+
metadata: Record<string, any>
|
|
634
|
+
}
|
|
635
|
+
tokenBalances: {
|
|
636
|
+
balance: string
|
|
637
|
+
decimals: number
|
|
638
|
+
name: string
|
|
639
|
+
rawBalance: string
|
|
640
|
+
symbol: string
|
|
641
|
+
metadata: Record<string, any>
|
|
642
|
+
}[]
|
|
643
|
+
nfts?: NFTAsset[]
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
export interface NFTAsset {
|
|
647
|
+
nftId: string
|
|
648
|
+
name: string
|
|
649
|
+
description: string
|
|
650
|
+
imageUrl: string
|
|
651
|
+
chain: string
|
|
652
|
+
contractAddress: string
|
|
653
|
+
tokenId: string
|
|
654
|
+
collection: {
|
|
655
|
+
name: string
|
|
656
|
+
description: string | null
|
|
657
|
+
imageUrl: string
|
|
658
|
+
}
|
|
659
|
+
lastSale: {
|
|
660
|
+
price: number
|
|
661
|
+
currency: string
|
|
662
|
+
date: string
|
|
663
|
+
} | null
|
|
664
|
+
rarity: {
|
|
665
|
+
rank: number | null
|
|
666
|
+
score: number | null
|
|
667
|
+
}
|
|
668
|
+
floorPrice: {
|
|
669
|
+
price: number
|
|
670
|
+
currency: string
|
|
671
|
+
} | null
|
|
672
|
+
detailedInfo: {
|
|
673
|
+
ownerCount: number
|
|
674
|
+
tokenCount: number
|
|
675
|
+
createdDate: string | null
|
|
676
|
+
attributes: Attribute[]
|
|
677
|
+
owners: Owner[]
|
|
678
|
+
extendedCollectionInfo: ExtendedCollectionInfo
|
|
679
|
+
extendedSaleInfo: ExtendedSaleInfo | null
|
|
680
|
+
marketplaceInfo: MarketplaceInfo[]
|
|
681
|
+
mediaInfo: MediaInfo
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
interface Attribute {
|
|
686
|
+
traitType: string
|
|
687
|
+
value: string | number
|
|
688
|
+
displayType: string | null
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
interface Owner {
|
|
692
|
+
ownerAddress: string
|
|
693
|
+
quantity: number
|
|
694
|
+
firstAcquiredDate: string
|
|
695
|
+
lastAcquiredDate: string
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
interface ExtendedCollectionInfo {
|
|
699
|
+
bannerImageUrl: string | null
|
|
700
|
+
externalUrl: string | null
|
|
701
|
+
twitterUsername: string | null
|
|
702
|
+
discordUrl: string | null
|
|
703
|
+
instagramUsername: string | null
|
|
704
|
+
mediumUsername: string | null
|
|
705
|
+
telegramUrl: string | null
|
|
706
|
+
distinctOwnerCount: number
|
|
707
|
+
distinctNftCount: number
|
|
708
|
+
totalQuantity: number
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
interface ExtendedSaleInfo {
|
|
712
|
+
fromAddress: string
|
|
713
|
+
toAddress: string
|
|
714
|
+
priceUsdCents: number
|
|
715
|
+
transaction: string
|
|
716
|
+
marketplaceId: string
|
|
717
|
+
marketplaceName: string
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
interface MarketplaceInfo {
|
|
721
|
+
marketplaceId: string
|
|
722
|
+
marketplaceName: string
|
|
723
|
+
marketplaceCollectionId: string
|
|
724
|
+
nftUrl: string
|
|
725
|
+
collectionUrl: string
|
|
726
|
+
verified: boolean | null
|
|
727
|
+
floorPrice: {
|
|
728
|
+
value: number
|
|
729
|
+
paymentToken: {
|
|
730
|
+
paymentTokenId: string
|
|
731
|
+
name: string
|
|
732
|
+
symbol: string
|
|
733
|
+
address: string | null
|
|
734
|
+
decimals: number
|
|
735
|
+
}
|
|
736
|
+
valueUsdCents: number | null
|
|
737
|
+
} | null
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
interface MediaInfo {
|
|
741
|
+
previews: {
|
|
742
|
+
imageSmallUrl: string
|
|
743
|
+
imageMediumUrl: string
|
|
744
|
+
imageLargeUrl: string
|
|
745
|
+
imageOpengraphUrl: string
|
|
746
|
+
blurhash: string
|
|
747
|
+
predominantColor: string
|
|
748
|
+
}
|
|
749
|
+
animationUrl: string | null
|
|
750
|
+
backgroundColor: string | null
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
export type BuiltTransaction = BuiltEip155Transaction | BuiltSolanaTransaction
|
|
754
|
+
|
|
755
|
+
export interface BuiltEip155Transaction {
|
|
756
|
+
transaction: {
|
|
757
|
+
from: string
|
|
758
|
+
to: string
|
|
759
|
+
data: string
|
|
760
|
+
}
|
|
761
|
+
metadata: {
|
|
762
|
+
amount: string
|
|
763
|
+
fromAddress: string
|
|
764
|
+
toAddress: string
|
|
765
|
+
tokenAddress: string
|
|
766
|
+
tokenDecimals: number
|
|
767
|
+
rawAmount: string
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
export interface BuiltSolanaTransaction {
|
|
772
|
+
transaction: string
|
|
773
|
+
metadata: {
|
|
774
|
+
amount: string
|
|
775
|
+
fromAddress: string
|
|
776
|
+
toAddress: string
|
|
777
|
+
tokenMintAddress: string
|
|
778
|
+
tokenDecimals: number
|
|
779
|
+
tokenProgramId: string
|
|
780
|
+
tokenExtensions: any[]
|
|
781
|
+
rawAmount: string
|
|
782
|
+
lastValidBlockHeight: string
|
|
783
|
+
serializedTransactionBase64Encoded: string
|
|
784
|
+
serializedTransactionBase58Encoded: string
|
|
785
|
+
unsignedTransactionMessage: {
|
|
786
|
+
signatures: null
|
|
787
|
+
message: {
|
|
788
|
+
accountKeys: string[]
|
|
789
|
+
header: {
|
|
790
|
+
numRequiredSignatures: number
|
|
791
|
+
numReadonlySignedAccounts: number
|
|
792
|
+
numReadonlyUnsignedAccounts: number
|
|
793
|
+
}
|
|
794
|
+
instructions: {
|
|
795
|
+
programIdIndex: number
|
|
796
|
+
accounts: number[]
|
|
797
|
+
data: string
|
|
798
|
+
}[]
|
|
799
|
+
recentBlockhash: string
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
540
805
|
export interface SwitchEthereumChainParameter {
|
|
541
806
|
chainId: string
|
|
542
807
|
}
|