@swapkit/helpers 3.0.0-beta.2 → 3.0.0-beta.20

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.
Files changed (73) hide show
  1. package/dist/api/index.cjs +2 -2
  2. package/dist/api/index.cjs.map +6 -6
  3. package/dist/api/index.js +2 -2
  4. package/dist/api/index.js.map +6 -6
  5. package/dist/{chunk-6vvdbb6s.js → chunk-7shcm26h.js} +3 -3
  6. package/dist/{chunk-6vvdbb6s.js.map → chunk-7shcm26h.js.map} +1 -1
  7. package/dist/chunk-8fdws4se.js +4 -0
  8. package/dist/chunk-8fdws4se.js.map +10 -0
  9. package/dist/{chunk-dbsrwnw2.js → chunk-b8hashv0.js} +3 -3
  10. package/dist/{chunk-dbsrwnw2.js.map → chunk-b8hashv0.js.map} +1 -1
  11. package/dist/{chunk-kdcsgh3q.js → chunk-bf0ph1bk.js} +3 -3
  12. package/dist/{chunk-kdcsgh3q.js.map → chunk-bf0ph1bk.js.map} +1 -1
  13. package/dist/{chunk-mmwvr2y8.js → chunk-bh986mnf.js} +3 -3
  14. package/dist/{chunk-mmwvr2y8.js.map → chunk-bh986mnf.js.map} +1 -1
  15. package/dist/{chunk-ahpfxkx0.js → chunk-dzypg9sp.js} +3 -3
  16. package/dist/{chunk-ahpfxkx0.js.map → chunk-dzypg9sp.js.map} +1 -1
  17. package/dist/{chunk-wmxwvv8c.js → chunk-ghdhtvtt.js} +3 -3
  18. package/dist/{chunk-wmxwvv8c.js.map → chunk-ghdhtvtt.js.map} +1 -1
  19. package/dist/{chunk-fr86y3rx.js → chunk-jhmhh7ax.js} +3 -3
  20. package/dist/{chunk-fr86y3rx.js.map → chunk-jhmhh7ax.js.map} +1 -1
  21. package/dist/{chunk-ekd1k975.js → chunk-nm1av1e6.js} +3 -3
  22. package/dist/{chunk-ekd1k975.js.map → chunk-nm1av1e6.js.map} +1 -1
  23. package/dist/{chunk-wrjh857m.js → chunk-rarep8vg.js} +3 -3
  24. package/dist/{chunk-wrjh857m.js.map → chunk-rarep8vg.js.map} +1 -1
  25. package/dist/{chunk-kr69v1tm.js → chunk-rr043vwc.js} +3 -3
  26. package/dist/{chunk-kr69v1tm.js.map → chunk-rr043vwc.js.map} +1 -1
  27. package/dist/{chunk-3wnfcm30.js → chunk-s82pm7xc.js} +2 -2
  28. package/dist/{chunk-3wnfcm30.js.map → chunk-s82pm7xc.js.map} +1 -1
  29. package/dist/chunk-sb9hymk1.js +3 -0
  30. package/dist/chunk-sb9hymk1.js.map +10 -0
  31. package/dist/{chunk-tq87xn7m.js → chunk-tn4e7zrk.js} +3 -3
  32. package/dist/{chunk-tq87xn7m.js.map → chunk-tn4e7zrk.js.map} +1 -1
  33. package/dist/{chunk-z8emzpyc.js → chunk-vadspc46.js} +3 -3
  34. package/dist/{chunk-z8emzpyc.js.map → chunk-vadspc46.js.map} +1 -1
  35. package/dist/{chunk-xyczdrny.js → chunk-vgg88vt8.js} +3 -3
  36. package/dist/{chunk-xyczdrny.js.map → chunk-vgg88vt8.js.map} +1 -1
  37. package/dist/{chunk-q8xy3739.js → chunk-wssz50sc.js} +3 -3
  38. package/dist/{chunk-q8xy3739.js.map → chunk-wssz50sc.js.map} +1 -1
  39. package/dist/contracts/index.js +1 -1
  40. package/dist/index.cjs +3 -3
  41. package/dist/index.cjs.map +18 -18
  42. package/dist/index.js +3 -3
  43. package/dist/index.js.map +18 -18
  44. package/dist/tokens/index.js +2 -2
  45. package/dist/tokens/index.js.map +2 -2
  46. package/package.json +6 -5
  47. package/src/api/microgard/types.ts +0 -3
  48. package/src/api/midgard/endpoints.ts +1 -65
  49. package/src/api/midgard/types.ts +0 -49
  50. package/src/api/swapkitApi/endpoints.ts +16 -10
  51. package/src/api/swapkitApi/types.ts +1 -1
  52. package/src/api/thornode/endpoints.ts +22 -4
  53. package/src/api/thornode/types.ts +3 -2
  54. package/src/index.ts +1 -0
  55. package/src/modules/__tests__/assetValue.test.ts +66 -23
  56. package/src/modules/__tests__/swapKitNumber.test.ts +4 -5
  57. package/src/modules/assetValue.ts +84 -33
  58. package/src/modules/bigIntArithmetics.ts +12 -1
  59. package/src/modules/feeMultiplier.ts +87 -0
  60. package/src/modules/requestClient.ts +34 -23
  61. package/src/modules/swapKitConfig.ts +9 -1
  62. package/src/modules/swapKitError.ts +325 -105
  63. package/src/types/chains.ts +92 -44
  64. package/src/types/derivationPath.ts +2 -0
  65. package/src/types/quotes.ts +1 -2
  66. package/src/types/sdk.ts +0 -2
  67. package/src/types/wallet.ts +5 -0
  68. package/src/utils/__tests__/memo.test.ts +0 -20
  69. package/src/utils/asset.ts +18 -27
  70. package/src/utils/derivationPath.ts +6 -0
  71. package/src/utils/memo.ts +5 -42
  72. package/src/utils/others.ts +1 -2
  73. package/src/utils/wallets.ts +6 -3
@@ -2,44 +2,44 @@ const errorCodes = {
2
2
  /**
3
3
  * Core
4
4
  */
5
- core_estimated_max_spendable_chain_not_supported: 10002,
6
- core_extend_error: 10003,
7
- core_inbound_data_not_found: 10004,
8
- core_approve_asset_address_or_from_not_found: 10005,
9
- core_plugin_not_found: 10006,
10
- core_plugin_swap_not_found: 10007,
11
- core_approve_asset_target_invalid: 10008,
12
- core_explorer_unsupported_chain: 10009,
13
- core_verify_message_not_supported: 10010,
14
- core_chain_halted: 10099,
5
+ core_estimated_max_spendable_chain_not_supported: 10001,
6
+ core_extend_error: 10002,
7
+ core_inbound_data_not_found: 10003,
8
+ core_approve_asset_address_or_from_not_found: 10004,
9
+ core_plugin_not_found: 10005,
10
+ core_plugin_swap_not_found: 10006,
11
+ core_approve_asset_target_invalid: 10007,
12
+ core_explorer_unsupported_chain: 10008,
13
+ core_verify_message_not_supported: 10009,
14
+ core_chain_halted: 10010,
15
15
  /**
16
16
  * Core - Wallet
17
17
  */
18
- core_wallet_connection_not_found: 10100,
19
- core_wallet_ctrl_not_installed: 10101,
20
- core_wallet_evmwallet_not_installed: 10102,
21
- core_wallet_walletconnect_not_installed: 10103,
22
- core_wallet_keystore_not_installed: 10104,
23
- core_wallet_ledger_not_installed: 10105,
24
- core_wallet_trezor_not_installed: 10106,
25
- core_wallet_keplr_not_installed: 10107,
26
- core_wallet_okx_not_installed: 10108,
27
- core_wallet_keepkey_not_installed: 10109,
28
- core_wallet_talisman_not_installed: 10110,
29
- core_wallet_not_keypair_wallet: 10111,
30
- core_wallet_sign_message_not_supported: 10110,
31
- core_wallet_connection_failed: 10112,
18
+ core_wallet_connection_not_found: 10101,
19
+ core_wallet_ctrl_not_installed: 10102,
20
+ core_wallet_evmwallet_not_installed: 10103,
21
+ core_wallet_walletconnect_not_installed: 10104,
22
+ core_wallet_keystore_not_installed: 10105,
23
+ core_wallet_ledger_not_installed: 10106,
24
+ core_wallet_trezor_not_installed: 10107,
25
+ core_wallet_keplr_not_installed: 10108,
26
+ core_wallet_okx_not_installed: 10109,
27
+ core_wallet_keepkey_not_installed: 10110,
28
+ core_wallet_talisman_not_installed: 10111,
29
+ core_wallet_not_keypair_wallet: 10112,
30
+ core_wallet_sign_message_not_supported: 10113,
31
+ core_wallet_connection_failed: 10114,
32
32
  /**
33
33
  * Core - Swap
34
34
  */
35
- core_swap_invalid_params: 10200,
36
- core_swap_route_not_complete: 10201,
37
- core_swap_asset_not_recognized: 10202,
38
- core_swap_contract_not_found: 10203,
39
- core_swap_route_transaction_not_found: 10204,
40
- core_swap_contract_not_supported: 10205,
41
- core_swap_transaction_error: 10206,
42
- core_swap_quote_mode_not_supported: 10207,
35
+ core_swap_invalid_params: 10201,
36
+ core_swap_route_not_complete: 10202,
37
+ core_swap_asset_not_recognized: 10203,
38
+ core_swap_contract_not_found: 10204,
39
+ core_swap_route_transaction_not_found: 10205,
40
+ core_swap_contract_not_supported: 10206,
41
+ core_swap_transaction_error: 10207,
42
+ core_swap_quote_mode_not_supported: 10208,
43
43
  /**
44
44
  * Core - Transaction
45
45
  */
@@ -61,111 +61,326 @@ const errorCodes = {
61
61
  core_transaction_failed: 10316,
62
62
  core_transaction_invalid_recipient_address: 10317,
63
63
  /**
64
- * Wallets
64
+ * Wallets - General
65
+ */
66
+ wallet_connection_rejected_by_user: 20001,
67
+ wallet_missing_api_key: 20002,
68
+ wallet_chain_not_supported: 20003,
69
+ wallet_missing_params: 20004,
70
+ wallet_provider_not_found: 20005,
71
+ wallet_failed_to_add_or_switch_network: 20006,
72
+ /**
73
+ * Wallets - Ledger
65
74
  */
66
- wallet_connection_rejected_by_user: 20000,
67
- wallet_missing_api_key: 20001,
68
- wallet_chain_not_supported: 20002,
69
- wallet_missing_params: 20003,
70
- wallet_provider_not_found: 20004,
71
- wallet_failed_to_add_or_switch_network: 20005,
72
75
  wallet_ledger_connection_error: 20101,
73
76
  wallet_ledger_connection_claimed: 20102,
74
77
  wallet_ledger_get_address_error: 20103,
75
78
  wallet_ledger_device_not_found: 20104,
76
79
  wallet_ledger_device_locked: 20105,
80
+ wallet_ledger_transport_error: 20106,
81
+ wallet_ledger_public_key_error: 20107,
82
+ wallet_ledger_derivation_path_error: 20108,
83
+ wallet_ledger_signing_error: 20109,
84
+ wallet_ledger_app_not_open: 20110,
85
+ wallet_ledger_invalid_response: 20111,
86
+ wallet_ledger_method_not_supported: 20112,
87
+ wallet_ledger_invalid_params: 20113,
88
+ wallet_ledger_invalid_signature: 20114,
89
+ wallet_ledger_no_provider: 20115,
90
+ wallet_ledger_pubkey_not_found: 20116,
91
+ wallet_ledger_transport_not_defined: 20117,
92
+ wallet_ledger_webusb_not_supported: 20118,
93
+ wallet_ledger_chain_not_supported: 20119,
94
+ wallet_ledger_invalid_asset: 20120,
95
+ wallet_ledger_invalid_account: 20121,
96
+ wallet_ledger_address_not_found: 20122,
97
+ wallet_ledger_failed_to_get_address: 20123,
98
+ /**
99
+ * Wallets - Phantom
100
+ */
77
101
  wallet_phantom_not_found: 20201,
102
+ /**
103
+ * Wallets - Ctrl
104
+ */
78
105
  wallet_ctrl_not_found: 20301,
79
106
  wallet_ctrl_send_transaction_no_address: 20302,
80
107
  wallet_ctrl_contract_address_not_provided: 20303,
81
108
  wallet_ctrl_asset_not_defined: 20304,
109
+ /**
110
+ * Wallets - WalletConnect
111
+ */
82
112
  wallet_walletconnect_project_id_not_specified: 20401,
83
113
  wallet_walletconnect_connection_not_established: 20402,
84
114
  wallet_walletconnect_namespace_not_supported: 20403,
115
+ wallet_walletconnect_chain_not_supported: 20404,
116
+ wallet_walletconnect_invalid_method: 20405,
117
+ wallet_walletconnect_method_not_supported: 20406,
118
+ /**
119
+ * Wallets - Trezor
120
+ */
85
121
  wallet_trezor_failed_to_sign_transaction: 20501,
86
122
  wallet_trezor_derivation_path_not_supported: 20502,
87
123
  wallet_trezor_failed_to_get_address: 20503,
124
+ wallet_trezor_transport_error: 20504,
125
+ wallet_trezor_method_not_supported: 20505,
126
+ /**
127
+ * Wallets - Talisman
128
+ */
88
129
  wallet_talisman_not_enabled: 20601,
89
130
  wallet_talisman_not_found: 20602,
131
+ /**
132
+ * Wallets - Polkadot
133
+ */
90
134
  wallet_polkadot_not_found: 20701,
135
+ /**
136
+ * Wallets - Radix
137
+ */
91
138
  wallet_radix_not_found: 20801,
92
139
  wallet_radix_transaction_failed: 20802,
93
- wallet_keepkey_not_found: 20900,
94
- wallet_keepkey_asset_not_defined: 20901,
95
- wallet_keepkey_contract_address_not_provided: 20902,
96
- wallet_keepkey_send_transaction_no_address: 20903,
140
+ wallet_radix_invalid_manifest: 20803,
141
+ wallet_radix_method_not_supported: 20804,
142
+ wallet_radix_no_account: 20805,
143
+ /**
144
+ * Wallets - KeepKey
145
+ */
146
+ wallet_keepkey_not_found: 20901,
147
+ wallet_keepkey_asset_not_defined: 20902,
148
+ wallet_keepkey_contract_address_not_provided: 20903,
149
+ wallet_keepkey_send_transaction_no_address: 20904,
150
+ wallet_keepkey_derivation_path_error: 20905,
151
+ wallet_keepkey_signing_error: 20906,
152
+ wallet_keepkey_transport_error: 20907,
153
+ wallet_keepkey_unsupported_chain: 20908,
154
+ wallet_keepkey_invalid_response: 20909,
155
+ wallet_keepkey_chain_not_supported: 20910,
156
+ wallet_keepkey_signer_not_found: 20911,
157
+ wallet_keepkey_no_accounts: 20912,
158
+ wallet_keepkey_method_not_supported: 20913,
159
+ wallet_keepkey_invalid_params: 20914,
160
+ wallet_keepkey_config_not_found: 20915,
161
+ wallet_keepkey_no_provider: 20916,
162
+ wallet_keepkey_account_not_found: 20917,
163
+ /**
164
+ * Wallets - BitKeep/BitGet
165
+ */
97
166
  wallet_bitkeep_not_found: 21001,
98
- wallet_exodus_sign_transaction_error: 21100,
99
- wallet_keystore_invalid_password: 29900,
100
- wallet_keystore_unsupported_version: 29901,
101
- wallet_onekey_not_found: 21200,
102
- wallet_onekey_sign_transaction_error: 21201,
167
+ wallet_bitkeep_failed_to_switch_network: 21002,
168
+ wallet_bitkeep_no_accounts: 21003,
169
+ /**
170
+ * Wallets - Exodus
171
+ */
172
+ wallet_exodus_sign_transaction_error: 21101,
173
+ wallet_exodus_not_found: 21102,
174
+ wallet_exodus_no_address: 21103,
175
+ wallet_exodus_request_canceled: 21104,
176
+ wallet_exodus_signature_canceled: 21105,
177
+ wallet_exodus_failed_to_switch_network: 21106,
178
+ wallet_exodus_chain_not_supported: 21107,
179
+ wallet_exodus_instance_missing: 21108,
180
+ /**
181
+ * Wallets - OneKey
182
+ */
183
+ wallet_onekey_not_found: 21201,
184
+ wallet_onekey_sign_transaction_error: 21202,
185
+ /**
186
+ * Wallets - OKX
187
+ */
188
+ wallet_okx_not_found: 21301,
189
+ wallet_okx_chain_not_supported: 21302,
190
+ wallet_okx_failed_to_switch_network: 21303,
191
+ wallet_okx_no_accounts: 21304,
192
+ /**
193
+ * Wallets - Keplr
194
+ */
195
+ wallet_keplr_not_found: 21401,
196
+ wallet_keplr_chain_not_supported: 21402,
197
+ wallet_keplr_signer_not_found: 21403,
198
+ wallet_keplr_no_accounts: 21404,
199
+ /**
200
+ * Wallets - Cosmostation
201
+ */
202
+ wallet_cosmostation_not_found: 21501,
203
+ wallet_cosmostation_chain_not_supported: 21502,
204
+ wallet_cosmostation_evm_provider_not_found: 21503,
205
+ wallet_cosmostation_keplr_provider_not_found: 21504,
206
+ wallet_cosmostation_no_accounts: 21505,
207
+ wallet_cosmostation_no_evm_accounts: 21506,
208
+ wallet_cosmostation_no_evm_address: 21507,
209
+ wallet_cosmostation_signer_not_found: 21508,
210
+ /**
211
+ * Wallets - XDefi
212
+ */
213
+ wallet_xdefi_not_found: 21601,
214
+ wallet_xdefi_chain_not_supported: 21602,
215
+ /**
216
+ * Wallets - Coinbase
217
+ */
218
+ wallet_coinbase_not_found: 21701,
219
+ wallet_coinbase_chain_not_supported: 21702,
220
+ wallet_coinbase_method_not_supported: 21703,
221
+ wallet_coinbase_no_accounts: 21704,
222
+ /**
223
+ * Wallets - EVM Extensions
224
+ */
225
+ wallet_evm_extensions_failed_to_switch_network: 21801,
226
+ wallet_evm_extensions_no_provider: 21802,
227
+ wallet_evm_extensions_not_found: 21803,
228
+ /**
229
+ * Wallets - Keystore
230
+ */
231
+ wallet_keystore_invalid_password: 21901,
232
+ wallet_keystore_unsupported_version: 21902,
233
+ /**
234
+ * Wallets - Near Extensions
235
+ */
236
+ wallet_near_extensions_failed_to_switch_network: 22001,
237
+ wallet_near_extensions_no_provider: 22002,
238
+ wallet_near_extensions_not_found: 22003,
239
+ wallet_near_method_not_supported: 22003,
103
240
  /**
104
241
  * Chainflip
105
242
  */
106
243
  chainflip_channel_error: 30001,
107
244
  chainflip_unknown_asset: 30002,
108
- chainflip_broker_invalid_params: 30100,
109
- chainflip_broker_recipient_error: 30101,
110
- chainflip_broker_register: 30102,
111
- chainflip_broker_tx_error: 30103,
112
- chainflip_broker_withdraw: 30104,
113
- chainflip_broker_fund_only_flip_supported: 30105,
114
- chainflip_broker_fund_invalid_address: 30106,
245
+ /**
246
+ * Chainflip - Broker
247
+ */
248
+ chainflip_broker_invalid_params: 30101,
249
+ chainflip_broker_recipient_error: 30102,
250
+ chainflip_broker_register: 30103,
251
+ chainflip_broker_tx_error: 30104,
252
+ chainflip_broker_withdraw: 30105,
253
+ chainflip_broker_fund_only_flip_supported: 30106,
254
+ chainflip_broker_fund_invalid_address: 30107,
115
255
  /**
116
256
  * THORChain
117
257
  */
118
258
  thorchain_chain_halted: 40001,
119
259
  thorchain_trading_halted: 40002,
120
- thorchain_swapin_router_required: 40100,
121
- thorchain_swapin_vault_required: 40101,
122
- thorchain_swapin_memo_required: 40102,
123
- thorchain_swapin_token_required: 40103,
124
- thorchain_preferred_asset_payout_required: 40104,
260
+ /**
261
+ * THORChain - Swap
262
+ */
263
+ thorchain_swapin_router_required: 40101,
264
+ thorchain_swapin_vault_required: 40102,
265
+ thorchain_swapin_memo_required: 40103,
266
+ thorchain_swapin_token_required: 40104,
267
+ thorchain_preferred_asset_payout_required: 40105,
268
+ /**
269
+ * Toolboxes - Cosmos
270
+ */
271
+ toolbox_cosmos_account_not_found: 50101,
272
+ toolbox_cosmos_invalid_fee: 50102,
273
+ toolbox_cosmos_invalid_params: 50103,
274
+ toolbox_cosmos_no_signer: 50104,
275
+ toolbox_cosmos_not_supported: 50105,
276
+ toolbox_cosmos_signer_not_defined: 50106,
277
+ toolbox_cosmos_validate_address_prefix_not_found: 50107,
278
+ toolbox_cosmos_verify_signature_no_pubkey: 50108,
279
+ /**
280
+ * Toolboxes - EVM
281
+ */
282
+ toolbox_evm_error_estimating_gas_limit: 50201,
283
+ toolbox_evm_error_sending_transaction: 50202,
284
+ toolbox_evm_gas_estimation_error: 50203,
285
+ toolbox_evm_invalid_gas_asset_address: 50204,
286
+ toolbox_evm_invalid_params: 50205,
287
+ toolbox_evm_invalid_transaction: 50206,
288
+ toolbox_evm_no_abi_fragment: 50207,
289
+ toolbox_evm_no_contract_address: 50208,
290
+ toolbox_evm_no_fee_data: 50209,
291
+ toolbox_evm_no_from_address: 50210,
292
+ toolbox_evm_no_gas_price: 50211,
293
+ toolbox_evm_no_signer_address: 50212,
294
+ toolbox_evm_no_signer: 50213,
295
+ toolbox_evm_no_to_address: 50214,
296
+ toolbox_evm_not_supported: 50215,
297
+ toolbox_evm_provider_not_eip1193_compatible: 50216,
298
+ /**
299
+ * Toolboxes - UTXO
300
+ */
301
+ toolbox_utxo_api_error: 50301,
302
+ toolbox_utxo_broadcast_failed: 50302,
303
+ toolbox_utxo_insufficient_balance: 50303,
304
+ toolbox_utxo_invalid_address: 50304,
305
+ toolbox_utxo_invalid_params: 50305,
306
+ toolbox_utxo_invalid_transaction: 50306,
307
+ toolbox_utxo_no_signer: 50307,
308
+ toolbox_utxo_not_supported: 50308,
309
+ /**
310
+ * Toolboxes - Solana
311
+ */
312
+ toolbox_solana_no_signer: 50401,
313
+ toolbox_solana_fee_estimation_failed: 50402,
314
+ /**
315
+ * Toolboxes - Substrate
316
+ */
317
+ toolbox_substrate_not_supported: 50501,
318
+ /**
319
+ * Toolboxes - Radix
320
+ */
321
+ toolbox_radix_method_not_supported: 50601,
322
+ /**
323
+ * Toolboxes - Ripple
324
+ */
325
+ toolbox_ripple_get_balance_error: 50701,
326
+ toolbox_ripple_rpc_not_configured: 50702,
327
+ toolbox_ripple_signer_not_found: 50703,
328
+ toolbox_ripple_asset_not_supported: 50704,
329
+ toolbox_ripple_broadcast_error: 50705,
330
+ /**
331
+ * Toolboxes - Tron
332
+ */
333
+ toolbox_tron_no_signer: 50801,
334
+ toolbox_tron_invalid_token_identifier: 50802,
335
+ toolbox_tron_token_transfer_failed: 50803,
336
+ toolbox_tron_transaction_creation_failed: 50804,
337
+ /**
338
+ * Toolboxes - Near
339
+ */
340
+ toolbox_near_no_signer: 90601,
341
+ toolbox_near_invalid_address: 90602,
342
+ toolbox_near_invalid_amount: 90603,
343
+ toolbox_near_transfer_failed: 90604,
344
+ toolbox_near_access_key_error: 90605,
345
+ toolbox_near_no_rpc_url: 90606,
346
+ toolbox_near_empty_batch: 90607,
347
+ toolbox_near_balance_failed: 90608,
348
+ toolbox_near_invalid_name: 90609,
349
+ toolbox_near_missing_contract_address: 90610,
350
+ toolbox_near_no_account: 90611,
351
+ toolbox_near_invalid_gas_params: 90612,
352
+ /**
353
+ * Toolboxes - General
354
+ */
355
+ toolbox_not_supported: 59901,
356
+ /**
357
+ * NEAR Plugin
358
+ */
359
+ plugin_near_invalid_name: 41001,
360
+ plugin_near_no_connection: 41002,
361
+ plugin_near_name_unavailable: 41003,
362
+ plugin_near_registration_failed: 41004,
363
+ plugin_near_transfer_failed: 41005,
125
364
  /**
126
365
  * SwapKit API
127
366
  */
128
- api_v2_invalid_response: 50001,
129
- api_v2_server_error: 50002,
130
- api_v2_invalid_method_key_hash: 50003,
131
- /**
132
- * Toolboxes
133
- */
134
- toolbox_cosmos_signer_not_defined: 90101,
135
- toolbox_cosmos_no_accounts_found: 90102,
136
- toolbox_cosmos_verify_signature_no_pubkey: 90103,
137
- toolbox_cosmos_validate_address_prefix_not_found: 90104,
138
- toolbox_evm_no_abi_fragment: 90201,
139
- toolbox_evm_no_signer: 90202,
140
- toolbox_evm_no_signer_address: 90203,
141
- toolbox_evm_no_from_address: 90204,
142
- toolbox_evm_no_contract_address: 90205,
143
- toolbox_evm_no_fee_data: 90206,
144
- toolbox_evm_no_gas_price: 90207,
145
- toolbox_evm_no_to_address: 90208,
146
- toolbox_evm_invalid_gas_asset_address: 90209,
147
- toolbox_evm_provider_not_eip1193_compatible: 90210,
148
- toolbox_evm_error_estimating_gas_limit: 90211,
149
- toolbox_evm_error_sending_transaction: 90212,
150
- toolbox_radix_signer_not_defined: 90301,
151
- toolbox_solana_no_signer: 90401,
152
- toolbox_solana_fee_estimation_failed: 90402,
153
- toolbox_ripple_rpc_not_configured: 90501,
154
- toolbox_ripple_signer_not_found: 90502,
155
- toolbox_ripple_asset_not_supported: 90503,
156
- toolbox_ripple_broadcast_error: 90504,
157
- toolbox_ripple_get_balance_error: 90505,
367
+ api_v2_invalid_response: 60001,
368
+ api_v2_server_error: 60002,
369
+ api_v2_invalid_method_key_hash: 60003,
158
370
  /**
159
371
  * Helpers
160
372
  */
161
- helpers_invalid_number_different_decimals: 99000,
162
- helpers_invalid_number_of_years: 99001,
163
- helpers_invalid_identifier: 99002,
164
- helpers_invalid_asset_url: 99003,
165
- helpers_invalid_asset_identifier: 99004,
166
- helpers_invalid_memo_type: 99005,
167
- helpers_failed_to_switch_network: 99103,
168
- helpers_not_found_provider: 99200,
373
+ helpers_invalid_number_different_decimals: 70001,
374
+ helpers_invalid_number_of_years: 70002,
375
+ helpers_invalid_identifier: 70003,
376
+ helpers_invalid_asset_url: 70004,
377
+ helpers_invalid_asset_identifier: 70005,
378
+ helpers_invalid_memo_type: 70006,
379
+ helpers_failed_to_switch_network: 70007,
380
+ helpers_not_found_provider: 70008,
381
+ helpers_chain_not_supported: 70009,
382
+ helpers_invalid_params: 70010,
383
+ helpers_invalid_response: 70011,
169
384
  /**
170
385
  * Anything else
171
386
  */
@@ -183,15 +398,20 @@ export class SwapKitError extends Error {
183
398
  ) {
184
399
  const isErrorString = typeof errorOrErrorKey === "string";
185
400
  const errorKey = isErrorString ? errorOrErrorKey : errorOrErrorKey.errorKey;
186
- const message = `${errorKey}${isErrorString ? "" : `: ${JSON.stringify(errorOrErrorKey.info)}`}`;
401
+ const info = isErrorString ? undefined : errorOrErrorKey.info;
402
+ const message = `${errorKey}${info ? `: ${JSON.stringify(info)}` : ""}`;
187
403
 
188
- if (sourceErrorOrInfo) {
189
- console.error(sourceErrorOrInfo);
190
- }
404
+ super(message);
405
+ Object.setPrototypeOf(this, SwapKitError.prototype);
191
406
 
192
- console.error(errorKey, { code: SwapKitError.ErrorCode[errorKey], message });
407
+ this.name = "SwapKitError";
408
+ this.cause = sourceErrorOrInfo;
193
409
 
194
- super(errorKey);
195
- Object.setPrototypeOf(this, SwapKitError.prototype);
410
+ // Log errors for debugging - bundlers can strip this in production if needed
411
+ if (sourceErrorOrInfo) {
412
+ console.error(`SwapKitError [${errorKey}]:`, sourceErrorOrInfo);
413
+ } else if (info) {
414
+ console.error(`SwapKitError [${errorKey}]:`, info);
415
+ }
196
416
  }
197
417
  }