ault-sdk-ts 0.0.2-alpha.12 → 0.0.2-alpha.14
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/dist/agent/sign-and-broadcast.d.ts +2 -2
- package/dist/core/errors.d.ts +66 -0
- package/dist/eip712/sign-and-broadcast.d.ts +11 -3
- package/dist/high-level/types.d.ts +12 -1
- package/dist/index.cjs +226 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +218 -32
- package/dist/index.js.map +1 -1
- package/dist/rest/feemarket.d.ts +58 -0
- package/package.json +1 -1
|
@@ -32,7 +32,7 @@ export interface AgentSignAndBroadcastParams {
|
|
|
32
32
|
}
|
|
33
33
|
export declare function signAndBroadcastAgentTx({ network, keyMaterial, masterAddress, msgs, memo, gasLimit, confirmationTimeoutMs, timeoutSeconds, timeoutTimestamp, fetchFn, fetchOptions, cache, }: AgentSignAndBroadcastParams): Promise<{
|
|
34
34
|
txHash: string;
|
|
35
|
-
code:
|
|
35
|
+
code: 0;
|
|
36
36
|
rawLog?: string;
|
|
37
|
-
confirmed
|
|
37
|
+
confirmed: true;
|
|
38
38
|
}>;
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -15,3 +15,69 @@ export declare class WebSocketError extends Error {
|
|
|
15
15
|
reason?: string;
|
|
16
16
|
constructor(message: string, code?: number, reason?: string);
|
|
17
17
|
}
|
|
18
|
+
export interface TxErrorParams {
|
|
19
|
+
txHash: string;
|
|
20
|
+
code: number;
|
|
21
|
+
rawLog?: string;
|
|
22
|
+
/**
|
|
23
|
+
* - `true` -- chain returned a definitive non-zero code (CheckTx or DeliverTx).
|
|
24
|
+
* - `false` -- broadcast accepted but inclusion never observed within the timeout.
|
|
25
|
+
* - `undefined` -- broadcast accepted but the confirmation lookup endpoint failed.
|
|
26
|
+
*/
|
|
27
|
+
confirmed: boolean | undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Thrown when a tx broadcast resolves to a definitive on-chain failure
|
|
31
|
+
* (CheckTx or DeliverTx returned a non-zero code). Callers should catch
|
|
32
|
+
* this and surface the failure (e.g. UI toasts).
|
|
33
|
+
*/
|
|
34
|
+
export declare class TxError extends Error {
|
|
35
|
+
txHash: string;
|
|
36
|
+
code: number;
|
|
37
|
+
rawLog?: string;
|
|
38
|
+
confirmed: boolean | undefined;
|
|
39
|
+
constructor(params: TxErrorParams, message?: string);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Thrown when a tx was broadcast but block inclusion could not be confirmed
|
|
43
|
+
* within the deadline. The tx may still commit later — callers can re-query
|
|
44
|
+
* by `txHash` to recover the final result.
|
|
45
|
+
*/
|
|
46
|
+
export declare class TxNotConfirmedError extends TxError {
|
|
47
|
+
constructor(params: TxErrorParams);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Thrown when a tx was broadcast but the confirmation lookup endpoint was
|
|
51
|
+
* unreachable or returned an unrecognized payload. Distinct from
|
|
52
|
+
* `TxNotConfirmedError` so callers can distinguish "still pending" from
|
|
53
|
+
* "we cannot tell at all".
|
|
54
|
+
*/
|
|
55
|
+
export declare class TxConfirmationUnavailableError extends TxError {
|
|
56
|
+
constructor(params: TxErrorParams);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Thrown by `withdrawRewards` when a mid-loop tx fails AFTER one or more
|
|
60
|
+
* validators have already been withdrawn on-chain. Carries the txs that
|
|
61
|
+
* already committed so callers can reconcile the partial state.
|
|
62
|
+
*
|
|
63
|
+
* `cause` is the underlying error for the failed validator — typically a
|
|
64
|
+
* `TxError` (chain rejection) but it can also be a transport-level failure
|
|
65
|
+
* (`NetworkError`, `TimeoutError`, `ApiError`) raised by the broadcast
|
|
66
|
+
* helper before the chain ever sees the tx.
|
|
67
|
+
*/
|
|
68
|
+
export declare class WithdrawRewardsPartialError extends Error {
|
|
69
|
+
failedValidatorAddress: string;
|
|
70
|
+
partialResults: ReadonlyArray<{
|
|
71
|
+
txHash: string;
|
|
72
|
+
validatorAddress: string;
|
|
73
|
+
}>;
|
|
74
|
+
cause: Error;
|
|
75
|
+
constructor(params: {
|
|
76
|
+
failedValidatorAddress: string;
|
|
77
|
+
partialResults: ReadonlyArray<{
|
|
78
|
+
txHash: string;
|
|
79
|
+
validatorAddress: string;
|
|
80
|
+
}>;
|
|
81
|
+
cause: Error;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type AnyEip712Msg } from "./builder";
|
|
2
2
|
import { type NetworkConfig } from "../core/network";
|
|
3
3
|
import { type FetchFn, type FetchWithRetryOptions } from "../core/http";
|
|
4
|
+
import { type FeeMarketCache } from "../rest/feemarket";
|
|
4
5
|
import { type SignerInput } from "./signers";
|
|
5
6
|
export interface AccountInfo {
|
|
6
7
|
accountNumber: string;
|
|
@@ -47,10 +48,17 @@ export interface SignAndBroadcastParams {
|
|
|
47
48
|
fetchFn?: FetchFn;
|
|
48
49
|
fetchOptions?: import("../core/http").FetchWithRetryOptions;
|
|
49
50
|
cache?: AccountCache;
|
|
51
|
+
/**
|
|
52
|
+
* Optional cache for cosmos-evm feemarket params. When neither `feeAmount`
|
|
53
|
+
* nor `network.eip712FeeAmount` is set, the sign path queries the chain's
|
|
54
|
+
* feemarket params and computes a fee at `effectiveGasPrice * gas` plus a
|
|
55
|
+
* safety margin. Sharing one cache across calls avoids per-tx REST hits.
|
|
56
|
+
*/
|
|
57
|
+
feeMarketCache?: FeeMarketCache;
|
|
50
58
|
}
|
|
51
|
-
export declare function signAndBroadcastEip712({ network, signerAddress, signer, msgs, memo, gasLimit, feeDenom, feeAmount, confirmationTimeoutMs, fetchFn, fetchOptions, cache, }: SignAndBroadcastParams): Promise<{
|
|
59
|
+
export declare function signAndBroadcastEip712({ network, signerAddress, signer, msgs, memo, gasLimit, feeDenom, feeAmount, confirmationTimeoutMs, fetchFn, fetchOptions, cache, feeMarketCache, }: SignAndBroadcastParams): Promise<{
|
|
52
60
|
txHash: string;
|
|
53
|
-
code:
|
|
61
|
+
code: 0;
|
|
54
62
|
rawLog?: string;
|
|
55
|
-
confirmed
|
|
63
|
+
confirmed: true;
|
|
56
64
|
}>;
|
|
@@ -366,9 +366,20 @@ export interface StakingTxApi {
|
|
|
366
366
|
amount: string;
|
|
367
367
|
};
|
|
368
368
|
} & TxOptions): Promise<TxResult>;
|
|
369
|
+
/**
|
|
370
|
+
* Issues one `MsgWithdrawDelegatorReward` per validator as an independent,
|
|
371
|
+
* sequentially signed tx. The chain rejects EIP-712 transactions that pack
|
|
372
|
+
* multiple Cosmos messages (`sdk/18: expected exactly 1 message, got N`),
|
|
373
|
+
* so bundling is unsafe; each validator must travel in its own tx.
|
|
374
|
+
*
|
|
375
|
+
* On full success returns one `TxResult` per validator in the order the
|
|
376
|
+
* caller supplied them. If any tx fails, throws `WithdrawRewardsPartialError`
|
|
377
|
+
* carrying the validator that failed and the txs that already committed.
|
|
378
|
+
* Subsequent validators are not attempted.
|
|
379
|
+
*/
|
|
369
380
|
withdrawRewards(params: {
|
|
370
381
|
validatorAddresses: string[];
|
|
371
|
-
} & TxOptions): Promise<TxResult>;
|
|
382
|
+
} & TxOptions): Promise<TxResult[]>;
|
|
372
383
|
}
|
|
373
384
|
export interface TokenRegistryTxApi {
|
|
374
385
|
enableTokenRegistryTransfers(params?: TxOptions): Promise<TxResult>;
|
package/dist/index.cjs
CHANGED
|
@@ -106,8 +106,12 @@ __export(index_exports, {
|
|
|
106
106
|
TIMING_CONSTANTS: () => TIMING_CONSTANTS,
|
|
107
107
|
TX_BASE_FIELDS: () => TX_BASE_FIELDS,
|
|
108
108
|
TimeoutError: () => TimeoutError,
|
|
109
|
+
TxConfirmationUnavailableError: () => TxConfirmationUnavailableError,
|
|
110
|
+
TxError: () => TxError,
|
|
111
|
+
TxNotConfirmedError: () => TxNotConfirmedError,
|
|
109
112
|
ValidatorStatus: () => BondStatus,
|
|
110
113
|
WebSocketError: () => WebSocketError,
|
|
114
|
+
WithdrawRewardsPartialError: () => WithdrawRewardsPartialError,
|
|
111
115
|
_resetIndexingCache: () => _resetIndexingCache,
|
|
112
116
|
addressEquals: () => addressEquals,
|
|
113
117
|
assertValidatorAddress: () => assertValidatorAddress,
|
|
@@ -121,6 +125,7 @@ __export(index_exports, {
|
|
|
121
125
|
bytesToBase64: () => bytesToBase64,
|
|
122
126
|
computeFeeFreeGas: () => computeFeeFreeGas,
|
|
123
127
|
computeFeeFreeGasCompound: () => computeFeeFreeGasCompound,
|
|
128
|
+
computeRequiredFee: () => computeRequiredFee,
|
|
124
129
|
cosmosDecToDecimalString: () => cosmosDecToDecimalString,
|
|
125
130
|
cosmosDecToProtoInt: () => cosmosDecToProtoInt,
|
|
126
131
|
createAccountCache: () => createAccountCache,
|
|
@@ -136,6 +141,7 @@ __export(index_exports, {
|
|
|
136
141
|
createDexWs: () => createDexWs,
|
|
137
142
|
createEip1193Signer: () => createEip1193Signer,
|
|
138
143
|
createEthersSigner: () => createEthersSigner,
|
|
144
|
+
createFeeMarketCache: () => createFeeMarketCache,
|
|
139
145
|
createLicenseApi: () => createLicenseApi,
|
|
140
146
|
createMarketApi: () => createMarketApi,
|
|
141
147
|
createMinerApi: () => createMinerApi,
|
|
@@ -162,12 +168,14 @@ __export(index_exports, {
|
|
|
162
168
|
encodeTxRaw: () => encodeTxRaw,
|
|
163
169
|
evmToAult: () => evmToAult,
|
|
164
170
|
fetchAllPaginatedProto: () => fetchAllPaginatedProto,
|
|
171
|
+
fetchFeeMarketParams: () => fetchFeeMarketParams,
|
|
165
172
|
fetchJson: () => fetchJson,
|
|
166
173
|
fetchProtoJson: () => fetchProtoJson,
|
|
167
174
|
fetchWithRetry: () => fetchWithRetry,
|
|
168
175
|
getBalanceResponseFreeRegExpOne: () => getBalanceResponseFreeRegExpOne,
|
|
169
176
|
getBalanceResponseTotalRegExpOne: () => getBalanceResponseTotalRegExpOne,
|
|
170
177
|
getBalanceResponseUsedRegExpOne: () => getBalanceResponseUsedRegExpOne,
|
|
178
|
+
getCachedFeeMarketParams: () => getCachedFeeMarketParams,
|
|
171
179
|
getNetworkConfig: () => getNetworkConfig,
|
|
172
180
|
getOHLCVQueryLimitDefault: () => getOHLCVQueryLimitDefault,
|
|
173
181
|
getOHLCVQueryLimitMax: () => getOHLCVQueryLimitMax,
|
|
@@ -366,6 +374,50 @@ var WebSocketError = class extends Error {
|
|
|
366
374
|
this.reason = reason;
|
|
367
375
|
}
|
|
368
376
|
};
|
|
377
|
+
var TxError = class extends Error {
|
|
378
|
+
constructor(params, message) {
|
|
379
|
+
super(message ?? formatTxErrorMessage(params));
|
|
380
|
+
this.name = "TxError";
|
|
381
|
+
this.txHash = params.txHash;
|
|
382
|
+
this.code = params.code;
|
|
383
|
+
this.rawLog = params.rawLog;
|
|
384
|
+
this.confirmed = params.confirmed;
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
var TxNotConfirmedError = class extends TxError {
|
|
388
|
+
constructor(params) {
|
|
389
|
+
super(
|
|
390
|
+
params,
|
|
391
|
+
params.rawLog ?? `Transaction ${params.txHash} was not confirmed before the deadline elapsed.`
|
|
392
|
+
);
|
|
393
|
+
this.name = "TxNotConfirmedError";
|
|
394
|
+
}
|
|
395
|
+
};
|
|
396
|
+
var TxConfirmationUnavailableError = class extends TxError {
|
|
397
|
+
constructor(params) {
|
|
398
|
+
super(
|
|
399
|
+
params,
|
|
400
|
+
params.rawLog ?? `Transaction ${params.txHash} was broadcast but the confirmation endpoint was unavailable.`
|
|
401
|
+
);
|
|
402
|
+
this.name = "TxConfirmationUnavailableError";
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
function formatTxErrorMessage(params) {
|
|
406
|
+
const head = `Transaction ${params.txHash} failed (code ${params.code})`;
|
|
407
|
+
return params.rawLog ? `${head}: ${params.rawLog}` : `${head}.`;
|
|
408
|
+
}
|
|
409
|
+
var WithdrawRewardsPartialError = class extends Error {
|
|
410
|
+
constructor(params) {
|
|
411
|
+
const completed = params.partialResults.length;
|
|
412
|
+
super(
|
|
413
|
+
`withdrawRewards failed at validator ${params.failedValidatorAddress}: ${params.cause.message} (${completed} validator(s) committed before the failure)`
|
|
414
|
+
);
|
|
415
|
+
this.name = "WithdrawRewardsPartialError";
|
|
416
|
+
this.failedValidatorAddress = params.failedValidatorAddress;
|
|
417
|
+
this.partialResults = params.partialResults;
|
|
418
|
+
this.cause = params.cause;
|
|
419
|
+
}
|
|
420
|
+
};
|
|
369
421
|
|
|
370
422
|
// src/core/http.ts
|
|
371
423
|
var DEFAULT_OPTIONS = {
|
|
@@ -13788,6 +13840,67 @@ function buildEip712TypedData(context, msgs, evmChainId) {
|
|
|
13788
13840
|
};
|
|
13789
13841
|
}
|
|
13790
13842
|
|
|
13843
|
+
// src/rest/feemarket.ts
|
|
13844
|
+
async function fetchFeeMarketParams(network, fetchFn, fetchOptions) {
|
|
13845
|
+
const data = await fetchJson(
|
|
13846
|
+
`${network.restUrl}/cosmos/evm/feemarket/v1/params`,
|
|
13847
|
+
{},
|
|
13848
|
+
fetchOptions,
|
|
13849
|
+
fetchFn
|
|
13850
|
+
);
|
|
13851
|
+
const raw = data.params ?? {};
|
|
13852
|
+
return {
|
|
13853
|
+
noBaseFee: raw.noBaseFee ?? raw.no_base_fee ?? false,
|
|
13854
|
+
baseFee: raw.baseFee ?? raw.base_fee ?? "0",
|
|
13855
|
+
minGasPrice: raw.minGasPrice ?? raw.min_gas_price ?? "0"
|
|
13856
|
+
};
|
|
13857
|
+
}
|
|
13858
|
+
var ONE_E18 = 1000000000000000000n;
|
|
13859
|
+
function computeRequiredFee(params, gas, options) {
|
|
13860
|
+
const marginPercent = options?.marginPercent ?? 20;
|
|
13861
|
+
if (marginPercent < 0) {
|
|
13862
|
+
throw new Error(`marginPercent must be >= 0, got ${marginPercent}`);
|
|
13863
|
+
}
|
|
13864
|
+
const minGasPriceI = BigInt(cosmosDecToProtoInt(params.minGasPrice || "0"));
|
|
13865
|
+
const baseFeeI = params.noBaseFee ? 0n : BigInt(cosmosDecToProtoInt(params.baseFee || "0"));
|
|
13866
|
+
const effectiveI = baseFeeI > minGasPriceI ? baseFeeI : minGasPriceI;
|
|
13867
|
+
if (effectiveI <= 0n) return "0";
|
|
13868
|
+
const gasI = BigInt(gas);
|
|
13869
|
+
if (gasI <= 0n) return "0";
|
|
13870
|
+
const margin = BigInt(100 + marginPercent);
|
|
13871
|
+
const numerator = effectiveI * gasI * margin;
|
|
13872
|
+
const denominator = ONE_E18 * 100n;
|
|
13873
|
+
return ((numerator + denominator - 1n) / denominator).toString();
|
|
13874
|
+
}
|
|
13875
|
+
var DEFAULT_FEE_MARKET_TTL_MS = 3e3;
|
|
13876
|
+
function createFeeMarketCache(ttlMs = DEFAULT_FEE_MARKET_TTL_MS) {
|
|
13877
|
+
return { ttlMs, entries: /* @__PURE__ */ new Map() };
|
|
13878
|
+
}
|
|
13879
|
+
async function getCachedFeeMarketParams(cache, network, fetchFn, fetchOptions) {
|
|
13880
|
+
const key = network.chainId;
|
|
13881
|
+
const now = Date.now();
|
|
13882
|
+
if (cache) {
|
|
13883
|
+
const existing = cache.entries.get(key);
|
|
13884
|
+
if (existing && now - existing.fetchedAt < cache.ttlMs) {
|
|
13885
|
+
return existing.params;
|
|
13886
|
+
}
|
|
13887
|
+
}
|
|
13888
|
+
let params;
|
|
13889
|
+
try {
|
|
13890
|
+
params = await fetchFeeMarketParams(network, fetchFn, fetchOptions);
|
|
13891
|
+
} catch (error) {
|
|
13892
|
+
if (!isGatewayUnsupportedError(error)) throw error;
|
|
13893
|
+
params = null;
|
|
13894
|
+
}
|
|
13895
|
+
if (cache) {
|
|
13896
|
+
cache.entries.set(key, { params, fetchedAt: now });
|
|
13897
|
+
}
|
|
13898
|
+
return params;
|
|
13899
|
+
}
|
|
13900
|
+
function isGatewayUnsupportedError(error) {
|
|
13901
|
+
return error instanceof ApiError && (error.status === 404 || error.status === 501);
|
|
13902
|
+
}
|
|
13903
|
+
|
|
13791
13904
|
// src/eip712/signers.ts
|
|
13792
13905
|
var import_accounts = require("viem/accounts");
|
|
13793
13906
|
|
|
@@ -21084,6 +21197,18 @@ async function queryAccount(network, address, fetchFn, fetchOptions) {
|
|
|
21084
21197
|
const pubkey = base.pub_key?.key ?? null;
|
|
21085
21198
|
return { accountNumber, sequence, pubkeyBase64: pubkey };
|
|
21086
21199
|
}
|
|
21200
|
+
async function resolveDynamicFeeAmount(network, gas, feeMarketCache, fetchFn, fetchOptions) {
|
|
21201
|
+
const params = await getCachedFeeMarketParams(feeMarketCache, network, fetchFn, fetchOptions);
|
|
21202
|
+
if (!params) return GAS_CONSTANTS.EIP712_FEE_AMOUNT;
|
|
21203
|
+
let dynamicI;
|
|
21204
|
+
try {
|
|
21205
|
+
dynamicI = BigInt(computeRequiredFee(params, gas));
|
|
21206
|
+
} catch {
|
|
21207
|
+
return GAS_CONSTANTS.EIP712_FEE_AMOUNT;
|
|
21208
|
+
}
|
|
21209
|
+
const staticI = BigInt(GAS_CONSTANTS.EIP712_FEE_AMOUNT);
|
|
21210
|
+
return dynamicI > staticI ? dynamicI.toString() : GAS_CONSTANTS.EIP712_FEE_AMOUNT;
|
|
21211
|
+
}
|
|
21087
21212
|
async function recoverPubkeyFromTypedDataSignature(typedData, signature) {
|
|
21088
21213
|
const hash = (0, import_viem3.hashTypedData)({
|
|
21089
21214
|
domain: typedData.domain,
|
|
@@ -21210,7 +21335,8 @@ async function signAndBroadcastEip712({
|
|
|
21210
21335
|
confirmationTimeoutMs,
|
|
21211
21336
|
fetchFn,
|
|
21212
21337
|
fetchOptions,
|
|
21213
|
-
cache
|
|
21338
|
+
cache,
|
|
21339
|
+
feeMarketCache
|
|
21214
21340
|
}) {
|
|
21215
21341
|
const resolvedSigner = normalizeSigner(signer);
|
|
21216
21342
|
if (!resolvedSigner) {
|
|
@@ -21232,14 +21358,16 @@ async function signAndBroadcastEip712({
|
|
|
21232
21358
|
if (!sequence) {
|
|
21233
21359
|
throw new Error(`Unable to resolve account sequence for signer ${resolvedSignerAddress}.`);
|
|
21234
21360
|
}
|
|
21361
|
+
const resolvedGas = gasLimit ?? network.eip712GasLimit ?? GAS_CONSTANTS.EIP712_GAS_LIMIT;
|
|
21362
|
+
const resolvedFeeAmount = feeAmount ?? network.eip712FeeAmount ?? await resolveDynamicFeeAmount(network, resolvedGas, feeMarketCache, fetchFn, fetchOptions);
|
|
21235
21363
|
const context = {
|
|
21236
21364
|
chainId: network.chainId,
|
|
21237
21365
|
accountNumber,
|
|
21238
21366
|
sequence,
|
|
21239
21367
|
fee: {
|
|
21240
|
-
amount:
|
|
21368
|
+
amount: resolvedFeeAmount,
|
|
21241
21369
|
denom: feeDenom ?? network.eip712FeeDenom ?? GAS_CONSTANTS.DENOM,
|
|
21242
|
-
gas:
|
|
21370
|
+
gas: resolvedGas
|
|
21243
21371
|
},
|
|
21244
21372
|
memo
|
|
21245
21373
|
};
|
|
@@ -21296,12 +21424,12 @@ async function signAndBroadcastEip712({
|
|
|
21296
21424
|
const txHash = normalizeTxHash(result.tx_response.txhash);
|
|
21297
21425
|
if (result.tx_response.code !== 0) {
|
|
21298
21426
|
clearCachedSequence(cache);
|
|
21299
|
-
|
|
21427
|
+
throw new TxError({
|
|
21300
21428
|
txHash,
|
|
21301
21429
|
code: result.tx_response.code,
|
|
21302
21430
|
rawLog: result.tx_response.raw_log,
|
|
21303
21431
|
confirmed: true
|
|
21304
|
-
};
|
|
21432
|
+
});
|
|
21305
21433
|
}
|
|
21306
21434
|
const deliverResult = await pollTxInclusion(
|
|
21307
21435
|
network,
|
|
@@ -21318,18 +21446,34 @@ async function signAndBroadcastEip712({
|
|
|
21318
21446
|
}
|
|
21319
21447
|
}
|
|
21320
21448
|
if (deliverResult.confirmed === void 0) {
|
|
21321
|
-
|
|
21449
|
+
throw new TxConfirmationUnavailableError({
|
|
21322
21450
|
txHash,
|
|
21323
|
-
code:
|
|
21451
|
+
code: deliverResult.code,
|
|
21324
21452
|
rawLog: deliverResult.rawLog ?? result.tx_response.raw_log,
|
|
21325
21453
|
confirmed: void 0
|
|
21326
|
-
};
|
|
21454
|
+
});
|
|
21455
|
+
}
|
|
21456
|
+
if (deliverResult.confirmed === false) {
|
|
21457
|
+
throw new TxNotConfirmedError({
|
|
21458
|
+
txHash,
|
|
21459
|
+
code: deliverResult.code,
|
|
21460
|
+
rawLog: deliverResult.rawLog,
|
|
21461
|
+
confirmed: false
|
|
21462
|
+
});
|
|
21463
|
+
}
|
|
21464
|
+
if (deliverResult.code !== 0) {
|
|
21465
|
+
throw new TxError({
|
|
21466
|
+
txHash,
|
|
21467
|
+
code: deliverResult.code,
|
|
21468
|
+
rawLog: deliverResult.rawLog,
|
|
21469
|
+
confirmed: true
|
|
21470
|
+
});
|
|
21327
21471
|
}
|
|
21328
21472
|
return {
|
|
21329
21473
|
txHash,
|
|
21330
|
-
code:
|
|
21474
|
+
code: 0,
|
|
21331
21475
|
rawLog: deliverResult.rawLog,
|
|
21332
|
-
confirmed:
|
|
21476
|
+
confirmed: true
|
|
21333
21477
|
};
|
|
21334
21478
|
}
|
|
21335
21479
|
|
|
@@ -21337,6 +21481,7 @@ async function signAndBroadcastEip712({
|
|
|
21337
21481
|
function createAultClient(options) {
|
|
21338
21482
|
const context = createRestContext(options.network.restUrl, options.fetchFn, options.fetchOptions);
|
|
21339
21483
|
const eip712Caches = /* @__PURE__ */ new Map();
|
|
21484
|
+
const feeMarketCache = createFeeMarketCache();
|
|
21340
21485
|
const dexApiUrl = options.network.dexApiUrl ?? "";
|
|
21341
21486
|
const dexContext = createRestContext(dexApiUrl, options.fetchFn, options.fetchOptions);
|
|
21342
21487
|
const wsUrl = options.network.dexWsUrl ?? (dexApiUrl ? dexApiUrl.replace(/^http/, "ws").replace(/\/?$/, "/ws") : "");
|
|
@@ -21393,6 +21538,7 @@ function createAultClient(options) {
|
|
|
21393
21538
|
signer,
|
|
21394
21539
|
signerAddress,
|
|
21395
21540
|
cache,
|
|
21541
|
+
feeMarketCache,
|
|
21396
21542
|
confirmationTimeoutMs: params.confirmationTimeoutMs ?? options.defaultConfirmationTimeoutMs
|
|
21397
21543
|
});
|
|
21398
21544
|
},
|
|
@@ -22527,13 +22673,35 @@ function createStakingTxApi({ signerAddress, exec }) {
|
|
|
22527
22673
|
if (validatorAddresses.length === 0) {
|
|
22528
22674
|
throw new Error("validatorAddresses must include at least one validator address.");
|
|
22529
22675
|
}
|
|
22530
|
-
const
|
|
22531
|
-
|
|
22532
|
-
|
|
22533
|
-
|
|
22534
|
-
|
|
22535
|
-
|
|
22536
|
-
|
|
22676
|
+
const normalized = validatorAddresses.map(assertValidatorAddress);
|
|
22677
|
+
const results = [];
|
|
22678
|
+
const partial = [];
|
|
22679
|
+
for (let i = 0; i < normalized.length; i++) {
|
|
22680
|
+
const validatorAddress = normalized[i];
|
|
22681
|
+
try {
|
|
22682
|
+
const result = await exec(
|
|
22683
|
+
[
|
|
22684
|
+
msg.distribution.withdrawDelegatorReward({
|
|
22685
|
+
delegatorAddress: signerAddress,
|
|
22686
|
+
validatorAddress
|
|
22687
|
+
})
|
|
22688
|
+
],
|
|
22689
|
+
{ gasLimit, feeAmount, memo, confirmationTimeoutMs }
|
|
22690
|
+
);
|
|
22691
|
+
results.push(result);
|
|
22692
|
+
partial.push({ txHash: result.txHash, validatorAddress });
|
|
22693
|
+
} catch (error) {
|
|
22694
|
+
if (partial.length > 0) {
|
|
22695
|
+
throw new WithdrawRewardsPartialError({
|
|
22696
|
+
failedValidatorAddress: validatorAddress,
|
|
22697
|
+
partialResults: partial,
|
|
22698
|
+
cause: error instanceof Error ? error : new Error(String(error))
|
|
22699
|
+
});
|
|
22700
|
+
}
|
|
22701
|
+
throw error;
|
|
22702
|
+
}
|
|
22703
|
+
}
|
|
22704
|
+
return results;
|
|
22537
22705
|
}
|
|
22538
22706
|
};
|
|
22539
22707
|
}
|
|
@@ -22622,6 +22790,7 @@ function createTxExecutor(options) {
|
|
|
22622
22790
|
const defaultMemo = options.defaultMemo ?? "";
|
|
22623
22791
|
const defaultConfirmationTimeoutMs = options.defaultConfirmationTimeoutMs;
|
|
22624
22792
|
const cache = createAccountCache();
|
|
22793
|
+
const feeMarketCache = createFeeMarketCache();
|
|
22625
22794
|
const fetchOptions = {
|
|
22626
22795
|
timeout: TIMING_CONSTANTS.API_TIMEOUT_MS,
|
|
22627
22796
|
retries: 3,
|
|
@@ -22640,14 +22809,15 @@ function createTxExecutor(options) {
|
|
|
22640
22809
|
confirmationTimeoutMs: txOptions?.confirmationTimeoutMs ?? defaultConfirmationTimeoutMs,
|
|
22641
22810
|
fetchFn: options.fetchFn,
|
|
22642
22811
|
fetchOptions,
|
|
22643
|
-
cache
|
|
22812
|
+
cache,
|
|
22813
|
+
feeMarketCache
|
|
22644
22814
|
});
|
|
22645
22815
|
return {
|
|
22646
22816
|
txHash: result.txHash,
|
|
22647
|
-
code:
|
|
22817
|
+
code: 0,
|
|
22648
22818
|
rawLog: result.rawLog,
|
|
22649
|
-
confirmed:
|
|
22650
|
-
success:
|
|
22819
|
+
confirmed: true,
|
|
22820
|
+
success: true
|
|
22651
22821
|
};
|
|
22652
22822
|
};
|
|
22653
22823
|
}
|
|
@@ -22817,12 +22987,12 @@ async function signAndBroadcastAgentTx({
|
|
|
22817
22987
|
);
|
|
22818
22988
|
const txHash = normalizeTxHash(result.tx_response.txhash);
|
|
22819
22989
|
if (result.tx_response.code !== 0) {
|
|
22820
|
-
|
|
22990
|
+
throw new TxError({
|
|
22821
22991
|
txHash,
|
|
22822
22992
|
code: result.tx_response.code,
|
|
22823
22993
|
rawLog: result.tx_response.raw_log,
|
|
22824
22994
|
confirmed: true
|
|
22825
|
-
};
|
|
22995
|
+
});
|
|
22826
22996
|
}
|
|
22827
22997
|
const deliverResult = await pollTxInclusion(
|
|
22828
22998
|
network,
|
|
@@ -22832,18 +23002,34 @@ async function signAndBroadcastAgentTx({
|
|
|
22832
23002
|
confirmationTimeoutMs
|
|
22833
23003
|
);
|
|
22834
23004
|
if (deliverResult.confirmed === void 0) {
|
|
22835
|
-
|
|
23005
|
+
throw new TxConfirmationUnavailableError({
|
|
22836
23006
|
txHash,
|
|
22837
|
-
code:
|
|
23007
|
+
code: deliverResult.code,
|
|
22838
23008
|
rawLog: deliverResult.rawLog ?? result.tx_response.raw_log,
|
|
22839
23009
|
confirmed: void 0
|
|
22840
|
-
};
|
|
23010
|
+
});
|
|
23011
|
+
}
|
|
23012
|
+
if (deliverResult.confirmed === false) {
|
|
23013
|
+
throw new TxNotConfirmedError({
|
|
23014
|
+
txHash,
|
|
23015
|
+
code: deliverResult.code,
|
|
23016
|
+
rawLog: deliverResult.rawLog,
|
|
23017
|
+
confirmed: false
|
|
23018
|
+
});
|
|
23019
|
+
}
|
|
23020
|
+
if (deliverResult.code !== 0) {
|
|
23021
|
+
throw new TxError({
|
|
23022
|
+
txHash,
|
|
23023
|
+
code: deliverResult.code,
|
|
23024
|
+
rawLog: deliverResult.rawLog,
|
|
23025
|
+
confirmed: true
|
|
23026
|
+
});
|
|
22841
23027
|
}
|
|
22842
23028
|
return {
|
|
22843
23029
|
txHash,
|
|
22844
|
-
code:
|
|
23030
|
+
code: 0,
|
|
22845
23031
|
rawLog: deliverResult.rawLog,
|
|
22846
|
-
confirmed:
|
|
23032
|
+
confirmed: true
|
|
22847
23033
|
};
|
|
22848
23034
|
}
|
|
22849
23035
|
|
|
@@ -22876,10 +23062,10 @@ function createAgentTxExecutor(options) {
|
|
|
22876
23062
|
});
|
|
22877
23063
|
return {
|
|
22878
23064
|
txHash: result.txHash,
|
|
22879
|
-
code:
|
|
23065
|
+
code: 0,
|
|
22880
23066
|
rawLog: result.rawLog,
|
|
22881
|
-
confirmed:
|
|
22882
|
-
success:
|
|
23067
|
+
confirmed: true,
|
|
23068
|
+
success: true
|
|
22883
23069
|
};
|
|
22884
23070
|
};
|
|
22885
23071
|
}
|
|
@@ -23605,7 +23791,7 @@ function createDexWs(url, options) {
|
|
|
23605
23791
|
}
|
|
23606
23792
|
|
|
23607
23793
|
// src/index.ts
|
|
23608
|
-
var SDK_VERSION = "0.0.2-alpha.
|
|
23794
|
+
var SDK_VERSION = "0.0.2-alpha.14";
|
|
23609
23795
|
// Annotate the CommonJS export names for ESM import in node:
|
|
23610
23796
|
0 && (module.exports = {
|
|
23611
23797
|
AGENT_DEFAULTS,
|
|
@@ -23684,8 +23870,12 @@ var SDK_VERSION = "0.0.2-alpha.12";
|
|
|
23684
23870
|
TIMING_CONSTANTS,
|
|
23685
23871
|
TX_BASE_FIELDS,
|
|
23686
23872
|
TimeoutError,
|
|
23873
|
+
TxConfirmationUnavailableError,
|
|
23874
|
+
TxError,
|
|
23875
|
+
TxNotConfirmedError,
|
|
23687
23876
|
ValidatorStatus,
|
|
23688
23877
|
WebSocketError,
|
|
23878
|
+
WithdrawRewardsPartialError,
|
|
23689
23879
|
_resetIndexingCache,
|
|
23690
23880
|
addressEquals,
|
|
23691
23881
|
assertValidatorAddress,
|
|
@@ -23699,6 +23889,7 @@ var SDK_VERSION = "0.0.2-alpha.12";
|
|
|
23699
23889
|
bytesToBase64,
|
|
23700
23890
|
computeFeeFreeGas,
|
|
23701
23891
|
computeFeeFreeGasCompound,
|
|
23892
|
+
computeRequiredFee,
|
|
23702
23893
|
cosmosDecToDecimalString,
|
|
23703
23894
|
cosmosDecToProtoInt,
|
|
23704
23895
|
createAccountCache,
|
|
@@ -23714,6 +23905,7 @@ var SDK_VERSION = "0.0.2-alpha.12";
|
|
|
23714
23905
|
createDexWs,
|
|
23715
23906
|
createEip1193Signer,
|
|
23716
23907
|
createEthersSigner,
|
|
23908
|
+
createFeeMarketCache,
|
|
23717
23909
|
createLicenseApi,
|
|
23718
23910
|
createMarketApi,
|
|
23719
23911
|
createMinerApi,
|
|
@@ -23740,12 +23932,14 @@ var SDK_VERSION = "0.0.2-alpha.12";
|
|
|
23740
23932
|
encodeTxRaw,
|
|
23741
23933
|
evmToAult,
|
|
23742
23934
|
fetchAllPaginatedProto,
|
|
23935
|
+
fetchFeeMarketParams,
|
|
23743
23936
|
fetchJson,
|
|
23744
23937
|
fetchProtoJson,
|
|
23745
23938
|
fetchWithRetry,
|
|
23746
23939
|
getBalanceResponseFreeRegExpOne,
|
|
23747
23940
|
getBalanceResponseTotalRegExpOne,
|
|
23748
23941
|
getBalanceResponseUsedRegExpOne,
|
|
23942
|
+
getCachedFeeMarketParams,
|
|
23749
23943
|
getNetworkConfig,
|
|
23750
23944
|
getOHLCVQueryLimitDefault,
|
|
23751
23945
|
getOHLCVQueryLimitMax,
|