@sodax/wallet-sdk-core 2.0.0-rc.2 → 2.0.0-rc.4
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 +1 -2
- package/dist/index.cjs +1 -4
- package/dist/index.mjs +1 -4
- package/package.json +18 -11
- package/ai-exported/AGENTS.md +0 -139
- package/ai-exported/integration/README.md +0 -108
- package/ai-exported/integration/ai-rules.md +0 -141
- package/ai-exported/integration/architecture.md +0 -212
- package/ai-exported/integration/features/README.md +0 -22
- package/ai-exported/integration/features/bitcoin.md +0 -103
- package/ai-exported/integration/features/evm.md +0 -102
- package/ai-exported/integration/features/icon.md +0 -88
- package/ai-exported/integration/features/injective.md +0 -92
- package/ai-exported/integration/features/near.md +0 -92
- package/ai-exported/integration/features/solana.md +0 -104
- package/ai-exported/integration/features/stacks.md +0 -91
- package/ai-exported/integration/features/stellar.md +0 -95
- package/ai-exported/integration/features/sui.md +0 -96
- package/ai-exported/integration/quickstart.md +0 -259
- package/ai-exported/integration/recipes/README.md +0 -15
- package/ai-exported/integration/recipes/bridge-to-sdk.md +0 -145
- package/ai-exported/integration/recipes/defaults-and-overrides.md +0 -159
- package/ai-exported/integration/recipes/library-exports.md +0 -129
- package/ai-exported/integration/recipes/setup-browser-extension.md +0 -137
- package/ai-exported/integration/recipes/setup-private-key.md +0 -115
- package/ai-exported/integration/recipes/sign-and-broadcast.md +0 -201
- package/ai-exported/integration/recipes/testing.md +0 -163
- package/ai-exported/integration/reference/README.md +0 -13
- package/ai-exported/integration/reference/chain-support.md +0 -65
- package/ai-exported/integration/reference/glossary.md +0 -28
- package/ai-exported/integration/reference/interfaces.md +0 -131
- package/ai-exported/integration/reference/provider-classes.md +0 -54
- package/ai-exported/integration/reference/public-api.md +0 -128
- package/ai-exported/migration/README.md +0 -84
- package/ai-exported/migration/ai-rules.md +0 -139
- package/ai-exported/migration/breaking-changes/README.md +0 -14
- package/ai-exported/migration/breaking-changes/base-wallet-provider.md +0 -52
- package/ai-exported/migration/breaking-changes/defaults-config.md +0 -57
- package/ai-exported/migration/breaking-changes/folder-layout.md +0 -99
- package/ai-exported/migration/breaking-changes/library-exports.md +0 -58
- package/ai-exported/migration/checklist.md +0 -62
- package/ai-exported/migration/recipes/README.md +0 -12
- package/ai-exported/migration/recipes/adopt-defaults.md +0 -84
- package/ai-exported/migration/recipes/adopt-library-exports.md +0 -99
- package/ai-exported/migration/reference/README.md +0 -12
- package/ai-exported/migration/reference/added-fields.md +0 -71
- package/ai-exported/migration/reference/deleted-exports.md +0 -35
- package/ai-exported/migration/reference/renamed-symbols.md +0 -31
- package/ai-exported/migration/reference/return-shapes.md +0 -23
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# NEAR — `NearWalletProvider`
|
|
2
|
-
|
|
3
|
-
Backed by `near-api-js` (PK signing) and `@hot-labs/near-connect` (browser-extension `NearConnector`).
|
|
4
|
-
|
|
5
|
-
| | |
|
|
6
|
-
|---|---|
|
|
7
|
-
| Class | `NearWalletProvider` |
|
|
8
|
-
| Interface | `INearWalletProvider` (from `@sodax/types`) |
|
|
9
|
-
| Discriminant style | **Field presence** (no `type` field) |
|
|
10
|
-
| Underlying SDK | `near-api-js`, `@hot-labs/near-connect` |
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Config
|
|
15
|
-
|
|
16
|
-
```ts
|
|
17
|
-
type NearWalletConfig = PrivateKeyNearWalletConfig | BrowserExtensionNearWalletConfig;
|
|
18
|
-
|
|
19
|
-
type PrivateKeyNearWalletConfig = {
|
|
20
|
-
rpcUrl: string;
|
|
21
|
-
accountId: string; // e.g. 'alice.near'
|
|
22
|
-
privateKey: string; // 'ed25519:…' format
|
|
23
|
-
defaults?: NearWalletDefaults;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
type BrowserExtensionNearWalletConfig = {
|
|
27
|
-
wallet: NearConnector; // from @hot-labs/near-connect
|
|
28
|
-
defaults?: NearWalletDefaults;
|
|
29
|
-
};
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
| Mode discriminant | How to detect |
|
|
33
|
-
|---|---|
|
|
34
|
-
| Private-key | `'privateKey' in config` (also `accountId`, `rpcUrl`) |
|
|
35
|
-
| Browser-extension | `'wallet' in config` |
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## `NearWalletDefaults`
|
|
40
|
-
|
|
41
|
-
```ts
|
|
42
|
-
type NearWalletDefaults = {
|
|
43
|
-
throwOnFailure?: boolean; // default true — PK path only
|
|
44
|
-
waitUntil?: NearTxExecutionStatus; // default 'FINAL'
|
|
45
|
-
gasDefault?: bigint; // applied if tx omits gas
|
|
46
|
-
depositDefault?: bigint; // applied if tx omits deposit
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
type NearTxExecutionStatus =
|
|
50
|
-
| 'NONE' | 'INCLUDED' | 'EXECUTED_OPTIMISTIC' | 'INCLUDED_FINAL' | 'EXECUTED' | 'FINAL';
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## Methods
|
|
56
|
-
|
|
57
|
-
| Method | Signature | Returns |
|
|
58
|
-
|---|---|---|
|
|
59
|
-
| `getWalletAddress` | `() => Promise<string>` | accountId (e.g. `alice.near`) |
|
|
60
|
-
| `getRawTransaction` | `(params: CallContractParams) => Promise<NearRawTransaction>` | unsigned tx — useful for inspection |
|
|
61
|
-
| `signAndSubmitTxn` | `(transaction: NearRawTransaction, options?: NearWalletDefaults) => Promise<string>` | tx hash |
|
|
62
|
-
|
|
63
|
-
`signAndSubmitTxn` merges `defaults` (flat) over per-call `options`.
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## Public fields
|
|
68
|
-
|
|
69
|
-
| Field | Type | Notes |
|
|
70
|
-
|---|---|---|
|
|
71
|
-
| `chainType` | `'NEAR'` (literal) | Discriminant. |
|
|
72
|
-
| `account` | `Account \| undefined` | PK mode only — `near-api-js` `Account`. |
|
|
73
|
-
| `rpcProvider` | `JsonRpcProvider \| undefined` | PK mode only. |
|
|
74
|
-
|
|
75
|
-
`wallet` (`NearConnector`) is private. Browser-extension mode exposes neither `account` nor `rpcProvider`.
|
|
76
|
-
|
|
77
|
-
---
|
|
78
|
-
|
|
79
|
-
## Gotchas
|
|
80
|
-
|
|
81
|
-
- **`privateKey` is the full `ed25519:…` string**, not just the bytes. NEAR stores keys with the algorithm prefix.
|
|
82
|
-
- **`accountId` is mandatory in PK mode.** NEAR keys don't determine the account — accounts can hold multiple keys. The provider needs both.
|
|
83
|
-
- **`waitUntil` defaults to `'FINAL'`.** Slowest but safest. Lower (`'EXECUTED'`) for faster scripts, with the usual caveats about reverts.
|
|
84
|
-
- **Browser-extension mode uses `@hot-labs/near-connect`'s `NearConnector`.** It already abstracts over multiple NEAR wallets (Meteor, MyNearWallet, …) — pass the connector instance, not a lower-level wallet object.
|
|
85
|
-
|
|
86
|
-
---
|
|
87
|
-
|
|
88
|
-
## See also
|
|
89
|
-
|
|
90
|
-
- [`recipes/setup-private-key.md`](../recipes/setup-private-key.md)
|
|
91
|
-
- [`recipes/setup-browser-extension.md`](../recipes/setup-browser-extension.md)
|
|
92
|
-
- [`recipes/sign-and-broadcast.md`](../recipes/sign-and-broadcast.md)
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
# Solana — `SolanaWalletProvider`
|
|
2
|
-
|
|
3
|
-
Backed by `@solana/web3.js` and `@solana/wallet-adapter-base` interfaces.
|
|
4
|
-
|
|
5
|
-
| | |
|
|
6
|
-
|---|---|
|
|
7
|
-
| Class | `SolanaWalletProvider` |
|
|
8
|
-
| Interface | `ISolanaWalletProvider` (from `@sodax/types`) |
|
|
9
|
-
| Discriminant style | **Field presence** (no `type` field) |
|
|
10
|
-
| Underlying SDK | `@solana/web3.js` |
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Config
|
|
15
|
-
|
|
16
|
-
```ts
|
|
17
|
-
type SolanaWalletConfig = PrivateKeySolanaWalletConfig | BrowserExtensionSolanaWalletConfig;
|
|
18
|
-
|
|
19
|
-
type PrivateKeySolanaWalletConfig = {
|
|
20
|
-
privateKey: Uint8Array; // secret key bytes — usually length 64
|
|
21
|
-
endpoint: string; // RPC URL
|
|
22
|
-
defaults?: SolanaWalletDefaults;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
type BrowserExtensionSolanaWalletConfig = {
|
|
26
|
-
wallet: WalletContextState; // { publicKey, signTransaction }
|
|
27
|
-
endpoint: string;
|
|
28
|
-
defaults?: SolanaWalletDefaults;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
interface WalletContextState {
|
|
32
|
-
publicKey: PublicKey | null;
|
|
33
|
-
signTransaction: SignerWalletAdapterProps['signTransaction'] | undefined;
|
|
34
|
-
}
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
| Mode discriminant | How to detect |
|
|
38
|
-
|---|---|
|
|
39
|
-
| Private-key | `'privateKey' in config` |
|
|
40
|
-
| Browser-extension | `'wallet' in config` |
|
|
41
|
-
|
|
42
|
-
---
|
|
43
|
-
|
|
44
|
-
## `SolanaWalletDefaults`
|
|
45
|
-
|
|
46
|
-
```ts
|
|
47
|
-
type SolanaWalletDefaults = {
|
|
48
|
-
connectionCommitment?: Commitment; // for Connection ctor — default 'confirmed'
|
|
49
|
-
connectionConfig?: ConnectionConfig; // overrides connectionCommitment if present
|
|
50
|
-
sendOptions?: SendOptions; // default for sendRawTransaction
|
|
51
|
-
confirmCommitment?: Commitment; // for confirmation polling — default 'finalized'
|
|
52
|
-
};
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
`connectionConfig` is the full ConnectionConfig — if you set it, `connectionCommitment` is ignored.
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
## Methods
|
|
60
|
-
|
|
61
|
-
| Method | Signature | Returns |
|
|
62
|
-
|---|---|---|
|
|
63
|
-
| `getWalletAddress` | `() => Promise<string>` | base58 public key |
|
|
64
|
-
| `getWalletBase58PublicKey` | `() => SolanaBase58PublicKey` | synchronous public key |
|
|
65
|
-
| `sendTransaction` | `(rawTx: SolanaSerializedTransaction, options?: SendOptions) => Promise<string>` | signature |
|
|
66
|
-
| `sendTransactionWithConfirmation` | `(rawTx, sendOptions?, confirmCommitment?) => Promise<string>` | signature, after confirmation |
|
|
67
|
-
| `waitForConfirmation` | `(signature, commitment?) => Promise<…>` | confirmation status |
|
|
68
|
-
| `buildV0Txn` | `(rawInstructions: SolanaRawTransactionInstruction[]) => Promise<SolanaSerializedTransaction>` | serialised v0 transaction |
|
|
69
|
-
| `getAssociatedTokenAddress` | `(mint) => Promise<SolanaBase58PublicKey>` | derived ATA |
|
|
70
|
-
| `getBalance` | `(publicKey) => Promise<number>` | lamports |
|
|
71
|
-
| `getTokenAccountBalance` | `(publicKey) => Promise<RpcResponseAndContext<TokenAmount>>` | SPL balance |
|
|
72
|
-
|
|
73
|
-
Default slice merging:
|
|
74
|
-
- `defaults.sendOptions` → merged into `sendTransaction(_, options)`.
|
|
75
|
-
- `defaults.confirmCommitment` → falls back when `sendTransactionWithConfirmation(_, _, commit)` is undefined.
|
|
76
|
-
- `defaults.connectionCommitment` / `defaults.connectionConfig` → used at construction time only.
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
## Public fields
|
|
81
|
-
|
|
82
|
-
| Field | Type | Notes |
|
|
83
|
-
|---|---|---|
|
|
84
|
-
| `chainType` | `'SOLANA'` (literal) | Discriminant. |
|
|
85
|
-
| `connection` | `Connection` | The web3.js Connection, derived from `endpoint` + defaults. |
|
|
86
|
-
|
|
87
|
-
`wallet` (Keypair or `WalletContextState`) is private — call provider methods instead.
|
|
88
|
-
|
|
89
|
-
---
|
|
90
|
-
|
|
91
|
-
## Gotchas
|
|
92
|
-
|
|
93
|
-
- **`buildV0Txn` is the canonical path for building transactions.** It picks the keypair-vs-adapter signing path internally based on construction mode. Don't construct transactions yourself.
|
|
94
|
-
- **`WalletContextState.signTransaction` is allowed to be `undefined`.** This mirrors `@solana/wallet-adapter-base` — the adapter may not implement signing for all flows. The provider throws at signing time if `signTransaction` is missing.
|
|
95
|
-
- **`confirmCommitment` defaults to `'finalized'`.** Slow but safe. Lower (`'confirmed'`) for faster UX, with the usual finality caveats.
|
|
96
|
-
- **`endpoint` is a required field.** There is no public-RPC fallback like EVM has.
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## See also
|
|
101
|
-
|
|
102
|
-
- [`recipes/setup-private-key.md`](../recipes/setup-private-key.md)
|
|
103
|
-
- [`recipes/setup-browser-extension.md`](../recipes/setup-browser-extension.md)
|
|
104
|
-
- [`recipes/sign-and-broadcast.md`](../recipes/sign-and-broadcast.md)
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# Stacks — `StacksWalletProvider`
|
|
2
|
-
|
|
3
|
-
Backed by `@stacks/transactions` and `@stacks/connect` (browser-extension `StacksProvider`).
|
|
4
|
-
|
|
5
|
-
| | |
|
|
6
|
-
|---|---|
|
|
7
|
-
| Class | `StacksWalletProvider` |
|
|
8
|
-
| Interface | `IStacksWalletProvider` (from `@sodax/types`) |
|
|
9
|
-
| Discriminant style | **Field presence** (no `type` field) |
|
|
10
|
-
| Underlying SDK | `@stacks/transactions`, `@stacks/connect`, `@stacks/network` |
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Config
|
|
15
|
-
|
|
16
|
-
```ts
|
|
17
|
-
type StacksWalletConfig = PrivateKeyStacksWalletConfig | BrowserExtensionStacksWalletConfig;
|
|
18
|
-
|
|
19
|
-
type PrivateKeyStacksWalletConfig = {
|
|
20
|
-
privateKey: string;
|
|
21
|
-
endpoint?: string; // Stacks API endpoint
|
|
22
|
-
defaults?: StacksWalletDefaults;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
type BrowserExtensionStacksWalletConfig = {
|
|
26
|
-
address: string; // 'SP…' (mainnet) or 'ST…' (testnet)
|
|
27
|
-
endpoint?: string;
|
|
28
|
-
provider?: StacksProvider; // from @stacks/connect — optional
|
|
29
|
-
defaults?: StacksWalletDefaults;
|
|
30
|
-
};
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
| Mode discriminant | How to detect |
|
|
34
|
-
|---|---|
|
|
35
|
-
| Private-key | `'privateKey' in config` |
|
|
36
|
-
| Browser-extension | `'address' in config` (no `privateKey`) |
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## `StacksWalletDefaults`
|
|
41
|
-
|
|
42
|
-
```ts
|
|
43
|
-
type StacksWalletDefaults = {
|
|
44
|
-
network?: 'mainnet' | 'testnet'; // default 'mainnet'
|
|
45
|
-
postConditionMode?: PostConditionMode;
|
|
46
|
-
};
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
`PostConditionMode` is re-exported as a runtime value from this package — see [`recipes/library-exports.md`](../recipes/library-exports.md).
|
|
50
|
-
|
|
51
|
-
---
|
|
52
|
-
|
|
53
|
-
## Methods
|
|
54
|
-
|
|
55
|
-
| Method | Signature | Returns |
|
|
56
|
-
|---|---|---|
|
|
57
|
-
| `getWalletAddress` | `() => Promise<string>` | Stacks address (`SP…` / `ST…`) |
|
|
58
|
-
| `getPublicKey` | `() => Promise<string>` | hex pubkey |
|
|
59
|
-
| `sendTransaction` | `(params: StacksTransactionParams) => Promise<…>` | tx response |
|
|
60
|
-
| `readContract` | `(txParams: StacksTransactionParams) => Promise<ClarityValue>` | read-only call result |
|
|
61
|
-
| `getBalance` | `(address: string) => Promise<bigint>` | STX micro-balance |
|
|
62
|
-
|
|
63
|
-
Internally `sendTransaction` dispatches to `sendTransactionWithPrivateKey` or `sendTransactionWithAdapter` based on construction mode.
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## Public fields
|
|
68
|
-
|
|
69
|
-
| Field | Type | Notes |
|
|
70
|
-
|---|---|---|
|
|
71
|
-
| `chainType` | `'STACKS'` (literal) | Discriminant. |
|
|
72
|
-
|
|
73
|
-
`network` (`StacksNetwork`) and `wallet` are private.
|
|
74
|
-
|
|
75
|
-
---
|
|
76
|
-
|
|
77
|
-
## Gotchas
|
|
78
|
-
|
|
79
|
-
- **`endpoint` is optional.** Defaults to the Hiro mainnet/testnet API URL depending on `network`. Override for private RPCs.
|
|
80
|
-
- **`provider` (StacksProvider) is optional in browser-extension mode.** When omitted, the provider falls back to the globally-injected `window`-level provider (Leather, Xverse, Asigna). Pass it explicitly for tests or non-injected environments.
|
|
81
|
-
- **`postConditionMode` is a runtime enum.** Import from `@sodax/wallet-sdk-core` (re-exported via `library-exports`) — no need to add `@stacks/transactions` as a direct dep.
|
|
82
|
-
- **Mainnet vs testnet split.** `network: 'mainnet'` resolves to `STACKS_MAINNET`; `'testnet'` to `STACKS_TESTNET`. Cross-environment addresses will reject.
|
|
83
|
-
|
|
84
|
-
---
|
|
85
|
-
|
|
86
|
-
## See also
|
|
87
|
-
|
|
88
|
-
- [`recipes/setup-private-key.md`](../recipes/setup-private-key.md)
|
|
89
|
-
- [`recipes/setup-browser-extension.md`](../recipes/setup-browser-extension.md)
|
|
90
|
-
- [`recipes/sign-and-broadcast.md`](../recipes/sign-and-broadcast.md)
|
|
91
|
-
- [`recipes/library-exports.md`](../recipes/library-exports.md) — `PostConditionMode` enum
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
# Stellar — `StellarWalletProvider`
|
|
2
|
-
|
|
3
|
-
Backed by `@stellar/stellar-sdk` (`Horizon.Server` + Soroban primitives).
|
|
4
|
-
|
|
5
|
-
| | |
|
|
6
|
-
|---|---|
|
|
7
|
-
| Class | `StellarWalletProvider` |
|
|
8
|
-
| Interface | `IStellarWalletProvider` (from `@sodax/types`) |
|
|
9
|
-
| Discriminant style | **Explicit uppercase `type`** (`'PRIVATE_KEY' \| 'BROWSER_EXTENSION'`) |
|
|
10
|
-
| Underlying SDK | `@stellar/stellar-sdk` |
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Config
|
|
15
|
-
|
|
16
|
-
```ts
|
|
17
|
-
type StellarWalletConfig = PrivateKeyStellarWalletConfig | BrowserExtensionStellarWalletConfig;
|
|
18
|
-
|
|
19
|
-
type PrivateKeyStellarWalletConfig = {
|
|
20
|
-
type: 'PRIVATE_KEY';
|
|
21
|
-
privateKey: Hex; // `0x…`
|
|
22
|
-
network: 'TESTNET' | 'PUBLIC';
|
|
23
|
-
rpcUrl?: string; // defaults to a public Horizon URL per network
|
|
24
|
-
defaults?: StellarWalletDefaults;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
type BrowserExtensionStellarWalletConfig = {
|
|
28
|
-
type: 'BROWSER_EXTENSION';
|
|
29
|
-
walletsKit: StellarWalletsKit; // Freighter / xBull / Lobstr adapter
|
|
30
|
-
network: 'TESTNET' | 'PUBLIC';
|
|
31
|
-
rpcUrl?: string;
|
|
32
|
-
defaults?: StellarWalletDefaults;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
interface StellarWalletsKit {
|
|
36
|
-
getAddress(): Promise<{ address: string }>;
|
|
37
|
-
signTransaction(tx: XDR, options: { networkPassphrase: string }): Promise<{ signedTxXdr: XDR }>;
|
|
38
|
-
}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
| Mode discriminant | How to detect |
|
|
42
|
-
|---|---|
|
|
43
|
-
| Private-key | `config.type === 'PRIVATE_KEY'` |
|
|
44
|
-
| Browser-extension | `config.type === 'BROWSER_EXTENSION'` |
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## `StellarWalletDefaults`
|
|
49
|
-
|
|
50
|
-
```ts
|
|
51
|
-
type StellarWalletDefaults = {
|
|
52
|
-
pollInterval?: number; // ms — default 2_000
|
|
53
|
-
pollTimeout?: number; // ms — default 60_000 (≥ 30_000 recommended on mainnet)
|
|
54
|
-
networkPassphrase?: string; // override for FUTURENET / private networks
|
|
55
|
-
};
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Merge strategy: flat (`mergeDefaults`).
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
## Methods
|
|
63
|
-
|
|
64
|
-
| Method | Signature | Returns |
|
|
65
|
-
|---|---|---|
|
|
66
|
-
| `getWalletAddress` | `() => Promise<string>` | Stellar address |
|
|
67
|
-
| `signTransaction` | `(tx: XDR) => Promise<XDR>` | signed XDR |
|
|
68
|
-
| `waitForTransactionReceipt` | `(hash: string, options?: Partial<StellarWalletDefaults>) => Promise<…>` | tx result; respects `pollInterval` / `pollTimeout` |
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
## Public fields
|
|
73
|
-
|
|
74
|
-
| Field | Type | Notes |
|
|
75
|
-
|---|---|---|
|
|
76
|
-
| `chainType` | `'STELLAR'` (literal) | Discriminant. |
|
|
77
|
-
|
|
78
|
-
`wallet`, `server` (`Horizon.Server`), and `networkPassphrase` are private. Pass overrides via `defaults` instead of mutating fields.
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## Gotchas
|
|
83
|
-
|
|
84
|
-
- **`networkPassphrase` is derived from `network`.** Override via `defaults.networkPassphrase` only for FUTURENET or private networks.
|
|
85
|
-
- **`rpcUrl` defaults to a public Horizon endpoint.** Replace with a private RPC for production.
|
|
86
|
-
- **`pollTimeout` floor of 30_000 ms is a strong recommendation, not enforced.** Mainnet confirmation typically takes 5–30 s. Setting it too low surfaces false negatives.
|
|
87
|
-
- **Stellar uses XDR strings** for both transaction input and signed output — the type alias `XDR` is from `@sodax/types`.
|
|
88
|
-
|
|
89
|
-
---
|
|
90
|
-
|
|
91
|
-
## See also
|
|
92
|
-
|
|
93
|
-
- [`recipes/setup-private-key.md`](../recipes/setup-private-key.md)
|
|
94
|
-
- [`recipes/setup-browser-extension.md`](../recipes/setup-browser-extension.md)
|
|
95
|
-
- [`recipes/sign-and-broadcast.md`](../recipes/sign-and-broadcast.md)
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# Sui — `SuiWalletProvider`
|
|
2
|
-
|
|
3
|
-
Backed by `@mysten/sui` and `@mysten/wallet-standard`.
|
|
4
|
-
|
|
5
|
-
| | |
|
|
6
|
-
|---|---|
|
|
7
|
-
| Class | `SuiWalletProvider` |
|
|
8
|
-
| Interface | `ISuiWalletProvider` (from `@sodax/types`) |
|
|
9
|
-
| Discriminant style | **Field presence** (no `type` field) — but uses `mnemonics`, not `privateKey` |
|
|
10
|
-
| Underlying SDK | `@mysten/sui`, `@mysten/wallet-standard` |
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## Config
|
|
15
|
-
|
|
16
|
-
```ts
|
|
17
|
-
type SuiWalletConfig = PrivateKeySuiWalletConfig | BrowserExtensionSuiWalletConfig;
|
|
18
|
-
|
|
19
|
-
type PrivateKeySuiWalletConfig = {
|
|
20
|
-
rpcUrl: string;
|
|
21
|
-
mnemonics: string; // BIP-39 mnemonic — NOT a raw private key
|
|
22
|
-
defaults?: SuiWalletDefaults;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
type BrowserExtensionSuiWalletConfig = {
|
|
26
|
-
client: SuiClient; // pre-built by consumer
|
|
27
|
-
wallet: WalletWithFeatures<Partial<SuiWalletFeatures>>;
|
|
28
|
-
account: WalletAccount; // active account from wallet
|
|
29
|
-
defaults?: SuiWalletDefaults;
|
|
30
|
-
};
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
| Mode discriminant | How to detect |
|
|
34
|
-
|---|---|
|
|
35
|
-
| Private-key | `'mnemonics' in config` |
|
|
36
|
-
| Browser-extension | `'client' in config` (also requires `wallet` + `account`) |
|
|
37
|
-
|
|
38
|
-
Note the name — `PrivateKeySuiWalletConfig` is still called "PrivateKey" for consistency, even though the credential is a mnemonic. The library derives an Ed25519 keypair from the mnemonic phrase.
|
|
39
|
-
|
|
40
|
-
---
|
|
41
|
-
|
|
42
|
-
## `SuiWalletDefaults`
|
|
43
|
-
|
|
44
|
-
```ts
|
|
45
|
-
type SuiWalletDefaults = {
|
|
46
|
-
signAndExecuteTxn?: {
|
|
47
|
-
dryRun?: { enabled?: boolean }; // default: enabled = true
|
|
48
|
-
response?: SuiTransactionBlockResponseOptions;
|
|
49
|
-
};
|
|
50
|
-
getCoins?: { limit?: number };
|
|
51
|
-
};
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## Methods
|
|
57
|
-
|
|
58
|
-
| Method | Signature | Returns | Default slice merged |
|
|
59
|
-
|---|---|---|---|
|
|
60
|
-
| `getWalletAddress` | `() => Promise<string>` | Sui address | — |
|
|
61
|
-
| `signAndExecuteTxn` | `(txn: SuiTransaction, options?: SuiSignAndExecutePolicy) => Promise<string>` | digest | `defaults.signAndExecuteTxn` |
|
|
62
|
-
| `viewContract` | `(txn: SuiTransaction, …) => Promise<…>` | dry-run result | — |
|
|
63
|
-
| `getCoins` | `(address: string, token: string, options?: SuiGetCoinsPolicy) => Promise<SuiPaginatedCoins>` | coin pagination | `defaults.getCoins` |
|
|
64
|
-
|
|
65
|
-
`signAndExecuteTxn` runs a **pre-flight dry-run by default**. Disable only when paying gas for a doomed tx is acceptable:
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
await provider.signAndExecuteTxn(tx, { dryRun: { enabled: false } });
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## Public fields
|
|
74
|
-
|
|
75
|
-
| Field | Type | Notes |
|
|
76
|
-
|---|---|---|
|
|
77
|
-
| `chainType` | `'SUI'` (literal) | Discriminant. |
|
|
78
|
-
|
|
79
|
-
The internal `client: SuiClient` and `wallet: SuiWallet` are private.
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
## Gotchas
|
|
84
|
-
|
|
85
|
-
- **Browser-extension mode requires THREE objects.** Many wallet adapters expose `client` + `wallet` but not the active `account`. Fetch it via `wallet.accounts[0]` or your adapter's "current account" API before constructing the provider.
|
|
86
|
-
- **Mnemonic is the only private-key option.** There is no raw-secret-key constructor. If you have a 32-byte key bytes you must convert it to a mnemonic upstream (or fork the provider).
|
|
87
|
-
- **Dry-run is on by default for safety.** Production scripts almost never want to disable it.
|
|
88
|
-
- **`response` options forward to the underlying SuiClient call.** In PK mode that's `signAndExecuteTransaction`; in browser-extension mode it's `executeTransactionBlock`. Same option shape (`SuiTransactionBlockResponseOptions`).
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## See also
|
|
93
|
-
|
|
94
|
-
- [`recipes/setup-private-key.md`](../recipes/setup-private-key.md)
|
|
95
|
-
- [`recipes/setup-browser-extension.md`](../recipes/setup-browser-extension.md)
|
|
96
|
-
- [`recipes/sign-and-broadcast.md`](../recipes/sign-and-broadcast.md)
|