ault-sdk-ts 0.7.0 → 0.7.2
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 +36 -9
- package/dist/core/errors.d.ts +13 -0
- package/dist/core/http.d.ts +10 -0
- package/dist/core/manifest-types.d.ts +2 -0
- package/dist/core/network.d.ts +6 -2
- package/dist/core/user-agent.d.ts +15 -0
- package/dist/eip712/sign-and-broadcast.d.ts +10 -1
- package/dist/eip712/simulate.d.ts +41 -0
- package/dist/high-level/tx-executor.d.ts +3 -2
- package/dist/index.cjs +859 -623
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +853 -623
- package/dist/index.js.map +1 -1
- package/dist/ws/types.d.ts +7 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ __export(index_exports, {
|
|
|
38
38
|
BondStatus: () => BondStatus,
|
|
39
39
|
COIN_TYPE: () => COIN_TYPE,
|
|
40
40
|
DEFAULT_CHAIN_ID: () => DEFAULT_CHAIN_ID,
|
|
41
|
+
DEFAULT_RETRYABLE_STATUSES: () => DEFAULT_RETRYABLE_STATUSES,
|
|
41
42
|
DexWsClient: () => DexWsClient,
|
|
42
43
|
EIP712_DOMAIN_TYPE: () => EIP712_DOMAIN_TYPE,
|
|
43
44
|
EIP712_MSG_TYPES: () => EIP712_MSG_TYPES,
|
|
@@ -113,6 +114,7 @@ __export(index_exports, {
|
|
|
113
114
|
SDK_VERSION: () => SDK_VERSION,
|
|
114
115
|
SIGN_MODE_DIRECT: () => SIGN_MODE_DIRECT,
|
|
115
116
|
SIGN_MODE_LEGACY_AMINO_JSON: () => SIGN_MODE_LEGACY_AMINO_JSON,
|
|
117
|
+
SIMULATION_PLACEHOLDER_PUBKEY: () => SIMULATION_PLACEHOLDER_PUBKEY,
|
|
116
118
|
SearchUDFSymbolsQueryParams: () => SearchUDFSymbolsQueryParams,
|
|
117
119
|
SearchUDFSymbolsResponse: () => SearchUDFSymbolsResponse,
|
|
118
120
|
SearchUDFSymbolsResponseItem: () => SearchUDFSymbolsResponseItem,
|
|
@@ -122,6 +124,8 @@ __export(index_exports, {
|
|
|
122
124
|
TxConfirmationUnavailableError: () => TxConfirmationUnavailableError,
|
|
123
125
|
TxError: () => TxError,
|
|
124
126
|
TxNotConfirmedError: () => TxNotConfirmedError,
|
|
127
|
+
TxSimulationError: () => TxSimulationError,
|
|
128
|
+
USER_AGENT: () => USER_AGENT,
|
|
125
129
|
ValidatorStatus: () => BondStatus,
|
|
126
130
|
WebSocketError: () => WebSocketError,
|
|
127
131
|
WithdrawRewardsPartialError: () => WithdrawRewardsPartialError,
|
|
@@ -144,6 +148,7 @@ __export(index_exports, {
|
|
|
144
148
|
computeFeeFreeGas: () => computeFeeFreeGas,
|
|
145
149
|
computeFeeFreeGasCompound: () => computeFeeFreeGasCompound,
|
|
146
150
|
computeRequiredFee: () => computeRequiredFee,
|
|
151
|
+
computeSimulatedGas: () => computeSimulatedGas,
|
|
147
152
|
cosmosDecToDecimalString: () => cosmosDecToDecimalString,
|
|
148
153
|
cosmosDecToProtoInt: () => cosmosDecToProtoInt,
|
|
149
154
|
createAccountCache: () => createAccountCache,
|
|
@@ -307,6 +312,7 @@ __export(index_exports, {
|
|
|
307
312
|
resolveSignerAddress: () => resolveSignerAddress,
|
|
308
313
|
signAndBroadcastAgentTx: () => signAndBroadcastAgentTx,
|
|
309
314
|
signAndBroadcastEip712: () => signAndBroadcastEip712,
|
|
315
|
+
simulateTx: () => simulateTx,
|
|
310
316
|
stripEip712Domain: () => stripEip712Domain,
|
|
311
317
|
toViemChain: () => toViemChain,
|
|
312
318
|
validateEip712FieldOrder: () => validateEip712FieldOrder,
|
|
@@ -314,6 +320,16 @@ __export(index_exports, {
|
|
|
314
320
|
});
|
|
315
321
|
module.exports = __toCommonJS(index_exports);
|
|
316
322
|
|
|
323
|
+
// src/core/user-agent.ts
|
|
324
|
+
var SDK_VERSION = "0.7.2";
|
|
325
|
+
var USER_AGENT = `ault-sdk-ts/${SDK_VERSION}`;
|
|
326
|
+
function isServerRuntime() {
|
|
327
|
+
if (typeof document !== "undefined") return false;
|
|
328
|
+
if (typeof globalThis.Deno !== "undefined") return false;
|
|
329
|
+
const versions = globalThis.process?.versions;
|
|
330
|
+
return Boolean(versions?.node || versions?.bun);
|
|
331
|
+
}
|
|
332
|
+
|
|
317
333
|
// src/proto/gen/google/protobuf/duration.ts
|
|
318
334
|
var import_wire = require("@bufbuild/protobuf/wire");
|
|
319
335
|
function createBaseDuration() {
|
|
@@ -455,6 +471,14 @@ var TxError = class extends Error {
|
|
|
455
471
|
this.confirmed = params.confirmed;
|
|
456
472
|
}
|
|
457
473
|
};
|
|
474
|
+
var TxSimulationError = class extends Error {
|
|
475
|
+
constructor(params) {
|
|
476
|
+
super(`Transaction simulation failed: ${params.rawLog}`);
|
|
477
|
+
this.name = "TxSimulationError";
|
|
478
|
+
this.chainCode = params.chainCode;
|
|
479
|
+
this.rawLog = params.rawLog;
|
|
480
|
+
}
|
|
481
|
+
};
|
|
458
482
|
var TxNotConfirmedError = class extends TxError {
|
|
459
483
|
constructor(params) {
|
|
460
484
|
super(
|
|
@@ -501,14 +525,16 @@ var WithdrawRewardsPartialError = class extends Error {
|
|
|
501
525
|
};
|
|
502
526
|
|
|
503
527
|
// src/core/http.ts
|
|
528
|
+
var DEFAULT_RETRYABLE_STATUSES = [408, 429, 500, 502, 503, 504];
|
|
504
529
|
var DEFAULT_OPTIONS = {
|
|
505
530
|
timeout: 3e4,
|
|
506
531
|
retries: 3,
|
|
507
532
|
retryDelay: 1e3,
|
|
508
533
|
exponentialBackoff: true,
|
|
509
534
|
retryableMethods: ["GET", "HEAD", "OPTIONS"],
|
|
510
|
-
retryableStatuses: [
|
|
511
|
-
retryOnTimeout: false
|
|
535
|
+
retryableStatuses: [...DEFAULT_RETRYABLE_STATUSES],
|
|
536
|
+
retryOnTimeout: false,
|
|
537
|
+
userAgent: USER_AGENT
|
|
512
538
|
};
|
|
513
539
|
function ensureFetch(fetchFn) {
|
|
514
540
|
const resolved = fetchFn ?? globalThis.fetch;
|
|
@@ -553,6 +579,21 @@ async function fetchWithTimeout(fetchFn, url, options, timeout) {
|
|
|
553
579
|
removeAbortListener?.();
|
|
554
580
|
}
|
|
555
581
|
}
|
|
582
|
+
function withUserAgent(options, userAgent) {
|
|
583
|
+
if (!isServerRuntime()) return options;
|
|
584
|
+
const entries = [];
|
|
585
|
+
const raw = options.headers;
|
|
586
|
+
if (Array.isArray(raw)) {
|
|
587
|
+
entries.push(...raw.map(([k, v]) => [k, v]));
|
|
588
|
+
} else if (raw && typeof raw.forEach === "function") {
|
|
589
|
+
raw.forEach((value, key) => entries.push([key, value]));
|
|
590
|
+
} else if (raw) {
|
|
591
|
+
entries.push(...Object.entries(raw));
|
|
592
|
+
}
|
|
593
|
+
if (entries.some(([k]) => k.toLowerCase() === "user-agent")) return options;
|
|
594
|
+
entries.push(["user-agent", userAgent]);
|
|
595
|
+
return { ...options, headers: entries };
|
|
596
|
+
}
|
|
556
597
|
function calculateDelay(attempt, baseDelay, exponential) {
|
|
557
598
|
if (exponential) {
|
|
558
599
|
const exponentialDelay = baseDelay * Math.pow(2, attempt);
|
|
@@ -569,11 +610,12 @@ async function fetchWithRetry(url, options = {}, fetchOptions = {}, fetchFn) {
|
|
|
569
610
|
const method = (options.method || "GET").toUpperCase();
|
|
570
611
|
const canRetry = opts.retryableMethods.includes(method);
|
|
571
612
|
const resolvedFetch = ensureFetch(fetchFn);
|
|
613
|
+
const init = withUserAgent(options, opts.userAgent);
|
|
572
614
|
const isAbortError = (error) => error instanceof Error && error.name === "AbortError";
|
|
573
615
|
let lastError = null;
|
|
574
616
|
for (let attempt = 0; attempt <= opts.retries; attempt++) {
|
|
575
617
|
try {
|
|
576
|
-
const response = await fetchWithTimeout(resolvedFetch, url,
|
|
618
|
+
const response = await fetchWithTimeout(resolvedFetch, url, init, opts.timeout);
|
|
577
619
|
if (!response.ok && canRetry && opts.retryableStatuses.includes(response.status) && attempt < opts.retries) {
|
|
578
620
|
const delay = calculateDelay(attempt, opts.retryDelay, opts.exponentialBackoff);
|
|
579
621
|
await sleep(delay);
|
|
@@ -746,6 +788,8 @@ var GAS_CONSTANTS = {
|
|
|
746
788
|
DENOM: "aault",
|
|
747
789
|
/** Chain multiplier applied to min gas to derive max gas (120 = 1.2×). */
|
|
748
790
|
FEE_FREE_GAS_MULTIPLIER: 120,
|
|
791
|
+
/** Headroom over simulated `gas_used` (130 = 1.3×). */
|
|
792
|
+
SIMULATED_GAS_MULTIPLIER: 130,
|
|
749
793
|
// License module
|
|
750
794
|
PER_LICENSE: 2e5,
|
|
751
795
|
PER_KYC_MEMBER: 2e5,
|
|
@@ -776,11 +820,19 @@ var GAS_CONSTANTS = {
|
|
|
776
820
|
// Accountx module
|
|
777
821
|
OPEN_ACCOUNT: 96e3,
|
|
778
822
|
// Staking module (cosmos-sdk standard, NOT fee-free — user pays gas).
|
|
823
|
+
// Staking gas depends on the delegator's state, so the builders simulate;
|
|
824
|
+
// these are the fallback (×FEE_FREE_GAS_MULTIPLIER) when simulate is down.
|
|
779
825
|
DELEGATE: 22e4,
|
|
780
|
-
UNDELEGATE:
|
|
781
|
-
BEGIN_REDELEGATE:
|
|
826
|
+
UNDELEGATE: 26e4,
|
|
827
|
+
BEGIN_REDELEGATE: 4e5,
|
|
782
828
|
WITHDRAW_DELEGATOR_REWARD: 22e4
|
|
783
829
|
};
|
|
830
|
+
function computeSimulatedGas(gasUsed, multiplier = GAS_CONSTANTS.SIMULATED_GAS_MULTIPLIER) {
|
|
831
|
+
if (!Number.isInteger(multiplier) || multiplier < 100) {
|
|
832
|
+
throw new Error(`simulated gas multiplier must be an integer >= 100, got ${multiplier}`);
|
|
833
|
+
}
|
|
834
|
+
return (gasUsed * BigInt(multiplier) / 100n).toString();
|
|
835
|
+
}
|
|
784
836
|
function computeFeeFreeGas(minGasPerOp, count, multiplier = GAS_CONSTANTS.FEE_FREE_GAS_MULTIPLIER) {
|
|
785
837
|
return (BigInt(minGasPerOp) * BigInt(count) * BigInt(multiplier) / 100n).toString();
|
|
786
838
|
}
|
|
@@ -12424,22 +12476,31 @@ function frameMatches(sub, data) {
|
|
|
12424
12476
|
}
|
|
12425
12477
|
}
|
|
12426
12478
|
var isowsModulePromise = null;
|
|
12427
|
-
function wrapCtor(Ctor) {
|
|
12428
|
-
return (url, protocols) =>
|
|
12479
|
+
function wrapCtor(Ctor, userAgent) {
|
|
12480
|
+
return (url, protocols) => {
|
|
12481
|
+
if (protocols !== void 0) return new Ctor(url, protocols);
|
|
12482
|
+
if (isServerRuntime()) {
|
|
12483
|
+
try {
|
|
12484
|
+
return new Ctor(url, { headers: { "User-Agent": userAgent } });
|
|
12485
|
+
} catch {
|
|
12486
|
+
}
|
|
12487
|
+
}
|
|
12488
|
+
return new Ctor(url);
|
|
12489
|
+
};
|
|
12429
12490
|
}
|
|
12430
12491
|
function currentGlobalCtor() {
|
|
12431
12492
|
return typeof globalThis !== "undefined" && typeof globalThis.WebSocket === "function" ? globalThis.WebSocket : null;
|
|
12432
12493
|
}
|
|
12433
|
-
function getDefaultWebSocketFactory() {
|
|
12494
|
+
function getDefaultWebSocketFactory(userAgent) {
|
|
12434
12495
|
const G = currentGlobalCtor();
|
|
12435
|
-
if (G) return wrapCtor(G);
|
|
12496
|
+
if (G) return wrapCtor(G, userAgent);
|
|
12436
12497
|
if (!isowsModulePromise) {
|
|
12437
12498
|
isowsModulePromise = import("isows");
|
|
12438
12499
|
}
|
|
12439
12500
|
return isowsModulePromise.then((mod) => {
|
|
12440
12501
|
const G2 = currentGlobalCtor();
|
|
12441
|
-
if (G2) return wrapCtor(G2);
|
|
12442
|
-
return wrapCtor(mod.WebSocket);
|
|
12502
|
+
if (G2) return wrapCtor(G2, userAgent);
|
|
12503
|
+
return wrapCtor(mod.WebSocket, userAgent);
|
|
12443
12504
|
});
|
|
12444
12505
|
}
|
|
12445
12506
|
var DexWsClient = class {
|
|
@@ -12467,7 +12528,8 @@ var DexWsClient = class {
|
|
|
12467
12528
|
reconnect: opts?.reconnect ?? true,
|
|
12468
12529
|
maxReconnectAttempts: opts?.maxReconnectAttempts ?? Infinity,
|
|
12469
12530
|
reconnectDelay: opts?.reconnectDelay ?? 1e3,
|
|
12470
|
-
maxReconnectDelay: opts?.maxReconnectDelay ?? 3e4
|
|
12531
|
+
maxReconnectDelay: opts?.maxReconnectDelay ?? 3e4,
|
|
12532
|
+
userAgent: opts?.userAgent ?? USER_AGENT
|
|
12471
12533
|
};
|
|
12472
12534
|
this.userFactory = opts?.createWebSocket;
|
|
12473
12535
|
}
|
|
@@ -12685,7 +12747,7 @@ var DexWsClient = class {
|
|
|
12685
12747
|
}
|
|
12686
12748
|
resolveFactory() {
|
|
12687
12749
|
if (this.userFactory) return this.userFactory;
|
|
12688
|
-
return getDefaultWebSocketFactory();
|
|
12750
|
+
return getDefaultWebSocketFactory(this.options.userAgent);
|
|
12689
12751
|
}
|
|
12690
12752
|
handleMessage(raw) {
|
|
12691
12753
|
let msg2;
|
|
@@ -15739,422 +15801,175 @@ function buildEip712TypedData(context, msgs, evmChainId) {
|
|
|
15739
15801
|
};
|
|
15740
15802
|
}
|
|
15741
15803
|
|
|
15742
|
-
// src/
|
|
15743
|
-
|
|
15744
|
-
|
|
15745
|
-
|
|
15746
|
-
|
|
15747
|
-
|
|
15748
|
-
fetchFn
|
|
15749
|
-
);
|
|
15750
|
-
const raw = data.params ?? {};
|
|
15751
|
-
return {
|
|
15752
|
-
noBaseFee: raw.noBaseFee ?? raw.no_base_fee ?? false,
|
|
15753
|
-
baseFee: raw.baseFee ?? raw.base_fee ?? "0",
|
|
15754
|
-
minGasPrice: raw.minGasPrice ?? raw.min_gas_price ?? "0"
|
|
15755
|
-
};
|
|
15756
|
-
}
|
|
15757
|
-
var ONE_E18 = 1000000000000000000n;
|
|
15758
|
-
var DEFAULT_FEE_MARGIN_PERCENT = 20;
|
|
15759
|
-
function marginFactorScaled(marginPercent) {
|
|
15760
|
-
if (!Number.isFinite(marginPercent) || !Number.isInteger(marginPercent)) {
|
|
15761
|
-
throw new Error(`marginPercent must be a non-negative integer, got ${marginPercent}`);
|
|
15804
|
+
// src/proto/tx-encode.ts
|
|
15805
|
+
var WIRE_VARINT = 0;
|
|
15806
|
+
var WIRE_LENGTH_DELIMITED = 2;
|
|
15807
|
+
var BinaryWriter35 = class {
|
|
15808
|
+
constructor() {
|
|
15809
|
+
this.chunks = [];
|
|
15762
15810
|
}
|
|
15763
|
-
|
|
15764
|
-
|
|
15811
|
+
writeVarint(value) {
|
|
15812
|
+
let v = BigInt(value);
|
|
15813
|
+
const bytes = [];
|
|
15814
|
+
do {
|
|
15815
|
+
let byte = Number(v & 0x7fn);
|
|
15816
|
+
v >>= 7n;
|
|
15817
|
+
if (v > 0n) byte |= 128;
|
|
15818
|
+
bytes.push(byte);
|
|
15819
|
+
} while (v > 0n);
|
|
15820
|
+
this.chunks.push(new Uint8Array(bytes));
|
|
15821
|
+
return this;
|
|
15765
15822
|
}
|
|
15766
|
-
|
|
15767
|
-
|
|
15768
|
-
|
|
15769
|
-
|
|
15770
|
-
|
|
15771
|
-
|
|
15772
|
-
|
|
15773
|
-
|
|
15774
|
-
|
|
15775
|
-
|
|
15776
|
-
|
|
15777
|
-
|
|
15778
|
-
|
|
15779
|
-
|
|
15780
|
-
|
|
15781
|
-
|
|
15782
|
-
|
|
15783
|
-
|
|
15784
|
-
|
|
15785
|
-
|
|
15786
|
-
|
|
15787
|
-
|
|
15788
|
-
|
|
15789
|
-
|
|
15790
|
-
|
|
15823
|
+
writeTag(fieldNumber, wireType) {
|
|
15824
|
+
return this.writeVarint(fieldNumber << 3 | wireType);
|
|
15825
|
+
}
|
|
15826
|
+
writeString(fieldNumber, value) {
|
|
15827
|
+
if (!value) return this;
|
|
15828
|
+
this.writeTag(fieldNumber, WIRE_LENGTH_DELIMITED);
|
|
15829
|
+
const bytes = new TextEncoder().encode(value);
|
|
15830
|
+
this.writeVarint(bytes.length);
|
|
15831
|
+
this.chunks.push(bytes);
|
|
15832
|
+
return this;
|
|
15833
|
+
}
|
|
15834
|
+
writeBool(fieldNumber, value) {
|
|
15835
|
+
if (!value) return this;
|
|
15836
|
+
this.writeTag(fieldNumber, WIRE_VARINT);
|
|
15837
|
+
this.writeVarint(value ? 1 : 0);
|
|
15838
|
+
return this;
|
|
15839
|
+
}
|
|
15840
|
+
writeUint64(fieldNumber, value) {
|
|
15841
|
+
const v = BigInt(value);
|
|
15842
|
+
if (v === 0n) return this;
|
|
15843
|
+
this.writeTag(fieldNumber, WIRE_VARINT);
|
|
15844
|
+
this.writeVarint(v);
|
|
15845
|
+
return this;
|
|
15846
|
+
}
|
|
15847
|
+
writeInt32(fieldNumber, value) {
|
|
15848
|
+
if (value === 0) return this;
|
|
15849
|
+
this.writeTag(fieldNumber, WIRE_VARINT);
|
|
15850
|
+
this.writeVarint(value);
|
|
15851
|
+
return this;
|
|
15852
|
+
}
|
|
15853
|
+
writeBytes(fieldNumber, value) {
|
|
15854
|
+
if (value.length === 0) return this;
|
|
15855
|
+
this.writeTag(fieldNumber, WIRE_LENGTH_DELIMITED);
|
|
15856
|
+
this.writeVarint(value.length);
|
|
15857
|
+
this.chunks.push(value);
|
|
15858
|
+
return this;
|
|
15859
|
+
}
|
|
15860
|
+
writeRepeatedString(fieldNumber, values) {
|
|
15861
|
+
for (const value of values) {
|
|
15862
|
+
this.writeString(fieldNumber, value);
|
|
15791
15863
|
}
|
|
15864
|
+
return this;
|
|
15792
15865
|
}
|
|
15793
|
-
|
|
15794
|
-
|
|
15795
|
-
|
|
15796
|
-
|
|
15797
|
-
|
|
15798
|
-
|
|
15866
|
+
writeRepeatedUint64(fieldNumber, values) {
|
|
15867
|
+
for (const value of values) {
|
|
15868
|
+
this.writeTag(fieldNumber, WIRE_VARINT);
|
|
15869
|
+
this.writeVarint(BigInt(value));
|
|
15870
|
+
}
|
|
15871
|
+
return this;
|
|
15799
15872
|
}
|
|
15800
|
-
|
|
15801
|
-
|
|
15873
|
+
writeRepeatedBytes(fieldNumber, values) {
|
|
15874
|
+
for (const value of values) {
|
|
15875
|
+
this.writeBytes(fieldNumber, value);
|
|
15876
|
+
}
|
|
15877
|
+
return this;
|
|
15802
15878
|
}
|
|
15803
|
-
|
|
15879
|
+
finish() {
|
|
15880
|
+
const total = this.chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
15881
|
+
const result = new Uint8Array(total);
|
|
15882
|
+
let offset = 0;
|
|
15883
|
+
for (const chunk of this.chunks) {
|
|
15884
|
+
result.set(chunk, offset);
|
|
15885
|
+
offset += chunk.length;
|
|
15886
|
+
}
|
|
15887
|
+
return result;
|
|
15888
|
+
}
|
|
15889
|
+
};
|
|
15890
|
+
function encodeAny(typeUrl, value) {
|
|
15891
|
+
const writer = new BinaryWriter35();
|
|
15892
|
+
writer.writeString(1, typeUrl);
|
|
15893
|
+
writer.writeBytes(2, value);
|
|
15894
|
+
return writer.finish();
|
|
15804
15895
|
}
|
|
15805
|
-
function
|
|
15806
|
-
|
|
15896
|
+
function encodeCoin(denom, amount) {
|
|
15897
|
+
const writer = new BinaryWriter35();
|
|
15898
|
+
writer.writeString(1, denom);
|
|
15899
|
+
writer.writeString(2, amount);
|
|
15900
|
+
return writer.finish();
|
|
15807
15901
|
}
|
|
15808
|
-
function
|
|
15809
|
-
const
|
|
15810
|
-
const
|
|
15811
|
-
|
|
15812
|
-
|
|
15813
|
-
if (effectiveI <= 0n) {
|
|
15814
|
-
return { maxFeePerGas: 0n, maxPriorityFeePerGas: 0n };
|
|
15902
|
+
function encodeFee(fee) {
|
|
15903
|
+
const writer = new BinaryWriter35();
|
|
15904
|
+
for (const coin of fee.amount) {
|
|
15905
|
+
const coinBytes = encodeCoin(coin.denom, coin.amount);
|
|
15906
|
+
writer.writeBytes(1, coinBytes);
|
|
15815
15907
|
}
|
|
15816
|
-
|
|
15817
|
-
|
|
15818
|
-
const gasPriceWei = (numerator + denominator - 1n) / denominator;
|
|
15819
|
-
return { maxFeePerGas: gasPriceWei, maxPriorityFeePerGas: gasPriceWei };
|
|
15908
|
+
writer.writeUint64(2, fee.gasLimit);
|
|
15909
|
+
return writer.finish();
|
|
15820
15910
|
}
|
|
15821
|
-
|
|
15822
|
-
const
|
|
15823
|
-
|
|
15824
|
-
|
|
15825
|
-
options?.fetchFn,
|
|
15826
|
-
options?.fetchOptions
|
|
15827
|
-
);
|
|
15828
|
-
if (!params) return null;
|
|
15829
|
-
let fees;
|
|
15830
|
-
try {
|
|
15831
|
-
fees = computeEvmFeesPerGas(params, { marginPercent: options?.marginPercent });
|
|
15832
|
-
} catch {
|
|
15833
|
-
return null;
|
|
15834
|
-
}
|
|
15835
|
-
if (fees.maxFeePerGas === 0n && fees.maxPriorityFeePerGas === 0n) return null;
|
|
15836
|
-
return fees;
|
|
15911
|
+
function encodeModeInfoSingle(mode) {
|
|
15912
|
+
const writer = new BinaryWriter35();
|
|
15913
|
+
writer.writeInt32(1, mode);
|
|
15914
|
+
return writer.finish();
|
|
15837
15915
|
}
|
|
15838
|
-
|
|
15839
|
-
|
|
15840
|
-
|
|
15841
|
-
|
|
15842
|
-
|
|
15843
|
-
return typeof obj === "object" && obj !== null && AULT_SIGNER_MARKER in obj && obj[AULT_SIGNER_MARKER] === true;
|
|
15916
|
+
function encodeModeInfo(mode) {
|
|
15917
|
+
const writer = new BinaryWriter35();
|
|
15918
|
+
const singleBytes = encodeModeInfoSingle(mode);
|
|
15919
|
+
writer.writeBytes(1, singleBytes);
|
|
15920
|
+
return writer.finish();
|
|
15844
15921
|
}
|
|
15845
|
-
function
|
|
15846
|
-
|
|
15847
|
-
|
|
15848
|
-
|
|
15849
|
-
|
|
15850
|
-
|
|
15851
|
-
|
|
15852
|
-
|
|
15853
|
-
throw new Error("Invalid signer: expected a signer object or signTypedData function.");
|
|
15922
|
+
function encodeSignerInfo(info) {
|
|
15923
|
+
const writer = new BinaryWriter35();
|
|
15924
|
+
const pubKeyAny = encodeAny(info.publicKey.typeUrl, info.publicKey.value);
|
|
15925
|
+
writer.writeBytes(1, pubKeyAny);
|
|
15926
|
+
const modeInfoBytes = encodeModeInfo(info.mode);
|
|
15927
|
+
writer.writeBytes(2, modeInfoBytes);
|
|
15928
|
+
writer.writeUint64(3, typeof info.sequence === "string" ? BigInt(info.sequence) : info.sequence);
|
|
15929
|
+
return writer.finish();
|
|
15854
15930
|
}
|
|
15855
|
-
function
|
|
15856
|
-
|
|
15857
|
-
|
|
15858
|
-
|
|
15859
|
-
if (result && typeof result.signature === "string") {
|
|
15860
|
-
return result.signature;
|
|
15931
|
+
function encodeAuthInfo(authInfo) {
|
|
15932
|
+
const writer = new BinaryWriter35();
|
|
15933
|
+
for (const signerInfo of authInfo.signerInfos) {
|
|
15934
|
+
writer.writeBytes(1, encodeSignerInfo(signerInfo));
|
|
15861
15935
|
}
|
|
15862
|
-
|
|
15936
|
+
writer.writeBytes(2, encodeFee(authInfo.fee));
|
|
15937
|
+
return writer.finish();
|
|
15863
15938
|
}
|
|
15864
|
-
|
|
15865
|
-
|
|
15866
|
-
|
|
15939
|
+
function encodeTxBody(body) {
|
|
15940
|
+
const writer = new BinaryWriter35();
|
|
15941
|
+
for (const msg2 of body.messages) {
|
|
15942
|
+
writer.writeBytes(1, encodeAny(msg2.typeUrl, msg2.value));
|
|
15867
15943
|
}
|
|
15868
|
-
if (
|
|
15869
|
-
|
|
15870
|
-
return typeof address === "string" ? address : null;
|
|
15944
|
+
if (body.memo) {
|
|
15945
|
+
writer.writeString(2, body.memo);
|
|
15871
15946
|
}
|
|
15872
|
-
|
|
15873
|
-
|
|
15874
|
-
async function resolveSignerAddress(signer, signerAddress) {
|
|
15875
|
-
const raw = signerAddress ?? (signer ? await getSignerAddress(signer) : null);
|
|
15876
|
-
if (!raw) {
|
|
15877
|
-
throw new Error("signerAddress is required when the signer has no address.");
|
|
15878
|
-
}
|
|
15879
|
-
if (isValidAultAddress(raw)) {
|
|
15880
|
-
return raw;
|
|
15881
|
-
}
|
|
15882
|
-
if (isValidEvmAddress(raw)) {
|
|
15883
|
-
return evmToAult(raw);
|
|
15884
|
-
}
|
|
15885
|
-
throw new Error(`Invalid signerAddress: ${raw}`);
|
|
15886
|
-
}
|
|
15887
|
-
function stripEip712Domain(types) {
|
|
15888
|
-
const { EIP712Domain: _removed, ...rest } = types;
|
|
15889
|
-
return rest;
|
|
15890
|
-
}
|
|
15891
|
-
function createEip1193Signer(options) {
|
|
15892
|
-
const method = options.method ?? "eth_signTypedData_v4";
|
|
15893
|
-
return {
|
|
15894
|
-
[AULT_SIGNER_MARKER]: true,
|
|
15895
|
-
address: options.address,
|
|
15896
|
-
signTypedData: async (typedData) => {
|
|
15897
|
-
const payload = method === "eth_signTypedData_v4" ? JSON.stringify(typedData) : typedData;
|
|
15898
|
-
const signature = await options.provider.request({
|
|
15899
|
-
method,
|
|
15900
|
-
params: [options.address, payload]
|
|
15901
|
-
});
|
|
15902
|
-
if (typeof signature !== "string") {
|
|
15903
|
-
throw new Error("Provider did not return a signature string.");
|
|
15904
|
-
}
|
|
15905
|
-
return { signature };
|
|
15906
|
-
}
|
|
15907
|
-
};
|
|
15908
|
-
}
|
|
15909
|
-
function createViemSigner(wallet, options) {
|
|
15910
|
-
const preferRpc = options?.preferRpc ?? true;
|
|
15911
|
-
const getAddress3 = async () => {
|
|
15912
|
-
if (wallet.address) return wallet.address;
|
|
15913
|
-
if (wallet.getAddresses) {
|
|
15914
|
-
const addresses = await wallet.getAddresses();
|
|
15915
|
-
if (addresses?.length) return addresses[0];
|
|
15916
|
-
}
|
|
15917
|
-
return void 0;
|
|
15918
|
-
};
|
|
15919
|
-
return {
|
|
15920
|
-
[AULT_SIGNER_MARKER]: true,
|
|
15921
|
-
getAddress: async () => {
|
|
15922
|
-
const addr = await getAddress3();
|
|
15923
|
-
if (!addr) throw new Error("Viem wallet has no address");
|
|
15924
|
-
return addr;
|
|
15925
|
-
},
|
|
15926
|
-
signTypedData: async (typedData) => {
|
|
15927
|
-
if (preferRpc && wallet.request) {
|
|
15928
|
-
const address = await getAddress3();
|
|
15929
|
-
if (!address) {
|
|
15930
|
-
throw new Error("Viem wallet has no address; pass signerAddress explicitly.");
|
|
15931
|
-
}
|
|
15932
|
-
const signature2 = await wallet.request({
|
|
15933
|
-
method: "eth_signTypedData_v4",
|
|
15934
|
-
params: [address, JSON.stringify(typedData)]
|
|
15935
|
-
});
|
|
15936
|
-
if (typeof signature2 !== "string") {
|
|
15937
|
-
throw new Error("RPC signer did not return a signature string.");
|
|
15938
|
-
}
|
|
15939
|
-
return { signature: signature2 };
|
|
15940
|
-
}
|
|
15941
|
-
if (!wallet.signTypedData) {
|
|
15942
|
-
throw new Error("Viem signer does not support signTypedData.");
|
|
15943
|
-
}
|
|
15944
|
-
const signature = await wallet.signTypedData({
|
|
15945
|
-
domain: typedData.domain,
|
|
15946
|
-
types: typedData.types,
|
|
15947
|
-
primaryType: typedData.primaryType,
|
|
15948
|
-
message: typedData.message
|
|
15949
|
-
});
|
|
15950
|
-
return { signature };
|
|
15951
|
-
}
|
|
15952
|
-
};
|
|
15953
|
-
}
|
|
15954
|
-
function createEthersSigner(signer) {
|
|
15955
|
-
const sign = signer.signTypedData ?? signer._signTypedData;
|
|
15956
|
-
if (!sign) {
|
|
15957
|
-
throw new Error("Ethers signer must implement signTypedData or _signTypedData.");
|
|
15958
|
-
}
|
|
15959
|
-
return {
|
|
15960
|
-
[AULT_SIGNER_MARKER]: true,
|
|
15961
|
-
getAddress: () => signer.getAddress(),
|
|
15962
|
-
signTypedData: async (typedData) => {
|
|
15963
|
-
const types = stripEip712Domain(typedData.types);
|
|
15964
|
-
const signature = await sign(typedData.domain, types, typedData.message);
|
|
15965
|
-
return { signature };
|
|
15966
|
-
}
|
|
15967
|
-
};
|
|
15968
|
-
}
|
|
15969
|
-
function createPrivySigner(options) {
|
|
15970
|
-
return {
|
|
15971
|
-
[AULT_SIGNER_MARKER]: true,
|
|
15972
|
-
address: options.address,
|
|
15973
|
-
signTypedData: (typedData) => options.signTypedData(typedData, options.address ? { address: options.address } : void 0)
|
|
15974
|
-
};
|
|
15975
|
-
}
|
|
15976
|
-
function createPrivateKeySigner(privateKey) {
|
|
15977
|
-
const normalized = privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`;
|
|
15978
|
-
const account = (0, import_accounts.privateKeyToAccount)(normalized);
|
|
15979
|
-
return createViemSigner(account);
|
|
15980
|
-
}
|
|
15981
|
-
|
|
15982
|
-
// src/utils/tx-hash.ts
|
|
15983
|
-
function normalizeTxHash(raw) {
|
|
15984
|
-
if (!raw) return raw;
|
|
15985
|
-
const stripped = raw.startsWith("0x") || raw.startsWith("0X") ? raw.slice(2) : raw;
|
|
15986
|
-
return stripped.toLowerCase();
|
|
15987
|
-
}
|
|
15988
|
-
|
|
15989
|
-
// src/proto/tx-encode.ts
|
|
15990
|
-
var WIRE_VARINT = 0;
|
|
15991
|
-
var WIRE_LENGTH_DELIMITED = 2;
|
|
15992
|
-
var BinaryWriter35 = class {
|
|
15993
|
-
constructor() {
|
|
15994
|
-
this.chunks = [];
|
|
15995
|
-
}
|
|
15996
|
-
writeVarint(value) {
|
|
15997
|
-
let v = BigInt(value);
|
|
15998
|
-
const bytes = [];
|
|
15999
|
-
do {
|
|
16000
|
-
let byte = Number(v & 0x7fn);
|
|
16001
|
-
v >>= 7n;
|
|
16002
|
-
if (v > 0n) byte |= 128;
|
|
16003
|
-
bytes.push(byte);
|
|
16004
|
-
} while (v > 0n);
|
|
16005
|
-
this.chunks.push(new Uint8Array(bytes));
|
|
16006
|
-
return this;
|
|
16007
|
-
}
|
|
16008
|
-
writeTag(fieldNumber, wireType) {
|
|
16009
|
-
return this.writeVarint(fieldNumber << 3 | wireType);
|
|
16010
|
-
}
|
|
16011
|
-
writeString(fieldNumber, value) {
|
|
16012
|
-
if (!value) return this;
|
|
16013
|
-
this.writeTag(fieldNumber, WIRE_LENGTH_DELIMITED);
|
|
16014
|
-
const bytes = new TextEncoder().encode(value);
|
|
16015
|
-
this.writeVarint(bytes.length);
|
|
16016
|
-
this.chunks.push(bytes);
|
|
16017
|
-
return this;
|
|
16018
|
-
}
|
|
16019
|
-
writeBool(fieldNumber, value) {
|
|
16020
|
-
if (!value) return this;
|
|
16021
|
-
this.writeTag(fieldNumber, WIRE_VARINT);
|
|
16022
|
-
this.writeVarint(value ? 1 : 0);
|
|
16023
|
-
return this;
|
|
16024
|
-
}
|
|
16025
|
-
writeUint64(fieldNumber, value) {
|
|
16026
|
-
const v = BigInt(value);
|
|
16027
|
-
if (v === 0n) return this;
|
|
16028
|
-
this.writeTag(fieldNumber, WIRE_VARINT);
|
|
16029
|
-
this.writeVarint(v);
|
|
16030
|
-
return this;
|
|
16031
|
-
}
|
|
16032
|
-
writeInt32(fieldNumber, value) {
|
|
16033
|
-
if (value === 0) return this;
|
|
16034
|
-
this.writeTag(fieldNumber, WIRE_VARINT);
|
|
16035
|
-
this.writeVarint(value);
|
|
16036
|
-
return this;
|
|
16037
|
-
}
|
|
16038
|
-
writeBytes(fieldNumber, value) {
|
|
16039
|
-
if (value.length === 0) return this;
|
|
16040
|
-
this.writeTag(fieldNumber, WIRE_LENGTH_DELIMITED);
|
|
16041
|
-
this.writeVarint(value.length);
|
|
16042
|
-
this.chunks.push(value);
|
|
16043
|
-
return this;
|
|
16044
|
-
}
|
|
16045
|
-
writeRepeatedString(fieldNumber, values) {
|
|
16046
|
-
for (const value of values) {
|
|
16047
|
-
this.writeString(fieldNumber, value);
|
|
16048
|
-
}
|
|
16049
|
-
return this;
|
|
16050
|
-
}
|
|
16051
|
-
writeRepeatedUint64(fieldNumber, values) {
|
|
16052
|
-
for (const value of values) {
|
|
16053
|
-
this.writeTag(fieldNumber, WIRE_VARINT);
|
|
16054
|
-
this.writeVarint(BigInt(value));
|
|
16055
|
-
}
|
|
16056
|
-
return this;
|
|
16057
|
-
}
|
|
16058
|
-
writeRepeatedBytes(fieldNumber, values) {
|
|
16059
|
-
for (const value of values) {
|
|
16060
|
-
this.writeBytes(fieldNumber, value);
|
|
16061
|
-
}
|
|
16062
|
-
return this;
|
|
16063
|
-
}
|
|
16064
|
-
finish() {
|
|
16065
|
-
const total = this.chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
16066
|
-
const result = new Uint8Array(total);
|
|
16067
|
-
let offset = 0;
|
|
16068
|
-
for (const chunk of this.chunks) {
|
|
16069
|
-
result.set(chunk, offset);
|
|
16070
|
-
offset += chunk.length;
|
|
16071
|
-
}
|
|
16072
|
-
return result;
|
|
16073
|
-
}
|
|
16074
|
-
};
|
|
16075
|
-
function encodeAny(typeUrl, value) {
|
|
16076
|
-
const writer = new BinaryWriter35();
|
|
16077
|
-
writer.writeString(1, typeUrl);
|
|
16078
|
-
writer.writeBytes(2, value);
|
|
16079
|
-
return writer.finish();
|
|
16080
|
-
}
|
|
16081
|
-
function encodeCoin(denom, amount) {
|
|
16082
|
-
const writer = new BinaryWriter35();
|
|
16083
|
-
writer.writeString(1, denom);
|
|
16084
|
-
writer.writeString(2, amount);
|
|
16085
|
-
return writer.finish();
|
|
16086
|
-
}
|
|
16087
|
-
function encodeFee(fee) {
|
|
16088
|
-
const writer = new BinaryWriter35();
|
|
16089
|
-
for (const coin of fee.amount) {
|
|
16090
|
-
const coinBytes = encodeCoin(coin.denom, coin.amount);
|
|
16091
|
-
writer.writeBytes(1, coinBytes);
|
|
15947
|
+
if (body.timeoutHeight) {
|
|
15948
|
+
writer.writeUint64(3, body.timeoutHeight);
|
|
16092
15949
|
}
|
|
16093
|
-
writer.writeUint64(2, fee.gasLimit);
|
|
16094
|
-
return writer.finish();
|
|
16095
|
-
}
|
|
16096
|
-
function encodeModeInfoSingle(mode) {
|
|
16097
|
-
const writer = new BinaryWriter35();
|
|
16098
|
-
writer.writeInt32(1, mode);
|
|
16099
15950
|
return writer.finish();
|
|
16100
15951
|
}
|
|
16101
|
-
function
|
|
15952
|
+
function encodeTxRaw(txRaw) {
|
|
16102
15953
|
const writer = new BinaryWriter35();
|
|
16103
|
-
|
|
16104
|
-
writer.writeBytes(
|
|
15954
|
+
writer.writeBytes(1, txRaw.bodyBytes);
|
|
15955
|
+
writer.writeBytes(2, txRaw.authInfoBytes);
|
|
15956
|
+
writer.writeRepeatedBytes(3, txRaw.signatures);
|
|
16105
15957
|
return writer.finish();
|
|
16106
15958
|
}
|
|
16107
|
-
function
|
|
15959
|
+
function encodeEthSecp256k1PubKey(key) {
|
|
16108
15960
|
const writer = new BinaryWriter35();
|
|
16109
|
-
|
|
16110
|
-
writer.writeBytes(1, pubKeyAny);
|
|
16111
|
-
const modeInfoBytes = encodeModeInfo(info.mode);
|
|
16112
|
-
writer.writeBytes(2, modeInfoBytes);
|
|
16113
|
-
writer.writeUint64(3, typeof info.sequence === "string" ? BigInt(info.sequence) : info.sequence);
|
|
15961
|
+
writer.writeBytes(1, key);
|
|
16114
15962
|
return writer.finish();
|
|
16115
15963
|
}
|
|
16116
|
-
|
|
15964
|
+
var SIGN_MODE_LEGACY_AMINO_JSON = 127;
|
|
15965
|
+
var SIGN_MODE_DIRECT = 1;
|
|
15966
|
+
function encodeTimestamp(seconds, nanos) {
|
|
16117
15967
|
const writer = new BinaryWriter35();
|
|
16118
|
-
|
|
16119
|
-
|
|
16120
|
-
}
|
|
16121
|
-
writer.writeBytes(2, encodeFee(authInfo.fee));
|
|
15968
|
+
writer.writeUint64(1, seconds);
|
|
15969
|
+
writer.writeInt32(2, nanos);
|
|
16122
15970
|
return writer.finish();
|
|
16123
15971
|
}
|
|
16124
|
-
function
|
|
16125
|
-
const writer = new BinaryWriter35();
|
|
16126
|
-
for (const msg2 of body.messages) {
|
|
16127
|
-
writer.writeBytes(1, encodeAny(msg2.typeUrl, msg2.value));
|
|
16128
|
-
}
|
|
16129
|
-
if (body.memo) {
|
|
16130
|
-
writer.writeString(2, body.memo);
|
|
16131
|
-
}
|
|
16132
|
-
if (body.timeoutHeight) {
|
|
16133
|
-
writer.writeUint64(3, body.timeoutHeight);
|
|
16134
|
-
}
|
|
16135
|
-
return writer.finish();
|
|
16136
|
-
}
|
|
16137
|
-
function encodeTxRaw(txRaw) {
|
|
16138
|
-
const writer = new BinaryWriter35();
|
|
16139
|
-
writer.writeBytes(1, txRaw.bodyBytes);
|
|
16140
|
-
writer.writeBytes(2, txRaw.authInfoBytes);
|
|
16141
|
-
writer.writeRepeatedBytes(3, txRaw.signatures);
|
|
16142
|
-
return writer.finish();
|
|
16143
|
-
}
|
|
16144
|
-
function encodeEthSecp256k1PubKey(key) {
|
|
16145
|
-
const writer = new BinaryWriter35();
|
|
16146
|
-
writer.writeBytes(1, key);
|
|
16147
|
-
return writer.finish();
|
|
16148
|
-
}
|
|
16149
|
-
var SIGN_MODE_LEGACY_AMINO_JSON = 127;
|
|
16150
|
-
var SIGN_MODE_DIRECT = 1;
|
|
16151
|
-
function encodeTimestamp(seconds, nanos) {
|
|
16152
|
-
const writer = new BinaryWriter35();
|
|
16153
|
-
writer.writeUint64(1, seconds);
|
|
16154
|
-
writer.writeInt32(2, nanos);
|
|
16155
|
-
return writer.finish();
|
|
16156
|
-
}
|
|
16157
|
-
function encodeTxBodyAgent(body) {
|
|
15972
|
+
function encodeTxBodyAgent(body) {
|
|
16158
15973
|
const writer = new BinaryWriter35();
|
|
16159
15974
|
for (const msg2 of body.messages) {
|
|
16160
15975
|
writer.writeBytes(1, encodeAny(msg2.typeUrl, msg2.value));
|
|
@@ -24655,224 +24470,595 @@ function mapCosmosStakingV1beta1MsgDelegate(input, label = "value") {
|
|
|
24655
24470
|
amount: mapCosmosBaseV1beta1Coin(asRecord(record2["amount"]), `${prefix}amount`)
|
|
24656
24471
|
};
|
|
24657
24472
|
}
|
|
24658
|
-
function mapCosmosStakingV1beta1MsgUndelegate(input, label = "value") {
|
|
24659
|
-
const record2 = asRecord(input);
|
|
24660
|
-
const prefix = label ? `${label}.` : "";
|
|
24473
|
+
function mapCosmosStakingV1beta1MsgUndelegate(input, label = "value") {
|
|
24474
|
+
const record2 = asRecord(input);
|
|
24475
|
+
const prefix = label ? `${label}.` : "";
|
|
24476
|
+
return {
|
|
24477
|
+
delegatorAddress: requireString(record2["delegatorAddress"], `${prefix}delegatorAddress`),
|
|
24478
|
+
validatorAddress: requireString(record2["validatorAddress"], `${prefix}validatorAddress`),
|
|
24479
|
+
amount: mapCosmosBaseV1beta1Coin(asRecord(record2["amount"]), `${prefix}amount`)
|
|
24480
|
+
};
|
|
24481
|
+
}
|
|
24482
|
+
function mapGoogleProtobufAny(input, label = "value") {
|
|
24483
|
+
const record2 = asRecord(input);
|
|
24484
|
+
const prefix = label ? `${label}.` : "";
|
|
24485
|
+
return {
|
|
24486
|
+
typeUrl: requireString(record2["typeUrl"], `${prefix}typeUrl`),
|
|
24487
|
+
value: requireBytes(record2["value"], `${prefix}value`)
|
|
24488
|
+
};
|
|
24489
|
+
}
|
|
24490
|
+
var MSG_ENCODERS = {
|
|
24491
|
+
"/ault.accountx.v1.MsgOpenAccount": (value) => MsgOpenAccount.encode(
|
|
24492
|
+
MsgOpenAccount.fromPartial(mapAultAccountxV1MsgOpenAccount(value))
|
|
24493
|
+
).finish(),
|
|
24494
|
+
"/ault.accountx.v1.MsgUpdateFeeTiers": (value) => MsgUpdateFeeTiers.encode(
|
|
24495
|
+
MsgUpdateFeeTiers.fromPartial(mapAultAccountxV1MsgUpdateFeeTiers(value))
|
|
24496
|
+
).finish(),
|
|
24497
|
+
"/ault.accountx.v1.MsgUpdateParams": (value) => MsgUpdateParams.encode(
|
|
24498
|
+
MsgUpdateParams.fromPartial(mapAultAccountxV1MsgUpdateParams(value))
|
|
24499
|
+
).finish(),
|
|
24500
|
+
"/ault.accountx.v1.MsgUpdateTradingTiers": (value) => MsgUpdateTradingTiers.encode(
|
|
24501
|
+
MsgUpdateTradingTiers.fromPartial(mapAultAccountxV1MsgUpdateTradingTiers(value))
|
|
24502
|
+
).finish(),
|
|
24503
|
+
"/ault.agent.v1.MsgApproveAgent": (value) => MsgApproveAgent.encode(
|
|
24504
|
+
MsgApproveAgent.fromPartial(mapAultAgentV1MsgApproveAgent(value))
|
|
24505
|
+
).finish(),
|
|
24506
|
+
"/ault.agent.v1.MsgRevokeAgent": (value) => MsgRevokeAgent.encode(MsgRevokeAgent.fromPartial(mapAultAgentV1MsgRevokeAgent(value))).finish(),
|
|
24507
|
+
"/ault.agent.v1.MsgUpdateParams": (value) => MsgUpdateParams2.encode(
|
|
24508
|
+
MsgUpdateParams2.fromPartial(mapAultAgentV1MsgUpdateParams(value))
|
|
24509
|
+
).finish(),
|
|
24510
|
+
"/ault.authority.v1.MsgGrantRole": (value) => MsgGrantRole.encode(MsgGrantRole.fromPartial(mapAultAuthorityV1MsgGrantRole(value))).finish(),
|
|
24511
|
+
"/ault.authority.v1.MsgRevokeRole": (value) => MsgRevokeRole.encode(
|
|
24512
|
+
MsgRevokeRole.fromPartial(mapAultAuthorityV1MsgRevokeRole(value))
|
|
24513
|
+
).finish(),
|
|
24514
|
+
"/ault.clob.v1.MsgCancelOrders": (value) => MsgCancelOrders.encode(
|
|
24515
|
+
MsgCancelOrders.fromPartial(mapAultClobV1MsgCancelOrders(value))
|
|
24516
|
+
).finish(),
|
|
24517
|
+
"/ault.clob.v1.MsgModifyOrders": (value) => MsgModifyOrders.encode(
|
|
24518
|
+
MsgModifyOrders.fromPartial(mapAultClobV1MsgModifyOrders(value))
|
|
24519
|
+
).finish(),
|
|
24520
|
+
"/ault.clob.v1.MsgPlaceLimitOrder": (value) => MsgPlaceLimitOrder.encode(
|
|
24521
|
+
MsgPlaceLimitOrder.fromPartial(mapAultClobV1MsgPlaceLimitOrder(value))
|
|
24522
|
+
).finish(),
|
|
24523
|
+
"/ault.clob.v1.MsgPlaceMarketOrder": (value) => MsgPlaceMarketOrder.encode(
|
|
24524
|
+
MsgPlaceMarketOrder.fromPartial(mapAultClobV1MsgPlaceMarketOrder(value))
|
|
24525
|
+
).finish(),
|
|
24526
|
+
"/ault.clob.v1.MsgPlaceScaleOrder": (value) => MsgPlaceScaleOrder.encode(
|
|
24527
|
+
MsgPlaceScaleOrder.fromPartial(mapAultClobV1MsgPlaceScaleOrder(value))
|
|
24528
|
+
).finish(),
|
|
24529
|
+
"/ault.clob.v1.MsgPlaceTwapOrder": (value) => MsgPlaceTwapOrder.encode(
|
|
24530
|
+
MsgPlaceTwapOrder.fromPartial(mapAultClobV1MsgPlaceTwapOrder(value))
|
|
24531
|
+
).finish(),
|
|
24532
|
+
"/ault.clob.v1.MsgUpdateParams": (value) => MsgUpdateParams3.encode(
|
|
24533
|
+
MsgUpdateParams3.fromPartial(mapAultClobV1MsgUpdateParams(value))
|
|
24534
|
+
).finish(),
|
|
24535
|
+
"/ault.license.v1.MsgApproveMember": (value) => MsgApproveMember.encode(
|
|
24536
|
+
MsgApproveMember.fromPartial(mapAultLicenseV1MsgApproveMember(value))
|
|
24537
|
+
).finish(),
|
|
24538
|
+
"/ault.license.v1.MsgBatchApproveMember": (value) => MsgBatchApproveMember.encode(
|
|
24539
|
+
MsgBatchApproveMember.fromPartial(mapAultLicenseV1MsgBatchApproveMember(value))
|
|
24540
|
+
).finish(),
|
|
24541
|
+
"/ault.license.v1.MsgBatchMintLicense": (value) => MsgBatchMintLicense.encode(
|
|
24542
|
+
MsgBatchMintLicense.fromPartial(mapAultLicenseV1MsgBatchMintLicense(value))
|
|
24543
|
+
).finish(),
|
|
24544
|
+
"/ault.license.v1.MsgBatchRevokeMember": (value) => MsgBatchRevokeMember.encode(
|
|
24545
|
+
MsgBatchRevokeMember.fromPartial(mapAultLicenseV1MsgBatchRevokeMember(value))
|
|
24546
|
+
).finish(),
|
|
24547
|
+
"/ault.license.v1.MsgBurnLicense": (value) => MsgBurnLicense.encode(
|
|
24548
|
+
MsgBurnLicense.fromPartial(mapAultLicenseV1MsgBurnLicense(value))
|
|
24549
|
+
).finish(),
|
|
24550
|
+
"/ault.license.v1.MsgMintLicense": (value) => MsgMintLicense.encode(
|
|
24551
|
+
MsgMintLicense.fromPartial(mapAultLicenseV1MsgMintLicense(value))
|
|
24552
|
+
).finish(),
|
|
24553
|
+
"/ault.license.v1.MsgRevokeLicense": (value) => MsgRevokeLicense.encode(
|
|
24554
|
+
MsgRevokeLicense.fromPartial(mapAultLicenseV1MsgRevokeLicense(value))
|
|
24555
|
+
).finish(),
|
|
24556
|
+
"/ault.license.v1.MsgRevokeMember": (value) => MsgRevokeMember.encode(
|
|
24557
|
+
MsgRevokeMember.fromPartial(mapAultLicenseV1MsgRevokeMember(value))
|
|
24558
|
+
).finish(),
|
|
24559
|
+
"/ault.license.v1.MsgSetKYCApprovers": (value) => MsgSetKYCApprovers.encode(
|
|
24560
|
+
MsgSetKYCApprovers.fromPartial(mapAultLicenseV1MsgSetKYCApprovers(value))
|
|
24561
|
+
).finish(),
|
|
24562
|
+
"/ault.license.v1.MsgSetMinters": (value) => MsgSetMinters.encode(MsgSetMinters.fromPartial(mapAultLicenseV1MsgSetMinters(value))).finish(),
|
|
24563
|
+
"/ault.license.v1.MsgSetTokenURI": (value) => MsgSetTokenURI.encode(
|
|
24564
|
+
MsgSetTokenURI.fromPartial(mapAultLicenseV1MsgSetTokenURI(value))
|
|
24565
|
+
).finish(),
|
|
24566
|
+
"/ault.license.v1.MsgTransferLicense": (value) => MsgTransferLicense.encode(
|
|
24567
|
+
MsgTransferLicense.fromPartial(mapAultLicenseV1MsgTransferLicense(value))
|
|
24568
|
+
).finish(),
|
|
24569
|
+
"/ault.license.v1.MsgUpdateParams": (value) => MsgUpdateParams4.encode(
|
|
24570
|
+
MsgUpdateParams4.fromPartial(mapAultLicenseV1MsgUpdateParams(value))
|
|
24571
|
+
).finish(),
|
|
24572
|
+
"/ault.market.v1.MsgCreateMarket": (value) => MsgCreateMarket.encode(
|
|
24573
|
+
MsgCreateMarket.fromPartial(mapAultMarketV1MsgCreateMarket(value))
|
|
24574
|
+
).finish(),
|
|
24575
|
+
"/ault.market.v1.MsgHaltAllMarkets": (value) => MsgHaltAllMarkets.encode(
|
|
24576
|
+
MsgHaltAllMarkets.fromPartial(mapAultMarketV1MsgHaltAllMarkets(value))
|
|
24577
|
+
).finish(),
|
|
24578
|
+
"/ault.market.v1.MsgHaltMarkets": (value) => MsgHaltMarkets.encode(
|
|
24579
|
+
MsgHaltMarkets.fromPartial(mapAultMarketV1MsgHaltMarkets(value))
|
|
24580
|
+
).finish(),
|
|
24581
|
+
"/ault.market.v1.MsgResumeAllMarkets": (value) => MsgResumeAllMarkets.encode(
|
|
24582
|
+
MsgResumeAllMarkets.fromPartial(mapAultMarketV1MsgResumeAllMarkets(value))
|
|
24583
|
+
).finish(),
|
|
24584
|
+
"/ault.market.v1.MsgResumeMarkets": (value) => MsgResumeMarkets.encode(
|
|
24585
|
+
MsgResumeMarkets.fromPartial(mapAultMarketV1MsgResumeMarkets(value))
|
|
24586
|
+
).finish(),
|
|
24587
|
+
"/ault.market.v1.MsgUpdateMarket": (value) => MsgUpdateMarket.encode(
|
|
24588
|
+
MsgUpdateMarket.fromPartial(mapAultMarketV1MsgUpdateMarket(value))
|
|
24589
|
+
).finish(),
|
|
24590
|
+
"/ault.market.v1.MsgUpdateMarketDeployer": (value) => MsgUpdateMarketDeployer.encode(
|
|
24591
|
+
MsgUpdateMarketDeployer.fromPartial(mapAultMarketV1MsgUpdateMarketDeployer(value))
|
|
24592
|
+
).finish(),
|
|
24593
|
+
"/ault.market.v1.MsgUpdateParams": (value) => MsgUpdateParams5.encode(
|
|
24594
|
+
MsgUpdateParams5.fromPartial(mapAultMarketV1MsgUpdateParams(value))
|
|
24595
|
+
).finish(),
|
|
24596
|
+
"/ault.miner.v1.MsgBatchSubmitWork": (value) => MsgBatchSubmitWork.encode(
|
|
24597
|
+
MsgBatchSubmitWork.fromPartial(mapAultMinerV1MsgBatchSubmitWork(value))
|
|
24598
|
+
).finish(),
|
|
24599
|
+
"/ault.miner.v1.MsgCancelMiningDelegation": (value) => MsgCancelMiningDelegation.encode(
|
|
24600
|
+
MsgCancelMiningDelegation.fromPartial(mapAultMinerV1MsgCancelMiningDelegation(value))
|
|
24601
|
+
).finish(),
|
|
24602
|
+
"/ault.miner.v1.MsgDelegateMining": (value) => MsgDelegateMining.encode(
|
|
24603
|
+
MsgDelegateMining.fromPartial(mapAultMinerV1MsgDelegateMining(value))
|
|
24604
|
+
).finish(),
|
|
24605
|
+
"/ault.miner.v1.MsgRedelegateMining": (value) => MsgRedelegateMining.encode(
|
|
24606
|
+
MsgRedelegateMining.fromPartial(mapAultMinerV1MsgRedelegateMining(value))
|
|
24607
|
+
).finish(),
|
|
24608
|
+
"/ault.miner.v1.MsgRegisterOperator": (value) => MsgRegisterOperator.encode(
|
|
24609
|
+
MsgRegisterOperator.fromPartial(mapAultMinerV1MsgRegisterOperator(value))
|
|
24610
|
+
).finish(),
|
|
24611
|
+
"/ault.miner.v1.MsgSetOwnerVrfKey": (value) => MsgSetOwnerVrfKey.encode(
|
|
24612
|
+
MsgSetOwnerVrfKey.fromPartial(mapAultMinerV1MsgSetOwnerVrfKey(value))
|
|
24613
|
+
).finish(),
|
|
24614
|
+
"/ault.miner.v1.MsgSubmitWork": (value) => MsgSubmitWork.encode(MsgSubmitWork.fromPartial(mapAultMinerV1MsgSubmitWork(value))).finish(),
|
|
24615
|
+
"/ault.miner.v1.MsgUnregisterOperator": (value) => MsgUnregisterOperator.encode(
|
|
24616
|
+
MsgUnregisterOperator.fromPartial(mapAultMinerV1MsgUnregisterOperator(value))
|
|
24617
|
+
).finish(),
|
|
24618
|
+
"/ault.miner.v1.MsgUpdateOperatorInfo": (value) => MsgUpdateOperatorInfo.encode(
|
|
24619
|
+
MsgUpdateOperatorInfo.fromPartial(mapAultMinerV1MsgUpdateOperatorInfo(value))
|
|
24620
|
+
).finish(),
|
|
24621
|
+
"/ault.miner.v1.MsgUpdateParams": (value) => MsgUpdateParams6.encode(
|
|
24622
|
+
MsgUpdateParams6.fromPartial(mapAultMinerV1MsgUpdateParams(value))
|
|
24623
|
+
).finish(),
|
|
24624
|
+
"/ault.ratelimit.v1.MsgUpdateParams": (value) => MsgUpdateParams7.encode(
|
|
24625
|
+
MsgUpdateParams7.fromPartial(mapAultRatelimitV1MsgUpdateParams(value))
|
|
24626
|
+
).finish(),
|
|
24627
|
+
"/ault.reward.v1.MsgApproveBuilder": (value) => MsgApproveBuilder.encode(
|
|
24628
|
+
MsgApproveBuilder.fromPartial(mapAultRewardV1MsgApproveBuilder(value))
|
|
24629
|
+
).finish(),
|
|
24630
|
+
"/ault.reward.v1.MsgRevokeBuilder": (value) => MsgRevokeBuilder.encode(
|
|
24631
|
+
MsgRevokeBuilder.fromPartial(mapAultRewardV1MsgRevokeBuilder(value))
|
|
24632
|
+
).finish(),
|
|
24633
|
+
"/ault.reward.v1.MsgSetDeployerShare": (value) => MsgSetDeployerShare.encode(
|
|
24634
|
+
MsgSetDeployerShare.fromPartial(mapAultRewardV1MsgSetDeployerShare(value))
|
|
24635
|
+
).finish(),
|
|
24636
|
+
"/ault.reward.v1.MsgSetReferral": (value) => MsgSetReferral.encode(
|
|
24637
|
+
MsgSetReferral.fromPartial(mapAultRewardV1MsgSetReferral(value))
|
|
24638
|
+
).finish(),
|
|
24639
|
+
"/ault.reward.v1.MsgSetReferralCode": (value) => MsgSetReferralCode.encode(
|
|
24640
|
+
MsgSetReferralCode.fromPartial(mapAultRewardV1MsgSetReferralCode(value))
|
|
24641
|
+
).finish(),
|
|
24642
|
+
"/ault.reward.v1.MsgUpdateEligibleReferrers": (value) => MsgUpdateEligibleReferrers.encode(
|
|
24643
|
+
MsgUpdateEligibleReferrers.fromPartial(mapAultRewardV1MsgUpdateEligibleReferrers(value))
|
|
24644
|
+
).finish(),
|
|
24645
|
+
"/ault.reward.v1.MsgUpdateFeeTierDiscounts": (value) => MsgUpdateFeeTierDiscounts.encode(
|
|
24646
|
+
MsgUpdateFeeTierDiscounts.fromPartial(mapAultRewardV1MsgUpdateFeeTierDiscounts(value))
|
|
24647
|
+
).finish(),
|
|
24648
|
+
"/ault.reward.v1.MsgUpdateParams": (value) => MsgUpdateParams8.encode(
|
|
24649
|
+
MsgUpdateParams8.fromPartial(mapAultRewardV1MsgUpdateParams(value))
|
|
24650
|
+
).finish(),
|
|
24651
|
+
"/ault.reward.v1.MsgUpdateRefereeDiscountRate": (value) => MsgUpdateRefereeDiscountRate.encode(
|
|
24652
|
+
MsgUpdateRefereeDiscountRate.fromPartial(mapAultRewardV1MsgUpdateRefereeDiscountRate(value))
|
|
24653
|
+
).finish(),
|
|
24654
|
+
"/ault.reward.v1.MsgUpdateTradingTierBenefits": (value) => MsgUpdateTradingTierBenefits.encode(
|
|
24655
|
+
MsgUpdateTradingTierBenefits.fromPartial(mapAultRewardV1MsgUpdateTradingTierBenefits(value))
|
|
24656
|
+
).finish(),
|
|
24657
|
+
"/ault.tokenregistry.v1.MsgDisableTokenPair": (value) => MsgDisableTokenPair.encode(
|
|
24658
|
+
MsgDisableTokenPair.fromPartial(mapAultTokenregistryV1MsgDisableTokenPair(value))
|
|
24659
|
+
).finish(),
|
|
24660
|
+
"/ault.tokenregistry.v1.MsgDisableTransfers": (value) => MsgDisableTransfers.encode(
|
|
24661
|
+
MsgDisableTransfers.fromPartial(mapAultTokenregistryV1MsgDisableTransfers(value))
|
|
24662
|
+
).finish(),
|
|
24663
|
+
"/ault.tokenregistry.v1.MsgEnableTokenPair": (value) => MsgEnableTokenPair.encode(
|
|
24664
|
+
MsgEnableTokenPair.fromPartial(mapAultTokenregistryV1MsgEnableTokenPair(value))
|
|
24665
|
+
).finish(),
|
|
24666
|
+
"/ault.tokenregistry.v1.MsgEnableTransfers": (value) => MsgEnableTransfers.encode(
|
|
24667
|
+
MsgEnableTransfers.fromPartial(mapAultTokenregistryV1MsgEnableTransfers(value))
|
|
24668
|
+
).finish(),
|
|
24669
|
+
"/ault.tokenregistry.v1.MsgRegisterTokenPair": (value) => MsgRegisterTokenPair.encode(
|
|
24670
|
+
MsgRegisterTokenPair.fromPartial(mapAultTokenregistryV1MsgRegisterTokenPair(value))
|
|
24671
|
+
).finish(),
|
|
24672
|
+
"/ault.tokenregistry.v1.MsgRemoveTransferLimit": (value) => MsgRemoveTransferLimit.encode(
|
|
24673
|
+
MsgRemoveTransferLimit.fromPartial(mapAultTokenregistryV1MsgRemoveTransferLimit(value))
|
|
24674
|
+
).finish(),
|
|
24675
|
+
"/ault.tokenregistry.v1.MsgSetTransferLimit": (value) => MsgSetTransferLimit.encode(
|
|
24676
|
+
MsgSetTransferLimit.fromPartial(mapAultTokenregistryV1MsgSetTransferLimit(value))
|
|
24677
|
+
).finish(),
|
|
24678
|
+
"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward": (value) => MsgWithdrawDelegatorReward.encode(
|
|
24679
|
+
MsgWithdrawDelegatorReward.fromPartial(
|
|
24680
|
+
mapCosmosDistributionV1beta1MsgWithdrawDelegatorReward(value)
|
|
24681
|
+
)
|
|
24682
|
+
).finish(),
|
|
24683
|
+
"/cosmos.staking.v1beta1.MsgBeginRedelegate": (value) => MsgBeginRedelegate.encode(
|
|
24684
|
+
MsgBeginRedelegate.fromPartial(mapCosmosStakingV1beta1MsgBeginRedelegate(value))
|
|
24685
|
+
).finish(),
|
|
24686
|
+
"/cosmos.staking.v1beta1.MsgDelegate": (value) => MsgDelegate.encode(MsgDelegate.fromPartial(mapCosmosStakingV1beta1MsgDelegate(value))).finish(),
|
|
24687
|
+
"/cosmos.staking.v1beta1.MsgUndelegate": (value) => MsgUndelegate.encode(
|
|
24688
|
+
MsgUndelegate.fromPartial(mapCosmosStakingV1beta1MsgUndelegate(value))
|
|
24689
|
+
).finish()
|
|
24690
|
+
};
|
|
24691
|
+
|
|
24692
|
+
// src/eip712/simulate.ts
|
|
24693
|
+
var SIMULATE_PATH = "/cosmos/tx/v1beta1/simulate";
|
|
24694
|
+
var SIMULATION_PLACEHOLDER_PUBKEY = new Uint8Array([
|
|
24695
|
+
2,
|
|
24696
|
+
121,
|
|
24697
|
+
190,
|
|
24698
|
+
102,
|
|
24699
|
+
126,
|
|
24700
|
+
249,
|
|
24701
|
+
220,
|
|
24702
|
+
187,
|
|
24703
|
+
172,
|
|
24704
|
+
85,
|
|
24705
|
+
160,
|
|
24706
|
+
98,
|
|
24707
|
+
149,
|
|
24708
|
+
206,
|
|
24709
|
+
135,
|
|
24710
|
+
11,
|
|
24711
|
+
7,
|
|
24712
|
+
2,
|
|
24713
|
+
155,
|
|
24714
|
+
252,
|
|
24715
|
+
219,
|
|
24716
|
+
45,
|
|
24717
|
+
206,
|
|
24718
|
+
40,
|
|
24719
|
+
217,
|
|
24720
|
+
89,
|
|
24721
|
+
242,
|
|
24722
|
+
129,
|
|
24723
|
+
91,
|
|
24724
|
+
22,
|
|
24725
|
+
248,
|
|
24726
|
+
23,
|
|
24727
|
+
152
|
|
24728
|
+
]);
|
|
24729
|
+
var SIMULATION_PLACEHOLDER_SIGNATURE = new Uint8Array(64);
|
|
24730
|
+
var CHAIN_VERDICT_STATUSES = /* @__PURE__ */ new Set([400, 500]);
|
|
24731
|
+
var CHAIN_VERDICT_CODES = /* @__PURE__ */ new Set([2, 3]);
|
|
24732
|
+
async function simulateTx({
|
|
24733
|
+
network,
|
|
24734
|
+
msgs,
|
|
24735
|
+
memo = "",
|
|
24736
|
+
sequence,
|
|
24737
|
+
pubkeyBase64,
|
|
24738
|
+
placeholderGasLimit,
|
|
24739
|
+
placeholderFee,
|
|
24740
|
+
fetchFn,
|
|
24741
|
+
fetchOptions
|
|
24742
|
+
}) {
|
|
24743
|
+
const encodedMessages = msgs.map((msg2) => {
|
|
24744
|
+
const encoder = MSG_ENCODERS[msg2.typeUrl];
|
|
24745
|
+
if (!encoder) {
|
|
24746
|
+
throw new Error(`No encoder found for message type: ${msg2.typeUrl}`);
|
|
24747
|
+
}
|
|
24748
|
+
return { typeUrl: msg2.typeUrl, value: encoder(msg2.value) };
|
|
24749
|
+
});
|
|
24750
|
+
const pubkeyBytes = pubkeyBase64 ? base64ToBytes(pubkeyBase64) : SIMULATION_PLACEHOLDER_PUBKEY;
|
|
24751
|
+
const txRawBytes = encodeTxRaw({
|
|
24752
|
+
bodyBytes: encodeTxBody({ messages: encodedMessages, memo }),
|
|
24753
|
+
authInfoBytes: encodeAuthInfo({
|
|
24754
|
+
signerInfos: [
|
|
24755
|
+
{
|
|
24756
|
+
publicKey: {
|
|
24757
|
+
typeUrl: "/cosmos.evm.crypto.v1.ethsecp256k1.PubKey",
|
|
24758
|
+
value: encodeEthSecp256k1PubKey(pubkeyBytes)
|
|
24759
|
+
},
|
|
24760
|
+
mode: SIGN_MODE_LEGACY_AMINO_JSON,
|
|
24761
|
+
sequence
|
|
24762
|
+
}
|
|
24763
|
+
],
|
|
24764
|
+
fee: { amount: [placeholderFee], gasLimit: BigInt(placeholderGasLimit) }
|
|
24765
|
+
}),
|
|
24766
|
+
signatures: [SIMULATION_PLACEHOLDER_SIGNATURE]
|
|
24767
|
+
});
|
|
24768
|
+
const url = `${network.restUrl}${SIMULATE_PATH}`;
|
|
24769
|
+
let response;
|
|
24770
|
+
try {
|
|
24771
|
+
response = await postJson(
|
|
24772
|
+
url,
|
|
24773
|
+
{ tx_bytes: bytesToBase64(txRawBytes) },
|
|
24774
|
+
{
|
|
24775
|
+
...fetchOptions,
|
|
24776
|
+
// 500 carries the verdict; never retry it. The rest of the caller's
|
|
24777
|
+
// policy stays.
|
|
24778
|
+
retryableStatuses: (fetchOptions?.retryableStatuses ?? DEFAULT_RETRYABLE_STATUSES).filter(
|
|
24779
|
+
(status) => status !== 500
|
|
24780
|
+
)
|
|
24781
|
+
},
|
|
24782
|
+
fetchFn
|
|
24783
|
+
);
|
|
24784
|
+
} catch (error) {
|
|
24785
|
+
const verdict = chainVerdict(error);
|
|
24786
|
+
if (verdict) {
|
|
24787
|
+
throw new TxSimulationError(verdict);
|
|
24788
|
+
}
|
|
24789
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
24790
|
+
console.warn(`[ault-sdk] tx simulation unavailable (${url}); using static gas: ${detail}`);
|
|
24791
|
+
return null;
|
|
24792
|
+
}
|
|
24793
|
+
const gasUsed = response.gas_info?.gas_used;
|
|
24794
|
+
if (typeof gasUsed !== "string" || !/^\d+$/.test(gasUsed) || gasUsed === "0") {
|
|
24795
|
+
console.warn(`[ault-sdk] tx simulation returned no usable gas_used (${url}); using static gas`);
|
|
24796
|
+
return null;
|
|
24797
|
+
}
|
|
24798
|
+
return { gasUsed: BigInt(gasUsed) };
|
|
24799
|
+
}
|
|
24800
|
+
function chainVerdict(error) {
|
|
24801
|
+
if (!(error instanceof ApiError) || typeof error.status !== "number") return null;
|
|
24802
|
+
if (!CHAIN_VERDICT_STATUSES.has(error.status) || !error.response) return null;
|
|
24803
|
+
let body;
|
|
24804
|
+
try {
|
|
24805
|
+
body = JSON.parse(error.response);
|
|
24806
|
+
} catch {
|
|
24807
|
+
return null;
|
|
24808
|
+
}
|
|
24809
|
+
if (typeof body !== "object" || body === null) return null;
|
|
24810
|
+
const { code, message } = body;
|
|
24811
|
+
if (typeof code !== "number" || !CHAIN_VERDICT_CODES.has(code)) return null;
|
|
24812
|
+
if (typeof message !== "string" || message.length === 0) return null;
|
|
24813
|
+
return { rawLog: message, chainCode: code };
|
|
24814
|
+
}
|
|
24815
|
+
|
|
24816
|
+
// src/rest/feemarket.ts
|
|
24817
|
+
async function fetchFeeMarketParams(network, fetchFn, fetchOptions) {
|
|
24818
|
+
const data = await fetchJson(
|
|
24819
|
+
`${network.restUrl}/cosmos/evm/feemarket/v1/params`,
|
|
24820
|
+
{},
|
|
24821
|
+
fetchOptions,
|
|
24822
|
+
fetchFn
|
|
24823
|
+
);
|
|
24824
|
+
const raw = data.params ?? {};
|
|
24825
|
+
return {
|
|
24826
|
+
noBaseFee: raw.noBaseFee ?? raw.no_base_fee ?? false,
|
|
24827
|
+
baseFee: raw.baseFee ?? raw.base_fee ?? "0",
|
|
24828
|
+
minGasPrice: raw.minGasPrice ?? raw.min_gas_price ?? "0"
|
|
24829
|
+
};
|
|
24830
|
+
}
|
|
24831
|
+
var ONE_E18 = 1000000000000000000n;
|
|
24832
|
+
var DEFAULT_FEE_MARGIN_PERCENT = 20;
|
|
24833
|
+
function marginFactorScaled(marginPercent) {
|
|
24834
|
+
if (!Number.isFinite(marginPercent) || !Number.isInteger(marginPercent)) {
|
|
24835
|
+
throw new Error(`marginPercent must be a non-negative integer, got ${marginPercent}`);
|
|
24836
|
+
}
|
|
24837
|
+
if (marginPercent < 0) {
|
|
24838
|
+
throw new Error(`marginPercent must be >= 0, got ${marginPercent}`);
|
|
24839
|
+
}
|
|
24840
|
+
return BigInt(100 + marginPercent);
|
|
24841
|
+
}
|
|
24842
|
+
function computeRequiredFee(params, gas, options) {
|
|
24843
|
+
const margin = marginFactorScaled(options?.marginPercent ?? DEFAULT_FEE_MARGIN_PERCENT);
|
|
24844
|
+
const minGasPriceI = BigInt(cosmosDecToProtoInt(params.minGasPrice || "0"));
|
|
24845
|
+
const baseFeeI = params.noBaseFee ? 0n : BigInt(cosmosDecToProtoInt(params.baseFee || "0"));
|
|
24846
|
+
const effectiveI = baseFeeI > minGasPriceI ? baseFeeI : minGasPriceI;
|
|
24847
|
+
if (effectiveI <= 0n) return "0";
|
|
24848
|
+
const gasI = BigInt(gas);
|
|
24849
|
+
if (gasI <= 0n) return "0";
|
|
24850
|
+
const numerator = effectiveI * gasI * margin;
|
|
24851
|
+
const denominator = ONE_E18 * 100n;
|
|
24852
|
+
return ((numerator + denominator - 1n) / denominator).toString();
|
|
24853
|
+
}
|
|
24854
|
+
var DEFAULT_FEE_MARKET_TTL_MS = 3e3;
|
|
24855
|
+
function createFeeMarketCache(ttlMs = DEFAULT_FEE_MARKET_TTL_MS) {
|
|
24856
|
+
return { ttlMs, entries: /* @__PURE__ */ new Map() };
|
|
24857
|
+
}
|
|
24858
|
+
async function getCachedFeeMarketParams(cache, network, fetchFn, fetchOptions) {
|
|
24859
|
+
const key = network.chainId;
|
|
24860
|
+
const now = Date.now();
|
|
24861
|
+
if (cache) {
|
|
24862
|
+
const existing = cache.entries.get(key);
|
|
24863
|
+
if (existing && now - existing.fetchedAt < cache.ttlMs) {
|
|
24864
|
+
return existing.params;
|
|
24865
|
+
}
|
|
24866
|
+
}
|
|
24867
|
+
let params;
|
|
24868
|
+
try {
|
|
24869
|
+
params = await fetchFeeMarketParams(network, fetchFn, fetchOptions);
|
|
24870
|
+
} catch (error) {
|
|
24871
|
+
if (!isGatewayUnsupportedError(error)) throw error;
|
|
24872
|
+
params = null;
|
|
24873
|
+
}
|
|
24874
|
+
if (cache) {
|
|
24875
|
+
cache.entries.set(key, { params, fetchedAt: now });
|
|
24876
|
+
}
|
|
24877
|
+
return params;
|
|
24878
|
+
}
|
|
24879
|
+
function isGatewayUnsupportedError(error) {
|
|
24880
|
+
return error instanceof ApiError && (error.status === 404 || error.status === 501);
|
|
24881
|
+
}
|
|
24882
|
+
function computeEvmFeesPerGas(params, options) {
|
|
24883
|
+
const margin = marginFactorScaled(options?.marginPercent ?? DEFAULT_FEE_MARGIN_PERCENT);
|
|
24884
|
+
const minGasPriceI = BigInt(cosmosDecToProtoInt(params.minGasPrice || "0"));
|
|
24885
|
+
const baseFeeI = params.noBaseFee ? 0n : BigInt(cosmosDecToProtoInt(params.baseFee || "0"));
|
|
24886
|
+
const effectiveI = baseFeeI > minGasPriceI ? baseFeeI : minGasPriceI;
|
|
24887
|
+
if (effectiveI <= 0n) {
|
|
24888
|
+
return { maxFeePerGas: 0n, maxPriorityFeePerGas: 0n };
|
|
24889
|
+
}
|
|
24890
|
+
const numerator = effectiveI * margin;
|
|
24891
|
+
const denominator = ONE_E18 * 100n;
|
|
24892
|
+
const gasPriceWei = (numerator + denominator - 1n) / denominator;
|
|
24893
|
+
return { maxFeePerGas: gasPriceWei, maxPriorityFeePerGas: gasPriceWei };
|
|
24894
|
+
}
|
|
24895
|
+
async function resolveEvmFeesPerGas(network, options) {
|
|
24896
|
+
const params = await getCachedFeeMarketParams(
|
|
24897
|
+
options?.cache,
|
|
24898
|
+
network,
|
|
24899
|
+
options?.fetchFn,
|
|
24900
|
+
options?.fetchOptions
|
|
24901
|
+
);
|
|
24902
|
+
if (!params) return null;
|
|
24903
|
+
let fees;
|
|
24904
|
+
try {
|
|
24905
|
+
fees = computeEvmFeesPerGas(params, { marginPercent: options?.marginPercent });
|
|
24906
|
+
} catch {
|
|
24907
|
+
return null;
|
|
24908
|
+
}
|
|
24909
|
+
if (fees.maxFeePerGas === 0n && fees.maxPriorityFeePerGas === 0n) return null;
|
|
24910
|
+
return fees;
|
|
24911
|
+
}
|
|
24912
|
+
|
|
24913
|
+
// src/eip712/signers.ts
|
|
24914
|
+
var import_accounts = require("viem/accounts");
|
|
24915
|
+
var AULT_SIGNER_MARKER = /* @__PURE__ */ Symbol.for("ault-sdk:signer");
|
|
24916
|
+
function isAultSigner(obj) {
|
|
24917
|
+
return typeof obj === "object" && obj !== null && AULT_SIGNER_MARKER in obj && obj[AULT_SIGNER_MARKER] === true;
|
|
24918
|
+
}
|
|
24919
|
+
function normalizeSigner(input) {
|
|
24920
|
+
if (!input) return null;
|
|
24921
|
+
if (typeof input === "function") {
|
|
24922
|
+
return { signTypedData: input };
|
|
24923
|
+
}
|
|
24924
|
+
if (typeof input === "object" && typeof input.signTypedData === "function") {
|
|
24925
|
+
return input;
|
|
24926
|
+
}
|
|
24927
|
+
throw new Error("Invalid signer: expected a signer object or signTypedData function.");
|
|
24928
|
+
}
|
|
24929
|
+
function normalizeSignature(result) {
|
|
24930
|
+
if (typeof result === "string") {
|
|
24931
|
+
return result;
|
|
24932
|
+
}
|
|
24933
|
+
if (result && typeof result.signature === "string") {
|
|
24934
|
+
return result.signature;
|
|
24935
|
+
}
|
|
24936
|
+
throw new Error("Invalid signature response: expected hex string or { signature }.");
|
|
24937
|
+
}
|
|
24938
|
+
async function getSignerAddress(signer) {
|
|
24939
|
+
if (typeof signer.address === "string") {
|
|
24940
|
+
return signer.address;
|
|
24941
|
+
}
|
|
24942
|
+
if (typeof signer.getAddress === "function") {
|
|
24943
|
+
const address = await signer.getAddress();
|
|
24944
|
+
return typeof address === "string" ? address : null;
|
|
24945
|
+
}
|
|
24946
|
+
return null;
|
|
24947
|
+
}
|
|
24948
|
+
async function resolveSignerAddress(signer, signerAddress) {
|
|
24949
|
+
const raw = signerAddress ?? (signer ? await getSignerAddress(signer) : null);
|
|
24950
|
+
if (!raw) {
|
|
24951
|
+
throw new Error("signerAddress is required when the signer has no address.");
|
|
24952
|
+
}
|
|
24953
|
+
if (isValidAultAddress(raw)) {
|
|
24954
|
+
return raw;
|
|
24955
|
+
}
|
|
24956
|
+
if (isValidEvmAddress(raw)) {
|
|
24957
|
+
return evmToAult(raw);
|
|
24958
|
+
}
|
|
24959
|
+
throw new Error(`Invalid signerAddress: ${raw}`);
|
|
24960
|
+
}
|
|
24961
|
+
function stripEip712Domain(types) {
|
|
24962
|
+
const { EIP712Domain: _removed, ...rest } = types;
|
|
24963
|
+
return rest;
|
|
24964
|
+
}
|
|
24965
|
+
function createEip1193Signer(options) {
|
|
24966
|
+
const method = options.method ?? "eth_signTypedData_v4";
|
|
24967
|
+
return {
|
|
24968
|
+
[AULT_SIGNER_MARKER]: true,
|
|
24969
|
+
address: options.address,
|
|
24970
|
+
signTypedData: async (typedData) => {
|
|
24971
|
+
const payload = method === "eth_signTypedData_v4" ? JSON.stringify(typedData) : typedData;
|
|
24972
|
+
const signature = await options.provider.request({
|
|
24973
|
+
method,
|
|
24974
|
+
params: [options.address, payload]
|
|
24975
|
+
});
|
|
24976
|
+
if (typeof signature !== "string") {
|
|
24977
|
+
throw new Error("Provider did not return a signature string.");
|
|
24978
|
+
}
|
|
24979
|
+
return { signature };
|
|
24980
|
+
}
|
|
24981
|
+
};
|
|
24982
|
+
}
|
|
24983
|
+
function createViemSigner(wallet, options) {
|
|
24984
|
+
const preferRpc = options?.preferRpc ?? true;
|
|
24985
|
+
const getAddress3 = async () => {
|
|
24986
|
+
if (wallet.address) return wallet.address;
|
|
24987
|
+
if (wallet.getAddresses) {
|
|
24988
|
+
const addresses = await wallet.getAddresses();
|
|
24989
|
+
if (addresses?.length) return addresses[0];
|
|
24990
|
+
}
|
|
24991
|
+
return void 0;
|
|
24992
|
+
};
|
|
24993
|
+
return {
|
|
24994
|
+
[AULT_SIGNER_MARKER]: true,
|
|
24995
|
+
getAddress: async () => {
|
|
24996
|
+
const addr = await getAddress3();
|
|
24997
|
+
if (!addr) throw new Error("Viem wallet has no address");
|
|
24998
|
+
return addr;
|
|
24999
|
+
},
|
|
25000
|
+
signTypedData: async (typedData) => {
|
|
25001
|
+
if (preferRpc && wallet.request) {
|
|
25002
|
+
const address = await getAddress3();
|
|
25003
|
+
if (!address) {
|
|
25004
|
+
throw new Error("Viem wallet has no address; pass signerAddress explicitly.");
|
|
25005
|
+
}
|
|
25006
|
+
const signature2 = await wallet.request({
|
|
25007
|
+
method: "eth_signTypedData_v4",
|
|
25008
|
+
params: [address, JSON.stringify(typedData)]
|
|
25009
|
+
});
|
|
25010
|
+
if (typeof signature2 !== "string") {
|
|
25011
|
+
throw new Error("RPC signer did not return a signature string.");
|
|
25012
|
+
}
|
|
25013
|
+
return { signature: signature2 };
|
|
25014
|
+
}
|
|
25015
|
+
if (!wallet.signTypedData) {
|
|
25016
|
+
throw new Error("Viem signer does not support signTypedData.");
|
|
25017
|
+
}
|
|
25018
|
+
const signature = await wallet.signTypedData({
|
|
25019
|
+
domain: typedData.domain,
|
|
25020
|
+
types: typedData.types,
|
|
25021
|
+
primaryType: typedData.primaryType,
|
|
25022
|
+
message: typedData.message
|
|
25023
|
+
});
|
|
25024
|
+
return { signature };
|
|
25025
|
+
}
|
|
25026
|
+
};
|
|
25027
|
+
}
|
|
25028
|
+
function createEthersSigner(signer) {
|
|
25029
|
+
const sign = signer.signTypedData ?? signer._signTypedData;
|
|
25030
|
+
if (!sign) {
|
|
25031
|
+
throw new Error("Ethers signer must implement signTypedData or _signTypedData.");
|
|
25032
|
+
}
|
|
24661
25033
|
return {
|
|
24662
|
-
|
|
24663
|
-
|
|
24664
|
-
|
|
25034
|
+
[AULT_SIGNER_MARKER]: true,
|
|
25035
|
+
getAddress: () => signer.getAddress(),
|
|
25036
|
+
signTypedData: async (typedData) => {
|
|
25037
|
+
const types = stripEip712Domain(typedData.types);
|
|
25038
|
+
const signature = await sign(typedData.domain, types, typedData.message);
|
|
25039
|
+
return { signature };
|
|
25040
|
+
}
|
|
24665
25041
|
};
|
|
24666
25042
|
}
|
|
24667
|
-
function
|
|
24668
|
-
const record2 = asRecord(input);
|
|
24669
|
-
const prefix = label ? `${label}.` : "";
|
|
25043
|
+
function createPrivySigner(options) {
|
|
24670
25044
|
return {
|
|
24671
|
-
|
|
24672
|
-
|
|
25045
|
+
[AULT_SIGNER_MARKER]: true,
|
|
25046
|
+
address: options.address,
|
|
25047
|
+
signTypedData: (typedData) => options.signTypedData(typedData, options.address ? { address: options.address } : void 0)
|
|
24673
25048
|
};
|
|
24674
25049
|
}
|
|
24675
|
-
|
|
24676
|
-
|
|
24677
|
-
|
|
24678
|
-
|
|
24679
|
-
|
|
24680
|
-
|
|
24681
|
-
|
|
24682
|
-
|
|
24683
|
-
|
|
24684
|
-
).
|
|
24685
|
-
|
|
24686
|
-
|
|
24687
|
-
).finish(),
|
|
24688
|
-
"/ault.agent.v1.MsgApproveAgent": (value) => MsgApproveAgent.encode(
|
|
24689
|
-
MsgApproveAgent.fromPartial(mapAultAgentV1MsgApproveAgent(value))
|
|
24690
|
-
).finish(),
|
|
24691
|
-
"/ault.agent.v1.MsgRevokeAgent": (value) => MsgRevokeAgent.encode(MsgRevokeAgent.fromPartial(mapAultAgentV1MsgRevokeAgent(value))).finish(),
|
|
24692
|
-
"/ault.agent.v1.MsgUpdateParams": (value) => MsgUpdateParams2.encode(
|
|
24693
|
-
MsgUpdateParams2.fromPartial(mapAultAgentV1MsgUpdateParams(value))
|
|
24694
|
-
).finish(),
|
|
24695
|
-
"/ault.authority.v1.MsgGrantRole": (value) => MsgGrantRole.encode(MsgGrantRole.fromPartial(mapAultAuthorityV1MsgGrantRole(value))).finish(),
|
|
24696
|
-
"/ault.authority.v1.MsgRevokeRole": (value) => MsgRevokeRole.encode(
|
|
24697
|
-
MsgRevokeRole.fromPartial(mapAultAuthorityV1MsgRevokeRole(value))
|
|
24698
|
-
).finish(),
|
|
24699
|
-
"/ault.clob.v1.MsgCancelOrders": (value) => MsgCancelOrders.encode(
|
|
24700
|
-
MsgCancelOrders.fromPartial(mapAultClobV1MsgCancelOrders(value))
|
|
24701
|
-
).finish(),
|
|
24702
|
-
"/ault.clob.v1.MsgModifyOrders": (value) => MsgModifyOrders.encode(
|
|
24703
|
-
MsgModifyOrders.fromPartial(mapAultClobV1MsgModifyOrders(value))
|
|
24704
|
-
).finish(),
|
|
24705
|
-
"/ault.clob.v1.MsgPlaceLimitOrder": (value) => MsgPlaceLimitOrder.encode(
|
|
24706
|
-
MsgPlaceLimitOrder.fromPartial(mapAultClobV1MsgPlaceLimitOrder(value))
|
|
24707
|
-
).finish(),
|
|
24708
|
-
"/ault.clob.v1.MsgPlaceMarketOrder": (value) => MsgPlaceMarketOrder.encode(
|
|
24709
|
-
MsgPlaceMarketOrder.fromPartial(mapAultClobV1MsgPlaceMarketOrder(value))
|
|
24710
|
-
).finish(),
|
|
24711
|
-
"/ault.clob.v1.MsgPlaceScaleOrder": (value) => MsgPlaceScaleOrder.encode(
|
|
24712
|
-
MsgPlaceScaleOrder.fromPartial(mapAultClobV1MsgPlaceScaleOrder(value))
|
|
24713
|
-
).finish(),
|
|
24714
|
-
"/ault.clob.v1.MsgPlaceTwapOrder": (value) => MsgPlaceTwapOrder.encode(
|
|
24715
|
-
MsgPlaceTwapOrder.fromPartial(mapAultClobV1MsgPlaceTwapOrder(value))
|
|
24716
|
-
).finish(),
|
|
24717
|
-
"/ault.clob.v1.MsgUpdateParams": (value) => MsgUpdateParams3.encode(
|
|
24718
|
-
MsgUpdateParams3.fromPartial(mapAultClobV1MsgUpdateParams(value))
|
|
24719
|
-
).finish(),
|
|
24720
|
-
"/ault.license.v1.MsgApproveMember": (value) => MsgApproveMember.encode(
|
|
24721
|
-
MsgApproveMember.fromPartial(mapAultLicenseV1MsgApproveMember(value))
|
|
24722
|
-
).finish(),
|
|
24723
|
-
"/ault.license.v1.MsgBatchApproveMember": (value) => MsgBatchApproveMember.encode(
|
|
24724
|
-
MsgBatchApproveMember.fromPartial(mapAultLicenseV1MsgBatchApproveMember(value))
|
|
24725
|
-
).finish(),
|
|
24726
|
-
"/ault.license.v1.MsgBatchMintLicense": (value) => MsgBatchMintLicense.encode(
|
|
24727
|
-
MsgBatchMintLicense.fromPartial(mapAultLicenseV1MsgBatchMintLicense(value))
|
|
24728
|
-
).finish(),
|
|
24729
|
-
"/ault.license.v1.MsgBatchRevokeMember": (value) => MsgBatchRevokeMember.encode(
|
|
24730
|
-
MsgBatchRevokeMember.fromPartial(mapAultLicenseV1MsgBatchRevokeMember(value))
|
|
24731
|
-
).finish(),
|
|
24732
|
-
"/ault.license.v1.MsgBurnLicense": (value) => MsgBurnLicense.encode(
|
|
24733
|
-
MsgBurnLicense.fromPartial(mapAultLicenseV1MsgBurnLicense(value))
|
|
24734
|
-
).finish(),
|
|
24735
|
-
"/ault.license.v1.MsgMintLicense": (value) => MsgMintLicense.encode(
|
|
24736
|
-
MsgMintLicense.fromPartial(mapAultLicenseV1MsgMintLicense(value))
|
|
24737
|
-
).finish(),
|
|
24738
|
-
"/ault.license.v1.MsgRevokeLicense": (value) => MsgRevokeLicense.encode(
|
|
24739
|
-
MsgRevokeLicense.fromPartial(mapAultLicenseV1MsgRevokeLicense(value))
|
|
24740
|
-
).finish(),
|
|
24741
|
-
"/ault.license.v1.MsgRevokeMember": (value) => MsgRevokeMember.encode(
|
|
24742
|
-
MsgRevokeMember.fromPartial(mapAultLicenseV1MsgRevokeMember(value))
|
|
24743
|
-
).finish(),
|
|
24744
|
-
"/ault.license.v1.MsgSetKYCApprovers": (value) => MsgSetKYCApprovers.encode(
|
|
24745
|
-
MsgSetKYCApprovers.fromPartial(mapAultLicenseV1MsgSetKYCApprovers(value))
|
|
24746
|
-
).finish(),
|
|
24747
|
-
"/ault.license.v1.MsgSetMinters": (value) => MsgSetMinters.encode(MsgSetMinters.fromPartial(mapAultLicenseV1MsgSetMinters(value))).finish(),
|
|
24748
|
-
"/ault.license.v1.MsgSetTokenURI": (value) => MsgSetTokenURI.encode(
|
|
24749
|
-
MsgSetTokenURI.fromPartial(mapAultLicenseV1MsgSetTokenURI(value))
|
|
24750
|
-
).finish(),
|
|
24751
|
-
"/ault.license.v1.MsgTransferLicense": (value) => MsgTransferLicense.encode(
|
|
24752
|
-
MsgTransferLicense.fromPartial(mapAultLicenseV1MsgTransferLicense(value))
|
|
24753
|
-
).finish(),
|
|
24754
|
-
"/ault.license.v1.MsgUpdateParams": (value) => MsgUpdateParams4.encode(
|
|
24755
|
-
MsgUpdateParams4.fromPartial(mapAultLicenseV1MsgUpdateParams(value))
|
|
24756
|
-
).finish(),
|
|
24757
|
-
"/ault.market.v1.MsgCreateMarket": (value) => MsgCreateMarket.encode(
|
|
24758
|
-
MsgCreateMarket.fromPartial(mapAultMarketV1MsgCreateMarket(value))
|
|
24759
|
-
).finish(),
|
|
24760
|
-
"/ault.market.v1.MsgHaltAllMarkets": (value) => MsgHaltAllMarkets.encode(
|
|
24761
|
-
MsgHaltAllMarkets.fromPartial(mapAultMarketV1MsgHaltAllMarkets(value))
|
|
24762
|
-
).finish(),
|
|
24763
|
-
"/ault.market.v1.MsgHaltMarkets": (value) => MsgHaltMarkets.encode(
|
|
24764
|
-
MsgHaltMarkets.fromPartial(mapAultMarketV1MsgHaltMarkets(value))
|
|
24765
|
-
).finish(),
|
|
24766
|
-
"/ault.market.v1.MsgResumeAllMarkets": (value) => MsgResumeAllMarkets.encode(
|
|
24767
|
-
MsgResumeAllMarkets.fromPartial(mapAultMarketV1MsgResumeAllMarkets(value))
|
|
24768
|
-
).finish(),
|
|
24769
|
-
"/ault.market.v1.MsgResumeMarkets": (value) => MsgResumeMarkets.encode(
|
|
24770
|
-
MsgResumeMarkets.fromPartial(mapAultMarketV1MsgResumeMarkets(value))
|
|
24771
|
-
).finish(),
|
|
24772
|
-
"/ault.market.v1.MsgUpdateMarket": (value) => MsgUpdateMarket.encode(
|
|
24773
|
-
MsgUpdateMarket.fromPartial(mapAultMarketV1MsgUpdateMarket(value))
|
|
24774
|
-
).finish(),
|
|
24775
|
-
"/ault.market.v1.MsgUpdateMarketDeployer": (value) => MsgUpdateMarketDeployer.encode(
|
|
24776
|
-
MsgUpdateMarketDeployer.fromPartial(mapAultMarketV1MsgUpdateMarketDeployer(value))
|
|
24777
|
-
).finish(),
|
|
24778
|
-
"/ault.market.v1.MsgUpdateParams": (value) => MsgUpdateParams5.encode(
|
|
24779
|
-
MsgUpdateParams5.fromPartial(mapAultMarketV1MsgUpdateParams(value))
|
|
24780
|
-
).finish(),
|
|
24781
|
-
"/ault.miner.v1.MsgBatchSubmitWork": (value) => MsgBatchSubmitWork.encode(
|
|
24782
|
-
MsgBatchSubmitWork.fromPartial(mapAultMinerV1MsgBatchSubmitWork(value))
|
|
24783
|
-
).finish(),
|
|
24784
|
-
"/ault.miner.v1.MsgCancelMiningDelegation": (value) => MsgCancelMiningDelegation.encode(
|
|
24785
|
-
MsgCancelMiningDelegation.fromPartial(mapAultMinerV1MsgCancelMiningDelegation(value))
|
|
24786
|
-
).finish(),
|
|
24787
|
-
"/ault.miner.v1.MsgDelegateMining": (value) => MsgDelegateMining.encode(
|
|
24788
|
-
MsgDelegateMining.fromPartial(mapAultMinerV1MsgDelegateMining(value))
|
|
24789
|
-
).finish(),
|
|
24790
|
-
"/ault.miner.v1.MsgRedelegateMining": (value) => MsgRedelegateMining.encode(
|
|
24791
|
-
MsgRedelegateMining.fromPartial(mapAultMinerV1MsgRedelegateMining(value))
|
|
24792
|
-
).finish(),
|
|
24793
|
-
"/ault.miner.v1.MsgRegisterOperator": (value) => MsgRegisterOperator.encode(
|
|
24794
|
-
MsgRegisterOperator.fromPartial(mapAultMinerV1MsgRegisterOperator(value))
|
|
24795
|
-
).finish(),
|
|
24796
|
-
"/ault.miner.v1.MsgSetOwnerVrfKey": (value) => MsgSetOwnerVrfKey.encode(
|
|
24797
|
-
MsgSetOwnerVrfKey.fromPartial(mapAultMinerV1MsgSetOwnerVrfKey(value))
|
|
24798
|
-
).finish(),
|
|
24799
|
-
"/ault.miner.v1.MsgSubmitWork": (value) => MsgSubmitWork.encode(MsgSubmitWork.fromPartial(mapAultMinerV1MsgSubmitWork(value))).finish(),
|
|
24800
|
-
"/ault.miner.v1.MsgUnregisterOperator": (value) => MsgUnregisterOperator.encode(
|
|
24801
|
-
MsgUnregisterOperator.fromPartial(mapAultMinerV1MsgUnregisterOperator(value))
|
|
24802
|
-
).finish(),
|
|
24803
|
-
"/ault.miner.v1.MsgUpdateOperatorInfo": (value) => MsgUpdateOperatorInfo.encode(
|
|
24804
|
-
MsgUpdateOperatorInfo.fromPartial(mapAultMinerV1MsgUpdateOperatorInfo(value))
|
|
24805
|
-
).finish(),
|
|
24806
|
-
"/ault.miner.v1.MsgUpdateParams": (value) => MsgUpdateParams6.encode(
|
|
24807
|
-
MsgUpdateParams6.fromPartial(mapAultMinerV1MsgUpdateParams(value))
|
|
24808
|
-
).finish(),
|
|
24809
|
-
"/ault.ratelimit.v1.MsgUpdateParams": (value) => MsgUpdateParams7.encode(
|
|
24810
|
-
MsgUpdateParams7.fromPartial(mapAultRatelimitV1MsgUpdateParams(value))
|
|
24811
|
-
).finish(),
|
|
24812
|
-
"/ault.reward.v1.MsgApproveBuilder": (value) => MsgApproveBuilder.encode(
|
|
24813
|
-
MsgApproveBuilder.fromPartial(mapAultRewardV1MsgApproveBuilder(value))
|
|
24814
|
-
).finish(),
|
|
24815
|
-
"/ault.reward.v1.MsgRevokeBuilder": (value) => MsgRevokeBuilder.encode(
|
|
24816
|
-
MsgRevokeBuilder.fromPartial(mapAultRewardV1MsgRevokeBuilder(value))
|
|
24817
|
-
).finish(),
|
|
24818
|
-
"/ault.reward.v1.MsgSetDeployerShare": (value) => MsgSetDeployerShare.encode(
|
|
24819
|
-
MsgSetDeployerShare.fromPartial(mapAultRewardV1MsgSetDeployerShare(value))
|
|
24820
|
-
).finish(),
|
|
24821
|
-
"/ault.reward.v1.MsgSetReferral": (value) => MsgSetReferral.encode(
|
|
24822
|
-
MsgSetReferral.fromPartial(mapAultRewardV1MsgSetReferral(value))
|
|
24823
|
-
).finish(),
|
|
24824
|
-
"/ault.reward.v1.MsgSetReferralCode": (value) => MsgSetReferralCode.encode(
|
|
24825
|
-
MsgSetReferralCode.fromPartial(mapAultRewardV1MsgSetReferralCode(value))
|
|
24826
|
-
).finish(),
|
|
24827
|
-
"/ault.reward.v1.MsgUpdateEligibleReferrers": (value) => MsgUpdateEligibleReferrers.encode(
|
|
24828
|
-
MsgUpdateEligibleReferrers.fromPartial(mapAultRewardV1MsgUpdateEligibleReferrers(value))
|
|
24829
|
-
).finish(),
|
|
24830
|
-
"/ault.reward.v1.MsgUpdateFeeTierDiscounts": (value) => MsgUpdateFeeTierDiscounts.encode(
|
|
24831
|
-
MsgUpdateFeeTierDiscounts.fromPartial(mapAultRewardV1MsgUpdateFeeTierDiscounts(value))
|
|
24832
|
-
).finish(),
|
|
24833
|
-
"/ault.reward.v1.MsgUpdateParams": (value) => MsgUpdateParams8.encode(
|
|
24834
|
-
MsgUpdateParams8.fromPartial(mapAultRewardV1MsgUpdateParams(value))
|
|
24835
|
-
).finish(),
|
|
24836
|
-
"/ault.reward.v1.MsgUpdateRefereeDiscountRate": (value) => MsgUpdateRefereeDiscountRate.encode(
|
|
24837
|
-
MsgUpdateRefereeDiscountRate.fromPartial(mapAultRewardV1MsgUpdateRefereeDiscountRate(value))
|
|
24838
|
-
).finish(),
|
|
24839
|
-
"/ault.reward.v1.MsgUpdateTradingTierBenefits": (value) => MsgUpdateTradingTierBenefits.encode(
|
|
24840
|
-
MsgUpdateTradingTierBenefits.fromPartial(mapAultRewardV1MsgUpdateTradingTierBenefits(value))
|
|
24841
|
-
).finish(),
|
|
24842
|
-
"/ault.tokenregistry.v1.MsgDisableTokenPair": (value) => MsgDisableTokenPair.encode(
|
|
24843
|
-
MsgDisableTokenPair.fromPartial(mapAultTokenregistryV1MsgDisableTokenPair(value))
|
|
24844
|
-
).finish(),
|
|
24845
|
-
"/ault.tokenregistry.v1.MsgDisableTransfers": (value) => MsgDisableTransfers.encode(
|
|
24846
|
-
MsgDisableTransfers.fromPartial(mapAultTokenregistryV1MsgDisableTransfers(value))
|
|
24847
|
-
).finish(),
|
|
24848
|
-
"/ault.tokenregistry.v1.MsgEnableTokenPair": (value) => MsgEnableTokenPair.encode(
|
|
24849
|
-
MsgEnableTokenPair.fromPartial(mapAultTokenregistryV1MsgEnableTokenPair(value))
|
|
24850
|
-
).finish(),
|
|
24851
|
-
"/ault.tokenregistry.v1.MsgEnableTransfers": (value) => MsgEnableTransfers.encode(
|
|
24852
|
-
MsgEnableTransfers.fromPartial(mapAultTokenregistryV1MsgEnableTransfers(value))
|
|
24853
|
-
).finish(),
|
|
24854
|
-
"/ault.tokenregistry.v1.MsgRegisterTokenPair": (value) => MsgRegisterTokenPair.encode(
|
|
24855
|
-
MsgRegisterTokenPair.fromPartial(mapAultTokenregistryV1MsgRegisterTokenPair(value))
|
|
24856
|
-
).finish(),
|
|
24857
|
-
"/ault.tokenregistry.v1.MsgRemoveTransferLimit": (value) => MsgRemoveTransferLimit.encode(
|
|
24858
|
-
MsgRemoveTransferLimit.fromPartial(mapAultTokenregistryV1MsgRemoveTransferLimit(value))
|
|
24859
|
-
).finish(),
|
|
24860
|
-
"/ault.tokenregistry.v1.MsgSetTransferLimit": (value) => MsgSetTransferLimit.encode(
|
|
24861
|
-
MsgSetTransferLimit.fromPartial(mapAultTokenregistryV1MsgSetTransferLimit(value))
|
|
24862
|
-
).finish(),
|
|
24863
|
-
"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward": (value) => MsgWithdrawDelegatorReward.encode(
|
|
24864
|
-
MsgWithdrawDelegatorReward.fromPartial(
|
|
24865
|
-
mapCosmosDistributionV1beta1MsgWithdrawDelegatorReward(value)
|
|
24866
|
-
)
|
|
24867
|
-
).finish(),
|
|
24868
|
-
"/cosmos.staking.v1beta1.MsgBeginRedelegate": (value) => MsgBeginRedelegate.encode(
|
|
24869
|
-
MsgBeginRedelegate.fromPartial(mapCosmosStakingV1beta1MsgBeginRedelegate(value))
|
|
24870
|
-
).finish(),
|
|
24871
|
-
"/cosmos.staking.v1beta1.MsgDelegate": (value) => MsgDelegate.encode(MsgDelegate.fromPartial(mapCosmosStakingV1beta1MsgDelegate(value))).finish(),
|
|
24872
|
-
"/cosmos.staking.v1beta1.MsgUndelegate": (value) => MsgUndelegate.encode(
|
|
24873
|
-
MsgUndelegate.fromPartial(mapCosmosStakingV1beta1MsgUndelegate(value))
|
|
24874
|
-
).finish()
|
|
24875
|
-
};
|
|
25050
|
+
function createPrivateKeySigner(privateKey) {
|
|
25051
|
+
const normalized = privateKey.startsWith("0x") ? privateKey : `0x${privateKey}`;
|
|
25052
|
+
const account = (0, import_accounts.privateKeyToAccount)(normalized);
|
|
25053
|
+
return createViemSigner(account);
|
|
25054
|
+
}
|
|
25055
|
+
|
|
25056
|
+
// src/utils/tx-hash.ts
|
|
25057
|
+
function normalizeTxHash(raw) {
|
|
25058
|
+
if (!raw) return raw;
|
|
25059
|
+
const stripped = raw.startsWith("0x") || raw.startsWith("0X") ? raw.slice(2) : raw;
|
|
25060
|
+
return stripped.toLowerCase();
|
|
25061
|
+
}
|
|
24876
25062
|
|
|
24877
25063
|
// src/eip712/sign-and-broadcast.ts
|
|
24878
25064
|
async function queryAccount(network, address, fetchFn, fetchOptions) {
|
|
@@ -24931,6 +25117,9 @@ function createAccountCache() {
|
|
|
24931
25117
|
function getNextSequence(sequence) {
|
|
24932
25118
|
return String(BigInt(sequence) + 1n);
|
|
24933
25119
|
}
|
|
25120
|
+
function isSequenceMismatch(rawLog) {
|
|
25121
|
+
return rawLog.includes("account sequence mismatch") || rawLog.includes("incorrect account sequence");
|
|
25122
|
+
}
|
|
24934
25123
|
function clearCachedSequence(cache) {
|
|
24935
25124
|
if (cache) {
|
|
24936
25125
|
cache.nextSequence = null;
|
|
@@ -25033,6 +25222,8 @@ async function signAndBroadcastEip712({
|
|
|
25033
25222
|
feeDenom,
|
|
25034
25223
|
feeAmount,
|
|
25035
25224
|
confirmationTimeoutMs,
|
|
25225
|
+
simulateGas = false,
|
|
25226
|
+
simulatedGasMultiplier,
|
|
25036
25227
|
wait = true,
|
|
25037
25228
|
fetchFn,
|
|
25038
25229
|
fetchOptions,
|
|
@@ -25059,15 +25250,46 @@ async function signAndBroadcastEip712({
|
|
|
25059
25250
|
if (!sequence) {
|
|
25060
25251
|
throw new Error(`Unable to resolve account sequence for signer ${resolvedSignerAddress}.`);
|
|
25061
25252
|
}
|
|
25062
|
-
|
|
25063
|
-
const
|
|
25253
|
+
let resolvedGas = gasLimit ?? network.eip712GasLimit ?? GAS_CONSTANTS.EIP712_GAS_LIMIT;
|
|
25254
|
+
const resolvedFeeDenom = feeDenom ?? network.eip712FeeDenom ?? GAS_CONSTANTS.DENOM;
|
|
25255
|
+
const feeOverride = feeAmount ?? network.eip712FeeAmount;
|
|
25256
|
+
const feeFor = async (gas) => feeOverride ?? await resolveDynamicFeeAmount(network, gas, feeMarketCache, fetchFn, fetchOptions);
|
|
25257
|
+
let resolvedFeeAmount;
|
|
25258
|
+
if (simulateGas) {
|
|
25259
|
+
let simulated;
|
|
25260
|
+
try {
|
|
25261
|
+
simulated = await simulateTx({
|
|
25262
|
+
network,
|
|
25263
|
+
msgs,
|
|
25264
|
+
memo,
|
|
25265
|
+
sequence,
|
|
25266
|
+
pubkeyBase64: cache?.pubkeyBase64 ?? accountInfo?.pubkeyBase64 ?? null,
|
|
25267
|
+
placeholderGasLimit: resolvedGas,
|
|
25268
|
+
placeholderFee: { denom: resolvedFeeDenom, amount: await feeFor(resolvedGas) },
|
|
25269
|
+
fetchFn,
|
|
25270
|
+
fetchOptions
|
|
25271
|
+
});
|
|
25272
|
+
} catch (error) {
|
|
25273
|
+
if (error instanceof TxSimulationError && isSequenceMismatch(error.rawLog)) {
|
|
25274
|
+
clearCachedSequence(cache);
|
|
25275
|
+
}
|
|
25276
|
+
throw error;
|
|
25277
|
+
}
|
|
25278
|
+
if (simulated) {
|
|
25279
|
+
resolvedGas = computeSimulatedGas(
|
|
25280
|
+
simulated.gasUsed,
|
|
25281
|
+
simulatedGasMultiplier ?? GAS_CONSTANTS.SIMULATED_GAS_MULTIPLIER
|
|
25282
|
+
);
|
|
25283
|
+
}
|
|
25284
|
+
}
|
|
25285
|
+
resolvedFeeAmount = await feeFor(resolvedGas);
|
|
25064
25286
|
const context = {
|
|
25065
25287
|
chainId: network.chainId,
|
|
25066
25288
|
accountNumber,
|
|
25067
25289
|
sequence,
|
|
25068
25290
|
fee: {
|
|
25069
25291
|
amount: resolvedFeeAmount,
|
|
25070
|
-
denom:
|
|
25292
|
+
denom: resolvedFeeDenom,
|
|
25071
25293
|
gas: resolvedGas
|
|
25072
25294
|
},
|
|
25073
25295
|
memo
|
|
@@ -26732,6 +26954,13 @@ function createRewardTxApi({ signerAddress, exec, getGas }) {
|
|
|
26732
26954
|
}
|
|
26733
26955
|
|
|
26734
26956
|
// src/high-level/tx/staking.ts
|
|
26957
|
+
function stakingGasOptions(gas, fallbackMinGas, gasLimit) {
|
|
26958
|
+
return {
|
|
26959
|
+
gasLimit: gasLimit ?? computeFeeFreeGas(fallbackMinGas, 1, gas.FEE_FREE_GAS_MULTIPLIER),
|
|
26960
|
+
simulateGas: gasLimit == null,
|
|
26961
|
+
simulatedGasMultiplier: gas.SIMULATED_GAS_MULTIPLIER
|
|
26962
|
+
};
|
|
26963
|
+
}
|
|
26735
26964
|
function createStakingTxApi({ signerAddress, exec, getGas }) {
|
|
26736
26965
|
return {
|
|
26737
26966
|
async delegate({ validatorAddress, amount, gasLimit, feeAmount, memo, confirmationTimeoutMs }) {
|
|
@@ -26745,7 +26974,7 @@ function createStakingTxApi({ signerAddress, exec, getGas }) {
|
|
|
26745
26974
|
})
|
|
26746
26975
|
],
|
|
26747
26976
|
{
|
|
26748
|
-
|
|
26977
|
+
...stakingGasOptions(gas, gas.DELEGATE, gasLimit),
|
|
26749
26978
|
feeAmount,
|
|
26750
26979
|
memo,
|
|
26751
26980
|
confirmationTimeoutMs
|
|
@@ -26770,7 +26999,7 @@ function createStakingTxApi({ signerAddress, exec, getGas }) {
|
|
|
26770
26999
|
})
|
|
26771
27000
|
],
|
|
26772
27001
|
{
|
|
26773
|
-
|
|
27002
|
+
...stakingGasOptions(gas, gas.UNDELEGATE, gasLimit),
|
|
26774
27003
|
feeAmount,
|
|
26775
27004
|
memo,
|
|
26776
27005
|
confirmationTimeoutMs
|
|
@@ -26797,7 +27026,7 @@ function createStakingTxApi({ signerAddress, exec, getGas }) {
|
|
|
26797
27026
|
})
|
|
26798
27027
|
],
|
|
26799
27028
|
{
|
|
26800
|
-
|
|
27029
|
+
...stakingGasOptions(gas, gas.BEGIN_REDELEGATE, gasLimit),
|
|
26801
27030
|
feeAmount,
|
|
26802
27031
|
memo,
|
|
26803
27032
|
confirmationTimeoutMs
|
|
@@ -26816,7 +27045,7 @@ function createStakingTxApi({ signerAddress, exec, getGas }) {
|
|
|
26816
27045
|
}
|
|
26817
27046
|
const normalized = validatorAddresses.map(assertValidatorAddress);
|
|
26818
27047
|
const gas = getGas();
|
|
26819
|
-
const
|
|
27048
|
+
const gasOptions = stakingGasOptions(gas, gas.WITHDRAW_DELEGATOR_REWARD, gasLimit);
|
|
26820
27049
|
const results = [];
|
|
26821
27050
|
const partial = [];
|
|
26822
27051
|
for (let i = 0; i < normalized.length; i++) {
|
|
@@ -26829,7 +27058,7 @@ function createStakingTxApi({ signerAddress, exec, getGas }) {
|
|
|
26829
27058
|
validatorAddress
|
|
26830
27059
|
})
|
|
26831
27060
|
],
|
|
26832
|
-
{
|
|
27061
|
+
{ ...gasOptions, feeAmount, memo, confirmationTimeoutMs }
|
|
26833
27062
|
);
|
|
26834
27063
|
results.push(result);
|
|
26835
27064
|
partial.push({ txHash: result.txHash, validatorAddress });
|
|
@@ -27018,6 +27247,8 @@ function createTxExecutor(options) {
|
|
|
27018
27247
|
feeAmount: txOptions?.feeAmount,
|
|
27019
27248
|
memo: txOptions?.memo ?? defaultMemo,
|
|
27020
27249
|
confirmationTimeoutMs: txOptions?.confirmationTimeoutMs ?? defaultConfirmationTimeoutMs,
|
|
27250
|
+
simulateGas: txOptions?.simulateGas ?? false,
|
|
27251
|
+
simulatedGasMultiplier: txOptions?.simulatedGasMultiplier,
|
|
27021
27252
|
wait: txOptions?.wait ?? true,
|
|
27022
27253
|
fetchFn: options.fetchFn,
|
|
27023
27254
|
fetchOptions,
|
|
@@ -27040,6 +27271,8 @@ function createTxExecutor(options) {
|
|
|
27040
27271
|
var import_zod = require("zod");
|
|
27041
27272
|
var ManifestGasSchema = import_zod.z.object({
|
|
27042
27273
|
FEE_FREE_GAS_MULTIPLIER: import_zod.z.number().int().positive(),
|
|
27274
|
+
// Under 100% signs less gas than the simulation already burned.
|
|
27275
|
+
SIMULATED_GAS_MULTIPLIER: import_zod.z.number().int().min(100),
|
|
27043
27276
|
PER_LICENSE: import_zod.z.number().int().positive(),
|
|
27044
27277
|
PER_KYC_MEMBER: import_zod.z.number().int().positive(),
|
|
27045
27278
|
PER_DELEGATE_MINING: import_zod.z.number().int().positive(),
|
|
@@ -28745,9 +28978,6 @@ var GetUDFTimescaleMarksResponse = zod.array(GetUDFTimescaleMarksResponseItem);
|
|
|
28745
28978
|
function createDexWs(url, options) {
|
|
28746
28979
|
return new DexWsClient(url, options);
|
|
28747
28980
|
}
|
|
28748
|
-
|
|
28749
|
-
// src/index.ts
|
|
28750
|
-
var SDK_VERSION = "0.7.0";
|
|
28751
28981
|
// Annotate the CommonJS export names for ESM import in node:
|
|
28752
28982
|
0 && (module.exports = {
|
|
28753
28983
|
AGENT_DEFAULTS,
|
|
@@ -28758,6 +28988,7 @@ var SDK_VERSION = "0.7.0";
|
|
|
28758
28988
|
BondStatus,
|
|
28759
28989
|
COIN_TYPE,
|
|
28760
28990
|
DEFAULT_CHAIN_ID,
|
|
28991
|
+
DEFAULT_RETRYABLE_STATUSES,
|
|
28761
28992
|
DexWsClient,
|
|
28762
28993
|
EIP712_DOMAIN_TYPE,
|
|
28763
28994
|
EIP712_MSG_TYPES,
|
|
@@ -28833,6 +29064,7 @@ var SDK_VERSION = "0.7.0";
|
|
|
28833
29064
|
SDK_VERSION,
|
|
28834
29065
|
SIGN_MODE_DIRECT,
|
|
28835
29066
|
SIGN_MODE_LEGACY_AMINO_JSON,
|
|
29067
|
+
SIMULATION_PLACEHOLDER_PUBKEY,
|
|
28836
29068
|
SearchUDFSymbolsQueryParams,
|
|
28837
29069
|
SearchUDFSymbolsResponse,
|
|
28838
29070
|
SearchUDFSymbolsResponseItem,
|
|
@@ -28842,6 +29074,8 @@ var SDK_VERSION = "0.7.0";
|
|
|
28842
29074
|
TxConfirmationUnavailableError,
|
|
28843
29075
|
TxError,
|
|
28844
29076
|
TxNotConfirmedError,
|
|
29077
|
+
TxSimulationError,
|
|
29078
|
+
USER_AGENT,
|
|
28845
29079
|
ValidatorStatus,
|
|
28846
29080
|
WebSocketError,
|
|
28847
29081
|
WithdrawRewardsPartialError,
|
|
@@ -28864,6 +29098,7 @@ var SDK_VERSION = "0.7.0";
|
|
|
28864
29098
|
computeFeeFreeGas,
|
|
28865
29099
|
computeFeeFreeGasCompound,
|
|
28866
29100
|
computeRequiredFee,
|
|
29101
|
+
computeSimulatedGas,
|
|
28867
29102
|
cosmosDecToDecimalString,
|
|
28868
29103
|
cosmosDecToProtoInt,
|
|
28869
29104
|
createAccountCache,
|
|
@@ -29027,6 +29262,7 @@ var SDK_VERSION = "0.7.0";
|
|
|
29027
29262
|
resolveSignerAddress,
|
|
29028
29263
|
signAndBroadcastAgentTx,
|
|
29029
29264
|
signAndBroadcastEip712,
|
|
29265
|
+
simulateTx,
|
|
29030
29266
|
stripEip712Domain,
|
|
29031
29267
|
toViemChain,
|
|
29032
29268
|
validateEip712FieldOrder,
|