@sodax/wallet-sdk-core 1.5.7-beta → 2.0.0-rc.10
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/README.md +230 -1
- package/dist/index.cjs +3307 -2400
- package/dist/index.d.cts +415 -129
- package/dist/index.d.ts +415 -129
- package/dist/index.mjs +3301 -2400
- package/package.json +25 -18
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,111 @@
|
|
|
1
|
+
import { EvmRawTransaction, EvmChainKey, IEvmWalletProvider, EvmRawTransactionReceipt, ISuiWalletProvider, SuiTransaction, SuiExecutionResult, SuiPaginatedCoins, IIconWalletProvider, IcxCallTransaction, IconTransactionResult, InjectiveCoin, IInjectiveWalletProvider, JsonObject, InjectiveRawTransaction, InjectiveEoaAddress, InjectiveExecuteResponse, ISolanaWalletProvider, SolanaRpcResponseAndContext, SolanaSignatureResult, TransactionSignature, SolanaRawTransactionInstruction, SolanaSerializedTransaction, SolanaBase58PublicKey, XDR, Hex as Hex$1, IStellarWalletProvider, StellarRawTransactionReceipt, IStacksWalletProvider, StacksTransactionParams, INearWalletProvider, CallContractParams, NearRawTransaction, BtcAddressType, IBitcoinWalletProvider } from '@sodax/types';
|
|
1
2
|
import * as viem from 'viem';
|
|
2
|
-
import { Chain, PublicClient,
|
|
3
|
-
|
|
4
|
-
import { SuiClient } from '@mysten/sui/client';
|
|
3
|
+
import { WalletClient, Transport, Chain, Account, PublicClient, PublicClientConfig, WalletClientConfig, HttpTransportConfig, SendTransactionParameters, WaitForTransactionReceiptParameters, Address, Hash as Hash$1 } from 'viem';
|
|
4
|
+
export { Account, Address, Chain, HttpTransportConfig, PublicClient, PublicClientConfig, SendTransactionParameters, TransactionReceipt, Transport, WaitForTransactionReceiptParameters, WalletClient, WalletClientConfig } from 'viem';
|
|
5
|
+
import { SuiClient, SuiTransactionBlockResponseOptions } from '@mysten/sui/client';
|
|
6
|
+
export { SuiTransactionBlockResponseOptions } from '@mysten/sui/client';
|
|
5
7
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
6
|
-
import { Transaction } from '@mysten/sui/transactions';
|
|
7
8
|
import { WalletWithFeatures, SuiWalletFeatures, WalletAccount } from '@mysten/wallet-standard';
|
|
8
|
-
|
|
9
|
+
export { SuiWalletFeatures, WalletAccount, WalletWithFeatures } from '@mysten/wallet-standard';
|
|
10
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
11
|
+
export { Transaction, TransactionArgument } from '@mysten/sui/transactions';
|
|
12
|
+
import { Wallet, IconService } from 'icon-sdk-js';
|
|
9
13
|
import { Network } from '@injectivelabs/networks';
|
|
10
|
-
|
|
14
|
+
export { Network } from '@injectivelabs/networks';
|
|
11
15
|
import { MsgBroadcasterWithPk } from '@injectivelabs/sdk-ts';
|
|
12
|
-
import { ChainId
|
|
13
|
-
|
|
16
|
+
import { ChainId, EvmChainId } from '@injectivelabs/ts-types';
|
|
17
|
+
export { ChainId, EvmChainId } from '@injectivelabs/ts-types';
|
|
18
|
+
import { MsgBroadcaster } from '@injectivelabs/wallet-core';
|
|
19
|
+
export { MsgBroadcaster } from '@injectivelabs/wallet-core';
|
|
20
|
+
import { PublicKey, Commitment, ConnectionConfig, SendOptions, Connection, RpcResponseAndContext, TokenAmount } from '@solana/web3.js';
|
|
21
|
+
export { Commitment, ConnectionConfig, SendOptions } from '@solana/web3.js';
|
|
14
22
|
import { SignerWalletAdapterProps } from '@solana/wallet-adapter-base';
|
|
15
23
|
import { Keypair } from '@stellar/stellar-sdk';
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
import {
|
|
20
|
-
|
|
24
|
+
export { Networks } from '@stellar/stellar-sdk';
|
|
25
|
+
import { PostConditionMode, ClarityValue } from '@sodax/libs/stacks/core';
|
|
26
|
+
export { ClarityValue, PostConditionMode, PostConditionModeName, StacksNetwork } from '@sodax/libs/stacks/core';
|
|
27
|
+
import { StacksProvider } from '@sodax/libs/stacks/connect';
|
|
28
|
+
export { StacksProvider } from '@sodax/libs/stacks/connect';
|
|
21
29
|
import { NearConnector } from '@hot-labs/near-connect';
|
|
30
|
+
export { NearConnector } from '@hot-labs/near-connect';
|
|
31
|
+
import { Account as Account$1, JsonRpcProvider } from 'near-api-js';
|
|
32
|
+
export { KeyPairString } from 'near-api-js';
|
|
33
|
+
import { ECPairInterface } from 'ecpair';
|
|
34
|
+
import * as bitcoin from 'bitcoinjs-lib';
|
|
35
|
+
export { Network as BitcoinJsNetwork } from 'bitcoinjs-lib/src/networks.js';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Common base for all wallet providers in this package.
|
|
39
|
+
* Holds the `defaults` config and exposes `mergePolicy` for per-call option merging.
|
|
40
|
+
*
|
|
41
|
+
* Subclasses are responsible for:
|
|
42
|
+
* - declaring `chainType` literal
|
|
43
|
+
* - validating their own config variants
|
|
44
|
+
* - implementing the chain-specific provider interface
|
|
45
|
+
*
|
|
46
|
+
* NOTE: All fields of `TDefaults` (and any nested per-method shape it groups)
|
|
47
|
+
* MUST be declared optional. The constructor falls back to `{}` when no defaults
|
|
48
|
+
* are supplied — required fields would silently arrive as `undefined` at runtime
|
|
49
|
+
* without TypeScript flagging it (the cast erases that constraint).
|
|
50
|
+
*/
|
|
51
|
+
declare abstract class BaseWalletProvider<TDefaults extends object> {
|
|
52
|
+
protected readonly defaults: TDefaults;
|
|
53
|
+
constructor(defaults: TDefaults | undefined);
|
|
54
|
+
/**
|
|
55
|
+
* Return the connected wallet address as a string. Subclasses may narrow the
|
|
56
|
+
* return type to a chain-specific brand (e.g. `Address`, `IconEoaAddress`).
|
|
57
|
+
*/
|
|
58
|
+
abstract getWalletAddress(): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Merge per-call options over a slice of `defaults` keyed by `key`.
|
|
61
|
+
* Use when defaults are grouped per-method (e.g. `defaults.sendTransaction`).
|
|
62
|
+
*/
|
|
63
|
+
protected mergePolicy<K extends keyof TDefaults>(key: K, options?: TDefaults[K] extends infer V ? (V extends object ? V : never) : never): TDefaults[K] extends infer V ? (V extends object ? V : never) : never;
|
|
64
|
+
/**
|
|
65
|
+
* Merge per-call options over the entire `defaults` object.
|
|
66
|
+
* Use when defaults are flat (single-level fields).
|
|
67
|
+
*/
|
|
68
|
+
protected mergeDefaults(options?: Partial<TDefaults>): TDefaults;
|
|
69
|
+
}
|
|
22
70
|
|
|
71
|
+
/** Send-tx execution params (gas/nonce/fees). Disjoint from EvmRawTransaction by type — no field collision possible. */
|
|
72
|
+
type EvmSendTransactionPolicy = Omit<Partial<SendTransactionParameters>, keyof EvmRawTransaction>;
|
|
73
|
+
/** Wait-for-receipt params (confirmations/polling/timeout). `hash` is positional, not part of the policy. */
|
|
74
|
+
type EvmWaitForTransactionReceiptPolicy = Partial<Omit<WaitForTransactionReceiptParameters, 'hash'>>;
|
|
75
|
+
/**
|
|
76
|
+
* Defaults applied to every call. Per-call options shallow-merge over these.
|
|
77
|
+
* `publicClient`/`walletClient`/`transport` only apply in private-key mode
|
|
78
|
+
* (consumer brings clients in browser-extension mode).
|
|
79
|
+
*/
|
|
80
|
+
type EvmWalletDefaults = {
|
|
81
|
+
publicClient?: Partial<Omit<PublicClientConfig, 'transport' | 'chain'>>;
|
|
82
|
+
walletClient?: Partial<Omit<WalletClientConfig, 'transport' | 'chain' | 'account'>>;
|
|
83
|
+
transport?: HttpTransportConfig;
|
|
84
|
+
sendTransaction?: EvmSendTransactionPolicy;
|
|
85
|
+
waitForTransactionReceipt?: EvmWaitForTransactionReceiptPolicy;
|
|
86
|
+
};
|
|
87
|
+
/** Configuration for constructing an `EvmWalletProvider` backed by a raw private key. */
|
|
88
|
+
type PrivateKeyEvmWalletConfig = {
|
|
89
|
+
privateKey: `0x${string}`;
|
|
90
|
+
chainId: EvmChainKey;
|
|
91
|
+
rpcUrl?: `http${string}`;
|
|
92
|
+
defaults?: EvmWalletDefaults;
|
|
93
|
+
};
|
|
94
|
+
/** Configuration for constructing an `EvmWalletProvider` backed by a browser-extension wallet (viem clients). */
|
|
95
|
+
type BrowserExtensionEvmWalletConfig = {
|
|
96
|
+
walletClient: WalletClient<Transport, Chain, Account>;
|
|
97
|
+
publicClient: PublicClient;
|
|
98
|
+
defaults?: EvmWalletDefaults;
|
|
99
|
+
};
|
|
100
|
+
type EvmWalletConfig = PrivateKeyEvmWalletConfig | BrowserExtensionEvmWalletConfig;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Manually defined viem chain config for HyperEVM.
|
|
104
|
+
*
|
|
105
|
+
* HyperEVM is absent from the `viem/chains` package, so the chain is defined
|
|
106
|
+
* here using `defineChain` with the canonical RPC, block-explorer, and Multicall3
|
|
107
|
+
* contract address.
|
|
108
|
+
*/
|
|
23
109
|
declare const hyper: {
|
|
24
110
|
blockExplorers: {
|
|
25
111
|
readonly default: {
|
|
@@ -53,42 +139,80 @@ declare const hyper: {
|
|
|
53
139
|
formatters?: undefined;
|
|
54
140
|
serializers?: viem.ChainSerializers<undefined, viem.TransactionSerializable> | undefined;
|
|
55
141
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Returns the viem `Chain` config for the given EVM chain key.
|
|
144
|
+
*
|
|
145
|
+
* @param key - An `EvmChainKey` constant (e.g. `ChainKeys.SONIC_MAINNET`).
|
|
146
|
+
* @returns The corresponding viem chain object.
|
|
147
|
+
* @throws {Error} If `key` is not a recognised EVM chain key.
|
|
148
|
+
*/
|
|
149
|
+
declare function getEvmViemChain(key: EvmChainKey): Chain;
|
|
150
|
+
/** Returns `true` when `config` carries a hex private key (server-side / script usage). */
|
|
151
|
+
declare function isPrivateKeyEvmWalletConfig(config: EvmWalletConfig): config is PrivateKeyEvmWalletConfig;
|
|
152
|
+
/** Returns `true` when `config` carries pre-built viem wallet and public clients (browser extension / dApp usage). */
|
|
153
|
+
declare function isBrowserExtensionEvmWalletConfig(config: EvmWalletConfig): config is BrowserExtensionEvmWalletConfig;
|
|
154
|
+
/**
|
|
155
|
+
* EVM wallet provider backed by [viem](https://viem.sh).
|
|
156
|
+
*
|
|
157
|
+
* Supports two modes selected by config shape:
|
|
158
|
+
* - **Private-key** (`PrivateKeyEvmWalletConfig`): creates its own viem wallet and public
|
|
159
|
+
* clients from the supplied private key, chain ID, and optional RPC URL. Intended for
|
|
160
|
+
* Node scripts and server-side testing.
|
|
161
|
+
* - **Browser-extension** (`BrowserExtensionEvmWalletConfig`): accepts pre-built viem clients
|
|
162
|
+
* injected by the dApp's wallet adapter (e.g. wagmi). Transport/client defaults are ignored
|
|
163
|
+
* in this mode.
|
|
164
|
+
*
|
|
165
|
+
* All 12 supported EVM chains are covered via {@link getEvmViemChain}; HyperEVM is defined
|
|
166
|
+
* locally as {@link hyper} because it is absent from `viem/chains`.
|
|
167
|
+
*/
|
|
168
|
+
declare class EvmWalletProvider extends BaseWalletProvider<EvmWalletDefaults> implements IEvmWalletProvider {
|
|
169
|
+
readonly chainType: "EVM";
|
|
59
170
|
readonly publicClient: PublicClient;
|
|
171
|
+
private readonly walletClient;
|
|
60
172
|
constructor(config: EvmWalletConfig);
|
|
61
|
-
sendTransaction(evmRawTx: EvmRawTransaction): Promise<Hash$1>;
|
|
62
|
-
waitForTransactionReceipt(txHash: Hash$1): Promise<EvmRawTransactionReceipt>;
|
|
63
173
|
getWalletAddress(): Promise<Address>;
|
|
174
|
+
/** Submits a signed transaction to the network and returns the transaction hash. */
|
|
175
|
+
sendTransaction(txData: EvmRawTransaction, options?: EvmSendTransactionPolicy): Promise<Hash$1>;
|
|
176
|
+
/**
|
|
177
|
+
* Polls until the transaction is included in a block and returns the serialised receipt.
|
|
178
|
+
* All `bigint` fields are converted to strings to allow safe JSON serialisation.
|
|
179
|
+
*/
|
|
180
|
+
waitForTransactionReceipt(txHash: Hash$1, options?: EvmWaitForTransactionReceiptPolicy): Promise<EvmRawTransactionReceipt>;
|
|
181
|
+
private static serializeReceipt;
|
|
64
182
|
}
|
|
183
|
+
|
|
65
184
|
/**
|
|
66
|
-
*
|
|
185
|
+
* signAndExecuteTxn behavior. Pre-flight dry-run is enabled by default — disable only when
|
|
186
|
+
* paying gas for a doomed tx is acceptable. `response` options forward to the underlying
|
|
187
|
+
* SuiClient call (signAndExecuteTransaction in PK mode, executeTransactionBlock in browser-ext).
|
|
67
188
|
*/
|
|
68
|
-
type
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
189
|
+
type SuiSignAndExecutePolicy = {
|
|
190
|
+
dryRun?: {
|
|
191
|
+
enabled?: boolean;
|
|
192
|
+
};
|
|
193
|
+
response?: SuiTransactionBlockResponseOptions;
|
|
72
194
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
195
|
+
/** getCoins pagination policy. */
|
|
196
|
+
type SuiGetCoinsPolicy = {
|
|
197
|
+
limit?: number;
|
|
76
198
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
199
|
+
/** Defaults applied to every call. Per-call options shallow-merge over these. */
|
|
200
|
+
type SuiWalletDefaults = {
|
|
201
|
+
signAndExecuteTxn?: SuiSignAndExecutePolicy;
|
|
202
|
+
getCoins?: SuiGetCoinsPolicy;
|
|
203
|
+
};
|
|
204
|
+
/** Configuration for constructing a `SuiWalletProvider` backed by a mnemonic-derived private key. */
|
|
84
205
|
type PrivateKeySuiWalletConfig = {
|
|
85
206
|
rpcUrl: string;
|
|
86
207
|
mnemonics: string;
|
|
208
|
+
defaults?: SuiWalletDefaults;
|
|
87
209
|
};
|
|
210
|
+
/** Configuration for constructing a `SuiWalletProvider` backed by a browser-extension wallet. */
|
|
88
211
|
type BrowserExtensionSuiWalletConfig = {
|
|
89
212
|
client: SuiClient;
|
|
90
213
|
wallet: WalletWithFeatures<Partial<SuiWalletFeatures>>;
|
|
91
214
|
account: WalletAccount;
|
|
215
|
+
defaults?: SuiWalletDefaults;
|
|
92
216
|
};
|
|
93
217
|
type SuiWalletConfig = PrivateKeySuiWalletConfig | BrowserExtensionSuiWalletConfig;
|
|
94
218
|
type PkSuiWallet = {
|
|
@@ -99,43 +223,51 @@ type BrowserExtensionSuiWallet = {
|
|
|
99
223
|
account: WalletAccount;
|
|
100
224
|
};
|
|
101
225
|
type SuiWallet = PkSuiWallet | BrowserExtensionSuiWallet;
|
|
226
|
+
|
|
102
227
|
declare function isPkSuiWallet(wallet: SuiWallet): wallet is PkSuiWallet;
|
|
103
228
|
declare function isBrowserExtensionSuiWallet(wallet: SuiWallet): wallet is BrowserExtensionSuiWallet;
|
|
104
|
-
declare
|
|
105
|
-
|
|
229
|
+
declare class SuiWalletProvider extends BaseWalletProvider<SuiWalletDefaults> implements ISuiWalletProvider {
|
|
230
|
+
readonly chainType: "SUI";
|
|
106
231
|
private readonly client;
|
|
107
232
|
private readonly wallet;
|
|
108
233
|
constructor(walletConfig: SuiWalletConfig);
|
|
109
|
-
|
|
234
|
+
getWalletAddress(): Promise<string>;
|
|
235
|
+
signAndExecuteTxn(txn: SuiTransaction, options?: SuiSignAndExecutePolicy): Promise<string>;
|
|
110
236
|
viewContract(tx: Transaction, packageId: string, module: string, functionName: string, args: unknown[], typeArgs?: string[]): Promise<SuiExecutionResult>;
|
|
111
|
-
getCoins(address: string, token: string): Promise<SuiPaginatedCoins>;
|
|
237
|
+
getCoins(address: string, token: string, options?: SuiGetCoinsPolicy): Promise<SuiPaginatedCoins>;
|
|
238
|
+
private buildAndDryRunOrThrow;
|
|
239
|
+
private buildOnly;
|
|
240
|
+
private assertEffectsSuccess;
|
|
112
241
|
private getSuiAddress;
|
|
113
|
-
getWalletAddress(): Promise<string>;
|
|
114
242
|
}
|
|
115
243
|
|
|
116
|
-
declare class IconWalletProvider implements IIconWalletProvider {
|
|
117
|
-
private readonly wallet;
|
|
118
|
-
readonly iconService: IconService;
|
|
119
|
-
constructor(wallet: IconWalletConfig);
|
|
120
|
-
sendTransaction(tx: IcxCallTransaction): Promise<Hash>;
|
|
121
|
-
waitForTransactionReceipt(txHash: Hash): Promise<IconTransactionResult>;
|
|
122
|
-
getWalletAddress(): Promise<IconEoaAddress>;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Icon Types
|
|
126
|
-
*/
|
|
127
244
|
type IconJsonRpcVersion = '2.0';
|
|
128
245
|
type Hex = `0x${string}`;
|
|
129
246
|
type Hash = `0x${string}`;
|
|
130
247
|
type IconAddress = `hx${string}` | `cx${string}`;
|
|
131
248
|
type IconEoaAddress = `hx${string}`;
|
|
249
|
+
/** Defaults applied to every call. Per-call options shallow-merge over these. */
|
|
250
|
+
type IconWalletDefaults = {
|
|
251
|
+
/** Step limit (gas) for transactions. Default `3_000_000`. */
|
|
252
|
+
stepLimit?: number;
|
|
253
|
+
/** Transaction version. Default `'0x3'`. */
|
|
254
|
+
version?: string;
|
|
255
|
+
/** Timestamp generator (microseconds). Default `() => Date.now() * 1000`. */
|
|
256
|
+
timestampProvider?: () => number;
|
|
257
|
+
/** Event ID for `requestJsonRpc` (browser-extension path). Default `99999`. */
|
|
258
|
+
jsonRpcId?: number;
|
|
259
|
+
};
|
|
260
|
+
/** Configuration for constructing an `IconWalletProvider` backed by a raw private key. */
|
|
132
261
|
type PrivateKeyIconWalletConfig = {
|
|
133
262
|
privateKey: `0x${string}`;
|
|
134
263
|
rpcUrl: `http${string}`;
|
|
264
|
+
defaults?: IconWalletDefaults;
|
|
135
265
|
};
|
|
266
|
+
/** Configuration for constructing an `IconWalletProvider` backed by a browser-extension wallet (Hana Wallet). */
|
|
136
267
|
type BrowserExtensionIconWalletConfig = {
|
|
137
268
|
walletAddress?: IconEoaAddress;
|
|
138
269
|
rpcUrl: `http${string}`;
|
|
270
|
+
defaults?: IconWalletDefaults;
|
|
139
271
|
};
|
|
140
272
|
type IconWalletConfig = PrivateKeyIconWalletConfig | BrowserExtensionIconWalletConfig;
|
|
141
273
|
type IconPkWallet = {
|
|
@@ -177,6 +309,16 @@ type JsonRpcPayloadResponse = {
|
|
|
177
309
|
id: number;
|
|
178
310
|
result: string;
|
|
179
311
|
};
|
|
312
|
+
|
|
313
|
+
declare class IconWalletProvider extends BaseWalletProvider<IconWalletDefaults> implements IIconWalletProvider {
|
|
314
|
+
readonly chainType: "ICON";
|
|
315
|
+
readonly iconService: IconService;
|
|
316
|
+
private readonly wallet;
|
|
317
|
+
constructor(wallet: IconWalletConfig);
|
|
318
|
+
sendTransaction(tx: IcxCallTransaction, options?: IconWalletDefaults): Promise<Hash>;
|
|
319
|
+
waitForTransactionReceipt(txHash: Hash): Promise<IconTransactionResult>;
|
|
320
|
+
getWalletAddress(): Promise<IconEoaAddress>;
|
|
321
|
+
}
|
|
180
322
|
/**
|
|
181
323
|
* Icon Type Guards
|
|
182
324
|
*/
|
|
@@ -201,79 +343,134 @@ declare function requestJsonRpc(rawTransaction: unknown, id?: number): Promise<J
|
|
|
201
343
|
declare function BigNumberToBigInt(bigNumber: BigNumber): bigint;
|
|
202
344
|
|
|
203
345
|
/**
|
|
204
|
-
*
|
|
346
|
+
* Defaults applied to every call. Per-call options shallow-merge over these.
|
|
347
|
+
* `msgBroadcaster` options apply at construction time only (private-key path) —
|
|
348
|
+
* the upstream MsgBroadcasterWithPk doesn't support post-construction reconfig.
|
|
205
349
|
*/
|
|
350
|
+
type InjectiveWalletDefaults = {
|
|
351
|
+
/** Coins attached to `getRawTransaction`/`execute` if caller doesn't supply funds. */
|
|
352
|
+
defaultFunds?: InjectiveCoin[];
|
|
353
|
+
/** Default memo on transactions. */
|
|
354
|
+
defaultMemo?: string;
|
|
355
|
+
/** Sequence override for `createTransaction`. Default 0. */
|
|
356
|
+
sequence?: number;
|
|
357
|
+
/** Account number override for `createTransaction`. Default 0. */
|
|
358
|
+
accountNumber?: number;
|
|
359
|
+
};
|
|
206
360
|
type BrowserExtensionInjectiveWalletConfig = {
|
|
207
361
|
msgBroadcaster: MsgBroadcaster;
|
|
362
|
+
defaults?: InjectiveWalletDefaults;
|
|
208
363
|
};
|
|
364
|
+
/**
|
|
365
|
+
* Server-side / private-key Injective wallet configuration.
|
|
366
|
+
*
|
|
367
|
+
* Unlike most providers that accept a top-level `privateKey`, Injective nests
|
|
368
|
+
* credentials under `secret` to accommodate both a raw private key and a BIP-39
|
|
369
|
+
* mnemonic phrase as first-class alternatives:
|
|
370
|
+
*
|
|
371
|
+
* ```ts
|
|
372
|
+
* // Private-key variant
|
|
373
|
+
* { secret: { privateKey: '0x…' }, chainId, network }
|
|
374
|
+
*
|
|
375
|
+
* // Mnemonic variant
|
|
376
|
+
* { secret: { mnemonics: 'word1 word2 …' }, chainId, network }
|
|
377
|
+
* ```
|
|
378
|
+
*
|
|
379
|
+
* This mirrors the `PrivateKey.fromPrivateKey` / `PrivateKey.fromMnemonic` split
|
|
380
|
+
* in `@injectivelabs/sdk-ts` and avoids a union at the config root.
|
|
381
|
+
*/
|
|
209
382
|
type SecretInjectiveWalletConfig = {
|
|
210
383
|
secret: {
|
|
211
384
|
privateKey: string;
|
|
212
385
|
} | {
|
|
213
386
|
mnemonics: string;
|
|
214
387
|
};
|
|
215
|
-
chainId: ChainId
|
|
388
|
+
chainId: ChainId;
|
|
216
389
|
network: Network;
|
|
390
|
+
/**
|
|
391
|
+
* Reserved for future EVM-sidecar support on Injective.
|
|
392
|
+
*
|
|
393
|
+
* @remarks Currently unused — `InjectiveWalletProvider` does not read this
|
|
394
|
+
* field. It is declared here to keep the config shape stable while EVM
|
|
395
|
+
* compatibility is under development.
|
|
396
|
+
*/
|
|
217
397
|
evmOptions?: {
|
|
218
398
|
evmChainId: EvmChainId;
|
|
219
399
|
rpcUrl: `http${string}`;
|
|
220
400
|
};
|
|
401
|
+
defaults?: InjectiveWalletDefaults;
|
|
221
402
|
};
|
|
222
403
|
type InjectiveWalletConfig = BrowserExtensionInjectiveWalletConfig | SecretInjectiveWalletConfig;
|
|
223
|
-
/**
|
|
224
|
-
* Injective Type Guards
|
|
225
|
-
*/
|
|
226
|
-
declare function isBrowserExtensionInjectiveWalletConfig(config: InjectiveWalletConfig): config is BrowserExtensionInjectiveWalletConfig;
|
|
227
|
-
declare function isSecretInjectiveWalletConfig(config: InjectiveWalletConfig): config is SecretInjectiveWalletConfig;
|
|
228
404
|
type InjectiveWallet = {
|
|
229
405
|
msgBroadcaster: MsgBroadcaster | MsgBroadcasterWithPk;
|
|
230
406
|
};
|
|
231
|
-
|
|
407
|
+
|
|
408
|
+
declare function isBrowserExtensionInjectiveWalletConfig(config: InjectiveWalletConfig): config is BrowserExtensionInjectiveWalletConfig;
|
|
409
|
+
declare function isSecretInjectiveWalletConfig(config: InjectiveWalletConfig): config is SecretInjectiveWalletConfig;
|
|
410
|
+
declare class InjectiveWalletProvider extends BaseWalletProvider<InjectiveWalletDefaults> implements IInjectiveWalletProvider {
|
|
411
|
+
readonly chainType: "INJECTIVE";
|
|
232
412
|
wallet: InjectiveWallet;
|
|
233
413
|
constructor(config: InjectiveWalletConfig);
|
|
234
|
-
|
|
414
|
+
/**
|
|
415
|
+
* Builds a signed-but-unbroadcast Injective transaction for a CosmWasm contract call.
|
|
416
|
+
*
|
|
417
|
+
* @param chainId - Injective chain ID (e.g. `"injective-1"`).
|
|
418
|
+
* @param _ - Unused positional parameter retained for interface-compat with other spoke
|
|
419
|
+
* providers that accept a signer public key at this position. Injective derives the
|
|
420
|
+
* public key internally via {@link getWalletPubKey}; pass an empty string `""` here.
|
|
421
|
+
* @param senderAddress - Bech32 address of the transaction sender.
|
|
422
|
+
* @param contractAddress - CosmWasm contract address to call.
|
|
423
|
+
* @param msg - JSON execute message sent to the contract.
|
|
424
|
+
* @param memo - Optional transaction memo; falls back to `defaults.defaultMemo` then `""`.
|
|
425
|
+
* @param options - Per-call overrides for defaults (funds, memo, sequence, accountNumber).
|
|
426
|
+
*/
|
|
427
|
+
getRawTransaction(chainId: string, _: string, senderAddress: string, contractAddress: string, msg: JsonObject, memo?: string, options?: InjectiveWalletDefaults): Promise<InjectiveRawTransaction>;
|
|
235
428
|
getWalletAddress(): Promise<InjectiveEoaAddress>;
|
|
236
429
|
getWalletPubKey(): Promise<string>;
|
|
237
|
-
execute(senderAddress: string, contractAddress: string, msg: JsonObject, funds?: InjectiveCoin[]): Promise<InjectiveExecuteResponse>;
|
|
430
|
+
execute(senderAddress: string, contractAddress: string, msg: JsonObject, funds?: InjectiveCoin[], options?: InjectiveWalletDefaults): Promise<InjectiveExecuteResponse>;
|
|
238
431
|
}
|
|
239
432
|
|
|
240
433
|
interface WalletContextState {
|
|
241
434
|
publicKey: PublicKey | null;
|
|
242
435
|
signTransaction: SignerWalletAdapterProps['signTransaction'] | undefined;
|
|
243
436
|
}
|
|
437
|
+
/** Defaults applied to every call. Per-call options shallow-merge over these. */
|
|
438
|
+
type SolanaWalletDefaults = {
|
|
439
|
+
/** Commitment for `Connection`. Default `'confirmed'`. */
|
|
440
|
+
connectionCommitment?: Commitment;
|
|
441
|
+
/** Full ConnectionConfig (overrides `connectionCommitment` if present). */
|
|
442
|
+
connectionConfig?: ConnectionConfig;
|
|
443
|
+
/** Default `SendOptions` for `sendRawTransaction`. */
|
|
444
|
+
sendOptions?: SendOptions;
|
|
445
|
+
/** Commitment for confirmation polling. Default `'finalized'`. */
|
|
446
|
+
confirmCommitment?: Commitment;
|
|
447
|
+
};
|
|
448
|
+
/** Configuration for constructing a `SolanaWalletProvider` backed by a raw private key. */
|
|
244
449
|
type PrivateKeySolanaWalletConfig = {
|
|
245
450
|
privateKey: Uint8Array;
|
|
246
451
|
endpoint: string;
|
|
452
|
+
defaults?: SolanaWalletDefaults;
|
|
247
453
|
};
|
|
454
|
+
/** Configuration for constructing a `SolanaWalletProvider` backed by a browser-extension wallet adapter. */
|
|
248
455
|
type BrowserExtensionSolanaWalletConfig = {
|
|
249
456
|
wallet: WalletContextState;
|
|
250
457
|
endpoint: string;
|
|
458
|
+
defaults?: SolanaWalletDefaults;
|
|
251
459
|
};
|
|
252
460
|
type SolanaWalletConfig = PrivateKeySolanaWalletConfig | BrowserExtensionSolanaWalletConfig;
|
|
253
|
-
|
|
254
|
-
|
|
461
|
+
|
|
462
|
+
declare class SolanaWalletProvider extends BaseWalletProvider<SolanaWalletDefaults> implements ISolanaWalletProvider {
|
|
463
|
+
readonly chainType: "SOLANA";
|
|
255
464
|
readonly connection: Connection;
|
|
465
|
+
private readonly wallet;
|
|
256
466
|
private readonly isAdapterMode;
|
|
257
467
|
constructor(walletConfig: SolanaWalletConfig);
|
|
258
468
|
waitForConfirmation(signature: string, commitment?: Commitment): Promise<SolanaRpcResponseAndContext<SolanaSignatureResult>>;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
sendTransaction(rawTransaction: Uint8Array | Array<number>): Promise<TransactionSignature>;
|
|
265
|
-
/**
|
|
266
|
-
* Send a raw transaction to the Solana network and wait for confirmation.
|
|
267
|
-
* @param rawTransaction - The raw transaction to send.
|
|
268
|
-
* @param commitment - The commitment level to use. Defaults to 'finalized'.
|
|
269
|
-
* @returns The transaction signature.
|
|
270
|
-
*/
|
|
271
|
-
sendTransactionWithConfirmation(rawTransaction: Uint8Array | Array<number>, commitment?: Commitment): Promise<TransactionSignature>;
|
|
272
|
-
/**
|
|
273
|
-
* Build a v0 versioned transaction.
|
|
274
|
-
* @param instructions - The instructions to include in the transaction.
|
|
275
|
-
* @returns The v0 transaction.
|
|
276
|
-
*/
|
|
469
|
+
sendTransaction(rawTransaction: Uint8Array | Array<number>, options?: SendOptions): Promise<TransactionSignature>;
|
|
470
|
+
sendTransactionWithConfirmation(rawTransaction: Uint8Array | Array<number>, optionsOrCommitment?: Commitment | {
|
|
471
|
+
send?: SendOptions;
|
|
472
|
+
commitment?: Commitment;
|
|
473
|
+
}): Promise<TransactionSignature>;
|
|
277
474
|
buildV0Txn(rawInstructions: SolanaRawTransactionInstruction[]): Promise<SolanaSerializedTransaction>;
|
|
278
475
|
private buildV0TxnWithAdapter;
|
|
279
476
|
private buildV0TxnWithKeypair;
|
|
@@ -296,26 +493,31 @@ interface StellarWalletsKit {
|
|
|
296
493
|
}>;
|
|
297
494
|
}
|
|
298
495
|
type StellarNetwork = 'TESTNET' | 'PUBLIC';
|
|
299
|
-
declare const STELLAR_ERROR_CODES: {
|
|
300
|
-
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
301
|
-
readonly SIGN_TX_ERROR: "SIGN_TX_ERROR";
|
|
302
|
-
readonly TX_RECEIPT_TIMEOUT: "TX_RECEIPT_TIMEOUT";
|
|
303
|
-
readonly SEND_TX_ERROR: "SEND_TX_ERROR";
|
|
304
|
-
readonly INVALID_NETWORK: "INVALID_NETWORK";
|
|
305
|
-
readonly INVALID_PRIVATE_KEY: "INVALID_PRIVATE_KEY";
|
|
306
|
-
};
|
|
307
496
|
type StellarAddress = string;
|
|
497
|
+
/** Defaults applied to every call. Per-call options shallow-merge over these. */
|
|
498
|
+
type StellarWalletDefaults = {
|
|
499
|
+
/** Polling interval (ms) for `waitForTransactionReceipt`. Default `2000`. */
|
|
500
|
+
pollInterval?: number;
|
|
501
|
+
/** Total wait (ms) before timeout. Default `60_000`. Recommended floor `30_000` on mainnet. */
|
|
502
|
+
pollTimeout?: number;
|
|
503
|
+
/** Custom network passphrase (use for FUTURENET / private networks). */
|
|
504
|
+
networkPassphrase?: string;
|
|
505
|
+
};
|
|
506
|
+
/** Configuration for constructing a `StellarWalletProvider` backed by a raw private key. */
|
|
308
507
|
type PrivateKeyStellarWalletConfig = {
|
|
309
508
|
type: 'PRIVATE_KEY';
|
|
310
509
|
privateKey: Hex$1;
|
|
311
510
|
network: StellarNetwork;
|
|
312
511
|
rpcUrl?: string;
|
|
512
|
+
defaults?: StellarWalletDefaults;
|
|
313
513
|
};
|
|
514
|
+
/** Configuration for constructing a `StellarWalletProvider` backed by a browser-extension wallet. */
|
|
314
515
|
type BrowserExtensionStellarWalletConfig = {
|
|
315
516
|
type: 'BROWSER_EXTENSION';
|
|
316
517
|
walletsKit: StellarWalletsKit;
|
|
317
518
|
network: StellarNetwork;
|
|
318
519
|
rpcUrl?: string;
|
|
520
|
+
defaults?: StellarWalletDefaults;
|
|
319
521
|
};
|
|
320
522
|
type StellarWalletConfig = PrivateKeyStellarWalletConfig | BrowserExtensionStellarWalletConfig;
|
|
321
523
|
type StellarPkWallet = {
|
|
@@ -327,6 +529,15 @@ type StellarBrowserExtensionWallet = {
|
|
|
327
529
|
walletsKit: StellarWalletsKit;
|
|
328
530
|
};
|
|
329
531
|
type StellarWallet = StellarPkWallet | StellarBrowserExtensionWallet;
|
|
532
|
+
|
|
533
|
+
declare const STELLAR_ERROR_CODES: {
|
|
534
|
+
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
535
|
+
readonly SIGN_TX_ERROR: "SIGN_TX_ERROR";
|
|
536
|
+
readonly TX_RECEIPT_TIMEOUT: "TX_RECEIPT_TIMEOUT";
|
|
537
|
+
readonly SEND_TX_ERROR: "SEND_TX_ERROR";
|
|
538
|
+
readonly INVALID_NETWORK: "INVALID_NETWORK";
|
|
539
|
+
readonly INVALID_PRIVATE_KEY: "INVALID_PRIVATE_KEY";
|
|
540
|
+
};
|
|
330
541
|
declare class StellarWalletError extends Error {
|
|
331
542
|
readonly code: keyof typeof STELLAR_ERROR_CODES;
|
|
332
543
|
constructor(message: string, code: keyof typeof STELLAR_ERROR_CODES);
|
|
@@ -337,40 +548,117 @@ declare function isStellarPkWallet(wallet: StellarWallet): wallet is StellarPkWa
|
|
|
337
548
|
declare function isStellarBrowserExtensionWallet(wallet: StellarWallet): wallet is StellarBrowserExtensionWallet;
|
|
338
549
|
declare function isValidStellarNetwork(network: string): network is StellarNetwork;
|
|
339
550
|
declare function isValidStellarPrivateKey(privateKey: string): boolean;
|
|
340
|
-
declare class StellarWalletProvider implements IStellarWalletProvider {
|
|
551
|
+
declare class StellarWalletProvider extends BaseWalletProvider<StellarWalletDefaults> implements IStellarWalletProvider {
|
|
552
|
+
readonly chainType: "STELLAR";
|
|
341
553
|
private readonly wallet;
|
|
342
554
|
private readonly server;
|
|
343
555
|
private readonly networkPassphrase;
|
|
344
556
|
constructor(config: StellarWalletConfig);
|
|
345
557
|
getWalletAddress(): Promise<string>;
|
|
558
|
+
/**
|
|
559
|
+
* Signs the given XDR-encoded transaction and returns the signed XDR.
|
|
560
|
+
* @throws {StellarWalletError} with code `SIGN_TX_ERROR` if signing fails.
|
|
561
|
+
*/
|
|
346
562
|
signTransaction(tx: XDR): Promise<XDR>;
|
|
347
|
-
|
|
563
|
+
/**
|
|
564
|
+
* Polls the Horizon server until the transaction is confirmed or the timeout is reached.
|
|
565
|
+
* @throws {StellarWalletError} with code `TX_RECEIPT_TIMEOUT` if the transaction is not found within `pollTimeout` ms.
|
|
566
|
+
*/
|
|
567
|
+
waitForTransactionReceipt(txHash: string, options?: Pick<StellarWalletDefaults, 'pollInterval' | 'pollTimeout'>): Promise<StellarRawTransactionReceipt>;
|
|
348
568
|
}
|
|
349
569
|
|
|
570
|
+
/** Defaults applied to every call. Per-call options shallow-merge over these. */
|
|
571
|
+
type StacksWalletDefaults = {
|
|
572
|
+
/** Network selector. Default `'mainnet'`. */
|
|
573
|
+
network?: 'mainnet' | 'testnet';
|
|
574
|
+
/** Default post-condition mode if not present in tx params. */
|
|
575
|
+
postConditionMode?: PostConditionMode;
|
|
576
|
+
};
|
|
577
|
+
/** Configuration for constructing a `StacksWalletProvider` backed by a raw private key. */
|
|
350
578
|
type PrivateKeyStacksWalletConfig = {
|
|
351
579
|
privateKey: string;
|
|
352
580
|
endpoint?: string;
|
|
581
|
+
defaults?: StacksWalletDefaults;
|
|
353
582
|
};
|
|
583
|
+
/** Configuration for constructing a `StacksWalletProvider` backed by a browser-extension wallet. */
|
|
354
584
|
type BrowserExtensionStacksWalletConfig = {
|
|
355
585
|
address: string;
|
|
356
586
|
endpoint?: string;
|
|
357
587
|
provider?: StacksProvider;
|
|
588
|
+
defaults?: StacksWalletDefaults;
|
|
358
589
|
};
|
|
359
590
|
type StacksWalletConfig = PrivateKeyStacksWalletConfig | BrowserExtensionStacksWalletConfig;
|
|
591
|
+
type StacksPkWallet = {
|
|
592
|
+
type: 'PRIVATE_KEY';
|
|
593
|
+
privateKey: string;
|
|
594
|
+
};
|
|
595
|
+
type StacksBrowserExtensionWallet = {
|
|
596
|
+
type: 'BROWSER_EXTENSION';
|
|
597
|
+
address: string;
|
|
598
|
+
provider?: StacksProvider;
|
|
599
|
+
};
|
|
600
|
+
type StacksWallet = StacksPkWallet | StacksBrowserExtensionWallet;
|
|
601
|
+
|
|
360
602
|
declare function isPrivateKeyStacksWalletConfig(config: StacksWalletConfig): config is PrivateKeyStacksWalletConfig;
|
|
361
603
|
declare function isBrowserExtensionStacksWalletConfig(config: StacksWalletConfig): config is BrowserExtensionStacksWalletConfig;
|
|
362
|
-
declare class StacksWalletProvider implements IStacksWalletProvider {
|
|
604
|
+
declare class StacksWalletProvider extends BaseWalletProvider<StacksWalletDefaults> implements IStacksWalletProvider {
|
|
605
|
+
readonly chainType: "STACKS";
|
|
363
606
|
private readonly network;
|
|
364
607
|
private readonly wallet;
|
|
365
608
|
constructor(config: StacksWalletConfig);
|
|
366
|
-
sendTransaction(txParams: StacksTransactionParams): Promise<string>;
|
|
609
|
+
sendTransaction(txParams: StacksTransactionParams, options?: Pick<StacksWalletDefaults, 'postConditionMode'>): Promise<string>;
|
|
367
610
|
private sendTransactionWithPrivateKey;
|
|
368
611
|
private sendTransactionWithAdapter;
|
|
369
612
|
readContract(txParams: StacksTransactionParams): Promise<ClarityValue>;
|
|
370
613
|
getWalletAddress(): Promise<string>;
|
|
614
|
+
getPublicKey(): Promise<string>;
|
|
615
|
+
/**
|
|
616
|
+
* Returns the STX balance for the given address in micro-STX.
|
|
617
|
+
* @warning Network and fetch errors are silently swallowed — `0n` is returned on failure.
|
|
618
|
+
* Callers cannot distinguish "zero balance" from "fetch failed"; treat `0n` accordingly.
|
|
619
|
+
*/
|
|
371
620
|
getBalance(address: string): Promise<bigint>;
|
|
372
621
|
}
|
|
373
622
|
|
|
623
|
+
type NearTxExecutionStatus = 'NONE' | 'INCLUDED' | 'EXECUTED_OPTIMISTIC' | 'INCLUDED_FINAL' | 'EXECUTED' | 'FINAL';
|
|
624
|
+
/** Defaults applied to every call. Per-call options shallow-merge over these. */
|
|
625
|
+
type NearWalletDefaults = {
|
|
626
|
+
/** Throw on failure flag for `signAndSendTransaction` (PK path). Default `true`. */
|
|
627
|
+
throwOnFailure?: boolean;
|
|
628
|
+
/** Wait-until status for confirmation. Default `'FINAL'`. */
|
|
629
|
+
waitUntil?: NearTxExecutionStatus;
|
|
630
|
+
/** Default gas if tx omits. */
|
|
631
|
+
gasDefault?: bigint;
|
|
632
|
+
/** Default deposit if tx omits. */
|
|
633
|
+
depositDefault?: bigint;
|
|
634
|
+
};
|
|
635
|
+
/** Configuration for constructing a `NearWalletProvider` backed by a raw private key. */
|
|
636
|
+
type PrivateKeyNearWalletConfig = {
|
|
637
|
+
rpcUrl: string;
|
|
638
|
+
accountId: string;
|
|
639
|
+
privateKey: string;
|
|
640
|
+
defaults?: NearWalletDefaults;
|
|
641
|
+
};
|
|
642
|
+
/** Configuration for constructing a `NearWalletProvider` backed by a browser-extension wallet. */
|
|
643
|
+
type BrowserExtensionNearWalletConfig = {
|
|
644
|
+
wallet: NearConnector;
|
|
645
|
+
defaults?: NearWalletDefaults;
|
|
646
|
+
};
|
|
647
|
+
type NearWalletConfig = PrivateKeyNearWalletConfig | BrowserExtensionNearWalletConfig;
|
|
648
|
+
|
|
649
|
+
declare function isPrivateKeyNearWalletConfig(config: NearWalletConfig): config is PrivateKeyNearWalletConfig;
|
|
650
|
+
declare function isBrowserExtensionNearWalletConfig(config: NearWalletConfig): config is BrowserExtensionNearWalletConfig;
|
|
651
|
+
declare class NearWalletProvider extends BaseWalletProvider<NearWalletDefaults> implements INearWalletProvider {
|
|
652
|
+
readonly chainType: "NEAR";
|
|
653
|
+
readonly account?: Account$1;
|
|
654
|
+
readonly rpcProvider?: JsonRpcProvider;
|
|
655
|
+
private readonly wallet?;
|
|
656
|
+
constructor(config: NearWalletConfig);
|
|
657
|
+
getWalletAddress(): Promise<string>;
|
|
658
|
+
getRawTransaction(params: CallContractParams): Promise<NearRawTransaction>;
|
|
659
|
+
signAndSubmitTxn(transaction: NearRawTransaction, options?: NearWalletDefaults): Promise<string>;
|
|
660
|
+
}
|
|
661
|
+
|
|
374
662
|
type BitcoinNetwork = 'TESTNET' | 'MAINNET';
|
|
375
663
|
interface BitcoinWalletsKit {
|
|
376
664
|
getAccounts(): Promise<string[]>;
|
|
@@ -383,71 +671,69 @@ interface BitcoinWalletsKit {
|
|
|
383
671
|
getPublicKey(): Promise<string>;
|
|
384
672
|
sendBitcoin?(toAddress: string, satoshis: number): Promise<string>;
|
|
385
673
|
}
|
|
674
|
+
/** Defaults applied to every call. Per-call options shallow-merge over these. */
|
|
675
|
+
type BitcoinWalletDefaults = {
|
|
676
|
+
/** Default `finalize` flag for `signTransaction`. Default `true`. */
|
|
677
|
+
defaultFinalize?: boolean;
|
|
678
|
+
};
|
|
679
|
+
/** Configuration for constructing a `BitcoinWalletProvider` backed by a raw private key. */
|
|
386
680
|
type PrivateKeyBitcoinWalletConfig = {
|
|
387
681
|
type: 'PRIVATE_KEY';
|
|
388
682
|
privateKey: Hex$1;
|
|
389
683
|
network: BitcoinNetwork;
|
|
390
|
-
addressType?:
|
|
684
|
+
addressType?: BtcAddressType;
|
|
685
|
+
defaults?: BitcoinWalletDefaults;
|
|
391
686
|
};
|
|
687
|
+
/** Configuration for constructing a `BitcoinWalletProvider` backed by a browser-extension wallet. */
|
|
392
688
|
type BrowserExtensionBitcoinWalletConfig = {
|
|
393
689
|
type: 'BROWSER_EXTENSION';
|
|
394
690
|
walletsKit: BitcoinWalletsKit;
|
|
395
691
|
network: BitcoinNetwork;
|
|
692
|
+
defaults?: BitcoinWalletDefaults;
|
|
396
693
|
};
|
|
397
694
|
type BitcoinWalletConfig = PrivateKeyBitcoinWalletConfig | BrowserExtensionBitcoinWalletConfig;
|
|
695
|
+
type BitcoinPkWallet = {
|
|
696
|
+
type: 'PRIVATE_KEY';
|
|
697
|
+
keyPair: ECPairInterface;
|
|
698
|
+
addressType: BtcAddressType;
|
|
699
|
+
};
|
|
700
|
+
type BitcoinBrowserWallet = {
|
|
701
|
+
type: 'BROWSER_EXTENSION';
|
|
702
|
+
walletsKit: BitcoinWalletsKit;
|
|
703
|
+
};
|
|
704
|
+
type BitcoinWallet = BitcoinPkWallet | BitcoinBrowserWallet;
|
|
705
|
+
|
|
398
706
|
declare class BitcoinWalletError extends Error {
|
|
399
707
|
constructor(message: string);
|
|
400
708
|
}
|
|
401
|
-
declare class BitcoinWalletProvider implements IBitcoinWalletProvider {
|
|
709
|
+
declare class BitcoinWalletProvider extends BaseWalletProvider<BitcoinWalletDefaults> implements IBitcoinWalletProvider {
|
|
710
|
+
readonly chainType: "BITCOIN";
|
|
402
711
|
private readonly wallet;
|
|
403
712
|
private readonly network;
|
|
404
713
|
constructor(config: BitcoinWalletConfig);
|
|
405
714
|
getWalletAddress(): Promise<string>;
|
|
715
|
+
/**
|
|
716
|
+
* Returns the public key as a hex string.
|
|
717
|
+
* Private-key mode: returns the 32-byte x-only pubkey for P2TR addresses, or the full
|
|
718
|
+
* 33-byte compressed pubkey for all other address types.
|
|
719
|
+
* Browser-extension mode: delegates to the wallet kit's `getPublicKey()`.
|
|
720
|
+
*/
|
|
406
721
|
getPublicKey(): Promise<string>;
|
|
407
|
-
getAddressType(address: string): Promise<
|
|
722
|
+
getAddressType(address: string): Promise<BtcAddressType>;
|
|
408
723
|
/**
|
|
409
724
|
* Sign PSBT and return fully signed transaction hex
|
|
410
725
|
*/
|
|
411
726
|
signTransaction(psbtBase64: string, finalize?: boolean): Promise<string>;
|
|
727
|
+
private doSignTransaction;
|
|
412
728
|
/**
|
|
413
|
-
* Sign arbitrary message using ECDSA
|
|
414
|
-
*
|
|
729
|
+
* Sign arbitrary message using ECDSA over keccak256(message).
|
|
730
|
+
* Note: uses keccak256 (Ethereum-style) rather than Bitcoin's double-SHA256 standard,
|
|
731
|
+
* making this non-standard for typical Bitcoin message signing. Used for cross-chain withdrawals.
|
|
415
732
|
*/
|
|
416
733
|
signEcdsaMessage(message: string): Promise<string>;
|
|
417
734
|
signBip322Message(message: string): Promise<string>;
|
|
418
|
-
getPayment(keyPair: ECPairInterface, addressType:
|
|
735
|
+
getPayment(keyPair: ECPairInterface, addressType: BtcAddressType): bitcoin.Payment;
|
|
419
736
|
sendBitcoin(toAddress: string, satoshis: bigint): Promise<string>;
|
|
420
737
|
}
|
|
421
738
|
|
|
422
|
-
|
|
423
|
-
* Near Wallet Configuration Types
|
|
424
|
-
*/
|
|
425
|
-
type PrivateKeyNearWalletConfig = {
|
|
426
|
-
rpcUrl: string;
|
|
427
|
-
accountId: string;
|
|
428
|
-
privateKey: string;
|
|
429
|
-
};
|
|
430
|
-
type BrowserExtensionNearWalletConfig = {
|
|
431
|
-
wallet: NearConnector;
|
|
432
|
-
};
|
|
433
|
-
type NearWalletConfig = PrivateKeyNearWalletConfig | BrowserExtensionNearWalletConfig;
|
|
434
|
-
/**
|
|
435
|
-
* Near Type Guards
|
|
436
|
-
*/
|
|
437
|
-
declare function isPrivateKeyNearWalletConfig(config: NearWalletConfig): config is PrivateKeyNearWalletConfig;
|
|
438
|
-
declare function isBrowserExtensionNearWalletConfig(config: NearWalletConfig): config is BrowserExtensionNearWalletConfig;
|
|
439
|
-
/**
|
|
440
|
-
* NearWalletProvider implements INearWalletProvider
|
|
441
|
-
* Supports both private key and browser extension wallet configurations
|
|
442
|
-
*/
|
|
443
|
-
declare class NearWalletProvider implements INearWalletProvider {
|
|
444
|
-
readonly account?: Account$1;
|
|
445
|
-
readonly rpcProvider?: JsonRpcProvider;
|
|
446
|
-
private readonly wallet?;
|
|
447
|
-
constructor(config: NearWalletConfig);
|
|
448
|
-
getWalletAddress(): Promise<string>;
|
|
449
|
-
getRawTransaction(params: CallContractParams): Promise<NearRawTransaction>;
|
|
450
|
-
signAndSubmitTxn(transaction: NearRawTransaction): Promise<string>;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
export { BigNumberToBigInt, type BitcoinNetwork, type BitcoinWalletConfig, BitcoinWalletError, BitcoinWalletProvider, type BitcoinWalletsKit, type BrowserExtensionBitcoinWalletConfig, type BrowserExtensionEvmWalletConfig, type BrowserExtensionIconWalletConfig, type BrowserExtensionInjectiveWalletConfig, type BrowserExtensionNearWalletConfig, type BrowserExtensionSolanaWalletConfig, type BrowserExtensionStacksWalletConfig, type BrowserExtensionStellarWalletConfig, type BrowserExtensionSuiWallet, type BrowserExtensionSuiWalletConfig, type EvmWalletConfig, EvmWalletProvider, type HanaWalletRequestEvent, type HanaWalletResponseEvent, type Hash, type Hex, type IconAddress, type IconBrowserExtensionWallet, type IconEoaAddress, type IconJsonRpcVersion, type IconPkWallet, type IconWallet, type IconWalletConfig, IconWalletProvider, type InjectiveWallet, type InjectiveWalletConfig, InjectiveWalletProvider, type JsonRpcPayloadResponse, type NearWalletConfig, NearWalletProvider, type PkSuiWallet, type PrivateKeyBitcoinWalletConfig, type PrivateKeyEvmWalletConfig, type PrivateKeyIconWalletConfig, type PrivateKeyNearWalletConfig, type PrivateKeySolanaWalletConfig, type PrivateKeyStacksWalletConfig, type PrivateKeyStellarWalletConfig, type PrivateKeySuiWalletConfig, type RelayRequestDetail, type RelayRequestSigning, type ResponseAddressType, type ResponseSigningType, type SecretInjectiveWalletConfig, type SolanaWalletConfig, SolanaWalletProvider, type StacksWalletConfig, StacksWalletProvider, type StellarAddress, type StellarBrowserExtensionWallet, type StellarNetwork, type StellarPkWallet, type StellarWallet, type StellarWalletConfig, StellarWalletError, StellarWalletProvider, type SuiWallet, type SuiWalletConfig, SuiWalletProvider, getEvmViemChain, hyper, isBrowserExtensionEvmWalletConfig, isBrowserExtensionIconWalletConfig, isBrowserExtensionInjectiveWalletConfig, isBrowserExtensionNearWalletConfig, isBrowserExtensionStacksWalletConfig, isBrowserExtensionStellarWalletConfig, isBrowserExtensionSuiWallet, isIconAddress, isIconBrowserExtensionWallet, isIconEoaAddress, isIconPkWallet, isJsonRpcPayloadResponse, isPkSuiWallet, isPrivateKeyEvmWalletConfig, isPrivateKeyIconWalletConfig, isPrivateKeyNearWalletConfig, isPrivateKeyStacksWalletConfig, isPrivateKeyStellarWalletConfig, isResponseAddressType, isResponseSigningType, isSecretInjectiveWalletConfig, isStellarBrowserExtensionWallet, isStellarPkWallet, isSuiWallet, isValidStellarNetwork, isValidStellarPrivateKey, requestAddress, requestJsonRpc, requestSigning };
|
|
739
|
+
export { BaseWalletProvider, BigNumberToBigInt, type BitcoinBrowserWallet, type BitcoinNetwork, type BitcoinPkWallet, type BitcoinWallet, type BitcoinWalletConfig, type BitcoinWalletDefaults, BitcoinWalletError, BitcoinWalletProvider, type BitcoinWalletsKit, type BrowserExtensionBitcoinWalletConfig, type BrowserExtensionEvmWalletConfig, type BrowserExtensionIconWalletConfig, type BrowserExtensionInjectiveWalletConfig, type BrowserExtensionNearWalletConfig, type BrowserExtensionSolanaWalletConfig, type BrowserExtensionStacksWalletConfig, type BrowserExtensionStellarWalletConfig, type BrowserExtensionSuiWallet, type BrowserExtensionSuiWalletConfig, type EvmSendTransactionPolicy, type EvmWaitForTransactionReceiptPolicy, type EvmWalletConfig, type EvmWalletDefaults, EvmWalletProvider, type HanaWalletRequestEvent, type HanaWalletResponseEvent, type Hash, type Hex, type IconAddress, type IconBrowserExtensionWallet, type IconEoaAddress, type IconJsonRpcVersion, type IconPkWallet, type IconWallet, type IconWalletConfig, type IconWalletDefaults, IconWalletProvider, type InjectiveWallet, type InjectiveWalletConfig, type InjectiveWalletDefaults, InjectiveWalletProvider, type JsonRpcPayloadResponse, type NearTxExecutionStatus, type NearWalletConfig, type NearWalletDefaults, NearWalletProvider, type PkSuiWallet, type PrivateKeyBitcoinWalletConfig, type PrivateKeyEvmWalletConfig, type PrivateKeyIconWalletConfig, type PrivateKeyNearWalletConfig, type PrivateKeySolanaWalletConfig, type PrivateKeyStacksWalletConfig, type PrivateKeyStellarWalletConfig, type PrivateKeySuiWalletConfig, type RelayRequestDetail, type RelayRequestSigning, type ResponseAddressType, type ResponseSigningType, type SecretInjectiveWalletConfig, type SolanaWalletConfig, type SolanaWalletDefaults, SolanaWalletProvider, type StacksBrowserExtensionWallet, type StacksPkWallet, type StacksWallet, type StacksWalletConfig, type StacksWalletDefaults, StacksWalletProvider, type StellarAddress, type StellarBrowserExtensionWallet, type StellarNetwork, type StellarPkWallet, type StellarWallet, type StellarWalletConfig, type StellarWalletDefaults, StellarWalletError, StellarWalletProvider, type StellarWalletsKit, type SuiGetCoinsPolicy, type SuiSignAndExecutePolicy, type SuiWallet, type SuiWalletConfig, type SuiWalletDefaults, SuiWalletProvider, type WalletContextState, getEvmViemChain, hyper, isBrowserExtensionEvmWalletConfig, isBrowserExtensionIconWalletConfig, isBrowserExtensionInjectiveWalletConfig, isBrowserExtensionNearWalletConfig, isBrowserExtensionStacksWalletConfig, isBrowserExtensionStellarWalletConfig, isBrowserExtensionSuiWallet, isIconAddress, isIconBrowserExtensionWallet, isIconEoaAddress, isIconPkWallet, isJsonRpcPayloadResponse, isPkSuiWallet, isPrivateKeyEvmWalletConfig, isPrivateKeyIconWalletConfig, isPrivateKeyNearWalletConfig, isPrivateKeyStacksWalletConfig, isPrivateKeyStellarWalletConfig, isResponseAddressType, isResponseSigningType, isSecretInjectiveWalletConfig, isStellarBrowserExtensionWallet, isStellarPkWallet, isValidStellarNetwork, isValidStellarPrivateKey, requestAddress, requestJsonRpc, requestSigning };
|