@argent/x-shared 1.58.0 → 1.60.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 +224 -214
- package/dist/simulation.cjs +1 -1
- package/dist/simulation.js +68 -55
- package/dist/src/features/simulation/fees/schema.cjs +1 -1
- package/dist/src/features/simulation/fees/schema.d.ts +848 -0
- package/dist/src/features/simulation/fees/schema.js +36 -4
- package/dist/src/features/simulation/transactionReview/schema.cjs +1 -1
- package/dist/src/features/simulation/transactionReview/schema.d.ts +8264 -148
- package/dist/src/features/simulation/transactionReview/schema.js +105 -85
- package/dist/src/staking/schema.d.ts +24 -24
- package/dist/src/tokens/service/types/defiPosition.model.cjs +1 -1
- package/dist/src/tokens/service/types/defiPosition.model.d.ts +26 -0
- package/dist/src/tokens/service/types/defiPosition.model.js +12 -11
- package/dist/src/transactions/estimate/index.d.ts +1 -0
- package/dist/src/transactions/estimate/utilsV2.cjs +1 -0
- package/dist/src/transactions/estimate/utilsV2.d.ts +14 -0
- package/dist/src/transactions/estimate/utilsV2.js +96 -0
- package/dist/src/transactions/getTransactionVersion.cjs +1 -1
- package/dist/src/transactions/getTransactionVersion.d.ts +6 -0
- package/dist/src/transactions/getTransactionVersion.js +15 -12
- package/dist/src/transactions/txv3.cjs +1 -1
- package/dist/src/transactions/txv3.js +4 -4
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/type.utils.d.ts +215 -0
- package/package.json +3 -3
|
@@ -1576,6 +1576,7 @@ export declare const stakingPositionSchema: z.ZodObject<z.objectUtil.extendShape
|
|
|
1576
1576
|
ccyDayChange?: string | undefined;
|
|
1577
1577
|
currencySymbol?: string | undefined;
|
|
1578
1578
|
}>;
|
|
1579
|
+
liquidTokenAddress: z.ZodEffects<z.ZodPipeline<z.ZodString, z.ZodEffects<z.ZodString, string, string>>, `0x${string}`, string>;
|
|
1579
1580
|
}>, "strip", z.ZodTypeAny, {
|
|
1580
1581
|
id: string;
|
|
1581
1582
|
totalApy: number;
|
|
@@ -1605,6 +1606,7 @@ export declare const stakingPositionSchema: z.ZodObject<z.objectUtil.extendShape
|
|
|
1605
1606
|
eth: string;
|
|
1606
1607
|
currency: string;
|
|
1607
1608
|
};
|
|
1609
|
+
liquidTokenAddress: `0x${string}`;
|
|
1608
1610
|
address?: `0x${string}` | undefined;
|
|
1609
1611
|
}, {
|
|
1610
1612
|
id: string;
|
|
@@ -1634,6 +1636,7 @@ export declare const stakingPositionSchema: z.ZodObject<z.objectUtil.extendShape
|
|
|
1634
1636
|
eth: string;
|
|
1635
1637
|
currency: string;
|
|
1636
1638
|
};
|
|
1639
|
+
liquidTokenAddress: string;
|
|
1637
1640
|
address?: string | undefined;
|
|
1638
1641
|
currencyValue?: string | undefined;
|
|
1639
1642
|
}>;
|
|
@@ -1726,6 +1729,7 @@ export declare const stakingPositionsSchema: z.ZodArray<z.ZodObject<z.objectUtil
|
|
|
1726
1729
|
ccyDayChange?: string | undefined;
|
|
1727
1730
|
currencySymbol?: string | undefined;
|
|
1728
1731
|
}>;
|
|
1732
|
+
liquidTokenAddress: z.ZodEffects<z.ZodPipeline<z.ZodString, z.ZodEffects<z.ZodString, string, string>>, `0x${string}`, string>;
|
|
1729
1733
|
}>, "strip", z.ZodTypeAny, {
|
|
1730
1734
|
id: string;
|
|
1731
1735
|
totalApy: number;
|
|
@@ -1755,6 +1759,7 @@ export declare const stakingPositionsSchema: z.ZodArray<z.ZodObject<z.objectUtil
|
|
|
1755
1759
|
eth: string;
|
|
1756
1760
|
currency: string;
|
|
1757
1761
|
};
|
|
1762
|
+
liquidTokenAddress: `0x${string}`;
|
|
1758
1763
|
address?: `0x${string}` | undefined;
|
|
1759
1764
|
}, {
|
|
1760
1765
|
id: string;
|
|
@@ -1784,6 +1789,7 @@ export declare const stakingPositionsSchema: z.ZodArray<z.ZodObject<z.objectUtil
|
|
|
1784
1789
|
eth: string;
|
|
1785
1790
|
currency: string;
|
|
1786
1791
|
};
|
|
1792
|
+
liquidTokenAddress: string;
|
|
1787
1793
|
address?: string | undefined;
|
|
1788
1794
|
currencyValue?: string | undefined;
|
|
1789
1795
|
}>, "many">;
|
|
@@ -3224,6 +3230,7 @@ export declare const defiPositionSchema: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.Z
|
|
|
3224
3230
|
ccyDayChange?: string | undefined;
|
|
3225
3231
|
currencySymbol?: string | undefined;
|
|
3226
3232
|
}>;
|
|
3233
|
+
liquidTokenAddress: z.ZodEffects<z.ZodPipeline<z.ZodString, z.ZodEffects<z.ZodString, string, string>>, `0x${string}`, string>;
|
|
3227
3234
|
}>, "strip", z.ZodTypeAny, {
|
|
3228
3235
|
id: string;
|
|
3229
3236
|
totalApy: number;
|
|
@@ -3253,6 +3260,7 @@ export declare const defiPositionSchema: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.Z
|
|
|
3253
3260
|
eth: string;
|
|
3254
3261
|
currency: string;
|
|
3255
3262
|
};
|
|
3263
|
+
liquidTokenAddress: `0x${string}`;
|
|
3256
3264
|
address?: `0x${string}` | undefined;
|
|
3257
3265
|
}, {
|
|
3258
3266
|
id: string;
|
|
@@ -3282,6 +3290,7 @@ export declare const defiPositionSchema: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.Z
|
|
|
3282
3290
|
eth: string;
|
|
3283
3291
|
currency: string;
|
|
3284
3292
|
};
|
|
3293
|
+
liquidTokenAddress: string;
|
|
3285
3294
|
address?: string | undefined;
|
|
3286
3295
|
currencyValue?: string | undefined;
|
|
3287
3296
|
}>]>;
|
|
@@ -4301,6 +4310,7 @@ export declare const defiProductSchema: z.ZodObject<{
|
|
|
4301
4310
|
ccyDayChange?: string | undefined;
|
|
4302
4311
|
currencySymbol?: string | undefined;
|
|
4303
4312
|
}>;
|
|
4313
|
+
liquidTokenAddress: z.ZodEffects<z.ZodPipeline<z.ZodString, z.ZodEffects<z.ZodString, string, string>>, `0x${string}`, string>;
|
|
4304
4314
|
}>, "strip", z.ZodTypeAny, {
|
|
4305
4315
|
id: string;
|
|
4306
4316
|
totalApy: number;
|
|
@@ -4330,6 +4340,7 @@ export declare const defiProductSchema: z.ZodObject<{
|
|
|
4330
4340
|
eth: string;
|
|
4331
4341
|
currency: string;
|
|
4332
4342
|
};
|
|
4343
|
+
liquidTokenAddress: `0x${string}`;
|
|
4333
4344
|
address?: `0x${string}` | undefined;
|
|
4334
4345
|
}, {
|
|
4335
4346
|
id: string;
|
|
@@ -4359,6 +4370,7 @@ export declare const defiProductSchema: z.ZodObject<{
|
|
|
4359
4370
|
eth: string;
|
|
4360
4371
|
currency: string;
|
|
4361
4372
|
};
|
|
4373
|
+
liquidTokenAddress: string;
|
|
4362
4374
|
address?: string | undefined;
|
|
4363
4375
|
currencyValue?: string | undefined;
|
|
4364
4376
|
}>]>, "many">;
|
|
@@ -4548,6 +4560,7 @@ export declare const defiProductSchema: z.ZodObject<{
|
|
|
4548
4560
|
eth: string;
|
|
4549
4561
|
currency: string;
|
|
4550
4562
|
};
|
|
4563
|
+
liquidTokenAddress: `0x${string}`;
|
|
4551
4564
|
address?: `0x${string}` | undefined;
|
|
4552
4565
|
} | {
|
|
4553
4566
|
id: string;
|
|
@@ -4772,6 +4785,7 @@ export declare const defiProductSchema: z.ZodObject<{
|
|
|
4772
4785
|
eth: string;
|
|
4773
4786
|
currency: string;
|
|
4774
4787
|
};
|
|
4788
|
+
liquidTokenAddress: string;
|
|
4775
4789
|
address?: string | undefined;
|
|
4776
4790
|
currencyValue?: string | undefined;
|
|
4777
4791
|
} | {
|
|
@@ -5832,6 +5846,7 @@ export declare const defiProductsSchema: z.ZodArray<z.ZodObject<{
|
|
|
5832
5846
|
ccyDayChange?: string | undefined;
|
|
5833
5847
|
currencySymbol?: string | undefined;
|
|
5834
5848
|
}>;
|
|
5849
|
+
liquidTokenAddress: z.ZodEffects<z.ZodPipeline<z.ZodString, z.ZodEffects<z.ZodString, string, string>>, `0x${string}`, string>;
|
|
5835
5850
|
}>, "strip", z.ZodTypeAny, {
|
|
5836
5851
|
id: string;
|
|
5837
5852
|
totalApy: number;
|
|
@@ -5861,6 +5876,7 @@ export declare const defiProductsSchema: z.ZodArray<z.ZodObject<{
|
|
|
5861
5876
|
eth: string;
|
|
5862
5877
|
currency: string;
|
|
5863
5878
|
};
|
|
5879
|
+
liquidTokenAddress: `0x${string}`;
|
|
5864
5880
|
address?: `0x${string}` | undefined;
|
|
5865
5881
|
}, {
|
|
5866
5882
|
id: string;
|
|
@@ -5890,6 +5906,7 @@ export declare const defiProductsSchema: z.ZodArray<z.ZodObject<{
|
|
|
5890
5906
|
eth: string;
|
|
5891
5907
|
currency: string;
|
|
5892
5908
|
};
|
|
5909
|
+
liquidTokenAddress: string;
|
|
5893
5910
|
address?: string | undefined;
|
|
5894
5911
|
currencyValue?: string | undefined;
|
|
5895
5912
|
}>]>, "many">;
|
|
@@ -6079,6 +6096,7 @@ export declare const defiProductsSchema: z.ZodArray<z.ZodObject<{
|
|
|
6079
6096
|
eth: string;
|
|
6080
6097
|
currency: string;
|
|
6081
6098
|
};
|
|
6099
|
+
liquidTokenAddress: `0x${string}`;
|
|
6082
6100
|
address?: `0x${string}` | undefined;
|
|
6083
6101
|
} | {
|
|
6084
6102
|
id: string;
|
|
@@ -6303,6 +6321,7 @@ export declare const defiProductsSchema: z.ZodArray<z.ZodObject<{
|
|
|
6303
6321
|
eth: string;
|
|
6304
6322
|
currency: string;
|
|
6305
6323
|
};
|
|
6324
|
+
liquidTokenAddress: string;
|
|
6306
6325
|
address?: string | undefined;
|
|
6307
6326
|
currencyValue?: string | undefined;
|
|
6308
6327
|
} | {
|
|
@@ -7365,6 +7384,7 @@ export declare const defiDappsProductsSchema: z.ZodObject<{
|
|
|
7365
7384
|
ccyDayChange?: string | undefined;
|
|
7366
7385
|
currencySymbol?: string | undefined;
|
|
7367
7386
|
}>;
|
|
7387
|
+
liquidTokenAddress: z.ZodEffects<z.ZodPipeline<z.ZodString, z.ZodEffects<z.ZodString, string, string>>, `0x${string}`, string>;
|
|
7368
7388
|
}>, "strip", z.ZodTypeAny, {
|
|
7369
7389
|
id: string;
|
|
7370
7390
|
totalApy: number;
|
|
@@ -7394,6 +7414,7 @@ export declare const defiDappsProductsSchema: z.ZodObject<{
|
|
|
7394
7414
|
eth: string;
|
|
7395
7415
|
currency: string;
|
|
7396
7416
|
};
|
|
7417
|
+
liquidTokenAddress: `0x${string}`;
|
|
7397
7418
|
address?: `0x${string}` | undefined;
|
|
7398
7419
|
}, {
|
|
7399
7420
|
id: string;
|
|
@@ -7423,6 +7444,7 @@ export declare const defiDappsProductsSchema: z.ZodObject<{
|
|
|
7423
7444
|
eth: string;
|
|
7424
7445
|
currency: string;
|
|
7425
7446
|
};
|
|
7447
|
+
liquidTokenAddress: string;
|
|
7426
7448
|
address?: string | undefined;
|
|
7427
7449
|
currencyValue?: string | undefined;
|
|
7428
7450
|
}>]>, "many">;
|
|
@@ -7612,6 +7634,7 @@ export declare const defiDappsProductsSchema: z.ZodObject<{
|
|
|
7612
7634
|
eth: string;
|
|
7613
7635
|
currency: string;
|
|
7614
7636
|
};
|
|
7637
|
+
liquidTokenAddress: `0x${string}`;
|
|
7615
7638
|
address?: `0x${string}` | undefined;
|
|
7616
7639
|
} | {
|
|
7617
7640
|
id: string;
|
|
@@ -7836,6 +7859,7 @@ export declare const defiDappsProductsSchema: z.ZodObject<{
|
|
|
7836
7859
|
eth: string;
|
|
7837
7860
|
currency: string;
|
|
7838
7861
|
};
|
|
7862
|
+
liquidTokenAddress: string;
|
|
7839
7863
|
address?: string | undefined;
|
|
7840
7864
|
currencyValue?: string | undefined;
|
|
7841
7865
|
} | {
|
|
@@ -8065,6 +8089,7 @@ export declare const defiDappsProductsSchema: z.ZodObject<{
|
|
|
8065
8089
|
eth: string;
|
|
8066
8090
|
currency: string;
|
|
8067
8091
|
};
|
|
8092
|
+
liquidTokenAddress: `0x${string}`;
|
|
8068
8093
|
address?: `0x${string}` | undefined;
|
|
8069
8094
|
} | {
|
|
8070
8095
|
id: string;
|
|
@@ -8292,6 +8317,7 @@ export declare const defiDappsProductsSchema: z.ZodObject<{
|
|
|
8292
8317
|
eth: string;
|
|
8293
8318
|
currency: string;
|
|
8294
8319
|
};
|
|
8320
|
+
liquidTokenAddress: string;
|
|
8295
8321
|
address?: string | undefined;
|
|
8296
8322
|
currencyValue?: string | undefined;
|
|
8297
8323
|
} | {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z as t } from "zod";
|
|
2
2
|
import { addressSchema as o } from "../../../chains/starknet/address.js";
|
|
3
3
|
import { apiTokenInfoSchema as p, apiStrkDelegatedStakingSchema as g } from "./backend.model.js";
|
|
4
|
-
import { defiPositionTypeSchema as
|
|
4
|
+
import { defiPositionTypeSchema as u } from "./defiPositionType.model.js";
|
|
5
5
|
import { webTokenWithBalanceAndPriceSchema as e } from "./webToken.model.js";
|
|
6
6
|
const i = e.extend({
|
|
7
7
|
accruedFees: t.string(),
|
|
@@ -51,7 +51,8 @@ const i = e.extend({
|
|
|
51
51
|
total: a,
|
|
52
52
|
apy: t.number(),
|
|
53
53
|
totalApy: t.number(),
|
|
54
|
-
token: e
|
|
54
|
+
token: e,
|
|
55
|
+
liquidTokenAddress: o
|
|
55
56
|
}), V = t.array(l), d = n.extend({
|
|
56
57
|
id: t.string(),
|
|
57
58
|
accruedRewards: a,
|
|
@@ -61,23 +62,23 @@ const i = e.extend({
|
|
|
61
62
|
totalApy: t.number(),
|
|
62
63
|
stakerInfo: g.shape.data.shape.stakerInfo,
|
|
63
64
|
token: e
|
|
64
|
-
}), C = t.array(d),
|
|
65
|
+
}), C = t.array(d), m = r.or(s).or(c).or(d).or(l), h = t.record(t.object({
|
|
65
66
|
name: t.string().optional(),
|
|
66
67
|
healthRatio: t.string().optional(),
|
|
67
68
|
accountAddress: o.optional()
|
|
68
|
-
})),
|
|
69
|
-
type:
|
|
69
|
+
})), k = t.object({
|
|
70
|
+
type: u,
|
|
70
71
|
manageUrl: t.string().url().optional(),
|
|
71
72
|
name: t.string(),
|
|
72
|
-
positions: t.array(
|
|
73
|
+
positions: t.array(m),
|
|
73
74
|
// other types will be added when available from be
|
|
74
75
|
positionsTotalValue: t.string(),
|
|
75
76
|
brandColor: t.string().optional(),
|
|
76
77
|
groups: h.optional(),
|
|
77
78
|
accountAddress: o
|
|
78
|
-
}),
|
|
79
|
+
}), S = t.array(k), I = t.object({
|
|
79
80
|
dappId: t.string(),
|
|
80
|
-
products:
|
|
81
|
+
products: S
|
|
81
82
|
});
|
|
82
83
|
export {
|
|
83
84
|
x as collateralizedDebtGroupSchema,
|
|
@@ -86,9 +87,9 @@ export {
|
|
|
86
87
|
r as concentratedLiquidityPositionSchema,
|
|
87
88
|
T as concentratedLiquidityPositionsSchema,
|
|
88
89
|
I as defiDappsProductsSchema,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
m as defiPositionSchema,
|
|
91
|
+
k as defiProductSchema,
|
|
92
|
+
S as defiProductsSchema,
|
|
92
93
|
j as delegatedTokensArraySchema,
|
|
93
94
|
c as delegatedTokensSchema,
|
|
94
95
|
h as productGroupsSchema,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("lodash-es"),m=require("starknet"),l=require("./error.cjs"),o=require("./utils.cjs"),c=require("../../chains/starknet/constants.cjs"),A=require("../../chains/starknet/address.cjs"),v=e=>{const{transactions:t}=e;if(!t)throw new l.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});const n=t.map(s=>{if(!s.simulation)throw new l.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});const{nativeFeeEstimation:u,paymasterFeeEstimations:T}=g(s.simulation.feeEstimations);return{...s.simulation,feeEstimation:u,paymasterFeeEstimations:T}}),a=o.getEstimatedFeeFromBulkSimulation(n),[r,d]=n.length===1?[n[0],void 0]:[n[1],n[0]],y=E(a.transactions,r),F=a.deployment&&d?E(a.deployment,d):void 0;return[{type:"native",transactions:y,deployment:F},...p(n)]},E=(e,t)=>({...e,dataGasConsumed:e.dataGasConsumed??0n,dataGasPrice:e.dataGasPrice??0n,max:o.toMax(o.castFeeEstimation(t.feeEstimation,m.num.toBigInt))}),g=e=>{const[t,n]=f.partition(e,a=>"unit"in a&&(a.unit==="FRI"||a.unit==="WEI"));return{nativeFeeEstimation:t[0],paymasterFeeEstimations:n}},p=e=>{if(!e)return[];if(!Array.isArray(e))throw Error(`Unexpected simulation response. Expected array. Got ${typeof e}`);if(e.length===1)return e[0].paymasterFeeEstimations.map(t=>({type:"paymaster",transactions:i(t),deployment:void 0}));if(e.length===2){const t=e[0].paymasterFeeEstimations,n=e[1].paymasterFeeEstimations;if(t.length!==n.length)throw Error("Deployment and transaction fee estimations length mismatch");return n.map((a,r)=>({type:"paymaster",transactions:i(a),deployment:i(t[r])}))}throw Error("Unexpected simulation response length")},i=e=>({feeTokenAddress:e.token.address,maxFee:BigInt(e.maxFee),overallFee:BigInt(e.overallFee)}),S=e=>{var a;if(e.type==="paymaster")return e.transactions.maxFee+(((a=e.deployment)==null?void 0:a.maxFee)??0n);if(e.deployment&&!A.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=e.deployment?o.estimatedFeeToMaxFeeTotal(e.deployment):0n,n=o.estimatedFeeToMaxFeeTotal(e.transactions);return t+n},N=e=>{var t;return e.type==="paymaster"?e.transactions.overallFee+(((t=e.deployment)==null?void 0:t.overallFee)??0n):o.estimatedFeeToTotal(e.transactions)},h=e=>{const t=e==null?void 0:e.find(n=>n.type==="native");return t||{type:"native",transactions:{amount:0n,feeTokenAddress:c.STRK_TOKEN_ADDRESS,pricePerUnit:0n}}},I=e=>e.filter(t=>t.type==="paymaster"),_=e=>e===m.constants.TRANSACTION_VERSION.V1||e===m.constants.TRANSACTION_VERSION.F1?c.ETH_TOKEN_ADDRESS:c.STRK_TOKEN_ADDRESS;exports.estimatedFeesToMaxFeeTotalV2=S;exports.estimatedFeesToTotalV2=N;exports.filterPaymasterEstimatedFees=I;exports.getEstimatedFeeFromSimulationAndRespectWatermarkFeeV2=v;exports.getNativeEstimatedFees=h;exports.getNativeFeeTokenAddress=_;exports.getPaymasterFeeFromSimulation=p;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Address } from '../../chains';
|
|
2
|
+
import { PaymasterFeeEstimation, SimulateAndReview } from '../../features/simulation';
|
|
3
|
+
import { EstimatedFeesV2, NativeEstimatedFees, PaymasterEstimatedFees } from '../../features/simulation/fees/schema';
|
|
4
|
+
import { StrictOmit } from '../../utils/type.utils';
|
|
5
|
+
import { TransactionVersion } from '../transactionVersion';
|
|
6
|
+
export declare const getEstimatedFeeFromSimulationAndRespectWatermarkFeeV2: (simulateAndReviewResult: Pick<SimulateAndReview, "transactions">) => EstimatedFeesV2[];
|
|
7
|
+
export declare const getPaymasterFeeFromSimulation: (simulation: {
|
|
8
|
+
paymasterFeeEstimations: PaymasterFeeEstimation[];
|
|
9
|
+
}[]) => EstimatedFeesV2[];
|
|
10
|
+
export declare const estimatedFeesToMaxFeeTotalV2: (estimatedFees: EstimatedFeesV2) => bigint;
|
|
11
|
+
export declare const estimatedFeesToTotalV2: (estimatedFees: EstimatedFeesV2) => bigint;
|
|
12
|
+
export declare const getNativeEstimatedFees: (estimatedFees?: EstimatedFeesV2[]) => NativeEstimatedFees;
|
|
13
|
+
export declare const filterPaymasterEstimatedFees: (estimatedFees: EstimatedFeesV2[]) => StrictOmit<PaymasterEstimatedFees, "type">[];
|
|
14
|
+
export declare const getNativeFeeTokenAddress: (transactionVersion: TransactionVersion) => Address;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { partition as u } from "lodash-es";
|
|
2
|
+
import { num as T, constants as m } from "starknet";
|
|
3
|
+
import { EstimateError as c } from "./error.js";
|
|
4
|
+
import { getEstimatedFeeFromBulkSimulation as A, toMax as v, castFeeEstimation as g, estimatedFeeToMaxFeeTotal as p, estimatedFeeToTotal as I } from "./utils.js";
|
|
5
|
+
import { STRK_TOKEN_ADDRESS as E, ETH_TOKEN_ADDRESS as h } from "../../chains/starknet/constants.js";
|
|
6
|
+
import { isEqualAddress as N } from "../../chains/starknet/address.js";
|
|
7
|
+
const O = (t) => {
|
|
8
|
+
const { transactions: e } = t;
|
|
9
|
+
if (!e)
|
|
10
|
+
throw new c({ code: "SIMULATE_AND_REVIEW_FAILED" });
|
|
11
|
+
const n = e.map((r) => {
|
|
12
|
+
if (!r.simulation)
|
|
13
|
+
throw new c({ code: "SIMULATE_AND_REVIEW_FAILED" });
|
|
14
|
+
const { nativeFeeEstimation: F, paymasterFeeEstimations: f } = S(r.simulation.feeEstimations);
|
|
15
|
+
return {
|
|
16
|
+
...r.simulation,
|
|
17
|
+
feeEstimation: F,
|
|
18
|
+
paymasterFeeEstimations: f
|
|
19
|
+
};
|
|
20
|
+
}), a = A(n), [o, i] = n.length === 1 ? [n[0], void 0] : [n[1], n[0]], l = d(a.transactions, o), y = a.deployment && i ? d(a.deployment, i) : void 0;
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
type: "native",
|
|
24
|
+
transactions: l,
|
|
25
|
+
deployment: y
|
|
26
|
+
},
|
|
27
|
+
..._(n)
|
|
28
|
+
];
|
|
29
|
+
}, d = (t, e) => ({
|
|
30
|
+
...t,
|
|
31
|
+
dataGasConsumed: t.dataGasConsumed ?? 0n,
|
|
32
|
+
dataGasPrice: t.dataGasPrice ?? 0n,
|
|
33
|
+
max: v(g(e.feeEstimation, T.toBigInt))
|
|
34
|
+
}), S = (t) => {
|
|
35
|
+
const [e, n] = u(t, (a) => "unit" in a && (a.unit === "FRI" || a.unit === "WEI"));
|
|
36
|
+
return {
|
|
37
|
+
nativeFeeEstimation: e[0],
|
|
38
|
+
paymasterFeeEstimations: n
|
|
39
|
+
};
|
|
40
|
+
}, _ = (t) => {
|
|
41
|
+
if (!t)
|
|
42
|
+
return [];
|
|
43
|
+
if (!Array.isArray(t))
|
|
44
|
+
throw Error(`Unexpected simulation response. Expected array. Got ${typeof t}`);
|
|
45
|
+
if (t.length === 1)
|
|
46
|
+
return t[0].paymasterFeeEstimations.map((e) => ({
|
|
47
|
+
type: "paymaster",
|
|
48
|
+
transactions: s(e),
|
|
49
|
+
deployment: void 0
|
|
50
|
+
}));
|
|
51
|
+
if (t.length === 2) {
|
|
52
|
+
const e = t[0].paymasterFeeEstimations, n = t[1].paymasterFeeEstimations;
|
|
53
|
+
if (e.length !== n.length)
|
|
54
|
+
throw Error("Deployment and transaction fee estimations length mismatch");
|
|
55
|
+
return n.map((a, o) => ({
|
|
56
|
+
type: "paymaster",
|
|
57
|
+
transactions: s(a),
|
|
58
|
+
deployment: s(e[o])
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
throw Error("Unexpected simulation response length");
|
|
62
|
+
}, s = (t) => ({
|
|
63
|
+
feeTokenAddress: t.token.address,
|
|
64
|
+
maxFee: BigInt(t.maxFee),
|
|
65
|
+
overallFee: BigInt(t.overallFee)
|
|
66
|
+
}), P = (t) => {
|
|
67
|
+
var a;
|
|
68
|
+
if (t.type === "paymaster")
|
|
69
|
+
return t.transactions.maxFee + (((a = t.deployment) == null ? void 0 : a.maxFee) ?? 0n);
|
|
70
|
+
if (t.deployment && !N(t.deployment.feeTokenAddress, t.transactions.feeTokenAddress))
|
|
71
|
+
throw Error("Cannot calculate estimated fees for different tokens");
|
|
72
|
+
const e = t.deployment ? p(t.deployment) : 0n, n = p(t.transactions);
|
|
73
|
+
return e + n;
|
|
74
|
+
}, U = (t) => {
|
|
75
|
+
var e;
|
|
76
|
+
return t.type === "paymaster" ? t.transactions.overallFee + (((e = t.deployment) == null ? void 0 : e.overallFee) ?? 0n) : I(t.transactions);
|
|
77
|
+
}, C = (t) => {
|
|
78
|
+
const e = t == null ? void 0 : t.find((n) => n.type === "native");
|
|
79
|
+
return e || {
|
|
80
|
+
type: "native",
|
|
81
|
+
transactions: {
|
|
82
|
+
amount: 0n,
|
|
83
|
+
feeTokenAddress: E,
|
|
84
|
+
pricePerUnit: 0n
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}, G = (t) => t.filter((e) => e.type === "paymaster"), M = (t) => t === m.TRANSACTION_VERSION.V1 || t === m.TRANSACTION_VERSION.F1 ? h : E;
|
|
88
|
+
export {
|
|
89
|
+
P as estimatedFeesToMaxFeeTotalV2,
|
|
90
|
+
U as estimatedFeesToTotalV2,
|
|
91
|
+
G as filterPaymasterEstimatedFees,
|
|
92
|
+
O as getEstimatedFeeFromSimulationAndRespectWatermarkFeeV2,
|
|
93
|
+
C as getNativeEstimatedFees,
|
|
94
|
+
M as getNativeFeeTokenAddress,
|
|
95
|
+
_ as getPaymasterFeeFromSimulation
|
|
96
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("starknet"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("starknet"),n=require("./txv3.cjs");function r(t){return n.feeTokenNeedsTxV3Support({address:t})?e.constants.TRANSACTION_VERSION.V3:e.constants.TRANSACTION_VERSION.V1}function s(t){return n.feeTokenNeedsTxV3Support({address:t})?e.constants.TRANSACTION_VERSION.F3:e.constants.TRANSACTION_VERSION.F1}function T(t,o){return e.isSierra(o.contract)?n.feeTokenNeedsTxV3Support({address:t})?e.constants.TRANSACTION_VERSION.V3:e.constants.TRANSACTION_VERSION.V2:e.constants.TRANSACTION_VERSION.V1}const N=({classHash:t})=>t&&!n.classHashSupportsTxV3(t)?e.constants.TRANSACTION_VERSION.V1:e.constants.TRANSACTION_VERSION.V3,c=({classHash:t},o)=>e.isSierra(o.contract)?t&&!n.classHashSupportsTxV3(t)?e.constants.TRANSACTION_VERSION.V2:e.constants.TRANSACTION_VERSION.V3:e.constants.TRANSACTION_VERSION.V1;exports.getAccountTxVersion=N;exports.getSimulationTxVersionFromFeeToken=s;exports.getTxVersionForDeclareContract=c;exports.getTxVersionFromFeeToken=r;exports.getTxVersionFromFeeTokenForDeclareContract=T;
|
|
@@ -4,3 +4,9 @@ import { TransactionInvokeVersion, TransactionSimulationVersion } from './transa
|
|
|
4
4
|
export declare function getTxVersionFromFeeToken(feeTokenAddress: Address): TransactionInvokeVersion;
|
|
5
5
|
export declare function getSimulationTxVersionFromFeeToken(feeTokenAddress: Address): TransactionSimulationVersion;
|
|
6
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,18 +1,21 @@
|
|
|
1
|
-
import { constants as
|
|
2
|
-
import { feeTokenNeedsTxV3Support as
|
|
3
|
-
function S(
|
|
4
|
-
return
|
|
5
|
-
address:
|
|
6
|
-
}) ?
|
|
1
|
+
import { constants as r, isSierra as T } from "starknet";
|
|
2
|
+
import { feeTokenNeedsTxV3Support as t, classHashSupportsTxV3 as n } from "./txv3.js";
|
|
3
|
+
function S(e) {
|
|
4
|
+
return t({
|
|
5
|
+
address: e
|
|
6
|
+
}) ? r.TRANSACTION_VERSION.V3 : r.TRANSACTION_VERSION.V1;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
return
|
|
8
|
+
function A(e) {
|
|
9
|
+
return t({ address: e }) ? r.TRANSACTION_VERSION.F3 : r.TRANSACTION_VERSION.F1;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return N
|
|
11
|
+
function I(e, N) {
|
|
12
|
+
return T(N.contract) ? t({ address: e }) ? r.TRANSACTION_VERSION.V3 : r.TRANSACTION_VERSION.V2 : r.TRANSACTION_VERSION.V1;
|
|
13
13
|
}
|
|
14
|
+
const O = ({ classHash: e }) => e && !n(e) ? r.TRANSACTION_VERSION.V1 : r.TRANSACTION_VERSION.V3, R = ({ classHash: e }, N) => T(N.contract) ? e && !n(e) ? r.TRANSACTION_VERSION.V2 : r.TRANSACTION_VERSION.V3 : r.TRANSACTION_VERSION.V1;
|
|
14
15
|
export {
|
|
15
|
-
|
|
16
|
+
O as getAccountTxVersion,
|
|
17
|
+
A as getSimulationTxVersionFromFeeToken,
|
|
18
|
+
R as getTxVersionForDeclareContract,
|
|
16
19
|
S as getTxVersionFromFeeToken,
|
|
17
|
-
|
|
20
|
+
I as getTxVersionFromFeeTokenForDeclareContract
|
|
18
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chains/starknet/
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chains/starknet/services/deploymentData/getAccountClassHash.cjs"),o=require("../chains/starknet/constants.cjs"),t=require("../chains/starknet/address.cjs"),u=[o.STRK_TOKEN_ADDRESS];function n({address:e}){return u.some(s=>t.isEqualAddress(e,s))}function a(e){return e?r.getArgentAccountClassHashesWithTxV3Support().some(s=>t.isEqualAddress(s,e)):!1}exports.classHashSupportsTxV3=a;exports.feeTokenNeedsTxV3Support=n;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getArgentAccountClassHashesWithTxV3Support as t } from "../chains/starknet/services/deploymentData/getAccountClassHash.js";
|
|
2
|
+
import { STRK_TOKEN_ADDRESS as s } from "../chains/starknet/constants.js";
|
|
3
3
|
import { isEqualAddress as o } from "../chains/starknet/address.js";
|
|
4
|
-
const n = [
|
|
4
|
+
const n = [s];
|
|
5
5
|
function f({ address: r }) {
|
|
6
6
|
return n.some((e) => o(r, e));
|
|
7
7
|
}
|
|
8
8
|
function m(r) {
|
|
9
|
-
return r ?
|
|
9
|
+
return r ? t().some((e) => o(e, r)) : !1;
|
|
10
10
|
}
|
|
11
11
|
export {
|
|
12
12
|
m as classHashSupportsTxV3,
|