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.
Files changed (138) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +923 -0
  3. package/dist/agent/create-agent-client.d.ts +3 -0
  4. package/dist/agent/sign-and-broadcast.d.ts +38 -0
  5. package/dist/agent/tx/clob.d.ts +7 -0
  6. package/dist/agent/tx-executor.d.ts +17 -0
  7. package/dist/client.d.ts +61 -0
  8. package/dist/core/address.d.ts +14 -0
  9. package/dist/core/base64.d.ts +2 -0
  10. package/dist/core/clob-msgs.d.ts +33 -0
  11. package/dist/core/errors.d.ts +17 -0
  12. package/dist/core/http.d.ts +14 -0
  13. package/dist/core/network.d.ts +59 -0
  14. package/dist/core/pagination.d.ts +14 -0
  15. package/dist/core/query.d.ts +5 -0
  16. package/dist/core/with-status-fallback.d.ts +5 -0
  17. package/dist/eip712/builder.d.ts +45 -0
  18. package/dist/eip712/field-order.d.ts +2 -0
  19. package/dist/eip712/msg-encoders.generated.d.ts +1 -0
  20. package/dist/eip712/msg.generated.d.ts +109 -0
  21. package/dist/eip712/registry.d.ts +36 -0
  22. package/dist/eip712/registry.generated.d.ts +2 -0
  23. package/dist/eip712/sign-and-broadcast.d.ts +55 -0
  24. package/dist/eip712/signers.d.ts +83 -0
  25. package/dist/eip712/types.d.ts +58 -0
  26. package/dist/high-level/address-utils.d.ts +2 -0
  27. package/dist/high-level/create-client.d.ts +26 -0
  28. package/dist/high-level/query-helpers.d.ts +3 -0
  29. package/dist/high-level/signer.d.ts +6 -0
  30. package/dist/high-level/tx/agent.d.ts +3 -0
  31. package/dist/high-level/tx/authority.d.ts +3 -0
  32. package/dist/high-level/tx/clob.d.ts +3 -0
  33. package/dist/high-level/tx/context.d.ts +5 -0
  34. package/dist/high-level/tx/license.d.ts +3 -0
  35. package/dist/high-level/tx/market.d.ts +3 -0
  36. package/dist/high-level/tx/miner.d.ts +3 -0
  37. package/dist/high-level/tx/ratelimit.d.ts +3 -0
  38. package/dist/high-level/tx/reward.d.ts +3 -0
  39. package/dist/high-level/tx/staking.d.ts +3 -0
  40. package/dist/high-level/tx/tokenregistry.d.ts +3 -0
  41. package/dist/high-level/tx-executor.d.ts +18 -0
  42. package/dist/high-level/types.d.ts +477 -0
  43. package/dist/high-level-client.d.ts +2 -0
  44. package/dist/index.cjs +18409 -0
  45. package/dist/index.cjs.map +1 -0
  46. package/dist/index.d.ts +38 -0
  47. package/dist/index.js +18137 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/proto/duration-json.d.ts +6 -0
  50. package/dist/proto/gen/amino/amino.d.ts +1 -0
  51. package/dist/proto/gen/ault/agent/v1/agent.d.ts +63 -0
  52. package/dist/proto/gen/ault/agent/v1/genesis.d.ts +44 -0
  53. package/dist/proto/gen/ault/agent/v1/params.d.ts +42 -0
  54. package/dist/proto/gen/ault/agent/v1/query.d.ts +73 -0
  55. package/dist/proto/gen/ault/agent/v1/tx.d.ts +91 -0
  56. package/dist/proto/gen/ault/authority/v1/authority.d.ts +15 -0
  57. package/dist/proto/gen/ault/authority/v1/genesis.d.ts +36 -0
  58. package/dist/proto/gen/ault/authority/v1/query.d.ts +53 -0
  59. package/dist/proto/gen/ault/authority/v1/tx.d.ts +50 -0
  60. package/dist/proto/gen/ault/clob/v1/fee.d.ts +37 -0
  61. package/dist/proto/gen/ault/clob/v1/genesis.d.ts +56 -0
  62. package/dist/proto/gen/ault/clob/v1/order_book.d.ts +32 -0
  63. package/dist/proto/gen/ault/clob/v1/params.d.ts +29 -0
  64. package/dist/proto/gen/ault/clob/v1/query.d.ts +56 -0
  65. package/dist/proto/gen/ault/clob/v1/tx.d.ts +116 -0
  66. package/dist/proto/gen/ault/license/v1/genesis.d.ts +140 -0
  67. package/dist/proto/gen/ault/license/v1/license.d.ts +151 -0
  68. package/dist/proto/gen/ault/license/v1/query.d.ts +273 -0
  69. package/dist/proto/gen/ault/license/v1/tx.d.ts +227 -0
  70. package/dist/proto/gen/ault/market/v1/genesis.d.ts +28 -0
  71. package/dist/proto/gen/ault/market/v1/market.d.ts +66 -0
  72. package/dist/proto/gen/ault/market/v1/params.d.ts +34 -0
  73. package/dist/proto/gen/ault/market/v1/query.d.ts +48 -0
  74. package/dist/proto/gen/ault/market/v1/tx.d.ts +87 -0
  75. package/dist/proto/gen/ault/miner/v1/genesis.d.ts +166 -0
  76. package/dist/proto/gen/ault/miner/v1/miner.d.ts +232 -0
  77. package/dist/proto/gen/ault/miner/v1/query.d.ts +254 -0
  78. package/dist/proto/gen/ault/miner/v1/tx.d.ts +207 -0
  79. package/dist/proto/gen/ault/ratelimit/v1/genesis.d.ts +27 -0
  80. package/dist/proto/gen/ault/ratelimit/v1/params.d.ts +35 -0
  81. package/dist/proto/gen/ault/ratelimit/v1/query.d.ts +42 -0
  82. package/dist/proto/gen/ault/ratelimit/v1/tx.d.ts +32 -0
  83. package/dist/proto/gen/ault/reward/v1/genesis.d.ts +67 -0
  84. package/dist/proto/gen/ault/reward/v1/query.d.ts +93 -0
  85. package/dist/proto/gen/ault/reward/v1/reward.d.ts +53 -0
  86. package/dist/proto/gen/ault/reward/v1/tx.d.ts +120 -0
  87. package/dist/proto/gen/ault/spot/v1/genesis.d.ts +26 -0
  88. package/dist/proto/gen/ault/spot/v1/order.d.ts +66 -0
  89. package/dist/proto/gen/ault/tokenregistry/v1/genesis.d.ts +34 -0
  90. package/dist/proto/gen/ault/tokenregistry/v1/query.d.ts +77 -0
  91. package/dist/proto/gen/ault/tokenregistry/v1/tokenregistry.d.ts +118 -0
  92. package/dist/proto/gen/ault/tokenregistry/v1/tx.d.ts +132 -0
  93. package/dist/proto/gen/cosmos/base/query/v1beta1/pagination.d.ts +82 -0
  94. package/dist/proto/gen/cosmos/base/v1beta1/coin.d.ts +59 -0
  95. package/dist/proto/gen/cosmos/distribution/v1beta1/distribution.d.ts +162 -0
  96. package/dist/proto/gen/cosmos/distribution/v1beta1/tx.d.ts +140 -0
  97. package/dist/proto/gen/cosmos/msg/v1/msg.d.ts +1 -0
  98. package/dist/proto/gen/cosmos/staking/v1beta1/staking.d.ts +310 -0
  99. package/dist/proto/gen/cosmos/staking/v1beta1/tx.d.ts +144 -0
  100. package/dist/proto/gen/cosmos_proto/cosmos.d.ts +80 -0
  101. package/dist/proto/gen/gogoproto/gogo.d.ts +1 -0
  102. package/dist/proto/gen/google/api/annotations.d.ts +1 -0
  103. package/dist/proto/gen/google/api/http.d.ts +379 -0
  104. package/dist/proto/gen/google/protobuf/any.d.ts +144 -0
  105. package/dist/proto/gen/google/protobuf/descriptor.d.ts +1285 -0
  106. package/dist/proto/gen/google/protobuf/duration.d.ts +99 -0
  107. package/dist/proto/gen/google/protobuf/timestamp.d.ts +128 -0
  108. package/dist/proto/gen/tendermint/abci/types.d.ts +507 -0
  109. package/dist/proto/gen/tendermint/crypto/keys.d.ts +27 -0
  110. package/dist/proto/gen/tendermint/crypto/proof.d.ts +57 -0
  111. package/dist/proto/gen/tendermint/types/params.d.ts +112 -0
  112. package/dist/proto/gen/tendermint/types/types.d.ts +197 -0
  113. package/dist/proto/gen/tendermint/types/validator.d.ts +54 -0
  114. package/dist/proto/gen/tendermint/version/types.d.ts +41 -0
  115. package/dist/proto/tx-encode.d.ts +78 -0
  116. package/dist/rest/agent.d.ts +12 -0
  117. package/dist/rest/authority.d.ts +12 -0
  118. package/dist/rest/clob.d.ts +11 -0
  119. package/dist/rest/context.d.ts +22 -0
  120. package/dist/rest/dex-fetcher.d.ts +10 -0
  121. package/dist/rest/dex-types.generated.d.ts +780 -0
  122. package/dist/rest/dex.d.ts +34 -0
  123. package/dist/rest/dex.generated.d.ts +1381 -0
  124. package/dist/rest/license.d.ts +79 -0
  125. package/dist/rest/market.d.ts +11 -0
  126. package/dist/rest/miner.d.ts +59 -0
  127. package/dist/rest/ratelimit.d.ts +7 -0
  128. package/dist/rest/reward.d.ts +25 -0
  129. package/dist/rest/staking.d.ts +38 -0
  130. package/dist/rest/tokenregistry.d.ts +11 -0
  131. package/dist/rest/types.d.ts +871 -0
  132. package/dist/utils/address.d.ts +6 -0
  133. package/dist/utils/chain-id.d.ts +1 -0
  134. package/dist/utils/cosmos-dec.d.ts +2 -0
  135. package/dist/ws/client.d.ts +34 -0
  136. package/dist/ws/index.d.ts +5 -0
  137. package/dist/ws/types.d.ts +72 -0
  138. package/package.json +103 -0
@@ -0,0 +1,6 @@
1
+ export declare function evmToAult(evmAddress: string): string;
2
+ export declare function aultToEvm(aultAddress: string): string;
3
+ export declare function isValidAultAddress(address: string): boolean;
4
+ export declare function isValidEvmAddress(address: string): boolean;
5
+ export declare function isValidValidatorAddress(address: string): boolean;
6
+ export declare function assertValidatorAddress(address: string): string;
@@ -0,0 +1 @@
1
+ export declare function parseEvmChainIdFromCosmosChainId(cosmosChainId: string): number | null;
@@ -0,0 +1,2 @@
1
+ export declare function cosmosDecToDecimalString(value: string): string;
2
+ export declare function cosmosDecToProtoInt(value: string): string;
@@ -0,0 +1,34 @@
1
+ import type { DexWsEventMap, DexWsOptions, PayloadFor, Subscription, SubscriptionHandlers, WsConnectionState } from "./types";
2
+ export declare class DexWsClient {
3
+ private url;
4
+ private options;
5
+ private ws;
6
+ private connectionState;
7
+ private subscriptions;
8
+ private listeners;
9
+ private pendingCommands;
10
+ private reconnectAttempt;
11
+ private reconnectTimer;
12
+ private connectResolvers;
13
+ constructor(url: string, opts?: DexWsOptions);
14
+ get state(): WsConnectionState;
15
+ connect(): Promise<void>;
16
+ disconnect(): void;
17
+ subscribe<T extends string>(topic: T, handlers: SubscriptionHandlers<PayloadFor<T>>, options?: {
18
+ ttl?: number;
19
+ }): Subscription;
20
+ unsubscribe(topic: string): void;
21
+ on<E extends keyof DexWsEventMap>(event: E, handler: DexWsEventMap[E]): () => void;
22
+ private createSocket;
23
+ private handleMessage;
24
+ private send;
25
+ private sendCommand;
26
+ private commandKey;
27
+ private scheduleReconnect;
28
+ private resubscribeAll;
29
+ private resolveConnect;
30
+ private rejectConnect;
31
+ private clearReconnectTimer;
32
+ private rejectPendingCommands;
33
+ private emit;
34
+ }
@@ -0,0 +1,5 @@
1
+ export { DexWsClient } from "./client";
2
+ export * from "./types";
3
+ import type { DexWsOptions } from "./types";
4
+ import { DexWsClient } from "./client";
5
+ export declare function createDexWs(url: string, options?: DexWsOptions): DexWsClient;
@@ -0,0 +1,72 @@
1
+ import type { OrderbookResponse, TradeResponse, TickerResponse, OrderResponse, BalancesResponse, OHLCVEntry } from "../rest/dex.generated";
2
+ export type WsEvent = "snapshot" | "new_trades" | "update" | "bar_update" | "response" | "subscription_expired";
3
+ export interface WsServerMessage<T = unknown> {
4
+ topic: string;
5
+ event: WsEvent;
6
+ data: T;
7
+ ts: number;
8
+ height: number;
9
+ }
10
+ export interface WsSubscribeCommand {
11
+ action: "subscribe";
12
+ topic: string;
13
+ ttl?: number;
14
+ }
15
+ export interface WsUnsubscribeCommand {
16
+ action: "unsubscribe";
17
+ topic: string;
18
+ }
19
+ export type WsClientCommand = WsSubscribeCommand | WsUnsubscribeCommand;
20
+ export interface WsCommandResponse {
21
+ action: string;
22
+ topic?: string;
23
+ success: boolean;
24
+ error?: string;
25
+ ttl?: number;
26
+ }
27
+ /**
28
+ * Payload for the `chain:block` topic. Emitted once per new block regardless
29
+ * of market activity so subscribers can drive liveness indicators.
30
+ *
31
+ * The block header fields (hash, proposer, tx_count, gas_used, gas_wanted)
32
+ * are optional because older chain versions may not supply them.
33
+ */
34
+ export interface BlockUpdate {
35
+ height: number;
36
+ timestamp: number;
37
+ hash?: string;
38
+ proposer?: string;
39
+ tx_count?: number;
40
+ gas_used?: number;
41
+ gas_wanted?: number;
42
+ }
43
+ export type PayloadFor<T extends string> = T extends `orderbook:${string}` ? OrderbookResponse : T extends `trades:${string}` ? TradeResponse[] : T extends `ticker:${string}` ? TickerResponse : T extends `chart:${string}` ? OHLCVEntry : T extends `orders:${string}` ? OrderResponse[] : T extends `balances:${string}` ? BalancesResponse : T extends `mytrades:${string}` ? TradeResponse[] : T extends "chain:block" ? BlockUpdate : unknown;
44
+ export interface SubscriptionHandlers<T> {
45
+ onData: (data: T, message: WsServerMessage<T>) => void;
46
+ onError?: (error: Error) => void;
47
+ onSubscribed?: () => void;
48
+ onExpired?: () => void;
49
+ }
50
+ export interface Subscription {
51
+ topic: string;
52
+ unsubscribe: () => void;
53
+ }
54
+ export type WsConnectionState = "disconnected" | "connecting" | "connected" | "reconnecting";
55
+ export interface DexWsOptions {
56
+ /** Auto-reconnect on unexpected disconnect (default: true). */
57
+ reconnect?: boolean;
58
+ /** Max reconnection attempts (default: Infinity). */
59
+ maxReconnectAttempts?: number;
60
+ /** Initial reconnect delay in ms (default: 1000). */
61
+ reconnectDelay?: number;
62
+ /** Max reconnect delay in ms (default: 30000). */
63
+ maxReconnectDelay?: number;
64
+ }
65
+ export interface DexWsEventMap {
66
+ open: () => void;
67
+ close: (code: number, reason: string) => void;
68
+ error: (error: Error) => void;
69
+ message: (message: WsServerMessage) => void;
70
+ reconnecting: (attempt: number) => void;
71
+ reconnected: () => void;
72
+ }
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "ault-sdk-ts",
3
+ "version": "0.0.2-alpha.10",
4
+ "description": "TypeScript SDK for the Ault blockchain with high-level transaction methods and REST query clients",
5
+ "keywords": [
6
+ "ault",
7
+ "blockchain",
8
+ "cosmos",
9
+ "crypto",
10
+ "eip712",
11
+ "sdk",
12
+ "typescript",
13
+ "web3"
14
+ ],
15
+ "homepage": "https://github.com/Ault-Blockchain/ault-sdk-ts#readme",
16
+ "bugs": {
17
+ "url": "https://github.com/Ault-Blockchain/ault-sdk-ts/issues"
18
+ },
19
+ "license": "MIT",
20
+ "author": "AULT core contributors",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/Ault-Blockchain/ault-sdk-ts.git"
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "type": "module",
29
+ "sideEffects": [
30
+ "./src/proto/duration-json.ts",
31
+ "./dist/proto/duration-json.js",
32
+ "./dist/proto/duration-json.cjs"
33
+ ],
34
+ "main": "./dist/index.cjs",
35
+ "module": "./dist/index.js",
36
+ "types": "./dist/index.d.ts",
37
+ "exports": {
38
+ ".": {
39
+ "types": "./dist/index.d.ts",
40
+ "import": "./dist/index.js",
41
+ "require": "./dist/index.cjs"
42
+ }
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "scripts": {
48
+ "gen:openapi": "orval",
49
+ "gen:proto": "node scripts/generate-protos.mjs",
50
+ "gen:eip712": "node scripts/generate-eip712-registry.mjs",
51
+ "prepare": "node scripts/prepare.mjs",
52
+ "build": "tsup && tsc -p tsconfig.build.json && npx tsc-alias -p tsconfig.build.json",
53
+ "dev": "tsup --watch",
54
+ "test": "vitest run",
55
+ "test:e2e": "vitest run --config vitest.e2e.config.ts",
56
+ "test:coverage": "vitest run --coverage",
57
+ "typecheck": "npm run typecheck:src && npm run typecheck:test",
58
+ "typecheck:src": "tsc --noEmit -p tsconfig.build.json",
59
+ "typecheck:test": "tsc --noEmit -p tsconfig.tests.json",
60
+ "lint": "oxlint . --type-aware",
61
+ "lint:fix": "oxlint --fix .",
62
+ "format": "oxfmt .",
63
+ "format:check": "oxfmt --check .",
64
+ "prepack": "npm run build"
65
+ },
66
+ "dependencies": {
67
+ "@bufbuild/protobuf": "^2.10.2",
68
+ "@cosmjs/encoding": "^0.33.0",
69
+ "@noble/curves": "^1.9.1",
70
+ "isows": "^1.0.7",
71
+ "viem": "^2.27.0",
72
+ "zod": "^4.3.5"
73
+ },
74
+ "devDependencies": {
75
+ "@testcontainers/mysql": "^11.13.0",
76
+ "@types/dockerode": "^4.0.1",
77
+ "@types/node": "^22.13.10",
78
+ "@vitest/coverage-v8": "4.1.1",
79
+ "dockerode": "^4.0.10",
80
+ "husky": "^9.0.0",
81
+ "lint-staged": "^15.0.0",
82
+ "orval": "^8.6.2",
83
+ "oxfmt": "^0.24.0",
84
+ "oxlint": "^1.39.0",
85
+ "oxlint-tsgolint": "^0.15.0",
86
+ "testcontainers": "^11.13.0",
87
+ "ts-proto": "^2.11.0",
88
+ "tsc-alias": "^1.8.13",
89
+ "tsup": "^8.0.0",
90
+ "typescript": "^5.6.3",
91
+ "vite": "8.0.2",
92
+ "vitest": "4.1.1"
93
+ },
94
+ "lint-staged": {
95
+ "*.{ts,tsx,js,jsx}": [
96
+ "oxlint --fix"
97
+ ],
98
+ "*.{ts,tsx,js,jsx,json,md}": [
99
+ "oxfmt"
100
+ ]
101
+ },
102
+ "packageManager": "pnpm@10.28.0+sha512.05df71d1421f21399e053fde567cea34d446fa02c76571441bfc1c7956e98e363088982d940465fd34480d4d90a0668bc12362f8aa88000a64e83d0b0e47be48"
103
+ }