ault-sdk-ts 0.0.2-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +923 -0
- package/dist/agent/create-agent-client.d.ts +3 -0
- package/dist/agent/sign-and-broadcast.d.ts +38 -0
- package/dist/agent/tx/clob.d.ts +7 -0
- package/dist/agent/tx-executor.d.ts +17 -0
- package/dist/client.d.ts +61 -0
- package/dist/core/address.d.ts +14 -0
- package/dist/core/base64.d.ts +2 -0
- package/dist/core/clob-msgs.d.ts +33 -0
- package/dist/core/errors.d.ts +17 -0
- package/dist/core/http.d.ts +14 -0
- package/dist/core/network.d.ts +59 -0
- package/dist/core/pagination.d.ts +14 -0
- package/dist/core/query.d.ts +5 -0
- package/dist/core/with-status-fallback.d.ts +5 -0
- package/dist/eip712/builder.d.ts +45 -0
- package/dist/eip712/field-order.d.ts +2 -0
- package/dist/eip712/msg-encoders.generated.d.ts +1 -0
- package/dist/eip712/msg.generated.d.ts +109 -0
- package/dist/eip712/registry.d.ts +36 -0
- package/dist/eip712/registry.generated.d.ts +2 -0
- package/dist/eip712/sign-and-broadcast.d.ts +55 -0
- package/dist/eip712/signers.d.ts +83 -0
- package/dist/eip712/types.d.ts +58 -0
- package/dist/high-level/address-utils.d.ts +2 -0
- package/dist/high-level/create-client.d.ts +26 -0
- package/dist/high-level/query-helpers.d.ts +3 -0
- package/dist/high-level/signer.d.ts +6 -0
- package/dist/high-level/tx/agent.d.ts +3 -0
- package/dist/high-level/tx/authority.d.ts +3 -0
- package/dist/high-level/tx/clob.d.ts +3 -0
- package/dist/high-level/tx/context.d.ts +5 -0
- package/dist/high-level/tx/license.d.ts +3 -0
- package/dist/high-level/tx/market.d.ts +3 -0
- package/dist/high-level/tx/miner.d.ts +3 -0
- package/dist/high-level/tx/ratelimit.d.ts +3 -0
- package/dist/high-level/tx/reward.d.ts +3 -0
- package/dist/high-level/tx/staking.d.ts +3 -0
- package/dist/high-level/tx/tokenregistry.d.ts +3 -0
- package/dist/high-level/tx-executor.d.ts +18 -0
- package/dist/high-level/types.d.ts +477 -0
- package/dist/high-level-client.d.ts +2 -0
- package/dist/index.cjs +18409 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +18137 -0
- package/dist/index.js.map +1 -0
- package/dist/proto/duration-json.d.ts +6 -0
- package/dist/proto/gen/amino/amino.d.ts +1 -0
- package/dist/proto/gen/ault/agent/v1/agent.d.ts +63 -0
- package/dist/proto/gen/ault/agent/v1/genesis.d.ts +44 -0
- package/dist/proto/gen/ault/agent/v1/params.d.ts +42 -0
- package/dist/proto/gen/ault/agent/v1/query.d.ts +73 -0
- package/dist/proto/gen/ault/agent/v1/tx.d.ts +91 -0
- package/dist/proto/gen/ault/authority/v1/authority.d.ts +15 -0
- package/dist/proto/gen/ault/authority/v1/genesis.d.ts +36 -0
- package/dist/proto/gen/ault/authority/v1/query.d.ts +53 -0
- package/dist/proto/gen/ault/authority/v1/tx.d.ts +50 -0
- package/dist/proto/gen/ault/clob/v1/fee.d.ts +37 -0
- package/dist/proto/gen/ault/clob/v1/genesis.d.ts +56 -0
- package/dist/proto/gen/ault/clob/v1/order_book.d.ts +32 -0
- package/dist/proto/gen/ault/clob/v1/params.d.ts +29 -0
- package/dist/proto/gen/ault/clob/v1/query.d.ts +56 -0
- package/dist/proto/gen/ault/clob/v1/tx.d.ts +116 -0
- package/dist/proto/gen/ault/license/v1/genesis.d.ts +140 -0
- package/dist/proto/gen/ault/license/v1/license.d.ts +151 -0
- package/dist/proto/gen/ault/license/v1/query.d.ts +273 -0
- package/dist/proto/gen/ault/license/v1/tx.d.ts +227 -0
- package/dist/proto/gen/ault/market/v1/genesis.d.ts +28 -0
- package/dist/proto/gen/ault/market/v1/market.d.ts +66 -0
- package/dist/proto/gen/ault/market/v1/params.d.ts +34 -0
- package/dist/proto/gen/ault/market/v1/query.d.ts +48 -0
- package/dist/proto/gen/ault/market/v1/tx.d.ts +87 -0
- package/dist/proto/gen/ault/miner/v1/genesis.d.ts +166 -0
- package/dist/proto/gen/ault/miner/v1/miner.d.ts +232 -0
- package/dist/proto/gen/ault/miner/v1/query.d.ts +254 -0
- package/dist/proto/gen/ault/miner/v1/tx.d.ts +207 -0
- package/dist/proto/gen/ault/ratelimit/v1/genesis.d.ts +27 -0
- package/dist/proto/gen/ault/ratelimit/v1/params.d.ts +35 -0
- package/dist/proto/gen/ault/ratelimit/v1/query.d.ts +42 -0
- package/dist/proto/gen/ault/ratelimit/v1/tx.d.ts +32 -0
- package/dist/proto/gen/ault/reward/v1/genesis.d.ts +67 -0
- package/dist/proto/gen/ault/reward/v1/query.d.ts +93 -0
- package/dist/proto/gen/ault/reward/v1/reward.d.ts +53 -0
- package/dist/proto/gen/ault/reward/v1/tx.d.ts +120 -0
- package/dist/proto/gen/ault/spot/v1/genesis.d.ts +26 -0
- package/dist/proto/gen/ault/spot/v1/order.d.ts +66 -0
- package/dist/proto/gen/ault/tokenregistry/v1/genesis.d.ts +34 -0
- package/dist/proto/gen/ault/tokenregistry/v1/query.d.ts +77 -0
- package/dist/proto/gen/ault/tokenregistry/v1/tokenregistry.d.ts +118 -0
- package/dist/proto/gen/ault/tokenregistry/v1/tx.d.ts +132 -0
- package/dist/proto/gen/cosmos/base/query/v1beta1/pagination.d.ts +82 -0
- package/dist/proto/gen/cosmos/base/v1beta1/coin.d.ts +59 -0
- package/dist/proto/gen/cosmos/distribution/v1beta1/distribution.d.ts +162 -0
- package/dist/proto/gen/cosmos/distribution/v1beta1/tx.d.ts +140 -0
- package/dist/proto/gen/cosmos/msg/v1/msg.d.ts +1 -0
- package/dist/proto/gen/cosmos/staking/v1beta1/staking.d.ts +310 -0
- package/dist/proto/gen/cosmos/staking/v1beta1/tx.d.ts +144 -0
- package/dist/proto/gen/cosmos_proto/cosmos.d.ts +80 -0
- package/dist/proto/gen/gogoproto/gogo.d.ts +1 -0
- package/dist/proto/gen/google/api/annotations.d.ts +1 -0
- package/dist/proto/gen/google/api/http.d.ts +379 -0
- package/dist/proto/gen/google/protobuf/any.d.ts +144 -0
- package/dist/proto/gen/google/protobuf/descriptor.d.ts +1285 -0
- package/dist/proto/gen/google/protobuf/duration.d.ts +99 -0
- package/dist/proto/gen/google/protobuf/timestamp.d.ts +128 -0
- package/dist/proto/gen/tendermint/abci/types.d.ts +507 -0
- package/dist/proto/gen/tendermint/crypto/keys.d.ts +27 -0
- package/dist/proto/gen/tendermint/crypto/proof.d.ts +57 -0
- package/dist/proto/gen/tendermint/types/params.d.ts +112 -0
- package/dist/proto/gen/tendermint/types/types.d.ts +197 -0
- package/dist/proto/gen/tendermint/types/validator.d.ts +54 -0
- package/dist/proto/gen/tendermint/version/types.d.ts +41 -0
- package/dist/proto/tx-encode.d.ts +78 -0
- package/dist/rest/agent.d.ts +12 -0
- package/dist/rest/authority.d.ts +12 -0
- package/dist/rest/clob.d.ts +11 -0
- package/dist/rest/context.d.ts +22 -0
- package/dist/rest/dex-fetcher.d.ts +10 -0
- package/dist/rest/dex-types.generated.d.ts +780 -0
- package/dist/rest/dex.d.ts +34 -0
- package/dist/rest/dex.generated.d.ts +1381 -0
- package/dist/rest/license.d.ts +79 -0
- package/dist/rest/market.d.ts +11 -0
- package/dist/rest/miner.d.ts +59 -0
- package/dist/rest/ratelimit.d.ts +7 -0
- package/dist/rest/reward.d.ts +25 -0
- package/dist/rest/staking.d.ts +38 -0
- package/dist/rest/tokenregistry.d.ts +11 -0
- package/dist/rest/types.d.ts +871 -0
- package/dist/utils/address.d.ts +6 -0
- package/dist/utils/chain-id.d.ts +1 -0
- package/dist/utils/cosmos-dec.d.ts +2 -0
- package/dist/ws/client.d.ts +34 -0
- package/dist/ws/index.d.ts +5 -0
- package/dist/ws/types.d.ts +72 -0
- package/package.json +103 -0
package/README.md
ADDED
|
@@ -0,0 +1,923 @@
|
|
|
1
|
+
# Ault SDK for TypeScript
|
|
2
|
+
|
|
3
|
+
A TypeScript SDK for the Ault blockchain that provides high-level transaction methods and REST query clients for the current Ault modules, including License, Miner, Market, CLOB, Agent, Authority, RateLimit, Reward, and TokenRegistry.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- High-level client with simple transaction methods (no manual message building)
|
|
8
|
+
- Flexible signer support (viem, ethers, Privy, MetaMask, private keys)
|
|
9
|
+
- Automatic address format conversion (0x <-> ault1)
|
|
10
|
+
- DEX API client for market data, orders, trades, and UDF charting
|
|
11
|
+
- DEX WebSocket client for real-time streaming with type-safe subscriptions and auto-reconnect
|
|
12
|
+
- REST query clients for the current Ault modules
|
|
13
|
+
- EIP-712 typed data signing
|
|
14
|
+
- Works across Node.js, Bun, and browser runtimes
|
|
15
|
+
- Full TypeScript support with comprehensive type definitions
|
|
16
|
+
- Automatic retry with exponential backoff
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# npm
|
|
22
|
+
npm install ault-sdk-ts
|
|
23
|
+
|
|
24
|
+
# pnpm
|
|
25
|
+
pnpm add ault-sdk-ts
|
|
26
|
+
|
|
27
|
+
# bun
|
|
28
|
+
bun add ault-sdk-ts
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Installing from the npm registry is the supported path for production use.
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import { createClient, getNetworkConfig } from "ault-sdk-ts";
|
|
37
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
38
|
+
|
|
39
|
+
// Create a client with a viem account
|
|
40
|
+
const account = privateKeyToAccount("0x...");
|
|
41
|
+
const client = await createClient({
|
|
42
|
+
network: getNetworkConfig("ault_10904-1"),
|
|
43
|
+
signer: account,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Query data
|
|
47
|
+
const licenses = await client.license.getOwnedBy(client.address);
|
|
48
|
+
const epoch = await client.miner.getCurrentEpoch();
|
|
49
|
+
|
|
50
|
+
// Execute transactions (no message building required!)
|
|
51
|
+
const result = await client.delegateMining({
|
|
52
|
+
licenseIds: [1, 2, 3], // accepts numbers, strings, or bigints
|
|
53
|
+
operator: "0xOperator...", // accepts 0x or ault1 format
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
console.log(
|
|
57
|
+
`TX Hash: ${result.txHash}, Confirmed: ${result.confirmed}, Success: ${result.success}`,
|
|
58
|
+
);
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Creating a Client
|
|
62
|
+
|
|
63
|
+
The `createClient()` function accepts multiple signer types and auto-detects the format:
|
|
64
|
+
|
|
65
|
+
### With viem
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { createClient, getNetworkConfig } from "ault-sdk-ts";
|
|
69
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
70
|
+
|
|
71
|
+
const account = privateKeyToAccount("0x...");
|
|
72
|
+
const client = await createClient({
|
|
73
|
+
network: getNetworkConfig("ault_10904-1"),
|
|
74
|
+
signer: account,
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### With viem WalletClient (Browser)
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import { createClient, getNetworkConfig } from "ault-sdk-ts";
|
|
82
|
+
import { createWalletClient, custom } from "viem";
|
|
83
|
+
|
|
84
|
+
const walletClient = createWalletClient({
|
|
85
|
+
transport: custom(window.ethereum),
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const client = await createClient({
|
|
89
|
+
network: getNetworkConfig("ault_10904-1"),
|
|
90
|
+
signer: walletClient,
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### With ethers.js
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import { createClient, getNetworkConfig } from "ault-sdk-ts";
|
|
98
|
+
import { ethers } from "ethers";
|
|
99
|
+
|
|
100
|
+
const provider = new ethers.JsonRpcProvider("...");
|
|
101
|
+
const signer = new ethers.Wallet("0x...", provider);
|
|
102
|
+
|
|
103
|
+
const client = await createClient({
|
|
104
|
+
network: getNetworkConfig("ault_10904-1"),
|
|
105
|
+
signer: { type: "ethers", signer },
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### With MetaMask (EIP-1193)
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { createClient, getNetworkConfig } from "ault-sdk-ts";
|
|
113
|
+
|
|
114
|
+
const accounts = await window.ethereum.request({ method: "eth_requestAccounts" });
|
|
115
|
+
|
|
116
|
+
const client = await createClient({
|
|
117
|
+
network: getNetworkConfig("ault_10904-1"),
|
|
118
|
+
signer: {
|
|
119
|
+
type: "eip1193",
|
|
120
|
+
provider: window.ethereum,
|
|
121
|
+
address: accounts[0],
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### With Privy
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
import { createClient, getNetworkConfig } from "ault-sdk-ts";
|
|
130
|
+
import { useSignTypedData, useWallets } from "@privy-io/react-auth";
|
|
131
|
+
|
|
132
|
+
const { signTypedData } = useSignTypedData();
|
|
133
|
+
const { wallets } = useWallets();
|
|
134
|
+
|
|
135
|
+
const client = await createClient({
|
|
136
|
+
network: getNetworkConfig("ault_10904-1"),
|
|
137
|
+
signer: {
|
|
138
|
+
type: "privy",
|
|
139
|
+
signTypedData,
|
|
140
|
+
address: wallets[0]?.address,
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### With Private Key (Server-side)
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import { createClient, getNetworkConfig } from "ault-sdk-ts";
|
|
149
|
+
|
|
150
|
+
const client = await createClient({
|
|
151
|
+
network: getNetworkConfig("ault_10904-1"),
|
|
152
|
+
signer: { type: "privateKey", key: "0x..." },
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Client Options
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
interface ClientOptions {
|
|
160
|
+
network: NetworkConfig; // Required: network configuration
|
|
161
|
+
signer: FlexibleSignerInput; // Required: wallet/signer
|
|
162
|
+
signerAddress?: string; // Optional: override signer address
|
|
163
|
+
fetchFn?: typeof fetch; // Optional: custom fetch
|
|
164
|
+
fetchOptions?: FetchWithRetryOptions;
|
|
165
|
+
defaultGasLimit?: string; // Optional: default gas limit
|
|
166
|
+
defaultMemo?: string; // Optional: default memo
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Query Methods
|
|
171
|
+
|
|
172
|
+
The client provides pass-through access to all REST API methods:
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
// License queries
|
|
176
|
+
const license = await client.license.getLicense("1");
|
|
177
|
+
const licenses = await client.license.getOwnedBy(client.address);
|
|
178
|
+
const balance = await client.license.getBalance(client.address);
|
|
179
|
+
const isApproved = await client.license.isApprovedMember(address);
|
|
180
|
+
|
|
181
|
+
// Miner queries
|
|
182
|
+
const epoch = await client.miner.getCurrentEpoch();
|
|
183
|
+
const operators = await client.miner.getOperators();
|
|
184
|
+
const delegation = await client.miner.getLicenseDelegation("123");
|
|
185
|
+
const emission = await client.miner.getEmissionInfo();
|
|
186
|
+
|
|
187
|
+
// Market and CLOB queries
|
|
188
|
+
const markets = await client.market.getMarkets();
|
|
189
|
+
const market = await client.market.getMarket(1);
|
|
190
|
+
const orders = await client.clob.getOrders({ orderer: client.address, marketId: 1 });
|
|
191
|
+
|
|
192
|
+
// Reward queries
|
|
193
|
+
const rewardParams = await client.reward.getParams();
|
|
194
|
+
const referralCode = await client.reward.getReferralCode(client.address);
|
|
195
|
+
const builderAllowances = await client.reward.getBuilderAllowances({ user: client.address });
|
|
196
|
+
|
|
197
|
+
// TokenRegistry queries
|
|
198
|
+
const tokenRegistryParams = await client.tokenregistry.getParams();
|
|
199
|
+
const tokenPair = await client.tokenregistry.getTokenPair(
|
|
200
|
+
"0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B",
|
|
201
|
+
);
|
|
202
|
+
const tokenPairs = await client.tokenregistry.getTokenPairs();
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## DEX API
|
|
206
|
+
|
|
207
|
+
The SDK includes a client for the Ault DEX API — a REST API for market data, order books, trades, balances, and UDF charting. This is a separate service from the on-chain Cosmos REST endpoints.
|
|
208
|
+
|
|
209
|
+
### Market Data
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
import { createAultClient, getNetworkConfig } from "ault-sdk-ts";
|
|
213
|
+
|
|
214
|
+
const client = createAultClient({
|
|
215
|
+
network: { ...getNetworkConfig("<CHAIN_ID>"), dexApiUrl: "<DEX_API_URL>" },
|
|
216
|
+
});
|
|
217
|
+
const dex = client.rest.dex;
|
|
218
|
+
|
|
219
|
+
// Markets and currencies
|
|
220
|
+
const markets = await dex.listMarkets();
|
|
221
|
+
const currencies = await dex.listCurrencies();
|
|
222
|
+
|
|
223
|
+
// Tickers
|
|
224
|
+
const ticker = await dex.getTicker("AULT/USDT");
|
|
225
|
+
const allTickers = await dex.getAllTickers();
|
|
226
|
+
|
|
227
|
+
// Order book
|
|
228
|
+
const orderbook = await dex.getOrderbook("AULT/USDT", { limit: 50 });
|
|
229
|
+
|
|
230
|
+
// Recent trades
|
|
231
|
+
const trades = await dex.listTrades("AULT/USDT", { limit: 100, since: 1773600000000 });
|
|
232
|
+
|
|
233
|
+
// Trading fees
|
|
234
|
+
const fees = await dex.getTradingFees();
|
|
235
|
+
|
|
236
|
+
// OHLCV candles
|
|
237
|
+
const candles = await dex.getOHLCV("AULT/USDT", {
|
|
238
|
+
timeframe: "1h",
|
|
239
|
+
limit: 100,
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### User Queries
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
// Orders for an address
|
|
247
|
+
const orders = await dex.listOrders({
|
|
248
|
+
address: "ault1...",
|
|
249
|
+
status: "open",
|
|
250
|
+
symbol: "AULT/USDT",
|
|
251
|
+
limit: 50,
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
// Single order by ID
|
|
255
|
+
const order = await dex.getOrder("010000000000000000000002");
|
|
256
|
+
|
|
257
|
+
// User's trade history
|
|
258
|
+
const myTrades = await dex.listMyTrades({
|
|
259
|
+
address: "ault1...",
|
|
260
|
+
symbol: "AULT/USDT",
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
// Balances
|
|
264
|
+
const balances = await dex.getBalance({ address: "ault1..." });
|
|
265
|
+
console.log(balances.free); // { AULT: 100, USDT: 500 }
|
|
266
|
+
console.log(balances.total); // { AULT: 150, USDT: 500 }
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### UDF charting
|
|
270
|
+
|
|
271
|
+
All UDF (TradingView) charting endpoints are available on `dex`:
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
const config = await dex.getUDFConfig();
|
|
275
|
+
const serverTime = await dex.getUDFTime();
|
|
276
|
+
const symbolInfo = await dex.getUDFSymbol({ symbol: "AULT/USDT" });
|
|
277
|
+
|
|
278
|
+
const results = await dex.searchUDFSymbols({ query: "AULT", limit: 10 });
|
|
279
|
+
|
|
280
|
+
const history = await dex.getUDFHistory({
|
|
281
|
+
symbol: "AULT/USDT",
|
|
282
|
+
resolution: "60",
|
|
283
|
+
from: 1773500000,
|
|
284
|
+
to: 1773600000,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
const quotes = await dex.getUDFQuotes({ symbols: "AULT/USDT,BTC/USDT" });
|
|
288
|
+
const marks = await dex.getUDFMarks({ symbol: "AULT/USDT", from: 1773500000, to: 1773600000 });
|
|
289
|
+
const tsMarks = await dex.getUDFTimescaleMarks({
|
|
290
|
+
symbol: "AULT/USDT",
|
|
291
|
+
from: 1773500000,
|
|
292
|
+
to: 1773600000,
|
|
293
|
+
});
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## DEX WebSocket
|
|
297
|
+
|
|
298
|
+
The SDK includes a WebSocket client for real-time streaming from the DEX API. All payload types are shared with the REST client — no extra types needed.
|
|
299
|
+
|
|
300
|
+
### Connecting
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
import { createAultClient, getNetworkConfig } from "ault-sdk-ts";
|
|
304
|
+
|
|
305
|
+
const client = createAultClient({
|
|
306
|
+
network: { ...getNetworkConfig("<CHAIN_ID>"), dexApiUrl: "<DEX_API_URL>" },
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
// The WS client is created lazily from dexApiUrl (http→ws, appends /ws)
|
|
310
|
+
await client.ws.connect();
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
Or use the standalone factory:
|
|
314
|
+
|
|
315
|
+
```typescript
|
|
316
|
+
import { createDexWs } from "ault-sdk-ts";
|
|
317
|
+
|
|
318
|
+
const ws = createDexWs("wss://my-dex-api.example.com/ws");
|
|
319
|
+
await ws.connect();
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### Subscribing to Topics
|
|
323
|
+
|
|
324
|
+
Subscriptions are type-safe — the `onData` callback is automatically typed based on the topic string.
|
|
325
|
+
|
|
326
|
+
```typescript
|
|
327
|
+
// Orderbook snapshots (data typed as OrderbookResponse)
|
|
328
|
+
const sub = client.ws.subscribe("orderbook:AULT/USDT", {
|
|
329
|
+
onData: (orderbook) => {
|
|
330
|
+
console.log(orderbook.bids[0], orderbook.asks[0]);
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
// Trades (data typed as TradeResponse[])
|
|
335
|
+
client.ws.subscribe("trades:AULT/USDT", {
|
|
336
|
+
onData: (trades) => {
|
|
337
|
+
for (const t of trades) console.log(t.side, t.price, t.amount);
|
|
338
|
+
},
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
// 24h ticker (data typed as TickerResponse)
|
|
342
|
+
client.ws.subscribe("ticker:AULT/USDT", {
|
|
343
|
+
onData: (ticker) => console.log(ticker.last, ticker.percentage),
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
// OHLCV candles (data typed as OHLCVEntry)
|
|
347
|
+
client.ws.subscribe("chart:AULT/USDT:60", {
|
|
348
|
+
onData: (bar) => console.log(bar), // [timestamp, o, h, l, c, v]
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
// Unsubscribe
|
|
352
|
+
sub.unsubscribe();
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### Subscription Options
|
|
356
|
+
|
|
357
|
+
```typescript
|
|
358
|
+
// TTL: auto-expire after 300 seconds
|
|
359
|
+
client.ws.subscribe(
|
|
360
|
+
"orderbook:AULT/USDT",
|
|
361
|
+
{
|
|
362
|
+
onData: (data) => {
|
|
363
|
+
/* ... */
|
|
364
|
+
},
|
|
365
|
+
onSubscribed: () => console.log("subscribed!"),
|
|
366
|
+
onExpired: () => console.log("subscription expired"),
|
|
367
|
+
onError: (err) => console.error(err),
|
|
368
|
+
},
|
|
369
|
+
{ ttl: 300 },
|
|
370
|
+
);
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### Address Topics
|
|
374
|
+
|
|
375
|
+
Address topics (`orders`, `balances`, `mytrades`) expose read-only projections
|
|
376
|
+
of public on-chain state — no authentication is required:
|
|
377
|
+
|
|
378
|
+
```typescript
|
|
379
|
+
// Orders (data typed as OrderResponse[])
|
|
380
|
+
client.ws.subscribe("orders:ault1...", {
|
|
381
|
+
onData: (orders) => {
|
|
382
|
+
for (const o of orders) console.log(o.id, o.status, o.filled);
|
|
383
|
+
},
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
// Balances (data typed as BalancesResponse)
|
|
387
|
+
client.ws.subscribe("balances:ault1...", {
|
|
388
|
+
onData: (balances) => console.log(balances.free),
|
|
389
|
+
});
|
|
390
|
+
|
|
391
|
+
// User trades (data typed as TradeResponse[])
|
|
392
|
+
client.ws.subscribe("mytrades:ault1...", {
|
|
393
|
+
onData: (trades) => console.log(trades[0].order, trades[0].price),
|
|
394
|
+
});
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### Connection Events
|
|
398
|
+
|
|
399
|
+
```typescript
|
|
400
|
+
client.ws.on("open", () => console.log("connected"));
|
|
401
|
+
client.ws.on("close", (code, reason) => console.log("closed", code, reason));
|
|
402
|
+
client.ws.on("error", (err) => console.error(err));
|
|
403
|
+
client.ws.on("reconnecting", (attempt) => console.log("reconnecting...", attempt));
|
|
404
|
+
client.ws.on("reconnected", () => console.log("reconnected"));
|
|
405
|
+
|
|
406
|
+
// Raw message listener
|
|
407
|
+
client.ws.on("message", (msg) => console.log(msg.topic, msg.event));
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### Reconnection
|
|
411
|
+
|
|
412
|
+
Auto-reconnect is enabled by default with exponential backoff. On reconnect, all active subscriptions are automatically restored (including re-authentication if needed).
|
|
413
|
+
|
|
414
|
+
```typescript
|
|
415
|
+
const ws = createDexWs("wss://my-dex-api.example.com/ws", {
|
|
416
|
+
reconnect: true, // default: true
|
|
417
|
+
reconnectDelay: 1000, // default: 1000ms
|
|
418
|
+
maxReconnectDelay: 30000, // default: 30000ms
|
|
419
|
+
maxReconnectAttempts: Infinity, // default: Infinity
|
|
420
|
+
});
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Disconnecting
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
client.ws.disconnect();
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
## Parallel Query Helpers
|
|
430
|
+
|
|
431
|
+
For analyzing large numbers of licenses efficiently, use the parallel query helpers:
|
|
432
|
+
|
|
433
|
+
```typescript
|
|
434
|
+
// Analyze all licenses for an owner in one call (parallel fetching)
|
|
435
|
+
const analysis = await client.analyzeLicenses("ault1...");
|
|
436
|
+
console.log(`Total: ${analysis.total}`);
|
|
437
|
+
console.log(`Active: ${analysis.active}`);
|
|
438
|
+
console.log(`Delegated: ${analysis.delegated}`);
|
|
439
|
+
|
|
440
|
+
// Group delegations by operator
|
|
441
|
+
const byOperator = new Map<string, number>();
|
|
442
|
+
for (const d of analysis.delegations) {
|
|
443
|
+
byOperator.set(d.operator, (byOperator.get(d.operator) ?? 0) + 1);
|
|
444
|
+
}
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
The `analyzeLicenses()` method fetches all data in parallel batches, making it much faster than sequential queries. For an address with 464 licenses, it completes in ~15-30 seconds instead of several minutes.
|
|
448
|
+
|
|
449
|
+
### Individual Parallel Helpers
|
|
450
|
+
|
|
451
|
+
For more control, use the individual parallel helpers:
|
|
452
|
+
|
|
453
|
+
```typescript
|
|
454
|
+
// Get all license IDs owned by an address (parallel batched)
|
|
455
|
+
const licenseIds = await client.getAllLicenseIds("ault1...");
|
|
456
|
+
|
|
457
|
+
// Get license details for multiple IDs in parallel
|
|
458
|
+
const licenses = await client.getLicenseDetailsParallel(licenseIds);
|
|
459
|
+
|
|
460
|
+
// Get delegation status for multiple IDs in parallel
|
|
461
|
+
const delegations = await client.getLicenseDelegationsParallel(licenseIds);
|
|
462
|
+
|
|
463
|
+
// Process results
|
|
464
|
+
for (const d of delegations) {
|
|
465
|
+
if (d.isDelegated) {
|
|
466
|
+
console.log(`License ${d.licenseId} delegated to ${d.operator}`);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
## Transaction Methods
|
|
472
|
+
|
|
473
|
+
All transaction methods return a `TxResult`:
|
|
474
|
+
|
|
475
|
+
```typescript
|
|
476
|
+
interface TxResult {
|
|
477
|
+
txHash: string; // Transaction hash
|
|
478
|
+
code: number; // Result code (0 = success)
|
|
479
|
+
rawLog?: string; // Raw log from transaction
|
|
480
|
+
confirmed?: boolean; // true = definitive result, false = timed out, undefined = confirmation lookup unavailable
|
|
481
|
+
success: boolean; // True only when DeliverTx success was confirmed
|
|
482
|
+
}
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
### License Transactions
|
|
486
|
+
|
|
487
|
+
```typescript
|
|
488
|
+
// Mint a license
|
|
489
|
+
await client.mintLicense({
|
|
490
|
+
to: "0x...", // EVM or ault1 address
|
|
491
|
+
uri: "https://example.com/metadata.json",
|
|
492
|
+
reason: "Minted via SDK", // Optional, defaults to ""
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
// Batch mint
|
|
496
|
+
await client.batchMintLicense({
|
|
497
|
+
recipients: [
|
|
498
|
+
{ to: "0xAddr1...", uri: "https://example.com/1.json" },
|
|
499
|
+
{ to: "0xAddr2...", uri: "https://example.com/2.json" },
|
|
500
|
+
],
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
// Transfer
|
|
504
|
+
await client.transferLicense({
|
|
505
|
+
licenseId: 123, // bigint, number, or string
|
|
506
|
+
to: "0x...",
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
// Burn/Revoke (admin only)
|
|
510
|
+
await client.burnLicense({ licenseId: 123 });
|
|
511
|
+
await client.revokeLicense({ licenseId: 123 });
|
|
512
|
+
|
|
513
|
+
// KYC management
|
|
514
|
+
await client.approveMember({ member: "0x..." });
|
|
515
|
+
await client.revokeMember({ member: "0x..." });
|
|
516
|
+
await client.batchApproveMember({ members: ["0x...", "0x..."] });
|
|
517
|
+
|
|
518
|
+
// Admin functions
|
|
519
|
+
await client.setMinters({ add: ["0x..."], remove: [] });
|
|
520
|
+
await client.setKYCApprovers({ add: ["0x..."], remove: [] });
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
### Miner Transactions
|
|
524
|
+
|
|
525
|
+
```typescript
|
|
526
|
+
import { base64ToBytes, MarketType } from "ault-sdk-ts";
|
|
527
|
+
|
|
528
|
+
// Delegate licenses to an operator
|
|
529
|
+
await client.delegateMining({
|
|
530
|
+
licenseIds: [1, 2, 3], // bigint[], number[], or string[]
|
|
531
|
+
operator: "0xOperator...",
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
// Cancel mining delegation
|
|
535
|
+
await client.cancelMiningDelegation({
|
|
536
|
+
licenseIds: [1, 2, 3],
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
// Redelegate to a new operator
|
|
540
|
+
await client.redelegateMining({
|
|
541
|
+
licenseIds: [1, 2, 3],
|
|
542
|
+
newOperator: "0xNewOperator...",
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
// Set VRF key (Uint8Array)
|
|
546
|
+
await client.setOwnerVrfKey({
|
|
547
|
+
vrfPubkey: base64ToBytes("base64..."),
|
|
548
|
+
possessionProof: base64ToBytes("base64..."),
|
|
549
|
+
nonce: 1n,
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
// Submit mining work (Uint8Array)
|
|
553
|
+
await client.submitWork({
|
|
554
|
+
licenseId: 123,
|
|
555
|
+
epoch: 456,
|
|
556
|
+
y: base64ToBytes("base64..."),
|
|
557
|
+
proof: base64ToBytes("base64..."),
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
// Batch submit work
|
|
561
|
+
await client.batchSubmitWork({
|
|
562
|
+
submissions: [
|
|
563
|
+
{ licenseId: 1, epoch: 100, y: base64ToBytes("..."), proof: base64ToBytes("...") },
|
|
564
|
+
{ licenseId: 2, epoch: 100, y: base64ToBytes("..."), proof: base64ToBytes("...") },
|
|
565
|
+
],
|
|
566
|
+
});
|
|
567
|
+
|
|
568
|
+
// Operator management
|
|
569
|
+
await client.registerOperator({
|
|
570
|
+
commissionRate: 5, // Percentage (0-100)
|
|
571
|
+
commissionRecipient: "0x...", // Optional, defaults to signer
|
|
572
|
+
});
|
|
573
|
+
await client.unregisterOperator();
|
|
574
|
+
await client.updateOperatorInfo({
|
|
575
|
+
newCommissionRate: 6,
|
|
576
|
+
newCommissionRecipient: "0x...",
|
|
577
|
+
});
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
### Market And CLOB Transactions
|
|
581
|
+
|
|
582
|
+
```typescript
|
|
583
|
+
import { base64ToBytes } from "ault-sdk-ts";
|
|
584
|
+
|
|
585
|
+
// Place a limit order
|
|
586
|
+
await client.placeLimitOrder({
|
|
587
|
+
marketId: 1,
|
|
588
|
+
isBuy: true,
|
|
589
|
+
price: "1.5",
|
|
590
|
+
quantity: "100",
|
|
591
|
+
lifespan: { seconds: 3600n, nanos: 0 }, // 1 hour
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
// Place a market order
|
|
595
|
+
await client.placeMarketOrder({
|
|
596
|
+
marketId: 1,
|
|
597
|
+
isBuy: true,
|
|
598
|
+
deposit: "100",
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
// Cancel specific orders
|
|
602
|
+
await client.cancelOrders({ orderIds: [base64ToBytes("base64OrderId...")] });
|
|
603
|
+
|
|
604
|
+
// Create a market
|
|
605
|
+
await client.createMarket({
|
|
606
|
+
marketType: MarketType.MARKET_TYPE_SPOT,
|
|
607
|
+
baseDenom: "uatom",
|
|
608
|
+
quoteDenom: "uusdc",
|
|
609
|
+
tickPrecision: 6,
|
|
610
|
+
});
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
### Reward And TokenRegistry Transactions
|
|
614
|
+
|
|
615
|
+
```typescript
|
|
616
|
+
// Create a referral code as an eligible referrer
|
|
617
|
+
await client.setReferralCode({
|
|
618
|
+
code: "RW18A001",
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
// Approve a builder fee allowance
|
|
622
|
+
await client.approveBuilder({
|
|
623
|
+
builder: "0x0000000000000000000000000000000000000001",
|
|
624
|
+
maxFeeRate: "0.005",
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
// Register an ERC20 token pair
|
|
628
|
+
await client.registerTokenPair({
|
|
629
|
+
erc20Address: "0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B",
|
|
630
|
+
enabled: true,
|
|
631
|
+
});
|
|
632
|
+
|
|
633
|
+
// Toggle module-wide token conversions
|
|
634
|
+
await client.disableTokenRegistryTransfers();
|
|
635
|
+
await client.enableTokenRegistryTransfers();
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
### Transaction Options
|
|
639
|
+
|
|
640
|
+
All transaction methods accept optional `gasLimit` and `memo`:
|
|
641
|
+
|
|
642
|
+
```typescript
|
|
643
|
+
await client.delegateMining({
|
|
644
|
+
licenseIds: [1, 2, 3],
|
|
645
|
+
operator: "0x...",
|
|
646
|
+
gasLimit: "300000", // Override default gas limit
|
|
647
|
+
memo: "Delegating via SDK", // Custom memo
|
|
648
|
+
});
|
|
649
|
+
```
|
|
650
|
+
|
|
651
|
+
## Development
|
|
652
|
+
|
|
653
|
+
### Generating Protos
|
|
654
|
+
|
|
655
|
+
Proto and EIP-712 generation expects both the Ault core repo and the Cosmos SDK repo to be checked out alongside this repo:
|
|
656
|
+
|
|
657
|
+
```
|
|
658
|
+
../ault/proto
|
|
659
|
+
../cosmos-sdk/proto
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
From this repo root, run:
|
|
663
|
+
|
|
664
|
+
```bash
|
|
665
|
+
pnpm gen:proto
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
Note: `pnpm gen:eip712` also reads Cosmos SDK protos (staking/distribution) and requires `../cosmos-sdk/proto`.
|
|
669
|
+
|
|
670
|
+
## Error Handling
|
|
671
|
+
|
|
672
|
+
```typescript
|
|
673
|
+
import { ApiError, NetworkError, TimeoutError } from "ault-sdk-ts";
|
|
674
|
+
|
|
675
|
+
try {
|
|
676
|
+
const result = await client.mintLicense({ to: "0x...", uri: "..." });
|
|
677
|
+
if (result.success) {
|
|
678
|
+
console.log(`Transaction committed: ${result.txHash}`);
|
|
679
|
+
} else if (result.confirmed === false) {
|
|
680
|
+
console.warn(`Transaction broadcast but not confirmed yet: ${result.txHash}`);
|
|
681
|
+
} else if (result.confirmed === undefined) {
|
|
682
|
+
console.warn(
|
|
683
|
+
`Transaction accepted by CheckTx, but this node cannot confirm it: ${result.txHash}`,
|
|
684
|
+
);
|
|
685
|
+
} else {
|
|
686
|
+
console.error(`Transaction failed: ${result.rawLog}`);
|
|
687
|
+
}
|
|
688
|
+
} catch (error) {
|
|
689
|
+
if (error instanceof ApiError) {
|
|
690
|
+
console.error(`API Error (${error.status}): ${error.message}`);
|
|
691
|
+
} else if (error instanceof NetworkError) {
|
|
692
|
+
console.error(`Network Error: ${error.message}`);
|
|
693
|
+
} else if (error instanceof TimeoutError) {
|
|
694
|
+
console.error("Request timed out");
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
```
|
|
698
|
+
|
|
699
|
+
## Advanced Usage
|
|
700
|
+
|
|
701
|
+
For advanced use cases, you can access the low-level client:
|
|
702
|
+
|
|
703
|
+
```typescript
|
|
704
|
+
// Access low-level client
|
|
705
|
+
const lowLevel = client._lowLevel;
|
|
706
|
+
|
|
707
|
+
// Build EIP-712 typed data manually
|
|
708
|
+
const typedData = lowLevel.eip712.buildTypedData(context, msgs);
|
|
709
|
+
|
|
710
|
+
// Use the msg namespace directly
|
|
711
|
+
import { msg } from "ault-sdk-ts";
|
|
712
|
+
import { privateKeyToAccount } from "viem/accounts";
|
|
713
|
+
|
|
714
|
+
const mySigner = privateKeyToAccount("0x...");
|
|
715
|
+
|
|
716
|
+
const delegateMsg = msg.miner.delegateMining({
|
|
717
|
+
owner: "ault1...",
|
|
718
|
+
operator: "ault1...",
|
|
719
|
+
licenseIds: [1n, 2n, 3n],
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
// Sign and broadcast manually
|
|
723
|
+
const result = await lowLevel.eip712.signAndBroadcast({
|
|
724
|
+
signer: mySigner, // provide the signer explicitly
|
|
725
|
+
signerAddress: "ault1...",
|
|
726
|
+
msgs: [delegateMsg],
|
|
727
|
+
});
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
### Low-Level Client
|
|
731
|
+
|
|
732
|
+
For more control, use `createAultClient()` directly:
|
|
733
|
+
|
|
734
|
+
```typescript
|
|
735
|
+
import { createAultClient, getNetworkConfig, msg, signAndBroadcastEip712 } from "ault-sdk-ts";
|
|
736
|
+
|
|
737
|
+
const client = createAultClient({
|
|
738
|
+
network: getNetworkConfig("ault_10904-1"),
|
|
739
|
+
});
|
|
740
|
+
|
|
741
|
+
// Query
|
|
742
|
+
const licenses = await client.rest.license.getLicenses();
|
|
743
|
+
|
|
744
|
+
// Build and broadcast transactions manually
|
|
745
|
+
const result = await signAndBroadcastEip712({
|
|
746
|
+
network: client.network,
|
|
747
|
+
signer: mySigner,
|
|
748
|
+
signerAddress: "ault1...",
|
|
749
|
+
msgs: [
|
|
750
|
+
msg.miner.delegateMining({
|
|
751
|
+
owner: "ault1...",
|
|
752
|
+
operator: "ault1...",
|
|
753
|
+
licenseIds: [1n, 2n, 3n],
|
|
754
|
+
}),
|
|
755
|
+
],
|
|
756
|
+
});
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
## Network Configuration
|
|
760
|
+
|
|
761
|
+
```typescript
|
|
762
|
+
import { getNetworkConfig, NETWORKS } from "ault-sdk-ts";
|
|
763
|
+
|
|
764
|
+
// Use predefined networks
|
|
765
|
+
const testnet = getNetworkConfig("ault_10904-1");
|
|
766
|
+
const localnet = getNetworkConfig("ault_30904-1");
|
|
767
|
+
|
|
768
|
+
// Or define custom network
|
|
769
|
+
const customNetwork = {
|
|
770
|
+
name: "My Network",
|
|
771
|
+
type: "testnet" as const,
|
|
772
|
+
chainId: "ault_10904-1",
|
|
773
|
+
evmChainId: 10904,
|
|
774
|
+
rpcUrl: "https://my-rpc.example.com",
|
|
775
|
+
restUrl: "https://my-rest.example.com",
|
|
776
|
+
evmRpcUrl: "https://my-evm.example.com",
|
|
777
|
+
dexApiUrl: "https://my-dex-api.example.com",
|
|
778
|
+
dexWsUrl: "wss://my-dex-api.example.com/ws", // optional, derived from dexApiUrl if omitted
|
|
779
|
+
isProduction: false,
|
|
780
|
+
};
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
## Utility Functions
|
|
784
|
+
|
|
785
|
+
```typescript
|
|
786
|
+
import {
|
|
787
|
+
evmToAult,
|
|
788
|
+
aultToEvm,
|
|
789
|
+
isValidAultAddress,
|
|
790
|
+
isValidEvmAddress,
|
|
791
|
+
parseEvmChainIdFromCosmosChainId,
|
|
792
|
+
} from "ault-sdk-ts";
|
|
793
|
+
|
|
794
|
+
// Address conversion
|
|
795
|
+
const aultAddr = evmToAult("0x1234...abcd"); // => "ault1..."
|
|
796
|
+
const evmAddr = aultToEvm("ault1..."); // => "0x1234...abcd"
|
|
797
|
+
|
|
798
|
+
// Validation
|
|
799
|
+
isValidAultAddress("ault1..."); // true/false
|
|
800
|
+
isValidEvmAddress("0x1234..."); // true/false
|
|
801
|
+
|
|
802
|
+
// Chain ID
|
|
803
|
+
const evmChainId = parseEvmChainIdFromCosmosChainId("ault_10904-1"); // => 10904
|
|
804
|
+
```
|
|
805
|
+
|
|
806
|
+
## Constants
|
|
807
|
+
|
|
808
|
+
```typescript
|
|
809
|
+
import { GAS_CONSTANTS, TIMING_CONSTANTS } from "ault-sdk-ts";
|
|
810
|
+
|
|
811
|
+
GAS_CONSTANTS.EIP712_FEE_AMOUNT; // '5000000000000000'
|
|
812
|
+
GAS_CONSTANTS.EIP712_GAS_LIMIT; // '200000'
|
|
813
|
+
GAS_CONSTANTS.DENOM; // 'aault'
|
|
814
|
+
GAS_CONSTANTS.PER_LICENSE; // 200000
|
|
815
|
+
|
|
816
|
+
TIMING_CONSTANTS.API_TIMEOUT_MS; // 30000
|
|
817
|
+
TIMING_CONSTANTS.API_RETRY_DELAY_MS; // 1000
|
|
818
|
+
TIMING_CONSTANTS.API_MAX_BACKOFF_MS; // 30000
|
|
819
|
+
```
|
|
820
|
+
|
|
821
|
+
## Runtime Compatibility
|
|
822
|
+
|
|
823
|
+
- **Node.js**: Requires Node.js 18+ (for native fetch) or provide custom fetch
|
|
824
|
+
- **Bun**: Full support
|
|
825
|
+
- **Browser**: Full support in modern browsers
|
|
826
|
+
|
|
827
|
+
For older Node.js versions:
|
|
828
|
+
|
|
829
|
+
```typescript
|
|
830
|
+
import fetch from "node-fetch";
|
|
831
|
+
|
|
832
|
+
const client = await createClient({
|
|
833
|
+
network: getNetworkConfig("ault_10904-1"),
|
|
834
|
+
signer: mySigner,
|
|
835
|
+
fetchFn: fetch as unknown as typeof globalThis.fetch,
|
|
836
|
+
});
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
## Releases
|
|
840
|
+
|
|
841
|
+
This project uses [Semantic Versioning](https://semver.org/) and publishes to npm via GitHub Actions.
|
|
842
|
+
|
|
843
|
+
### Publishing a stable release
|
|
844
|
+
|
|
845
|
+
1. Update `CHANGELOG.md` with the changes since the last release.
|
|
846
|
+
|
|
847
|
+
2. Bump the version in `package.json`:
|
|
848
|
+
|
|
849
|
+
```bash
|
|
850
|
+
# Patch release (bug fixes): 0.0.2 -> 0.0.3
|
|
851
|
+
npm version patch --no-git-tag-version
|
|
852
|
+
|
|
853
|
+
# Minor release (new features): 0.0.2 -> 0.1.0
|
|
854
|
+
npm version minor --no-git-tag-version
|
|
855
|
+
|
|
856
|
+
# Major release (breaking changes): 0.0.2 -> 1.0.0
|
|
857
|
+
npm version major --no-git-tag-version
|
|
858
|
+
```
|
|
859
|
+
|
|
860
|
+
3. Commit, tag, and push:
|
|
861
|
+
|
|
862
|
+
```bash
|
|
863
|
+
git add package.json CHANGELOG.md
|
|
864
|
+
git commit -m "chore: release v0.1.0"
|
|
865
|
+
git tag v0.1.0
|
|
866
|
+
git push origin master v0.1.0
|
|
867
|
+
```
|
|
868
|
+
|
|
869
|
+
4. The `Publish` workflow runs automatically: validates the build, publishes to npm with provenance, and creates a GitHub Release with auto-generated notes.
|
|
870
|
+
|
|
871
|
+
### Publishing a pre-release (alpha / beta / rc)
|
|
872
|
+
|
|
873
|
+
Pre-release tags publish to a separate npm dist-tag so they never become the default install.
|
|
874
|
+
|
|
875
|
+
```bash
|
|
876
|
+
# Set the pre-release version
|
|
877
|
+
npm version 0.1.0-alpha.1 --no-git-tag-version
|
|
878
|
+
|
|
879
|
+
git add package.json
|
|
880
|
+
git commit -m "chore: release v0.1.0-alpha.1"
|
|
881
|
+
git tag v0.1.0-alpha.1
|
|
882
|
+
git push origin master v0.1.0-alpha.1
|
|
883
|
+
```
|
|
884
|
+
|
|
885
|
+
Consumers install with the corresponding tag:
|
|
886
|
+
|
|
887
|
+
```bash
|
|
888
|
+
npm install ault-sdk-ts@alpha # latest alpha
|
|
889
|
+
npm install ault-sdk-ts@beta # latest beta
|
|
890
|
+
npm install ault-sdk-ts@rc # latest release candidate
|
|
891
|
+
```
|
|
892
|
+
|
|
893
|
+
| Tag pattern | npm dist-tag | GitHub Release |
|
|
894
|
+
| ---------------- | ------------ | -------------- |
|
|
895
|
+
| `v0.1.0` | `latest` | stable |
|
|
896
|
+
| `v0.1.0-alpha.*` | `alpha` | pre-release |
|
|
897
|
+
| `v0.1.0-beta.*` | `beta` | pre-release |
|
|
898
|
+
| `v0.1.0-rc.*` | `rc` | pre-release |
|
|
899
|
+
|
|
900
|
+
### CI checks
|
|
901
|
+
|
|
902
|
+
All PRs and pushes to `master` run:
|
|
903
|
+
|
|
904
|
+
- Lint (oxlint)
|
|
905
|
+
- Typecheck (tsc)
|
|
906
|
+
- Unit tests (vitest)
|
|
907
|
+
- Build validation
|
|
908
|
+
- Package contents check (`npm pack --dry-run`)
|
|
909
|
+
|
|
910
|
+
### PR conventions
|
|
911
|
+
|
|
912
|
+
- PR titles should follow [Conventional Commits](https://www.conventionalcommits.org/) (e.g. `feat: add batch orders`, `fix: WebSocket reconnect`). A bot will comment if the title doesn't match — this is a warning, not a blocker.
|
|
913
|
+
- PRs with user-facing changes (`feat:`, `fix:`) should update `CHANGELOG.md`.
|
|
914
|
+
|
|
915
|
+
### Repository setup
|
|
916
|
+
|
|
917
|
+
Required GitHub Actions secrets:
|
|
918
|
+
|
|
919
|
+
- `NPM_TOKEN` — npm access token with publish rights for `ault-sdk-ts`
|
|
920
|
+
|
|
921
|
+
## License
|
|
922
|
+
|
|
923
|
+
MIT
|