ault-sdk-ts 0.0.2-alpha.16 → 0.0.2-alpha.18
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 +139 -0
- package/dist/core/manifest-resolver.d.ts +51 -2
- package/dist/high-level/types.d.ts +10 -0
- package/dist/index.cjs +92 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +89 -12
- package/dist/index.js.map +1 -1
- package/dist/rest/feemarket.d.ts +56 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -164,9 +164,148 @@ interface ClientOptions {
|
|
|
164
164
|
fetchOptions?: FetchWithRetryOptions;
|
|
165
165
|
defaultGasLimit?: string; // Optional: default gas limit
|
|
166
166
|
defaultMemo?: string; // Optional: default memo
|
|
167
|
+
defaultConfirmationTimeoutMs?: number;
|
|
168
|
+
manifestOverride?: Manifest; // Optional: caller-supplied manifest layer (see "SDK Manifest")
|
|
167
169
|
}
|
|
168
170
|
```
|
|
169
171
|
|
|
172
|
+
## SDK Manifest
|
|
173
|
+
|
|
174
|
+
`createClient` resolves network endpoints and gas/EIP-712 defaults from three
|
|
175
|
+
layers, in increasing precedence:
|
|
176
|
+
|
|
177
|
+
1. The embedded baseline shipped with the SDK (`NetworkConfig` plus
|
|
178
|
+
`GAS_CONSTANTS`).
|
|
179
|
+
2. The manifest fetched from `<dexApiUrl>/api/v1/sdk-manifest` at bootstrap
|
|
180
|
+
and refreshed every five minutes in the background. The operator
|
|
181
|
+
rotates URLs, EIP-712 fee defaults, and per-module gas constants by
|
|
182
|
+
editing the dex-api `SDK_MANIFEST_JSON` env var; older SDK versions
|
|
183
|
+
pick up the new values within one refresh window without a package
|
|
184
|
+
bump.
|
|
185
|
+
3. An optional `manifestOverride` you pass to `createClient`. The
|
|
186
|
+
override sits on top of both other layers, is frozen for the
|
|
187
|
+
lifetime of the client, and is not touched by background refreshes.
|
|
188
|
+
|
|
189
|
+
The override layer covers cases the fetched manifest cannot: pointing the
|
|
190
|
+
client at a private RPC during local development, pinning a deterministic
|
|
191
|
+
manifest in tests, surviving a URL rotation cutover by keeping the old
|
|
192
|
+
endpoint until you redeploy, or tuning gas constants without waiting on a
|
|
193
|
+
manifest deploy.
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
import { createClient, getNetworkConfig, type Manifest } from "ault-sdk-ts";
|
|
197
|
+
|
|
198
|
+
const manifestOverride: Manifest = {
|
|
199
|
+
schemaVersion: 1,
|
|
200
|
+
urls: {
|
|
201
|
+
rpc: "https://rpc.internal.example.com",
|
|
202
|
+
},
|
|
203
|
+
gas: {
|
|
204
|
+
LIMIT_ORDER: 250000,
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const client = await createClient({
|
|
209
|
+
network: getNetworkConfig("ault_10904-1"),
|
|
210
|
+
signer: account,
|
|
211
|
+
manifestOverride,
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
The override is sparse — every field is optional and only the keys you set
|
|
216
|
+
take effect. Disjoint keys still flow through from the fetched manifest, so
|
|
217
|
+
`{gas: {LIMIT_ORDER: 250000}}` does not erase a `MARKET_ORDER` value the
|
|
218
|
+
dex-api emits. Unknown top-level keys pass through untouched for forward
|
|
219
|
+
compatibility with future manifest fields.
|
|
220
|
+
|
|
221
|
+
### Supported fields
|
|
222
|
+
|
|
223
|
+
The `Manifest` type has four top-level keys. `schemaVersion` is required; the
|
|
224
|
+
three sub-objects are optional and each one is itself sparse.
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
interface Manifest {
|
|
228
|
+
schemaVersion: number; // required, integer >= 1
|
|
229
|
+
urls?: Partial<ManifestUrls>;
|
|
230
|
+
eip712?: Partial<ManifestEip712>;
|
|
231
|
+
gas?: Partial<ManifestGas>;
|
|
232
|
+
// unknown top-level keys are preserved for forward compatibility
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**`urls`** — endpoint overrides. Each value is a string and applies only if
|
|
237
|
+
non-empty. The `dexApiUrl` itself is not overridable here (it is the trust
|
|
238
|
+
root for the fetched manifest).
|
|
239
|
+
|
|
240
|
+
| Key | Maps to `NetworkConfig` field |
|
|
241
|
+
| ---------- | ----------------------------- |
|
|
242
|
+
| `rpc` | `rpcUrl` |
|
|
243
|
+
| `rest` | `restUrl` |
|
|
244
|
+
| `evm` | `evmRpcUrl` |
|
|
245
|
+
| `explorer` | `explorerUrl` |
|
|
246
|
+
| `dexWs` | `dexWsUrl` |
|
|
247
|
+
|
|
248
|
+
URL rotations propagate to the tx executor on the next call but not to the
|
|
249
|
+
REST/WS contexts captured at `createClient` time. Re-create the client to
|
|
250
|
+
pick up new endpoints across the board.
|
|
251
|
+
|
|
252
|
+
**`eip712`** — fee defaults applied to every transaction unless per-call
|
|
253
|
+
options override them.
|
|
254
|
+
|
|
255
|
+
| Key | Type | Notes |
|
|
256
|
+
| ----------- | -------------------------------- | ------------------------------ |
|
|
257
|
+
| `feeDenom` | non-empty string | replaces `GAS_CONSTANTS.DENOM` |
|
|
258
|
+
| `feeAmount` | non-negative integer string | raw `aault`, `"0"` allowed |
|
|
259
|
+
| `gasLimit` | strictly positive integer string | gas units, `"0"` rejected |
|
|
260
|
+
|
|
261
|
+
**`gas`** — per-message-type gas constants and the fee-free multiplier.
|
|
262
|
+
Every value is a positive integer. Keys outside the supported list are
|
|
263
|
+
dropped silently and the embedded baseline keeps applying.
|
|
264
|
+
|
|
265
|
+
The keys most consumers will touch are the CLOB ones plus the fee-free
|
|
266
|
+
multiplier:
|
|
267
|
+
|
|
268
|
+
| Key | Used by |
|
|
269
|
+
| ------------------------- | ---------------------------------------- |
|
|
270
|
+
| `FEE_FREE_GAS_MULTIPLIER` | fee-free gas computation across all msgs |
|
|
271
|
+
| `LIMIT_ORDER` | `placeLimitOrder` |
|
|
272
|
+
| `MARKET_ORDER` | `placeMarketOrder` |
|
|
273
|
+
| `SCALE_ORDER_BASE` | `placeScaleOrder` (base cost) |
|
|
274
|
+
| `SCALE_ORDER_PER_SUB` | `placeScaleOrder` (per sub-order) |
|
|
275
|
+
| `CANCEL_ORDER_BASE` | `cancelOrders` (base cost) |
|
|
276
|
+
| `CANCEL_ORDER_PER_ID` | `cancelOrders` (per order id) |
|
|
277
|
+
|
|
278
|
+
The schema also accepts per-message gas constants for the license,
|
|
279
|
+
miner, agent, reward, and accountx modules (`PER_LICENSE`,
|
|
280
|
+
`PER_DELEGATE_MINING`, `APPROVE_AGENT`, `SET_REFERRAL_CODE`,
|
|
281
|
+
`OPEN_ACCOUNT`, and the rest). These exist for operator-side
|
|
282
|
+
deploy-cycle bypass and are rarely needed in consumer code. The full
|
|
283
|
+
list lives in `ManifestGasSchema` in `src/core/manifest-types.ts`.
|
|
284
|
+
|
|
285
|
+
The `gas` blob never accepts `EIP712_FEE_AMOUNT`, `EIP712_GAS_LIMIT`, or
|
|
286
|
+
`DENOM` — those live on `eip712` as `feeAmount`, `gasLimit`, and
|
|
287
|
+
`feeDenom`. Smuggling them through `gas` is dropped defensively because
|
|
288
|
+
the broadcast layer never reads them off the gas object.
|
|
289
|
+
|
|
290
|
+
The value validates against `ManifestSchema` synchronously at `createClient`
|
|
291
|
+
time. A malformed override throws straight away with the schema error
|
|
292
|
+
instead of falling back to the baseline the way a broken fetched manifest
|
|
293
|
+
does, since override data comes from your code and a typo is a bug worth
|
|
294
|
+
surfacing loudly. The caller's object is deep-cloned at construction, so
|
|
295
|
+
mutating it after `createClient` returns does not affect resolver state.
|
|
296
|
+
|
|
297
|
+
When a non-empty override is present, the resolver emits one
|
|
298
|
+
`console.info` line at boot listing the override key paths (never values,
|
|
299
|
+
since `urls` may carry private endpoints).
|
|
300
|
+
|
|
301
|
+
If you also use `client.attachAgent(...)`, the agent surface reuses the
|
|
302
|
+
same manifest resolver, so the override flows through to agent-signed
|
|
303
|
+
transactions without separate plumbing.
|
|
304
|
+
|
|
305
|
+
The package also re-exports the low-level helpers if you need them:
|
|
306
|
+
`mergeManifests`, `fetchManifest`, `applyNetworkOverrides`,
|
|
307
|
+
`applyGasOverrides`, `createManifestResolver`, `createStaticResolver`.
|
|
308
|
+
|
|
170
309
|
## Query Methods
|
|
171
310
|
|
|
172
311
|
The client provides pass-through access to all REST API methods:
|
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import { GAS_CONSTANTS, type NetworkConfig } from "./network";
|
|
2
2
|
import type { FetchFn, FetchWithRetryOptions } from "./http";
|
|
3
|
-
import type
|
|
3
|
+
import { type Manifest, type ManifestGas } from "./manifest-types";
|
|
4
|
+
/**
|
|
5
|
+
* Sparse field-level merge of two manifests. The right operand wins on every
|
|
6
|
+
* key it provides. Returns null only when both inputs are null.
|
|
7
|
+
*
|
|
8
|
+
* `schemaVersion` is taken from `top` when present so a caller override can
|
|
9
|
+
* declare a future schema version while the SDK keeps validating per the
|
|
10
|
+
* version it knows. Sub-objects (`gas`, `eip712`, `urls`) are merged at the
|
|
11
|
+
* leaf-key level, not replaced wholesale — passing `{gas: {LIMIT_ORDER: 1}}`
|
|
12
|
+
* does not erase a fetched `MARKET_ORDER`.
|
|
13
|
+
*
|
|
14
|
+
* Unknown top-level keys (anything outside `schemaVersion / gas / eip712 / urls`)
|
|
15
|
+
* pass through with `top` winning on overlap. The manifest schema is a zod
|
|
16
|
+
* looseObject so a future dex-api emitting additional fields keeps working
|
|
17
|
+
* with older SDKs; reconstructing only the four known fields here would have
|
|
18
|
+
* silently dropped those forward-compat keys whenever a caller-side override
|
|
19
|
+
* was present.
|
|
20
|
+
*/
|
|
21
|
+
export declare function mergeManifests(base: Manifest | null, top: Manifest | null): Manifest | null;
|
|
4
22
|
/**
|
|
5
23
|
* Returns a NetworkConfig with manifest URL and eip712 overrides applied.
|
|
6
24
|
* Fields the manifest does not specify pass through unchanged. URL values
|
|
@@ -36,6 +54,13 @@ export interface ManifestResolverOptions {
|
|
|
36
54
|
* 0 disables hot-swap (the initial fetch still runs).
|
|
37
55
|
*/
|
|
38
56
|
refreshIntervalMs?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Caller-supplied override applied on top of the fetched manifest. Frozen
|
|
59
|
+
* at construction time (deep-cloned) so post-`createClient` mutation by the
|
|
60
|
+
* caller cannot poison resolver state. Must validate against
|
|
61
|
+
* `ManifestSchema`; otherwise `createManifestResolver` throws.
|
|
62
|
+
*/
|
|
63
|
+
override?: Manifest;
|
|
39
64
|
}
|
|
40
65
|
export interface ManifestResolver {
|
|
41
66
|
/** The base network the resolver was created against. Stable. */
|
|
@@ -63,9 +88,33 @@ export interface ManifestResolver {
|
|
|
63
88
|
* a fleet of SDK consumers from hitting the dex-api in lockstep.
|
|
64
89
|
*/
|
|
65
90
|
export declare function createManifestResolver(opts: ManifestResolverOptions): Promise<ManifestResolver>;
|
|
91
|
+
/**
|
|
92
|
+
* Options for {@link createStaticResolver}. Mirrors the `network`/`override`
|
|
93
|
+
* shape of {@link ManifestResolverOptions} so callers can move between the
|
|
94
|
+
* two without re-ordering arguments. The `manifest` field is the static
|
|
95
|
+
* fetched-layer stand-in (typically `null` in tests that want the embedded
|
|
96
|
+
* baseline; non-null when injecting a fixed manifest).
|
|
97
|
+
*/
|
|
98
|
+
export interface StaticResolverOptions {
|
|
99
|
+
network: NetworkConfig;
|
|
100
|
+
/** Static stand-in for the fetched manifest. Defaults to `null`. */
|
|
101
|
+
manifest?: Manifest | null;
|
|
102
|
+
/** Caller-supplied override, validated and frozen at construction. */
|
|
103
|
+
override?: Manifest;
|
|
104
|
+
}
|
|
66
105
|
/**
|
|
67
106
|
* Static resolver — does not fetch, does not run a timer. Useful as the
|
|
68
107
|
* embedded-only path (no `dexApiUrl`) or in tests where you want to inject a
|
|
69
|
-
* fixed manifest.
|
|
108
|
+
* fixed manifest. The `override` is treated identically to the
|
|
109
|
+
* `createManifestResolver` override: validated, deep-cloned, merged on top.
|
|
110
|
+
*
|
|
111
|
+
* Two call shapes are supported:
|
|
112
|
+
*
|
|
113
|
+
* 1. Options bag (preferred): `createStaticResolver({ network, manifest, override })`.
|
|
114
|
+
* 2. Legacy positional `(network, manifest)`: kept for backward compatibility
|
|
115
|
+
* with the pre-override signature. Untyped JS callers using the old shape
|
|
116
|
+
* keep working; TypeScript callers see the typed overload and pick whichever
|
|
117
|
+
* matches their argument shape.
|
|
70
118
|
*/
|
|
119
|
+
export declare function createStaticResolver(opts: StaticResolverOptions): ManifestResolver;
|
|
71
120
|
export declare function createStaticResolver(network: NetworkConfig, manifest?: Manifest | null): ManifestResolver;
|
|
@@ -2,6 +2,7 @@ import type { NetworkConfig } from "../core/network";
|
|
|
2
2
|
import type { FetchWithRetryOptions, FetchFn } from "../core/http";
|
|
3
3
|
import type { AultClient } from "../client";
|
|
4
4
|
import type { ManifestResolver } from "../core/manifest-resolver";
|
|
5
|
+
import type { Manifest } from "../core/manifest-types";
|
|
5
6
|
import type { AccountxApi } from "../rest/accountx";
|
|
6
7
|
import type { AgentApi } from "../rest/agent";
|
|
7
8
|
import type { AuthorityApi, AuthorityRoleInput } from "../rest/authority";
|
|
@@ -86,6 +87,15 @@ export interface ClientOptions {
|
|
|
86
87
|
defaultMemo?: string;
|
|
87
88
|
/** Optional: default time to wait for DeliverTx confirmation before returning a provisional result */
|
|
88
89
|
defaultConfirmationTimeoutMs?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Optional sparse manifest applied on top of the fetched manifest and the
|
|
92
|
+
* embedded baseline. Frozen for the lifetime of the client; not affected
|
|
93
|
+
* by background refreshes. The caller's reference is deep-cloned at
|
|
94
|
+
* construction so post-`createClient` mutation does not poison resolver
|
|
95
|
+
* state. Throws synchronously at `createClient` time if the value does not
|
|
96
|
+
* validate against `ManifestSchema`.
|
|
97
|
+
*/
|
|
98
|
+
manifestOverride?: Manifest;
|
|
89
99
|
}
|
|
90
100
|
/**
|
|
91
101
|
* Result of a transaction.
|
package/dist/index.cjs
CHANGED
|
@@ -130,6 +130,7 @@ __export(index_exports, {
|
|
|
130
130
|
buildEip712TypedData: () => buildEip712TypedData,
|
|
131
131
|
buildFetchOptions: () => buildFetchOptions,
|
|
132
132
|
bytesToBase64: () => bytesToBase64,
|
|
133
|
+
computeEvmFeesPerGas: () => computeEvmFeesPerGas,
|
|
133
134
|
computeFeeFreeGas: () => computeFeeFreeGas,
|
|
134
135
|
computeFeeFreeGasCompound: () => computeFeeFreeGasCompound,
|
|
135
136
|
computeRequiredFee: () => computeRequiredFee,
|
|
@@ -245,6 +246,7 @@ __export(index_exports, {
|
|
|
245
246
|
listTradesResponseInfoAddressOneRegExp: () => listTradesResponseInfoAddressOneRegExp,
|
|
246
247
|
listTradesResponseInfoBlockHeightRegExp: () => listTradesResponseInfoBlockHeightRegExp,
|
|
247
248
|
listTradesResponsePriceRegExp: () => listTradesResponsePriceRegExp,
|
|
249
|
+
mergeManifests: () => mergeManifests,
|
|
248
250
|
msg: () => msg,
|
|
249
251
|
normalizeSignature: () => normalizeSignature,
|
|
250
252
|
normalizeSigner: () => normalizeSigner,
|
|
@@ -254,6 +256,7 @@ __export(index_exports, {
|
|
|
254
256
|
pollTxInclusion: () => pollTxInclusion,
|
|
255
257
|
postJson: () => postJson,
|
|
256
258
|
queryAccount: () => queryAccount,
|
|
259
|
+
resolveEvmFeesPerGas: () => resolveEvmFeesPerGas,
|
|
257
260
|
resolveSignerAddress: () => resolveSignerAddress,
|
|
258
261
|
signAndBroadcastAgentTx: () => signAndBroadcastAgentTx,
|
|
259
262
|
signAndBroadcastEip712: () => signAndBroadcastEip712,
|
|
@@ -14072,18 +14075,24 @@ async function fetchFeeMarketParams(network, fetchFn, fetchOptions) {
|
|
|
14072
14075
|
};
|
|
14073
14076
|
}
|
|
14074
14077
|
var ONE_E18 = 1000000000000000000n;
|
|
14075
|
-
|
|
14076
|
-
|
|
14078
|
+
var DEFAULT_FEE_MARGIN_PERCENT = 20;
|
|
14079
|
+
function marginFactorScaled(marginPercent) {
|
|
14080
|
+
if (!Number.isFinite(marginPercent) || !Number.isInteger(marginPercent)) {
|
|
14081
|
+
throw new Error(`marginPercent must be a non-negative integer, got ${marginPercent}`);
|
|
14082
|
+
}
|
|
14077
14083
|
if (marginPercent < 0) {
|
|
14078
14084
|
throw new Error(`marginPercent must be >= 0, got ${marginPercent}`);
|
|
14079
14085
|
}
|
|
14086
|
+
return BigInt(100 + marginPercent);
|
|
14087
|
+
}
|
|
14088
|
+
function computeRequiredFee(params, gas, options) {
|
|
14089
|
+
const margin = marginFactorScaled(options?.marginPercent ?? DEFAULT_FEE_MARGIN_PERCENT);
|
|
14080
14090
|
const minGasPriceI = BigInt(cosmosDecToProtoInt(params.minGasPrice || "0"));
|
|
14081
14091
|
const baseFeeI = params.noBaseFee ? 0n : BigInt(cosmosDecToProtoInt(params.baseFee || "0"));
|
|
14082
14092
|
const effectiveI = baseFeeI > minGasPriceI ? baseFeeI : minGasPriceI;
|
|
14083
14093
|
if (effectiveI <= 0n) return "0";
|
|
14084
14094
|
const gasI = BigInt(gas);
|
|
14085
14095
|
if (gasI <= 0n) return "0";
|
|
14086
|
-
const margin = BigInt(100 + marginPercent);
|
|
14087
14096
|
const numerator = effectiveI * gasI * margin;
|
|
14088
14097
|
const denominator = ONE_E18 * 100n;
|
|
14089
14098
|
return ((numerator + denominator - 1n) / denominator).toString();
|
|
@@ -14116,6 +14125,36 @@ async function getCachedFeeMarketParams(cache, network, fetchFn, fetchOptions) {
|
|
|
14116
14125
|
function isGatewayUnsupportedError(error) {
|
|
14117
14126
|
return error instanceof ApiError && (error.status === 404 || error.status === 501);
|
|
14118
14127
|
}
|
|
14128
|
+
function computeEvmFeesPerGas(params, options) {
|
|
14129
|
+
const margin = marginFactorScaled(options?.marginPercent ?? DEFAULT_FEE_MARGIN_PERCENT);
|
|
14130
|
+
const minGasPriceI = BigInt(cosmosDecToProtoInt(params.minGasPrice || "0"));
|
|
14131
|
+
const baseFeeI = params.noBaseFee ? 0n : BigInt(cosmosDecToProtoInt(params.baseFee || "0"));
|
|
14132
|
+
const effectiveI = baseFeeI > minGasPriceI ? baseFeeI : minGasPriceI;
|
|
14133
|
+
if (effectiveI <= 0n) {
|
|
14134
|
+
return { maxFeePerGas: 0n, maxPriorityFeePerGas: 0n };
|
|
14135
|
+
}
|
|
14136
|
+
const numerator = effectiveI * margin;
|
|
14137
|
+
const denominator = ONE_E18 * 100n;
|
|
14138
|
+
const gasPriceWei = (numerator + denominator - 1n) / denominator;
|
|
14139
|
+
return { maxFeePerGas: gasPriceWei, maxPriorityFeePerGas: gasPriceWei };
|
|
14140
|
+
}
|
|
14141
|
+
async function resolveEvmFeesPerGas(network, options) {
|
|
14142
|
+
const params = await getCachedFeeMarketParams(
|
|
14143
|
+
options?.cache,
|
|
14144
|
+
network,
|
|
14145
|
+
options?.fetchFn,
|
|
14146
|
+
options?.fetchOptions
|
|
14147
|
+
);
|
|
14148
|
+
if (!params) return null;
|
|
14149
|
+
let fees;
|
|
14150
|
+
try {
|
|
14151
|
+
fees = computeEvmFeesPerGas(params, { marginPercent: options?.marginPercent });
|
|
14152
|
+
} catch {
|
|
14153
|
+
return null;
|
|
14154
|
+
}
|
|
14155
|
+
if (fees.maxFeePerGas === 0n && fees.maxPriorityFeePerGas === 0n) return null;
|
|
14156
|
+
return fees;
|
|
14157
|
+
}
|
|
14119
14158
|
|
|
14120
14159
|
// src/eip712/signers.ts
|
|
14121
14160
|
var import_accounts = require("viem/accounts");
|
|
@@ -23047,6 +23086,17 @@ function stripTrailingSlash(s) {
|
|
|
23047
23086
|
}
|
|
23048
23087
|
|
|
23049
23088
|
// src/core/manifest-resolver.ts
|
|
23089
|
+
function mergeManifests(base, top) {
|
|
23090
|
+
if (!base && !top) return null;
|
|
23091
|
+
if (!base) return top;
|
|
23092
|
+
if (!top) return base;
|
|
23093
|
+
const merged = { ...base, ...top };
|
|
23094
|
+
merged.schemaVersion = top.schemaVersion ?? base.schemaVersion;
|
|
23095
|
+
if (base.gas || top.gas) merged.gas = { ...base.gas, ...top.gas };
|
|
23096
|
+
if (base.eip712 || top.eip712) merged.eip712 = { ...base.eip712, ...top.eip712 };
|
|
23097
|
+
if (base.urls || top.urls) merged.urls = { ...base.urls, ...top.urls };
|
|
23098
|
+
return merged;
|
|
23099
|
+
}
|
|
23050
23100
|
function applyNetworkOverrides(network, manifest) {
|
|
23051
23101
|
if (!manifest) return network;
|
|
23052
23102
|
const isUrl = (v) => typeof v === "string" && v.length > 0;
|
|
@@ -23078,6 +23128,25 @@ function applyGasOverrides(gas) {
|
|
|
23078
23128
|
}
|
|
23079
23129
|
return Object.assign({}, GAS_CONSTANTS, safeRest);
|
|
23080
23130
|
}
|
|
23131
|
+
function prepareOverride(override) {
|
|
23132
|
+
if (override === void 0) return null;
|
|
23133
|
+
const parsed = ManifestSchema.safeParse(override);
|
|
23134
|
+
if (!parsed.success) {
|
|
23135
|
+
throw new Error(
|
|
23136
|
+
`manifestOverride failed schema validation: ${JSON.stringify(parsed.error.issues)}`
|
|
23137
|
+
);
|
|
23138
|
+
}
|
|
23139
|
+
const frozen = structuredClone(parsed.data);
|
|
23140
|
+
const gasKeys = frozen.gas ? Object.keys(frozen.gas) : [];
|
|
23141
|
+
const eip712Keys = frozen.eip712 ? Object.keys(frozen.eip712) : [];
|
|
23142
|
+
const urlsKeys = frozen.urls ? Object.keys(frozen.urls) : [];
|
|
23143
|
+
if (gasKeys.length || eip712Keys.length || urlsKeys.length) {
|
|
23144
|
+
console.info(
|
|
23145
|
+
`[ault-sdk] manifest override active: gas keys=[${gasKeys.join(", ")}], eip712 keys=[${eip712Keys.join(", ")}], urls keys=[${urlsKeys.join(", ")}]`
|
|
23146
|
+
);
|
|
23147
|
+
}
|
|
23148
|
+
return frozen;
|
|
23149
|
+
}
|
|
23081
23150
|
var DEFAULT_REFRESH_INTERVAL_MS = 5 * 60 * 1e3;
|
|
23082
23151
|
var INITIAL_FETCH_TIMEOUT_MS = 2e3;
|
|
23083
23152
|
var MAX_REFRESH_INTERVAL_MS = 2147483647;
|
|
@@ -23091,8 +23160,10 @@ async function createManifestResolver(opts) {
|
|
|
23091
23160
|
const refreshIntervalMs = normalizeRefreshIntervalMs(
|
|
23092
23161
|
opts.refreshIntervalMs ?? DEFAULT_REFRESH_INTERVAL_MS
|
|
23093
23162
|
);
|
|
23163
|
+
const frozenOverride = prepareOverride(opts.override);
|
|
23094
23164
|
let manifest = null;
|
|
23095
23165
|
let disposed = false;
|
|
23166
|
+
const resolved = () => mergeManifests(manifest, frozenOverride);
|
|
23096
23167
|
let pullSeq = 0;
|
|
23097
23168
|
async function pull(isInitial) {
|
|
23098
23169
|
if (disposed || !network.dexApiUrl) return;
|
|
@@ -23121,9 +23192,9 @@ async function createManifestResolver(opts) {
|
|
|
23121
23192
|
scheduleNext();
|
|
23122
23193
|
return {
|
|
23123
23194
|
baseNetwork: network,
|
|
23124
|
-
currentManifest:
|
|
23125
|
-
currentNetwork: () => applyNetworkOverrides(network,
|
|
23126
|
-
currentGas: () => applyGasOverrides(
|
|
23195
|
+
currentManifest: resolved,
|
|
23196
|
+
currentNetwork: () => applyNetworkOverrides(network, resolved()),
|
|
23197
|
+
currentGas: () => applyGasOverrides(resolved()?.gas),
|
|
23127
23198
|
async refresh() {
|
|
23128
23199
|
await pull(false);
|
|
23129
23200
|
},
|
|
@@ -23136,12 +23207,17 @@ async function createManifestResolver(opts) {
|
|
|
23136
23207
|
}
|
|
23137
23208
|
};
|
|
23138
23209
|
}
|
|
23139
|
-
function createStaticResolver(
|
|
23210
|
+
function createStaticResolver(optsOrNetwork, legacyManifest) {
|
|
23211
|
+
const opts = "network" in optsOrNetwork && optsOrNetwork.network !== void 0 ? optsOrNetwork : { network: optsOrNetwork, manifest: legacyManifest ?? null };
|
|
23212
|
+
const { network } = opts;
|
|
23213
|
+
const manifest = opts.manifest ?? null;
|
|
23214
|
+
const frozenOverride = prepareOverride(opts.override);
|
|
23215
|
+
const resolved = () => mergeManifests(manifest, frozenOverride);
|
|
23140
23216
|
return {
|
|
23141
23217
|
baseNetwork: network,
|
|
23142
|
-
currentManifest:
|
|
23143
|
-
currentNetwork: () => applyNetworkOverrides(network,
|
|
23144
|
-
currentGas: () => applyGasOverrides(
|
|
23218
|
+
currentManifest: resolved,
|
|
23219
|
+
currentNetwork: () => applyNetworkOverrides(network, resolved()),
|
|
23220
|
+
currentGas: () => applyGasOverrides(resolved()?.gas),
|
|
23145
23221
|
refresh: async () => {
|
|
23146
23222
|
},
|
|
23147
23223
|
dispose: () => {
|
|
@@ -23438,7 +23514,8 @@ async function createClient(options) {
|
|
|
23438
23514
|
const resolver = await createManifestResolver({
|
|
23439
23515
|
network: options.network,
|
|
23440
23516
|
fetchFn: options.fetchFn,
|
|
23441
|
-
fetchOptions: options.fetchOptions
|
|
23517
|
+
fetchOptions: options.fetchOptions,
|
|
23518
|
+
override: options.manifestOverride
|
|
23442
23519
|
});
|
|
23443
23520
|
try {
|
|
23444
23521
|
return await buildClient(options, resolver);
|
|
@@ -24286,7 +24363,7 @@ function createDexWs(url, options) {
|
|
|
24286
24363
|
}
|
|
24287
24364
|
|
|
24288
24365
|
// src/index.ts
|
|
24289
|
-
var SDK_VERSION = "0.0.2-alpha.
|
|
24366
|
+
var SDK_VERSION = "0.0.2-alpha.18";
|
|
24290
24367
|
// Annotate the CommonJS export names for ESM import in node:
|
|
24291
24368
|
0 && (module.exports = {
|
|
24292
24369
|
AGENT_DEFAULTS,
|
|
@@ -24389,6 +24466,7 @@ var SDK_VERSION = "0.0.2-alpha.16";
|
|
|
24389
24466
|
buildEip712TypedData,
|
|
24390
24467
|
buildFetchOptions,
|
|
24391
24468
|
bytesToBase64,
|
|
24469
|
+
computeEvmFeesPerGas,
|
|
24392
24470
|
computeFeeFreeGas,
|
|
24393
24471
|
computeFeeFreeGasCompound,
|
|
24394
24472
|
computeRequiredFee,
|
|
@@ -24504,6 +24582,7 @@ var SDK_VERSION = "0.0.2-alpha.16";
|
|
|
24504
24582
|
listTradesResponseInfoAddressOneRegExp,
|
|
24505
24583
|
listTradesResponseInfoBlockHeightRegExp,
|
|
24506
24584
|
listTradesResponsePriceRegExp,
|
|
24585
|
+
mergeManifests,
|
|
24507
24586
|
msg,
|
|
24508
24587
|
normalizeSignature,
|
|
24509
24588
|
normalizeSigner,
|
|
@@ -24513,6 +24592,7 @@ var SDK_VERSION = "0.0.2-alpha.16";
|
|
|
24513
24592
|
pollTxInclusion,
|
|
24514
24593
|
postJson,
|
|
24515
24594
|
queryAccount,
|
|
24595
|
+
resolveEvmFeesPerGas,
|
|
24516
24596
|
resolveSignerAddress,
|
|
24517
24597
|
signAndBroadcastAgentTx,
|
|
24518
24598
|
signAndBroadcastEip712,
|