@swapkit/toolboxes 4.0.0-beta.50 → 4.0.0-beta.52
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/src/cosmos/index.cjs +2 -2
- package/dist/src/cosmos/index.cjs.map +10 -6
- package/dist/src/cosmos/index.js +2 -2
- package/dist/src/cosmos/index.js.map +10 -6
- package/dist/src/evm/index.cjs +2 -2
- package/dist/src/evm/index.cjs.map +10 -8
- package/dist/src/evm/index.js +2 -2
- package/dist/src/evm/index.js.map +10 -8
- package/dist/src/index.cjs +4 -2
- package/dist/src/index.cjs.map +54 -4
- package/dist/src/index.js +4 -2
- package/dist/src/index.js.map +54 -4
- package/dist/src/near/index.cjs +2 -2
- package/dist/src/near/index.cjs.map +7 -5
- package/dist/src/near/index.js +2 -2
- package/dist/src/near/index.js.map +7 -5
- package/dist/src/radix/index.cjs +2 -2
- package/dist/src/radix/index.cjs.map +2 -2
- package/dist/src/radix/index.js +2 -2
- package/dist/src/radix/index.js.map +2 -2
- package/dist/src/ripple/index.cjs +2 -2
- package/dist/src/ripple/index.cjs.map +2 -2
- package/dist/src/ripple/index.js +2 -2
- package/dist/src/ripple/index.js.map +2 -2
- package/dist/src/solana/index.cjs +2 -2
- package/dist/src/solana/index.cjs.map +5 -4
- package/dist/src/solana/index.js +2 -2
- package/dist/src/solana/index.js.map +5 -4
- package/dist/src/substrate/index.cjs +2 -2
- package/dist/src/substrate/index.cjs.map +6 -5
- package/dist/src/substrate/index.js +2 -2
- package/dist/src/substrate/index.js.map +6 -5
- package/dist/src/tron/index.cjs +2 -2
- package/dist/src/tron/index.cjs.map +6 -5
- package/dist/src/tron/index.js +2 -2
- package/dist/src/tron/index.js.map +6 -5
- package/dist/src/utxo/index.cjs +4 -4
- package/dist/src/utxo/index.cjs.map +10 -7
- package/dist/src/utxo/index.js +4 -4
- package/dist/src/utxo/index.js.map +10 -7
- package/{src/cosmos/index.ts → dist/types/cosmos/index.d.ts} +1 -0
- package/dist/types/cosmos/index.d.ts.map +1 -0
- package/dist/types/cosmos/thorchainUtils/addressFormat.d.ts +5 -0
- package/dist/types/cosmos/thorchainUtils/addressFormat.d.ts.map +1 -0
- package/{src/cosmos/thorchainUtils/index.ts → dist/types/cosmos/thorchainUtils/index.d.ts} +1 -0
- package/dist/types/cosmos/thorchainUtils/index.d.ts.map +1 -0
- package/dist/types/cosmos/thorchainUtils/messages.d.ts +208 -0
- package/dist/types/cosmos/thorchainUtils/messages.d.ts.map +1 -0
- package/dist/types/cosmos/thorchainUtils/registry.d.ts +4 -0
- package/dist/types/cosmos/thorchainUtils/registry.d.ts.map +1 -0
- package/dist/types/cosmos/thorchainUtils/types/MsgCompiled.d.ts +2 -0
- package/dist/types/cosmos/thorchainUtils/types/MsgCompiled.d.ts.map +1 -0
- package/dist/types/cosmos/thorchainUtils/types/client-types.d.ts +66 -0
- package/dist/types/cosmos/thorchainUtils/types/client-types.d.ts.map +1 -0
- package/dist/types/cosmos/thorchainUtils/types/index.d.ts +2 -0
- package/dist/types/cosmos/thorchainUtils/types/index.d.ts.map +1 -0
- package/dist/types/cosmos/toolbox/cosmos.d.ts +93 -0
- package/dist/types/cosmos/toolbox/cosmos.d.ts.map +1 -0
- package/dist/types/cosmos/toolbox/index.d.ts +14 -0
- package/dist/types/cosmos/toolbox/index.d.ts.map +1 -0
- package/dist/types/cosmos/toolbox/thorchain.d.ts +158 -0
- package/dist/types/cosmos/toolbox/thorchain.d.ts.map +1 -0
- package/{src/cosmos/types.ts → dist/types/cosmos/types.d.ts} +24 -29
- package/dist/types/cosmos/types.d.ts.map +1 -0
- package/dist/types/cosmos/util.d.ts +68 -0
- package/dist/types/cosmos/util.d.ts.map +1 -0
- package/dist/types/evm/api.d.ts +8 -0
- package/dist/types/evm/api.d.ts.map +1 -0
- package/dist/types/evm/contracts/eth/multicall.d.ts +36 -0
- package/dist/types/evm/contracts/eth/multicall.d.ts.map +1 -0
- package/dist/types/evm/contracts/op/gasOracle.d.ts +40 -0
- package/dist/types/evm/contracts/op/gasOracle.d.ts.map +1 -0
- package/dist/types/evm/helpers.d.ts +20 -0
- package/dist/types/evm/helpers.d.ts.map +1 -0
- package/{src/evm/index.ts → dist/types/evm/index.d.ts} +1 -0
- package/dist/types/evm/index.d.ts.map +1 -0
- package/dist/types/evm/toolbox/baseEVMToolbox.d.ts +82 -0
- package/dist/types/evm/toolbox/baseEVMToolbox.d.ts.map +1 -0
- package/dist/types/evm/toolbox/evm.d.ts +367 -0
- package/dist/types/evm/toolbox/evm.d.ts.map +1 -0
- package/dist/types/evm/toolbox/index.d.ts +89 -0
- package/dist/types/evm/toolbox/index.d.ts.map +1 -0
- package/dist/types/evm/toolbox/op.d.ts +62 -0
- package/dist/types/evm/toolbox/op.d.ts.map +1 -0
- package/dist/types/evm/types.d.ts +98 -0
- package/dist/types/evm/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +63 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/near/helpers/core.d.ts +15 -0
- package/dist/types/near/helpers/core.d.ts.map +1 -0
- package/dist/types/near/helpers/gasEstimation.d.ts +41 -0
- package/dist/types/near/helpers/gasEstimation.d.ts.map +1 -0
- package/dist/types/near/helpers/nep141.d.ts +72 -0
- package/dist/types/near/helpers/nep141.d.ts.map +1 -0
- package/dist/types/near/index.d.ts +10 -0
- package/dist/types/near/index.d.ts.map +1 -0
- package/dist/types/near/toolbox.d.ts +4 -0
- package/dist/types/near/toolbox.d.ts.map +1 -0
- package/dist/types/near/types/contract.d.ts +38 -0
- package/dist/types/near/types/contract.d.ts.map +1 -0
- package/dist/types/near/types/nep141.d.ts +56 -0
- package/dist/types/near/types/nep141.d.ts.map +1 -0
- package/dist/types/near/types/toolbox.d.ts +57 -0
- package/dist/types/near/types/toolbox.d.ts.map +1 -0
- package/dist/types/near/types.d.ts +44 -0
- package/dist/types/near/types.d.ts.map +1 -0
- package/dist/types/radix/index.d.ts +14 -0
- package/dist/types/radix/index.d.ts.map +1 -0
- package/dist/types/ripple/index.d.ts +43 -0
- package/dist/types/ripple/index.d.ts.map +1 -0
- package/dist/types/solana/index.d.ts +37 -0
- package/dist/types/solana/index.d.ts.map +1 -0
- package/dist/types/solana/toolbox.d.ts +41 -0
- package/dist/types/solana/toolbox.d.ts.map +1 -0
- package/dist/types/substrate/balance.d.ts +17 -0
- package/dist/types/substrate/balance.d.ts.map +1 -0
- package/{src/substrate/index.ts → dist/types/substrate/index.d.ts} +1 -0
- package/dist/types/substrate/index.d.ts.map +1 -0
- package/dist/types/substrate/substrate.d.ts +148 -0
- package/dist/types/substrate/substrate.d.ts.map +1 -0
- package/dist/types/substrate/types.d.ts +100 -0
- package/dist/types/substrate/types.d.ts.map +1 -0
- package/dist/types/tron/helpers/trc20.abi.d.ts +156 -0
- package/dist/types/tron/helpers/trc20.abi.d.ts.map +1 -0
- package/dist/types/tron/helpers/trongrid.d.ts +8 -0
- package/dist/types/tron/helpers/trongrid.d.ts.map +1 -0
- package/dist/types/tron/index.d.ts +6 -0
- package/dist/types/tron/index.d.ts.map +1 -0
- package/dist/types/tron/toolbox.d.ts +26 -0
- package/dist/types/tron/toolbox.d.ts.map +1 -0
- package/dist/types/tron/types.d.ts +101 -0
- package/dist/types/tron/types.d.ts.map +1 -0
- package/dist/types/types.d.ts +18 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/utils.d.ts +4 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/utxo/helpers/api.d.ts +133 -0
- package/dist/types/utxo/helpers/api.d.ts.map +1 -0
- package/dist/types/utxo/helpers/bchaddrjs.d.ts +10 -0
- package/dist/types/utxo/helpers/bchaddrjs.d.ts.map +1 -0
- package/dist/types/utxo/helpers/coinselect.d.ts +16 -0
- package/dist/types/utxo/helpers/coinselect.d.ts.map +1 -0
- package/{src/utxo/helpers/index.ts → dist/types/utxo/helpers/index.d.ts} +1 -0
- package/dist/types/utxo/helpers/index.d.ts.map +1 -0
- package/dist/types/utxo/helpers/txSize.d.ts +21 -0
- package/dist/types/utxo/helpers/txSize.d.ts.map +1 -0
- package/{src/utxo/index.ts → dist/types/utxo/index.d.ts} +1 -0
- package/dist/types/utxo/index.d.ts.map +1 -0
- package/dist/types/utxo/toolbox/bitcoinCash.d.ts +104 -0
- package/dist/types/utxo/toolbox/bitcoinCash.d.ts.map +1 -0
- package/dist/types/utxo/toolbox/index.d.ts +50 -0
- package/dist/types/utxo/toolbox/index.d.ts.map +1 -0
- package/dist/types/utxo/toolbox/utxo.d.ts +102 -0
- package/dist/types/utxo/toolbox/utxo.d.ts.map +1 -0
- package/dist/types/utxo/toolbox/zcash.d.ts +83 -0
- package/dist/types/utxo/toolbox/zcash.d.ts.map +1 -0
- package/dist/types/utxo/types.d.ts +46 -0
- package/dist/types/utxo/types.d.ts.map +1 -0
- package/package.json +15 -18
- package/dist/chunk-0h4xdrwz.js +0 -5
- package/dist/chunk-0h4xdrwz.js.map +0 -10
- package/dist/chunk-4yap1fvd.js +0 -4
- package/dist/chunk-4yap1fvd.js.map +0 -10
- package/dist/chunk-9bqegm61.js +0 -4
- package/dist/chunk-9bqegm61.js.map +0 -10
- package/dist/chunk-fazw0jvt.js +0 -4
- package/dist/chunk-fazw0jvt.js.map +0 -9
- package/dist/chunk-fjfxga2v.js +0 -4
- package/dist/chunk-fjfxga2v.js.map +0 -10
- package/dist/chunk-s47y8512.js +0 -5
- package/dist/chunk-s47y8512.js.map +0 -9
- package/dist/chunk-vtd17cje.js +0 -4
- package/dist/chunk-vtd17cje.js.map +0 -10
- package/dist/chunk-zcdeg6h9.js +0 -5
- package/dist/chunk-zcdeg6h9.js.map +0 -10
- package/src/cosmos/thorchainUtils/addressFormat.ts +0 -26
- package/src/cosmos/thorchainUtils/messages.ts +0 -262
- package/src/cosmos/thorchainUtils/registry.ts +0 -44
- package/src/cosmos/thorchainUtils/types/MsgCompiled.ts +0 -2800
- package/src/cosmos/thorchainUtils/types/client-types.ts +0 -73
- package/src/cosmos/thorchainUtils/types/index.ts +0 -1
- package/src/cosmos/toolbox/cosmos.ts +0 -375
- package/src/cosmos/toolbox/index.ts +0 -33
- package/src/cosmos/toolbox/thorchain.ts +0 -313
- package/src/cosmos/util.ts +0 -266
- package/src/evm/__tests__/address-validation.test.ts +0 -86
- package/src/evm/__tests__/ethereum.test.ts +0 -141
- package/src/evm/api.ts +0 -21
- package/src/evm/contracts/eth/multicall.ts +0 -165
- package/src/evm/contracts/op/gasOracle.ts +0 -151
- package/src/evm/helpers.ts +0 -194
- package/src/evm/toolbox/baseEVMToolbox.ts +0 -762
- package/src/evm/toolbox/evm.ts +0 -66
- package/src/evm/toolbox/index.ts +0 -52
- package/src/evm/toolbox/op.ts +0 -131
- package/src/evm/types.ts +0 -146
- package/src/index.ts +0 -263
- package/src/near/__tests__/core.test.ts +0 -80
- package/src/near/helpers/contractFactory.ts +0 -22
- package/src/near/helpers/core.ts +0 -91
- package/src/near/helpers/gasEstimation.ts +0 -110
- package/src/near/helpers/index.ts +0 -5
- package/src/near/helpers/nep141.ts +0 -110
- package/src/near/index.ts +0 -24
- package/src/near/toolbox.ts +0 -509
- package/src/near/types/contract.ts +0 -48
- package/src/near/types/nep141.ts +0 -66
- package/src/near/types.ts +0 -57
- package/src/radix/index.ts +0 -156
- package/src/ripple/index.ts +0 -192
- package/src/solana/index.ts +0 -55
- package/src/solana/toolbox.ts +0 -433
- package/src/substrate/balance.ts +0 -92
- package/src/substrate/substrate.ts +0 -320
- package/src/substrate/types.ts +0 -120
- package/src/tron/__tests__/toolbox.test.ts +0 -147
- package/src/tron/helpers/trc20.abi.ts +0 -107
- package/src/tron/helpers/trongrid.ts +0 -54
- package/src/tron/index.ts +0 -17
- package/src/tron/toolbox.ts +0 -650
- package/src/tron/types.ts +0 -120
- package/src/utils.ts +0 -27
- package/src/utxo/__tests__/zcash-integration.test.ts +0 -114
- package/src/utxo/helpers/api.ts +0 -560
- package/src/utxo/helpers/bchaddrjs.ts +0 -183
- package/src/utxo/helpers/coinselect.ts +0 -98
- package/src/utxo/helpers/txSize.ts +0 -104
- package/src/utxo/toolbox/bitcoinCash.ts +0 -320
- package/src/utxo/toolbox/index.ts +0 -90
- package/src/utxo/toolbox/utxo.ts +0 -525
- package/src/utxo/toolbox/zcash.ts +0 -208
- package/src/utxo/types.ts +0 -57
|
@@ -1,320 +0,0 @@
|
|
|
1
|
-
import type { ApiPromise } from "@polkadot/api";
|
|
2
|
-
import type { SubmittableExtrinsic } from "@polkadot/api/types";
|
|
3
|
-
import type { KeyringPair } from "@polkadot/keyring/types";
|
|
4
|
-
import type { Callback, IKeyringPair, ISubmittableResult, Signer } from "@polkadot/types/types";
|
|
5
|
-
import { hexToU8a, isHex, u8aToHex } from "@polkadot/util";
|
|
6
|
-
import {
|
|
7
|
-
decodeAddress as decodePolkadotAddress,
|
|
8
|
-
encodeAddress as encodePolkadotAddress,
|
|
9
|
-
} from "@polkadot/util-crypto";
|
|
10
|
-
import {
|
|
11
|
-
AssetValue,
|
|
12
|
-
Chain,
|
|
13
|
-
type DerivationPathArray,
|
|
14
|
-
type GenericCreateTransactionParams,
|
|
15
|
-
SKConfig,
|
|
16
|
-
type SubstrateChain,
|
|
17
|
-
SwapKitError,
|
|
18
|
-
SwapKitNumber,
|
|
19
|
-
} from "@swapkit/helpers";
|
|
20
|
-
|
|
21
|
-
import { P, match } from "ts-pattern";
|
|
22
|
-
import { createBalanceGetter } from "./balance";
|
|
23
|
-
import { SubstrateNetwork, type SubstrateTransferParams } from "./types";
|
|
24
|
-
|
|
25
|
-
export const PolkadotToolbox = ({ generic = false, ...signerParams }: ToolboxParams = {}) => {
|
|
26
|
-
return createSubstrateToolbox({ chain: Chain.Polkadot, generic, ...signerParams });
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const ChainflipToolbox = async ({
|
|
30
|
-
generic = false,
|
|
31
|
-
...signerParams
|
|
32
|
-
}: ToolboxParams = {}) => {
|
|
33
|
-
const toolbox = await createSubstrateToolbox({
|
|
34
|
-
chain: Chain.Chainflip,
|
|
35
|
-
generic,
|
|
36
|
-
...signerParams,
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
return { ...toolbox };
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export type SubstrateToolboxes = {
|
|
43
|
-
DOT: Awaited<ReturnType<typeof PolkadotToolbox>>;
|
|
44
|
-
FLIP: Awaited<ReturnType<typeof ChainflipToolbox>>;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export function getSubstrateToolbox<T extends SubstrateChain>(chain: T, params?: ToolboxParams) {
|
|
48
|
-
switch (chain) {
|
|
49
|
-
case Chain.Chainflip: {
|
|
50
|
-
return ChainflipToolbox(params);
|
|
51
|
-
}
|
|
52
|
-
case Chain.Polkadot: {
|
|
53
|
-
return PolkadotToolbox(params);
|
|
54
|
-
}
|
|
55
|
-
default:
|
|
56
|
-
throw new SwapKitError("toolbox_substrate_not_supported", { chain });
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function isKeyringPair(account: IKeyringPair | Signer): account is IKeyringPair {
|
|
61
|
-
return "address" in account;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export async function createKeyring(phrase: string, networkPrefix: number) {
|
|
65
|
-
const { Keyring } = await import("@polkadot/api");
|
|
66
|
-
const { cryptoWaitReady } = await import("@polkadot/util-crypto");
|
|
67
|
-
await cryptoWaitReady();
|
|
68
|
-
|
|
69
|
-
return new Keyring({ type: "sr25519", ss58Format: networkPrefix }).addFromUri(phrase);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const getNonce = (api: ApiPromise, address: string) => api.rpc.system.accountNextIndex(address);
|
|
73
|
-
|
|
74
|
-
const validateAddress = (address: string, networkPrefix: number) => {
|
|
75
|
-
try {
|
|
76
|
-
const decodedAddress = decodeAddress(address, networkPrefix);
|
|
77
|
-
|
|
78
|
-
encodeAddress(decodedAddress, "ss58", networkPrefix);
|
|
79
|
-
|
|
80
|
-
return true;
|
|
81
|
-
} catch (_error) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const createTransaction = (api: ApiPromise, { recipient, assetValue }: SubstrateTransferParams) =>
|
|
87
|
-
api.tx.balances?.transferAllowDeath?.(recipient, assetValue.getBaseValue("number"));
|
|
88
|
-
|
|
89
|
-
const transfer = async (
|
|
90
|
-
api: ApiPromise,
|
|
91
|
-
signer: IKeyringPair | Signer,
|
|
92
|
-
{ recipient, assetValue, sender }: SubstrateTransferParams,
|
|
93
|
-
) => {
|
|
94
|
-
const transfer = createTransaction(api, {
|
|
95
|
-
recipient,
|
|
96
|
-
assetValue,
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
const isKeyring = isKeyringPair(signer);
|
|
100
|
-
|
|
101
|
-
if (!transfer) return;
|
|
102
|
-
|
|
103
|
-
const address = isKeyring ? (signer as IKeyringPair).address : sender;
|
|
104
|
-
if (!address) throw new SwapKitError("core_transaction_invalid_sender_address");
|
|
105
|
-
|
|
106
|
-
const nonce = await getNonce(api, address);
|
|
107
|
-
|
|
108
|
-
const tx = await transfer.signAndSend(isKeyring ? signer : address, {
|
|
109
|
-
signer: isKeyring ? undefined : signer,
|
|
110
|
-
nonce,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
return tx?.toString();
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const estimateTransactionFee = async (
|
|
117
|
-
api: ApiPromise,
|
|
118
|
-
signer: IKeyringPair | Signer,
|
|
119
|
-
gasAsset: AssetValue,
|
|
120
|
-
{ recipient, assetValue, sender }: SubstrateTransferParams,
|
|
121
|
-
) => {
|
|
122
|
-
const transfer = createTransaction(api, { recipient, assetValue });
|
|
123
|
-
|
|
124
|
-
const address = isKeyringPair(signer) ? signer.address : sender;
|
|
125
|
-
if (!address) return;
|
|
126
|
-
|
|
127
|
-
const paymentInfo = (await transfer?.paymentInfo(address, {
|
|
128
|
-
nonce: await getNonce(api, address),
|
|
129
|
-
})) || { partialFee: 0 };
|
|
130
|
-
return gasAsset.set(
|
|
131
|
-
SwapKitNumber.fromBigInt(BigInt(paymentInfo.partialFee.toString()), gasAsset.decimal).getValue(
|
|
132
|
-
"string",
|
|
133
|
-
),
|
|
134
|
-
);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
const broadcast = async (
|
|
138
|
-
tx: SubmittableExtrinsic<"promise">,
|
|
139
|
-
callback?: Callback<ISubmittableResult>,
|
|
140
|
-
) => {
|
|
141
|
-
if (callback) return tx.send(callback);
|
|
142
|
-
const hash = await tx.send();
|
|
143
|
-
return hash.toString();
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const sign = async (signer: IKeyringPair, tx: SubmittableExtrinsic<"promise">) => {
|
|
147
|
-
const signedTx = await tx.signAsync(signer);
|
|
148
|
-
return signedTx;
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const signAndBroadcastKeyring = (
|
|
152
|
-
signer: IKeyringPair,
|
|
153
|
-
tx: SubmittableExtrinsic<"promise">,
|
|
154
|
-
callback?: Callback<ISubmittableResult>,
|
|
155
|
-
) => {
|
|
156
|
-
if (callback) return tx.signAndSend(signer, callback);
|
|
157
|
-
const hash = tx.signAndSend(signer);
|
|
158
|
-
return hash.toString();
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
const signAndBroadcast = async ({
|
|
162
|
-
signer,
|
|
163
|
-
address,
|
|
164
|
-
tx,
|
|
165
|
-
callback,
|
|
166
|
-
api,
|
|
167
|
-
}: {
|
|
168
|
-
signer: Signer;
|
|
169
|
-
address: string;
|
|
170
|
-
tx: SubmittableExtrinsic<"promise">;
|
|
171
|
-
api: ApiPromise;
|
|
172
|
-
callback?: Callback<ISubmittableResult>;
|
|
173
|
-
}) => {
|
|
174
|
-
const nonce = await getNonce(api, address);
|
|
175
|
-
if (callback) {
|
|
176
|
-
tx.signAndSend(address, { nonce, signer }, callback);
|
|
177
|
-
}
|
|
178
|
-
const hash = tx.signAndSend(address, { nonce, signer });
|
|
179
|
-
return hash.toString();
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
function convertAddress(address: string, newPrefix: number) {
|
|
183
|
-
const decodedAddress = decodePolkadotAddress(address);
|
|
184
|
-
const convertedAddress = encodePolkadotAddress(decodedAddress, newPrefix);
|
|
185
|
-
return convertedAddress;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function decodeAddress(address: string, networkPrefix?: number) {
|
|
189
|
-
return isHex(address)
|
|
190
|
-
? hexToU8a(address)
|
|
191
|
-
: decodePolkadotAddress(address, undefined, networkPrefix);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function encodeAddress(
|
|
195
|
-
address: Uint8Array,
|
|
196
|
-
encoding: "ss58" | "hex" = "ss58",
|
|
197
|
-
networkPrefix?: number,
|
|
198
|
-
) {
|
|
199
|
-
if (encoding === "hex") {
|
|
200
|
-
return u8aToHex(address);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return encodePolkadotAddress(address, networkPrefix);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export const BaseSubstrateToolbox = ({
|
|
207
|
-
api,
|
|
208
|
-
network,
|
|
209
|
-
gasAsset,
|
|
210
|
-
signer,
|
|
211
|
-
chain,
|
|
212
|
-
}: {
|
|
213
|
-
api: ApiPromise;
|
|
214
|
-
network: SubstrateNetwork;
|
|
215
|
-
gasAsset: AssetValue;
|
|
216
|
-
signer?: IKeyringPair | Signer;
|
|
217
|
-
chain?: SubstrateChain;
|
|
218
|
-
}) => ({
|
|
219
|
-
api,
|
|
220
|
-
network,
|
|
221
|
-
gasAsset,
|
|
222
|
-
decodeAddress,
|
|
223
|
-
encodeAddress,
|
|
224
|
-
convertAddress,
|
|
225
|
-
getBalance: createBalanceGetter(chain || Chain.Polkadot, api),
|
|
226
|
-
createKeyring: (phrase: string) => createKeyring(phrase, network.prefix),
|
|
227
|
-
getAddress: (keyring?: IKeyringPair | Signer) => {
|
|
228
|
-
const keyringPair = keyring || signer;
|
|
229
|
-
if (!keyringPair) throw new SwapKitError("core_wallet_not_keypair_wallet");
|
|
230
|
-
|
|
231
|
-
return isKeyringPair(keyringPair) ? keyringPair.address : undefined;
|
|
232
|
-
},
|
|
233
|
-
createTransaction: (params: GenericCreateTransactionParams) => createTransaction(api, params),
|
|
234
|
-
validateAddress: (address: string) => validateAddress(address, network.prefix),
|
|
235
|
-
transfer: (params: SubstrateTransferParams) => {
|
|
236
|
-
if (!signer) throw new SwapKitError("core_wallet_not_keypair_wallet");
|
|
237
|
-
return transfer(api, signer, params);
|
|
238
|
-
},
|
|
239
|
-
estimateTransactionFee: (params: SubstrateTransferParams) => {
|
|
240
|
-
if (!signer) throw new SwapKitError("core_wallet_not_keypair_wallet");
|
|
241
|
-
return estimateTransactionFee(api, signer, gasAsset, params);
|
|
242
|
-
},
|
|
243
|
-
sign: (tx: SubmittableExtrinsic<"promise">) => {
|
|
244
|
-
if (!signer) throw new SwapKitError("core_wallet_not_keypair_wallet");
|
|
245
|
-
if (isKeyringPair(signer)) return sign(signer, tx);
|
|
246
|
-
|
|
247
|
-
throw new SwapKitError(
|
|
248
|
-
"core_wallet_not_keypair_wallet",
|
|
249
|
-
"Signer does not have keyring pair capabilities required for signing.",
|
|
250
|
-
);
|
|
251
|
-
},
|
|
252
|
-
broadcast,
|
|
253
|
-
signAndBroadcast: ({
|
|
254
|
-
tx,
|
|
255
|
-
callback,
|
|
256
|
-
address,
|
|
257
|
-
}: {
|
|
258
|
-
tx: SubmittableExtrinsic<"promise">;
|
|
259
|
-
callback?: Callback<ISubmittableResult>;
|
|
260
|
-
address?: string;
|
|
261
|
-
}) => {
|
|
262
|
-
if (!signer) throw new SwapKitError("core_wallet_not_keypair_wallet");
|
|
263
|
-
if (isKeyringPair(signer)) return signAndBroadcastKeyring(signer, tx, callback);
|
|
264
|
-
|
|
265
|
-
if (address) {
|
|
266
|
-
return signAndBroadcast({ signer, address, tx, callback, api });
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
throw new SwapKitError(
|
|
270
|
-
"core_wallet_not_keypair_wallet",
|
|
271
|
-
"Signer does not have keyring pair capabilities required for signing.",
|
|
272
|
-
);
|
|
273
|
-
},
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
export const substrateValidateAddress = ({
|
|
277
|
-
address,
|
|
278
|
-
chain,
|
|
279
|
-
}: { address: string; chain: Chain.Polkadot | Chain.Chainflip }) => {
|
|
280
|
-
const { prefix } = chain === Chain.Polkadot ? SubstrateNetwork.DOT : SubstrateNetwork.FLIP;
|
|
281
|
-
|
|
282
|
-
return (
|
|
283
|
-
validateAddress(address, prefix) || validateAddress(address, SubstrateNetwork.GENERIC.prefix)
|
|
284
|
-
);
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
export async function createSubstrateToolbox({
|
|
288
|
-
generic,
|
|
289
|
-
chain,
|
|
290
|
-
...signerParams
|
|
291
|
-
}: ToolboxParams & { chain: SubstrateChain }) {
|
|
292
|
-
const { ApiPromise, WsProvider } = await import("@polkadot/api");
|
|
293
|
-
|
|
294
|
-
const provider = new WsProvider(SKConfig.get("rpcUrls")[chain]);
|
|
295
|
-
const api = await ApiPromise.create({ provider });
|
|
296
|
-
const gasAsset = AssetValue.from({ chain });
|
|
297
|
-
const network = generic ? SubstrateNetwork.GENERIC : SubstrateNetwork[chain];
|
|
298
|
-
|
|
299
|
-
const signer = await match(signerParams)
|
|
300
|
-
.with({ phrase: P.string }, ({ phrase }) =>
|
|
301
|
-
createKeyring(phrase, SubstrateNetwork[chain].prefix),
|
|
302
|
-
)
|
|
303
|
-
.with({ signer: P.any }, ({ signer }) => signer)
|
|
304
|
-
.otherwise(() => undefined);
|
|
305
|
-
|
|
306
|
-
return BaseSubstrateToolbox({ api, signer, gasAsset, network, chain });
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
export type ToolboxParams = {
|
|
310
|
-
generic?: boolean;
|
|
311
|
-
} & (
|
|
312
|
-
| {
|
|
313
|
-
signer?: KeyringPair | Signer;
|
|
314
|
-
}
|
|
315
|
-
| {
|
|
316
|
-
phrase?: string;
|
|
317
|
-
derivationPath?: DerivationPathArray;
|
|
318
|
-
index?: number;
|
|
319
|
-
}
|
|
320
|
-
);
|
package/src/substrate/types.ts
DELETED
|
@@ -1,120 +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
|
-
import type { GenericTransferParams, SubstrateChain } from "@swapkit/helpers";
|
|
6
|
-
|
|
7
|
-
const polkadotNetwork = {
|
|
8
|
-
prefix: 0,
|
|
9
|
-
network: "polkadot",
|
|
10
|
-
displayName: "Polkadot Relay Chain",
|
|
11
|
-
symbols: ["DOT"],
|
|
12
|
-
decimals: [10],
|
|
13
|
-
standardAccount: "*25519",
|
|
14
|
-
website: "https://polkadot.network",
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const chainflipNetwork = {
|
|
18
|
-
prefix: 2112,
|
|
19
|
-
network: "chainflip",
|
|
20
|
-
displayName: "Chainflip",
|
|
21
|
-
symbols: ["FLIP"],
|
|
22
|
-
decimals: [18],
|
|
23
|
-
standardAccount: "*25519",
|
|
24
|
-
website: "https://chainflip.io/",
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const subtrateNetwork = {
|
|
28
|
-
prefix: 42,
|
|
29
|
-
network: "substrate",
|
|
30
|
-
displayName: "Substrate",
|
|
31
|
-
symbols: [],
|
|
32
|
-
decimals: [],
|
|
33
|
-
standardAccount: "*25519",
|
|
34
|
-
website: "https://substrate.io/",
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const SubstrateNetwork: Record<SubstrateChain | "GENERIC", SubstrateNetwork> = {
|
|
38
|
-
DOT: polkadotNetwork,
|
|
39
|
-
FLIP: chainflipNetwork,
|
|
40
|
-
GENERIC: subtrateNetwork,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export type SubstrateNetwork =
|
|
44
|
-
| typeof polkadotNetwork
|
|
45
|
-
| typeof chainflipNetwork
|
|
46
|
-
| typeof subtrateNetwork;
|
|
47
|
-
|
|
48
|
-
export type SubstrateTransferParams = GenericTransferParams & {
|
|
49
|
-
sender?: string;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
type Unsubcall = () => void;
|
|
53
|
-
|
|
54
|
-
interface InjectedAccount {
|
|
55
|
-
address: string;
|
|
56
|
-
genesisHash?: string | null;
|
|
57
|
-
name?: string;
|
|
58
|
-
type?: KeypairType;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
interface InjectedAccounts {
|
|
62
|
-
get: (anyType?: boolean) => Promise<InjectedAccount[]>;
|
|
63
|
-
subscribe: (cb: (accounts: InjectedAccount[]) => void | Promise<void>) => Unsubcall;
|
|
64
|
-
}
|
|
65
|
-
interface InjectedExtensionInfo {
|
|
66
|
-
name: string;
|
|
67
|
-
version: string;
|
|
68
|
-
}
|
|
69
|
-
interface ProviderMeta {
|
|
70
|
-
network: string;
|
|
71
|
-
node: "full" | "light";
|
|
72
|
-
source: string;
|
|
73
|
-
transport: string;
|
|
74
|
-
}
|
|
75
|
-
interface MetadataDefBase {
|
|
76
|
-
chain: string;
|
|
77
|
-
genesisHash: string;
|
|
78
|
-
icon: string;
|
|
79
|
-
ss58Format: number;
|
|
80
|
-
chainType?: "substrate" | "ethereum";
|
|
81
|
-
}
|
|
82
|
-
interface MetadataDef extends MetadataDefBase {
|
|
83
|
-
color?: string;
|
|
84
|
-
specVersion: number;
|
|
85
|
-
tokenDecimals: number;
|
|
86
|
-
tokenSymbol: string;
|
|
87
|
-
types: Record<string, Record<string, string> | string>;
|
|
88
|
-
metaCalls?: string;
|
|
89
|
-
userExtensions?: ExtDef;
|
|
90
|
-
}
|
|
91
|
-
interface InjectedMetadataKnown {
|
|
92
|
-
genesisHash: string;
|
|
93
|
-
specVersion: number;
|
|
94
|
-
}
|
|
95
|
-
interface InjectedMetadata {
|
|
96
|
-
get: () => Promise<InjectedMetadataKnown[]>;
|
|
97
|
-
provide: (definition: MetadataDef) => Promise<boolean>;
|
|
98
|
-
}
|
|
99
|
-
type ProviderList = Record<string, ProviderMeta>;
|
|
100
|
-
|
|
101
|
-
interface InjectedProvider extends ProviderInterface {
|
|
102
|
-
listProviders: () => Promise<ProviderList>;
|
|
103
|
-
startProvider: (key: string) => Promise<ProviderMeta>;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
type InjectedWalletData = {
|
|
107
|
-
accounts: InjectedAccounts;
|
|
108
|
-
metadata?: InjectedMetadata;
|
|
109
|
-
provider?: InjectedProvider;
|
|
110
|
-
signer: InjectedSigner;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
export type SubstrateInjectedExtension = Record<
|
|
114
|
-
string,
|
|
115
|
-
{
|
|
116
|
-
connect?: (origin: string) => Promise<InjectedExtensionInfo & InjectedWalletData>;
|
|
117
|
-
enable?: (origin: string) => Promise<InjectedWalletData>;
|
|
118
|
-
version?: string;
|
|
119
|
-
}
|
|
120
|
-
>;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { beforeAll, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
-
import { AssetValue, Chain, SKConfig } from "@swapkit/helpers";
|
|
3
|
-
import { createTronToolbox, getTronAddressValidator } from "../toolbox";
|
|
4
|
-
|
|
5
|
-
// Test mnemonic for consistent testing
|
|
6
|
-
const TEST_PHRASE =
|
|
7
|
-
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
|
|
8
|
-
|
|
9
|
-
const context: {
|
|
10
|
-
toolbox: Awaited<ReturnType<typeof createTronToolbox>>;
|
|
11
|
-
validateAddress: (address: string) => boolean;
|
|
12
|
-
} = {} as any;
|
|
13
|
-
|
|
14
|
-
beforeAll(async () => {
|
|
15
|
-
// Set up TRON mainnet configuration
|
|
16
|
-
SKConfig.set({
|
|
17
|
-
rpcUrls: {
|
|
18
|
-
[Chain.Tron]: "https://api.trongrid.io",
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// Get the address validator
|
|
23
|
-
context.validateAddress = await getTronAddressValidator();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
beforeEach(async () => {
|
|
27
|
-
context.toolbox = await createTronToolbox({ phrase: TEST_PHRASE });
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe("TRON Address Validation", () => {
|
|
31
|
-
test("should validate valid TRON addresses", () => {
|
|
32
|
-
const validAddresses = [
|
|
33
|
-
"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", // USDT contract
|
|
34
|
-
"TLa2f6VPqDgRE67v1736s7bJ8Ray5wYjU7", // Mainnet address
|
|
35
|
-
"TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE", // Another valid address
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
for (const address of validAddresses) {
|
|
39
|
-
expect(context.validateAddress(address)).toBe(true);
|
|
40
|
-
expect(context.toolbox.validateAddress(address)).toBe(true);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test("should reject invalid TRON addresses", () => {
|
|
45
|
-
const invalidAddresses = [
|
|
46
|
-
"", // Empty string
|
|
47
|
-
"invalid", // Random string
|
|
48
|
-
"0x742d35Cc6648C532F5e7c3d2a7a8E1e1e5b7c8D3", // Ethereum address
|
|
49
|
-
"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa", // Bitcoin address
|
|
50
|
-
"cosmos1abc123", // Cosmos address
|
|
51
|
-
"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6", // Too short
|
|
52
|
-
"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6tt", // Too long
|
|
53
|
-
"XR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", // Wrong prefix
|
|
54
|
-
"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6O", // Invalid checksum
|
|
55
|
-
];
|
|
56
|
-
|
|
57
|
-
for (const address of invalidAddresses) {
|
|
58
|
-
expect(context.validateAddress(address)).toBe(false);
|
|
59
|
-
expect(context.toolbox.validateAddress(address)).toBe(false);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test("should validate address from generated account", async () => {
|
|
64
|
-
const toolbox = context.toolbox;
|
|
65
|
-
|
|
66
|
-
// Get address from the toolbox
|
|
67
|
-
const address = await toolbox.getAddress();
|
|
68
|
-
|
|
69
|
-
expect(address).toBeDefined();
|
|
70
|
-
expect(typeof address).toBe("string");
|
|
71
|
-
expect(address.length).toBeGreaterThan(0);
|
|
72
|
-
|
|
73
|
-
// The generated address should be valid
|
|
74
|
-
expect(context.validateAddress(address)).toBe(true);
|
|
75
|
-
expect(toolbox.validateAddress(address)).toBe(true);
|
|
76
|
-
|
|
77
|
-
// Address should start with 'T'
|
|
78
|
-
expect(address.startsWith("T")).toBe(true);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
test("should create TRON transaction with valid addresses", async () => {
|
|
82
|
-
const toolbox = context.toolbox;
|
|
83
|
-
const fromAddress = "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE";
|
|
84
|
-
const toAddress = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"; // Valid TRON address
|
|
85
|
-
|
|
86
|
-
// Both addresses should be valid
|
|
87
|
-
expect(toolbox.validateAddress(fromAddress)).toBe(true);
|
|
88
|
-
expect(toolbox.validateAddress(toAddress)).toBe(true);
|
|
89
|
-
|
|
90
|
-
// Create a transaction
|
|
91
|
-
const transaction = await toolbox.createTransaction({
|
|
92
|
-
recipient: toAddress,
|
|
93
|
-
sender: fromAddress,
|
|
94
|
-
assetValue: AssetValue.from({
|
|
95
|
-
chain: Chain.Tron,
|
|
96
|
-
value: "1", // 1 TRX
|
|
97
|
-
}),
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
expect(transaction).toBeDefined();
|
|
101
|
-
expect(transaction.raw_data_hex).toBeDefined();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
test("should create TRON.USDT transaction with valid addresses", async () => {
|
|
105
|
-
const toolbox = context.toolbox;
|
|
106
|
-
const fromAddress = "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE";
|
|
107
|
-
const toAddress = "TT87ESmqUmH87hMx1MKCEqYrJKaQyNg9ao"; // Valid TRON address
|
|
108
|
-
|
|
109
|
-
// Both addresses should be valid
|
|
110
|
-
expect(toolbox.validateAddress(fromAddress)).toBe(true);
|
|
111
|
-
expect(toolbox.validateAddress(toAddress)).toBe(true);
|
|
112
|
-
|
|
113
|
-
// Create a transaction
|
|
114
|
-
const transaction = await toolbox.createTransaction({
|
|
115
|
-
recipient: toAddress,
|
|
116
|
-
sender: fromAddress,
|
|
117
|
-
assetValue: AssetValue.from({
|
|
118
|
-
asset: "TRX.USDT-TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
|
|
119
|
-
value: "100", // 1 TRX
|
|
120
|
-
}),
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
expect(transaction).toBeDefined();
|
|
124
|
-
expect(transaction.raw_data_hex).toBeDefined();
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
test("should handle case sensitivity in addresses", () => {
|
|
128
|
-
const address = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t";
|
|
129
|
-
const lowerCase = address.toLowerCase();
|
|
130
|
-
const upperCase = address.toUpperCase();
|
|
131
|
-
|
|
132
|
-
// TRON addresses are case sensitive - only the original should be valid
|
|
133
|
-
expect(context.validateAddress(address)).toBe(true);
|
|
134
|
-
expect(context.validateAddress(lowerCase)).toBe(false);
|
|
135
|
-
expect(context.validateAddress(upperCase)).toBe(false);
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
test("should handle edge cases", () => {
|
|
139
|
-
const edgeCases = [null, undefined, 123, {}, [], true, false];
|
|
140
|
-
|
|
141
|
-
for (const testCase of edgeCases) {
|
|
142
|
-
// Should not throw but return false for invalid inputs
|
|
143
|
-
expect(context.validateAddress(testCase as any)).toBe(false);
|
|
144
|
-
expect(context.toolbox.validateAddress(testCase as any)).toBe(false);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
});
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
export const trc20ABI = [
|
|
2
|
-
{
|
|
3
|
-
constant: true,
|
|
4
|
-
inputs: [{ name: "_owner", type: "address" }],
|
|
5
|
-
name: "balanceOf",
|
|
6
|
-
outputs: [{ name: "balance", type: "uint256" }],
|
|
7
|
-
stateMutability: "view",
|
|
8
|
-
type: "function",
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
constant: false,
|
|
12
|
-
inputs: [
|
|
13
|
-
{ name: "_to", type: "address" },
|
|
14
|
-
{ name: "_value", type: "uint256" },
|
|
15
|
-
],
|
|
16
|
-
name: "transfer",
|
|
17
|
-
outputs: [{ name: "success", type: "bool" }],
|
|
18
|
-
stateMutability: "nonpayable",
|
|
19
|
-
type: "function",
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
constant: true,
|
|
23
|
-
inputs: [],
|
|
24
|
-
name: "decimals",
|
|
25
|
-
outputs: [{ name: "", type: "uint8" }],
|
|
26
|
-
stateMutability: "view",
|
|
27
|
-
type: "function",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
constant: true,
|
|
31
|
-
inputs: [],
|
|
32
|
-
name: "symbol",
|
|
33
|
-
outputs: [{ name: "", type: "string" }],
|
|
34
|
-
stateMutability: "view",
|
|
35
|
-
type: "function",
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
constant: true,
|
|
39
|
-
inputs: [],
|
|
40
|
-
name: "name",
|
|
41
|
-
outputs: [{ name: "", type: "string" }],
|
|
42
|
-
stateMutability: "view",
|
|
43
|
-
type: "function",
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
constant: true,
|
|
47
|
-
inputs: [
|
|
48
|
-
{ name: "_owner", type: "address" },
|
|
49
|
-
{ name: "_spender", type: "address" },
|
|
50
|
-
],
|
|
51
|
-
name: "allowance",
|
|
52
|
-
outputs: [{ name: "remaining", type: "uint256" }],
|
|
53
|
-
stateMutability: "view",
|
|
54
|
-
type: "function",
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
constant: false,
|
|
58
|
-
inputs: [
|
|
59
|
-
{ name: "_spender", type: "address" },
|
|
60
|
-
{ name: "_value", type: "uint256" },
|
|
61
|
-
],
|
|
62
|
-
name: "approve",
|
|
63
|
-
outputs: [{ name: "success", type: "bool" }],
|
|
64
|
-
stateMutability: "nonpayable",
|
|
65
|
-
type: "function",
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
constant: true,
|
|
69
|
-
inputs: [],
|
|
70
|
-
name: "totalSupply",
|
|
71
|
-
outputs: [{ name: "", type: "uint256" }],
|
|
72
|
-
stateMutability: "view",
|
|
73
|
-
type: "function",
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
constant: false,
|
|
77
|
-
inputs: [
|
|
78
|
-
{ name: "_from", type: "address" },
|
|
79
|
-
{ name: "_to", type: "address" },
|
|
80
|
-
{ name: "_value", type: "uint256" },
|
|
81
|
-
],
|
|
82
|
-
name: "transferFrom",
|
|
83
|
-
outputs: [{ name: "success", type: "bool" }],
|
|
84
|
-
stateMutability: "nonpayable",
|
|
85
|
-
type: "function",
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
anonymous: false,
|
|
89
|
-
inputs: [
|
|
90
|
-
{ indexed: true, name: "_from", type: "address" },
|
|
91
|
-
{ indexed: true, name: "_to", type: "address" },
|
|
92
|
-
{ indexed: false, name: "_value", type: "uint256" },
|
|
93
|
-
],
|
|
94
|
-
name: "Transfer",
|
|
95
|
-
type: "event",
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
anonymous: false,
|
|
99
|
-
inputs: [
|
|
100
|
-
{ indexed: true, name: "_owner", type: "address" },
|
|
101
|
-
{ indexed: true, name: "_spender", type: "address" },
|
|
102
|
-
{ indexed: false, name: "_value", type: "uint256" },
|
|
103
|
-
],
|
|
104
|
-
name: "Approval",
|
|
105
|
-
type: "event",
|
|
106
|
-
},
|
|
107
|
-
] as const;
|