@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
package/src/tron/types.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
DerivationPathArray,
|
|
3
|
-
FeeOption,
|
|
4
|
-
GenericCreateTransactionParams,
|
|
5
|
-
GenericTransferParams,
|
|
6
|
-
} from "@swapkit/helpers";
|
|
7
|
-
import type { Contract, Types } from "tronweb";
|
|
8
|
-
|
|
9
|
-
// Re-export TronWeb types for convenience
|
|
10
|
-
export type TronTransaction = Types.Transaction;
|
|
11
|
-
export type TronContract = Contract;
|
|
12
|
-
export type TronSignedTransaction = Types.SignedTransaction;
|
|
13
|
-
|
|
14
|
-
// Signer interface compatible with TronWeb and wallet implementations
|
|
15
|
-
export interface TronSigner {
|
|
16
|
-
getAddress(): Promise<string>;
|
|
17
|
-
signTransaction(transaction: TronTransaction): Promise<TronSignedTransaction>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type TronToolboxOptions =
|
|
21
|
-
| { signer?: TronSigner }
|
|
22
|
-
| { phrase?: string; derivationPath?: DerivationPathArray; index?: number }
|
|
23
|
-
| {};
|
|
24
|
-
|
|
25
|
-
export interface TronTransferParams extends GenericTransferParams {
|
|
26
|
-
// No additional fields needed - all inherited from GenericTransferParams
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface TronCreateTransactionParams
|
|
30
|
-
extends Omit<GenericCreateTransactionParams, "feeRate"> {
|
|
31
|
-
// No additional fields needed - all inherited from GenericCreateTransactionParams
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Same as EVM types for consistency
|
|
35
|
-
export type ApproveParams = {
|
|
36
|
-
assetAddress: string;
|
|
37
|
-
spenderAddress: string;
|
|
38
|
-
feeOptionKey?: FeeOption;
|
|
39
|
-
amount?: bigint | string | number; // BigNumberish equivalent for Tron
|
|
40
|
-
from?: string;
|
|
41
|
-
gasLimitFallback?: bigint | string | number;
|
|
42
|
-
nonce?: number;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export type ApprovedParams = {
|
|
46
|
-
assetAddress: string;
|
|
47
|
-
spenderAddress: string;
|
|
48
|
-
from: string;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export type IsApprovedParams = ApprovedParams & {
|
|
52
|
-
amount?: bigint | string | number;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// TronGrid API Types
|
|
56
|
-
export type TronGridTRC20Balance = Array<{
|
|
57
|
-
[contractAddress: string]: string; // Balance as string
|
|
58
|
-
}>;
|
|
59
|
-
|
|
60
|
-
export interface TronGridAccountResponse {
|
|
61
|
-
data: Array<{
|
|
62
|
-
address: string;
|
|
63
|
-
balance: number; // TRX balance in SUN
|
|
64
|
-
create_time: number;
|
|
65
|
-
latest_opration_time: number; // Note: typo in API response
|
|
66
|
-
free_net_usage: number;
|
|
67
|
-
net_window_size: number;
|
|
68
|
-
net_window_optimized: boolean;
|
|
69
|
-
trc20: TronGridTRC20Balance;
|
|
70
|
-
assetV2?: Array<{
|
|
71
|
-
key: string;
|
|
72
|
-
value: number;
|
|
73
|
-
}>;
|
|
74
|
-
frozenV2?: Array<{
|
|
75
|
-
type?: string;
|
|
76
|
-
}>;
|
|
77
|
-
free_asset_net_usageV2?: Array<{
|
|
78
|
-
key: string;
|
|
79
|
-
value: number;
|
|
80
|
-
}>;
|
|
81
|
-
latest_consume_free_time?: number;
|
|
82
|
-
owner_permission?: {
|
|
83
|
-
keys: Array<{
|
|
84
|
-
address: string;
|
|
85
|
-
weight: number;
|
|
86
|
-
}>;
|
|
87
|
-
threshold: number;
|
|
88
|
-
permission_name: string;
|
|
89
|
-
};
|
|
90
|
-
active_permission?: Array<{
|
|
91
|
-
operations: string;
|
|
92
|
-
keys: Array<{
|
|
93
|
-
address: string;
|
|
94
|
-
weight: number;
|
|
95
|
-
}>;
|
|
96
|
-
threshold: number;
|
|
97
|
-
id: number;
|
|
98
|
-
type: string;
|
|
99
|
-
permission_name: string;
|
|
100
|
-
}>;
|
|
101
|
-
account_resource?: {
|
|
102
|
-
energy_window_optimized: boolean;
|
|
103
|
-
energy_window_size: number;
|
|
104
|
-
};
|
|
105
|
-
}>;
|
|
106
|
-
success: boolean;
|
|
107
|
-
meta: {
|
|
108
|
-
at: number;
|
|
109
|
-
page_size: number;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface TronGridTokenInfo {
|
|
114
|
-
symbol: string;
|
|
115
|
-
address: string;
|
|
116
|
-
decimals: number;
|
|
117
|
-
name: string;
|
|
118
|
-
totalSupply: string;
|
|
119
|
-
owner: string;
|
|
120
|
-
}
|
package/src/utils.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AssetValue, BaseDecimal, type Chain } from "@swapkit/helpers";
|
|
2
|
-
import { SwapKitApi } from "@swapkit/helpers/api";
|
|
3
|
-
|
|
4
|
-
const pid = typeof process !== "undefined" && process.pid ? process.pid.toString(36) : "";
|
|
5
|
-
|
|
6
|
-
let last = 0;
|
|
7
|
-
export function uniqid() {
|
|
8
|
-
function now() {
|
|
9
|
-
const time = Date.now();
|
|
10
|
-
const lastTime = last || time;
|
|
11
|
-
last = lastTime;
|
|
12
|
-
|
|
13
|
-
return time > last ? time : lastTime + 1;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return pid + now().toString(36);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function getBalance<T extends Chain>(chain: T) {
|
|
20
|
-
return async function getBalance(address: string, scamFilter = true) {
|
|
21
|
-
const balances = await SwapKitApi.getChainBalance({ chain, address, scamFilter });
|
|
22
|
-
|
|
23
|
-
return balances.map(({ identifier, value, decimal }) => {
|
|
24
|
-
return new AssetValue({ decimal: decimal || BaseDecimal[chain], value, identifier });
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "bun:test";
|
|
2
|
-
import { Chain, DerivationPath } from "@swapkit/helpers";
|
|
3
|
-
import { getUtxoToolbox } from "../toolbox";
|
|
4
|
-
|
|
5
|
-
describe("UTXO Toolbox Zcash Integration", () => {
|
|
6
|
-
const testPhrase =
|
|
7
|
-
"abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
|
|
8
|
-
|
|
9
|
-
it("should create Zcash toolbox through main UTXO toolbox factory", async () => {
|
|
10
|
-
const toolbox = await getUtxoToolbox(Chain.Zcash);
|
|
11
|
-
|
|
12
|
-
expect(toolbox).toBeDefined();
|
|
13
|
-
expect(typeof toolbox.validateAddress).toBe("function");
|
|
14
|
-
expect(typeof toolbox.getBalance).toBe("function");
|
|
15
|
-
expect(typeof toolbox.getFeeRates).toBe("function");
|
|
16
|
-
expect(typeof toolbox.broadcastTx).toBe("function");
|
|
17
|
-
expect(typeof toolbox.createTransaction).toBe("function");
|
|
18
|
-
expect(typeof toolbox.transfer).toBe("function");
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("should create Zcash toolbox with phrase", async () => {
|
|
22
|
-
const toolbox = await getUtxoToolbox(Chain.Zcash, {
|
|
23
|
-
phrase: testPhrase,
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
expect(toolbox).toBeDefined();
|
|
27
|
-
expect(() => toolbox.getAddress()).not.toThrow();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("should generate valid Zcash addresses", async () => {
|
|
31
|
-
const toolbox = await getUtxoToolbox(Chain.Zcash, {
|
|
32
|
-
phrase: testPhrase,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const address = await toolbox.getAddress();
|
|
36
|
-
expect(address).toBeDefined();
|
|
37
|
-
expect(typeof address).toBe("string");
|
|
38
|
-
expect(address?.startsWith("t1")).toBe(true); // Zcash mainnet addresses start with t1
|
|
39
|
-
expect(toolbox.validateAddress(address || "")).toBe(true);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("should validate Zcash addresses correctly", async () => {
|
|
43
|
-
const toolbox = await getUtxoToolbox(Chain.Zcash);
|
|
44
|
-
|
|
45
|
-
// Valid Zcash mainnet address format
|
|
46
|
-
expect(toolbox.validateAddress("t1XVXWCvpMgBvUaed4XDqWtgQgJSu1Ghz7F")).toBe(true);
|
|
47
|
-
|
|
48
|
-
// Invalid addresses
|
|
49
|
-
expect(toolbox.validateAddress("1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2")).toBe(false); // Bitcoin address
|
|
50
|
-
expect(toolbox.validateAddress("zcash:qr5agtachyxvrwxu76vzszan5pnvuzy8dm")).toBe(false); // Wrong format
|
|
51
|
-
expect(toolbox.validateAddress("")).toBe(false); // Empty string
|
|
52
|
-
expect(toolbox.validateAddress("invalid")).toBe(false); // Invalid string
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("should reject shielded addresses", async () => {
|
|
56
|
-
const toolbox = await getUtxoToolbox(Chain.Zcash);
|
|
57
|
-
|
|
58
|
-
// Test z-address (shielded) - should be rejected with warning
|
|
59
|
-
const originalWarn = console.warn;
|
|
60
|
-
let warnCalled = false;
|
|
61
|
-
let warnMessage = "";
|
|
62
|
-
|
|
63
|
-
console.warn = (message: string) => {
|
|
64
|
-
warnCalled = true;
|
|
65
|
-
warnMessage = message;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const isValid = toolbox.validateAddress(
|
|
69
|
-
"zs1z7rejlpsa98s2rrrfkwmaxu2xldqmfq5nj2m3hq6s7r8qjq8eqqqq9p4e7x",
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
expect(isValid).toBe(false);
|
|
73
|
-
expect(warnCalled).toBe(true);
|
|
74
|
-
expect(warnMessage).toBe(
|
|
75
|
-
"Shielded Zcash addresses (z-addresses) are not supported. Use transparent addresses (t1/t3) only.",
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
console.warn = originalWarn;
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("should create keys for derivation path", async () => {
|
|
82
|
-
const toolbox = await getUtxoToolbox(Chain.Zcash, {
|
|
83
|
-
phrase: testPhrase,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const keys = await toolbox.createKeysForPath({
|
|
87
|
-
phrase: testPhrase,
|
|
88
|
-
derivationPath: DerivationPath.ZEC,
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
expect(keys).toBeDefined();
|
|
92
|
-
expect(keys.publicKey).toBeDefined();
|
|
93
|
-
expect(keys.privateKey).toBeDefined();
|
|
94
|
-
expect(typeof keys.toWIF).toBe("function");
|
|
95
|
-
|
|
96
|
-
const address = await toolbox.getAddress();
|
|
97
|
-
expect(address).toBeDefined();
|
|
98
|
-
expect(address?.startsWith("t1")).toBe(true);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("should get WIF private key from mnemonic", async () => {
|
|
102
|
-
const toolbox = await getUtxoToolbox(Chain.Zcash, {
|
|
103
|
-
phrase: testPhrase,
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const wif = await toolbox.getPrivateKeyFromMnemonic({
|
|
107
|
-
phrase: testPhrase,
|
|
108
|
-
derivationPath: DerivationPath.ZEC,
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
expect(typeof wif).toBe("string");
|
|
112
|
-
expect(wif.length).toBeGreaterThan(50); // WIF keys are typically 51-52 characters
|
|
113
|
-
});
|
|
114
|
-
});
|