@argent/x-shared 1.55.0 → 1.56.1

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.
@@ -5017,6 +5017,9 @@ export declare const nativeActivityMetaSchema: z.ZodObject<{
5017
5017
  /** let's not import the keys from x-ui here */
5018
5018
  icon: z.ZodOptional<z.ZodString>;
5019
5019
  investment: z.ZodOptional<z.ZodObject<{
5020
+ useFullBalance: z.ZodOptional<z.ZodBoolean>;
5021
+ subsequentTransaction: z.ZodOptional<z.ZodBoolean>;
5022
+ investmentId: z.ZodOptional<z.ZodString>;
5020
5023
  stakingAction: z.ZodEnum<["deposit", "stake", "initiateWithdraw", "withdraw", "claim"]>;
5021
5024
  stakerInfo: z.ZodObject<{
5022
5025
  name: z.ZodOptional<z.ZodString>;
@@ -5042,6 +5045,9 @@ export declare const nativeActivityMetaSchema: z.ZodObject<{
5042
5045
  iconUrl?: string | undefined;
5043
5046
  };
5044
5047
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
5048
+ investmentId?: string | undefined;
5049
+ useFullBalance?: boolean | undefined;
5050
+ subsequentTransaction?: boolean | undefined;
5045
5051
  }, {
5046
5052
  amount: string;
5047
5053
  tokenAddress: string;
@@ -5051,6 +5057,9 @@ export declare const nativeActivityMetaSchema: z.ZodObject<{
5051
5057
  iconUrl?: string | undefined;
5052
5058
  };
5053
5059
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
5060
+ investmentId?: string | undefined;
5061
+ useFullBalance?: boolean | undefined;
5062
+ subsequentTransaction?: boolean | undefined;
5054
5063
  }>>;
5055
5064
  isExecuteFromOutside: z.ZodOptional<z.ZodBoolean>;
5056
5065
  }, "strip", z.ZodTypeAny, {
@@ -5067,6 +5076,9 @@ export declare const nativeActivityMetaSchema: z.ZodObject<{
5067
5076
  iconUrl?: string | undefined;
5068
5077
  };
5069
5078
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
5079
+ investmentId?: string | undefined;
5080
+ useFullBalance?: boolean | undefined;
5081
+ subsequentTransaction?: boolean | undefined;
5070
5082
  } | undefined;
5071
5083
  isExecuteFromOutside?: boolean | undefined;
5072
5084
  }, {
@@ -5083,6 +5095,9 @@ export declare const nativeActivityMetaSchema: z.ZodObject<{
5083
5095
  iconUrl?: string | undefined;
5084
5096
  };
5085
5097
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
5098
+ investmentId?: string | undefined;
5099
+ useFullBalance?: boolean | undefined;
5100
+ subsequentTransaction?: boolean | undefined;
5086
5101
  } | undefined;
5087
5102
  isExecuteFromOutside?: boolean | undefined;
5088
5103
  }>;
@@ -7606,6 +7621,9 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7606
7621
  /** let's not import the keys from x-ui here */
7607
7622
  icon: z.ZodOptional<z.ZodString>;
7608
7623
  investment: z.ZodOptional<z.ZodObject<{
7624
+ useFullBalance: z.ZodOptional<z.ZodBoolean>;
7625
+ subsequentTransaction: z.ZodOptional<z.ZodBoolean>;
7626
+ investmentId: z.ZodOptional<z.ZodString>;
7609
7627
  stakingAction: z.ZodEnum<["deposit", "stake", "initiateWithdraw", "withdraw", "claim"]>;
7610
7628
  stakerInfo: z.ZodObject<{
7611
7629
  name: z.ZodOptional<z.ZodString>;
@@ -7631,6 +7649,9 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7631
7649
  iconUrl?: string | undefined;
7632
7650
  };
7633
7651
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
7652
+ investmentId?: string | undefined;
7653
+ useFullBalance?: boolean | undefined;
7654
+ subsequentTransaction?: boolean | undefined;
7634
7655
  }, {
7635
7656
  amount: string;
7636
7657
  tokenAddress: string;
@@ -7640,6 +7661,9 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7640
7661
  iconUrl?: string | undefined;
7641
7662
  };
7642
7663
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
7664
+ investmentId?: string | undefined;
7665
+ useFullBalance?: boolean | undefined;
7666
+ subsequentTransaction?: boolean | undefined;
7643
7667
  }>>;
7644
7668
  isExecuteFromOutside: z.ZodOptional<z.ZodBoolean>;
7645
7669
  }, "strip", z.ZodTypeAny, {
@@ -7656,6 +7680,9 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7656
7680
  iconUrl?: string | undefined;
7657
7681
  };
7658
7682
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
7683
+ investmentId?: string | undefined;
7684
+ useFullBalance?: boolean | undefined;
7685
+ subsequentTransaction?: boolean | undefined;
7659
7686
  } | undefined;
7660
7687
  isExecuteFromOutside?: boolean | undefined;
7661
7688
  }, {
@@ -7672,6 +7699,9 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7672
7699
  iconUrl?: string | undefined;
7673
7700
  };
7674
7701
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
7702
+ investmentId?: string | undefined;
7703
+ useFullBalance?: boolean | undefined;
7704
+ subsequentTransaction?: boolean | undefined;
7675
7705
  } | undefined;
7676
7706
  isExecuteFromOutside?: boolean | undefined;
7677
7707
  }>>;
@@ -7867,6 +7897,9 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7867
7897
  iconUrl?: string | undefined;
7868
7898
  };
7869
7899
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
7900
+ investmentId?: string | undefined;
7901
+ useFullBalance?: boolean | undefined;
7902
+ subsequentTransaction?: boolean | undefined;
7870
7903
  } | undefined;
7871
7904
  isExecuteFromOutside?: boolean | undefined;
7872
7905
  } | undefined;
@@ -8062,6 +8095,9 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
8062
8095
  iconUrl?: string | undefined;
8063
8096
  };
8064
8097
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
8098
+ investmentId?: string | undefined;
8099
+ useFullBalance?: boolean | undefined;
8100
+ subsequentTransaction?: boolean | undefined;
8065
8101
  } | undefined;
8066
8102
  isExecuteFromOutside?: boolean | undefined;
8067
8103
  } | undefined;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod"),c=require("../utils/starknet/starknet.cjs"),t=require("../chains/starknet/address.cjs"),a=e.z.object({id:e.z.string(),dappId:e.z.string(),productId:e.z.string(),productName:e.z.string(),chain:e.z.string(),name:e.z.string(),description:e.z.string(),iconUrl:e.z.string().url(),learnMoreUrl:e.z.string().url().optional(),riskFactor:e.z.enum(["low"]),metrics:e.z.object({baseApy:e.z.string(),totalApy:e.z.string(),tvl:e.z.string().optional()}),incentives:e.z.array(e.z.object({name:e.z.string(),description:e.z.string(),iconUrl:e.z.string().url(),learnMoreUrl:e.z.string().url(),metric:e.z.object({apy:e.z.string()})})),buyEnabled:e.z.boolean(),sellEnabled:e.z.boolean()}),s=a.extend({category:e.z.literal("staking"),investableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),withdrawableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),fees:e.z.object({depositFees:e.z.object({protocolFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),withdrawalFees:e.z.object({protocolFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),performanceFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}).optional()})}),o=a.extend({category:e.z.literal("lending"),investableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),withdrawableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),fees:e.z.object({depositFees:e.z.object({totalFee:e.z.string()}),withdrawalFees:e.z.object({totalFee:e.z.string()})})}),n=e.z.object({name:e.z.string().optional(),iconUrl:e.z.string().url().optional(),address:e.z.string().optional()}),r=a.extend({category:e.z.literal("strkDelegatedStaking"),stakerInfo:n,investableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"]),useDecomposedBalances:e.z.boolean().optional()}),withdrawableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"]),useDecomposedBalances:e.z.boolean().optional(),amountsRequirement:e.z.enum(["fullBalance"]).optional(),timelockDuration:e.z.number().optional()}),fees:e.z.object({depositFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),withdrawalFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),performanceFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}).optional()}),buyEnabled:e.z.boolean().optional(),sellEnabled:e.z.boolean().optional(),claimEnabled:e.z.boolean().optional()}),i=e.z.discriminatedUnion("category",[s,o,r]),z=e.z.object({investments:e.z.array(i)}),d=e.z.object({calls:e.z.array(c.callSchema)}),g=e.z.object({investmentId:e.z.string(),investmentType:e.z.enum(["staking","lending","strkDelegatedStaking"]).optional(),accountAddress:t.addressSchemaArgentBackend,tokenAddress:t.addressSchemaArgentBackend,stakerInfo:n,amount:e.z.string()}),l=e.z.enum(["deposit","stake","initiateWithdraw","withdraw","claim"]),m=e.z.object({stakingAction:l,stakerInfo:n,tokenAddress:t.addressSchema,amount:e.z.string()});exports.investmentMetaSchema=m;exports.investmentSchema=i;exports.investmentsResponseSchema=z;exports.lendingInvestmentSchema=o;exports.liquidStakingInvestmentSchema=s;exports.stakerInfoSchema=n;exports.stakingActionSchema=l;exports.strkDelegatedStakingInvestmentSchema=r;exports.strkStakingCalldataResponseSchema=d;exports.strkStakingCalldataSchema=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod"),z=require("../utils/starknet/starknet.cjs"),t=require("../chains/starknet/address.cjs"),a=e.z.object({id:e.z.string(),dappId:e.z.string(),productId:e.z.string(),productName:e.z.string(),chain:e.z.string(),name:e.z.string(),description:e.z.string(),iconUrl:e.z.string().url(),learnMoreUrl:e.z.string().url().optional(),riskFactor:e.z.enum(["low"]),metrics:e.z.object({baseApy:e.z.string(),totalApy:e.z.string(),tvl:e.z.string().optional()}),incentives:e.z.array(e.z.object({name:e.z.string(),description:e.z.string(),iconUrl:e.z.string().url(),learnMoreUrl:e.z.string().url(),metric:e.z.object({apy:e.z.string()})})),buyEnabled:e.z.boolean(),sellEnabled:e.z.boolean()}),s=a.extend({category:e.z.literal("staking"),investableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),withdrawableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),fees:e.z.object({depositFees:e.z.object({protocolFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),withdrawalFees:e.z.object({protocolFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),performanceFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}).optional()})}),o=a.extend({category:e.z.literal("lending"),investableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),withdrawableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"])}),fees:e.z.object({depositFees:e.z.object({totalFee:e.z.string()}),withdrawalFees:e.z.object({totalFee:e.z.string()})})}),n=e.z.object({name:e.z.string().optional(),iconUrl:e.z.string().url().optional(),address:e.z.string().optional()}),r=a.extend({category:e.z.literal("strkDelegatedStaking"),stakerInfo:n,investableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"]),useDecomposedBalances:e.z.boolean().optional()}),withdrawableAssets:e.z.object({tokenAddresses:e.z.array(t.addressSchemaArgentBackend),tokensRequirement:e.z.enum(["any"]),useDecomposedBalances:e.z.boolean().optional(),amountsRequirement:e.z.enum(["fullBalance"]).optional(),timelockDuration:e.z.number().optional()}),fees:e.z.object({depositFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),withdrawalFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}),performanceFees:e.z.object({argentFee:e.z.string().nullable().optional(),protocolFee:e.z.string().nullable().optional(),providerFee:e.z.string().nullable().optional(),totalFee:e.z.string()}).optional()}),buyEnabled:e.z.boolean().optional(),sellEnabled:e.z.boolean().optional(),claimEnabled:e.z.boolean().optional()}),l=e.z.discriminatedUnion("category",[s,o,r]),d=e.z.object({investments:e.z.array(l)}),g=e.z.object({calls:e.z.array(z.callSchema)}),m=e.z.object({investmentId:e.z.string(),investmentType:e.z.enum(["staking","lending","strkDelegatedStaking"]).optional(),accountAddress:t.addressSchemaArgentBackend,tokenAddress:t.addressSchemaArgentBackend,stakerInfo:n,amount:e.z.string()}),i=e.z.enum(["deposit","stake","initiateWithdraw","withdraw","claim"]),c=e.z.object({useFullBalance:e.z.boolean().optional(),subsequentTransaction:e.z.boolean().optional()}),b=e.z.object({investmentId:e.z.string().optional(),stakingAction:i,stakerInfo:n,tokenAddress:t.addressSchema,amount:e.z.string(),...c.shape});exports.buildSellOptsSchema=c;exports.investmentMetaSchema=b;exports.investmentSchema=l;exports.investmentsResponseSchema=d;exports.lendingInvestmentSchema=o;exports.liquidStakingInvestmentSchema=s;exports.stakerInfoSchema=n;exports.stakingActionSchema=i;exports.strkDelegatedStakingInvestmentSchema=r;exports.strkStakingCalldataResponseSchema=g;exports.strkStakingCalldataSchema=m;
@@ -2712,7 +2712,21 @@ export declare const strkStakingCalldataSchema: z.ZodObject<{
2712
2712
  }>;
2713
2713
  export type StrkStakingCalldata = z.infer<typeof strkStakingCalldataSchema>;
2714
2714
  export declare const stakingActionSchema: z.ZodEnum<["deposit", "stake", "initiateWithdraw", "withdraw", "claim"]>;
2715
+ export declare const buildSellOptsSchema: z.ZodObject<{
2716
+ useFullBalance: z.ZodOptional<z.ZodBoolean>;
2717
+ subsequentTransaction: z.ZodOptional<z.ZodBoolean>;
2718
+ }, "strip", z.ZodTypeAny, {
2719
+ useFullBalance?: boolean | undefined;
2720
+ subsequentTransaction?: boolean | undefined;
2721
+ }, {
2722
+ useFullBalance?: boolean | undefined;
2723
+ subsequentTransaction?: boolean | undefined;
2724
+ }>;
2725
+ export type BuildSellOpts = z.infer<typeof buildSellOptsSchema>;
2715
2726
  export declare const investmentMetaSchema: z.ZodObject<{
2727
+ useFullBalance: z.ZodOptional<z.ZodBoolean>;
2728
+ subsequentTransaction: z.ZodOptional<z.ZodBoolean>;
2729
+ investmentId: z.ZodOptional<z.ZodString>;
2716
2730
  stakingAction: z.ZodEnum<["deposit", "stake", "initiateWithdraw", "withdraw", "claim"]>;
2717
2731
  stakerInfo: z.ZodObject<{
2718
2732
  name: z.ZodOptional<z.ZodString>;
@@ -2738,6 +2752,9 @@ export declare const investmentMetaSchema: z.ZodObject<{
2738
2752
  iconUrl?: string | undefined;
2739
2753
  };
2740
2754
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
2755
+ investmentId?: string | undefined;
2756
+ useFullBalance?: boolean | undefined;
2757
+ subsequentTransaction?: boolean | undefined;
2741
2758
  }, {
2742
2759
  amount: string;
2743
2760
  tokenAddress: string;
@@ -2747,5 +2764,8 @@ export declare const investmentMetaSchema: z.ZodObject<{
2747
2764
  iconUrl?: string | undefined;
2748
2765
  };
2749
2766
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
2767
+ investmentId?: string | undefined;
2768
+ useFullBalance?: boolean | undefined;
2769
+ subsequentTransaction?: boolean | undefined;
2750
2770
  }>;
2751
2771
  export type InvestmentMeta = z.infer<typeof investmentMetaSchema>;
@@ -28,7 +28,7 @@ const n = e.object({
28
28
  })),
29
29
  buyEnabled: e.boolean(),
30
30
  sellEnabled: e.boolean()
31
- }), r = n.extend({
31
+ }), l = n.extend({
32
32
  category: e.literal("staking"),
33
33
  investableAssets: e.object({
34
34
  tokenAddresses: e.array(t),
@@ -54,7 +54,7 @@ const n = e.object({
54
54
  totalFee: e.string()
55
55
  }).optional()
56
56
  })
57
- }), i = n.extend({
57
+ }), r = n.extend({
58
58
  category: e.literal("lending"),
59
59
  investableAssets: e.object({
60
60
  tokenAddresses: e.array(t),
@@ -76,7 +76,7 @@ const n = e.object({
76
76
  name: e.string().optional(),
77
77
  iconUrl: e.string().url().optional(),
78
78
  address: e.string().optional()
79
- }), l = n.extend({
79
+ }), i = n.extend({
80
80
  category: e.literal("strkDelegatedStaking"),
81
81
  stakerInfo: o,
82
82
  investableAssets: e.object({
@@ -115,14 +115,14 @@ const n = e.object({
115
115
  sellEnabled: e.boolean().optional(),
116
116
  claimEnabled: e.boolean().optional()
117
117
  }), c = e.discriminatedUnion("category", [
118
+ l,
118
119
  r,
119
- i,
120
- l
121
- ]), p = e.object({
120
+ i
121
+ ]), u = e.object({
122
122
  investments: e.array(c)
123
- }), u = e.object({
124
- calls: e.array(a)
125
123
  }), k = e.object({
124
+ calls: e.array(a)
125
+ }), F = e.object({
126
126
  investmentId: e.string(),
127
127
  investmentType: e.enum(["staking", "lending", "strkDelegatedStaking"]).optional(),
128
128
  accountAddress: t,
@@ -135,21 +135,27 @@ const n = e.object({
135
135
  "initiateWithdraw",
136
136
  "withdraw",
137
137
  "claim"
138
- ]), F = e.object({
138
+ ]), g = e.object({
139
+ useFullBalance: e.boolean().optional(),
140
+ subsequentTransaction: e.boolean().optional()
141
+ }), j = e.object({
142
+ investmentId: e.string().optional(),
139
143
  stakingAction: d,
140
144
  stakerInfo: o,
141
145
  tokenAddress: s,
142
- amount: e.string()
146
+ amount: e.string(),
147
+ ...g.shape
143
148
  });
144
149
  export {
145
- F as investmentMetaSchema,
150
+ g as buildSellOptsSchema,
151
+ j as investmentMetaSchema,
146
152
  c as investmentSchema,
147
- p as investmentsResponseSchema,
148
- i as lendingInvestmentSchema,
149
- r as liquidStakingInvestmentSchema,
153
+ u as investmentsResponseSchema,
154
+ r as lendingInvestmentSchema,
155
+ l as liquidStakingInvestmentSchema,
150
156
  o as stakerInfoSchema,
151
157
  d as stakingActionSchema,
152
- l as strkDelegatedStakingInvestmentSchema,
153
- u as strkStakingCalldataResponseSchema,
154
- k as strkStakingCalldataSchema
158
+ i as strkDelegatedStakingInvestmentSchema,
159
+ k as strkStakingCalldataResponseSchema,
160
+ F as strkStakingCalldataSchema
155
161
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("lodash-es"),r=require("starknet"),y=require("../../chains/starknet/address.cjs"),x=require("../../chains/starknet/constants.cjs"),M=require("./argentMaxFee.cjs"),E=require("./error.cjs"),S=require("../../utils/starknet/starknet.cjs"),F=require("../../features/simulation/transactionReview/schema.cjs"),_=require("../../utils/arrays.cjs");function P(e){return A.upperCase(e.unit)==="WEI"}function I(e){return A.upperCase(e.unit)==="FRI"}function u(e,n){return P(e)?{...e,maxFee:n(e.maxFee),overallFee:n(e.overallFee),gasPrice:n(e.gasPrice),gasUsage:n(e.gasUsage)}:{...e,overallFee:n(e.overallFee),gasPrice:n(e.gasPrice),gasUsage:n(e.gasUsage),maxAmount:n(e.maxAmount),maxPricePerUnit:n(e.maxPricePerUnit)}}function d(e){return P(e)?{maxFee:e.maxFee}:{amount:e.maxAmount,pricePerUnit:e.maxPricePerUnit}}function p(e){return I({unit:e})?x.STRK_TOKEN_ADDRESS:x.ETH_TOKEN_ADDRESS}function k(e,n,t=2){const a=BigInt(10**t),s=BigInt(Math.round(n*10**t));return e*s/a}const N=[x.STRK_TOKEN_ADDRESS],G=(e,n=U)=>{if(e.max&&"amount"in e.max)return{...e,...e.max};const t=10000n,{amount:a,pricePerUnit:s,dataGasConsumed:o=0n,dataGasPrice:m=0n}=e,c=a*s+o*m;if(c<0)throw Error("Cannot calculate max fee for negative fee");const i=r.num.toBigInt(M.argentMaxFee({estimatedFee:c})),f=Number(i)/Number(c),h=n(f),g=BigInt(Math.trunc(h*Number(t)));return{...e,amount:a*g/t,pricePerUnit:s*g/t,dataGasConsumed:o*g/t,dataGasPrice:m*g/t}},l=e=>{const{amount:n,pricePerUnit:t,dataGasConsumed:a=0n,dataGasPrice:s=0n}=e;return n*t+a*s},B=e=>{if(e.max)return"maxFee"in e.max?e.max.maxFee:l(e.max)},T=e=>{const n=B(e);return n||l(G(e))},R=e=>{if(e.deployment&&!y.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const n=l(e.transactions),t=e.deployment?l(e.deployment):0n;return n+t},q=e=>{if(e.deployment&&!y.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const n=e.deployment?T(e.deployment):0n,t=T(e.transactions);return n+t},D=(e,n)=>[{contractAddress:e,entrypoint:"transfer",calldata:r.CallData.compile(S.transferCalldataSchema.parse({recipient:n,amount:r.uint256.bnToUint256(BigInt(1))}))}],C=(e,n)=>{if(!e)return{transactions:{feeTokenAddress:n??x.ETH_TOKEN_ADDRESS,amount:0n,pricePerUnit:0n,dataGasConsumed:0n,dataGasPrice:0n}};if(!Array.isArray(e))throw Error(`Unexpected simulation response. Expected array. Got ${typeof e}`);if(e.length===1){const t=F.feeEstimationSchema.parse(e[0].feeEstimation);return{transactions:{feeTokenAddress:p(t.unit),amount:r.num.toBigInt(t.gasUsage),pricePerUnit:r.num.toBigInt(t.gasPrice),max:d(u(t,r.num.toBigInt)),dataGasConsumed:t.dataGasConsumed?r.num.toBigInt(t.dataGasConsumed):0n,dataGasPrice:t.dataGasPrice?r.num.toBigInt(t.dataGasPrice):0n}}}if(e.length===2){const t=F.feeEstimationSchema.parse(e[0].feeEstimation),a=F.feeEstimationSchema.parse(e[1].feeEstimation);return{deployment:{feeTokenAddress:p(t.unit),amount:r.num.toBigInt(t.gasUsage),pricePerUnit:r.num.toBigInt(t.gasPrice),max:d(u(t,r.num.toBigInt)),dataGasConsumed:t.dataGasConsumed?r.num.toBigInt(t.dataGasConsumed):0n,dataGasPrice:t.dataGasPrice?r.num.toBigInt(t.dataGasPrice):0n},transactions:{feeTokenAddress:p(a.unit),amount:r.num.toBigInt(a.gasUsage),pricePerUnit:r.num.toBigInt(a.gasPrice),max:d(u(a,r.num.toBigInt)),dataGasConsumed:a.dataGasConsumed?r.num.toBigInt(a.dataGasConsumed):0n,dataGasPrice:a.dataGasPrice?r.num.toBigInt(a.dataGasPrice):0n}}}throw Error("Unexpected simulation response length")},b=({transaction:e,nonce:n,chainId:t,version:a,isDeploymentTransaction:s,cairoVersion:o,address:m,appDomain:c})=>{let i=n;s&&e.type!=="DEPLOY_ACCOUNT"&&(i=r.num.toHex(1));const f=_.ensureArray(e.calls);return{type:e.type,chainId:t,cairoVersion:o,nonce:i,version:a,account:m,calls:f,calldata:e.calldata,salt:e.salt,signature:e.signature,classHash:e.classHash,appDomain:c}},j=(e,n)=>{const{transactions:t}=e;if(!t)throw new E.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});const a=t.map(i=>{if(!i.simulation)throw new E.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});return i}),s=a.map(i=>({...i.simulation,feeEstimation:u(i.simulation.feeEstimation,Number)})),o=C(s,n),[m,c]=a.length===1?[a[0],void 0]:[a[1],a[0]];return{...o,transactions:{...o.transactions,dataGasConsumed:o.transactions.dataGasConsumed??0n,dataGasPrice:o.transactions.dataGasPrice??0n,max:d(u(m.simulation.feeEstimation,r.num.toBigInt))},deployment:o.deployment&&c?{...o.deployment,dataGasConsumed:o.deployment.dataGasConsumed??0n,dataGasPrice:o.deployment.dataGasPrice??0n,max:d(u(c.simulation.feeEstimation,r.num.toBigInt))}:void 0}},w=e=>{const n=G(e),t=T(e);return{maxFee:t,resourceBounds:{l1_gas:{max_amount:r.num.toHex(t/e.pricePerUnit),max_price_per_unit:r.num.toHex(n.pricePerUnit)},l2_gas:{max_amount:"0x0",max_price_per_unit:"0x0"}}}},W=e=>{const n=Math.sqrt(e);return isNaN(n)?Math.sqrt(2):n},U=e=>{const n=Math.cbrt(e);return isNaN(n)?Math.cbrt(2):n},O=e=>e<1||isNaN(e)?1.1:Math.log(e+1)+1;exports.buildDummyTx=D;exports.calculateCubeRootAdjustment=U;exports.calculateNonLinearAdjustment=O;exports.calculateSqrtAdjustment=W;exports.castFeeEstimation=u;exports.estimatedFeeToMaxFeeTotal=T;exports.estimatedFeeToMaxResourceBounds=w;exports.estimatedFeeToTotal=l;exports.estimatedFeesToMaxFeeTotal=q;exports.estimatedFeesToTotal=R;exports.getEstimatedFeeFromBulkSimulation=C;exports.getEstimatedFeeFromSimulationAndRespectWatermarkFee=j;exports.getPayloadFromTransaction=b;exports.getWatermarkedMaxFeeTotal=B;exports.isFRI=I;exports.isWEI=P;exports.multiplyBigIntByFloat=k;exports.toMax=d;exports.tokensRequireTxV3Support=N;exports.unitToFeeTokenAddress=p;
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 T } from "lodash-es";
2
- import { num as r, CallData as C, uint256 as U } from "starknet";
3
- import { isEqualAddress as I } from "../../chains/starknet/address.js";
4
- import { STRK_TOKEN_ADDRESS as y, ETH_TOKEN_ADDRESS as A } from "../../chains/starknet/constants.js";
5
- import { argentMaxFee as h } from "./argentMaxFee.js";
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 _ } from "../../utils/starknet/starknet.js";
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 T(t.unit) === "WEI";
11
+ return A(t.unit) === "WEI";
12
12
  }
13
13
  function k(t) {
14
- return T(t.unit) === "FRI";
14
+ return A(t.unit) === "FRI";
15
15
  }
16
- function u(t, n) {
16
+ function u(t, e) {
17
17
  return E(t) ? {
18
18
  ...t,
19
- maxFee: n(t.maxFee),
20
- overallFee: n(t.overallFee),
21
- gasPrice: n(t.gasPrice),
22
- gasUsage: n(t.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: n(t.overallFee),
26
- gasPrice: n(t.gasPrice),
27
- gasUsage: n(t.gasUsage),
28
- maxAmount: n(t.maxAmount),
29
- maxPricePerUnit: n(t.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 }) ? y : A;
41
+ return k({ unit: t }) ? I : y;
42
42
  }
43
- function O(t, n, e = 2) {
44
- const a = BigInt(10 ** e), s = BigInt(Math.round(n * 10 ** e));
45
- return t * s / a;
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 K = [y], F = (t, n = D) => {
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 e = 10000n, { amount: a, pricePerUnit: s, dataGasConsumed: o = 0n, dataGasPrice: m = 0n } = t, c = a * s + o * m;
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(h({ estimatedFee: c })), g = Number(i) / Number(c), B = n(g), l = BigInt(Math.trunc(B * Number(e)));
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 / e,
60
- pricePerUnit: s * l / e,
61
- dataGasConsumed: o * l / e,
62
- dataGasPrice: m * l / e
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: n, pricePerUnit: e, dataGasConsumed: a = 0n, dataGasPrice: s = 0n } = t;
66
- return n * e + a * s;
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 n = N(t);
72
- return n || p(F(t));
73
- }, V = (t) => {
74
- if (t.deployment && !I(t.deployment.feeTokenAddress, t.transactions.feeTokenAddress))
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 n = p(t.transactions), e = t.deployment ? p(t.deployment) : 0n;
77
- return n + e;
78
- }, Y = (t) => {
79
- if (t.deployment && !I(t.deployment.feeTokenAddress, t.transactions.feeTokenAddress))
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 n = t.deployment ? P(t.deployment) : 0n, e = P(t.transactions);
82
- return n + e;
83
- }, $ = (t, n) => [
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: C.compile(_.parse({
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: n,
89
+ recipient: e,
90
90
  // We are using the smallest possible amount to make sure this doesn't throw an error
91
- amount: U.bnToUint256(BigInt(1))
91
+ amount: C.bnToUint256(BigInt(1))
92
92
  }))
93
93
  }
94
- ], S = (t, n) => {
94
+ ], S = (t, e) => {
95
95
  if (!t)
96
96
  return {
97
97
  transactions: {
98
- feeTokenAddress: n ?? A,
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 e = f.parse(t[0].feeEstimation);
108
+ const n = f.parse(t[0].feeEstimation);
109
109
  return {
110
110
  transactions: {
111
- feeTokenAddress: x(e.unit),
112
- amount: r.toBigInt(e.gasUsage),
113
- pricePerUnit: r.toBigInt(e.gasPrice),
114
- max: d(u(e, r.toBigInt)),
115
- dataGasConsumed: e.dataGasConsumed ? r.toBigInt(e.dataGasConsumed) : 0n,
116
- dataGasPrice: e.dataGasPrice ? r.toBigInt(e.dataGasPrice) : 0n
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 e = f.parse(t[0].feeEstimation), a = f.parse(t[1].feeEstimation);
121
+ const n = f.parse(t[0].feeEstimation), a = f.parse(t[1].feeEstimation);
122
122
  return {
123
123
  deployment: {
124
- feeTokenAddress: x(e.unit),
125
- amount: r.toBigInt(e.gasUsage),
126
- pricePerUnit: r.toBigInt(e.gasPrice),
127
- max: d(u(e, r.toBigInt)),
128
- dataGasConsumed: e.dataGasConsumed ? r.toBigInt(e.dataGasConsumed) : 0n,
129
- dataGasPrice: e.dataGasPrice ? r.toBigInt(e.dataGasPrice) : 0n
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
- }, z = ({ transaction: t, nonce: n, chainId: e, version: a, isDeploymentTransaction: s, cairoVersion: o, address: m, appDomain: c }) => {
143
- let i = n;
144
- s && t.type !== "DEPLOY_ACCOUNT" && (i = r.toHex(1));
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: e,
149
- cairoVersion: o,
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
- }, J = (t, n) => {
162
- const { transactions: e } = t;
163
- if (!e)
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 = e.map((i) => {
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
- }), s = a.map((i) => ({
169
+ }), o = a.map((i) => ({
170
170
  ...i.simulation,
171
171
  feeEstimation: u(i.simulation.feeEstimation, Number)
172
- })), o = S(s, n), [m, c] = a.length === 1 ? [a[0], void 0] : [a[1], a[0]];
172
+ })), s = S(o, e), [m, c] = a.length === 1 ? [a[0], void 0] : [a[1], a[0]];
173
173
  return {
174
- ...o,
174
+ ...s,
175
175
  transactions: {
176
- ...o.transactions,
177
- dataGasConsumed: o.transactions.dataGasConsumed ?? 0n,
178
- dataGasPrice: o.transactions.dataGasPrice ?? 0n,
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: o.deployment && c ? {
182
- ...o.deployment,
183
- dataGasConsumed: o.deployment.dataGasConsumed ?? 0n,
184
- dataGasPrice: o.deployment.dataGasPrice ?? 0n,
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
- }, Q = (t) => {
189
- const n = F(t), e = P(t);
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: e,
200
+ maxFee: n,
193
201
  // for v3 transactions
194
202
  resourceBounds: {
195
- l1_gas: {
196
- // (overall_fee / gas_price) × gas_safety_margin
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
- }, X = (t) => {
208
- const n = Math.sqrt(t);
209
- return isNaN(n) ? Math.sqrt(2) : n;
210
- }, D = (t) => {
211
- const n = Math.cbrt(t);
212
- return isNaN(n) ? Math.cbrt(2) : n;
213
- }, Z = (t) => t < 1 || isNaN(t) ? 1.1 : Math.log(t + 1) + 1;
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
- $ as buildDummyTx,
216
- D as calculateCubeRootAdjustment,
217
- Z as calculateNonLinearAdjustment,
218
- X as calculateSqrtAdjustment,
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
- Q as estimatedFeeToMaxResourceBounds,
221
+ Z as estimatedFeeToMaxResourceBounds,
222
222
  p as estimatedFeeToTotal,
223
- Y as estimatedFeesToMaxFeeTotal,
224
- V as estimatedFeesToTotal,
223
+ z as estimatedFeesToMaxFeeTotal,
224
+ $ as estimatedFeesToTotal,
225
225
  S as getEstimatedFeeFromBulkSimulation,
226
- J as getEstimatedFeeFromSimulationAndRespectWatermarkFee,
227
- z as getPayloadFromTransaction,
226
+ X as getEstimatedFeeFromSimulationAndRespectWatermarkFee,
227
+ Q as getPayloadFromTransaction,
228
228
  N as getWatermarkedMaxFeeTotal,
229
229
  k as isFRI,
230
230
  E as isWEI,
231
- O as multiplyBigIntByFloat,
231
+ V as multiplyBigIntByFloat,
232
232
  d as toMax,
233
- K as tokensRequireTxV3Support,
233
+ Y as tokensRequireTxV3Support,
234
234
  x as unitToFeeTokenAddress
235
235
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@argent/x-shared",
3
- "version": "1.55.0",
3
+ "version": "1.56.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/argentlabs/x-shared.git"