@portal-hq/web 3.7.0 → 3.8.0

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.
@@ -0,0 +1,681 @@
1
+ /**
2
+ * Common shared types used by both browser and iframe packages
3
+ */
4
+
5
+ // Basic types
6
+ export interface FeatureFlags {
7
+ isMultiBackupEnabled?: boolean
8
+ }
9
+
10
+ export interface Network {
11
+ id: string
12
+ chainId: string
13
+ name: string
14
+ }
15
+
16
+ export interface Address {
17
+ id: string
18
+ network: Network
19
+ value: string
20
+ }
21
+
22
+ export interface Balance {
23
+ contractAddress: string
24
+ balance: string
25
+ }
26
+
27
+ export interface PortalError {
28
+ code: number
29
+ message?: string
30
+ }
31
+
32
+ // DKG types
33
+ export interface DkgData {
34
+ backupSharePairId?: string
35
+ share: string
36
+ signingSharePairId?: string
37
+ }
38
+
39
+ // Transaction types
40
+ export interface EIP1559Transaction {
41
+ from: string
42
+ to: string
43
+
44
+ // Optional
45
+ data?: string
46
+ gasLimit?: string
47
+ maxFeePerGas?: string
48
+ maxPriorityFeePerGas?: string
49
+ nonce?: string
50
+ value?: string
51
+ }
52
+
53
+ export interface LegacyTransaction {
54
+ from: string
55
+ to: string
56
+
57
+ // Optional
58
+ data?: string
59
+ gasLimit?: string
60
+ gasPrice?: string
61
+ nonce?: string
62
+ value?: string
63
+ }
64
+
65
+ export type EthereumTransaction = EIP1559Transaction | LegacyTransaction
66
+
67
+ export interface Transaction {
68
+ asset: string
69
+ blockNum: string
70
+ category: string
71
+ chainId: string
72
+ erc1155Metadata: null | string
73
+ erc721TokenId: null | string
74
+ from: string
75
+ hash: string
76
+ metadata: {
77
+ blockTimestamp: string
78
+ }
79
+ rawContract: {
80
+ address: string
81
+ decimal: string
82
+ value: string
83
+ }
84
+ to: string
85
+ tokenId: null | string
86
+ uniqueId: string
87
+ value: number
88
+ }
89
+
90
+ // Built transaction types
91
+ export type BuiltTransaction = BuiltEip155Transaction | BuiltSolanaTransaction
92
+
93
+ export interface BuiltEip155Transaction {
94
+ transaction: {
95
+ from: string
96
+ to: string
97
+ data: string
98
+ }
99
+ metadata: {
100
+ amount: string
101
+ fromAddress: string
102
+ toAddress: string
103
+ tokenAddress: string
104
+ tokenDecimals: number
105
+ rawAmount: string
106
+ }
107
+ }
108
+
109
+ export interface BuiltSolanaTransaction {
110
+ transaction:
111
+ | string
112
+ | {
113
+ from: string
114
+ to: string
115
+ data?: string
116
+ value?: string
117
+ }
118
+ metadata: {
119
+ amount: string
120
+ fromAddress: string
121
+ toAddress: string
122
+ tokenMintAddress: string
123
+ tokenDecimals: number
124
+ tokenProgramId: string
125
+ tokenExtensions: any[]
126
+ rawAmount: string
127
+ lastValidBlockHeight: string
128
+ serializedTransactionBase64Encoded: string
129
+ serializedTransactionBase58Encoded: string
130
+ unsignedTransactionMessage: {
131
+ signatures: null
132
+ message: {
133
+ accountKeys: string[]
134
+ header: {
135
+ numRequiredSignatures: number
136
+ numReadonlySignedAccounts: number
137
+ numReadonlyUnsignedAccounts: number
138
+ }
139
+ instructions: {
140
+ programIdIndex: number
141
+ accounts: number[]
142
+ data: string
143
+ }[]
144
+ recentBlockhash: string
145
+ }
146
+ }
147
+ }
148
+ }
149
+
150
+ // Simulation types
151
+ export interface SimulateTransactionParam {
152
+ to: string
153
+ value?: string
154
+ data?: string
155
+ gas?: string
156
+ gasPrice?: string
157
+ maxFeePerGas?: string
158
+ maxPriorityFeePerGas?: string
159
+ }
160
+
161
+ export interface SimulatedTransactionChange {
162
+ amount?: string
163
+ assetType?: string
164
+ changeType?: string
165
+ contractAddress?: string
166
+ decimals?: number
167
+ from?: string
168
+ name?: string
169
+ rawAmount?: string
170
+ symbol?: string
171
+ to?: string
172
+ tokenId?: number
173
+ }
174
+
175
+ export interface SimulatedTransactionError {
176
+ message: string
177
+ }
178
+
179
+ export interface SimulatedTransaction {
180
+ changes: SimulatedTransactionChange[]
181
+ gasUsed?: string
182
+ error?: SimulatedTransactionError
183
+ requestError?: SimulatedTransactionError
184
+ }
185
+
186
+ export type EvaluateTransactionParam =
187
+ | {
188
+ to: string
189
+ value?: string
190
+ data?: string
191
+ gas?: string
192
+ gasPrice?: string
193
+ maxFeePerGas?: string
194
+ maxPriorityFeePerGas?: string
195
+ }
196
+ | {
197
+ transactions: string[]
198
+ }
199
+
200
+ export type EvaluateTransactionOperationType =
201
+ | 'validation'
202
+ | 'simulation'
203
+ | 'all'
204
+
205
+ export interface EvaluatedTransaction {
206
+ validation?: Validation
207
+ simulation?: Simulation
208
+ block?: number
209
+ }
210
+
211
+ interface AssetMovement {
212
+ summary: string
213
+ value: string
214
+ usdPrice?: string
215
+ rawValue: string
216
+ }
217
+
218
+ interface AssetDiff {
219
+ asset: Record<
220
+ string,
221
+ {
222
+ type: string
223
+ decimals: number
224
+ chainName?: string
225
+ chainId?: number
226
+ logoUrl?: string
227
+ name?: string
228
+ symbol?: string
229
+ }
230
+ >
231
+ in: Record<string, AssetMovement>[]
232
+ out: Record<string, AssetMovement>[]
233
+ }
234
+
235
+ interface AccountSummary {
236
+ assetsDiffs: Record<string, AssetDiff>[]
237
+ [k: string]: any
238
+ }
239
+
240
+ export type Simulation = SuccessfulSimulation | UnsuccessfulSimulation
241
+
242
+ interface SuccessfulSimulation {
243
+ accountAddress: string
244
+ accountSummary: AccountSummary
245
+ addressDetails: Record<string, any>
246
+ assetsDiffs: Record<string, AssetDiff[]>
247
+ status: string
248
+ exposures?: Record<string, any>
249
+ totalUsdDiff?: Record<string, any>
250
+ totalUsdExposure?: Record<string, any>
251
+ solana?: {
252
+ delegations: Record<string, Record<string, any>[]>
253
+ assetsOwnershipDiff: Record<string, Record<string, any>[]>
254
+ }
255
+ }
256
+
257
+ interface UnsuccessfulSimulation {
258
+ status: 'Error'
259
+ error: string
260
+ }
261
+
262
+ export type Validation = SuccessfulValidation | UnsuccessfulValidation
263
+
264
+ interface SuccessfulValidation {
265
+ classification?: string | null
266
+ description?: string | null
267
+ features: {
268
+ type?: 'Malicious' | 'Warning' | 'Benign' | 'Info'
269
+ featureId?: string
270
+ description: string
271
+ address?: string | null
272
+ }[]
273
+ reason?: string | null
274
+ resultType: 'Benign' | 'Warning' | 'Malicious'
275
+ status: string
276
+ }
277
+
278
+ interface UnsuccessfulValidation {
279
+ error: string
280
+ classification?: string | null
281
+ description?: string | null
282
+ features: {
283
+ type?: 'Malicious' | 'Warning' | 'Benign' | 'Info'
284
+ featureId?: string
285
+ description: string
286
+ address?: string | null
287
+ }[]
288
+ reason?: string | null
289
+ resultType: 'Error'
290
+ status: 'Error'
291
+ }
292
+
293
+ // NFT types
294
+ export interface NFTContract {
295
+ address: string
296
+ }
297
+
298
+ export interface TokenId {
299
+ tokenId: string
300
+ tokenMetadata: TokenMetadata
301
+ }
302
+
303
+ export interface TokenMetadata {
304
+ tokenType: string
305
+ }
306
+
307
+ export interface TokenUri {
308
+ gateway: string
309
+ raw: string
310
+ }
311
+
312
+ export interface Media {
313
+ gateway: string
314
+ thumbnail: string
315
+ raw: string
316
+ format: string
317
+ bytes: number
318
+ }
319
+
320
+ export interface Metadata {
321
+ name: string
322
+ description: string
323
+ image: string
324
+ external_url?: string
325
+ }
326
+
327
+ export interface ContractMetadata {
328
+ name: string
329
+ symbol: string
330
+ tokenType: string
331
+ contractDeployer: string
332
+ deployedBlockNumber: number
333
+ openSea?: OpenSeaMetadata
334
+ }
335
+
336
+ export interface OpenSeaMetadata {
337
+ collectionName: string
338
+ safelistRequestStatus: string
339
+ imageUrl?: string
340
+ description: string
341
+ externalUrl: string
342
+ lastIngestedAt: string
343
+ floorPrice?: number
344
+ twitterUsername?: string
345
+ discordUrl?: string
346
+ }
347
+
348
+ export interface NFT {
349
+ contract: NFTContract
350
+ id: TokenId
351
+ balance: string
352
+ title: string
353
+ description: string
354
+ tokenUri: TokenUri
355
+ media: Media[]
356
+ metadata: Metadata
357
+ timeLastUpdated: string
358
+ contractMetadata: ContractMetadata
359
+ }
360
+
361
+ // Config types
362
+ export interface GDriveConfig {
363
+ clientId: string
364
+ }
365
+
366
+ export interface PasskeyConfig {
367
+ relyingParty?: string
368
+ relyingPartyOrigins?: string[]
369
+ webAuthnHost?: string
370
+ }
371
+
372
+ export interface RpcConfig {
373
+ [key: string]: string
374
+ }
375
+
376
+ export interface CustomBackupConfig {
377
+ encryptionKey: string
378
+ }
379
+
380
+ // Backup method types - matches enum values from both browser and iframe packages
381
+ export type BackupMethod = 'GDRIVE' | 'PASSWORD' | 'PASSKEY' | 'CUSTOM' | 'UNKNOWN'
382
+
383
+ export interface BackupConfigs {
384
+ passwordStorage?: PasswordConfig
385
+ customStorage?: CustomBackupConfig
386
+ }
387
+
388
+ export interface BackupWorkerResult {
389
+ result: EncryptedData | EncryptedWithPasswordData
390
+ backupMethod: BackupMethod
391
+ }
392
+
393
+ export interface PasswordConfig {
394
+ password: string
395
+ }
396
+
397
+ export interface OrgBackupShares {
398
+ SECP256K1: string
399
+ ED25519?: string
400
+ }
401
+
402
+ // Fund types
403
+ export interface FundParams {
404
+ amount: string
405
+ token: string
406
+ }
407
+
408
+ export interface FundResponseData {
409
+ explorerUrl: string
410
+ txHash: string
411
+ }
412
+
413
+ export interface FundResponseMetadata {
414
+ amount: string
415
+ chainId: string
416
+ clientId: string
417
+ custodianId: string
418
+ environmentId: string
419
+ token: string
420
+ }
421
+
422
+ export interface FundResponse {
423
+ data?: FundResponseData
424
+ metadata: FundResponseMetadata
425
+ error?: string
426
+ }
427
+
428
+ // Send asset types
429
+ export interface SendAssetParams {
430
+ amount: string
431
+ to: string
432
+ token: string
433
+ sponsorGas?: boolean
434
+ }
435
+
436
+ export interface SendAssetResponse {
437
+ transactionHash: string
438
+ metadata: {
439
+ amount?: string
440
+ lastValidBlockHeight?: string
441
+ rawAmount?: string
442
+ tokenAddress?: string
443
+ tokenDecimals?: number
444
+ tokenSymbol?: string
445
+ }
446
+ }
447
+
448
+ // Encrypt/Decrypt types
449
+ export interface EncryptedData {
450
+ cipherText: string
451
+ key: string
452
+ }
453
+
454
+ export interface EncryptedWithPasswordData {
455
+ cipherText: string
456
+ }
457
+
458
+ // Alias for backward compatibility
459
+ export type EncryptWithPasswordData = EncryptedWithPasswordData
460
+
461
+ export interface DecryptData {
462
+ plaintext: string
463
+ }
464
+
465
+ // Quote types
466
+ export interface QuoteArgs {
467
+ affiliateAddress?: string
468
+ buyAmount?: number
469
+ buyToken: string
470
+ buyTokenPercentageFee?: number
471
+ enableSlippageProtection?: boolean
472
+ excludedSources?: string
473
+ feeRecipient?: string
474
+ gasPrice?: number
475
+ includedSources?: string
476
+ intentOnFilling?: boolean
477
+ priceImpactProtectionPercentage?: number
478
+ sellAmount?: number
479
+ sellToken: string
480
+ skipValidation?: boolean
481
+ slippagePercentage?: number
482
+ takerAddress?: string
483
+ }
484
+
485
+ export interface QuoteResponse {
486
+ allowanceTarget: string
487
+ cost: string
488
+ transaction: EIP1559Transaction | LegacyTransaction
489
+ }
490
+
491
+ // Misc types
492
+ export interface SwitchEthereumChainParameter {
493
+ chainId: string
494
+ }
495
+
496
+ export interface TypedData {
497
+ types: Type[]
498
+ primaryType: string
499
+ domain: string
500
+ message: string
501
+ }
502
+
503
+ export interface Type {
504
+ name: string
505
+ type: string
506
+ }
507
+
508
+ // Dapp types
509
+ export interface DappOnNetwork {
510
+ clientUrl?: string
511
+ dapp: Dapp
512
+ id: string
513
+ network: Network
514
+ }
515
+
516
+ export interface Dapp {
517
+ id: string
518
+ name: string
519
+
520
+ addresses: Address[]
521
+ dappOnNetworks: DappOnNetwork[]
522
+ image: DappImage
523
+ }
524
+
525
+ export interface DappImage {
526
+ id: string
527
+ filename: string
528
+ data: string
529
+ }
530
+
531
+ // MPC operation types
532
+ export interface SignArgs {
533
+ chainId: string
534
+ method: string
535
+ params: string
536
+ rpcUrl: string
537
+ sponsorGas?: boolean
538
+ }
539
+
540
+ export interface SignResult {
541
+ data: string
542
+ error: PortalError
543
+ }
544
+
545
+ export interface EncryptArgs {
546
+ dkgData: string
547
+ }
548
+
549
+ export interface DecryptArgs {
550
+ cipherText: string
551
+ key?: string
552
+ privateKey?: string
553
+ }
554
+
555
+ export interface GenerateData {
556
+ address: string
557
+ dkgResult: DkgData
558
+ }
559
+
560
+ export interface EncryptedResult {
561
+ data: EncryptedData | EncryptedWithPasswordData
562
+ error: PortalError
563
+ }
564
+
565
+ export interface DecryptResult {
566
+ data: DecryptData
567
+ error: PortalError
568
+ }
569
+
570
+ export interface EncryptedWithPasswordResult {
571
+ data: EncryptedWithPasswordData
572
+ error: PortalError
573
+ }
574
+
575
+ export interface MpcStatus {
576
+ status: string
577
+ done: boolean
578
+ }
579
+
580
+ export interface SharesOnDeviceResponse {
581
+ ED25519: boolean
582
+ SECP256K1: boolean
583
+ }
584
+
585
+ export interface EjectResult {
586
+ SECP256K1: string
587
+ }
588
+
589
+ export interface EjectPrivateKeysResult {
590
+ ED25519: string
591
+ SECP256K1: string
592
+ }
593
+
594
+ export interface GenerateResult {
595
+ data: GenerateData
596
+ error: PortalError
597
+ }
598
+
599
+ export interface GenerateResponse {
600
+ address: string
601
+ cipherText?: string
602
+ share?: string
603
+ }
604
+
605
+ export interface RotateData {
606
+ address: string
607
+ dkgResult: DkgData
608
+ }
609
+
610
+ export interface RotateResult {
611
+ data: RotateData
612
+ error: PortalError
613
+ }
614
+
615
+ export interface BackupData {
616
+ share: string
617
+ }
618
+
619
+ export interface BackupResult {
620
+ backupIds: string[]
621
+ cipherText: string
622
+ encryptionKey?: string
623
+ }
624
+
625
+ export interface BackupResponse {
626
+ cipherText: string
627
+ storageCallback: () => Promise<void>
628
+ encryptionKey?: string
629
+ }
630
+
631
+ export interface AddressResult {
632
+ data: string
633
+ type: string
634
+ }
635
+
636
+ // Passkey types
637
+ export interface PasskeyStatusResponse {
638
+ status: string
639
+ }
640
+
641
+ export interface PasskeyStorageOptions<TPortal = unknown> {
642
+ portal: TPortal
643
+ relyingParty?: string
644
+ relyingPartyOrigins?: string[]
645
+ webAuthnHost?: string
646
+ authOrigin?: string
647
+ }
648
+
649
+ // Client Response types
650
+ export type SharePairStatus = 'completed' | 'incomplete'
651
+
652
+ export interface ClientResponseCustodian {
653
+ id: string
654
+ name: string
655
+ }
656
+
657
+ export interface ClientResponseSharePair {
658
+ id: string
659
+ createdAt: string
660
+ status: SharePairStatus
661
+ }
662
+
663
+ export interface WalletPublicKey {
664
+ X: string
665
+ Y: string
666
+ }
667
+
668
+ // MPC Operation types
669
+ export interface MpcOperationArgs {
670
+ host: string
671
+ mpcVersion: string
672
+ apiKey?: string
673
+ featureFlags?: FeatureFlags
674
+ }
675
+
676
+ export type GenerateArgs = MpcOperationArgs
677
+
678
+ export interface EjectWorkerArgs extends MpcOperationArgs {
679
+ clientShare: string
680
+ organizationBackupShare: string
681
+ }