@swapkit/toolboxes 1.0.0-beta.0 → 1.0.0-beta.1
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/chunk-0f0249b1.js +3 -0
- package/dist/chunk-0f0249b1.js.map +10 -0
- package/dist/chunk-0h4xdrwz.js +4 -0
- package/dist/chunk-0h4xdrwz.js.map +10 -0
- package/dist/chunk-4yap1fvd.js +3 -0
- package/dist/chunk-4yap1fvd.js.map +10 -0
- package/dist/chunk-fjfxga2v.js +3 -0
- package/dist/chunk-fjfxga2v.js.map +10 -0
- package/dist/{chunk-tvrdndbw.js → chunk-p1kdg37m.js} +2 -2
- package/dist/{chunk-tvrdndbw.js.map → chunk-p1kdg37m.js.map} +1 -1
- package/dist/cosmos/index.cjs +2 -2
- package/dist/cosmos/index.cjs.map +10 -13
- package/dist/cosmos/index.js +2 -2
- package/dist/cosmos/index.js.map +10 -13
- package/dist/evm/index.cjs +2 -2
- package/dist/evm/index.cjs.map +10 -16
- package/dist/evm/index.js +2 -2
- package/dist/evm/index.js.map +10 -16
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +4 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +4 -3
- package/dist/radix/index.cjs +2 -2
- package/dist/radix/index.cjs.map +3 -3
- package/dist/radix/index.js +2 -2
- package/dist/radix/index.js.map +3 -3
- package/dist/ripple/index.cjs +3 -0
- package/dist/ripple/index.cjs.map +10 -0
- package/dist/ripple/index.js +3 -0
- package/dist/ripple/index.js.map +10 -0
- package/dist/solana/index.cjs +2 -2
- package/dist/solana/index.cjs.map +3 -3
- package/dist/solana/index.js +2 -2
- package/dist/solana/index.js.map +3 -3
- package/dist/substrate/index.cjs +2 -2
- package/dist/substrate/index.cjs.map +5 -6
- package/dist/substrate/index.js +2 -2
- package/dist/substrate/index.js.map +5 -6
- package/dist/utxo/index.cjs +2 -2
- package/dist/utxo/index.cjs.map +9 -11
- package/dist/utxo/index.js +2 -2
- package/dist/utxo/index.js.map +9 -11
- package/package.json +30 -24
- package/src/cosmos/index.ts +2 -9
- package/src/cosmos/thorchainUtils/addressFormat.ts +1 -2
- package/src/cosmos/thorchainUtils/index.ts +1 -1
- package/src/cosmos/thorchainUtils/messages.ts +74 -56
- package/src/cosmos/thorchainUtils/registry.ts +16 -23
- package/src/cosmos/thorchainUtils/types/{proto/MsgCompiled.ts → MsgCompiled.ts} +1 -3
- package/src/cosmos/thorchainUtils/types/client-types.ts +16 -23
- package/src/cosmos/toolbox/cosmos.ts +334 -0
- package/src/cosmos/toolbox/index.ts +33 -0
- package/src/cosmos/toolbox/thorchain.ts +118 -131
- package/src/cosmos/types.ts +37 -18
- package/src/cosmos/util.ts +21 -71
- package/src/evm/__tests__/ethereum.test.ts +110 -116
- package/src/evm/api.ts +11 -147
- package/src/evm/helpers.ts +111 -83
- package/src/evm/index.ts +1 -17
- package/src/evm/toolbox/baseEVMToolbox.ts +742 -0
- package/src/evm/toolbox/evm.ts +69 -0
- package/src/evm/toolbox/index.ts +36 -0
- package/src/evm/toolbox/op.ts +97 -143
- package/src/evm/types.ts +50 -28
- package/src/index.ts +235 -0
- package/src/radix/index.ts +18 -19
- package/src/ripple/index.ts +203 -0
- package/src/solana/index.ts +11 -5
- package/src/solana/toolbox.ts +223 -133
- package/src/substrate/index.ts +2 -3
- package/src/substrate/{toolbox/baseSubstrateToolbox.ts → substrate.ts} +104 -72
- package/src/substrate/types.ts +120 -0
- package/src/utils.ts +27 -0
- package/src/utxo/helpers/api.ts +27 -23
- package/src/utxo/helpers/bchaddrjs.ts +21 -21
- package/src/utxo/helpers/index.ts +0 -1
- package/src/utxo/helpers/txSize.ts +3 -4
- package/src/utxo/index.ts +3 -7
- package/src/utxo/toolbox/bitcoinCash.ts +164 -154
- package/src/utxo/toolbox/index.ts +63 -24
- package/src/utxo/toolbox/utxo.ts +376 -229
- package/src/utxo/types.ts +24 -39
- package/src/cosmos/thorchainUtils/types/proto/MsgCompiled.js +0 -2806
- package/src/cosmos/thorchainUtils/util.ts +0 -46
- package/src/cosmos/toolbox/BaseCosmosToolbox.ts +0 -254
- package/src/cosmos/toolbox/gaia.ts +0 -39
- package/src/cosmos/toolbox/getToolboxByChain.ts +0 -29
- package/src/cosmos/toolbox/kujira.ts +0 -61
- package/src/evm/provider.ts +0 -6
- package/src/evm/toolbox/EVMToolbox.ts +0 -662
- package/src/evm/toolbox/arb.ts +0 -61
- package/src/evm/toolbox/avax.ts +0 -36
- package/src/evm/toolbox/base.ts +0 -42
- package/src/evm/toolbox/bsc.ts +0 -34
- package/src/evm/toolbox/eth.ts +0 -44
- package/src/evm/toolbox/getToolboxByChain.ts +0 -42
- package/src/evm/toolbox/matic.ts +0 -42
- package/src/radix/toolbox.ts +0 -693
- package/src/substrate/toolbox/index.ts +0 -40
- package/src/substrate/types/index.ts +0 -2
- package/src/substrate/types/network.ts +0 -42
- package/src/substrate/types/wallet.ts +0 -78
- package/src/utxo/helpers/utils.ts +0 -45
package/src/evm/toolbox/avax.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { BaseDecimal, Chain, ChainId, ChainToExplorerUrl, type FeeOption } from "@swapkit/helpers";
|
|
2
|
-
import type { BrowserProvider, JsonRpcProvider, Signer } from "ethers";
|
|
3
|
-
|
|
4
|
-
import { type EVMTxBaseParams, estimateTransactionFee, getBalance } from "../index";
|
|
5
|
-
|
|
6
|
-
import { EVMToolbox } from "./EVMToolbox";
|
|
7
|
-
|
|
8
|
-
const getNetworkParams = () => ({
|
|
9
|
-
chainId: ChainId.AvalancheHex,
|
|
10
|
-
chainName: "Avalanche Network",
|
|
11
|
-
nativeCurrency: { name: "Avalanche", symbol: Chain.Avalanche, decimals: BaseDecimal.AVAX },
|
|
12
|
-
// Use external rpc URL so wallets don't throw warning to user
|
|
13
|
-
rpcUrls: ["https://api.avax.network/ext/bc/C/rpc"],
|
|
14
|
-
blockExplorerUrls: [ChainToExplorerUrl[Chain.Avalanche]],
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export const AVAXToolbox = ({
|
|
18
|
-
provider,
|
|
19
|
-
signer,
|
|
20
|
-
}: { signer?: Signer; provider: JsonRpcProvider | BrowserProvider }) => {
|
|
21
|
-
const evmToolbox = EVMToolbox({ provider, signer });
|
|
22
|
-
const chain = Chain.Avalanche;
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
...evmToolbox,
|
|
26
|
-
getNetworkParams,
|
|
27
|
-
estimateTransactionFee: (txObject: EVMTxBaseParams, feeOptionKey: FeeOption) =>
|
|
28
|
-
estimateTransactionFee(txObject, feeOptionKey, chain, provider),
|
|
29
|
-
getBalance: (
|
|
30
|
-
address: string,
|
|
31
|
-
potentialScamFilter = true,
|
|
32
|
-
overwriteProvider?: JsonRpcProvider | BrowserProvider,
|
|
33
|
-
) =>
|
|
34
|
-
getBalance({ provider: overwriteProvider || provider, address, chain, potentialScamFilter }),
|
|
35
|
-
};
|
|
36
|
-
};
|
package/src/evm/toolbox/base.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseDecimal,
|
|
3
|
-
Chain,
|
|
4
|
-
ChainId,
|
|
5
|
-
ChainToExplorerUrl,
|
|
6
|
-
type FeeOption,
|
|
7
|
-
SKConfig,
|
|
8
|
-
} from "@swapkit/helpers";
|
|
9
|
-
import type { BrowserProvider, JsonRpcProvider, Signer } from "ethers";
|
|
10
|
-
|
|
11
|
-
import { type EVMTxBaseParams, estimateTransactionFee, getBalance } from "../index";
|
|
12
|
-
|
|
13
|
-
import { EVMToolbox } from "./EVMToolbox";
|
|
14
|
-
|
|
15
|
-
const getNetworkParams = () => ({
|
|
16
|
-
chainId: ChainId.BaseHex,
|
|
17
|
-
chainName: "Base Mainnet",
|
|
18
|
-
nativeCurrency: { name: "Ethereum", symbol: Chain.Ethereum, decimals: BaseDecimal.ETH },
|
|
19
|
-
rpcUrls: [SKConfig.get("rpcUrls")[Chain.Base]],
|
|
20
|
-
blockExplorerUrls: [ChainToExplorerUrl[Chain.Base]],
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export const BASEToolbox = ({
|
|
24
|
-
provider,
|
|
25
|
-
signer,
|
|
26
|
-
}: { signer?: Signer; provider: JsonRpcProvider | BrowserProvider }) => {
|
|
27
|
-
const evmToolbox = EVMToolbox({ provider, signer });
|
|
28
|
-
const chain = Chain.Base;
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
...evmToolbox,
|
|
32
|
-
getNetworkParams,
|
|
33
|
-
estimateTransactionFee: (txObject: EVMTxBaseParams, feeOptionKey: FeeOption) =>
|
|
34
|
-
estimateTransactionFee(txObject, feeOptionKey, chain, provider),
|
|
35
|
-
getBalance: async (
|
|
36
|
-
address: string,
|
|
37
|
-
potentialScamFilter = true,
|
|
38
|
-
overwriteProvider?: JsonRpcProvider | BrowserProvider,
|
|
39
|
-
) =>
|
|
40
|
-
getBalance({ provider: overwriteProvider || provider, address, chain, potentialScamFilter }),
|
|
41
|
-
};
|
|
42
|
-
};
|
package/src/evm/toolbox/bsc.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { BaseDecimal, Chain, ChainId, ChainToExplorerUrl, type FeeOption } from "@swapkit/helpers";
|
|
2
|
-
import type { BrowserProvider, JsonRpcProvider, Signer } from "ethers";
|
|
3
|
-
|
|
4
|
-
import { type EVMTxBaseParams, estimateTransactionFee, getBalance } from "../index";
|
|
5
|
-
import { EVMToolbox } from "./EVMToolbox";
|
|
6
|
-
|
|
7
|
-
const getNetworkParams = () => ({
|
|
8
|
-
chainId: ChainId.BinanceSmartChainHex,
|
|
9
|
-
chainName: "BNB Chain",
|
|
10
|
-
nativeCurrency: { name: "Binance Coin", symbol: "BNB", decimals: BaseDecimal.BSC },
|
|
11
|
-
rpcUrls: ["https://bsc-dataseed.binance.org"],
|
|
12
|
-
blockExplorerUrls: [ChainToExplorerUrl[Chain.BinanceSmartChain]],
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const BSCToolbox = ({
|
|
16
|
-
provider,
|
|
17
|
-
signer,
|
|
18
|
-
}: { signer?: Signer; provider: JsonRpcProvider | BrowserProvider }) => {
|
|
19
|
-
const evmToolbox = EVMToolbox({ provider, signer, isEIP1559Compatible: false });
|
|
20
|
-
const chain = Chain.BinanceSmartChain;
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
...evmToolbox,
|
|
24
|
-
getNetworkParams,
|
|
25
|
-
estimateTransactionFee: (txObject: EVMTxBaseParams, feeOptionKey: FeeOption) =>
|
|
26
|
-
estimateTransactionFee(txObject, feeOptionKey, chain, provider, false),
|
|
27
|
-
getBalance: (
|
|
28
|
-
address: string,
|
|
29
|
-
potentialScamFilter = true,
|
|
30
|
-
overwriteProvider?: JsonRpcProvider | BrowserProvider,
|
|
31
|
-
) =>
|
|
32
|
-
getBalance({ provider: overwriteProvider || provider, address, chain, potentialScamFilter }),
|
|
33
|
-
};
|
|
34
|
-
};
|
package/src/evm/toolbox/eth.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Chain, FeeOption } from "@swapkit/helpers";
|
|
2
|
-
import type { BrowserProvider, JsonRpcProvider, JsonRpcSigner, Signer } from "ethers";
|
|
3
|
-
|
|
4
|
-
import { type EVMTxBaseParams, estimateTransactionFee, getBalance } from "../index";
|
|
5
|
-
|
|
6
|
-
import { multicallAbi } from "../contracts/eth/multicall";
|
|
7
|
-
import { EVMToolbox } from "./EVMToolbox";
|
|
8
|
-
|
|
9
|
-
export const ETHToolbox = ({
|
|
10
|
-
signer,
|
|
11
|
-
provider,
|
|
12
|
-
}: { signer?: Signer | JsonRpcSigner; provider: JsonRpcProvider | BrowserProvider }) => {
|
|
13
|
-
const evmToolbox = EVMToolbox({ provider, signer });
|
|
14
|
-
const chain = Chain.Ethereum;
|
|
15
|
-
|
|
16
|
-
async function multicall(
|
|
17
|
-
callTuples: { address: string; data: string }[],
|
|
18
|
-
multicallAddress = "0x5ba1e12693dc8f9c48aad8770482f4739beed696",
|
|
19
|
-
funcName = "aggregate",
|
|
20
|
-
feeOptionKey: FeeOption = FeeOption.Fast,
|
|
21
|
-
) {
|
|
22
|
-
const txObject = await evmToolbox.createContractTxObject({
|
|
23
|
-
contractAddress: multicallAddress,
|
|
24
|
-
abi: multicallAbi,
|
|
25
|
-
funcName,
|
|
26
|
-
funcParams: [callTuples],
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return evmToolbox.sendTransaction(txObject, feeOptionKey);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
...evmToolbox,
|
|
34
|
-
multicall,
|
|
35
|
-
estimateTransactionFee: (txObject: EVMTxBaseParams, feeOptionKey?: FeeOption) =>
|
|
36
|
-
estimateTransactionFee(txObject, feeOptionKey, chain, provider),
|
|
37
|
-
getBalance: (
|
|
38
|
-
address: string,
|
|
39
|
-
potentialScamFilter = true,
|
|
40
|
-
overwriteProvider?: JsonRpcProvider | BrowserProvider,
|
|
41
|
-
) =>
|
|
42
|
-
getBalance({ provider: overwriteProvider || provider, address, chain, potentialScamFilter }),
|
|
43
|
-
};
|
|
44
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Chain } from "@swapkit/helpers";
|
|
2
|
-
|
|
3
|
-
import { ARBToolbox } from "./arb";
|
|
4
|
-
import { AVAXToolbox } from "./avax";
|
|
5
|
-
import { BASEToolbox } from "./base";
|
|
6
|
-
import { BSCToolbox } from "./bsc";
|
|
7
|
-
import { ETHToolbox } from "./eth";
|
|
8
|
-
import { MATICToolbox } from "./matic";
|
|
9
|
-
import { OPToolbox } from "./op";
|
|
10
|
-
|
|
11
|
-
type ToolboxType = {
|
|
12
|
-
ARB: typeof ARBToolbox;
|
|
13
|
-
AVAX: typeof AVAXToolbox;
|
|
14
|
-
BASE: typeof BASEToolbox;
|
|
15
|
-
BSC: typeof BSCToolbox;
|
|
16
|
-
ETH: typeof ETHToolbox;
|
|
17
|
-
MATIC: typeof MATICToolbox;
|
|
18
|
-
OP: typeof OPToolbox;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const getToolboxByChain = <T extends keyof ToolboxType>(chain: T): ToolboxType[T] => {
|
|
22
|
-
switch (chain) {
|
|
23
|
-
case Chain.Avalanche:
|
|
24
|
-
return AVAXToolbox as ToolboxType[T];
|
|
25
|
-
case Chain.Arbitrum:
|
|
26
|
-
return ARBToolbox as ToolboxType[T];
|
|
27
|
-
case Chain.Base:
|
|
28
|
-
return BASEToolbox as ToolboxType[T];
|
|
29
|
-
case Chain.Optimism:
|
|
30
|
-
return OPToolbox as ToolboxType[T];
|
|
31
|
-
case Chain.Polygon:
|
|
32
|
-
return MATICToolbox as ToolboxType[T];
|
|
33
|
-
case Chain.BinanceSmartChain:
|
|
34
|
-
return BSCToolbox as ToolboxType[T];
|
|
35
|
-
case Chain.Ethereum:
|
|
36
|
-
return ETHToolbox as ToolboxType[T];
|
|
37
|
-
default:
|
|
38
|
-
throw new Error(`Chain ${chain} is not supported`);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export { evmValidateAddress } from "./EVMToolbox";
|
package/src/evm/toolbox/matic.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BaseDecimal,
|
|
3
|
-
Chain,
|
|
4
|
-
ChainId,
|
|
5
|
-
ChainToExplorerUrl,
|
|
6
|
-
type FeeOption,
|
|
7
|
-
SKConfig,
|
|
8
|
-
} from "@swapkit/helpers";
|
|
9
|
-
import type { BrowserProvider, JsonRpcProvider, Signer } from "ethers";
|
|
10
|
-
|
|
11
|
-
import { type EVMTxBaseParams, estimateTransactionFee, getBalance } from "../index";
|
|
12
|
-
|
|
13
|
-
import { EVMToolbox } from "./EVMToolbox";
|
|
14
|
-
|
|
15
|
-
const getNetworkParams = () => ({
|
|
16
|
-
chainId: ChainId.PolygonHex,
|
|
17
|
-
chainName: "Polygon Mainnet",
|
|
18
|
-
nativeCurrency: { name: "Polygon", symbol: Chain.Polygon, decimals: BaseDecimal.MATIC },
|
|
19
|
-
rpcUrls: [SKConfig.get("rpcUrls")[Chain.Polygon]],
|
|
20
|
-
blockExplorerUrls: [ChainToExplorerUrl[Chain.Polygon]],
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export const MATICToolbox = ({
|
|
24
|
-
provider,
|
|
25
|
-
signer,
|
|
26
|
-
}: { signer?: Signer; provider: JsonRpcProvider | BrowserProvider }) => {
|
|
27
|
-
const evmToolbox = EVMToolbox({ provider, signer });
|
|
28
|
-
const chain = Chain.Polygon;
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
...evmToolbox,
|
|
32
|
-
getNetworkParams,
|
|
33
|
-
estimateTransactionFee: (txObject: EVMTxBaseParams, feeOptionKey: FeeOption) =>
|
|
34
|
-
estimateTransactionFee(txObject, feeOptionKey, chain, provider),
|
|
35
|
-
getBalance: (
|
|
36
|
-
address: string,
|
|
37
|
-
potentialScamFilter = true,
|
|
38
|
-
overwriteProvider?: JsonRpcProvider | BrowserProvider,
|
|
39
|
-
) =>
|
|
40
|
-
getBalance({ provider: overwriteProvider || provider, address, chain, potentialScamFilter }),
|
|
41
|
-
};
|
|
42
|
-
};
|