ault-sdk-ts 0.0.2-alpha.5 → 0.0.2-alpha.7
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 +6 -15
- package/dist/index.cjs +15 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -41
- package/dist/index.js.map +1 -1
- package/dist/ws/client.d.ts +0 -3
- package/dist/ws/types.d.ts +1 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -370,35 +370,26 @@ client.ws.subscribe(
|
|
|
370
370
|
);
|
|
371
371
|
```
|
|
372
372
|
|
|
373
|
-
###
|
|
373
|
+
### Address Topics
|
|
374
374
|
|
|
375
|
-
|
|
375
|
+
Address topics (`orders`, `balances`, `mytrades`) expose read-only projections
|
|
376
|
+
of public on-chain state — no authentication is required:
|
|
376
377
|
|
|
377
378
|
```typescript
|
|
378
|
-
const ws = createDexWs("wss://my-dex-api.example.com/ws", {
|
|
379
|
-
address: "ault1...",
|
|
380
|
-
signMessage: async (msg) => {
|
|
381
|
-
// Sign the message and return base64 signature
|
|
382
|
-
return await wallet.signArbitrary(msg);
|
|
383
|
-
},
|
|
384
|
-
});
|
|
385
|
-
await ws.connect();
|
|
386
|
-
await ws.authenticate();
|
|
387
|
-
|
|
388
379
|
// Orders (data typed as OrderResponse[])
|
|
389
|
-
ws.subscribe("orders:ault1...", {
|
|
380
|
+
client.ws.subscribe("orders:ault1...", {
|
|
390
381
|
onData: (orders) => {
|
|
391
382
|
for (const o of orders) console.log(o.id, o.status, o.filled);
|
|
392
383
|
},
|
|
393
384
|
});
|
|
394
385
|
|
|
395
386
|
// Balances (data typed as BalancesResponse)
|
|
396
|
-
ws.subscribe("balances:ault1...", {
|
|
387
|
+
client.ws.subscribe("balances:ault1...", {
|
|
397
388
|
onData: (balances) => console.log(balances.free),
|
|
398
389
|
});
|
|
399
390
|
|
|
400
391
|
// User trades (data typed as TradeResponse[])
|
|
401
|
-
ws.subscribe("mytrades:ault1...", {
|
|
392
|
+
client.ws.subscribe("mytrades:ault1...", {
|
|
402
393
|
onData: (trades) => console.log(trades[0].order, trades[0].price),
|
|
403
394
|
});
|
|
404
395
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -579,6 +579,17 @@ var NETWORKS = {
|
|
|
579
579
|
explorerUrl: "https://testnet-cosmos-explorer.cloud.aultblockchain.xyz",
|
|
580
580
|
isProduction: false
|
|
581
581
|
},
|
|
582
|
+
"ault_20904-1": {
|
|
583
|
+
name: "Ault Devnet",
|
|
584
|
+
type: "devnet",
|
|
585
|
+
chainId: "ault_20904-1",
|
|
586
|
+
evmChainId: 20904,
|
|
587
|
+
rpcUrl: "https://devnet-rpc.aultblockchain.xyz",
|
|
588
|
+
restUrl: "https://devnet-api.aultblockchain.xyz",
|
|
589
|
+
evmRpcUrl: "https://devnet-json-rpc.aultblockchain.xyz",
|
|
590
|
+
explorerUrl: "https://devnet-cosmos-explorer.aultblockchain.xyz",
|
|
591
|
+
isProduction: false
|
|
592
|
+
},
|
|
582
593
|
"ault_30904-1": {
|
|
583
594
|
name: "Ault Localnet",
|
|
584
595
|
type: "localnet",
|
|
@@ -5269,16 +5280,13 @@ var DexWsClient = class {
|
|
|
5269
5280
|
this.pendingCommands = /* @__PURE__ */ new Map();
|
|
5270
5281
|
this.reconnectAttempt = 0;
|
|
5271
5282
|
this.reconnectTimer = null;
|
|
5272
|
-
this.authenticated = false;
|
|
5273
5283
|
this.connectResolvers = [];
|
|
5274
5284
|
this.url = url;
|
|
5275
5285
|
this.options = {
|
|
5276
5286
|
reconnect: opts?.reconnect ?? true,
|
|
5277
5287
|
maxReconnectAttempts: opts?.maxReconnectAttempts ?? Infinity,
|
|
5278
5288
|
reconnectDelay: opts?.reconnectDelay ?? 1e3,
|
|
5279
|
-
maxReconnectDelay: opts?.maxReconnectDelay ?? 3e4
|
|
5280
|
-
signMessage: opts?.signMessage,
|
|
5281
|
-
address: opts?.address
|
|
5289
|
+
maxReconnectDelay: opts?.maxReconnectDelay ?? 3e4
|
|
5282
5290
|
};
|
|
5283
5291
|
}
|
|
5284
5292
|
// -----------------------------------------------------------------------
|
|
@@ -5287,9 +5295,6 @@ var DexWsClient = class {
|
|
|
5287
5295
|
get state() {
|
|
5288
5296
|
return this.connectionState;
|
|
5289
5297
|
}
|
|
5290
|
-
get isAuthenticated() {
|
|
5291
|
-
return this.authenticated;
|
|
5292
|
-
}
|
|
5293
5298
|
connect() {
|
|
5294
5299
|
if (this.connectionState === "connected") return Promise.resolve();
|
|
5295
5300
|
if (this.connectionState === "connecting") {
|
|
@@ -5306,7 +5311,6 @@ var DexWsClient = class {
|
|
|
5306
5311
|
disconnect() {
|
|
5307
5312
|
this.clearReconnectTimer();
|
|
5308
5313
|
this.connectionState = "disconnected";
|
|
5309
|
-
this.authenticated = false;
|
|
5310
5314
|
if (this.ws) {
|
|
5311
5315
|
this.ws.close(NORMAL_CLOSURE);
|
|
5312
5316
|
this.ws = null;
|
|
@@ -5341,26 +5345,6 @@ var DexWsClient = class {
|
|
|
5341
5345
|
this.send({ action: "unsubscribe", topic });
|
|
5342
5346
|
}
|
|
5343
5347
|
}
|
|
5344
|
-
async authenticate(address, signMessage) {
|
|
5345
|
-
const addr = address ?? this.options.address;
|
|
5346
|
-
const signer = signMessage ?? this.options.signMessage;
|
|
5347
|
-
if (!addr || !signer) {
|
|
5348
|
-
throw new WebSocketError("address and signMessage are required for authentication");
|
|
5349
|
-
}
|
|
5350
|
-
const timestamp = Math.floor(Date.now() / 1e3);
|
|
5351
|
-
const message = `ault-dex-auth:${timestamp}`;
|
|
5352
|
-
const signature = await signer(message);
|
|
5353
|
-
const resp = await this.sendCommand({
|
|
5354
|
-
action: "authenticate",
|
|
5355
|
-
address: addr,
|
|
5356
|
-
signature,
|
|
5357
|
-
message
|
|
5358
|
-
});
|
|
5359
|
-
if (!resp.success) {
|
|
5360
|
-
throw new WebSocketError(resp.error ?? "Authentication failed");
|
|
5361
|
-
}
|
|
5362
|
-
this.authenticated = true;
|
|
5363
|
-
}
|
|
5364
5348
|
on(event, handler) {
|
|
5365
5349
|
let set = this.listeners.get(event);
|
|
5366
5350
|
if (!set) {
|
|
@@ -5493,15 +5477,8 @@ var DexWsClient = class {
|
|
|
5493
5477
|
this.createSocket();
|
|
5494
5478
|
}, jitteredDelay);
|
|
5495
5479
|
}
|
|
5496
|
-
|
|
5480
|
+
resubscribeAll() {
|
|
5497
5481
|
this.emit("reconnected");
|
|
5498
|
-
if (this.authenticated) {
|
|
5499
|
-
this.authenticated = false;
|
|
5500
|
-
try {
|
|
5501
|
-
await this.authenticate();
|
|
5502
|
-
} catch {
|
|
5503
|
-
}
|
|
5504
|
-
}
|
|
5505
5482
|
for (const [topic, sub] of this.subscriptions) {
|
|
5506
5483
|
this.send({ action: "subscribe", topic, ttl: sub.ttl });
|
|
5507
5484
|
}
|
|
@@ -16114,10 +16091,7 @@ function createAultClient(options) {
|
|
|
16114
16091
|
"WebSocket URL not configured. Set dexWsUrl or dexApiUrl in your network config."
|
|
16115
16092
|
);
|
|
16116
16093
|
}
|
|
16117
|
-
wsClient = new DexWsClient(wsUrl,
|
|
16118
|
-
address: options.signerAddress,
|
|
16119
|
-
...options.wsOptions
|
|
16120
|
-
});
|
|
16094
|
+
wsClient = new DexWsClient(wsUrl, options.wsOptions);
|
|
16121
16095
|
}
|
|
16122
16096
|
return wsClient;
|
|
16123
16097
|
},
|
|
@@ -18185,7 +18159,7 @@ function createDexWs(url, options) {
|
|
|
18185
18159
|
}
|
|
18186
18160
|
|
|
18187
18161
|
// src/index.ts
|
|
18188
|
-
var SDK_VERSION = "0.0.2-alpha.
|
|
18162
|
+
var SDK_VERSION = "0.0.2-alpha.7";
|
|
18189
18163
|
// Annotate the CommonJS export names for ESM import in node:
|
|
18190
18164
|
0 && (module.exports = {
|
|
18191
18165
|
AGENT_DEFAULTS,
|