@argent/x-shared 1.70.2 → 1.71.0
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/index.cjs +1 -1
- package/dist/index.js +286 -307
- package/dist/simulation.cjs +1 -1
- package/dist/simulation.js +66 -68
- package/dist/src/features/paymaster/types.d.ts +2 -2
- package/dist/src/features/simulation/fees/schema.cjs +1 -1
- package/dist/src/features/simulation/fees/schema.d.ts +665 -705
- package/dist/src/features/simulation/fees/schema.js +32 -39
- package/dist/src/features/simulation/transactionReview/schema.cjs +1 -1
- package/dist/src/features/simulation/transactionReview/schema.d.ts +2117 -7917
- package/dist/src/features/simulation/transactionReview/schema.js +103 -112
- package/dist/src/features/swap/models/execute.model.d.ts +4 -0
- package/dist/src/features/swap/services/SwapTransactionService.cjs +1 -1
- package/dist/src/features/swap/services/SwapTransactionService.js +22 -18
- package/dist/src/staking/schema.cjs +1 -1
- package/dist/src/staking/schema.d.ts +11 -0
- package/dist/src/staking/schema.js +1 -0
- package/dist/src/tokens/isUnlimitedAmount.cjs +1 -1
- package/dist/src/tokens/isUnlimitedAmount.js +3 -3
- package/dist/src/transactions/amount.cjs +1 -1
- package/dist/src/transactions/amount.d.ts +2 -2
- package/dist/src/transactions/amount.js +9 -9
- package/dist/src/transactions/estimate/adjustment.cjs +1 -0
- package/dist/src/transactions/estimate/adjustment.d.ts +4 -0
- package/dist/src/transactions/estimate/adjustment.js +7 -0
- package/dist/src/transactions/estimate/argentMaxFee.d.ts +3 -3
- package/dist/src/transactions/estimate/index.d.ts +0 -1
- package/dist/src/transactions/estimate/model.d.ts +1 -10
- package/dist/src/transactions/estimate/utils.cjs +1 -1
- package/dist/src/transactions/estimate/utils.d.ts +31 -61
- package/dist/src/transactions/estimate/utils.js +156 -223
- package/dist/src/transactions/index.d.ts +0 -1
- package/dist/src/transactions/service/implementation.cjs +1 -1
- package/dist/src/transactions/service/implementation.d.ts +39 -22
- package/dist/src/transactions/service/implementation.js +130 -97
- package/dist/src/transactions/service/index.d.ts +1 -0
- package/dist/src/transactions/service/utils.cjs +1 -0
- package/dist/src/transactions/service/utils.d.ts +25 -0
- package/dist/src/transactions/service/utils.js +25 -0
- package/dist/src/transactions/transactionSimulationTypes.d.ts +1 -7
- package/dist/src/transactions/transactionVersion.cjs +1 -1
- package/dist/src/transactions/transactionVersion.d.ts +5 -6
- package/dist/src/transactions/transactionVersion.js +10 -12
- package/package.json +2 -2
- package/dist/src/transactions/estimate/utilsV2.cjs +0 -1
- package/dist/src/transactions/estimate/utilsV2.d.ts +0 -26
- package/dist/src/transactions/estimate/utilsV2.js +0 -107
- package/dist/src/transactions/getTransactionVersion.cjs +0 -1
- package/dist/src/transactions/getTransactionVersion.d.ts +0 -12
- package/dist/src/transactions/getTransactionVersion.js +0 -21
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { isEmpty as u, partition as y } from "lodash-es";
|
|
2
|
-
import { num as s, constants as p } from "starknet";
|
|
3
|
-
import { getAccountTxVersion as f } from "../getTransactionVersion.js";
|
|
4
|
-
import { EstimateError as d } from "./error.js";
|
|
5
|
-
import { toMax as g, castFeeEstimation as T, unitToFeeTokenAddress as A, estimatedFeeToMaxFeeTotal as E, estimatedFeesToTotal as v } from "./utils.js";
|
|
6
|
-
import { isEqualAddress as l } from "../../chains/starknet/address.js";
|
|
7
|
-
import { ETH_TOKEN_ADDRESS as h, STRK_TOKEN_ADDRESS as I } from "../../chains/starknet/constants.js";
|
|
8
|
-
const O = (t) => {
|
|
9
|
-
const { transactions: e } = t;
|
|
10
|
-
if (!e)
|
|
11
|
-
throw new d({ code: "SIMULATE_AND_REVIEW_FAILED" });
|
|
12
|
-
if (!Array.isArray(e))
|
|
13
|
-
throw Error(`Unexpected simulation response. Expected array. Got ${typeof e}`);
|
|
14
|
-
if (u(e))
|
|
15
|
-
return [];
|
|
16
|
-
if (e.length > 2)
|
|
17
|
-
throw Error(`Unexpected simulation response length. Got ${e.length}`);
|
|
18
|
-
const n = e.map((i) => {
|
|
19
|
-
if (!i.simulation)
|
|
20
|
-
throw new d({ code: "SIMULATE_AND_REVIEW_FAILED" });
|
|
21
|
-
return {
|
|
22
|
-
...i.simulation,
|
|
23
|
-
...N(i.simulation.feeEstimations)
|
|
24
|
-
};
|
|
25
|
-
}), [o, a] = n.length === 1 ? [n[0], void 0] : [n[1], n[0]], r = _(o, a), F = S(o, a);
|
|
26
|
-
return [...r, ...F];
|
|
27
|
-
}, N = (t) => {
|
|
28
|
-
const [e, n] = y(t, (o) => "unit" in o && (o.unit === "FRI" || o.unit === "WEI"));
|
|
29
|
-
return { nativeFeeEstimations: e, paymasterFeeEstimations: n };
|
|
30
|
-
}, S = (t, e) => {
|
|
31
|
-
if (!t)
|
|
32
|
-
return [];
|
|
33
|
-
if (!e)
|
|
34
|
-
return t.paymasterFeeEstimations.map((a) => ({
|
|
35
|
-
type: "paymaster",
|
|
36
|
-
transactions: m(a),
|
|
37
|
-
deployment: void 0
|
|
38
|
-
}));
|
|
39
|
-
const n = e.paymasterFeeEstimations, o = t.paymasterFeeEstimations;
|
|
40
|
-
if (n.length !== o.length)
|
|
41
|
-
throw Error("Deployment and transaction fee estimations length mismatch");
|
|
42
|
-
return o.map((a, r) => ({
|
|
43
|
-
type: "paymaster",
|
|
44
|
-
transactions: m(a),
|
|
45
|
-
deployment: m(n[r])
|
|
46
|
-
}));
|
|
47
|
-
}, _ = (t, e) => {
|
|
48
|
-
if (!t)
|
|
49
|
-
return [];
|
|
50
|
-
if (!e)
|
|
51
|
-
return t.nativeFeeEstimations.map((a) => ({
|
|
52
|
-
type: "native",
|
|
53
|
-
transactions: c(a),
|
|
54
|
-
deployment: void 0
|
|
55
|
-
}));
|
|
56
|
-
const n = e.nativeFeeEstimations, o = t.nativeFeeEstimations;
|
|
57
|
-
if (n.length !== o.length)
|
|
58
|
-
throw Error("Deployment and transaction fee estimations length mismatch");
|
|
59
|
-
return o.map((a, r) => ({
|
|
60
|
-
type: "native",
|
|
61
|
-
transactions: c(a),
|
|
62
|
-
deployment: c(n[r])
|
|
63
|
-
}));
|
|
64
|
-
}, m = (t) => ({
|
|
65
|
-
feeTokenAddress: t.token.address,
|
|
66
|
-
maxFee: BigInt(t.maxFee),
|
|
67
|
-
overallFee: BigInt(t.overallFee)
|
|
68
|
-
}), c = (t) => ({
|
|
69
|
-
amount: s.toBigInt(t.gasUsage),
|
|
70
|
-
feeTokenAddress: A(t.unit),
|
|
71
|
-
pricePerUnit: s.toBigInt(t.gasPrice),
|
|
72
|
-
dataGasConsumed: s.toBigInt(t.dataGasConsumed ?? 0),
|
|
73
|
-
dataGasPrice: s.toBigInt(t.dataGasPrice ?? 0),
|
|
74
|
-
max: g(T(t, s.toBigInt))
|
|
75
|
-
}), U = (t) => {
|
|
76
|
-
var o;
|
|
77
|
-
if (t.type === "paymaster")
|
|
78
|
-
return t.transactions.maxFee + (((o = t.deployment) == null ? void 0 : o.maxFee) ?? 0n);
|
|
79
|
-
if (t.deployment && !l(t.deployment.feeTokenAddress, t.transactions.feeTokenAddress))
|
|
80
|
-
throw Error("Cannot calculate estimated fees for different tokens");
|
|
81
|
-
const e = t.deployment ? E(t.deployment) : 0n, n = E(t.transactions);
|
|
82
|
-
return e + n;
|
|
83
|
-
}, L = (t) => {
|
|
84
|
-
var e;
|
|
85
|
-
return t.type === "paymaster" ? t.transactions.overallFee + (((e = t.deployment) == null ? void 0 : e.overallFee) ?? 0n) : v(t);
|
|
86
|
-
}, x = (t = []) => t.filter((n) => n.type === "native"), W = (t) => t.filter((e) => e.type === "paymaster"), R = (t) => t === p.TRANSACTION_VERSION.V1 || t === p.TRANSACTION_VERSION.F1 ? h : I, V = (t = [], e) => {
|
|
87
|
-
const n = x(t).find((o) => l(o.transactions.feeTokenAddress, e));
|
|
88
|
-
if (!n)
|
|
89
|
-
throw Error(`No native estimated fee found for ${e}`);
|
|
90
|
-
return n;
|
|
91
|
-
}, w = (t = [], e) => {
|
|
92
|
-
const n = R(e);
|
|
93
|
-
return V(t, n);
|
|
94
|
-
}, K = (t = [], e) => w(t, f(e));
|
|
95
|
-
export {
|
|
96
|
-
U as estimatedFeesToMaxFeeTotalV2,
|
|
97
|
-
L as estimatedFeesToTotalV2,
|
|
98
|
-
W as filterPaymasterEstimatedFees,
|
|
99
|
-
O as getEstimatedFeeFromSimulationAndRespectWatermarkFeeV2,
|
|
100
|
-
V as getNativeEstimatedFeeByFeeToken,
|
|
101
|
-
w as getNativeEstimatedFeeByTxVersion,
|
|
102
|
-
K as getNativeEstimatedFeeForAccount,
|
|
103
|
-
x as getNativeEstimatedFees,
|
|
104
|
-
_ as getNativeFeeFromSimulation,
|
|
105
|
-
R as getNativeFeeTokenAddress,
|
|
106
|
-
S as getPaymasterFeeFromSimulation
|
|
107
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("starknet"),r=require("../chains/starknet/address.cjs"),o=require("../chains/starknet/constants.cjs"),s=require("./txv3.cjs");function T(e){return r.isEqualAddress(e,o.ETH_TOKEN_ADDRESS)?t.constants.TRANSACTION_VERSION.V1:t.constants.TRANSACTION_VERSION.V3}function c(e){return r.isEqualAddress(e,o.ETH_TOKEN_ADDRESS)?t.constants.TRANSACTION_VERSION.F1:t.constants.TRANSACTION_VERSION.F3}function N(e,n){return t.isSierra(n.contract)?r.isEqualAddress(e,o.ETH_TOKEN_ADDRESS)?t.constants.TRANSACTION_VERSION.V2:t.constants.TRANSACTION_VERSION.V3:t.constants.TRANSACTION_VERSION.V1}const S=({classHash:e})=>e&&!s.classHashSupportsTxV3(e)?t.constants.TRANSACTION_VERSION.V1:t.constants.TRANSACTION_VERSION.V3,a=({classHash:e},n)=>t.isSierra(n.contract)?e&&!s.classHashSupportsTxV3(e)?t.constants.TRANSACTION_VERSION.V2:t.constants.TRANSACTION_VERSION.V3:t.constants.TRANSACTION_VERSION.V1;exports.getAccountTxVersion=S;exports.getSimulationTxVersionFromFeeToken=c;exports.getTxVersionForDeclareContract=a;exports.getTxVersionFromFeeToken=T;exports.getTxVersionFromFeeTokenForDeclareContract=N;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { DeclareContractPayload } from 'starknet';
|
|
2
|
-
import { Address } from '../chains/starknet';
|
|
3
|
-
import { TransactionInvokeVersion, TransactionSimulationVersion } from './transactionVersion';
|
|
4
|
-
export declare function getTxVersionFromFeeToken(feeTokenAddress: Address): TransactionInvokeVersion;
|
|
5
|
-
export declare function getSimulationTxVersionFromFeeToken(feeTokenAddress: Address): TransactionSimulationVersion;
|
|
6
|
-
export declare function getTxVersionFromFeeTokenForDeclareContract(feeTokenAddress: Address, payload: DeclareContractPayload): TransactionInvokeVersion;
|
|
7
|
-
type AccountClassHash = {
|
|
8
|
-
classHash?: string;
|
|
9
|
-
};
|
|
10
|
-
export declare const getAccountTxVersion: ({ classHash }: AccountClassHash) => "0x1" | "0x3";
|
|
11
|
-
export declare const getTxVersionForDeclareContract: ({ classHash }: AccountClassHash, payload: DeclareContractPayload) => TransactionInvokeVersion;
|
|
12
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { constants as r, isSierra as e } from "starknet";
|
|
2
|
-
import { isEqualAddress as o } from "../chains/starknet/address.js";
|
|
3
|
-
import { ETH_TOKEN_ADDRESS as T } from "../chains/starknet/constants.js";
|
|
4
|
-
import { classHashSupportsTxV3 as n } from "./txv3.js";
|
|
5
|
-
function R(N) {
|
|
6
|
-
return o(N, T) ? r.TRANSACTION_VERSION.V1 : r.TRANSACTION_VERSION.V3;
|
|
7
|
-
}
|
|
8
|
-
function I(N) {
|
|
9
|
-
return o(N, T) ? r.TRANSACTION_VERSION.F1 : r.TRANSACTION_VERSION.F3;
|
|
10
|
-
}
|
|
11
|
-
function i(N, t) {
|
|
12
|
-
return e(t.contract) ? o(N, T) ? r.TRANSACTION_VERSION.V2 : r.TRANSACTION_VERSION.V3 : r.TRANSACTION_VERSION.V1;
|
|
13
|
-
}
|
|
14
|
-
const E = ({ classHash: N }) => N && !n(N) ? r.TRANSACTION_VERSION.V1 : r.TRANSACTION_VERSION.V3, c = ({ classHash: N }, t) => e(t.contract) ? N && !n(N) ? r.TRANSACTION_VERSION.V2 : r.TRANSACTION_VERSION.V3 : r.TRANSACTION_VERSION.V1;
|
|
15
|
-
export {
|
|
16
|
-
E as getAccountTxVersion,
|
|
17
|
-
I as getSimulationTxVersionFromFeeToken,
|
|
18
|
-
c as getTxVersionForDeclareContract,
|
|
19
|
-
R as getTxVersionFromFeeToken,
|
|
20
|
-
i as getTxVersionFromFeeTokenForDeclareContract
|
|
21
|
-
};
|