@swapkit/toolboxes 1.0.0-beta.0 → 1.0.0-beta.2
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
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { AssetValue, Chain } from "@swapkit/helpers";
|
|
2
|
-
|
|
3
|
-
import { ToolboxFactory, type ToolboxParams } from "./baseSubstrateToolbox";
|
|
4
|
-
|
|
5
|
-
export const PolkadotToolbox = ({ signer, generic = false }: ToolboxParams) => {
|
|
6
|
-
return ToolboxFactory({ chain: Chain.Polkadot, generic, signer });
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const ChainflipToolbox = async ({ signer, generic = false }: ToolboxParams) => {
|
|
10
|
-
const toolbox = await ToolboxFactory({ chain: Chain.Chainflip, generic, signer });
|
|
11
|
-
|
|
12
|
-
async function getBalance(address: string) {
|
|
13
|
-
// @ts-expect-error @Towan some parts of data missing?
|
|
14
|
-
// biome-ignore lint/correctness/noUnsafeOptionalChaining: @Towan some parts of data missing?
|
|
15
|
-
const { balance } = await toolbox.api.query.flip?.account?.(address);
|
|
16
|
-
|
|
17
|
-
return [AssetValue.from({ chain: Chain.Chainflip, value: BigInt(balance.toString()) })];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return { ...toolbox, getBalance };
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type ToolboxType = {
|
|
24
|
-
DOT: ReturnType<typeof PolkadotToolbox>;
|
|
25
|
-
FLIP: ReturnType<typeof ChainflipToolbox>;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const getToolboxByChain = <T extends keyof ToolboxType>(
|
|
29
|
-
chain: T,
|
|
30
|
-
params: ToolboxParams,
|
|
31
|
-
): ToolboxType[T] => {
|
|
32
|
-
switch (chain) {
|
|
33
|
-
case Chain.Chainflip:
|
|
34
|
-
return ChainflipToolbox(params);
|
|
35
|
-
case Chain.Polkadot:
|
|
36
|
-
return PolkadotToolbox(params);
|
|
37
|
-
default:
|
|
38
|
-
throw new Error(`Chain ${chain} is not supported`);
|
|
39
|
-
}
|
|
40
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { SubstrateChain } from "@swapkit/helpers";
|
|
2
|
-
|
|
3
|
-
export const polkadotNetwork = {
|
|
4
|
-
prefix: 0,
|
|
5
|
-
network: "polkadot",
|
|
6
|
-
displayName: "Polkadot Relay Chain",
|
|
7
|
-
symbols: ["DOT"],
|
|
8
|
-
decimals: [10],
|
|
9
|
-
standardAccount: "*25519",
|
|
10
|
-
website: "https://polkadot.network",
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const chainflipNetwork = {
|
|
14
|
-
prefix: 2112,
|
|
15
|
-
network: "chainflip",
|
|
16
|
-
displayName: "Chainflip",
|
|
17
|
-
symbols: ["FLIP"],
|
|
18
|
-
decimals: [18],
|
|
19
|
-
standardAccount: "*25519",
|
|
20
|
-
website: "https://chainflip.io/",
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const subtrateNetwork = {
|
|
24
|
-
prefix: 42,
|
|
25
|
-
network: "substrate",
|
|
26
|
-
displayName: "Substrate",
|
|
27
|
-
symbols: [],
|
|
28
|
-
decimals: [],
|
|
29
|
-
standardAccount: "*25519",
|
|
30
|
-
website: "https://substrate.io/",
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const Network: Record<SubstrateChain | "GENERIC", SubstrateNetwork> = {
|
|
34
|
-
DOT: polkadotNetwork,
|
|
35
|
-
FLIP: chainflipNetwork,
|
|
36
|
-
GENERIC: subtrateNetwork,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type SubstrateNetwork =
|
|
40
|
-
| typeof polkadotNetwork
|
|
41
|
-
| typeof chainflipNetwork
|
|
42
|
-
| typeof subtrateNetwork;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import type { Signer as InjectedSigner } from "@polkadot/api/types";
|
|
2
|
-
import type { ProviderInterface } from "@polkadot/rpc-provider/types";
|
|
3
|
-
import type { ExtDef } from "@polkadot/types/extrinsic/signedExtensions/types";
|
|
4
|
-
import type { KeypairType } from "@polkadot/util-crypto/types";
|
|
5
|
-
|
|
6
|
-
type This = typeof globalThis;
|
|
7
|
-
|
|
8
|
-
export type Unsubcall = () => void;
|
|
9
|
-
|
|
10
|
-
export interface InjectedAccount {
|
|
11
|
-
address: string;
|
|
12
|
-
genesisHash?: string | null;
|
|
13
|
-
name?: string;
|
|
14
|
-
type?: KeypairType;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface InjectedAccounts {
|
|
18
|
-
get: (anyType?: boolean) => Promise<InjectedAccount[]>;
|
|
19
|
-
subscribe: (cb: (accounts: InjectedAccount[]) => void | Promise<void>) => Unsubcall;
|
|
20
|
-
}
|
|
21
|
-
export interface InjectedExtensionInfo {
|
|
22
|
-
name: string;
|
|
23
|
-
version: string;
|
|
24
|
-
}
|
|
25
|
-
export interface ProviderMeta {
|
|
26
|
-
network: string;
|
|
27
|
-
node: "full" | "light";
|
|
28
|
-
source: string;
|
|
29
|
-
transport: string;
|
|
30
|
-
}
|
|
31
|
-
export interface MetadataDefBase {
|
|
32
|
-
chain: string;
|
|
33
|
-
genesisHash: string;
|
|
34
|
-
icon: string;
|
|
35
|
-
ss58Format: number;
|
|
36
|
-
chainType?: "substrate" | "ethereum";
|
|
37
|
-
}
|
|
38
|
-
export interface MetadataDef extends MetadataDefBase {
|
|
39
|
-
color?: string;
|
|
40
|
-
specVersion: number;
|
|
41
|
-
tokenDecimals: number;
|
|
42
|
-
tokenSymbol: string;
|
|
43
|
-
types: Record<string, Record<string, string> | string>;
|
|
44
|
-
metaCalls?: string;
|
|
45
|
-
userExtensions?: ExtDef;
|
|
46
|
-
}
|
|
47
|
-
export interface InjectedMetadataKnown {
|
|
48
|
-
genesisHash: string;
|
|
49
|
-
specVersion: number;
|
|
50
|
-
}
|
|
51
|
-
export interface InjectedMetadata {
|
|
52
|
-
get: () => Promise<InjectedMetadataKnown[]>;
|
|
53
|
-
provide: (definition: MetadataDef) => Promise<boolean>;
|
|
54
|
-
}
|
|
55
|
-
export type ProviderList = Record<string, ProviderMeta>;
|
|
56
|
-
export interface InjectedProvider extends ProviderInterface {
|
|
57
|
-
listProviders: () => Promise<ProviderList>;
|
|
58
|
-
startProvider: (key: string) => Promise<ProviderMeta>;
|
|
59
|
-
}
|
|
60
|
-
export interface InjectedProviderWithMeta {
|
|
61
|
-
provider: InjectedProvider;
|
|
62
|
-
meta: ProviderMeta;
|
|
63
|
-
}
|
|
64
|
-
export interface Injected {
|
|
65
|
-
accounts: InjectedAccounts;
|
|
66
|
-
metadata?: InjectedMetadata;
|
|
67
|
-
provider?: InjectedProvider;
|
|
68
|
-
signer: InjectedSigner;
|
|
69
|
-
}
|
|
70
|
-
export interface InjectedWindowProvider {
|
|
71
|
-
connect?: (origin: string) => Promise<InjectedExtension>;
|
|
72
|
-
enable?: (origin: string) => Promise<Injected>;
|
|
73
|
-
version?: string;
|
|
74
|
-
}
|
|
75
|
-
export interface InjectedWindow extends This {
|
|
76
|
-
injectedWeb3: Record<string, InjectedWindowProvider>;
|
|
77
|
-
}
|
|
78
|
-
export type InjectedExtension = InjectedExtensionInfo & Injected;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Chain, FeeOption } from "@swapkit/helpers";
|
|
2
|
-
import { networks } from "bitcoinjs-lib";
|
|
3
|
-
// @ts-ignore TODO: check why wallets doesn't see modules included in toolbox
|
|
4
|
-
import coininfo from "coininfo";
|
|
5
|
-
|
|
6
|
-
const pid = typeof process !== "undefined" && process.pid ? process.pid.toString(36) : "";
|
|
7
|
-
|
|
8
|
-
export const getNetwork = (chain: Chain) => {
|
|
9
|
-
switch (chain) {
|
|
10
|
-
case Chain.Bitcoin:
|
|
11
|
-
return networks.bitcoin;
|
|
12
|
-
case Chain.BitcoinCash:
|
|
13
|
-
return coininfo.bitcoincash.main.toBitcoinJS();
|
|
14
|
-
case Chain.Dash:
|
|
15
|
-
return coininfo.dash.main.toBitcoinJS();
|
|
16
|
-
case Chain.Litecoin:
|
|
17
|
-
return coininfo.litecoin.main.toBitcoinJS();
|
|
18
|
-
|
|
19
|
-
case Chain.Dogecoin: {
|
|
20
|
-
const bip32 = { private: 0x04358394, public: 0x043587cf };
|
|
21
|
-
const test = coininfo.dogecoin.test;
|
|
22
|
-
test.versions.bip32 = bip32;
|
|
23
|
-
return coininfo.dogecoin.main.toBitcoinJS();
|
|
24
|
-
}
|
|
25
|
-
default:
|
|
26
|
-
throw new Error("Invalid chain");
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const standardFeeRates = (rate: number) => ({
|
|
31
|
-
[FeeOption.Average]: rate,
|
|
32
|
-
[FeeOption.Fast]: rate * 1.5,
|
|
33
|
-
[FeeOption.Fastest]: rate * 2.0,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
let last = 0;
|
|
37
|
-
const now = () => {
|
|
38
|
-
const time = Date.now();
|
|
39
|
-
const lastTime = last || time;
|
|
40
|
-
last = lastTime;
|
|
41
|
-
|
|
42
|
-
return time > last ? time : lastTime + 1;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const uniqid = () => pid + now().toString(36);
|