@swapkit/toolboxes 4.28.4 → 5.1.0
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/CHANGELOG.md +17 -20
- package/dist/chunk-55jkfkar.js +2 -0
- package/dist/{chunk-ap5mzmjf.js → chunk-v9dcj9m7.js} +1 -1
- package/dist/src/aptos/index.js +1 -1
- package/dist/src/cosmos/index.js +1 -1
- package/dist/src/evm/index.js +1 -1
- package/dist/src/hypercore/index.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/near/index.js +1 -1
- package/dist/src/ripple/index.js +1 -1
- package/dist/src/solana/index.js +1 -1
- package/dist/src/stellar/index.js +1 -1
- package/dist/src/ton/index.js +1 -1
- package/dist/src/tron/index.js +1 -1
- package/dist/src/utxo/index.js +1 -1
- package/dist/types/aptos/toolbox.d.ts +5 -5
- package/dist/types/aptos/types.d.ts +4 -0
- package/dist/types/cosmos/thorchainUtils/messages.d.ts +30 -6
- package/dist/types/cosmos/thorchainUtils/registry.d.ts +72 -2
- package/dist/types/cosmos/thorchainUtils/types/client-types.d.ts +6 -1
- package/dist/types/cosmos/toolbox/cosmos.d.ts +9 -11
- package/dist/types/cosmos/toolbox/thorchain.d.ts +83 -14
- package/dist/types/cosmos/types.d.ts +69 -3
- package/dist/types/cosmos/util.d.ts +150 -6
- package/dist/types/hypercore/__tests__/fixtures.d.ts +40 -0
- package/dist/types/hypercore/helpers.d.ts +12 -1
- package/dist/types/hypercore/index.d.ts +1 -0
- package/dist/types/hypercore/payin.d.ts +16 -0
- package/dist/types/hypercore/signing.d.ts +91 -0
- package/dist/types/hypercore/toolbox.d.ts +69 -6
- package/dist/types/hypercore/types.d.ts +25 -5
- package/dist/types/ripple/index.d.ts +5 -1
- package/dist/types/solana/index.d.ts +2 -0
- package/dist/types/solana/toolbox.d.ts +1 -1
- package/dist/types/ton/toolbox.d.ts +2 -0
- package/dist/types/tron/toolbox.d.ts +1 -1
- package/dist/types/tron/types.d.ts +2 -0
- package/package.json +22 -96
- package/dist/chunk-btth5bse.js +0 -1
- package/dist/chunk-z61r1327.js +0 -2
- package/dist/src/aleo/index.cjs +0 -1
- package/dist/src/aptos/index.cjs +0 -1
- package/dist/src/cardano/index.cjs +0 -1
- package/dist/src/cosmos/index.cjs +0 -1
- package/dist/src/evm/index.cjs +0 -1
- package/dist/src/hypercore/index.cjs +0 -1
- package/dist/src/index.cjs +0 -1
- package/dist/src/near/index.cjs +0 -1
- package/dist/src/radix/index.cjs +0 -1
- package/dist/src/ripple/index.cjs +0 -1
- package/dist/src/solana/index.cjs +0 -1
- package/dist/src/starknet/index.cjs +0 -1
- package/dist/src/stellar/index.cjs +0 -1
- package/dist/src/substrate/index.cjs +0 -1
- package/dist/src/sui/index.cjs +0 -1
- package/dist/src/ton/index.cjs +0 -1
- package/dist/src/tron/index.cjs +0 -1
- package/dist/src/utxo/index.cjs +0 -1
|
@@ -62,7 +62,10 @@ export declare const buildAminoMsg: ({ sender, recipient, assetValue, memo, }: {
|
|
|
62
62
|
to_address: string | undefined;
|
|
63
63
|
};
|
|
64
64
|
};
|
|
65
|
-
export declare const convertToSignable: (msg: MsgSend | MsgDeposit, chain: TCLikeChain) =>
|
|
65
|
+
export declare const convertToSignable: (msg: MsgSend | MsgDeposit, chain: TCLikeChain) => {
|
|
66
|
+
typeUrl: string;
|
|
67
|
+
value: unknown;
|
|
68
|
+
};
|
|
66
69
|
export declare function createTransaction(params: ThorchainCreateTransactionParams): Promise<{
|
|
67
70
|
accountNumber: number;
|
|
68
71
|
chainId: import("@swapkit/types").ChainId.Maya | import("@swapkit/types").ChainId.THORChain;
|
|
@@ -74,7 +77,7 @@ export declare function createTransaction(params: ThorchainCreateTransactionPara
|
|
|
74
77
|
gas: string;
|
|
75
78
|
};
|
|
76
79
|
memo: string;
|
|
77
|
-
msgs: (
|
|
80
|
+
msgs: ({
|
|
78
81
|
type: "thorchain/MsgSend" | "mayachain/MsgSend";
|
|
79
82
|
value: {
|
|
80
83
|
amount: {
|
|
@@ -84,6 +87,9 @@ export declare function createTransaction(params: ThorchainCreateTransactionPara
|
|
|
84
87
|
from_address: string;
|
|
85
88
|
to_address: string | undefined;
|
|
86
89
|
};
|
|
90
|
+
} | {
|
|
91
|
+
typeUrl: string;
|
|
92
|
+
value: unknown;
|
|
87
93
|
})[];
|
|
88
94
|
sequence: number;
|
|
89
95
|
} | {
|
|
@@ -97,7 +103,7 @@ export declare function createTransaction(params: ThorchainCreateTransactionPara
|
|
|
97
103
|
gas: string;
|
|
98
104
|
};
|
|
99
105
|
memo: string;
|
|
100
|
-
msgs: (
|
|
106
|
+
msgs: ({
|
|
101
107
|
type: "thorchain/MsgDeposit" | "mayachain/MsgDeposit";
|
|
102
108
|
value: {
|
|
103
109
|
coins: {
|
|
@@ -107,6 +113,9 @@ export declare function createTransaction(params: ThorchainCreateTransactionPara
|
|
|
107
113
|
memo: string;
|
|
108
114
|
signer: string;
|
|
109
115
|
};
|
|
116
|
+
} | {
|
|
117
|
+
typeUrl: string;
|
|
118
|
+
value: unknown;
|
|
110
119
|
})[];
|
|
111
120
|
sequence: number;
|
|
112
121
|
}>;
|
|
@@ -122,7 +131,7 @@ export declare function buildTransferTx({ sender, recipient, assetValue, memo, a
|
|
|
122
131
|
gas: string;
|
|
123
132
|
};
|
|
124
133
|
memo: string;
|
|
125
|
-
msgs: (
|
|
134
|
+
msgs: ({
|
|
126
135
|
type: "thorchain/MsgSend" | "mayachain/MsgSend";
|
|
127
136
|
value: {
|
|
128
137
|
amount: {
|
|
@@ -132,6 +141,9 @@ export declare function buildTransferTx({ sender, recipient, assetValue, memo, a
|
|
|
132
141
|
from_address: string;
|
|
133
142
|
to_address: string | undefined;
|
|
134
143
|
};
|
|
144
|
+
} | {
|
|
145
|
+
typeUrl: string;
|
|
146
|
+
value: unknown;
|
|
135
147
|
})[];
|
|
136
148
|
sequence: number;
|
|
137
149
|
}>;
|
|
@@ -146,7 +158,7 @@ export declare function buildDepositTx({ sender, assetValue, memo, asSignable, a
|
|
|
146
158
|
gas: string;
|
|
147
159
|
};
|
|
148
160
|
memo: string;
|
|
149
|
-
msgs: (
|
|
161
|
+
msgs: ({
|
|
150
162
|
type: "thorchain/MsgDeposit" | "mayachain/MsgDeposit";
|
|
151
163
|
value: {
|
|
152
164
|
coins: {
|
|
@@ -156,6 +168,9 @@ export declare function buildDepositTx({ sender, assetValue, memo, asSignable, a
|
|
|
156
168
|
memo: string;
|
|
157
169
|
signer: string;
|
|
158
170
|
};
|
|
171
|
+
} | {
|
|
172
|
+
typeUrl: string;
|
|
173
|
+
value: unknown;
|
|
159
174
|
})[];
|
|
160
175
|
sequence: number;
|
|
161
176
|
}>;
|
|
@@ -200,9 +215,18 @@ export declare function parseAminoMessageForDirectSigning<T extends MsgDeposit |
|
|
|
200
215
|
to_address: string | undefined;
|
|
201
216
|
};
|
|
202
217
|
});
|
|
218
|
+
/**
|
|
219
|
+
* Encode the TxBody for a THORChain/Maya transaction. Mirrors the cosmjs
|
|
220
|
+
* `Registry.encode({ typeUrl: "/cosmos.tx.v1beta1.TxBody", value: ... })`
|
|
221
|
+
* behaviour but uses our cosmos-signer encoder map + `encodeTxBody`.
|
|
222
|
+
*
|
|
223
|
+
* Each inner message is first converted from amino → direct (via the amino
|
|
224
|
+
* converter map's `fromAmino`), then encoded with the per-typeUrl encoder
|
|
225
|
+
* registered in `createDefaultRegistry`.
|
|
226
|
+
*/
|
|
203
227
|
export declare function buildEncodedTxBody({ chain, memo, msgs, }: {
|
|
204
228
|
msgs: DirectMsgDepositForBroadcast[] | DirectMsgSendForBroadcast[];
|
|
205
229
|
memo: string;
|
|
206
230
|
chain: TCLikeChain;
|
|
207
|
-
}):
|
|
231
|
+
}): Uint8Array;
|
|
208
232
|
export {};
|
|
@@ -1,3 +1,73 @@
|
|
|
1
|
+
import { type EncoderMap } from "@swapkit/cosmos-signer";
|
|
1
2
|
import { type TCLikeChain } from "@swapkit/helpers";
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Per-typeUrl encoder map for THORChain / Maya. Merges with `defaultEncoders`
|
|
5
|
+
* (which provides `/cosmos.bank.v1beta1.MsgSend`).
|
|
6
|
+
*/
|
|
7
|
+
export declare function createDefaultRegistry(): EncoderMap;
|
|
8
|
+
/**
|
|
9
|
+
* Amino converter map for THORChain / Maya. Lookup is by `typeUrl`. Each
|
|
10
|
+
* entry exposes both `fromAmino` (amino value → direct value) and
|
|
11
|
+
* `toAmino` (direct value → amino value).
|
|
12
|
+
*/
|
|
13
|
+
export declare function createDefaultAminoTypes(chain: TCLikeChain, addressPrefix?: string): {
|
|
14
|
+
readonly "/types.MsgDeposit": {
|
|
15
|
+
readonly aminoType: "thorchain/MsgDeposit" | "mayachain/MsgDeposit";
|
|
16
|
+
readonly fromAmino: ({ signer, ...rest }: {
|
|
17
|
+
signer: string;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}) => {
|
|
20
|
+
signer: string;
|
|
21
|
+
};
|
|
22
|
+
readonly toAmino: ({ signer, ...rest }: {
|
|
23
|
+
signer: unknown;
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}) => {
|
|
26
|
+
signer: unknown;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
readonly "/types.MsgSend": {
|
|
30
|
+
readonly aminoType: "thorchain/MsgSend" | "mayachain/MsgSend";
|
|
31
|
+
readonly fromAmino: ({ from_address, to_address, ...rest }: {
|
|
32
|
+
from_address: string;
|
|
33
|
+
to_address: string;
|
|
34
|
+
[key: string]: unknown;
|
|
35
|
+
}) => {
|
|
36
|
+
fromAddress: string;
|
|
37
|
+
toAddress: string;
|
|
38
|
+
};
|
|
39
|
+
readonly toAmino: ({ fromAddress, toAddress, ...rest }: {
|
|
40
|
+
fromAddress: unknown;
|
|
41
|
+
toAddress: unknown;
|
|
42
|
+
[key: string]: unknown;
|
|
43
|
+
}) => {
|
|
44
|
+
from_address: unknown;
|
|
45
|
+
to_address: unknown;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
} & {
|
|
49
|
+
fromAmino(message: {
|
|
50
|
+
type: string;
|
|
51
|
+
value: unknown;
|
|
52
|
+
}): {
|
|
53
|
+
typeUrl: string;
|
|
54
|
+
value: {
|
|
55
|
+
signer: string;
|
|
56
|
+
} | {
|
|
57
|
+
fromAddress: string;
|
|
58
|
+
toAddress: string;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
toAmino(message: {
|
|
62
|
+
typeUrl: string;
|
|
63
|
+
value: unknown;
|
|
64
|
+
}): {
|
|
65
|
+
type: "thorchain/MsgDeposit" | "mayachain/MsgDeposit" | "thorchain/MsgSend" | "mayachain/MsgSend";
|
|
66
|
+
value: {
|
|
67
|
+
signer: unknown;
|
|
68
|
+
} | {
|
|
69
|
+
from_address: unknown;
|
|
70
|
+
to_address: unknown;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
};
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Message } from "@swapkit/cosmos-signer";
|
|
2
2
|
import type { Asset, ChainId, GenericTransferParams } from "@swapkit/helpers";
|
|
3
3
|
import type { CosmosCreateTransactionParams } from "../../types";
|
|
4
|
+
/**
|
|
5
|
+
* Local replacement for cosmjs `EncodeObject` — same `{ typeUrl, value }`
|
|
6
|
+
* shape, sourced from cosmos-signer's `Message<unknown>`.
|
|
7
|
+
*/
|
|
8
|
+
export type EncodeObject = Message<unknown>;
|
|
4
9
|
declare enum TxType {
|
|
5
10
|
Transfer = "transfer",
|
|
6
11
|
Unknown = "unknown"
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import type { Account } from "@cosmjs/stargate";
|
|
2
1
|
import { AssetValue, Chain, type ChainId, type CosmosChain, type DerivationPathArray, type GenericTransferParams, SwapKitNumber } from "@swapkit/helpers";
|
|
3
2
|
import { type CosmosTransaction } from "@swapkit/helpers/api";
|
|
4
|
-
import type {
|
|
5
|
-
import type
|
|
6
|
-
import { cosmosCreateTransaction } from "../util";
|
|
3
|
+
import type { CosmosToolboxParams, OfflineDirectSigner } from "../types";
|
|
4
|
+
import { type Account, cosmosCreateTransaction, type SignedTx } from "../util";
|
|
7
5
|
export declare function fetchFeeRateFromSwapKit(chainId: ChainId, safeDefault: number): Promise<number>;
|
|
8
6
|
export declare function getSignerFromPhrase({ phrase, prefix, ...derivationParams }: {
|
|
9
7
|
phrase: string;
|
|
@@ -13,21 +11,21 @@ export declare function getSignerFromPhrase({ phrase, prefix, ...derivationParam
|
|
|
13
11
|
index?: number;
|
|
14
12
|
} | {
|
|
15
13
|
derivationPath: string;
|
|
16
|
-
})): Promise<
|
|
14
|
+
})): Promise<OfflineDirectSigner>;
|
|
17
15
|
export declare function getSignerFromPrivateKey({ privateKey, prefix }: {
|
|
18
16
|
privateKey: Uint8Array;
|
|
19
17
|
prefix: string;
|
|
20
|
-
}): Promise<
|
|
18
|
+
}): Promise<OfflineDirectSigner>;
|
|
21
19
|
export declare function verifySignature(getAccount: (address: string) => Promise<Account | null>): ({ signature, message, address, }: {
|
|
22
20
|
signature: string;
|
|
23
21
|
message: string;
|
|
24
22
|
address: string;
|
|
25
23
|
}) => Promise<boolean>;
|
|
26
24
|
export declare function createCosmosToolbox({ chain, ...toolboxParams }: CosmosToolboxParams): {
|
|
27
|
-
createPrivateKeyFromPhrase: (phrase: string) => Promise<Uint8Array<
|
|
25
|
+
createPrivateKeyFromPhrase: (phrase: string) => Promise<Uint8Array<ArrayBuffer>>;
|
|
28
26
|
createTransaction: typeof cosmosCreateTransaction;
|
|
29
27
|
fetchFeeRateFromSwapKit: typeof fetchFeeRateFromSwapKit;
|
|
30
|
-
getAccount: (address: string) => Promise<
|
|
28
|
+
getAccount: (address: string) => Promise<import("..").StargateAccount | null>;
|
|
31
29
|
getAddress: () => Promise<string | undefined>;
|
|
32
30
|
getBalance: (address: string, _potentialScamFilter?: boolean) => Promise<AssetValue[]>;
|
|
33
31
|
getBalanceAsDenoms: (address: string) => Promise<{
|
|
@@ -43,10 +41,10 @@ export declare function createCosmosToolbox({ chain, ...toolboxParams }: CosmosT
|
|
|
43
41
|
getSignerFromPhrase: ({ phrase, derivationPath }: {
|
|
44
42
|
phrase: string;
|
|
45
43
|
derivationPath: DerivationPathArray;
|
|
46
|
-
}) => Promise<
|
|
47
|
-
getSignerFromPrivateKey: (privateKey: Uint8Array) => Promise<
|
|
44
|
+
}) => Promise<OfflineDirectSigner>;
|
|
45
|
+
getSignerFromPrivateKey: (privateKey: Uint8Array) => Promise<OfflineDirectSigner>;
|
|
48
46
|
signAndBroadcastTransaction: (transaction: CosmosTransaction) => Promise<string>;
|
|
49
|
-
signTransaction: (transaction: CosmosTransaction) => Promise<
|
|
47
|
+
signTransaction: (transaction: CosmosTransaction) => Promise<SignedTx>;
|
|
50
48
|
transfer: ({ recipient, assetValue, memo, feeRate, feeOptionKey, sweep, }: GenericTransferParams) => Promise<string>;
|
|
51
49
|
validateAddress: (address: string) => boolean;
|
|
52
50
|
verifySignature: ({ signature, message, address, }: {
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type MultisigThresholdPubkey, type SinglePubkey } from "@swapkit/cosmos-signer";
|
|
2
2
|
import { type GenericTransferParams, type TCLikeChain } from "@swapkit/helpers";
|
|
3
3
|
import type { CosmosTransaction } from "@swapkit/helpers/api";
|
|
4
4
|
import { buildEncodedTxBody, createDefaultRegistry, createTransaction, parseAminoMessageForDirectSigning } from "../thorchainUtils";
|
|
5
|
-
import type { CosmosToolboxParams, MultiSigSigner, MultisigTx } from "../types";
|
|
6
|
-
|
|
5
|
+
import type { CosmosToolboxParams, LocalAminoSigner, MultiSigSigner, MultisigTx } from "../types";
|
|
6
|
+
/**
|
|
7
|
+
* Amino-signing wallet wrapper that mirrors the cosmjs `Secp256k1HdWallet`
|
|
8
|
+
* shape consumed by the multisig flow: exposes `getAccounts()` + `signAmino()`
|
|
9
|
+
* with the StdSignature shape downstream callers expect.
|
|
10
|
+
*/
|
|
11
|
+
type Secp256k1HdWalletLike = LocalAminoSigner;
|
|
12
|
+
declare function createMultisig(pubKeys: string[], threshold: number, noSortPubKeys?: boolean): MultisigThresholdPubkey;
|
|
7
13
|
declare function importSignature(signature: string): Uint8Array<ArrayBufferLike>;
|
|
8
14
|
declare function signWithPrivateKey({ privateKey, message }: {
|
|
9
15
|
privateKey: Uint8Array;
|
|
@@ -58,8 +64,71 @@ export declare function createThorchainToolbox({ chain, ...toolboxParams }: Cosm
|
|
|
58
64
|
memo: string;
|
|
59
65
|
signer: string;
|
|
60
66
|
};
|
|
61
|
-
}, chain: TCLikeChain) =>
|
|
62
|
-
|
|
67
|
+
}, chain: TCLikeChain) => {
|
|
68
|
+
typeUrl: string;
|
|
69
|
+
value: unknown;
|
|
70
|
+
};
|
|
71
|
+
createDefaultAminoTypes: () => {
|
|
72
|
+
readonly "/types.MsgDeposit": {
|
|
73
|
+
readonly aminoType: "thorchain/MsgDeposit" | "mayachain/MsgDeposit";
|
|
74
|
+
readonly fromAmino: ({ signer, ...rest }: {
|
|
75
|
+
signer: string;
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
}) => {
|
|
78
|
+
signer: string;
|
|
79
|
+
};
|
|
80
|
+
readonly toAmino: ({ signer, ...rest }: {
|
|
81
|
+
signer: unknown;
|
|
82
|
+
[key: string]: unknown;
|
|
83
|
+
}) => {
|
|
84
|
+
signer: unknown;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
readonly "/types.MsgSend": {
|
|
88
|
+
readonly aminoType: "thorchain/MsgSend" | "mayachain/MsgSend";
|
|
89
|
+
readonly fromAmino: ({ from_address, to_address, ...rest }: {
|
|
90
|
+
from_address: string;
|
|
91
|
+
to_address: string;
|
|
92
|
+
[key: string]: unknown;
|
|
93
|
+
}) => {
|
|
94
|
+
fromAddress: string;
|
|
95
|
+
toAddress: string;
|
|
96
|
+
};
|
|
97
|
+
readonly toAmino: ({ fromAddress, toAddress, ...rest }: {
|
|
98
|
+
fromAddress: unknown;
|
|
99
|
+
toAddress: unknown;
|
|
100
|
+
[key: string]: unknown;
|
|
101
|
+
}) => {
|
|
102
|
+
from_address: unknown;
|
|
103
|
+
to_address: unknown;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
} & {
|
|
107
|
+
fromAmino(message: {
|
|
108
|
+
type: string;
|
|
109
|
+
value: unknown;
|
|
110
|
+
}): {
|
|
111
|
+
typeUrl: string;
|
|
112
|
+
value: {
|
|
113
|
+
signer: string;
|
|
114
|
+
} | {
|
|
115
|
+
fromAddress: string;
|
|
116
|
+
toAddress: string;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
toAmino(message: {
|
|
120
|
+
typeUrl: string;
|
|
121
|
+
value: unknown;
|
|
122
|
+
}): {
|
|
123
|
+
type: "thorchain/MsgDeposit" | "mayachain/MsgDeposit" | "thorchain/MsgSend" | "mayachain/MsgSend";
|
|
124
|
+
value: {
|
|
125
|
+
signer: unknown;
|
|
126
|
+
} | {
|
|
127
|
+
from_address: unknown;
|
|
128
|
+
to_address: unknown;
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
};
|
|
63
132
|
createDefaultRegistry: typeof createDefaultRegistry;
|
|
64
133
|
createMultisig: typeof createMultisig;
|
|
65
134
|
createTransaction: typeof createTransaction;
|
|
@@ -73,24 +142,24 @@ export declare function createThorchainToolbox({ chain, ...toolboxParams }: Cosm
|
|
|
73
142
|
}>;
|
|
74
143
|
importSignature: typeof importSignature;
|
|
75
144
|
parseAminoMessageForDirectSigning: typeof parseAminoMessageForDirectSigning;
|
|
76
|
-
pubkeyToAddress: (pubkey:
|
|
77
|
-
secp256k1HdWalletFromMnemonic: (mnemonic: string, index?: number) => Promise<
|
|
145
|
+
pubkeyToAddress: (pubkey: SinglePubkey | MultisigThresholdPubkey) => string;
|
|
146
|
+
secp256k1HdWalletFromMnemonic: (mnemonic: string, index?: number) => Promise<Secp256k1HdWalletLike>;
|
|
78
147
|
signAndBroadcastTransaction: ({ fee, memo, msgs }: Pick<CosmosTransaction, "fee" | "memo" | "msgs">) => Promise<string>;
|
|
79
148
|
signMultisigTx: ({ wallet, tx }: {
|
|
80
|
-
wallet:
|
|
149
|
+
wallet: Secp256k1HdWalletLike;
|
|
81
150
|
tx: string | MultisigTx;
|
|
82
151
|
}) => Promise<{
|
|
83
|
-
bodyBytes: Uint8Array<
|
|
152
|
+
bodyBytes: Uint8Array<ArrayBufferLike>;
|
|
84
153
|
signature: string;
|
|
85
154
|
}>;
|
|
86
|
-
signTransaction: (transaction: CosmosTransaction) => Promise<import("
|
|
155
|
+
signTransaction: (transaction: CosmosTransaction) => Promise<import("..").SignedTx>;
|
|
87
156
|
signWithPrivateKey: typeof signWithPrivateKey;
|
|
88
157
|
transfer: ({ assetValue, memo, recipient, sweep, }: Omit<GenericTransferParams, "recipient"> & {
|
|
89
158
|
recipient?: string;
|
|
90
159
|
}) => Promise<string>;
|
|
91
|
-
createPrivateKeyFromPhrase: (phrase: string) => Promise<Uint8Array<
|
|
160
|
+
createPrivateKeyFromPhrase: (phrase: string) => Promise<Uint8Array<ArrayBuffer>>;
|
|
92
161
|
fetchFeeRateFromSwapKit: typeof import("./cosmos").fetchFeeRateFromSwapKit;
|
|
93
|
-
getAccount: (address: string) => Promise<import("
|
|
162
|
+
getAccount: (address: string) => Promise<import("..").StargateAccount | null>;
|
|
94
163
|
getAddress: () => Promise<string | undefined>;
|
|
95
164
|
getBalance: (address: string, _potentialScamFilter?: boolean) => Promise<import("@swapkit/helpers").AssetValue[]>;
|
|
96
165
|
getBalanceAsDenoms: (address: string) => Promise<{
|
|
@@ -101,8 +170,8 @@ export declare function createThorchainToolbox({ chain, ...toolboxParams }: Cosm
|
|
|
101
170
|
getSignerFromPhrase: ({ phrase, derivationPath }: {
|
|
102
171
|
phrase: string;
|
|
103
172
|
derivationPath: import("@swapkit/helpers").DerivationPathArray;
|
|
104
|
-
}) => Promise<import("
|
|
105
|
-
getSignerFromPrivateKey: (privateKey: Uint8Array) => Promise<import("
|
|
173
|
+
}) => Promise<import("..").OfflineDirectSigner>;
|
|
174
|
+
getSignerFromPrivateKey: (privateKey: Uint8Array) => Promise<import("..").OfflineDirectSigner>;
|
|
106
175
|
validateAddress: (address: string) => boolean;
|
|
107
176
|
verifySignature: ({ signature, message, address, }: {
|
|
108
177
|
signature: string;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { DirectSecp256k1HdWallet, OfflineDirectSigner } from "@cosmjs/proto-signing";
|
|
1
|
+
import type { StdSignDoc } from "@swapkit/cosmos-signer";
|
|
3
2
|
import type { ChainId, CosmosChain, DerivationPathArray, GenericCreateTransactionParams, TCLikeChain } from "@swapkit/helpers";
|
|
4
3
|
import type { buildAminoMsg } from "./thorchainUtils";
|
|
5
4
|
import type { createCosmosToolbox } from "./toolbox/cosmos";
|
|
@@ -27,7 +26,74 @@ export type MultisigTx = {
|
|
|
27
26
|
fee: ReturnType<typeof getDefaultChainFee>;
|
|
28
27
|
memo: string;
|
|
29
28
|
};
|
|
30
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Account data returned by signers (matches the cosmjs `AccountData` shape that
|
|
31
|
+
* external wallet adapters — Keplr, Leap, Ledger — already produce).
|
|
32
|
+
*/
|
|
33
|
+
export type AccountData = {
|
|
34
|
+
address: string;
|
|
35
|
+
algo: string;
|
|
36
|
+
pubkey: Uint8Array;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* StdSignature shape (matches `@cosmjs/amino`): used by Keplr-style adapters
|
|
40
|
+
* to return amino signatures.
|
|
41
|
+
*/
|
|
42
|
+
export type StdSignature = {
|
|
43
|
+
pub_key: {
|
|
44
|
+
type: string;
|
|
45
|
+
value: string;
|
|
46
|
+
};
|
|
47
|
+
signature: string;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* SignDoc shape for `SIGN_MODE_DIRECT`. Mirrors `@cosmjs/proto-signing`
|
|
51
|
+
* `SignDoc` — external wallet adapters that already speak the cosmjs API
|
|
52
|
+
* satisfy this shape unchanged.
|
|
53
|
+
*/
|
|
54
|
+
export type DirectSignDoc = {
|
|
55
|
+
bodyBytes: Uint8Array;
|
|
56
|
+
authInfoBytes: Uint8Array;
|
|
57
|
+
chainId: string;
|
|
58
|
+
accountNumber: bigint;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Offline signer for `SIGN_MODE_DIRECT` (Keplr-direct, Leap-direct, local
|
|
62
|
+
* cosmos-signer wrapper). Replaces `@cosmjs/proto-signing` `OfflineDirectSigner`.
|
|
63
|
+
*/
|
|
64
|
+
export interface OfflineDirectSigner {
|
|
65
|
+
getAccounts(): Promise<readonly AccountData[]>;
|
|
66
|
+
signDirect(signerAddress: string, signDoc: DirectSignDoc): Promise<{
|
|
67
|
+
signed: DirectSignDoc;
|
|
68
|
+
signature: StdSignature;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Offline signer for `SIGN_MODE_LEGACY_AMINO_JSON` (Keplr-amino, Leap-amino,
|
|
73
|
+
* Ledger, local amino wrappers). Replaces `@cosmjs/amino` `OfflineAminoSigner`.
|
|
74
|
+
*/
|
|
75
|
+
export interface OfflineAminoSigner {
|
|
76
|
+
getAccounts(): Promise<readonly AccountData[]>;
|
|
77
|
+
signAmino(signerAddress: string, signDoc: StdSignDoc): Promise<{
|
|
78
|
+
signed: StdSignDoc;
|
|
79
|
+
signature: StdSignature;
|
|
80
|
+
}>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Either an amino-mode signer or a direct-mode signer. External wallets
|
|
84
|
+
* implement one of the two — the toolbox detects via `"signAmino" in signer`.
|
|
85
|
+
*/
|
|
86
|
+
export type OfflineSigner = OfflineDirectSigner | OfflineAminoSigner;
|
|
87
|
+
/**
|
|
88
|
+
* Convenience alias matching the legacy cosmjs `Secp256k1HdWallet` shape.
|
|
89
|
+
* Our `createSecp256k1HdWallet` returns this — a local amino signer + the
|
|
90
|
+
* underlying mnemonic-derived key material exposed for the multisig
|
|
91
|
+
* combiner that needs the pubkey.
|
|
92
|
+
*/
|
|
93
|
+
export type LocalAminoSigner = OfflineAminoSigner & {
|
|
94
|
+
readonly accounts?: readonly AccountData[];
|
|
95
|
+
};
|
|
96
|
+
export type CosmosSigner = OfflineDirectSigner | OfflineAminoSigner;
|
|
31
97
|
export type CosmosToolboxParams<T = CosmosChain> = {
|
|
32
98
|
chain: T;
|
|
33
99
|
} & ({
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { SigningStargateClientOptions } from "@cosmjs/stargate";
|
|
1
|
+
import { type EncoderMap } from "@swapkit/cosmos-signer";
|
|
3
2
|
import { AssetValue, type CosmosChain, SwapKitNumber, type TCLikeChain } from "@swapkit/helpers";
|
|
4
|
-
import type { CosmosCreateTransactionParams } from "./types";
|
|
3
|
+
import type { CosmosCreateTransactionParams, OfflineSigner } from "./types";
|
|
5
4
|
export declare const USK_KUJIRA_FACTORY_DENOM = "FACTORY/KUJIRA1QK00H5ATUTPSV900X202PXX42NPJR9THG58DNQPA72F2P7M2LUASE444A7/UUSK";
|
|
6
5
|
export declare const YUM_KUJIRA_FACTORY_DENOM = "FACTORY/KUJIRA1YGFXN0ER40KLCNCK8THLTUPRDXLCK6WVNPKF2K/UYUM";
|
|
7
6
|
export declare const DEFAULT_COSMOS_FEE_MAINNET: {
|
|
@@ -35,9 +34,154 @@ export declare function getDefaultChainFee(chain: CosmosChain): {
|
|
|
35
34
|
export declare function getThorchainNativeFee(chain: TCLikeChain): Promise<SwapKitNumber>;
|
|
36
35
|
export declare const getMsgSendDenom: (symbol: string, isThorchain?: boolean) => string;
|
|
37
36
|
export declare const getDenomWithChain: ({ symbol, chain }: AssetValue) => string;
|
|
38
|
-
|
|
39
|
-
export
|
|
40
|
-
|
|
37
|
+
/** cosmjs `StdFee` shape — preserved here so callers don't change. */
|
|
38
|
+
export type StdFee = {
|
|
39
|
+
amount: {
|
|
40
|
+
amount: string;
|
|
41
|
+
denom: string;
|
|
42
|
+
}[];
|
|
43
|
+
gas: string;
|
|
44
|
+
payer?: string;
|
|
45
|
+
granter?: string;
|
|
46
|
+
};
|
|
47
|
+
/** cosmjs `Coin` shape returned by `getAllBalances`. Renamed `BalanceCoin`
|
|
48
|
+
* to avoid clashing with `@swapkit/helpers` `Coin` (which uses `asset`). */
|
|
49
|
+
export type BalanceCoin = {
|
|
50
|
+
amount: string;
|
|
51
|
+
denom: string;
|
|
52
|
+
};
|
|
53
|
+
/** cosmjs `Account` shape returned by `getAccount`. */
|
|
54
|
+
export type StargateAccount = {
|
|
55
|
+
address: string;
|
|
56
|
+
pubkey: {
|
|
57
|
+
type: string;
|
|
58
|
+
value: Uint8Array;
|
|
59
|
+
} | null;
|
|
60
|
+
accountNumber: number;
|
|
61
|
+
sequence: number;
|
|
62
|
+
};
|
|
63
|
+
/** Alias kept for source compatibility with existing callers. */
|
|
64
|
+
export type Account = StargateAccount;
|
|
65
|
+
/** Output of `SigningStargateClient.sign` — same as cosmjs `TxRaw`. */
|
|
66
|
+
export type SignedTx = {
|
|
67
|
+
bodyBytes: Uint8Array;
|
|
68
|
+
authInfoBytes: Uint8Array;
|
|
69
|
+
signatures: Uint8Array[];
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Options accepted by `createSigningStargateClient`. Mirrors the cosmjs
|
|
73
|
+
* `SigningStargateClientOptions` subset that the toolbox actually uses:
|
|
74
|
+
* - `registry` — encoder map merged with `defaultEncoders`
|
|
75
|
+
* - `aminoTypes` — amino<->proto converter (lookup by typeUrl)
|
|
76
|
+
*
|
|
77
|
+
* Both shapes are intentionally `unknown`-typed at the boundary because the
|
|
78
|
+
* thorchain registry currently returns the legacy `Registry`/`AminoTypes`
|
|
79
|
+
* classes; the duck-typing we do is "if it has `.encodeAsAny` / `.fromAmino`,
|
|
80
|
+
* use it." This lets the existing thorchain registry implementation work
|
|
81
|
+
* unchanged while we incrementally migrate it (next file in this batch).
|
|
82
|
+
*/
|
|
83
|
+
export type SigningStargateClientOptions = {
|
|
84
|
+
registry?: ToolboxRegistry;
|
|
85
|
+
aminoTypes?: ToolboxAminoTypes;
|
|
86
|
+
/** Reserved — accepted for source compatibility, currently unused. */
|
|
87
|
+
gasPrice?: unknown;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Toolbox-facing registry duck type. Either a cosmos-signer-style encoder
|
|
91
|
+
* map, OR the legacy thorchain `Registry` instance with `.encode()`. The
|
|
92
|
+
* adapter detects via `"encode" in registry` and routes accordingly.
|
|
93
|
+
*/
|
|
94
|
+
export type ToolboxRegistry = EncoderMap | {
|
|
95
|
+
encode(value: {
|
|
96
|
+
typeUrl: string;
|
|
97
|
+
value: unknown;
|
|
98
|
+
}): Uint8Array;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Toolbox-facing amino types duck type. Either an object of
|
|
102
|
+
* `{ [typeUrl]: { aminoType, fromAmino, toAmino } }`, OR the legacy
|
|
103
|
+
* thorchain `AminoTypes` instance with `.fromAmino` / `.toAmino` methods.
|
|
104
|
+
*
|
|
105
|
+
* The converter shape uses very loose types so concrete implementations
|
|
106
|
+
* (THORChain registry) can register strongly-typed converters without
|
|
107
|
+
* fighting variance — the adapter only invokes them via duck typing.
|
|
108
|
+
*/
|
|
109
|
+
export type ToolboxAminoConverter = {
|
|
110
|
+
aminoType: string;
|
|
111
|
+
fromAmino: (v: any) => any;
|
|
112
|
+
toAmino: (v: any) => any;
|
|
113
|
+
};
|
|
114
|
+
export type ToolboxAminoTypes = {
|
|
115
|
+
readonly [typeUrl: string]: ToolboxAminoConverter;
|
|
116
|
+
} | {
|
|
117
|
+
fromAmino(msg: {
|
|
118
|
+
type: string;
|
|
119
|
+
value: unknown;
|
|
120
|
+
}): {
|
|
121
|
+
typeUrl: string;
|
|
122
|
+
value: unknown;
|
|
123
|
+
};
|
|
124
|
+
toAmino(msg: {
|
|
125
|
+
typeUrl: string;
|
|
126
|
+
value: unknown;
|
|
127
|
+
}): {
|
|
128
|
+
type: string;
|
|
129
|
+
value: unknown;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
export declare function createStargateClient(url: string): Promise<{
|
|
133
|
+
broadcastTx(txBytes: Uint8Array): Promise<{
|
|
134
|
+
transactionHash: string;
|
|
135
|
+
code: number;
|
|
136
|
+
rawLog: string;
|
|
137
|
+
}>;
|
|
138
|
+
getAccount(address: string): Promise<Account | null>;
|
|
139
|
+
getAllBalances(address: string): Promise<readonly BalanceCoin[]>;
|
|
140
|
+
}>;
|
|
141
|
+
export type StargateClientLike = Awaited<ReturnType<typeof createStargateClient>>;
|
|
142
|
+
export declare function createSigningStargateClient(url: string, signer: OfflineSigner, optionsOrBaseGas?: string | SigningStargateClientOptions): Promise<{
|
|
143
|
+
broadcastTx(txBytes: Uint8Array): Promise<{
|
|
144
|
+
transactionHash: string;
|
|
145
|
+
code: number;
|
|
146
|
+
rawLog: string;
|
|
147
|
+
}>;
|
|
148
|
+
sendTokens(senderAddress: string, recipientAddress: string, amount: readonly {
|
|
149
|
+
amount: string;
|
|
150
|
+
denom: string;
|
|
151
|
+
}[], fee: StdFee, memo?: string): Promise<{
|
|
152
|
+
code: number;
|
|
153
|
+
rawLog: string;
|
|
154
|
+
transactionHash: string;
|
|
155
|
+
}>;
|
|
156
|
+
sign(signerAddress: string, msgs: {
|
|
157
|
+
typeUrl: string;
|
|
158
|
+
value: unknown;
|
|
159
|
+
}[], fee: StdFee, memo: string, signerData?: {
|
|
160
|
+
accountNumber: bigint;
|
|
161
|
+
chainId: string;
|
|
162
|
+
sequence: number | bigint;
|
|
163
|
+
}): Promise<SignedTx>;
|
|
164
|
+
signAndBroadcast(signerAddress: string, msgs: {
|
|
165
|
+
typeUrl: string;
|
|
166
|
+
value: unknown;
|
|
167
|
+
}[], fee: StdFee, memo?: string): Promise<{
|
|
168
|
+
code: number;
|
|
169
|
+
rawLog: string;
|
|
170
|
+
transactionHash: string;
|
|
171
|
+
}>;
|
|
172
|
+
}>;
|
|
173
|
+
export type SigningStargateClientLike = Awaited<ReturnType<typeof createSigningStargateClient>>;
|
|
174
|
+
export declare function createOfflineStargateClient(wallet: OfflineSigner, options?: SigningStargateClientOptions): Promise<{
|
|
175
|
+
sign(signerAddress: string, msgs: {
|
|
176
|
+
typeUrl: string;
|
|
177
|
+
value: unknown;
|
|
178
|
+
}[], fee: StdFee, memo: string, signerData?: {
|
|
179
|
+
accountNumber: bigint;
|
|
180
|
+
chainId: string;
|
|
181
|
+
sequence: number | bigint;
|
|
182
|
+
}): Promise<SignedTx>;
|
|
183
|
+
}>;
|
|
184
|
+
export type OfflineStargateClientLike = Awaited<ReturnType<typeof createOfflineStargateClient>>;
|
|
41
185
|
/**
|
|
42
186
|
* Used to build tx for Cosmos and Kujira
|
|
43
187
|
*/
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare const usdcTokenId = "USDC:0x6d1e7cde53ba9467b783cb7c530ce054";
|
|
2
|
+
export declare const payinMessage: {
|
|
3
|
+
amount: string;
|
|
4
|
+
destination: string;
|
|
5
|
+
destinationDex: string;
|
|
6
|
+
fromSubAccount: string;
|
|
7
|
+
hyperliquidChain: "Mainnet";
|
|
8
|
+
nonce: number;
|
|
9
|
+
sourceDex: string;
|
|
10
|
+
token: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const payinAction: {
|
|
13
|
+
signatureChainId: string;
|
|
14
|
+
type: "sendAsset";
|
|
15
|
+
amount: string;
|
|
16
|
+
destination: string;
|
|
17
|
+
destinationDex: string;
|
|
18
|
+
fromSubAccount: string;
|
|
19
|
+
hyperliquidChain: "Mainnet";
|
|
20
|
+
nonce: number;
|
|
21
|
+
sourceDex: string;
|
|
22
|
+
token: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const payinDomain: {
|
|
25
|
+
chainId: number;
|
|
26
|
+
name: string;
|
|
27
|
+
verifyingContract: string;
|
|
28
|
+
version: string;
|
|
29
|
+
};
|
|
30
|
+
export declare const sendAssetStruct: {
|
|
31
|
+
name: string;
|
|
32
|
+
type: string;
|
|
33
|
+
}[];
|
|
34
|
+
export declare const sendAssetStructTypes: {
|
|
35
|
+
"HyperliquidTransaction:SendAsset": {
|
|
36
|
+
name: string;
|
|
37
|
+
type: string;
|
|
38
|
+
}[];
|
|
39
|
+
};
|
|
40
|
+
export declare const payinDigest = "0x466d43f280b7fda240a3a97a424aaef3f2645e284425362d5c686094761b1b9e";
|