@swapkit/core 1.0.0-rc.110 → 1.0.0-rc.111
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 +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.js +589 -555
- package/dist/index.es.js.map +1 -1
- package/package.json +13 -13
- package/src/client/old.ts +38 -5
- package/src/helpers/mayanode.ts +31 -0
- package/src/helpers/thornode.ts +2 -2
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "swapkit-oss",
|
|
3
3
|
"dependencies": {
|
|
4
|
-
"@swapkit/helpers": "1.0.0-rc.
|
|
5
|
-
"@swapkit/types": "1.0.0-rc.
|
|
4
|
+
"@swapkit/helpers": "1.0.0-rc.75",
|
|
5
|
+
"@swapkit/types": "1.0.0-rc.41"
|
|
6
6
|
},
|
|
7
7
|
"description": "SwapKit Lib core",
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@vitest/coverage-istanbul": "1.3.1",
|
|
10
10
|
"vite": "5.1.3",
|
|
11
11
|
"vitest": "1.3.1",
|
|
12
|
-
"@swapkit/tokens": "1.0.0-rc.
|
|
13
|
-
"@swapkit/toolbox-cosmos": "1.0.0-rc.
|
|
14
|
-
"@swapkit/toolbox-evm": "1.0.0-rc.
|
|
15
|
-
"@swapkit/toolbox-substrate": "1.0.0-rc.
|
|
16
|
-
"@swapkit/toolbox-utxo": "1.0.0-rc.
|
|
12
|
+
"@swapkit/tokens": "1.0.0-rc.37",
|
|
13
|
+
"@swapkit/toolbox-cosmos": "1.0.0-rc.92",
|
|
14
|
+
"@swapkit/toolbox-evm": "1.0.0-rc.81",
|
|
15
|
+
"@swapkit/toolbox-substrate": "1.0.0-rc.10",
|
|
16
|
+
"@swapkit/toolbox-utxo": "1.0.0-rc.83"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
"@swapkit/tokens": "1.0.0-rc.
|
|
20
|
-
"@swapkit/toolbox-cosmos": "1.0.0-rc.
|
|
21
|
-
"@swapkit/toolbox-evm": "1.0.0-rc.
|
|
22
|
-
"@swapkit/toolbox-substrate": "1.0.0-rc.
|
|
23
|
-
"@swapkit/toolbox-utxo": "1.0.0-rc.
|
|
19
|
+
"@swapkit/tokens": "1.0.0-rc.37",
|
|
20
|
+
"@swapkit/toolbox-cosmos": "1.0.0-rc.92",
|
|
21
|
+
"@swapkit/toolbox-evm": "1.0.0-rc.81",
|
|
22
|
+
"@swapkit/toolbox-substrate": "1.0.0-rc.10",
|
|
23
|
+
"@swapkit/toolbox-utxo": "1.0.0-rc.83"
|
|
24
24
|
},
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"type": "module",
|
|
47
47
|
"types": "./dist/index.d.ts",
|
|
48
|
-
"version": "1.0.0-rc.
|
|
48
|
+
"version": "1.0.0-rc.111",
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "NODE_OPTIONS=--max_old_space_size=16384 vite build",
|
|
51
51
|
"clean": "rm -rf dist vite.config.ts.* node_modules",
|
package/src/client/old.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ErrorKeys,
|
|
3
|
+
MayanameRegisterParam,
|
|
4
|
+
QuoteRoute,
|
|
5
|
+
ThornameRegisterParam,
|
|
6
|
+
} from "@swapkit/helpers";
|
|
2
7
|
import {
|
|
3
8
|
AssetValue,
|
|
4
9
|
SwapKitError,
|
|
@@ -35,7 +40,8 @@ import { lowercasedContractAbiMapping } from "../aggregator/contracts/index.ts";
|
|
|
35
40
|
import { getSwapInParams } from "../aggregator/getSwapParams.ts";
|
|
36
41
|
|
|
37
42
|
import { getExplorerAddressUrl, getExplorerTxUrl } from "../helpers/explorerUrls.ts";
|
|
38
|
-
import {
|
|
43
|
+
import { getMayaMimirData } from "../helpers/mayanode.js";
|
|
44
|
+
import { getThorInboundData, getThorMimirData } from "../helpers/thornode.ts";
|
|
39
45
|
import type {
|
|
40
46
|
CoreTxParams,
|
|
41
47
|
EVMWallet,
|
|
@@ -347,7 +353,8 @@ export class SwapKitCore<T = ""> {
|
|
|
347
353
|
}
|
|
348
354
|
}
|
|
349
355
|
} catch (error: any) {
|
|
350
|
-
const errorMessage =
|
|
356
|
+
const errorMessage =
|
|
357
|
+
typeof error === "string" ? error.toLowerCase() : error?.message.toLowerCase();
|
|
351
358
|
const isInsufficientFunds = errorMessage?.includes("insufficient funds");
|
|
352
359
|
const isGas = errorMessage?.includes("gas");
|
|
353
360
|
const isServer = errorMessage?.includes("server");
|
|
@@ -613,6 +620,15 @@ export class SwapKitCore<T = ""> {
|
|
|
613
620
|
memo: getMemoFor(MemoType.THORNAME_REGISTER, param),
|
|
614
621
|
});
|
|
615
622
|
|
|
623
|
+
registerMayaname = ({
|
|
624
|
+
assetValue,
|
|
625
|
+
...param
|
|
626
|
+
}: MayanameRegisterParam & { assetValue: AssetValue }) =>
|
|
627
|
+
this.#mayachainTransfer({
|
|
628
|
+
assetValue,
|
|
629
|
+
memo: getMemoFor(MemoType.THORNAME_REGISTER, param),
|
|
630
|
+
});
|
|
631
|
+
|
|
616
632
|
extend = ({ wallets, config, apis = {}, rpcUrls = {} }: ExtendParams<T>) => {
|
|
617
633
|
try {
|
|
618
634
|
for (const wallet of wallets) {
|
|
@@ -725,7 +741,7 @@ export class SwapKitCore<T = ""> {
|
|
|
725
741
|
return { gas_rate: "0", router: "", address: "", halted: false, chain };
|
|
726
742
|
|
|
727
743
|
default: {
|
|
728
|
-
const inboundData = await
|
|
744
|
+
const inboundData = await getThorInboundData(this.stagenet);
|
|
729
745
|
const chainAddressData = inboundData.find((item) => item.chain === chain);
|
|
730
746
|
|
|
731
747
|
if (!chainAddressData) throw new SwapKitError("core_inbound_data_not_found");
|
|
@@ -818,7 +834,24 @@ export class SwapKitCore<T = ""> {
|
|
|
818
834
|
assetValue: AssetValue;
|
|
819
835
|
memo: string;
|
|
820
836
|
}) => {
|
|
821
|
-
const mimir = await
|
|
837
|
+
const mimir = await getThorMimirData(this.stagenet);
|
|
838
|
+
|
|
839
|
+
// check if trading is halted or not
|
|
840
|
+
if (mimir.HALTCHAINGLOBAL >= 1 || mimir.HALTTHORCHAIN >= 1) {
|
|
841
|
+
throw new SwapKitError("core_chain_halted");
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
return this.deposit({ assetValue, recipient: "", memo });
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
#mayachainTransfer = async ({
|
|
848
|
+
memo,
|
|
849
|
+
assetValue,
|
|
850
|
+
}: {
|
|
851
|
+
assetValue: AssetValue;
|
|
852
|
+
memo: string;
|
|
853
|
+
}) => {
|
|
854
|
+
const mimir = await getMayaMimirData(this.stagenet);
|
|
822
855
|
|
|
823
856
|
// check if trading is halted or not
|
|
824
857
|
if (mimir.HALTCHAINGLOBAL >= 1 || mimir.HALTTHORCHAIN >= 1) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { RequestClient } from "@swapkit/helpers";
|
|
2
|
+
import type { Chain } from "@swapkit/types";
|
|
3
|
+
import { ApiUrl } from "@swapkit/types";
|
|
4
|
+
|
|
5
|
+
type InboundAddressData = {
|
|
6
|
+
address: string;
|
|
7
|
+
chain: Chain;
|
|
8
|
+
chain_lp_actions_paused: boolean;
|
|
9
|
+
chain_trading_paused: boolean;
|
|
10
|
+
dust_threshold: string;
|
|
11
|
+
gas_rate: string;
|
|
12
|
+
gas_rate_units: string;
|
|
13
|
+
global_trading_paused: boolean;
|
|
14
|
+
halted: boolean;
|
|
15
|
+
outbound_fee: string;
|
|
16
|
+
outbound_tx_size: string;
|
|
17
|
+
pub_key: string;
|
|
18
|
+
router: string;
|
|
19
|
+
}[];
|
|
20
|
+
|
|
21
|
+
export const getMayaInboundData = (stagenet: boolean) => {
|
|
22
|
+
const baseUrl = stagenet ? ApiUrl.MayanodeStagenet : ApiUrl.MayanodeMainnet;
|
|
23
|
+
|
|
24
|
+
return RequestClient.get<InboundAddressData>(`${baseUrl}/mayachain/inbound_addresses`);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const getMayaMimirData = (stagenet: boolean) => {
|
|
28
|
+
const baseUrl = stagenet ? ApiUrl.MayanodeStagenet : ApiUrl.MayanodeMainnet;
|
|
29
|
+
|
|
30
|
+
return RequestClient.get<Record<string, number>>(`${baseUrl}/mayachain/mimir`);
|
|
31
|
+
};
|
package/src/helpers/thornode.ts
CHANGED
|
@@ -18,13 +18,13 @@ type InboundAddressData = {
|
|
|
18
18
|
router: string;
|
|
19
19
|
}[];
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const getThorInboundData = (stagenet: boolean) => {
|
|
22
22
|
const baseUrl = stagenet ? ApiUrl.ThornodeStagenet : ApiUrl.ThornodeMainnet;
|
|
23
23
|
|
|
24
24
|
return RequestClient.get<InboundAddressData>(`${baseUrl}/thorchain/inbound_addresses`);
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
export const
|
|
27
|
+
export const getThorMimirData = (stagenet: boolean) => {
|
|
28
28
|
const baseUrl = stagenet ? ApiUrl.ThornodeStagenet : ApiUrl.ThornodeMainnet;
|
|
29
29
|
|
|
30
30
|
return RequestClient.get<Record<string, number>>(`${baseUrl}/thorchain/mimir`);
|