@swapkit/helpers 1.0.0-rc.103 → 1.0.0-rc.105
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.js +1043 -1024
- package/dist/index.js.map +24 -24
- package/package.json +1 -1
- package/src/helpers/__tests__/memo.test.ts +2 -2
- package/src/helpers/asset.ts +20 -4
- package/src/helpers/memo.ts +4 -4
- package/src/modules/swapKitError.ts +3 -0
- package/src/types/sdk.ts +1 -1
package/package.json
CHANGED
|
@@ -25,7 +25,7 @@ describe("getMemoFor", () => {
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
test("returns correct memo for Thorname Register", () => {
|
|
28
|
-
const result = getMemoFor(MemoType.
|
|
28
|
+
const result = getMemoFor(MemoType.NAME_REGISTER, {
|
|
29
29
|
name: "thorname",
|
|
30
30
|
chain: "BNB",
|
|
31
31
|
address: "0xABC123",
|
|
@@ -35,7 +35,7 @@ describe("getMemoFor", () => {
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
test("returns correct memo for Mayaname Register", () => {
|
|
38
|
-
const result = getMemoFor(MemoType.
|
|
38
|
+
const result = getMemoFor(MemoType.NAME_REGISTER, {
|
|
39
39
|
name: "mayaname",
|
|
40
40
|
chain: "BNB",
|
|
41
41
|
address: "0xABC123",
|
package/src/helpers/asset.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AssetValue } from "../modules/assetValue.ts";
|
|
1
2
|
import { RequestClient } from "../modules/requestClient.ts";
|
|
2
3
|
import { BaseDecimal, Chain, ChainToRPC, type EVMChain, EVMChains } from "../types/chains.ts";
|
|
3
4
|
import type { TokenNames } from "../types/tokens.ts";
|
|
@@ -72,6 +73,25 @@ export const getDecimal = ({ chain, symbol }: { chain: Chain; symbol: string })
|
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
75
|
|
|
76
|
+
export const getGasAsset = ({ chain }: { chain: Chain }) => {
|
|
77
|
+
switch (chain) {
|
|
78
|
+
case Chain.Arbitrum:
|
|
79
|
+
case Chain.Optimism:
|
|
80
|
+
return AssetValue.fromStringSync(`${chain}.ETH`);
|
|
81
|
+
case Chain.Maya:
|
|
82
|
+
return AssetValue.fromStringSync(`${chain}.CACAO`);
|
|
83
|
+
case Chain.Cosmos:
|
|
84
|
+
return AssetValue.fromStringSync(`${chain}.ATOM`);
|
|
85
|
+
case Chain.BinanceSmartChain:
|
|
86
|
+
return AssetValue.fromStringSync(`${chain}.BNB`);
|
|
87
|
+
case Chain.THORChain:
|
|
88
|
+
return AssetValue.fromStringSync(`${chain}.RUNE`);
|
|
89
|
+
|
|
90
|
+
default:
|
|
91
|
+
return AssetValue.fromStringSync(`${chain}.${chain}`);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
75
95
|
export const isGasAsset = ({ chain, symbol }: { chain: Chain; symbol: string }) => {
|
|
76
96
|
switch (chain) {
|
|
77
97
|
case Chain.Arbitrum:
|
|
@@ -79,12 +99,8 @@ export const isGasAsset = ({ chain, symbol }: { chain: Chain; symbol: string })
|
|
|
79
99
|
return symbol === "ETH";
|
|
80
100
|
case Chain.Maya:
|
|
81
101
|
return symbol === "CACAO";
|
|
82
|
-
case Chain.Kujira:
|
|
83
|
-
return symbol === "KUJI";
|
|
84
102
|
case Chain.Cosmos:
|
|
85
103
|
return symbol === "ATOM";
|
|
86
|
-
case Chain.Polygon:
|
|
87
|
-
return symbol === "MATIC";
|
|
88
104
|
case Chain.BinanceSmartChain:
|
|
89
105
|
return symbol === "BNB";
|
|
90
106
|
case Chain.THORChain:
|
package/src/helpers/memo.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Chain } from "../types/chains";
|
|
2
2
|
import { MemoType } from "../types/sdk";
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type NameRegisterParam = {
|
|
5
5
|
name: string;
|
|
6
6
|
chain: string;
|
|
7
7
|
address: string;
|
|
@@ -26,7 +26,7 @@ export type MemoOptions<T extends MemoType> = {
|
|
|
26
26
|
targetAssetString?: string;
|
|
27
27
|
singleSide?: boolean;
|
|
28
28
|
}>;
|
|
29
|
-
[MemoType.
|
|
29
|
+
[MemoType.NAME_REGISTER]: Omit<NameRegisterParam, "preferredAsset" | "expiryBlock">;
|
|
30
30
|
}[T];
|
|
31
31
|
|
|
32
32
|
export const getMemoFor = <T extends MemoType>(memoType: T, options: MemoOptions<T>) => {
|
|
@@ -42,8 +42,8 @@ export const getMemoFor = <T extends MemoType>(memoType: T, options: MemoOptions
|
|
|
42
42
|
return `${memoType}:${address}:${unbondAmount}`;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
case MemoType.
|
|
46
|
-
const { name, chain, address, owner } = options as MemoOptions<MemoType.
|
|
45
|
+
case MemoType.NAME_REGISTER: {
|
|
46
|
+
const { name, chain, address, owner } = options as MemoOptions<MemoType.NAME_REGISTER>;
|
|
47
47
|
return `${memoType}:${name}:${chain}:${address}${owner ? `:${owner}` : ""}`;
|
|
48
48
|
}
|
|
49
49
|
|
|
@@ -53,6 +53,9 @@ const errorMessages = {
|
|
|
53
53
|
core_transaction_invalid_sender_address: 10313,
|
|
54
54
|
core_transaction_deposit_server_error: 10314,
|
|
55
55
|
core_transaction_user_rejected: 10315,
|
|
56
|
+
core_transaction_create_liquidity_cacao_error: 10316,
|
|
57
|
+
core_transaction_add_liquidity_no_cacao_address: 10306,
|
|
58
|
+
core_transaction_add_liquidity_cacao_error: 10307,
|
|
56
59
|
|
|
57
60
|
/**
|
|
58
61
|
* Wallets
|