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