@sodax/skills 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/.claude-plugin/plugin.json +13 -0
- package/AGENTS.md +81 -0
- package/LICENSE +21 -0
- package/README.md +49 -0
- package/knowledge/dapp-kit/AGENTS.md +50 -0
- package/knowledge/dapp-kit/integration/README.md +49 -0
- package/knowledge/dapp-kit/integration/ai-rules.md +80 -0
- package/knowledge/dapp-kit/integration/architecture.md +276 -0
- package/knowledge/dapp-kit/integration/features/README.md +29 -0
- package/knowledge/dapp-kit/integration/features/auxiliary-services.md +169 -0
- package/knowledge/dapp-kit/integration/features/bitcoin.md +87 -0
- package/knowledge/dapp-kit/integration/features/bridge.md +91 -0
- package/knowledge/dapp-kit/integration/features/dex.md +152 -0
- package/knowledge/dapp-kit/integration/features/migration.md +118 -0
- package/knowledge/dapp-kit/integration/features/money-market.md +144 -0
- package/knowledge/dapp-kit/integration/features/staking.md +123 -0
- package/knowledge/dapp-kit/integration/features/swap.md +101 -0
- package/knowledge/dapp-kit/integration/quickstart.md +188 -0
- package/knowledge/dapp-kit/integration/recipes/README.md +136 -0
- package/knowledge/dapp-kit/integration/recipes/backend-queries.md +157 -0
- package/knowledge/dapp-kit/integration/recipes/bitcoin.md +193 -0
- package/knowledge/dapp-kit/integration/recipes/bridge.md +174 -0
- package/knowledge/dapp-kit/integration/recipes/dex.md +204 -0
- package/knowledge/dapp-kit/integration/recipes/invalidations.md +115 -0
- package/knowledge/dapp-kit/integration/recipes/migration.md +212 -0
- package/knowledge/dapp-kit/integration/recipes/money-market.md +207 -0
- package/knowledge/dapp-kit/integration/recipes/mutation-error-handling.md +118 -0
- package/knowledge/dapp-kit/integration/recipes/observability.md +93 -0
- package/knowledge/dapp-kit/integration/recipes/setup.md +168 -0
- package/knowledge/dapp-kit/integration/recipes/staking.md +202 -0
- package/knowledge/dapp-kit/integration/recipes/swap.md +272 -0
- package/knowledge/dapp-kit/integration/recipes/wallet-connectivity.md +128 -0
- package/knowledge/dapp-kit/integration/reference/README.md +12 -0
- package/knowledge/dapp-kit/integration/reference/glossary.md +190 -0
- package/knowledge/dapp-kit/integration/reference/hooks-index.md +190 -0
- package/knowledge/dapp-kit/integration/reference/public-api.md +110 -0
- package/knowledge/dapp-kit/integration/reference/querykey-conventions.md +179 -0
- package/knowledge/dapp-kit/migration/README.md +60 -0
- package/knowledge/dapp-kit/migration/ai-rules.md +81 -0
- package/knowledge/dapp-kit/migration/breaking-changes/hook-signatures.md +233 -0
- package/knowledge/dapp-kit/migration/breaking-changes/querykey-conventions.md +108 -0
- package/knowledge/dapp-kit/migration/breaking-changes/result-handling.md +211 -0
- package/knowledge/dapp-kit/migration/breaking-changes/sdk-leakage.md +167 -0
- package/knowledge/dapp-kit/migration/checklist.md +89 -0
- package/knowledge/dapp-kit/migration/features/README.md +34 -0
- package/knowledge/dapp-kit/migration/features/auxiliary-services.md +114 -0
- package/knowledge/dapp-kit/migration/features/bitcoin.md +88 -0
- package/knowledge/dapp-kit/migration/features/bridge.md +160 -0
- package/knowledge/dapp-kit/migration/features/dex.md +101 -0
- package/knowledge/dapp-kit/migration/features/migration.md +120 -0
- package/knowledge/dapp-kit/migration/features/money-market.md +139 -0
- package/knowledge/dapp-kit/migration/features/staking.md +109 -0
- package/knowledge/dapp-kit/migration/features/swap.md +133 -0
- package/knowledge/dapp-kit/migration/recipes.md +185 -0
- package/knowledge/dapp-kit/migration/reference/README.md +15 -0
- package/knowledge/dapp-kit/migration/reference/deleted-hooks.md +110 -0
- package/knowledge/dapp-kit/migration/reference/error-shape-crosswalk.md +144 -0
- package/knowledge/dapp-kit/migration/reference/renamed-hooks.md +68 -0
- package/knowledge/sdk/AGENTS.md +41 -0
- package/knowledge/sdk/integration/README.md +41 -0
- package/knowledge/sdk/integration/ai-rules.md +75 -0
- package/knowledge/sdk/integration/architecture.md +533 -0
- package/knowledge/sdk/integration/chain-specifics.md +189 -0
- package/knowledge/sdk/integration/features/README.md +19 -0
- package/knowledge/sdk/integration/features/auxiliary-services.md +189 -0
- package/knowledge/sdk/integration/features/bridge.md +136 -0
- package/knowledge/sdk/integration/features/dex.md +182 -0
- package/knowledge/sdk/integration/features/icx-bnusd-baln.md +181 -0
- package/knowledge/sdk/integration/features/money-market.md +198 -0
- package/knowledge/sdk/integration/features/staking.md +166 -0
- package/knowledge/sdk/integration/features/swap.md +207 -0
- package/knowledge/sdk/integration/quickstart.md +213 -0
- package/knowledge/sdk/integration/recipes/README.md +21 -0
- package/knowledge/sdk/integration/recipes/backend-server-init.md +69 -0
- package/knowledge/sdk/integration/recipes/chain-key-narrowing.md +65 -0
- package/knowledge/sdk/integration/recipes/gas-estimation.md +33 -0
- package/knowledge/sdk/integration/recipes/initialize-sodax.md +78 -0
- package/knowledge/sdk/integration/recipes/raw-tx-flow.md +71 -0
- package/knowledge/sdk/integration/recipes/result-and-errors.md +104 -0
- package/knowledge/sdk/integration/recipes/signed-tx-flow.md +46 -0
- package/knowledge/sdk/integration/recipes/testing.md +101 -0
- package/knowledge/sdk/integration/reference/README.md +18 -0
- package/knowledge/sdk/integration/reference/chain-keys.md +67 -0
- package/knowledge/sdk/integration/reference/error-codes.md +165 -0
- package/knowledge/sdk/integration/reference/glossary.md +32 -0
- package/knowledge/sdk/integration/reference/public-api.md +138 -0
- package/knowledge/sdk/integration/reference/wallet-providers.md +62 -0
- package/knowledge/sdk/migration/README.md +58 -0
- package/knowledge/sdk/migration/ai-rules.md +80 -0
- package/knowledge/sdk/migration/breaking-changes/architecture.md +344 -0
- package/knowledge/sdk/migration/breaking-changes/result-and-errors.md +363 -0
- package/knowledge/sdk/migration/breaking-changes/type-system.md +341 -0
- package/knowledge/sdk/migration/checklist.md +67 -0
- package/knowledge/sdk/migration/features/README.md +35 -0
- package/knowledge/sdk/migration/features/auxiliary-services.md +156 -0
- package/knowledge/sdk/migration/features/bridge.md +128 -0
- package/knowledge/sdk/migration/features/dex.md +143 -0
- package/knowledge/sdk/migration/features/icx-bnusd-baln.md +151 -0
- package/knowledge/sdk/migration/features/money-market.md +214 -0
- package/knowledge/sdk/migration/features/staking.md +138 -0
- package/knowledge/sdk/migration/features/swap.md +198 -0
- package/knowledge/sdk/migration/recipes.md +350 -0
- package/knowledge/sdk/migration/reference/README.md +18 -0
- package/knowledge/sdk/migration/reference/deleted-exports.md +127 -0
- package/knowledge/sdk/migration/reference/error-code-crosswalk.md +104 -0
- package/knowledge/sdk/migration/reference/return-shapes.md +49 -0
- package/knowledge/sdk/migration/reference/sodax-config.md +145 -0
- package/knowledge/wallet-sdk-core/AGENTS.md +43 -0
- package/knowledge/wallet-sdk-core/integration/README.md +108 -0
- package/knowledge/wallet-sdk-core/integration/ai-rules.md +141 -0
- package/knowledge/wallet-sdk-core/integration/architecture.md +212 -0
- package/knowledge/wallet-sdk-core/integration/features/README.md +22 -0
- package/knowledge/wallet-sdk-core/integration/features/bitcoin.md +103 -0
- package/knowledge/wallet-sdk-core/integration/features/evm.md +102 -0
- package/knowledge/wallet-sdk-core/integration/features/icon.md +88 -0
- package/knowledge/wallet-sdk-core/integration/features/injective.md +92 -0
- package/knowledge/wallet-sdk-core/integration/features/near.md +92 -0
- package/knowledge/wallet-sdk-core/integration/features/solana.md +104 -0
- package/knowledge/wallet-sdk-core/integration/features/stacks.md +91 -0
- package/knowledge/wallet-sdk-core/integration/features/stellar.md +95 -0
- package/knowledge/wallet-sdk-core/integration/features/sui.md +96 -0
- package/knowledge/wallet-sdk-core/integration/quickstart.md +259 -0
- package/knowledge/wallet-sdk-core/integration/recipes/README.md +15 -0
- package/knowledge/wallet-sdk-core/integration/recipes/bridge-to-sdk.md +145 -0
- package/knowledge/wallet-sdk-core/integration/recipes/defaults-and-overrides.md +159 -0
- package/knowledge/wallet-sdk-core/integration/recipes/library-exports.md +129 -0
- package/knowledge/wallet-sdk-core/integration/recipes/setup-browser-extension.md +137 -0
- package/knowledge/wallet-sdk-core/integration/recipes/setup-private-key.md +115 -0
- package/knowledge/wallet-sdk-core/integration/recipes/sign-and-broadcast.md +201 -0
- package/knowledge/wallet-sdk-core/integration/recipes/testing.md +163 -0
- package/knowledge/wallet-sdk-core/integration/reference/README.md +13 -0
- package/knowledge/wallet-sdk-core/integration/reference/chain-support.md +65 -0
- package/knowledge/wallet-sdk-core/integration/reference/glossary.md +28 -0
- package/knowledge/wallet-sdk-core/integration/reference/interfaces.md +131 -0
- package/knowledge/wallet-sdk-core/integration/reference/provider-classes.md +54 -0
- package/knowledge/wallet-sdk-core/integration/reference/public-api.md +128 -0
- package/knowledge/wallet-sdk-core/migration/README.md +84 -0
- package/knowledge/wallet-sdk-core/migration/ai-rules.md +139 -0
- package/knowledge/wallet-sdk-core/migration/breaking-changes/README.md +14 -0
- package/knowledge/wallet-sdk-core/migration/breaking-changes/base-wallet-provider.md +52 -0
- package/knowledge/wallet-sdk-core/migration/breaking-changes/defaults-config.md +57 -0
- package/knowledge/wallet-sdk-core/migration/breaking-changes/folder-layout.md +99 -0
- package/knowledge/wallet-sdk-core/migration/breaking-changes/library-exports.md +58 -0
- package/knowledge/wallet-sdk-core/migration/checklist.md +62 -0
- package/knowledge/wallet-sdk-core/migration/recipes/README.md +12 -0
- package/knowledge/wallet-sdk-core/migration/recipes/adopt-defaults.md +84 -0
- package/knowledge/wallet-sdk-core/migration/recipes/adopt-library-exports.md +99 -0
- package/knowledge/wallet-sdk-core/migration/reference/README.md +12 -0
- package/knowledge/wallet-sdk-core/migration/reference/added-fields.md +71 -0
- package/knowledge/wallet-sdk-core/migration/reference/deleted-exports.md +35 -0
- package/knowledge/wallet-sdk-core/migration/reference/renamed-symbols.md +31 -0
- package/knowledge/wallet-sdk-core/migration/reference/return-shapes.md +23 -0
- package/knowledge/wallet-sdk-react/AGENTS.md +46 -0
- package/knowledge/wallet-sdk-react/integration/README.md +103 -0
- package/knowledge/wallet-sdk-react/integration/ai-rules.md +136 -0
- package/knowledge/wallet-sdk-react/integration/architecture.md +185 -0
- package/knowledge/wallet-sdk-react/integration/examples/01-minimal-evm.tsx +75 -0
- package/knowledge/wallet-sdk-react/integration/examples/02-multi-chain-modal.tsx +169 -0
- package/knowledge/wallet-sdk-react/integration/examples/03-nextjs-app-router.tsx +99 -0
- package/knowledge/wallet-sdk-react/integration/examples/04-walletconnect-setup.tsx +89 -0
- package/knowledge/wallet-sdk-react/integration/examples/README.md +29 -0
- package/knowledge/wallet-sdk-react/integration/recipes/batch-operations.md +224 -0
- package/knowledge/wallet-sdk-react/integration/recipes/bridge-to-sdk.md +165 -0
- package/knowledge/wallet-sdk-react/integration/recipes/chain-detection.md +259 -0
- package/knowledge/wallet-sdk-react/integration/recipes/connect-button.md +159 -0
- package/knowledge/wallet-sdk-react/integration/recipes/multi-chain-modal.md +203 -0
- package/knowledge/wallet-sdk-react/integration/recipes/setup.md +163 -0
- package/knowledge/wallet-sdk-react/integration/recipes/sign-message.md +138 -0
- package/knowledge/wallet-sdk-react/integration/recipes/sub-path-imports.md +97 -0
- package/knowledge/wallet-sdk-react/integration/recipes/switch-chain.md +144 -0
- package/knowledge/wallet-sdk-react/integration/recipes/walletconnect-setup.md +139 -0
- package/knowledge/wallet-sdk-react/integration/reference/api-surface.md +176 -0
- package/knowledge/wallet-sdk-react/integration/reference/chain-support.md +79 -0
- package/knowledge/wallet-sdk-react/integration/reference/connectors.md +75 -0
- package/knowledge/wallet-sdk-react/integration/reference/hooks.md +212 -0
- package/knowledge/wallet-sdk-react/integration/reference/wallet-brands.md +107 -0
- package/knowledge/wallet-sdk-react/migration/README.md +49 -0
- package/knowledge/wallet-sdk-react/migration/ai-rules.md +144 -0
- package/knowledge/wallet-sdk-react/migration/breaking-changes.md +310 -0
- package/knowledge/wallet-sdk-react/migration/checklist.md +159 -0
- package/knowledge/wallet-sdk-react/migration/recipes/connect-button.md +170 -0
- package/knowledge/wallet-sdk-react/migration/recipes/multi-chain-modal.md +245 -0
- package/knowledge/wallet-sdk-react/migration/recipes/ssr-setup.md +165 -0
- package/knowledge/wallet-sdk-react/migration/recipes/walletconnect-migration.md +170 -0
- package/knowledge/wallet-sdk-react/migration/reference/components.md +75 -0
- package/knowledge/wallet-sdk-react/migration/reference/config.md +339 -0
- package/knowledge/wallet-sdk-react/migration/reference/hooks.md +336 -0
- package/knowledge/wallet-sdk-react/migration/reference/imports.md +158 -0
- package/package.json +59 -0
- package/skills/sodax-dapp-kit-integration/SKILL.md +71 -0
- package/skills/sodax-dapp-kit-migration/SKILL.md +58 -0
- package/skills/sodax-sdk-integration/SKILL.md +66 -0
- package/skills/sodax-sdk-migration/SKILL.md +75 -0
- package/skills/sodax-wallet-sdk-core-integration/SKILL.md +55 -0
- package/skills/sodax-wallet-sdk-core-migration/SKILL.md +56 -0
- package/skills/sodax-wallet-sdk-react-integration/SKILL.md +80 -0
- package/skills/sodax-wallet-sdk-react-migration/SKILL.md +71 -0
|
@@ -0,0 +1,91 @@
|
|
|
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
|
|
@@ -0,0 +1,95 @@
|
|
|
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)
|
|
@@ -0,0 +1,96 @@
|
|
|
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)
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
# Quickstart — Copy/paste examples
|
|
2
|
+
|
|
3
|
+
Minimal end-to-end snippets per chain family. Pick the chain you need, copy the snippet, and run it. Each snippet covers **both** modes (private-key + browser-extension).
|
|
4
|
+
|
|
5
|
+
For chain-specific gotchas (Sui's mnemonics, Injective's `secret` wrapper, …) see [`features/<chain>.md`](./features/). For the mental model see [`architecture.md`](./architecture.md).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @sodax/wallet-sdk-core @sodax/types
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
If you plan to call `@sodax/sdk` after constructing the provider, also add it:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @sodax/sdk
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## EVM (12 chains)
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { EvmWalletProvider } from '@sodax/wallet-sdk-core';
|
|
27
|
+
import { ChainKeys } from '@sodax/types';
|
|
28
|
+
|
|
29
|
+
// Private-key (Node / scripts / CI)
|
|
30
|
+
const evmPk = new EvmWalletProvider({
|
|
31
|
+
privateKey: '0x…',
|
|
32
|
+
chainId: ChainKeys.SONIC_MAINNET,
|
|
33
|
+
rpcUrl: 'https://rpc.soniclabs.com',
|
|
34
|
+
defaults: {
|
|
35
|
+
sendTransaction: { gas: 3_000_000n },
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
console.log(await evmPk.getWalletAddress());
|
|
39
|
+
|
|
40
|
+
// Browser-extension (consumer supplies viem clients)
|
|
41
|
+
const evmBrowser = new EvmWalletProvider({
|
|
42
|
+
walletClient: myViemWalletClient, // from wagmi / viem
|
|
43
|
+
publicClient: myViemPublicClient,
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
See [`features/evm.md`](./features/evm.md).
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Solana
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { SolanaWalletProvider } from '@sodax/wallet-sdk-core';
|
|
55
|
+
|
|
56
|
+
// Private-key — secret key bytes (Uint8Array length 64)
|
|
57
|
+
const solanaPk = new SolanaWalletProvider({
|
|
58
|
+
privateKey: new Uint8Array(64),
|
|
59
|
+
endpoint: 'https://api.mainnet-beta.solana.com',
|
|
60
|
+
defaults: {
|
|
61
|
+
connectionCommitment: 'confirmed',
|
|
62
|
+
sendOptions: { skipPreflight: false },
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Browser-extension — wallet adapter context
|
|
67
|
+
const solanaBrowser = new SolanaWalletProvider({
|
|
68
|
+
wallet: {
|
|
69
|
+
publicKey: myPublicKey, // PublicKey | null
|
|
70
|
+
signTransaction: mySignTransaction, // SignerWalletAdapterProps['signTransaction'] | undefined
|
|
71
|
+
},
|
|
72
|
+
endpoint: 'https://api.mainnet-beta.solana.com',
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
See [`features/solana.md`](./features/solana.md).
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Sui
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { SuiWalletProvider } from '@sodax/wallet-sdk-core';
|
|
84
|
+
|
|
85
|
+
// Private-key — DERIVED FROM MNEMONIC, not a raw key
|
|
86
|
+
const suiPk = new SuiWalletProvider({
|
|
87
|
+
rpcUrl: 'https://fullnode.mainnet.sui.io:443',
|
|
88
|
+
mnemonics: 'word1 word2 … word12',
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Browser-extension — wallet-standard wallet
|
|
92
|
+
const suiBrowser = new SuiWalletProvider({
|
|
93
|
+
client: mySuiClient, // SuiClient
|
|
94
|
+
wallet: myWalletWithSuiFeatures, // WalletWithFeatures<Partial<SuiWalletFeatures>>
|
|
95
|
+
account: myActiveWalletAccount, // WalletAccount
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
See [`features/sui.md`](./features/sui.md).
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Bitcoin
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
import { BitcoinWalletProvider } from '@sodax/wallet-sdk-core';
|
|
107
|
+
|
|
108
|
+
// Private-key — uses explicit uppercase `type`
|
|
109
|
+
const btcPk = new BitcoinWalletProvider({
|
|
110
|
+
type: 'PRIVATE_KEY',
|
|
111
|
+
privateKey: '0x…',
|
|
112
|
+
network: 'TESTNET',
|
|
113
|
+
addressType: 'P2WPKH', // optional
|
|
114
|
+
defaults: { defaultFinalize: true },
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
// Browser-extension — uses explicit uppercase `type`
|
|
118
|
+
const btcBrowser = new BitcoinWalletProvider({
|
|
119
|
+
type: 'BROWSER_EXTENSION',
|
|
120
|
+
walletsKit: myBitcoinWalletsKit, // Xverse / Unisat / OKX adapter
|
|
121
|
+
network: 'TESTNET',
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
See [`features/bitcoin.md`](./features/bitcoin.md).
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Stellar
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
import { StellarWalletProvider } from '@sodax/wallet-sdk-core';
|
|
133
|
+
|
|
134
|
+
// Private-key — explicit uppercase `type`
|
|
135
|
+
const stellarPk = new StellarWalletProvider({
|
|
136
|
+
type: 'PRIVATE_KEY',
|
|
137
|
+
privateKey: '0x…',
|
|
138
|
+
network: 'PUBLIC', // 'PUBLIC' | 'TESTNET'
|
|
139
|
+
rpcUrl: 'https://horizon.stellar.org',
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Browser-extension — explicit uppercase `type`
|
|
143
|
+
const stellarBrowser = new StellarWalletProvider({
|
|
144
|
+
type: 'BROWSER_EXTENSION',
|
|
145
|
+
walletsKit: myStellarWalletsKit, // Freighter / xBull / Lobstr kit
|
|
146
|
+
network: 'PUBLIC',
|
|
147
|
+
});
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
See [`features/stellar.md`](./features/stellar.md).
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## ICON
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
import { IconWalletProvider } from '@sodax/wallet-sdk-core';
|
|
158
|
+
|
|
159
|
+
// Private-key (Node / scripts / CI)
|
|
160
|
+
const iconPk = new IconWalletProvider({
|
|
161
|
+
privateKey: '0x…',
|
|
162
|
+
rpcUrl: 'https://ctz.solidwallet.io/api/v3',
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Browser-extension — Hana wallet
|
|
166
|
+
const iconBrowser = new IconWalletProvider({
|
|
167
|
+
walletAddress: 'hx…', // optional; resolved at first signing call if omitted
|
|
168
|
+
rpcUrl: 'https://ctz.solidwallet.io/api/v3',
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
See [`features/icon.md`](./features/icon.md).
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Injective
|
|
177
|
+
|
|
178
|
+
```ts
|
|
179
|
+
import { InjectiveWalletProvider } from '@sodax/wallet-sdk-core';
|
|
180
|
+
import type { ChainId, Network } from '@sodax/wallet-sdk-core';
|
|
181
|
+
|
|
182
|
+
// Secret-credential variant: private key
|
|
183
|
+
const injectivePk = new InjectiveWalletProvider({
|
|
184
|
+
secret: { privateKey: '…' },
|
|
185
|
+
chainId: 'injective-1' as ChainId,
|
|
186
|
+
network: 'Mainnet' as Network,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// Secret-credential variant: mnemonic
|
|
190
|
+
const injectiveMnemonic = new InjectiveWalletProvider({
|
|
191
|
+
secret: { mnemonics: 'word1 word2 …' },
|
|
192
|
+
chainId: 'injective-1' as ChainId,
|
|
193
|
+
network: 'Mainnet' as Network,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// Browser-extension — caller supplies a configured MsgBroadcaster
|
|
197
|
+
const injectiveBrowser = new InjectiveWalletProvider({
|
|
198
|
+
msgBroadcaster: myMsgBroadcaster,
|
|
199
|
+
});
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
> Note: the private-key variant uses a nested `secret` wrapper instead of a top-level `privateKey`. See [`features/injective.md`](./features/injective.md).
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## NEAR
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
import { NearWalletProvider } from '@sodax/wallet-sdk-core';
|
|
210
|
+
|
|
211
|
+
// Private-key — accountId + raw key
|
|
212
|
+
const nearPk = new NearWalletProvider({
|
|
213
|
+
rpcUrl: 'https://rpc.mainnet.near.org',
|
|
214
|
+
accountId: 'alice.near',
|
|
215
|
+
privateKey: 'ed25519:…',
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
// Browser-extension — NearConnector
|
|
219
|
+
const nearBrowser = new NearWalletProvider({
|
|
220
|
+
wallet: myNearConnector, // from @hot-labs/near-connect
|
|
221
|
+
});
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
See [`features/near.md`](./features/near.md).
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Stacks
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
import { StacksWalletProvider } from '@sodax/wallet-sdk-core';
|
|
232
|
+
|
|
233
|
+
// Private-key (Node / scripts / CI)
|
|
234
|
+
const stacksPk = new StacksWalletProvider({
|
|
235
|
+
privateKey: '…',
|
|
236
|
+
endpoint: 'https://api.mainnet.hiro.so',
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// Browser-extension — Leather / Xverse / Asigna
|
|
240
|
+
const stacksBrowser = new StacksWalletProvider({
|
|
241
|
+
address: 'SP…',
|
|
242
|
+
endpoint: 'https://api.mainnet.hiro.so',
|
|
243
|
+
provider: myStacksProvider, // StacksProvider from @stacks/connect
|
|
244
|
+
});
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
See [`features/stacks.md`](./features/stacks.md).
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## Next steps
|
|
252
|
+
|
|
253
|
+
After construction:
|
|
254
|
+
|
|
255
|
+
- **Get the wallet address** — every provider exposes `getWalletAddress(): Promise<string>` (narrowed to a chain-specific brand by subclasses).
|
|
256
|
+
- **Sign and broadcast** — see [`recipes/sign-and-broadcast.md`](./recipes/sign-and-broadcast.md) for the per-chain flow.
|
|
257
|
+
- **Hand off to `@sodax/sdk`** — see [`recipes/bridge-to-sdk.md`](./recipes/bridge-to-sdk.md).
|
|
258
|
+
- **Tune defaults** — see [`recipes/defaults-and-overrides.md`](./recipes/defaults-and-overrides.md).
|
|
259
|
+
- **Avoid direct chain-SDK deps** — see [`recipes/library-exports.md`](./recipes/library-exports.md).
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Recipes
|
|
2
|
+
|
|
3
|
+
Self-contained, task-oriented guides. Each recipe has paired before/after code, prerequisites, and verification steps.
|
|
4
|
+
|
|
5
|
+
| Recipe | When to use | Depends on |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| [`setup-private-key.md`](./setup-private-key.md) | Construct a provider from a raw key (Node scripts, CI, tests). | none |
|
|
8
|
+
| [`setup-browser-extension.md`](./setup-browser-extension.md) | Construct a provider from a wallet-extension adapter (consumer dApps). | none |
|
|
9
|
+
| [`bridge-to-sdk.md`](./bridge-to-sdk.md) | Pass the provider to `@sodax/sdk` calls. | a setup recipe |
|
|
10
|
+
| [`defaults-and-overrides.md`](./defaults-and-overrides.md) | Configure the `defaults` slice and understand shallow-merge semantics. | a setup recipe |
|
|
11
|
+
| [`library-exports.md`](./library-exports.md) | Avoid direct deps on `viem`, `@mysten/sui`, etc. by re-importing types from `@sodax/wallet-sdk-core`. | none |
|
|
12
|
+
| [`sign-and-broadcast.md`](./sign-and-broadcast.md) | Typical raw-tx flow per chain. | a setup recipe |
|
|
13
|
+
| [`testing.md`](./testing.md) | Mock providers in unit tests. | none |
|
|
14
|
+
|
|
15
|
+
Pick the recipe that matches the user's task. Recipes are intentionally short and self-contained — do **not** chain more than 2 in one apply.
|