-
Notifications
You must be signed in to change notification settings - Fork 873
/
brave_wallet.mojom
3260 lines (2765 loc) · 101 KB
/
brave_wallet.mojom
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright (c) 2021 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at http://mozilla.org/MPL/2.0/.
module brave_wallet.mojom;
import "brave/components/brave_wallet/common/meld_integration.mojom";
import "mojo/public/mojom/base/time.mojom";
import "mojo/public/mojom/base/values.mojom";
import "url/mojom/origin.mojom";
import "url/mojom/url.mojom";
const int8 kAccountNameMaxCharacterLength = 30;
// Used to notify the renderer of provider information for use in
// window.ethereum events
interface EventsListener {
// Fired when the current netowrk changes
ChainChangedEvent(string chain_id);
// Fired when the accounts have changed such as when the wallet locked, the
// selected account changes, a new account is given permission, etc.
AccountsChangedEvent(array<string> accounts);
// Fired when there is a message from eth_subscribe
MessageEvent(string subscription_id, mojo_base.mojom.Value result);
};
interface SolanaEventsListener {
// base58 encoded account, account would be null when switching to an about to
// be created account
AccountChangedEvent(string? account);
// Wallet initiated disconnect event. Ex. permission revoked
DisconnectEvent();
};
// Pre-defined error codes specified in
// https://www.jsonrpc.org/specification#error_object
enum JsonRpcError {
kParsingError = -32700, // Parse error - Invalid JSON
kInvalidRequest = -32600, // JSON is not a valid request object
kMethodNotFound = -32601, // Method does not exist
kInvalidParams = -32602, // Invalid method parameters
kInternalError = -32603, // Internal JSON RPC error
};
// https://eips.ethereum.org/EIPS/eip-1193#provider-errors
// https://eips.ethereum.org/EIPS/eip-1474#error-codes
enum ProviderError {
kSuccess = 0, // No error
kUserRejectedRequest = 4001, // User rejected the request
kUnauthorized = 4100, // The requested account and/or method has not
// been authorized by the user
kUnsupportedMethod = 4200, // The requested method is not supported by this
// Ethereum provider
kDisconnected = 4900, // The provider is disconnected from all chains
kChainDisconnected = 4901, // The provider is disconnected from the
// specified chain
kUnknownChain = 4902, // The provider doesn't know this chain
// Pre-defined error codes specified in
// https://www.jsonrpc.org/specification#error_object
kParsingError = JsonRpcError.kParsingError, // Parse error - Invalid JSON
kInvalidRequest = JsonRpcError.kInvalidRequest, // JSON is not a valid request object
kMethodNotFound = JsonRpcError.kMethodNotFound, // Method does not exist
kInvalidParams = JsonRpcError.kInvalidParams, // Invalid method parameters
kInternalError = JsonRpcError.kInternalError, // Internal JSON RPC error
// Implementation-defined server-errors
kInvalidInput = -32000, // Missing or invalid parameters
kResourceNotFound = -32001, // Requested resource not found
kResourceUnavailable = -32002, // Requested resource not available
kTransactionRejected = -32003, // Transaction creation failed
kMethodNotSupported = -32004, // Method is not implemented
kLimitExceeded = -32005, // Request exceeds defined limit
kVersionNotSupported = -32006, // Version of JSON-RPC protocol is not supported
kUnknown = -1 // Unknown error
};
enum FilecoinProviderError {
kSuccess = ProviderError.kSuccess, // No error
kUnknown = ProviderError.kUnknown,
kActorNotFound = 1, // Actor not found for given address
// Pre-defined error codes specified in
// https://www.jsonrpc.org/specification#error_object
kParsingError = JsonRpcError.kParsingError, // Parse error - Invalid JSON
kInvalidRequest = JsonRpcError.kInvalidRequest, // JSON is not a valid request object
kMethodNotFound = JsonRpcError.kMethodNotFound, // Method does not exist
kInvalidParams = JsonRpcError.kInvalidParams, // Invalid method parameters
kInternalError = JsonRpcError.kInternalError, // Internal JSON RPC error
};
enum SolanaProviderError {
kSuccess = ProviderError.kSuccess, // No error
kUnknown = ProviderError.kUnknown,
kUserRejectedRequest = ProviderError.kUserRejectedRequest,
kUnauthorized = ProviderError.kUnauthorized,
kResourceUnavailable = ProviderError.kResourceUnavailable,
// Pre-defined error codes specified in
// https://www.jsonrpc.org/specification#error_object
kParsingError = JsonRpcError.kParsingError, // Parse error - Invalid JSON
kInvalidRequest = JsonRpcError.kInvalidRequest, // JSON is not a valid request object
kMethodNotFound = JsonRpcError.kMethodNotFound, // Method does not exist
kInvalidParams = JsonRpcError.kInvalidParams, // Invalid method parameters
kInternalError = JsonRpcError.kInternalError, // Internal JSON RPC error
// Implementation defined RPC server errors
// https://docs.rs/solana-client/1.9.9/src/solana_client/rpc_custom_error.rs.html
kBlockCleanedUp = -32001,
kSendTransactionPreflightFailure = -32002,
kTransactionSignatureVerificationFailure = -32003,
kBlockNotAvailable = -32004,
kNodeUnhealthy = -32005,
kTransactionPrecompileVerificationFailure = -32006,
kSlotSkipped = -32007,
kNoSnapshot = -32008,
kLongTermStorageSlotSkipped = -32009,
kKeyExcludedFromSecondaryIndex = -32010,
kTransactionHistoryNotAvailable = -32011,
kScanError = -32012,
kTransactionSignatureLenMismatch = -32013,
kBlockStatusNotAvailableYet = -32014
};
enum BitcoinProviderError {
kSuccess = ProviderError.kSuccess, // No error
kUnknown = ProviderError.kUnknown,
kInternalError = JsonRpcError.kInternalError,
};
enum ZCashProviderError {
kSuccess = ProviderError.kSuccess, // No error
kUnknown = ProviderError.kUnknown,
kInternalError = JsonRpcError.kInternalError,
// Fired when there are several outgoings transactions
kMultipleTransactionsNotSupported
};
union ProviderErrorUnion {
ProviderError provider_error;
SolanaProviderError solana_provider_error;
FilecoinProviderError filecoin_provider_error;
BitcoinProviderError bitcoin_provider_error;
ZCashProviderError zcash_provider_error;
};
// There is one EthereumProvider per renderer, the renderer communicates
// with this for window.ethereum usage.
interface EthereumProvider {
// Initializes an EventsListener
Init(pending_remote<EventsListener> events_listener);
// Corresponds to window.ethereum.request
Request(mojo_base.mojom.Value input) => (mojo_base.mojom.Value id, mojo_base.mojom.Value formed_response,bool reject, string first_allowed_account, bool update_bind_js_properties);
// Corresponds to window.ethereum.enable and eth_requestAccounts
Enable() => (mojo_base.mojom.Value id, mojo_base.mojom.Value formed_response,bool reject, string first_allowed_account, bool update_bind_js_properties);
Send(string method, mojo_base.mojom.ListValue params) => (mojo_base.mojom.Value id, mojo_base.mojom.Value formed_response,bool reject, string first_allowed_account, bool update_bind_js_properties);
SendAsync(mojo_base.mojom.Value input) => (mojo_base.mojom.Value id, mojo_base.mojom.Value formed_response, bool reject, string first_allowed_account, bool update_bind_js_properties);
// Used for the connect event
GetChainId() => (string chain_id);
// Determines if the keyring is locked.
IsLocked() => (bool isLocked);
};
struct EthereumSignatureVRS {
array<uint8> v_bytes;
array<uint8> r_bytes;
array<uint8> s_bytes;
};
struct EthereumSignatureBytes {
array<uint8> bytes;
};
struct SolanaSignature {
array<uint8> bytes;
};
struct FilecoinSignature {
// TODO(apaymyshev): this should be just a signature, not fully signed message.
string signed_message_json;
};
struct BitcoinSignature {
// Each item corresponds to each input of a transaction.
array<array<uint8>> witness_array;
};
// https://github.com/solana-labs/solana-web3.js/blob/6482d0d/src/transaction.ts#L126
struct SignaturePubkeyPair {
SolanaSignature? signature;
string public_key;
};
struct SolanaSignTransactionParam {
string encoded_serialized_msg;
array<SignaturePubkeyPair> signatures;
};
interface SolanaProvider {
// Initializes an SolanaEventsListener
Init(pending_remote<SolanaEventsListener> events_listener);
// Optional {onlyIfTrusted: true}, when that flag is enable, we will only
// connect and emit a connect event if the application is trusted.
// It will returns base58 encoded pu blic key when success
Connect(mojo_base.mojom.DictionaryValue? arg)
=> (SolanaProviderError error, string error_message, string public_key);
Disconnect();
[Sync]
IsConnected() => (bool is_connected);
// return base58 encoded public key
[Sync]
GetPublicKey() => (string public_key);
// It takes a base58 encoded serialized Message and return a serialized
// Transaction with signature in wire format.
SignTransaction(SolanaSignTransactionParam param)
=> (SolanaProviderError error, string error_message,
array<uint8> serialized_tx,
SolanaMessageVersion version);
SignAllTransactions(array<SolanaSignTransactionParam> params)
=> (SolanaProviderError error, string error_message,
array<array<uint8>> serialized_txs,
array<SolanaMessageVersion> versions);
// It takes a base58 encoded serialized Message and return an object
// containing both base58 encoded public key and signature as
// { publicKey: <base58 encoded string>,
// signature: <base58 encoded string>
// }
// Optional argument send_options:
// { maxRetries?: <number>,
// preflightCommitment?: <string>,
// skipPreflight?: <boolean>
// }
SignAndSendTransaction(
SolanaSignTransactionParam param,
mojo_base.mojom.DictionaryValue? send_options)
=> (SolanaProviderError error, string error_message,
mojo_base.mojom.DictionaryValue result);
// It takes a byte array and an optional display encoding for
// users and returns an object as
// { publicKey: <base58 encoded string>,
// signature: <base58 encoded string>
// }
SignMessage(array<uint8> blob_msg, string? display_encoding)
=> (SolanaProviderError error, string error_message,
mojo_base.mojom.DictionaryValue result);
// Arg is {method: <string>, params: {...}}
// returns a dictionary result to be converted into a v8 object
Request(mojo_base.mojom.DictionaryValue arg)
=> (SolanaProviderError error, string error_message,
mojo_base.mojom.DictionaryValue result);
};
// Used by the WebUI page to bootstrap bidirectional communication.
interface PanelHandlerFactory {
// The WebUI calls this method when the page is first initialized.
CreatePanelHandler(pending_receiver<PanelHandler> panel_handler,
pending_receiver<WalletHandler> wallet_handler,
pending_receiver<JsonRpcService> json_rpc_service,
pending_receiver<BitcoinWalletService> bitcoin_wallet_service,
pending_receiver<ZCashWalletService> zcash_wallet_service,
pending_receiver<SwapService> swap_service,
pending_receiver<SimulationService> simulation_service,
pending_receiver<AssetRatioService> asset_ratio_service,
pending_receiver<KeyringService> keyring_service,
pending_receiver<BlockchainRegistry> blockchain_registry,
pending_receiver<TxService> tx_service,
pending_receiver<EthTxManagerProxy> eth_tx_manager_proxy,
pending_receiver<SolanaTxManagerProxy> solana_tx_manager_proxy,
pending_receiver<FilTxManagerProxy> fil_tx_manager_proxy,
pending_receiver<BtcTxManagerProxy> btc_tx_manager_proxy,
pending_receiver<BraveWalletService> brave_wallet_service,
pending_receiver<BraveWalletP3A> brave_wallet_p3a,
pending_receiver<IpfsService>
brave_wallet_ipfs_service_receiver,
pending_receiver<MeldIntegrationService>
meld_integration_service);
};
interface PageHandlerFactory {
// The WebUI calls this method when the page is first initialized.
CreatePageHandler(pending_receiver<PageHandler> page_handler,
pending_receiver<WalletHandler> wallet_handler,
pending_receiver<JsonRpcService> json_rpc_service,
pending_receiver<BitcoinWalletService> bitcoin_wallet_service,
pending_receiver<ZCashWalletService> zcash_wallet_service,
pending_receiver<SwapService> swap_service,
pending_receiver<AssetRatioService> asset_ratio_service,
pending_receiver<KeyringService> keyring_service,
pending_receiver<BlockchainRegistry> blockchain_registry,
pending_receiver<TxService> tx_service,
pending_receiver<EthTxManagerProxy> eth_tx_manager_proxy,
pending_receiver<SolanaTxManagerProxy> solana_tx_manager_proxy,
pending_receiver<FilTxManagerProxy> fil_tx_manager_proxy,
pending_receiver<BtcTxManagerProxy> btc_tx_manager_proxy,
pending_receiver<BraveWalletService> brave_wallet_service,
pending_receiver<BraveWalletP3A> brave_wallet_p3a,
pending_receiver<IpfsService> brave_wallet_ipfs_service,
pending_receiver<MeldIntegrationService>
meld_integration_service);
};
// Lifetime option in sync with CreatePermissionLifetimeOptions()
enum PermissionLifetimeOption {
kPageClosed = 0,
k24Hours = 1,
k7Days = 2,
kForever = 3
};
// Browser-side handler for requests from WebUI page.
interface PanelHandler {
// Notify the backend that the UI is ready to be shown.
ShowUI();
// Notify the backend that the dialog should be closed.
CloseUI();
ConnectToSite(array<string> accounts, PermissionLifetimeOption option);
CancelConnectToSite();
SetCloseOnDeactivate(bool close);
Focus();
IsSolanaAccountConnected(string account) => (bool connected);
// Create a permission request for users based on active web contents.
// The flow will be similar to dapp request permission except it is initiated
// from panel. Desktop front end will be opened with same #connectWitSite ref
// and we need to call ConnectToSite or CancelConnectToSite based on user
// decision.
RequestPermission(AccountId account_id) => (bool success);
};
// Browser-side handler for requests from WebUI page.
interface PageHandler {
// Used by the brave://wallet page to open up the approval panel
ShowApprovePanelUI();
// Android only - Used by the brave://wallet page to open up the backup UI.
ShowWalletBackupUI();
// Android only - Used by the brave://wallet page to open up the unlock UI.
UnlockWalletUI();
};
enum AssetPriceTimeframe {
Live,
OneDay,
OneWeek,
OneMonth,
ThreeMonths,
OneYear,
All
};
struct AssetTimePrice {
mojo_base.mojom.TimeDelta date;
string price;
};
struct AssetPrice {
string from_asset;
string to_asset;
string price;
string asset_timeframe_change;
};
struct CoinMarket {
string id;
string symbol;
string name;
string image;
double market_cap;
uint32 market_cap_rank;
double current_price;
double price_change_24h;
double price_change_percentage_24h;
double total_volume;
};
struct Dapp {
uint32 id; // Assigned by DappRadar
string name;
string description;
string logo;
string website;
array<string> chains;
array<string> categories;
uint32 transactions;
uint32 uaw;
double volume;
double balance;
string range;
};
enum RoutePriority {
kFastest,
kCheapest
};
enum SwapProvider {
kAuto,
kLiFi,
kZeroEx,
kJupiter,
kSquid
};
struct SwapQuoteParams {
AccountId from_account_id;
string from_chain_id;
string from_token;
string from_amount;
// Setting the to_account_id is only supported for LiFi swaps.
AccountId to_account_id;
string to_chain_id;
string to_token;
// Setting the to_amount is not supported for Jupiter and LiFi swaps.
string to_amount;
string slippage_percentage;
// This is primarily used for LiFi swaps. For every other case, this should
// be set to kRecommended.
RoutePriority route_priority;
SwapProvider provider;
};
union SwapTransactionParamsUnion {
JupiterTransactionParams jupiter_transaction_params;
SwapQuoteParams zero_ex_transaction_params;
LiFiStep lifi_transaction_params;
SwapQuoteParams squid_transaction_params;
};
union SwapQuoteUnion {
JupiterQuote jupiter_quote;
ZeroExQuote zero_ex_quote;
LiFiQuote lifi_quote;
SquidQuote squid_quote;
};
union SwapTransactionUnion {
string jupiter_transaction;
ZeroExTransaction zero_ex_transaction;
LiFiTransactionUnion lifi_transaction;
SquidTransactionUnion squid_transaction;
};
struct ZeroExFee {
string amount;
string token;
string type;
};
struct ZeroExFees {
ZeroExFee? zero_ex_fee;
};
struct ZeroExTransaction {
string to;
string data;
string gas;
string gas_price;
string value;
};
struct ZeroExRouteFill {
string from;
string to;
string source;
string proportion_bps;
};
struct ZeroExRoute {
array<ZeroExRouteFill> fills;
};
struct ZeroExQuote {
string buy_amount;
string buy_token;
ZeroExFees fees;
string gas;
string gas_price;
bool liquidity_available;
string min_buy_amount;
ZeroExRoute route;
string sell_amount;
string sell_token;
string total_network_fee;
// Custom field
string allowance_target;
};
struct ZeroExError {
string name;
string message;
bool is_insufficient_liquidity;
};
union SwapErrorUnion {
JupiterError jupiter_error;
ZeroExError zero_ex_error;
LiFiError lifi_error;
SquidError squid_error;
};
// Structs to model Jupiter (swap) HTTP API interactions
// Swagger spec: https://station.jup.ag/api-v6/get-quote
//
// Note that amount field is incorrectly modelled as number in spec,
// but it has been fixed here.
struct JupiterPlatformFee {
string amount;
string fee_bps;
};
struct JupiterSwapInfo {
string amm_key;
string label;
string input_mint;
string output_mint;
string in_amount;
string out_amount;
string fee_amount;
string fee_mint;
};
struct JupiterRouteStep {
JupiterSwapInfo swap_info;
string percent;
};
struct JupiterQuote {
string input_mint;
string in_amount;
string output_mint;
string out_amount;
string other_amount_threshold;
string swap_mode;
string slippage_bps;
JupiterPlatformFee? platform_fee;
string price_impact_pct;
array<JupiterRouteStep> route_plan;
};
struct JupiterTransactionParams {
JupiterQuote quote;
string chain_id;
string user_public_key;
};
struct JupiterError {
string status_code;
string error;
string message;
bool is_insufficient_liquidity;
};
struct LiFiStepStatus {
string chain_id;
// The following fields are temporarily undefined in case of a pending
// receiving step.
string? tx_hash;
string? tx_link;
string? amount;
string? contract_address;
};
enum LiFiStatusCode {
kNotFound,
kInvalid,
kPending,
kDone,
kFailed
};
enum LiFiSubstatusCode {
// Substatuses for kPending
kWaitSourceConfirmations,
kWaitDestinationTransaction,
kBridgeNotAvailable,
kChainNotAvailable,
kRefundInProgress,
kUnknownError,
// Substatuses for kDone
kCompleted,
kPartial,
kRefunded,
// Substatuses for kFailed
kNotProcessableRefundNeeded,
kOutOfGas,
kSlippageExceeded,
kInsufficientAllowance,
kInsufficientBalance,
kExpired
};
struct LiFiStatus {
string transaction_id;
LiFiStepStatus sending;
LiFiStepStatus receiving;
string lifi_explorer_link;
string from_address;
string to_address;
string tool;
LiFiStatusCode status;
LiFiSubstatusCode substatus;
string substatus_message;
};
enum LiFiStepType {
kSwap,
kCross,
kLiFi
};
struct LiFiToolDetails {
string key;
string name;
string logo;
};
struct LiFiAction {
BlockchainToken from_token;
string from_amount;
BlockchainToken to_token;
string slippage;
string? from_address;
string? to_address;
string? destination_call_data;
};
struct LiFiFeeCost {
string name;
string description;
string percentage;
BlockchainToken token;
string amount;
bool included;
};
struct LiFiGasCost {
string type;
string estimate;
string limit;
string amount;
BlockchainToken token;
};
struct LiFiStepEstimate {
string tool;
string from_amount;
string to_amount;
string to_amount_min;
string approval_address;
string execution_duration;
array<LiFiFeeCost>? fee_costs;
array<LiFiGasCost> gas_costs;
};
struct LiFiStep {
string id;
LiFiStepType type;
string tool;
LiFiToolDetails tool_details;
LiFiAction action;
LiFiStepEstimate estimate;
// Not defined in included steps
string? integrator;
array<LiFiStep>? included_steps;
};
struct LiFiRoute {
string id;
string unique_id;
BlockchainToken from_token;
string from_amount;
string from_address;
BlockchainToken to_token;
string to_amount;
string to_amount_min;
string to_address;
array<LiFiStep> steps;
array<string> tags;
};
struct LiFiQuote {
array<LiFiRoute> routes;
};
union LiFiTransactionUnion {
string solana_transaction;
LiFiEvmTransaction evm_transaction;
};
struct LiFiEvmTransaction {
string data;
string from;
string to;
string value;
string gas_limit;
string gas_price;
string chain_id;
};
enum LifiToolErrorCode {
// No route was found for this action.
kNoPossibleRoute = 0,
// The tool's liquidity is insufficient.
kInsufficientLiquidity = 1,
// The third-party tool timed out.
kToolTimeout = 2,
// An unknown error occurred.
kUnknownError = 3,
// There was a problem getting on-chain data. Please try again later.
kRpcError = 3,
// he initial amount is too low to transfer using this tool.
kAmountTooLow = 4,
// The initial amount is too high to transfer using this tool.
kAmountTooHigh = 5,
// The fees are higher than the initial amount.
// This would result in negative resulting token.
kFeesHigherThanAmount = 6,
// This tool does not support different recipient addresses.
kDifferentRecipientNotSupported = 7,
// The third-party tool returned an error.
kToolSpecificError = 8,
// The tool cannot guarantee that the minimum amount will be met.
kCannotGuaranteeMinAmount = 9
};
// https://github.com/lifinance/types/blob/main/src/errors.ts
enum LiFiErrorCode {
kSuccess = 0,
kDefaultError = 1000,
kFailedToBuildTransactionError = 1001,
kNoQuoteError = 1002,
kNotFoundError = 1003,
kNotProcessableError = 1004,
kRateLimitError = 1005,
kServerError = 1006,
kSlippageError = 1007,
kThirdPartyError = 1008,
kTimeoutError = 1009,
kUnauthorizedError = 1010,
kValidationError = 1011,
};
struct LifiToolError {
string error_type;
string code;
string tool;
string message;
};
struct LiFiError {
string message;
LiFiErrorCode code;
};
// Squid types
enum SquidActionType {
kWrap,
kUnwrap,
kSwap,
kBridge,
kUnknown
};
struct SquidAction {
SquidActionType type;
string description;
string provider;
string logo_uri;
string from_amount;
BlockchainToken from_token;
string to_amount;
string to_amount_min;
BlockchainToken to_token;
};
struct SquidGasCost {
string amount;
string gas_limit;
BlockchainToken token;
};
struct SquidFeeCost {
string amount;
string description;
string name;
BlockchainToken token;
};
struct SquidQuote {
array<SquidAction> actions;
string aggregate_price_impact;
string aggregate_slippage;
string estimated_route_duration;
string exchange_rate;
array<SquidFeeCost> fee_costs;
array<SquidGasCost> gas_costs;
bool is_boost_supported;
string from_amount;
BlockchainToken from_token;
string to_amount;
string to_amount_min;
BlockchainToken to_token;
string allowance_target;
};
enum SquidErrorType {
kBadRequest,
kSchemaValidationError,
kUnknownError
};
struct SquidError {
string message;
SquidErrorType type;
};
union SquidTransactionUnion {
SquidEvmTransaction evm_transaction;
};
struct SquidEvmTransaction {
string data;
string target;
string value;
string gas_limit;
string gas_price;
string last_base_fee_per_gas;
string max_fee_per_gas;
string max_priority_fee_per_gas;
string chain_id;
};
enum SwapDiscountCode {
// No discount
kNone = 0,
// 100% discount is offered because of our inability to collect fees
// for the given output token.
//
// Applicable for Jupiter swaps only.
kUnknownJupiterOutputMint = 1,
};
struct SwapFees {
// The fee value to use for fetching quotes. The representation of this value
// is contextual to the underlying API being used.
//
// An empty value indicates that no fee value should be supplied to the
// API.
string fee_param;
string fee_pct;
string discount_pct;
string effective_fee_pct;
SwapDiscountCode discount_code;
};
enum KeyringId {
kDefault = 0,
kSolana = 1,
kFilecoin = 2,
kFilecoinTestnet = 3,
kBitcoin84 = 4,
kBitcoin84Testnet = 5,
kZCashMainnet = 6,
kZCashTestnet = 7,
kBitcoinImport = 8,
kBitcoinImportTestnet = 9,
kBitcoinHardware = 10,
kBitcoinHardwareTestnet = 11,
};
const string kP3ACountTestNetworksSwitch = "p3a-count-wallet-test-networks";
const string kP3ACountTestNetworksLoadTimeKey = "braveWalletP3ACountTestNetworks";
enum FilecoinAddressProtocol {
SECP256K1 = 1, // Represents the address SECP256K1 protocol
BLS = 3, // Represents the address BLS protocol
DELEGATED = 4
};
enum HardwareVendor {
kLedger = 1,
kTrezor = 2
};
struct HardwareWalletAccount {
string address; // Account's address or account's xpub for BTC.
string derivation_path;
string name;
HardwareVendor hardware_vendor;
string device_id;
KeyringId keyring_id;
};
struct HardwareInfo {
string path;
HardwareVendor vendor;
string device_id;
};
enum AccountKind {
kDerived,
kImported,
kHardware
};
struct AccountId {
CoinType coin;
// TODO(apaymyshev): that should be different keyrings for different kinds.
KeyringId keyring_id;
AccountKind kind;
// TODO(apaymyshev): should be an index within keyring.
string address;
// Account index for index-based keyrings (BTC and ZEC).
uint32 account_index;
// Two `AccountIds` equal iff their `unique_key` fields equal. Use this to
// check AccountIds for equality or to store as string keys. Persist with
// caution as format may change.
string unique_key;
};
struct AccountInfo {
AccountId account_id;
string address;
string name;
HardwareInfo? hardware;
};
struct AllAccountsInfo {
array<AccountInfo> accounts;
// `selected_account` is null only when there is no accounts at all which
// happens in tests.
AccountInfo? selected_account;
AccountInfo? eth_dapp_selected_account;
AccountInfo? sol_dapp_selected_account;
};
struct WalletInfo {
bool is_wallet_created;
bool is_wallet_locked;
bool is_wallet_backed_up;
bool is_bitcoin_enabled;
bool is_bitcoin_import_enabled;
bool is_bitcoin_ledger_enabled;
bool is_z_cash_enabled;
bool is_ankr_balances_feature_enabled;
bool is_transaction_simulations_feature_enabled;
bool is_z_cash_shielded_transactions_enabled;
};
// Browser-side handler for common panel / page things
interface WalletHandler {
// Obtains basic information about the wallet that is needed for first render
GetWalletInfo() => (WalletInfo walletInfo);
};
enum SPLTokenProgram {
kUnknown = 0, // To be determined by the backend.
kUnsupported = 1, // Unsupported token program or not SPL token.
kToken = 2,
kToken2022 = 3,
};
struct BlockchainToken {
// TODO(jocelyn): contract_address should be renamed to address to be a
// general naming for different coin type. Currently it's token mint address
// in Solana's context.
string contract_address;
string name;
string logo;