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/dist/index.js
CHANGED
|
@@ -308,6 +308,17 @@ var NETWORKS = {
|
|
|
308
308
|
explorerUrl: "https://testnet-cosmos-explorer.cloud.aultblockchain.xyz",
|
|
309
309
|
isProduction: false
|
|
310
310
|
},
|
|
311
|
+
"ault_20904-1": {
|
|
312
|
+
name: "Ault Devnet",
|
|
313
|
+
type: "devnet",
|
|
314
|
+
chainId: "ault_20904-1",
|
|
315
|
+
evmChainId: 20904,
|
|
316
|
+
rpcUrl: "https://devnet-rpc.aultblockchain.xyz",
|
|
317
|
+
restUrl: "https://devnet-api.aultblockchain.xyz",
|
|
318
|
+
evmRpcUrl: "https://devnet-json-rpc.aultblockchain.xyz",
|
|
319
|
+
explorerUrl: "https://devnet-cosmos-explorer.aultblockchain.xyz",
|
|
320
|
+
isProduction: false
|
|
321
|
+
},
|
|
311
322
|
"ault_30904-1": {
|
|
312
323
|
name: "Ault Localnet",
|
|
313
324
|
type: "localnet",
|
|
@@ -4998,16 +5009,13 @@ var DexWsClient = class {
|
|
|
4998
5009
|
this.pendingCommands = /* @__PURE__ */ new Map();
|
|
4999
5010
|
this.reconnectAttempt = 0;
|
|
5000
5011
|
this.reconnectTimer = null;
|
|
5001
|
-
this.authenticated = false;
|
|
5002
5012
|
this.connectResolvers = [];
|
|
5003
5013
|
this.url = url;
|
|
5004
5014
|
this.options = {
|
|
5005
5015
|
reconnect: opts?.reconnect ?? true,
|
|
5006
5016
|
maxReconnectAttempts: opts?.maxReconnectAttempts ?? Infinity,
|
|
5007
5017
|
reconnectDelay: opts?.reconnectDelay ?? 1e3,
|
|
5008
|
-
maxReconnectDelay: opts?.maxReconnectDelay ?? 3e4
|
|
5009
|
-
signMessage: opts?.signMessage,
|
|
5010
|
-
address: opts?.address
|
|
5018
|
+
maxReconnectDelay: opts?.maxReconnectDelay ?? 3e4
|
|
5011
5019
|
};
|
|
5012
5020
|
}
|
|
5013
5021
|
// -----------------------------------------------------------------------
|
|
@@ -5016,9 +5024,6 @@ var DexWsClient = class {
|
|
|
5016
5024
|
get state() {
|
|
5017
5025
|
return this.connectionState;
|
|
5018
5026
|
}
|
|
5019
|
-
get isAuthenticated() {
|
|
5020
|
-
return this.authenticated;
|
|
5021
|
-
}
|
|
5022
5027
|
connect() {
|
|
5023
5028
|
if (this.connectionState === "connected") return Promise.resolve();
|
|
5024
5029
|
if (this.connectionState === "connecting") {
|
|
@@ -5035,7 +5040,6 @@ var DexWsClient = class {
|
|
|
5035
5040
|
disconnect() {
|
|
5036
5041
|
this.clearReconnectTimer();
|
|
5037
5042
|
this.connectionState = "disconnected";
|
|
5038
|
-
this.authenticated = false;
|
|
5039
5043
|
if (this.ws) {
|
|
5040
5044
|
this.ws.close(NORMAL_CLOSURE);
|
|
5041
5045
|
this.ws = null;
|
|
@@ -5070,26 +5074,6 @@ var DexWsClient = class {
|
|
|
5070
5074
|
this.send({ action: "unsubscribe", topic });
|
|
5071
5075
|
}
|
|
5072
5076
|
}
|
|
5073
|
-
async authenticate(address, signMessage) {
|
|
5074
|
-
const addr = address ?? this.options.address;
|
|
5075
|
-
const signer = signMessage ?? this.options.signMessage;
|
|
5076
|
-
if (!addr || !signer) {
|
|
5077
|
-
throw new WebSocketError("address and signMessage are required for authentication");
|
|
5078
|
-
}
|
|
5079
|
-
const timestamp = Math.floor(Date.now() / 1e3);
|
|
5080
|
-
const message = `ault-dex-auth:${timestamp}`;
|
|
5081
|
-
const signature = await signer(message);
|
|
5082
|
-
const resp = await this.sendCommand({
|
|
5083
|
-
action: "authenticate",
|
|
5084
|
-
address: addr,
|
|
5085
|
-
signature,
|
|
5086
|
-
message
|
|
5087
|
-
});
|
|
5088
|
-
if (!resp.success) {
|
|
5089
|
-
throw new WebSocketError(resp.error ?? "Authentication failed");
|
|
5090
|
-
}
|
|
5091
|
-
this.authenticated = true;
|
|
5092
|
-
}
|
|
5093
5077
|
on(event, handler) {
|
|
5094
5078
|
let set = this.listeners.get(event);
|
|
5095
5079
|
if (!set) {
|
|
@@ -5222,15 +5206,8 @@ var DexWsClient = class {
|
|
|
5222
5206
|
this.createSocket();
|
|
5223
5207
|
}, jitteredDelay);
|
|
5224
5208
|
}
|
|
5225
|
-
|
|
5209
|
+
resubscribeAll() {
|
|
5226
5210
|
this.emit("reconnected");
|
|
5227
|
-
if (this.authenticated) {
|
|
5228
|
-
this.authenticated = false;
|
|
5229
|
-
try {
|
|
5230
|
-
await this.authenticate();
|
|
5231
|
-
} catch {
|
|
5232
|
-
}
|
|
5233
|
-
}
|
|
5234
5211
|
for (const [topic, sub] of this.subscriptions) {
|
|
5235
5212
|
this.send({ action: "subscribe", topic, ttl: sub.ttl });
|
|
5236
5213
|
}
|
|
@@ -15843,10 +15820,7 @@ function createAultClient(options) {
|
|
|
15843
15820
|
"WebSocket URL not configured. Set dexWsUrl or dexApiUrl in your network config."
|
|
15844
15821
|
);
|
|
15845
15822
|
}
|
|
15846
|
-
wsClient = new DexWsClient(wsUrl,
|
|
15847
|
-
address: options.signerAddress,
|
|
15848
|
-
...options.wsOptions
|
|
15849
|
-
});
|
|
15823
|
+
wsClient = new DexWsClient(wsUrl, options.wsOptions);
|
|
15850
15824
|
}
|
|
15851
15825
|
return wsClient;
|
|
15852
15826
|
},
|
|
@@ -17914,7 +17888,7 @@ function createDexWs(url, options) {
|
|
|
17914
17888
|
}
|
|
17915
17889
|
|
|
17916
17890
|
// src/index.ts
|
|
17917
|
-
var SDK_VERSION = "0.0.2-alpha.
|
|
17891
|
+
var SDK_VERSION = "0.0.2-alpha.7";
|
|
17918
17892
|
export {
|
|
17919
17893
|
AGENT_DEFAULTS,
|
|
17920
17894
|
AULT_SIGNER_MARKER,
|