@argent/x-shared 1.56.0 → 1.56.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("lodash-es"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("lodash-es"),a=require("starknet"),y=require("../../chains/starknet/address.cjs"),x=require("../../chains/starknet/constants.cjs"),U=require("./argentMaxFee.cjs"),E=require("./error.cjs"),h=require("../../utils/starknet/starknet.cjs"),P=require("../../features/simulation/transactionReview/schema.cjs"),S=require("../../utils/arrays.cjs");function F(t){return A.upperCase(t.unit)==="WEI"}function G(t){return A.upperCase(t.unit)==="FRI"}function u(t,n){return F(t)?{...t,maxFee:n(t.maxFee),overallFee:n(t.overallFee),gasPrice:n(t.gasPrice),gasUsage:n(t.gasUsage)}:{...t,overallFee:n(t.overallFee),gasPrice:n(t.gasPrice),gasUsage:n(t.gasUsage),maxAmount:n(t.maxAmount),maxPricePerUnit:n(t.maxPricePerUnit)}}function d(t){return F(t)?{maxFee:t.maxFee}:{amount:t.maxAmount,pricePerUnit:t.maxPricePerUnit}}function p(t){return G({unit:t})?x.STRK_TOKEN_ADDRESS:x.ETH_TOKEN_ADDRESS}function k(t,n,e=2){const r=BigInt(10**e),o=BigInt(Math.round(n*10**e));return t*o/r}const N=[x.STRK_TOKEN_ADDRESS],I=(t,n=C)=>{if(t.max&&"amount"in t.max)return{...t,...t.max};const e=10000n,{amount:r,pricePerUnit:o,dataGasConsumed:s=0n,dataGasPrice:m=0n}=t,c=r*o+s*m;if(c<0)throw Error("Cannot calculate max fee for negative fee");const i=a.num.toBigInt(U.argentMaxFee({estimatedFee:c})),f=Number(i)/Number(c),M=n(f),g=BigInt(Math.trunc(M*Number(e)));return{...t,amount:r*g/e,pricePerUnit:o*g/e,dataGasConsumed:s*g/e,dataGasPrice:m*g/e}},l=t=>{const{amount:n,pricePerUnit:e,dataGasConsumed:r=0n,dataGasPrice:o=0n}=t;return n*e+r*o},B=t=>{if(t.max)return"maxFee"in t.max?t.max.maxFee:l(t.max)},T=t=>{const n=B(t);return n||l(I(t))},R=t=>{if(t.deployment&&!y.isEqualAddress(t.deployment.feeTokenAddress,t.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const n=l(t.transactions),e=t.deployment?l(t.deployment):0n;return n+e},q=t=>{if(t.deployment&&!y.isEqualAddress(t.deployment.feeTokenAddress,t.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const n=t.deployment?T(t.deployment):0n,e=T(t.transactions);return n+e},D=(t,n)=>[{contractAddress:t,entrypoint:"transfer",calldata:a.CallData.compile(h.transferCalldataSchema.parse({recipient:n,amount:a.uint256.bnToUint256(BigInt(1))}))}],_=(t,n)=>{if(!t)return{transactions:{feeTokenAddress:n??x.ETH_TOKEN_ADDRESS,amount:0n,pricePerUnit:0n,dataGasConsumed:0n,dataGasPrice:0n}};if(!Array.isArray(t))throw Error(`Unexpected simulation response. Expected array. Got ${typeof t}`);if(t.length===1){const e=P.feeEstimationSchema.parse(t[0].feeEstimation);return{transactions:{feeTokenAddress:p(e.unit),amount:a.num.toBigInt(e.gasUsage),pricePerUnit:a.num.toBigInt(e.gasPrice),max:d(u(e,a.num.toBigInt)),dataGasConsumed:e.dataGasConsumed?a.num.toBigInt(e.dataGasConsumed):0n,dataGasPrice:e.dataGasPrice?a.num.toBigInt(e.dataGasPrice):0n}}}if(t.length===2){const e=P.feeEstimationSchema.parse(t[0].feeEstimation),r=P.feeEstimationSchema.parse(t[1].feeEstimation);return{deployment:{feeTokenAddress:p(e.unit),amount:a.num.toBigInt(e.gasUsage),pricePerUnit:a.num.toBigInt(e.gasPrice),max:d(u(e,a.num.toBigInt)),dataGasConsumed:e.dataGasConsumed?a.num.toBigInt(e.dataGasConsumed):0n,dataGasPrice:e.dataGasPrice?a.num.toBigInt(e.dataGasPrice):0n},transactions:{feeTokenAddress:p(r.unit),amount:a.num.toBigInt(r.gasUsage),pricePerUnit:a.num.toBigInt(r.gasPrice),max:d(u(r,a.num.toBigInt)),dataGasConsumed:r.dataGasConsumed?a.num.toBigInt(r.dataGasConsumed):0n,dataGasPrice:r.dataGasPrice?a.num.toBigInt(r.dataGasPrice):0n}}}throw Error("Unexpected simulation response length")},b=({transaction:t,nonce:n,chainId:e,version:r,isDeploymentTransaction:o,cairoVersion:s,address:m,appDomain:c})=>{let i=n;o&&t.type!=="DEPLOY_ACCOUNT"&&(i=a.num.toHex(1));const f=S.ensureArray(t.calls);return{type:t.type,chainId:e,cairoVersion:s,nonce:i,version:r,account:m,calls:f,calldata:t.calldata,salt:t.salt,signature:t.signature,classHash:t.classHash,appDomain:c}},W=(t,n)=>{const{transactions:e}=t;if(!e)throw new E.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});const r=e.map(i=>{if(!i.simulation)throw new E.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});return i}),o=r.map(i=>({...i.simulation,feeEstimation:u(i.simulation.feeEstimation,Number)})),s=_(o,n),[m,c]=r.length===1?[r[0],void 0]:[r[1],r[0]];return{...s,transactions:{...s.transactions,dataGasConsumed:s.transactions.dataGasConsumed??0n,dataGasPrice:s.transactions.dataGasPrice??0n,max:d(u(m.simulation.feeEstimation,a.num.toBigInt))},deployment:s.deployment&&c?{...s.deployment,dataGasConsumed:s.deployment.dataGasConsumed??0n,dataGasPrice:s.deployment.dataGasPrice??0n,max:d(u(c.simulation.feeEstimation,a.num.toBigInt))}:void 0}},j=t=>({max_amount:a.num.toHex(t.amount),max_price_per_unit:a.num.toHex(t.pricePerUnit)}),w=(t,n,e)=>({max_amount:a.num.toHex(t/n),max_price_per_unit:a.num.toHex(e)}),H=t=>{const n=I(t),e=T(t);return{maxFee:e,resourceBounds:{l1_gas:(o=>o!==void 0&&"amount"in o&&"pricePerUnit"in o)(t.max)?j(t.max):w(e,t.pricePerUnit,n.pricePerUnit),l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"}}}},L=t=>{const n=Math.sqrt(t);return isNaN(n)?Math.sqrt(2):n},C=t=>{const n=Math.cbrt(t);return isNaN(n)?Math.cbrt(2):n},v=t=>t<1||isNaN(t)?1.1:Math.log(t+1)+1;exports.buildDummyTx=D;exports.calculateCubeRootAdjustment=C;exports.calculateNonLinearAdjustment=v;exports.calculateSqrtAdjustment=L;exports.castFeeEstimation=u;exports.estimatedFeeToMaxFeeTotal=T;exports.estimatedFeeToMaxResourceBounds=H;exports.estimatedFeeToTotal=l;exports.estimatedFeesToMaxFeeTotal=q;exports.estimatedFeesToTotal=R;exports.getEstimatedFeeFromBulkSimulation=_;exports.getEstimatedFeeFromSimulationAndRespectWatermarkFee=W;exports.getPayloadFromTransaction=b;exports.getWatermarkedMaxFeeTotal=B;exports.isFRI=G;exports.isWEI=F;exports.multiplyBigIntByFloat=k;exports.toMax=d;exports.tokensRequireTxV3Support=N;exports.unitToFeeTokenAddress=p;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { upperCase as
|
|
2
|
-
import { num as r, CallData as
|
|
3
|
-
import { isEqualAddress as
|
|
4
|
-
import { STRK_TOKEN_ADDRESS as
|
|
5
|
-
import { argentMaxFee as
|
|
1
|
+
import { upperCase as A } from "lodash-es";
|
|
2
|
+
import { num as r, CallData as B, uint256 as C } from "starknet";
|
|
3
|
+
import { isEqualAddress as T } from "../../chains/starknet/address.js";
|
|
4
|
+
import { STRK_TOKEN_ADDRESS as I, ETH_TOKEN_ADDRESS as y } from "../../chains/starknet/constants.js";
|
|
5
|
+
import { argentMaxFee as _ } from "./argentMaxFee.js";
|
|
6
6
|
import { EstimateError as G } from "./error.js";
|
|
7
|
-
import { transferCalldataSchema as
|
|
7
|
+
import { transferCalldataSchema as h } from "../../utils/starknet/starknet.js";
|
|
8
8
|
import { feeEstimationSchema as f } from "../../features/simulation/transactionReview/schema.js";
|
|
9
9
|
import { ensureArray as M } from "../../utils/arrays.js";
|
|
10
10
|
function E(t) {
|
|
11
|
-
return
|
|
11
|
+
return A(t.unit) === "WEI";
|
|
12
12
|
}
|
|
13
13
|
function k(t) {
|
|
14
|
-
return
|
|
14
|
+
return A(t.unit) === "FRI";
|
|
15
15
|
}
|
|
16
|
-
function u(t,
|
|
16
|
+
function u(t, e) {
|
|
17
17
|
return E(t) ? {
|
|
18
18
|
...t,
|
|
19
|
-
maxFee:
|
|
20
|
-
overallFee:
|
|
21
|
-
gasPrice:
|
|
22
|
-
gasUsage:
|
|
19
|
+
maxFee: e(t.maxFee),
|
|
20
|
+
overallFee: e(t.overallFee),
|
|
21
|
+
gasPrice: e(t.gasPrice),
|
|
22
|
+
gasUsage: e(t.gasUsage)
|
|
23
23
|
} : {
|
|
24
24
|
...t,
|
|
25
|
-
overallFee:
|
|
26
|
-
gasPrice:
|
|
27
|
-
gasUsage:
|
|
28
|
-
maxAmount:
|
|
29
|
-
maxPricePerUnit:
|
|
25
|
+
overallFee: e(t.overallFee),
|
|
26
|
+
gasPrice: e(t.gasPrice),
|
|
27
|
+
gasUsage: e(t.gasUsage),
|
|
28
|
+
maxAmount: e(t.maxAmount),
|
|
29
|
+
maxPricePerUnit: e(t.maxPricePerUnit)
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
function d(t) {
|
|
@@ -38,64 +38,64 @@ function d(t) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
function x(t) {
|
|
41
|
-
return k({ unit: t }) ?
|
|
41
|
+
return k({ unit: t }) ? I : y;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
const a = BigInt(10 **
|
|
45
|
-
return t *
|
|
43
|
+
function V(t, e, n = 2) {
|
|
44
|
+
const a = BigInt(10 ** n), o = BigInt(Math.round(e * 10 ** n));
|
|
45
|
+
return t * o / a;
|
|
46
46
|
}
|
|
47
|
-
const
|
|
47
|
+
const Y = [I], U = (t, e = w) => {
|
|
48
48
|
if (t.max && "amount" in t.max)
|
|
49
49
|
return {
|
|
50
50
|
...t,
|
|
51
51
|
...t.max
|
|
52
52
|
};
|
|
53
|
-
const
|
|
53
|
+
const n = 10000n, { amount: a, pricePerUnit: o, dataGasConsumed: s = 0n, dataGasPrice: m = 0n } = t, c = a * o + s * m;
|
|
54
54
|
if (c < 0)
|
|
55
55
|
throw Error("Cannot calculate max fee for negative fee");
|
|
56
|
-
const i = r.toBigInt(
|
|
56
|
+
const i = r.toBigInt(_({ estimatedFee: c })), g = Number(i) / Number(c), F = e(g), l = BigInt(Math.trunc(F * Number(n)));
|
|
57
57
|
return {
|
|
58
58
|
...t,
|
|
59
|
-
amount: a * l /
|
|
60
|
-
pricePerUnit:
|
|
61
|
-
dataGasConsumed:
|
|
62
|
-
dataGasPrice: m * l /
|
|
59
|
+
amount: a * l / n,
|
|
60
|
+
pricePerUnit: o * l / n,
|
|
61
|
+
dataGasConsumed: s * l / n,
|
|
62
|
+
dataGasPrice: m * l / n
|
|
63
63
|
};
|
|
64
64
|
}, p = (t) => {
|
|
65
|
-
const { amount:
|
|
66
|
-
return
|
|
65
|
+
const { amount: e, pricePerUnit: n, dataGasConsumed: a = 0n, dataGasPrice: o = 0n } = t;
|
|
66
|
+
return e * n + a * o;
|
|
67
67
|
}, N = (t) => {
|
|
68
68
|
if (t.max)
|
|
69
69
|
return "maxFee" in t.max ? t.max.maxFee : p(t.max);
|
|
70
70
|
}, P = (t) => {
|
|
71
|
-
const
|
|
72
|
-
return
|
|
73
|
-
},
|
|
74
|
-
if (t.deployment && !
|
|
71
|
+
const e = N(t);
|
|
72
|
+
return e || p(U(t));
|
|
73
|
+
}, $ = (t) => {
|
|
74
|
+
if (t.deployment && !T(t.deployment.feeTokenAddress, t.transactions.feeTokenAddress))
|
|
75
75
|
throw Error("Cannot calculate estimated fees for different tokens");
|
|
76
|
-
const
|
|
77
|
-
return
|
|
78
|
-
},
|
|
79
|
-
if (t.deployment && !
|
|
76
|
+
const e = p(t.transactions), n = t.deployment ? p(t.deployment) : 0n;
|
|
77
|
+
return e + n;
|
|
78
|
+
}, z = (t) => {
|
|
79
|
+
if (t.deployment && !T(t.deployment.feeTokenAddress, t.transactions.feeTokenAddress))
|
|
80
80
|
throw Error("Cannot calculate estimated fees for different tokens");
|
|
81
|
-
const
|
|
82
|
-
return
|
|
83
|
-
},
|
|
81
|
+
const e = t.deployment ? P(t.deployment) : 0n, n = P(t.transactions);
|
|
82
|
+
return e + n;
|
|
83
|
+
}, J = (t, e) => [
|
|
84
84
|
{
|
|
85
85
|
contractAddress: t,
|
|
86
86
|
entrypoint: "transfer",
|
|
87
|
-
calldata:
|
|
87
|
+
calldata: B.compile(h.parse({
|
|
88
88
|
// We are using a dummy address (ETH here) as recipient to estimate the fee given we don't have a receipient yet
|
|
89
|
-
recipient:
|
|
89
|
+
recipient: e,
|
|
90
90
|
// We are using the smallest possible amount to make sure this doesn't throw an error
|
|
91
|
-
amount:
|
|
91
|
+
amount: C.bnToUint256(BigInt(1))
|
|
92
92
|
}))
|
|
93
93
|
}
|
|
94
|
-
], S = (t,
|
|
94
|
+
], S = (t, e) => {
|
|
95
95
|
if (!t)
|
|
96
96
|
return {
|
|
97
97
|
transactions: {
|
|
98
|
-
feeTokenAddress:
|
|
98
|
+
feeTokenAddress: e ?? y,
|
|
99
99
|
amount: 0n,
|
|
100
100
|
pricePerUnit: 0n,
|
|
101
101
|
dataGasConsumed: 0n,
|
|
@@ -105,28 +105,28 @@ const K = [y], F = (t, n = D) => {
|
|
|
105
105
|
if (!Array.isArray(t))
|
|
106
106
|
throw Error(`Unexpected simulation response. Expected array. Got ${typeof t}`);
|
|
107
107
|
if (t.length === 1) {
|
|
108
|
-
const
|
|
108
|
+
const n = f.parse(t[0].feeEstimation);
|
|
109
109
|
return {
|
|
110
110
|
transactions: {
|
|
111
|
-
feeTokenAddress: x(
|
|
112
|
-
amount: r.toBigInt(
|
|
113
|
-
pricePerUnit: r.toBigInt(
|
|
114
|
-
max: d(u(
|
|
115
|
-
dataGasConsumed:
|
|
116
|
-
dataGasPrice:
|
|
111
|
+
feeTokenAddress: x(n.unit),
|
|
112
|
+
amount: r.toBigInt(n.gasUsage),
|
|
113
|
+
pricePerUnit: r.toBigInt(n.gasPrice),
|
|
114
|
+
max: d(u(n, r.toBigInt)),
|
|
115
|
+
dataGasConsumed: n.dataGasConsumed ? r.toBigInt(n.dataGasConsumed) : 0n,
|
|
116
|
+
dataGasPrice: n.dataGasPrice ? r.toBigInt(n.dataGasPrice) : 0n
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
if (t.length === 2) {
|
|
121
|
-
const
|
|
121
|
+
const n = f.parse(t[0].feeEstimation), a = f.parse(t[1].feeEstimation);
|
|
122
122
|
return {
|
|
123
123
|
deployment: {
|
|
124
|
-
feeTokenAddress: x(
|
|
125
|
-
amount: r.toBigInt(
|
|
126
|
-
pricePerUnit: r.toBigInt(
|
|
127
|
-
max: d(u(
|
|
128
|
-
dataGasConsumed:
|
|
129
|
-
dataGasPrice:
|
|
124
|
+
feeTokenAddress: x(n.unit),
|
|
125
|
+
amount: r.toBigInt(n.gasUsage),
|
|
126
|
+
pricePerUnit: r.toBigInt(n.gasPrice),
|
|
127
|
+
max: d(u(n, r.toBigInt)),
|
|
128
|
+
dataGasConsumed: n.dataGasConsumed ? r.toBigInt(n.dataGasConsumed) : 0n,
|
|
129
|
+
dataGasPrice: n.dataGasPrice ? r.toBigInt(n.dataGasPrice) : 0n
|
|
130
130
|
},
|
|
131
131
|
transactions: {
|
|
132
132
|
feeTokenAddress: x(a.unit),
|
|
@@ -139,14 +139,14 @@ const K = [y], F = (t, n = D) => {
|
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
141
|
throw Error("Unexpected simulation response length");
|
|
142
|
-
},
|
|
143
|
-
let i =
|
|
144
|
-
|
|
142
|
+
}, Q = ({ transaction: t, nonce: e, chainId: n, version: a, isDeploymentTransaction: o, cairoVersion: s, address: m, appDomain: c }) => {
|
|
143
|
+
let i = e;
|
|
144
|
+
o && t.type !== "DEPLOY_ACCOUNT" && (i = r.toHex(1));
|
|
145
145
|
const g = M(t.calls);
|
|
146
146
|
return {
|
|
147
147
|
type: t.type,
|
|
148
|
-
chainId:
|
|
149
|
-
cairoVersion:
|
|
148
|
+
chainId: n,
|
|
149
|
+
cairoVersion: s,
|
|
150
150
|
nonce: i,
|
|
151
151
|
version: a,
|
|
152
152
|
account: m,
|
|
@@ -158,78 +158,78 @@ const K = [y], F = (t, n = D) => {
|
|
|
158
158
|
appDomain: c
|
|
159
159
|
// appDomain: "https://starknetkit-blacked-listed.vercel.app", // to simulate blacklisted domain
|
|
160
160
|
};
|
|
161
|
-
},
|
|
162
|
-
const { transactions:
|
|
163
|
-
if (!
|
|
161
|
+
}, X = (t, e) => {
|
|
162
|
+
const { transactions: n } = t;
|
|
163
|
+
if (!n)
|
|
164
164
|
throw new G({ code: "SIMULATE_AND_REVIEW_FAILED" });
|
|
165
|
-
const a =
|
|
165
|
+
const a = n.map((i) => {
|
|
166
166
|
if (!i.simulation)
|
|
167
167
|
throw new G({ code: "SIMULATE_AND_REVIEW_FAILED" });
|
|
168
168
|
return i;
|
|
169
|
-
}),
|
|
169
|
+
}), o = a.map((i) => ({
|
|
170
170
|
...i.simulation,
|
|
171
171
|
feeEstimation: u(i.simulation.feeEstimation, Number)
|
|
172
|
-
})),
|
|
172
|
+
})), s = S(o, e), [m, c] = a.length === 1 ? [a[0], void 0] : [a[1], a[0]];
|
|
173
173
|
return {
|
|
174
|
-
...
|
|
174
|
+
...s,
|
|
175
175
|
transactions: {
|
|
176
|
-
...
|
|
177
|
-
dataGasConsumed:
|
|
178
|
-
dataGasPrice:
|
|
176
|
+
...s.transactions,
|
|
177
|
+
dataGasConsumed: s.transactions.dataGasConsumed ?? 0n,
|
|
178
|
+
dataGasPrice: s.transactions.dataGasPrice ?? 0n,
|
|
179
179
|
max: d(u(m.simulation.feeEstimation, r.toBigInt))
|
|
180
180
|
},
|
|
181
|
-
deployment:
|
|
182
|
-
...
|
|
183
|
-
dataGasConsumed:
|
|
184
|
-
dataGasPrice:
|
|
181
|
+
deployment: s.deployment && c ? {
|
|
182
|
+
...s.deployment,
|
|
183
|
+
dataGasConsumed: s.deployment.dataGasConsumed ?? 0n,
|
|
184
|
+
dataGasPrice: s.deployment.dataGasPrice ?? 0n,
|
|
185
185
|
max: d(u(c.simulation.feeEstimation, r.toBigInt))
|
|
186
186
|
} : void 0
|
|
187
187
|
};
|
|
188
|
-
},
|
|
189
|
-
|
|
188
|
+
}, D = (t) => ({
|
|
189
|
+
max_amount: r.toHex(t.amount),
|
|
190
|
+
max_price_per_unit: r.toHex(t.pricePerUnit)
|
|
191
|
+
}), R = (t, e, n) => ({
|
|
192
|
+
// (overall_fee / gas_price) × gas_safety_margin
|
|
193
|
+
max_amount: r.toHex(t / e),
|
|
194
|
+
// max_price_per_unit: gas_price × fee_safety_margin
|
|
195
|
+
max_price_per_unit: r.toHex(n)
|
|
196
|
+
}), Z = (t) => {
|
|
197
|
+
const e = U(t), n = P(t);
|
|
190
198
|
return {
|
|
191
199
|
// for v1 transactions
|
|
192
|
-
maxFee:
|
|
200
|
+
maxFee: n,
|
|
193
201
|
// for v3 transactions
|
|
194
202
|
resourceBounds: {
|
|
195
|
-
l1_gas:
|
|
196
|
-
|
|
197
|
-
max_amount: r.toHex(e / t.pricePerUnit),
|
|
198
|
-
// max_price_per_unit: gas_price × fee_safety_margin
|
|
199
|
-
max_price_per_unit: r.toHex(n.pricePerUnit)
|
|
200
|
-
},
|
|
201
|
-
l2_gas: {
|
|
202
|
-
max_amount: "0x0",
|
|
203
|
-
max_price_per_unit: "0x0"
|
|
204
|
-
}
|
|
203
|
+
l1_gas: ((o) => o !== void 0 && "amount" in o && "pricePerUnit" in o)(t.max) ? D(t.max) : R(n, t.pricePerUnit, e.pricePerUnit),
|
|
204
|
+
l2_gas: { max_amount: "0x0", max_price_per_unit: "0x0" }
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
|
-
},
|
|
208
|
-
const
|
|
209
|
-
return isNaN(
|
|
210
|
-
},
|
|
211
|
-
const
|
|
212
|
-
return isNaN(
|
|
213
|
-
},
|
|
207
|
+
}, tt = (t) => {
|
|
208
|
+
const e = Math.sqrt(t);
|
|
209
|
+
return isNaN(e) ? Math.sqrt(2) : e;
|
|
210
|
+
}, w = (t) => {
|
|
211
|
+
const e = Math.cbrt(t);
|
|
212
|
+
return isNaN(e) ? Math.cbrt(2) : e;
|
|
213
|
+
}, nt = (t) => t < 1 || isNaN(t) ? 1.1 : Math.log(t + 1) + 1;
|
|
214
214
|
export {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
215
|
+
J as buildDummyTx,
|
|
216
|
+
w as calculateCubeRootAdjustment,
|
|
217
|
+
nt as calculateNonLinearAdjustment,
|
|
218
|
+
tt as calculateSqrtAdjustment,
|
|
219
219
|
u as castFeeEstimation,
|
|
220
220
|
P as estimatedFeeToMaxFeeTotal,
|
|
221
|
-
|
|
221
|
+
Z as estimatedFeeToMaxResourceBounds,
|
|
222
222
|
p as estimatedFeeToTotal,
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
z as estimatedFeesToMaxFeeTotal,
|
|
224
|
+
$ as estimatedFeesToTotal,
|
|
225
225
|
S as getEstimatedFeeFromBulkSimulation,
|
|
226
|
-
|
|
227
|
-
|
|
226
|
+
X as getEstimatedFeeFromSimulationAndRespectWatermarkFee,
|
|
227
|
+
Q as getPayloadFromTransaction,
|
|
228
228
|
N as getWatermarkedMaxFeeTotal,
|
|
229
229
|
k as isFRI,
|
|
230
230
|
E as isWEI,
|
|
231
|
-
|
|
231
|
+
V as multiplyBigIntByFloat,
|
|
232
232
|
d as toMax,
|
|
233
|
-
|
|
233
|
+
Y as tokensRequireTxV3Support,
|
|
234
234
|
x as unitToFeeTokenAddress
|
|
235
235
|
};
|
|
@@ -5,15 +5,15 @@ import { AllowArray, Call, DeclareContractPayload, DeployAccountContractPayload,
|
|
|
5
5
|
* Same as EstimateFeeAction from starknet.js
|
|
6
6
|
*/
|
|
7
7
|
export type TransactionAction = {
|
|
8
|
-
type: TransactionType.INVOKE;
|
|
8
|
+
type: typeof TransactionType.INVOKE;
|
|
9
9
|
payload: AllowArray<Call>;
|
|
10
10
|
} | {
|
|
11
|
-
type: TransactionType.DECLARE;
|
|
11
|
+
type: typeof TransactionType.DECLARE;
|
|
12
12
|
payload: DeclareContractPayload;
|
|
13
13
|
} | {
|
|
14
|
-
type: TransactionType.DEPLOY_ACCOUNT;
|
|
14
|
+
type: typeof TransactionType.DEPLOY_ACCOUNT;
|
|
15
15
|
payload: DeployAccountContractPayload;
|
|
16
16
|
} | {
|
|
17
|
-
type: TransactionType.DEPLOY;
|
|
17
|
+
type: typeof TransactionType.DEPLOY;
|
|
18
18
|
payload: UniversalDeployerContractPayload;
|
|
19
19
|
};
|
|
@@ -14,7 +14,7 @@ export interface SimulationError extends Error {
|
|
|
14
14
|
url: string;
|
|
15
15
|
}
|
|
16
16
|
export interface SimulateDeployAccountRequest {
|
|
17
|
-
type: TransactionType.DEPLOY_ACCOUNT;
|
|
17
|
+
type: typeof TransactionType.DEPLOY_ACCOUNT;
|
|
18
18
|
classHash: string;
|
|
19
19
|
calldata: Calldata;
|
|
20
20
|
salt: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argent/x-shared",
|
|
3
|
-
"version": "1.56.
|
|
3
|
+
"version": "1.56.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/argentlabs/x-shared.git"
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@starknet-io/types-js": "^0.7.7",
|
|
74
74
|
"big-decimal-number": "npm:bignumber.js@^9.1.2",
|
|
75
75
|
"micro-starknet": "^0.2.3",
|
|
76
|
-
"starknet": "6.
|
|
76
|
+
"starknet": "6.21.1",
|
|
77
77
|
"starknet4-deprecated": "npm:starknet@4.4.0",
|
|
78
78
|
"starknet5": "npm:starknet@5.25.0"
|
|
79
79
|
},
|