@swapkit/helpers 1.0.0-rc.5 → 1.0.0-rc.50
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/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +51 -24
- package/dist/index.es.js +853 -453
- package/dist/index.es.js.map +1 -0
- package/package.json +12 -9
- package/src/helpers/asset.ts +46 -15
- package/src/helpers/liquidity.ts +12 -10
- package/src/helpers/memo.ts +15 -3
- package/src/helpers/others.ts +0 -48
- package/src/helpers/request.ts +15 -0
- package/src/index.ts +1 -0
- package/src/modules/__tests__/assetValue.test.ts +117 -33
- package/src/modules/__tests__/swapKitNumber.test.ts +174 -48
- package/src/modules/assetValue.ts +89 -73
- package/src/modules/bigIntArithmetics.ts +189 -108
- package/src/modules/swapKitError.ts +2 -1
- package/src/modules/swapKitNumber.ts +8 -1
|
@@ -45,6 +45,7 @@ const errorMessages = {
|
|
|
45
45
|
core_transaction_deposit_to_pool_error: 10310,
|
|
46
46
|
core_transaction_deposit_insufficient_funds_error: 10311,
|
|
47
47
|
core_transaction_deposit_gas_error: 10312,
|
|
48
|
+
core_transaction_invalid_sender_address: 10313,
|
|
48
49
|
core_transaction_deposit_server_error: 10313,
|
|
49
50
|
|
|
50
51
|
/**
|
|
@@ -62,7 +63,7 @@ export type Keys = keyof typeof errorMessages;
|
|
|
62
63
|
|
|
63
64
|
export class SwapKitError extends Error {
|
|
64
65
|
constructor(errorKey: Keys, sourceError?: any) {
|
|
65
|
-
console.error(sourceError);
|
|
66
|
+
console.error(sourceError, { stack: sourceError?.stack, message: sourceError?.message });
|
|
66
67
|
|
|
67
68
|
super(errorKey, { cause: { code: errorMessages[errorKey], message: errorKey } });
|
|
68
69
|
Object.setPrototypeOf(this, SwapKitError.prototype);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BigIntArithmetics } from './bigIntArithmetics.ts';
|
|
1
|
+
import { BigIntArithmetics, formatBigIntToSafeValue } from './bigIntArithmetics.ts';
|
|
2
2
|
|
|
3
3
|
export type SwapKitValueType = BigIntArithmetics | string | number;
|
|
4
4
|
|
|
@@ -6,4 +6,11 @@ export class SwapKitNumber extends BigIntArithmetics {
|
|
|
6
6
|
eq(value: SwapKitValueType) {
|
|
7
7
|
return this.eqValue(value);
|
|
8
8
|
}
|
|
9
|
+
|
|
10
|
+
static fromBigInt(value: bigint, decimal?: number) {
|
|
11
|
+
return new SwapKitNumber({
|
|
12
|
+
decimal,
|
|
13
|
+
value: formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal }),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
9
16
|
}
|