@swapkit/helpers 4.5.8 → 4.12.3
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/LICENSE +246 -0
- package/dist/api/index.cjs +0 -4
- package/dist/api/index.js +1 -4
- package/dist/chunk-1m30h0t9.js +1 -0
- package/dist/chunk-jsgxsr8a.js +4 -0
- package/dist/chunk-z5an6869.js +5 -0
- package/dist/contracts.cjs +0 -3
- package/dist/contracts.js +0 -3
- package/dist/index.cjs +1 -7
- package/dist/index.js +1 -7
- package/dist/tokens.cjs +0 -3
- package/dist/tokens.js +0 -3
- package/dist/types/api/index.d.ts +126 -153
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/midgard/endpoints.d.ts +2 -1
- package/dist/types/api/midgard/endpoints.d.ts.map +1 -1
- package/dist/types/api/swapkitApi/endpoints.d.ts +134 -159
- package/dist/types/api/swapkitApi/endpoints.d.ts.map +1 -1
- package/dist/types/api/swapkitApi/types.d.ts +1038 -23
- package/dist/types/api/swapkitApi/types.d.ts.map +1 -1
- package/dist/types/api/thornode/endpoints.d.ts +1 -1
- package/dist/types/api/thornode/endpoints.d.ts.map +1 -1
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/assetValue.d.ts +6 -7
- package/dist/types/modules/assetValue.d.ts.map +1 -1
- package/dist/types/modules/bigIntArithmetics.d.ts +2 -1
- package/dist/types/modules/bigIntArithmetics.d.ts.map +1 -1
- package/dist/types/modules/requestClient.d.ts +1 -1
- package/dist/types/modules/requestClient.d.ts.map +1 -1
- package/dist/types/modules/swapKitConfig.d.ts +24 -78
- package/dist/types/modules/swapKitConfig.d.ts.map +1 -1
- package/dist/types/modules/swapKitError.d.ts +146 -14
- package/dist/types/modules/swapKitError.d.ts.map +1 -1
- package/dist/types/modules/widgetAuth.d.ts +6 -0
- package/dist/types/modules/widgetAuth.d.ts.map +1 -0
- package/dist/types/types/derivationPath.d.ts +1 -1
- package/dist/types/types/derivationPath.d.ts.map +1 -1
- package/dist/types/types/quotes.d.ts +2 -6
- package/dist/types/types/quotes.d.ts.map +1 -1
- package/dist/types/types/sdk.d.ts +6 -0
- package/dist/types/types/sdk.d.ts.map +1 -1
- package/dist/types/types/wallet.d.ts +12 -3
- package/dist/types/types/wallet.d.ts.map +1 -1
- package/dist/types/utils/asset.d.ts +17 -1
- package/dist/types/utils/asset.d.ts.map +1 -1
- package/dist/types/utils/chains.d.ts +5 -0
- package/dist/types/utils/chains.d.ts.map +1 -1
- package/dist/types/utils/derivationPath.d.ts +4 -2
- package/dist/types/utils/derivationPath.d.ts.map +1 -1
- package/dist/types/utils/wallets.d.ts +18 -2
- package/dist/types/utils/wallets.d.ts.map +1 -1
- package/package.json +12 -30
- package/dist/api/index.cjs.map +0 -14
- package/dist/api/index.js.map +0 -14
- package/dist/chunk-pfmeq01a.js +0 -5
- package/dist/chunk-pfmeq01a.js.map +0 -9
- package/dist/chunk-vb4wtm2w.js +0 -4
- package/dist/chunk-vb4wtm2w.js.map +0 -9
- package/dist/contracts.cjs.map +0 -10
- package/dist/contracts.js.map +0 -10
- package/dist/index.cjs.map +0 -30
- package/dist/index.js.map +0 -30
- package/dist/tokens.cjs.map +0 -10
- package/dist/tokens.js.map +0 -10
- package/src/api/index.ts +0 -9
- package/src/api/midgard/endpoints.ts +0 -348
- package/src/api/midgard/types.ts +0 -515
- package/src/api/swapkitApi/endpoints.ts +0 -247
- package/src/api/swapkitApi/types.ts +0 -624
- package/src/api/thornode/endpoints.ts +0 -105
- package/src/api/thornode/types.ts +0 -247
- package/src/contracts.ts +0 -1
- package/src/index.ts +0 -28
- package/src/modules/__tests__/assetValue.test.ts +0 -1892
- package/src/modules/__tests__/bigIntArithmetics.test.ts +0 -408
- package/src/modules/__tests__/feeMultiplier.test.ts +0 -125
- package/src/modules/__tests__/swapKitConfig.test.ts +0 -425
- package/src/modules/__tests__/swapKitNumber.test.ts +0 -435
- package/src/modules/assetValue.ts +0 -532
- package/src/modules/bigIntArithmetics.ts +0 -368
- package/src/modules/feeMultiplier.ts +0 -80
- package/src/modules/requestClient.ts +0 -110
- package/src/modules/swapKitConfig.ts +0 -174
- package/src/modules/swapKitError.ts +0 -470
- package/src/modules/swapKitNumber.ts +0 -13
- package/src/tokens.ts +0 -1
- package/src/types/commonTypes.ts +0 -10
- package/src/types/derivationPath.ts +0 -11
- package/src/types/errors/apiV1.ts +0 -0
- package/src/types/index.ts +0 -5
- package/src/types/quotes.ts +0 -174
- package/src/types/sdk.ts +0 -38
- package/src/types/wallet.ts +0 -124
- package/src/utils/__tests__/asset.test.ts +0 -186
- package/src/utils/__tests__/derivationPath.test.ts +0 -142
- package/src/utils/__tests__/explorerUrls.test.ts +0 -59
- package/src/utils/__tests__/liquidity.test.ts +0 -302
- package/src/utils/__tests__/memo.test.ts +0 -99
- package/src/utils/__tests__/others.test.ts +0 -165
- package/src/utils/__tests__/validators.test.ts +0 -84
- package/src/utils/__tests__/wallets.test.ts +0 -621
- package/src/utils/asset.ts +0 -399
- package/src/utils/chains.ts +0 -100
- package/src/utils/derivationPath.ts +0 -101
- package/src/utils/explorerUrls.ts +0 -32
- package/src/utils/liquidity.ts +0 -150
- package/src/utils/memo.ts +0 -102
- package/src/utils/others.ts +0 -62
- package/src/utils/validators.ts +0 -32
- package/src/utils/wallets.ts +0 -237
package/src/types/quotes.ts
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
export enum ErrorCode {
|
|
2
|
-
unknownError = "unknownError",
|
|
3
|
-
test_error = "test_error",
|
|
4
|
-
providerDetailsError = "providerDetailsError",
|
|
5
|
-
blockHeaderNotFound = "blockHeaderNotFound",
|
|
6
|
-
blockHashNotFoundAtHeight = "blockHashNotFoundAtHeight",
|
|
7
|
-
blockHashNotFoundAtHash = "blockHashNotFoundAtHash",
|
|
8
|
-
txHashMissing = "txHashMissing",
|
|
9
|
-
assetValueMissingInfo = "assetValueMissingInfo",
|
|
10
|
-
invalidAsset = "invalidAsset",
|
|
11
|
-
blockIsRequired = "blockIsRequired",
|
|
12
|
-
currentBlockHeaderNotFound = "currentBlockHeaderNotFound",
|
|
13
|
-
failedToRetrieveBalance = "failedToRetrieveBalance",
|
|
14
|
-
failedToRetrieveBlock = "failedToRetrieveBlock",
|
|
15
|
-
failedToRetrieveFees = "failedToRetrieveFees",
|
|
16
|
-
notImplementedBCH = "notImplementedBCH",
|
|
17
|
-
notImplementedDoge = "notImplementedDoge",
|
|
18
|
-
noPoolsFound = "noPoolsFound",
|
|
19
|
-
noVaultsFound = "noVaultsFound",
|
|
20
|
-
noTxFound = "noTxFound",
|
|
21
|
-
noInputCoinFound = "noInputCoinFound",
|
|
22
|
-
noBlockDataFound = "noBlockDataFound",
|
|
23
|
-
multipleCosmosMessages = "multipleCosmosMessages",
|
|
24
|
-
heightOrHashNotProvided = "heightOrHashNotProvided",
|
|
25
|
-
unknownDenom = "unknownDenom",
|
|
26
|
-
invalidBlockHeight = "invalidBlockHeight",
|
|
27
|
-
timestampExtrinsicNoArgumentsForBlock = "timestampExtrinsicNoArgumentsForBlock",
|
|
28
|
-
timestampExtrinsicNoTimestampForBlock = "timestampExtrinsicNoTimestampForBlock",
|
|
29
|
-
noTimestampExtrinsicForHash = "noTimestampExtrinsicForHash",
|
|
30
|
-
timestampExtrinsicNoArgumentsForHash = "timestampExtrinsicNoArgumentsForHash",
|
|
31
|
-
txMemoUndefined = "txMemoUndefined",
|
|
32
|
-
txMemoIncorrect = "txMemoIncorrect",
|
|
33
|
-
txTypeNotFound = "txTypeNotFound",
|
|
34
|
-
txNoMessage = "txNoMessage",
|
|
35
|
-
txNotFound = "txNotFound",
|
|
36
|
-
txReceiptNotFound = "txReceiptNotFound",
|
|
37
|
-
txParsingError = "txParsingError",
|
|
38
|
-
txLogsParsingError = "txLogsParsingError",
|
|
39
|
-
blockNotFound = "blockNotFound",
|
|
40
|
-
balanceNotFound = "balanceNotFound",
|
|
41
|
-
configError = "configError",
|
|
42
|
-
synthSwapDisallowed = "synthSwapDisallowed",
|
|
43
|
-
providerQuoteTimeout = "providerQuoteTimeout",
|
|
44
|
-
noQuoteResponse = "noQuoteResponse",
|
|
45
|
-
noPoolAssetsFound = "noPoolAssetsFound",
|
|
46
|
-
noThorchainPools = "noThorchainPools",
|
|
47
|
-
noMayachainPools = "noMayachainPools",
|
|
48
|
-
noThorchainNetworkInfo = "noThorchainNetworkInfo",
|
|
49
|
-
invalidAffiliateFee = "invalidAffiliateFee",
|
|
50
|
-
invalidBuyAssetAddress = "invalidBuyAssetAddress",
|
|
51
|
-
invalidSellAssetAddress = "invalidSellAssetAddress",
|
|
52
|
-
invalidSourceAddress = "invalidSourceAddress",
|
|
53
|
-
invalidDestinationAddress = "invalidDestinationAddress",
|
|
54
|
-
sourceAddressIsSmartContract = "sourceAddressIsSmartContract",
|
|
55
|
-
destinationAddressIsSmartContract = "destinationAddressIsSmartContract",
|
|
56
|
-
invalidChainId = "invalidChainId",
|
|
57
|
-
unsupportedChainId = "unsupportedChainId",
|
|
58
|
-
unsupportedEVMChainId = "unsupportedEVMChainId",
|
|
59
|
-
unsupportedMethod = "unsupportedMethod",
|
|
60
|
-
unsupportedProvider = "unsupportedProvider",
|
|
61
|
-
invalidParamsForMethod = "invalidParamsForMethod",
|
|
62
|
-
unsupportedAdapter = "unsupportedAdapter",
|
|
63
|
-
noWhitelistTokens = "noWhitelistTokens",
|
|
64
|
-
failedFetchGasPrice = "failedFetchGasPrice",
|
|
65
|
-
failedToCreateDepositChannel = "failedToCreateDepositChannel",
|
|
66
|
-
noProviderDetailsFound = "noProviderDetailsFound",
|
|
67
|
-
noTokenListsFound = "noTokenListsFound",
|
|
68
|
-
tokenNotFound = "tokenNotFound",
|
|
69
|
-
tokenPriceNotFound = "tokenPriceNotFound",
|
|
70
|
-
tokenPriceFailedToUpdate = "tokenPriceFailedToUpdate",
|
|
71
|
-
swapAmountTooSmall = "swapAmountTooSmall",
|
|
72
|
-
legsArrayIsEmpty = "legsArrayIsEmpty",
|
|
73
|
-
failedToFetchQuoteForLeg = "failedToFetchQuoteForLeg",
|
|
74
|
-
noBlockHeaderFound = "noBlockHeaderFound",
|
|
75
|
-
failedToSimulateSwap = "failedToSimulateSwap",
|
|
76
|
-
addressScreeningFailed = "addressScreeningFailed",
|
|
77
|
-
noLiquidtyProvidersFound = "noLiquidtyProvidersFound",
|
|
78
|
-
insufficientLiquidity = "insufficientLiquidity",
|
|
79
|
-
noInboundDataFound = "noInbounDataFound",
|
|
80
|
-
noInboundAddressesFound = "noInboundAddressesFound",
|
|
81
|
-
noInboundAddressFoundForChain = "noInboundAddressFoundForChain",
|
|
82
|
-
noLastBlocksFound = "noLastBlocksFound",
|
|
83
|
-
noVersionFound = "noVersionFound",
|
|
84
|
-
noConstantsFound = "noConstantsFound",
|
|
85
|
-
noMimirsFound = "noMimirsFound",
|
|
86
|
-
noRoutesFound = "noRoutesFound",
|
|
87
|
-
quoteNotFound = "quoteNotFound",
|
|
88
|
-
ledgerSignFailed = "ledgerSignFailed",
|
|
89
|
-
ledgerWrongPayload = "ledgerWrongPayload",
|
|
90
|
-
ledgerFetchSwapFailed = "ledgerFetchSwapFailed",
|
|
91
|
-
failedToFetchTx = "failedToFetchTx",
|
|
92
|
-
failedBuildTransactionDetails = "failedBuildTransactionDetails",
|
|
93
|
-
noLegsForRoute = "noLegsForRoute",
|
|
94
|
-
noRouterAddressFound = "noRouterAddressFound",
|
|
95
|
-
noAggregatorAddressFound = "noAggregatorAddressFound",
|
|
96
|
-
noContractInstanceFound = "noContractInstanceFound",
|
|
97
|
-
noContractAddressFound = "noContractAddressFound",
|
|
98
|
-
invalidAffiliate = "invalidAffiliate",
|
|
99
|
-
thornameAffiliate = "thornameAffiliate",
|
|
100
|
-
providerNotfound = "No provider found",
|
|
101
|
-
noRecordFound = "No Record found",
|
|
102
|
-
slippageTooLow = "Slippage too low",
|
|
103
|
-
tradingHalted = "tradingHalted",
|
|
104
|
-
noWrappedGasAsset = "noWrappedGasAsset",
|
|
105
|
-
aggregatorAddressNotFound = "aggregatorAddressNotFound",
|
|
106
|
-
routerAddressNotFound = "routerAddressNotFound",
|
|
107
|
-
dummyAddressNotFound = "dummyAddressNotFound",
|
|
108
|
-
trackerError = "trackerError",
|
|
109
|
-
thorchainPoolUnavailable = "thorchainPoolUnavailable",
|
|
110
|
-
noOhlcvDataFound = "noOhlcvDataFound",
|
|
111
|
-
noTradingPairs = "noTradingPairs",
|
|
112
|
-
noLendingAvailability = "noLendingAvailability",
|
|
113
|
-
lendingRepayTooSmall = "lendingRepayTooSmall",
|
|
114
|
-
missingState = "missingState",
|
|
115
|
-
ledgerSwapNotFound = "ledgerSwapNotFound",
|
|
116
|
-
ledgerSwapNotReadyForTracking = "ledgerSwapNotReadyForTracking",
|
|
117
|
-
errorEstimatingGas = "errorEstimatingGas",
|
|
118
|
-
apiKeyInvalid = "apiKeyInvalid",
|
|
119
|
-
apiKeyFailedToUpdate = "apiKeyFailedToUpdate",
|
|
120
|
-
apiKeyExpired = "apiKeyExpired",
|
|
121
|
-
unauthorized = "unauthorized",
|
|
122
|
-
failedToCreateMemo = "failedToCreateMemo",
|
|
123
|
-
radixIncorrectInstructions = "radixIncorrectInstructions",
|
|
124
|
-
radixTxMissedParam = "radixTxMissedParam",
|
|
125
|
-
radixTxMissedAccount = "radixTxMissedAccount",
|
|
126
|
-
radixManifestParseError = "radixManifestParseError",
|
|
127
|
-
radixManifestBuildError = "radixManifestBuildError",
|
|
128
|
-
invalidAddressForChain = "invalidAddressForChain",
|
|
129
|
-
riskyAddress = "riskyAddress",
|
|
130
|
-
noRoutesToProcess = "noRoutesToProcess",
|
|
131
|
-
sellAssetAmountTooSmall = "sellAssetAmountTooSmall",
|
|
132
|
-
missingPrivateKey = "missingPrivateKey",
|
|
133
|
-
noMemoPriceProtection = "noMemoPriceProtection",
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export enum WarningCodeEnum {
|
|
137
|
-
highSlippage = "highSlippage",
|
|
138
|
-
highPriceImpact = "highPriceImpact",
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export enum ProviderName {
|
|
142
|
-
CAVIAR_V1 = "CAVIAR_V1",
|
|
143
|
-
CAMELOT_V3 = "CAMELOT_V3",
|
|
144
|
-
CHAINFLIP = "CHAINFLIP",
|
|
145
|
-
CHAINFLIP_STREAMING = "CHAINFLIP_STREAMING",
|
|
146
|
-
JUPITER = "JUPITER",
|
|
147
|
-
MAYACHAIN = "MAYACHAIN",
|
|
148
|
-
MAYACHAIN_STREAMING = "MAYACHAIN_STREAMING",
|
|
149
|
-
OCISWAP_V1 = "OCISWAP_V1",
|
|
150
|
-
ONEINCH = "ONEINCH",
|
|
151
|
-
OPENOCEAN_V2 = "OPENOCEAN_V2",
|
|
152
|
-
PANCAKESWAP = "PANCAKESWAP",
|
|
153
|
-
PANGOLIN_V1 = "PANGOLIN_V1",
|
|
154
|
-
SUSHISWAP_V2 = "SUSHISWAP_V2",
|
|
155
|
-
THORCHAIN = "THORCHAIN",
|
|
156
|
-
THORCHAIN_STREAMING = "THORCHAIN_STREAMING",
|
|
157
|
-
TRADERJOE_V2 = "TRADERJOE_V2",
|
|
158
|
-
UNISWAP_V2 = "UNISWAP_V2",
|
|
159
|
-
UNISWAP_V3 = "UNISWAP_V3",
|
|
160
|
-
NEAR = "NEAR",
|
|
161
|
-
GARDEN = "GARDEN",
|
|
162
|
-
OKX = "OKX",
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export enum FeeTypeEnum {
|
|
166
|
-
LIQUIDITY = "liquidity",
|
|
167
|
-
NETWORK = "network",
|
|
168
|
-
INBOUND = "inbound",
|
|
169
|
-
OUTBOUND = "outbound",
|
|
170
|
-
AFFILIATE = "affiliate",
|
|
171
|
-
TAX = "tax",
|
|
172
|
-
PRIORITY = "priority",
|
|
173
|
-
SERVICE = "service",
|
|
174
|
-
}
|
package/src/types/sdk.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { AssetValue } from "../modules/assetValue";
|
|
2
|
-
|
|
3
|
-
export type GenericSwapParams<T = unknown> = {
|
|
4
|
-
buyAsset?: AssetValue;
|
|
5
|
-
sellAsset?: AssetValue;
|
|
6
|
-
recipient?: string;
|
|
7
|
-
feeOptionKey?: FeeOption;
|
|
8
|
-
route: T;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type SwapParams<PluginNames = string, R = unknown> = GenericSwapParams<R> & { pluginName?: PluginNames };
|
|
12
|
-
|
|
13
|
-
export enum FeeOption {
|
|
14
|
-
Average = "average",
|
|
15
|
-
Fast = "fast",
|
|
16
|
-
Fastest = "fastest",
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export enum ApproveMode {
|
|
20
|
-
Approve = "approve",
|
|
21
|
-
CheckOnly = "checkOnly",
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type ApproveReturnType<T extends ApproveMode> = T extends "checkOnly" ? Promise<boolean> : Promise<string>;
|
|
25
|
-
|
|
26
|
-
export enum MemoType {
|
|
27
|
-
NAME_REGISTER = "~",
|
|
28
|
-
BOND = "BOND",
|
|
29
|
-
DEPOSIT = "+",
|
|
30
|
-
LEAVE = "LEAVE",
|
|
31
|
-
UNBOND = "UNBOND",
|
|
32
|
-
WITHDRAW = "-",
|
|
33
|
-
RUNEPOOL_DEPOSIT = "POOL+",
|
|
34
|
-
RUNEPOOL_WITHDRAW = "POOL-",
|
|
35
|
-
CLAIM_TCY = "tcy",
|
|
36
|
-
STAKE_TCY = "tcy+",
|
|
37
|
-
UNSTAKE_TCY = "tcy-",
|
|
38
|
-
}
|
package/src/types/wallet.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import type { Chain, getChainConfig } from "@swapkit/types";
|
|
2
|
-
import type { BrowserProvider, Eip1193Provider } from "ethers";
|
|
3
|
-
|
|
4
|
-
import type { AssetValue } from "../modules/assetValue";
|
|
5
|
-
import type { FeeOption } from "./sdk";
|
|
6
|
-
|
|
7
|
-
declare global {
|
|
8
|
-
interface WindowEventMap {
|
|
9
|
-
"eip6963:announceProvider": CustomEvent;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type EthereumWindowProvider = BrowserProvider & {
|
|
14
|
-
__XDEFI?: boolean;
|
|
15
|
-
isBraveWallet?: boolean;
|
|
16
|
-
isCoinbaseWallet?: boolean;
|
|
17
|
-
isMetaMask?: boolean;
|
|
18
|
-
isOkxWallet?: boolean;
|
|
19
|
-
isKeepKeyWallet?: boolean;
|
|
20
|
-
isTrust?: boolean;
|
|
21
|
-
isTalisman?: boolean;
|
|
22
|
-
on: (event: string, callback?: () => void) => void;
|
|
23
|
-
overrideIsMetaMask?: boolean;
|
|
24
|
-
request: <T = unknown>(args: { method: string; params?: unknown[] }) => Promise<T>;
|
|
25
|
-
selectedProvider?: EthereumWindowProvider;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type NetworkParams = {
|
|
29
|
-
chainId: ReturnType<typeof getChainConfig>["chainIdHex"];
|
|
30
|
-
chainName: string;
|
|
31
|
-
nativeCurrency: { name: string; symbol: string; decimals: number };
|
|
32
|
-
rpcUrls: string[];
|
|
33
|
-
blockExplorerUrls: string[];
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export enum WalletOption {
|
|
37
|
-
BITGET = "BITGET",
|
|
38
|
-
BRAVE = "BRAVE",
|
|
39
|
-
COINBASE_MOBILE = "COINBASE_MOBILE",
|
|
40
|
-
COINBASE_WEB = "COINBASE_WEB",
|
|
41
|
-
COSMOSTATION = "COSMOSTATION",
|
|
42
|
-
CTRL = "CTRL",
|
|
43
|
-
EIP6963 = "EIP6963",
|
|
44
|
-
/**
|
|
45
|
-
* @deprecated Use PASSKEYS instead
|
|
46
|
-
*/
|
|
47
|
-
EXODUS = "EXODUS",
|
|
48
|
-
KEEPKEY = "KEEPKEY",
|
|
49
|
-
KEEPKEY_BEX = "KEEPKEY_BEX",
|
|
50
|
-
KEPLR = "KEPLR",
|
|
51
|
-
KEYSTORE = "KEYSTORE",
|
|
52
|
-
LEAP = "LEAP",
|
|
53
|
-
LEDGER = "LEDGER",
|
|
54
|
-
LEDGER_LIVE = "LEDGER_LIVE",
|
|
55
|
-
METAMASK = "METAMASK",
|
|
56
|
-
OKX = "OKX",
|
|
57
|
-
OKX_MOBILE = "OKX_MOBILE",
|
|
58
|
-
ONEKEY = "ONEKEY",
|
|
59
|
-
PASSKEYS = "PASSKEYS",
|
|
60
|
-
PHANTOM = "PHANTOM",
|
|
61
|
-
POLKADOT_JS = "POLKADOT_JS",
|
|
62
|
-
RADIX_WALLET = "RADIX_WALLET",
|
|
63
|
-
TALISMAN = "TALISMAN",
|
|
64
|
-
TREZOR = "TREZOR",
|
|
65
|
-
TRONLINK = "TRONLINK",
|
|
66
|
-
TRUSTWALLET_WEB = "TRUSTWALLET_WEB",
|
|
67
|
-
VULTISIG = "VULTISIG",
|
|
68
|
-
WALLETCONNECT = "WALLETCONNECT",
|
|
69
|
-
WALLET_SELECTOR = "WALLET_SELECTOR",
|
|
70
|
-
XAMAN = "XAMAN",
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export enum LedgerErrorCode {
|
|
74
|
-
NoError = 0x9000,
|
|
75
|
-
LockedDevice = 0x5515,
|
|
76
|
-
TC_NotFound = 65535,
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* @deprecated CryptoChain has been deprecated - use Chain instead
|
|
81
|
-
*/
|
|
82
|
-
export type CryptoChain = Chain;
|
|
83
|
-
|
|
84
|
-
export type ChainWallet<T extends Chain> = {
|
|
85
|
-
chain: T;
|
|
86
|
-
address: string;
|
|
87
|
-
balance: AssetValue[];
|
|
88
|
-
walletType: WalletOption | string;
|
|
89
|
-
disconnect?: () => void;
|
|
90
|
-
signMessage?: (message: string) => Promise<string>;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export type EmptyWallet = { [key in Chain]?: unknown };
|
|
94
|
-
export type BaseWallet<T extends EmptyWallet | Record<string, unknown>> = {
|
|
95
|
-
[key in Chain]: ChainWallet<key> & (T extends EmptyWallet ? T[key] : never);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export type EIP6963ProviderInfo = { walletId: string; uuid: string; name: string; icon: string };
|
|
99
|
-
|
|
100
|
-
export type EIP6963ProviderDetail = { info: EIP6963ProviderInfo; provider: Eip1193Provider };
|
|
101
|
-
|
|
102
|
-
export type EIP6963Provider = { info: EIP6963ProviderInfo; provider: Eip1193Provider };
|
|
103
|
-
|
|
104
|
-
// This type represents the structure of an event dispatched by a wallet to announce its presence based on EIP-6963.
|
|
105
|
-
export type EIP6963AnnounceProviderEvent = Event & { detail: EIP6963Provider };
|
|
106
|
-
|
|
107
|
-
export type ChainSigner<T, S> = {
|
|
108
|
-
signTransaction: (params: T) => Promise<S> | S;
|
|
109
|
-
getAddress: () => Promise<string> | string;
|
|
110
|
-
sign?: (message: string) => Promise<string> | string;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export type GenericTransferParams = {
|
|
114
|
-
recipient: string;
|
|
115
|
-
assetValue: AssetValue;
|
|
116
|
-
memo?: string;
|
|
117
|
-
feeRate?: number;
|
|
118
|
-
feeOptionKey?: FeeOption;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
export type GenericCreateTransactionParams = Omit<GenericTransferParams, "feeOptionKey" & "feeRate"> & {
|
|
122
|
-
sender: string;
|
|
123
|
-
feeRate: number;
|
|
124
|
-
};
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { AllChains, Chain, getChainConfig } from "@swapkit/types";
|
|
3
|
-
|
|
4
|
-
import { assetFromString, fetchTokenInfo, getAssetType } from "../asset";
|
|
5
|
-
|
|
6
|
-
// TODO: this should be handled via AssetValue
|
|
7
|
-
const tickerMap: Record<string, string> = {
|
|
8
|
-
[Chain.Arbitrum]: "ETH",
|
|
9
|
-
[Chain.Aurora]: "ETH",
|
|
10
|
-
[Chain.Base]: "ETH",
|
|
11
|
-
[Chain.BinanceSmartChain]: "BNB",
|
|
12
|
-
[Chain.Monad]: "MON",
|
|
13
|
-
[Chain.Cosmos]: "ATOM",
|
|
14
|
-
[Chain.Maya]: "CACAO",
|
|
15
|
-
[Chain.Optimism]: "ETH",
|
|
16
|
-
[Chain.THORChain]: "RUNE",
|
|
17
|
-
[Chain.Tron]: "TRX",
|
|
18
|
-
[Chain.XLayer]: "OKB",
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
describe("getAssetType", () => {
|
|
22
|
-
describe("when isSynth is true", () => {
|
|
23
|
-
test('should return "Synth"', () => {
|
|
24
|
-
const result = getAssetType({ chain: Chain.Bitcoin, symbol: "BTC/BTC" });
|
|
25
|
-
expect(result).toBe("Synth");
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe("when isSynth is false", () => {
|
|
30
|
-
describe("for gas assets on given chain", () => {
|
|
31
|
-
for (const chain of AllChains) {
|
|
32
|
-
test(`should return "Native" for chain ${chain} asset`, () => {
|
|
33
|
-
const ticker = tickerMap[chain] || chain;
|
|
34
|
-
const result = getAssetType({ chain: chain as Chain, symbol: ticker });
|
|
35
|
-
|
|
36
|
-
expect(result).toBe("Native");
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe("for non-gas assets on given chain", () => {
|
|
42
|
-
for (const chain of AllChains) {
|
|
43
|
-
test(`should return ${chain} for chain ${chain} asset`, () => {
|
|
44
|
-
const result = getAssetType({ chain: chain as Chain, symbol: "USDT" });
|
|
45
|
-
|
|
46
|
-
expect(result).toBe(chain);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe("fetchTokenInfo", () => {
|
|
54
|
-
/**
|
|
55
|
-
* Test out native
|
|
56
|
-
*/
|
|
57
|
-
const filteredChains = AllChains.filter((c) => ![Chain.Ethereum, Chain.Avalanche].includes(c));
|
|
58
|
-
|
|
59
|
-
for (const chain of filteredChains) {
|
|
60
|
-
describe(chain, () => {
|
|
61
|
-
test(`returns proper decimal for native ${chain} asset`, async () => {
|
|
62
|
-
const { decimals } = await fetchTokenInfo({ address: "", chain });
|
|
63
|
-
const { baseDecimal } = getChainConfig(chain);
|
|
64
|
-
expect(decimals).toBe(baseDecimal);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
describe("ETH", () => {
|
|
70
|
-
// TODO: if too many requests, this will fail due to timeout
|
|
71
|
-
test.todo("returns proper decimal for eth and it's assets", async () => {
|
|
72
|
-
const { decimals: ethDecimal } = await fetchTokenInfo({ address: "", chain: Chain.Ethereum });
|
|
73
|
-
expect(ethDecimal).toBe(getChainConfig(Chain.Ethereum).baseDecimal);
|
|
74
|
-
await Bun.sleep(500);
|
|
75
|
-
|
|
76
|
-
const { decimals: usdcDecimal } = await fetchTokenInfo({
|
|
77
|
-
address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
78
|
-
chain: Chain.Ethereum,
|
|
79
|
-
});
|
|
80
|
-
expect(usdcDecimal).toBe(6);
|
|
81
|
-
await Bun.sleep(500);
|
|
82
|
-
|
|
83
|
-
const { decimals: wbtcDecimal } = await fetchTokenInfo({
|
|
84
|
-
address: "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599",
|
|
85
|
-
chain: Chain.Ethereum,
|
|
86
|
-
});
|
|
87
|
-
expect(wbtcDecimal).toBe(8);
|
|
88
|
-
await Bun.sleep(500);
|
|
89
|
-
|
|
90
|
-
const { decimals: kindDecimal } = await fetchTokenInfo({
|
|
91
|
-
address: "0x4618519de4c304f3444ffa7f812dddc2971cc688",
|
|
92
|
-
chain: Chain.Ethereum,
|
|
93
|
-
});
|
|
94
|
-
expect(kindDecimal).toBe(8);
|
|
95
|
-
await Bun.sleep(500);
|
|
96
|
-
|
|
97
|
-
const { decimals: shitcoinDecimal } = await fetchTokenInfo({
|
|
98
|
-
address: "0xCa208BfD69ae6D2667f1FCbE681BAe12767c0078",
|
|
99
|
-
chain: Chain.Ethereum,
|
|
100
|
-
});
|
|
101
|
-
expect(shitcoinDecimal).toBe(0);
|
|
102
|
-
await Bun.sleep(500);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe("AVAX", () => {
|
|
107
|
-
// TODO: if too many requests, this will fail due to timeout
|
|
108
|
-
test.todo("returns proper decimal for avax and it's assets", async () => {
|
|
109
|
-
const { decimals: avaxDecimal } = await fetchTokenInfo({ address: "", chain: Chain.Avalanche });
|
|
110
|
-
expect(avaxDecimal).toBe(getChainConfig(Chain.Avalanche).baseDecimal);
|
|
111
|
-
|
|
112
|
-
const { decimals: wbtceDecimal } = await fetchTokenInfo({
|
|
113
|
-
address: "0x50b7545627a5162f82a992c33b87adc75187b218",
|
|
114
|
-
chain: Chain.Avalanche,
|
|
115
|
-
});
|
|
116
|
-
expect(wbtceDecimal).toBe(8);
|
|
117
|
-
|
|
118
|
-
const { decimals: btcbDecimal } = await fetchTokenInfo({
|
|
119
|
-
address: "0x152b9d0FdC40C096757F570A51E494bd4b943E50",
|
|
120
|
-
chain: Chain.Avalanche,
|
|
121
|
-
});
|
|
122
|
-
expect(btcbDecimal).toBe(8);
|
|
123
|
-
|
|
124
|
-
const { decimals: timeDecimal } = await fetchTokenInfo({
|
|
125
|
-
address: "0xb54f16fB19478766A268F172C9480f8da1a7c9C3",
|
|
126
|
-
chain: Chain.Avalanche,
|
|
127
|
-
});
|
|
128
|
-
expect(timeDecimal).toBe(9);
|
|
129
|
-
|
|
130
|
-
const { decimals: usdtDecimal } = await fetchTokenInfo({
|
|
131
|
-
address: "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",
|
|
132
|
-
chain: Chain.Avalanche,
|
|
133
|
-
});
|
|
134
|
-
expect(usdtDecimal).toBe(6);
|
|
135
|
-
|
|
136
|
-
const { decimals: usdcDecimal } = await fetchTokenInfo({
|
|
137
|
-
address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
|
|
138
|
-
chain: Chain.Avalanche,
|
|
139
|
-
});
|
|
140
|
-
expect(usdcDecimal).toBe(6);
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
describe("Radix", () => {
|
|
145
|
-
test.todo("returns proper decimal for radix and it's assets", async () => {
|
|
146
|
-
const { decimals: radixDecimal } = await fetchTokenInfo({ address: "", chain: Chain.Radix });
|
|
147
|
-
expect(radixDecimal).toBe(getChainConfig(Chain.Radix).baseDecimal);
|
|
148
|
-
await Bun.sleep(500);
|
|
149
|
-
|
|
150
|
-
const { decimals: xwBTCDecimal } = await fetchTokenInfo({
|
|
151
|
-
address: "xwBTC-resource_rdx1t580qxc7upat7lww4l2c4jckacafjeudxj5wpjrrct0p3e82sq4y75",
|
|
152
|
-
chain: Chain.Radix,
|
|
153
|
-
});
|
|
154
|
-
expect(xwBTCDecimal).toBe(8);
|
|
155
|
-
await Bun.sleep(500);
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
describe("assetFromString", () => {
|
|
161
|
-
test("should return the correct object", () => {
|
|
162
|
-
const assetString = "THOR.RUNE";
|
|
163
|
-
const result = assetFromString(assetString);
|
|
164
|
-
|
|
165
|
-
expect(result).toEqual({ chain: Chain.THORChain, symbol: "RUNE", synth: false, ticker: "RUNE" });
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
test("should return the correct object for multiple dashes", () => {
|
|
169
|
-
const assetString = "ETH.PENDLE-LPT-0x1234";
|
|
170
|
-
const result = assetFromString(assetString);
|
|
171
|
-
|
|
172
|
-
expect(result).toEqual({ chain: Chain.Ethereum, symbol: "PENDLE-LPT-0x1234", synth: false, ticker: "PENDLE-LPT" });
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
test.todo("should return the correct object for Radix resource", () => {
|
|
176
|
-
const assetString = "XRD.xwBTC-resource_rdx1t580qxc7upat7lww4l2c4jckacafjeudxj5wpjrrct0p3e82sq4y75";
|
|
177
|
-
const result = assetFromString(assetString);
|
|
178
|
-
|
|
179
|
-
expect(result).toEqual({
|
|
180
|
-
chain: Chain.Radix,
|
|
181
|
-
symbol: "xwBTC-resource_rdx1t580qxc7upat7lww4l2c4jckacafjeudxj5wpjrrct0p3e82sq4y75",
|
|
182
|
-
synth: false,
|
|
183
|
-
ticker: "xwBTC",
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
});
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { Chain } from "@swapkit/types";
|
|
3
|
-
|
|
4
|
-
import type { DerivationPathArray } from "../../types";
|
|
5
|
-
import {
|
|
6
|
-
DerivationPath,
|
|
7
|
-
derivationPathToString,
|
|
8
|
-
getDerivationPathFor,
|
|
9
|
-
getWalletFormatFor,
|
|
10
|
-
updateDerivationPath,
|
|
11
|
-
} from "../derivationPath";
|
|
12
|
-
|
|
13
|
-
describe("derivationPathToString", () => {
|
|
14
|
-
test("full 5-element path", () => {
|
|
15
|
-
expect(derivationPathToString([44, 60, 0, 0, 0] as DerivationPathArray)).toBe("m/44'/60'/0'/0/0");
|
|
16
|
-
expect(derivationPathToString([84, 0, 0, 0, 5] as DerivationPathArray)).toBe("m/84'/0'/0'/0/5");
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test("4-element path without index", () => {
|
|
20
|
-
expect(derivationPathToString([44, 60, 0, 0] as DerivationPathArray)).toBe("m/44'/60'/0'/0");
|
|
21
|
-
expect(derivationPathToString([49, 2, 0, 1] as DerivationPathArray)).toBe("m/49'/2'/0'/1");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("3-element account path", () => {
|
|
25
|
-
expect(derivationPathToString([44, 60, 0] as unknown as DerivationPathArray)).toBe("m/44'/60'/0'");
|
|
26
|
-
expect(derivationPathToString([44, 501, 5] as unknown as DerivationPathArray)).toBe("m/44'/501'/5'");
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe("updateDerivationPath", () => {
|
|
31
|
-
const basePath: DerivationPathArray = [44, 60, 0, 0, 0];
|
|
32
|
-
|
|
33
|
-
test("updates index (last element)", () => {
|
|
34
|
-
expect(updateDerivationPath(basePath, { index: 5 })).toEqual([44, 60, 0, 0, 5]);
|
|
35
|
-
expect(updateDerivationPath(basePath, { index: 100 })).toEqual([44, 60, 0, 0, 100]);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test("updates change (4th element)", () => {
|
|
39
|
-
expect(updateDerivationPath(basePath, { change: 1 })).toEqual([44, 60, 0, 1, 0]);
|
|
40
|
-
expect(updateDerivationPath([84, 0, 2, 0, 3], { change: 1 })).toEqual([84, 0, 2, 1, 3]);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test("updates account (3rd element)", () => {
|
|
44
|
-
expect(updateDerivationPath(basePath, { account: 5 })).toEqual([44, 60, 5, 0, 0]);
|
|
45
|
-
expect(updateDerivationPath([84, 0, 0, 1, 10], { account: 3 })).toEqual([84, 0, 3, 1, 10]);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test("returns unchanged path for empty params", () => {
|
|
49
|
-
expect(updateDerivationPath(basePath, {} as any)).toEqual(basePath);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
describe("getDerivationPathFor", () => {
|
|
54
|
-
describe("EVM chains", () => {
|
|
55
|
-
test("Ethereum default path", () => {
|
|
56
|
-
expect(getDerivationPathFor({ chain: Chain.Ethereum, index: 0 })).toEqual([44, 60, 0, 0, 0]);
|
|
57
|
-
expect(getDerivationPathFor({ chain: Chain.Ethereum, index: 5 })).toEqual([44, 60, 0, 0, 5]);
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("Ethereum legacy type", () => {
|
|
61
|
-
expect(getDerivationPathFor({ chain: Chain.Ethereum, index: 3, type: "legacy" })).toEqual([44, 60, 0, 3]);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test("Ethereum account type", () => {
|
|
65
|
-
expect(getDerivationPathFor({ chain: Chain.Ethereum, index: 2, type: "account" })).toEqual([44, 60, 0, 2]);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test("Ethereum ledgerLive type", () => {
|
|
69
|
-
expect(getDerivationPathFor({ chain: Chain.Ethereum, index: 0, type: "ledgerLive" })).toEqual([44, 60, 0, 0, 0]);
|
|
70
|
-
expect(getDerivationPathFor({ addressIndex: 1, chain: Chain.Ethereum, index: 2, type: "ledgerLive" })).toEqual([
|
|
71
|
-
44, 60, 2, 0, 1,
|
|
72
|
-
]);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test("other EVM chains use same derivation", () => {
|
|
76
|
-
expect(getDerivationPathFor({ chain: Chain.BinanceSmartChain, index: 0 })).toEqual([44, 60, 0, 0, 0]);
|
|
77
|
-
expect(getDerivationPathFor({ chain: Chain.Avalanche, index: 0 })).toEqual([44, 60, 0, 0, 0]);
|
|
78
|
-
expect(getDerivationPathFor({ chain: Chain.Arbitrum, index: 0 })).toEqual([44, 60, 0, 0, 0]);
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
describe("Solana", () => {
|
|
83
|
-
test("default path", () => {
|
|
84
|
-
const result = getDerivationPathFor({ chain: Chain.Solana, index: 0 });
|
|
85
|
-
expect(result[1]).toBe(501);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test("account type", () => {
|
|
89
|
-
expect(getDerivationPathFor({ chain: Chain.Solana, index: 3, type: "account" })).toEqual([44, 501, 0, 3]);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe("UTXO chains", () => {
|
|
94
|
-
test("Bitcoin nativeSegwitMiddleAccount", () => {
|
|
95
|
-
expect(getDerivationPathFor({ chain: Chain.Bitcoin, index: 0, type: "nativeSegwitMiddleAccount" })).toEqual([
|
|
96
|
-
84, 0, 0, 0, 0,
|
|
97
|
-
]);
|
|
98
|
-
expect(
|
|
99
|
-
getDerivationPathFor({ addressIndex: 5, chain: Chain.Bitcoin, index: 2, type: "nativeSegwitMiddleAccount" }),
|
|
100
|
-
).toEqual([84, 0, 2, 0, 5]);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test("Bitcoin segwit", () => {
|
|
104
|
-
expect(getDerivationPathFor({ chain: Chain.Bitcoin, index: 3, type: "segwit" })).toEqual([49, 0, 0, 0, 3]);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
test("Bitcoin legacy", () => {
|
|
108
|
-
expect(getDerivationPathFor({ chain: Chain.Bitcoin, index: 0, type: "legacy" })).toEqual([44, 0, 0, 0, 0]);
|
|
109
|
-
expect(getDerivationPathFor({ chain: Chain.Bitcoin, index: 5, type: "legacy" })).toEqual([44, 0, 0, 0, 5]);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
test("Litecoin uses chainId 2", () => {
|
|
113
|
-
expect(getDerivationPathFor({ chain: Chain.Litecoin, index: 0, type: "legacy" })).toEqual([44, 2, 0, 0, 0]);
|
|
114
|
-
expect(getDerivationPathFor({ chain: Chain.Litecoin, index: 0, type: "segwit" })).toEqual([49, 2, 0, 0, 0]);
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
describe("getWalletFormatFor", () => {
|
|
120
|
-
test("returns legacy for purpose 44", () => {
|
|
121
|
-
expect(getWalletFormatFor("m/44'/0'/0'/0/0")).toBe("legacy");
|
|
122
|
-
expect(getWalletFormatFor("m/44'/60'/0'/0/0")).toBe("legacy");
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test("returns p2sh for purpose 49", () => {
|
|
126
|
-
expect(getWalletFormatFor("m/49'/0'/0'/0/0")).toBe("p2sh");
|
|
127
|
-
expect(getWalletFormatFor("m/49'/2'/0'/0/0")).toBe("p2sh");
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
test("returns bech32 for purpose 84 and others", () => {
|
|
131
|
-
expect(getWalletFormatFor("m/84'/0'/0'/0/0")).toBe("bech32");
|
|
132
|
-
expect(getWalletFormatFor("m/86'/0'/0'/0/0")).toBe("bech32");
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
describe("DerivationPath export", () => {
|
|
137
|
-
test("exports string paths for common chains", () => {
|
|
138
|
-
expect(typeof DerivationPath[Chain.Ethereum]).toBe("string");
|
|
139
|
-
expect(typeof DerivationPath[Chain.Bitcoin]).toBe("string");
|
|
140
|
-
expect(DerivationPath[Chain.Ethereum]).toMatch(/^m\/\d+'\/\d+'\/\d+'/);
|
|
141
|
-
});
|
|
142
|
-
});
|