@swapkit/helpers 1.0.0-rc.113 → 1.0.0-rc.115

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/package.json CHANGED
@@ -2,17 +2,8 @@
2
2
  "author": "swapkit-oss",
3
3
  "description": "SwapKit - Helpers",
4
4
  "dependencies": {
5
- "ky": "1.2.3",
6
- "zod": "3.23.8"
7
- },
8
- "devDependencies": {
9
- "@swapkit/tokens": "1.0.0-rc.55",
10
- "bun-types": "1.1.8",
11
- "ethers": "6.11.1"
12
- },
13
- "peerDependencies": {
14
- "@swapkit/tokens": "1.0.0-rc.55",
15
- "ky": "1.2.3",
5
+ "@swapkit/tokens": "1.0.0-rc.57",
6
+ "ky": "1.3.0",
16
7
  "zod": "3.23.8"
17
8
  },
18
9
  "files": [
@@ -30,13 +21,13 @@
30
21
  },
31
22
  "scripts": {
32
23
  "build": "bun run ./build.ts",
33
- "clean": "rm -rf .turbo dist node_modules *.tsbuildinfo",
34
- "lint": "biome check --apply ./src",
24
+ "clean": "rm -rf dist node_modules *.tsbuildinfo",
25
+ "lint": "biome check --write ./src",
35
26
  "test": "bun test",
36
- "test:coverage": "echo 'bun test --coverage'",
27
+ "test:coverage": "bun test --coverage",
37
28
  "type-check": "tsc --noEmit"
38
29
  },
39
30
  "type": "module",
40
31
  "types": "./src/index.ts",
41
- "version": "1.0.0-rc.113"
32
+ "version": "1.0.0-rc.115"
42
33
  }
@@ -1,91 +1,72 @@
1
1
  import { describe, expect, test } from "bun:test";
2
2
  import { Chain, MemoType } from "../../types";
3
3
 
4
- import { getMemoFor } from "../memo.ts";
4
+ import {
5
+ getMemoForDeposit,
6
+ getMemoForLeaveAndBond,
7
+ getMemoForNameRegister,
8
+ getMemoForSaverDeposit,
9
+ getMemoForSaverWithdraw,
10
+ getMemoForWithdraw,
11
+ } from "../memo.ts";
5
12
 
6
- describe("getMemoFor", () => {
7
- describe("for Leave, Upgrade, and Bond", () => {
8
- const nodeMemos = [
9
- [MemoType.LEAVE, "LEAVE:ABC123"],
10
- [MemoType.BOND, "BOND:ABC123"],
11
- ];
12
-
13
- for (const [memoType, expected = ""] of nodeMemos) {
14
- test(`returns correct memo for ${memoType}`, () => {
15
- const result = getMemoFor(memoType as MemoType, { address: "ABC123" });
16
- expect(result).toBe(expected);
17
- });
18
- }
13
+ describe("getMemoForSaverDeposit", () => {
14
+ test("returns correct memo for single side", () => {
15
+ const result = getMemoForSaverDeposit({ chain: Chain.Ethereum, symbol: "ETH" });
16
+ expect(result).toBe("+:ETH/ETH");
19
17
  });
18
+ });
20
19
 
21
- describe("for Unbond and Thorname/Mayaname Register", () => {
22
- test("returns correct memo for Unbond", () => {
23
- const result = getMemoFor(MemoType.UNBOND, { address: "ABC123", unbondAmount: 1000000000 });
24
- expect(result).toBe("UNBOND:ABC123:1000000000");
25
- });
26
-
27
- test("returns correct memo for Thorname Register", () => {
28
- const result = getMemoFor(MemoType.NAME_REGISTER, {
29
- name: "thorname",
30
- chain: "BNB",
31
- address: "0xABC123",
32
- owner: "0xDEF456",
33
- });
34
- expect(result).toBe("~:thorname:BNB:0xABC123:0xDEF456");
20
+ describe("getMemoForSaverWithdraw", () => {
21
+ test("returns correct memo for single side", () => {
22
+ const result = getMemoForSaverWithdraw({
23
+ basisPoints: 5000,
24
+ chain: Chain.Ethereum,
25
+ symbol: "ETH",
35
26
  });
27
+ expect(result).toBe("-:ETH/ETH:5000");
28
+ });
29
+ });
36
30
 
37
- test("returns correct memo for Mayaname Register", () => {
38
- const result = getMemoFor(MemoType.NAME_REGISTER, {
39
- name: "mayaname",
40
- chain: "BNB",
41
- address: "0xABC123",
42
- owner: "0xDEF456",
43
- });
44
- expect(result).toBe("~:mayaname:BNB:0xABC123:0xDEF456");
45
- });
31
+ describe("getMemoForLeaveAndBond", () => {
32
+ test("returns correct memo for Leave", () => {
33
+ const result = getMemoForLeaveAndBond({ address: "ABC123", type: MemoType.LEAVE });
34
+ expect(result).toBe("LEAVE:ABC123");
46
35
  });
47
36
 
48
- describe("for Deposit", () => {
49
- test("returns correct memo for Deposit (single side)", () => {
50
- const result = getMemoFor(MemoType.DEPOSIT, {
51
- chain: Chain.Ethereum,
52
- symbol: "ETH",
53
- singleSide: true,
54
- });
55
- expect(result).toBe("+:ETH/ETH");
56
- });
37
+ test("returns correct memo for Bond", () => {
38
+ const result = getMemoForLeaveAndBond({ address: "ABC123", type: MemoType.BOND });
39
+ expect(result).toBe("BOND:ABC123");
40
+ });
41
+ });
57
42
 
58
- test("returns correct memo for Deposit (dual side)", () => {
59
- const result = getMemoFor(MemoType.DEPOSIT, {
60
- chain: Chain.Avalanche,
61
- symbol: "AVAX",
62
- address: "0xABC123",
63
- });
64
- expect(result).toBe("+:AVAX.AVAX:0xABC123");
43
+ describe("getMemoForNameRegister", () => {
44
+ test("returns correct memo for single side", () => {
45
+ const result = getMemoForNameRegister({
46
+ name: "asdfg",
47
+ chain: Chain.Ethereum,
48
+ owner: "thor1234",
49
+ address: "0xaasd123",
65
50
  });
51
+ expect(result).toBe("~:asdfg:ETH:0xaasd123:thor1234");
66
52
  });
53
+ });
67
54
 
68
- describe("for Withdraw", () => {
69
- test("returns correct memo for Withdraw (single side)", () => {
70
- const result = getMemoFor(MemoType.WITHDRAW, {
71
- chain: Chain.Bitcoin,
72
- ticker: "BTC",
73
- symbol: "BTC",
74
- basisPoints: 10000,
75
- singleSide: true,
76
- });
77
- expect(result).toBe("-:BTC/BTC:10000");
78
- });
55
+ describe("getMemoForDeposit", () => {
56
+ test("returns correct memo for single side", () => {
57
+ const result = getMemoForDeposit({ chain: Chain.Ethereum, symbol: "ETH" });
58
+ expect(result).toBe("+:ETH.ETH");
59
+ });
60
+ });
79
61
 
80
- test("returns correct memo for Withdraw (dual side)", () => {
81
- const result = getMemoFor(MemoType.WITHDRAW, {
82
- chain: Chain.Ethereum,
83
- ticker: "ETH",
84
- symbol: "ETH",
85
- basisPoints: 100,
86
- targetAssetString: "ETH.ETH",
87
- });
88
- expect(result).toBe("-:ETH.ETH:100:ETH.ETH");
62
+ describe("getMemoForWithdraw", () => {
63
+ test("returns correct memo for single side", () => {
64
+ const result = getMemoForWithdraw({
65
+ chain: Chain.Ethereum,
66
+ symbol: "ETH",
67
+ ticker: "ETH",
68
+ basisPoints: 100,
89
69
  });
70
+ expect(result).toBe("-:ETH.ETH:100");
90
71
  });
91
72
  });
@@ -1,17 +1,130 @@
1
1
  import { Chain } from "../types/chains";
2
2
  import { MemoType } from "../types/sdk";
3
3
 
4
- export type NameRegisterParam = {
5
- name: string;
6
- chain: string;
7
- address: string;
8
- owner?: string;
9
- preferredAsset?: string;
10
- expiryBlock?: string;
11
- };
12
-
13
4
  type WithChain<T extends {}> = T & { chain: Chain };
14
5
 
6
+ type WithAffiliate<T extends {}> = T & { affiliateAddress?: string; affiliateBasisPoints?: number };
7
+
8
+ function addAffiliate(memo: string, { affiliateAddress, affiliateBasisPoints }: WithAffiliate<{}>) {
9
+ const affiliatePart = affiliateAddress ? `:${affiliateAddress}:${affiliateBasisPoints || 0}` : "";
10
+
11
+ return `${memo}${affiliatePart}`;
12
+ }
13
+
14
+ function getPoolIdentifier({ chain, symbol }: { chain: Chain; symbol: string }) {
15
+ switch (chain) {
16
+ case Chain.Bitcoin:
17
+ case Chain.Dogecoin:
18
+ case Chain.Litecoin:
19
+ return chain.slice(0, 1).toLowerCase();
20
+ case Chain.BitcoinCash:
21
+ return "c";
22
+
23
+ default:
24
+ return `${chain}.${symbol}`;
25
+ }
26
+ }
27
+
28
+ export function getMemoForLeaveAndBond({
29
+ type,
30
+ address,
31
+ }: { type: MemoType.BOND | MemoType.LEAVE; address: string }) {
32
+ return `${type}:${address}`;
33
+ }
34
+
35
+ export function getMemoForUnbond({
36
+ address,
37
+ unbondAmount,
38
+ }: { address: string; unbondAmount: number }) {
39
+ return `${MemoType.UNBOND}:${address}:${unbondAmount}`;
40
+ }
41
+
42
+ export function getMemoForNameRegister({
43
+ name,
44
+ chain,
45
+ address,
46
+ owner,
47
+ }: { name: string; chain: string; address: string; owner?: string }) {
48
+ const baseMemo = `${MemoType.NAME_REGISTER}:${name}:${chain}:${address}`;
49
+ const ownerAssignmentOrChangePart = owner ? `:${owner}` : "";
50
+
51
+ return `${baseMemo}${ownerAssignmentOrChangePart}`;
52
+ }
53
+
54
+ export function getMemoForLoan(
55
+ memoType: MemoType.OPEN_LOAN | MemoType.CLOSE_LOAN,
56
+ {
57
+ asset,
58
+ address,
59
+ minAmount,
60
+ ...affiliate
61
+ }: WithAffiliate<{
62
+ address: string;
63
+ asset: string;
64
+ minAmount?: string;
65
+ }>,
66
+ ) {
67
+ const baseMemo = `${memoType}:${asset}:${address}`;
68
+ const minAmountPart = minAmount ? `:${minAmount}` : "";
69
+
70
+ return addAffiliate(`${baseMemo}${minAmountPart}`, affiliate);
71
+ }
72
+
73
+ export function getMemoForSaverDeposit({
74
+ chain,
75
+ symbol,
76
+ ...affiliate
77
+ }: WithAffiliate<{ chain: Chain; symbol: string }>) {
78
+ return addAffiliate(`${MemoType.DEPOSIT}:${chain}/${symbol}`, affiliate);
79
+ }
80
+
81
+ export function getMemoForDeposit({
82
+ chain,
83
+ symbol,
84
+ address,
85
+ }: { chain: Chain; symbol: string; address?: string }) {
86
+ const poolIdentifier = getPoolIdentifier({ chain, symbol });
87
+ const addressPart = address ? `:${address}` : "";
88
+
89
+ return `${MemoType.DEPOSIT}:${poolIdentifier}${addressPart}`;
90
+ }
91
+
92
+ export function getMemoForSaverWithdraw({
93
+ chain,
94
+ symbol,
95
+ basisPoints,
96
+ ...affiliate
97
+ }: WithAffiliate<{ chain: Chain; symbol: string; basisPoints: number }>) {
98
+ return addAffiliate(`${MemoType.WITHDRAW}:${chain}/${symbol}:${basisPoints}`, affiliate);
99
+ }
100
+
101
+ export function getMemoForWithdraw({
102
+ chain,
103
+ symbol,
104
+ ticker,
105
+ basisPoints,
106
+ targetAsset,
107
+ ...affiliate
108
+ }: WithAffiliate<{
109
+ chain: Chain;
110
+ symbol: string;
111
+ ticker: string;
112
+ basisPoints: number;
113
+ targetAsset?: string;
114
+ }>) {
115
+ const shortenedSymbol =
116
+ chain === "ETH" && ticker !== "ETH" ? `${ticker}-${symbol.slice(-3)}` : symbol;
117
+ const targetPart = targetAsset ? `:${targetAsset}` : "";
118
+
119
+ return addAffiliate(
120
+ `${MemoType.WITHDRAW}:${chain}.${shortenedSymbol}:${basisPoints}${targetPart}`,
121
+ affiliate,
122
+ );
123
+ }
124
+
125
+ /**
126
+ * @deprecated - Use separate functions per each memo type like getMemoForDeposit, getMemoForWithdraw, etc.
127
+ */
15
128
  export type MemoOptions<T extends MemoType> = {
16
129
  [MemoType.BOND]: { address: string };
17
130
  [MemoType.LEAVE]: { address: string };
@@ -26,68 +139,62 @@ export type MemoOptions<T extends MemoType> = {
26
139
  targetAssetString?: string;
27
140
  singleSide?: boolean;
28
141
  }>;
29
- [MemoType.NAME_REGISTER]: Omit<NameRegisterParam, "preferredAsset" | "expiryBlock">;
142
+ [MemoType.NAME_REGISTER]: { name: string; chain: string; address: string };
30
143
  }[T];
31
144
 
145
+ /**
146
+ * @deprecated - Use separate functions per each memo type like getMemoForDeposit, getMemoForWithdraw, etc.
147
+ */
32
148
  export const getMemoFor = <T extends MemoType>(memoType: T, options: MemoOptions<T>) => {
33
149
  switch (memoType) {
34
150
  case MemoType.LEAVE:
35
151
  case MemoType.BOND: {
36
152
  const { address } = options as MemoOptions<MemoType.BOND>;
37
- return `${memoType}:${address}`;
153
+ return getMemoForLeaveAndBond({ type: memoType, address });
38
154
  }
39
155
 
40
156
  case MemoType.UNBOND: {
41
157
  const { address, unbondAmount } = options as MemoOptions<MemoType.UNBOND>;
42
- return `${memoType}:${address}:${unbondAmount}`;
158
+ return getMemoForUnbond({ address, unbondAmount });
43
159
  }
44
160
 
45
161
  case MemoType.NAME_REGISTER: {
46
- const { name, chain, address, owner } = options as MemoOptions<MemoType.NAME_REGISTER>;
47
- return `${memoType}:${name}:${chain}:${address}${owner ? `:${owner}` : ""}`;
162
+ return getMemoForNameRegister(options as MemoOptions<MemoType.NAME_REGISTER>);
163
+ }
164
+
165
+ case MemoType.OPEN_LOAN:
166
+ case MemoType.CLOSE_LOAN: {
167
+ return getMemoForLoan(memoType, options as MemoOptions<MemoType.OPEN_LOAN>);
48
168
  }
49
169
 
50
170
  case MemoType.DEPOSIT: {
51
171
  const { chain, symbol, address, singleSide } = options as MemoOptions<MemoType.DEPOSIT>;
52
172
 
53
- const getPoolIdentifier = (chain: Chain, symbol: string): string => {
54
- switch (chain) {
55
- case Chain.Litecoin:
56
- return "l";
57
- case Chain.Dogecoin:
58
- return "d";
59
- case Chain.BitcoinCash:
60
- return "c";
61
- default:
62
- return `${chain}.${symbol}`;
63
- }
64
- };
65
-
66
- return singleSide
67
- ? `${memoType}:${chain}/${symbol}`
68
- : `${memoType}:${getPoolIdentifier(chain, symbol)}:${address || ""}`;
173
+ if (singleSide) {
174
+ return getMemoForSaverDeposit({ chain, symbol });
175
+ }
176
+
177
+ return getMemoForDeposit({ chain, symbol, address });
69
178
  }
70
179
 
71
180
  case MemoType.WITHDRAW: {
72
- const { chain, ticker, symbol, basisPoints, targetAssetString, singleSide } =
73
- options as MemoOptions<MemoType.WITHDRAW>;
181
+ const {
182
+ chain,
183
+ ticker,
184
+ symbol,
185
+ basisPoints,
186
+ targetAssetString: targetAsset,
187
+ singleSide,
188
+ } = options as MemoOptions<MemoType.WITHDRAW>;
74
189
 
75
- const shortenedSymbol =
76
- chain === "ETH" && ticker !== "ETH" ? `${ticker}-${symbol.slice(-3)}` : symbol;
77
- const target = !singleSide && targetAssetString ? `:${targetAssetString}` : "";
78
- const assetDivider = singleSide ? "/" : ".";
79
-
80
- return `${memoType}:${chain}${assetDivider}${shortenedSymbol}:${basisPoints}${target}`;
81
- }
82
-
83
- case MemoType.OPEN_LOAN:
84
- case MemoType.CLOSE_LOAN: {
85
- const { asset, address } = options as MemoOptions<MemoType.OPEN_LOAN>;
190
+ if (singleSide) {
191
+ return getMemoForSaverWithdraw({ chain, symbol, basisPoints });
192
+ }
86
193
 
87
- return `${memoType}:${asset}:${address}`; //:${minAmount ? `${minAmount}` : ''}:t:0`;
194
+ return getMemoForWithdraw({ chain, ticker, symbol, basisPoints, targetAsset });
88
195
  }
89
196
 
90
197
  default:
91
- return "";
198
+ throw new Error(`Unsupported memo type: ${memoType}`);
92
199
  }
93
200
  };
@@ -62,7 +62,7 @@ export class AssetValue extends BigIntArithmetics {
62
62
  return this.chain === chain && this.symbol === symbol;
63
63
  }
64
64
 
65
- eq(assetValue: AssetValue): boolean {
65
+ eq(assetValue: AssetValue) {
66
66
  return this.eqAsset(assetValue) && this.eqValue(assetValue);
67
67
  }
68
68
 
@@ -177,6 +177,7 @@ export class AssetValue extends BigIntArithmetics {
177
177
 
178
178
  static fromChainOrSignature(assetString: CommonAssetString, value: NumberPrimitives = 0) {
179
179
  const { decimal, identifier } = getCommonAssetInfo(assetString);
180
+
180
181
  return new AssetValue({ value: safeValue(value, decimal), decimal, identifier });
181
182
  }
182
183
 
@@ -42,9 +42,7 @@ export function formatBigIntToSafeValue({
42
42
  // Check if we need to round up
43
43
  if (Number.parseInt(decimalString[bigIntDecimal] || "0") >= 5) {
44
44
  // Increment the last decimal place and slice off the rest
45
- decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(
46
- Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1
47
- ).toString()}`;
45
+ decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1).toString()}`;
48
46
  } else {
49
47
  // Just slice off the extra digits
50
48
  decimalString = decimalString.substring(0, bigIntDecimal);
@@ -277,9 +275,7 @@ export class BigIntArithmetics {
277
275
  // Check if we need to round up
278
276
  if (Number.parseInt(decimalString[bigIntDecimal] || "0") >= 5) {
279
277
  // Increment the last decimal place and slice off the rest
280
- decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(
281
- Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1
282
- ).toString()}`;
278
+ decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1).toString()}`;
283
279
  } else {
284
280
  // Just slice off the extra digits
285
281
  decimalString = decimalString.substring(0, bigIntDecimal);
@@ -11,7 +11,6 @@ const errorMessages = {
11
11
  core_plugin_swap_not_found: 10007,
12
12
  core_approve_asset_target_invalid: 10008,
13
13
  core_chain_halted: 10099,
14
-
15
14
  /**
16
15
  * Core - Wallet Connection
17
16
  */
@@ -24,8 +23,6 @@ const errorMessages = {
24
23
  core_wallet_keplr_not_installed: 10107,
25
24
  core_wallet_okx_not_installed: 10108,
26
25
  core_wallet_keepkey_not_installed: 10109,
27
- core_wallet_talisman_not_installed: 10110,
28
- core_wallet_not_keypair_wallet: 10111,
29
26
  /**
30
27
  * Core - Swap
31
28
  */
@@ -41,12 +38,12 @@ const errorMessages = {
41
38
  * Core - Transaction
42
39
  */
43
40
  core_transaction_deposit_error: 10301,
44
- core_transaction_create_liquidity_rune_error: 10302,
41
+ core_transaction_create_liquidity_base_error: 10302,
45
42
  core_transaction_create_liquidity_asset_error: 10303,
46
43
  core_transaction_create_liquidity_invalid_params: 10304,
47
44
  core_transaction_add_liquidity_invalid_params: 10305,
48
- core_transaction_add_liquidity_no_rune_address: 10306,
49
- core_transaction_add_liquidity_rune_error: 10307,
45
+ core_transaction_add_liquidity_base_address: 10306,
46
+ core_transaction_add_liquidity_base_error: 10307,
50
47
  core_transaction_add_liquidity_asset_error: 10308,
51
48
  core_transaction_withdraw_error: 10309,
52
49
  core_transaction_deposit_to_pool_error: 10310,
@@ -55,38 +52,38 @@ const errorMessages = {
55
52
  core_transaction_invalid_sender_address: 10313,
56
53
  core_transaction_deposit_server_error: 10314,
57
54
  core_transaction_user_rejected: 10315,
58
- core_transaction_create_liquidity_cacao_error: 10316,
59
- core_transaction_add_liquidity_no_cacao_address: 10306,
60
- core_transaction_add_liquidity_cacao_error: 10307,
61
-
62
55
  /**
63
56
  * Wallets
64
57
  */
58
+ wallet_connection_rejected_by_user: 20000,
65
59
  wallet_ledger_connection_error: 20001,
66
60
  wallet_ledger_connection_claimed: 20002,
67
61
  wallet_ledger_get_address_error: 20003,
68
62
  wallet_ledger_device_not_found: 20004,
69
63
  wallet_ledger_device_locked: 20005,
70
-
64
+ wallet_phantom_not_found: 20101,
65
+ wallet_xdefi_not_found: 20201,
66
+ wallet_xdefi_failed_to_add_or_switch_network: 20202,
71
67
  /**
72
68
  * Chainflip
73
69
  */
74
70
  chainflip_channel_error: 30001,
75
71
  chainflip_broker_recipient_error: 30002,
76
-
72
+ chainflip_unknown_asset: 30003,
77
73
  /**
78
74
  * THORChain
79
75
  */
80
-
76
+ thorchain_chain_halted: 40001,
77
+ thorchain_trading_halted: 40002,
81
78
  /**
82
79
  * SwapKit API
83
80
  */
84
- api_v2_invalid_response: 40001,
81
+ api_v2_invalid_response: 50001,
85
82
 
86
83
  /**
87
84
  * Helpers
88
85
  */
89
- helpers_number_different_decimals: 99101,
86
+ helpers_number_different_decimals: 99001,
90
87
  } as const;
91
88
 
92
89
  export type ErrorKeys = keyof typeof errorMessages;
@@ -20,6 +20,7 @@ export enum Chain {
20
20
  Polygon = "MATIC",
21
21
  Radix = "XRD",
22
22
  THORChain = "THOR",
23
+ Solana = "SOL",
23
24
  }
24
25
 
25
26
  export type WalletChain = Exclude<Chain, Chain.Chainflip | Chain.Radix>;
@@ -52,6 +53,7 @@ export enum ChainId {
52
53
  Radix = "radix-mainnet",
53
54
  THORChain = "thorchain-mainnet-v1",
54
55
  THORChainStagenet = "thorchain-stagenet-v2",
56
+ Solana = "solana",
55
57
  }
56
58
 
57
59
  export const ChainIdToChain: Record<ChainId, Chain> = {
@@ -82,6 +84,7 @@ export const ChainIdToChain: Record<ChainId, Chain> = {
82
84
  [ChainId.Radix]: Chain.Radix,
83
85
  [ChainId.THORChainStagenet]: Chain.THORChain,
84
86
  [ChainId.THORChain]: Chain.THORChain,
87
+ [ChainId.Solana]: Chain.Solana,
85
88
  };
86
89
 
87
90
  type ChainNameType = keyof typeof Chain;
@@ -106,9 +109,10 @@ export enum BaseDecimal {
106
109
  MATIC = 18,
107
110
  MAYA = 10,
108
111
  OP = 18,
112
+ SOL = 9,
109
113
  THOR = 8,
110
- ZEC = 8,
111
114
  XRD = 18,
115
+ ZEC = 8,
112
116
  }
113
117
 
114
118
  export type SubstrateChain = Chain.Polkadot | Chain.Chainflip;
@@ -27,8 +27,9 @@ export enum DerivationPath {
27
27
  MATIC = "m/44'/60'/0'/0",
28
28
  MAYA = "m/44'/931'/0'/0",
29
29
  OP = "m/44'/60'/0'/0",
30
- XRD = "////",
30
+ SOL = "m/44'/501'/0'/0",
31
31
  THOR = "m/44'/931'/0'/0",
32
+ XRD = "////",
32
33
  }
33
34
 
34
35
  export type DerivationPathArray = [number, number, number, number, number?];
@@ -49,6 +50,7 @@ export const NetworkDerivationPath: Record<Chain, DerivationPathArray> = {
49
50
  MATIC: [44, 60, 0, 0, 0],
50
51
  MAYA: [44, 931, 0, 0, 0],
51
52
  OP: [44, 60, 0, 0, 0],
53
+ SOL: [44, 501, 0, 0, 0],
52
54
  THOR: [44, 931, 0, 0, 0],
53
55
 
54
56
  // Polkadot and related network derivation path is not number based
@@ -20,6 +20,7 @@ export enum RPCUrl {
20
20
  Radix = "https://radix-mainnet.rpc.grove.city/v1/326002fc/core",
21
21
  THORChain = "https://rpc.thorswap.net",
22
22
  THORChainStagenet = "https://stagenet-rpc.ninerealms.com",
23
+ Solana = "https://mainnet.helius-rpc.com/?api-key=2cbe3ae6-cfc5-4141-a093-0055d0fa3d80",
23
24
  }
24
25
 
25
26
  export enum ExplorerUrl {
@@ -38,8 +39,9 @@ export enum ExplorerUrl {
38
39
  Litecoin = "https://blockchair.com/litecoin",
39
40
  Maya = "https://www.mayascan.org",
40
41
  Optimism = "https://optimistic.etherscan.io",
41
- Polkadot = "https://polkadot.subscan.io/",
42
+ Polkadot = "https://polkadot.subscan.io",
42
43
  Polygon = "https://polygonscan.com",
43
44
  Radix = "https://dashboard.radixdlt.com",
44
45
  THORChain = "https://runescan.io",
46
+ Solana = "https://solscan.io",
45
47
  }
@@ -9,24 +9,25 @@ declare global {
9
9
  }
10
10
 
11
11
  export enum WalletOption {
12
- KEYSTORE = "KEYSTORE",
13
- KEEPKEY = "KEEPKEY",
14
- XDEFI = "XDEFI",
15
- METAMASK = "METAMASK",
16
- COINBASE_WEB = "COINBASE_WEB",
12
+ BRAVE = "BRAVE",
17
13
  COINBASE_MOBILE = "COINBASE_MOBILE",
18
- TREZOR = "TREZOR",
19
- TRUSTWALLET_WEB = "TRUSTWALLET_WEB",
20
- LEDGER = "LEDGER",
14
+ COINBASE_WEB = "COINBASE_WEB",
15
+ EIP6963 = "EIP6963",
16
+ EXODUS = "EXODUS",
17
+ KEEPKEY = "KEEPKEY",
21
18
  KEPLR = "KEPLR",
19
+ KEYSTORE = "KEYSTORE",
20
+ LEDGER = "LEDGER",
21
+ METAMASK = "METAMASK",
22
22
  OKX = "OKX",
23
23
  OKX_MOBILE = "OKX_MOBILE",
24
- BRAVE = "BRAVE",
25
- WALLETCONNECT = "WALLETCONNECT",
26
- EIP6963 = "EIP6963",
27
- EXODUS = "EXODUS",
24
+ PHANTOM = "PHANTOM",
28
25
  RADIX_WALLET = "RADIX_WALLET",
26
+ TREZOR = "TREZOR",
29
27
  TALISMAN = "TALISMAN",
28
+ TRUSTWALLET_WEB = "TRUSTWALLET_WEB",
29
+ WALLETCONNECT = "WALLETCONNECT",
30
+ XDEFI = "XDEFI",
30
31
  }
31
32
 
32
33
  export enum LedgerErrorCode {
@@ -44,10 +45,8 @@ export type ChainWallet = {
44
45
  };
45
46
 
46
47
  export type EmptyWallet = { [key in Chain]?: unknown };
47
-
48
- export type BaseWallet<T extends EmptyWallet | unknown> = {
49
- // @ts-expect-error
50
- [key in Chain]: ChainWallet & T[key];
48
+ export type BaseWallet<T extends EmptyWallet | Record<string, unknown>> = {
49
+ [key in Chain]: ChainWallet & (T extends EmptyWallet ? T[key] : unknown);
51
50
  };
52
51
 
53
52
  export type EIP6963ProviderInfo = {