@swapkit/helpers 1.0.0-rc.63 → 1.0.0-rc.65

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.
@@ -1,8 +1,7 @@
1
+ import { RequestClient } from '@swapkit/api';
1
2
  import type { EVMChain } from '@swapkit/types';
2
3
  import { BaseDecimal, Chain, ChainToRPC, EVMChainList, FeeOption } from '@swapkit/types';
3
4
 
4
- import { RequestClient } from '../index.ts';
5
-
6
5
  const getDecimalMethodHex = '0x313ce567';
7
6
 
8
7
  export type CommonAssetString =
package/src/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from '@swapkit/api';
2
+
1
3
  /**
2
4
  * Helpers
3
5
  */
@@ -5,7 +7,6 @@ export * from './helpers/asset.ts';
5
7
  export * from './helpers/liquidity.ts';
6
8
  export * from './helpers/memo.ts';
7
9
  export * from './helpers/others.ts';
8
- export * from './helpers/request.ts';
9
10
 
10
11
  /**
11
12
  * Modules
@@ -47,12 +47,17 @@ const errorMessages = {
47
47
  core_transaction_deposit_insufficient_funds_error: 10311,
48
48
  core_transaction_deposit_gas_error: 10312,
49
49
  core_transaction_invalid_sender_address: 10313,
50
- core_transaction_deposit_server_error: 10313,
50
+ core_transaction_deposit_server_error: 10314,
51
+ core_transaction_user_rejected: 10315,
51
52
 
52
53
  /**
53
54
  * Wallets
54
55
  */
55
56
  wallet_ledger_connection_error: 20001,
57
+ wallet_ledger_connection_claimed: 20002,
58
+ wallet_ledger_get_address_error: 20003,
59
+ wallet_ledger_device_not_found: 20004,
60
+ wallet_ledger_device_locked: 20005,
56
61
 
57
62
  /**
58
63
  * Helpers
@@ -60,11 +65,13 @@ const errorMessages = {
60
65
  helpers_number_different_decimals: 99101,
61
66
  } as const;
62
67
 
63
- export type Keys = keyof typeof errorMessages;
68
+ export type ErrorKeys = keyof typeof errorMessages;
64
69
 
65
70
  export class SwapKitError extends Error {
66
- constructor(errorKey: Keys, sourceError?: any) {
67
- console.error(sourceError, { stack: sourceError?.stack, message: sourceError?.message });
71
+ constructor(errorKey: ErrorKeys, sourceError?: any) {
72
+ if (sourceError) {
73
+ console.error(sourceError, { stack: sourceError?.stack, message: sourceError?.message });
74
+ }
68
75
 
69
76
  super(errorKey, { cause: { code: errorMessages[errorKey], message: errorKey } });
70
77
  Object.setPrototypeOf(this, SwapKitError.prototype);
@@ -1,15 +0,0 @@
1
- import type { Options } from 'ky';
2
- import ky from 'ky';
3
-
4
- const headers =
5
- typeof window !== 'undefined'
6
- ? {}
7
- : { referrer: 'https://sk.thorswap.net', referer: 'https://sk.thorswap.net' };
8
-
9
- const kyClient = ky.create({ headers });
10
-
11
- export const RequestClient = {
12
- get: <T>(url: string | URL | Request, options?: Options) => kyClient.get(url, options).json<T>(),
13
- post: <T>(url: string | URL | Request, options?: Options) =>
14
- kyClient.post(url, options).json<T>(),
15
- };