@argent/x-shared 1.66.0 → 1.66.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 l=require("lodash-es"),o=require("starknet"),N=require("../getTransactionVersion.cjs"),F=require("./error.cjs"),r=require("./utils.cjs"),u=require("../../chains/starknet/constants.cjs"),E=require("../../chains/starknet/address.cjs"),h=e=>{const{transactions:t}=e;if(!t)throw new F.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});if(!Array.isArray(t))throw Error(`Unexpected simulation response. Expected array. Got ${typeof t}`);if(l.isEmpty(t))return[];if(t.length>2)throw Error(`Unexpected simulation response length. Got ${t.length}`);const n=t.map(m=>{if(!m.simulation)throw new F.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});return{...m.simulation,...I(m.simulation.feeEstimations)}}),[a,s]=n.length===1?[n[0],void 0]:[n[1],n[0]],i=y(a,s),f=p(a,s);return[...i,...f]},I=e=>{const[t,n]=l.partition(e,a=>"unit"in a&&(a.unit==="FRI"||a.unit==="WEI"));return{nativeFeeEstimations:t,paymasterFeeEstimations:n}},p=(e,t)=>{if(!e)return[];if(!t)return e.paymasterFeeEstimations.map(s=>({type:"paymaster",transactions:c(s),deployment:void 0}));const n=t.paymasterFeeEstimations,a=e.paymasterFeeEstimations;if(n.length!==a.length)throw Error("Deployment and transaction fee estimations length mismatch");return a.map((s,i)=>({type:"paymaster",transactions:c(s),deployment:c(n[i])}))},y=(e,t)=>{if(!e)return[];if(!t)return e.nativeFeeEstimations.map(s=>({type:"native",transactions:d(s),deployment:void 0}));const n=t.nativeFeeEstimations,a=e.nativeFeeEstimations;if(n.length!==a.length)throw Error("Deployment and transaction fee estimations length mismatch");return a.map((s,i)=>({type:"native",transactions:d(s),deployment:d(n[i])}))},c=e=>({feeTokenAddress:e.token.address,maxFee:BigInt(e.maxFee),overallFee:BigInt(e.overallFee)}),d=e=>({amount:o.num.toBigInt(e.gasUsage),feeTokenAddress:r.unitToFeeTokenAddress(e.unit),pricePerUnit:o.num.toBigInt(e.gasPrice),dataGasConsumed:o.num.toBigInt(e.dataGasConsumed??0),dataGasPrice:o.num.toBigInt(e.dataGasPrice??0),max:r.toMax(r.castFeeEstimation(e,o.num.toBigInt))}),S=e=>{var a;if(e.type==="paymaster")return e.transactions.maxFee+(((a=e.deployment)==null?void 0:a.maxFee)??0n);if(e.deployment&&!E.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=e.deployment?r.estimatedFeeToMaxFeeTotal(e.deployment):0n,n=r.estimatedFeeToMaxFeeTotal(e.transactions);return t+n},V=e=>{var t;return e.type==="paymaster"?e.transactions.overallFee+(((t=e.deployment)==null?void 0:t.overallFee)??0n):r.estimatedFeesToTotal(e)},g=(e=[])=>e.filter(n=>n.type==="native"),x=e=>e.filter(t=>t.type==="paymaster"),T=e=>e===o.constants.TRANSACTION_VERSION.V1||e===o.constants.TRANSACTION_VERSION.F1?u.ETH_TOKEN_ADDRESS:u.STRK_TOKEN_ADDRESS,v=(e=[],t)=>{const n=g(e).find(a=>E.isEqualAddress(a.transactions.feeTokenAddress,t));if(!n)throw Error(`No native estimated fee found for ${t}`);return n},A=(e=[],t)=>{const n=T(t);return v(e,n)},_=(e=[],t)=>A(e,N.getAccountTxVersion(t));exports.estimatedFeesToMaxFeeTotalV2=S;exports.estimatedFeesToTotalV2=V;exports.filterPaymasterEstimatedFees=x;exports.getEstimatedFeeFromSimulationAndRespectWatermarkFeeV2=h;exports.getNativeEstimatedFeeByFeeToken=v;exports.getNativeEstimatedFeeByTxVersion=A;exports.getNativeEstimatedFeeForAccount=_;exports.getNativeEstimatedFees=g;exports.getNativeFeeFromSimulation=y;exports.getNativeFeeTokenAddress=T;exports.getPaymasterFeeFromSimulation=p;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("lodash-es"),o=require("starknet"),N=require("../getTransactionVersion.cjs"),F=require("./error.cjs"),r=require("./utils.cjs"),E=require("../../chains/starknet/address.cjs"),u=require("../../chains/starknet/constants.cjs"),h=e=>{const{transactions:t}=e;if(!t)throw new F.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});if(!Array.isArray(t))throw Error(`Unexpected simulation response. Expected array. Got ${typeof t}`);if(l.isEmpty(t))return[];if(t.length>2)throw Error(`Unexpected simulation response length. Got ${t.length}`);const n=t.map(m=>{if(!m.simulation)throw new F.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});return{...m.simulation,...I(m.simulation.feeEstimations)}}),[a,s]=n.length===1?[n[0],void 0]:[n[1],n[0]],i=y(a,s),f=p(a,s);return[...i,...f]},I=e=>{const[t,n]=l.partition(e,a=>"unit"in a&&(a.unit==="FRI"||a.unit==="WEI"));return{nativeFeeEstimations:t,paymasterFeeEstimations:n}},p=(e,t)=>{if(!e)return[];if(!t)return e.paymasterFeeEstimations.map(s=>({type:"paymaster",transactions:c(s),deployment:void 0}));const n=t.paymasterFeeEstimations,a=e.paymasterFeeEstimations;if(n.length!==a.length)throw Error("Deployment and transaction fee estimations length mismatch");return a.map((s,i)=>({type:"paymaster",transactions:c(s),deployment:c(n[i])}))},y=(e,t)=>{if(!e)return[];if(!t)return e.nativeFeeEstimations.map(s=>({type:"native",transactions:d(s),deployment:void 0}));const n=t.nativeFeeEstimations,a=e.nativeFeeEstimations;if(n.length!==a.length)throw Error("Deployment and transaction fee estimations length mismatch");return a.map((s,i)=>({type:"native",transactions:d(s),deployment:d(n[i])}))},c=e=>({feeTokenAddress:e.token.address,maxFee:BigInt(e.maxFee),overallFee:BigInt(e.overallFee)}),d=e=>({amount:o.num.toBigInt(e.gasUsage),feeTokenAddress:r.unitToFeeTokenAddress(e.unit),pricePerUnit:o.num.toBigInt(e.gasPrice),dataGasConsumed:o.num.toBigInt(e.dataGasConsumed??0),dataGasPrice:o.num.toBigInt(e.dataGasPrice??0),max:r.toMax(r.castFeeEstimation(e,o.num.toBigInt))}),S=e=>{var a;if(e.type==="paymaster")return e.transactions.maxFee+(((a=e.deployment)==null?void 0:a.maxFee)??0n);if(e.deployment&&!E.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=e.deployment?r.estimatedFeeToMaxFeeTotal(e.deployment):0n,n=r.estimatedFeeToMaxFeeTotal(e.transactions);return t+n},V=e=>{var t;return e.type==="paymaster"?e.transactions.overallFee+(((t=e.deployment)==null?void 0:t.overallFee)??0n):r.estimatedFeesToTotal(e)},g=(e=[])=>e.filter(n=>n.type==="native"),x=e=>e.filter(t=>t.type==="paymaster"),T=e=>e===o.constants.TRANSACTION_VERSION.V1||e===o.constants.TRANSACTION_VERSION.F1?u.ETH_TOKEN_ADDRESS:u.STRK_TOKEN_ADDRESS,v=(e=[],t)=>{const n=g(e).find(a=>E.isEqualAddress(a.transactions.feeTokenAddress,t));if(!n)throw Error(`No native estimated fee found for ${t}`);return n},A=(e=[],t)=>{const n=T(t);return v(e,n)},_=(e=[],t)=>A(e,N.getAccountTxVersion(t));exports.estimatedFeesToMaxFeeTotalV2=S;exports.estimatedFeesToTotalV2=V;exports.filterPaymasterEstimatedFees=x;exports.getEstimatedFeeFromSimulationAndRespectWatermarkFeeV2=h;exports.getNativeEstimatedFeeByFeeToken=v;exports.getNativeEstimatedFeeByTxVersion=A;exports.getNativeEstimatedFeeForAccount=_;exports.getNativeEstimatedFees=g;exports.getNativeFeeFromSimulation=y;exports.getNativeFeeTokenAddress=T;exports.getPaymasterFeeFromSimulation=p;
@@ -3,8 +3,8 @@ import { num as s, constants as p } from "starknet";
3
3
  import { getAccountTxVersion as f } from "../getTransactionVersion.js";
4
4
  import { EstimateError as d } from "./error.js";
5
5
  import { toMax as g, castFeeEstimation as T, unitToFeeTokenAddress as A, estimatedFeeToMaxFeeTotal as E, estimatedFeesToTotal as v } from "./utils.js";
6
- import { ETH_TOKEN_ADDRESS as h, STRK_TOKEN_ADDRESS as I } from "../../chains/starknet/constants.js";
7
6
  import { isEqualAddress as l } from "../../chains/starknet/address.js";
7
+ import { ETH_TOKEN_ADDRESS as h, STRK_TOKEN_ADDRESS as I } from "../../chains/starknet/constants.js";
8
8
  const O = (t) => {
9
9
  const { transactions: e } = t;
10
10
  if (!e)
@@ -1 +1 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("starknet"),r=require("../chains/starknet/address.cjs"),o=require("../chains/starknet/constants.cjs"),s=require("./txv3.cjs");function T(e){return r.isEqualAddress(e,o.ETH_TOKEN_ADDRESS)?t.constants.TRANSACTION_VERSION.V1:t.constants.TRANSACTION_VERSION.V3}function c(e){return r.isEqualAddress(e,o.ETH_TOKEN_ADDRESS)?t.constants.TRANSACTION_VERSION.F1:t.constants.TRANSACTION_VERSION.F3}function N(e,n){return t.isSierra(n.contract)?r.isEqualAddress(e,o.ETH_TOKEN_ADDRESS)?t.constants.TRANSACTION_VERSION.V2:t.constants.TRANSACTION_VERSION.V3:t.constants.TRANSACTION_VERSION.V1}const S=({classHash:e})=>e&&!s.classHashSupportsTxV3(e)?t.constants.TRANSACTION_VERSION.V1:t.constants.TRANSACTION_VERSION.V3,a=({classHash:e},n)=>t.isSierra(n.contract)?e&&!s.classHashSupportsTxV3(e)?t.constants.TRANSACTION_VERSION.V2:t.constants.TRANSACTION_VERSION.V3:t.constants.TRANSACTION_VERSION.V1;exports.getAccountTxVersion=S;exports.getSimulationTxVersionFromFeeToken=c;exports.getTxVersionForDeclareContract=a;exports.getTxVersionFromFeeToken=T;exports.getTxVersionFromFeeTokenForDeclareContract=N;
@@ -1,21 +1,21 @@
1
- import { constants as r, isSierra as T } from "starknet";
2
- import { classHashSupportsTxV3 as n, feeTokenNeedsTxV3Support as t } from "./txv3.js";
3
- function S(e) {
4
- return t({
5
- address: e
6
- }) ? r.TRANSACTION_VERSION.V3 : r.TRANSACTION_VERSION.V1;
1
+ import { constants as r, isSierra as e } from "starknet";
2
+ import { isEqualAddress as o } from "../chains/starknet/address.js";
3
+ import { ETH_TOKEN_ADDRESS as T } from "../chains/starknet/constants.js";
4
+ import { classHashSupportsTxV3 as n } from "./txv3.js";
5
+ function R(N) {
6
+ return o(N, T) ? r.TRANSACTION_VERSION.V1 : r.TRANSACTION_VERSION.V3;
7
7
  }
8
- function A(e) {
9
- return t({ address: e }) ? r.TRANSACTION_VERSION.F3 : r.TRANSACTION_VERSION.F1;
8
+ function I(N) {
9
+ return o(N, T) ? r.TRANSACTION_VERSION.F1 : r.TRANSACTION_VERSION.F3;
10
10
  }
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;
11
+ function i(N, t) {
12
+ return e(t.contract) ? o(N, T) ? r.TRANSACTION_VERSION.V2 : r.TRANSACTION_VERSION.V3 : r.TRANSACTION_VERSION.V1;
13
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
+ const E = ({ classHash: N }) => N && !n(N) ? r.TRANSACTION_VERSION.V1 : r.TRANSACTION_VERSION.V3, c = ({ classHash: N }, t) => e(t.contract) ? N && !n(N) ? r.TRANSACTION_VERSION.V2 : r.TRANSACTION_VERSION.V3 : r.TRANSACTION_VERSION.V1;
15
15
  export {
16
- O as getAccountTxVersion,
17
- A as getSimulationTxVersionFromFeeToken,
18
- R as getTxVersionForDeclareContract,
19
- S as getTxVersionFromFeeToken,
20
- I as getTxVersionFromFeeTokenForDeclareContract
16
+ E as getAccountTxVersion,
17
+ I as getSimulationTxVersionFromFeeToken,
18
+ c as getTxVersionForDeclareContract,
19
+ R as getTxVersionFromFeeToken,
20
+ i as getTxVersionFromFeeTokenForDeclareContract
21
21
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("zod"),o=t.z.object({tokenType:t.z.string(),tokenAddress:t.z.string(),tokenAmount:t.z.string()}),n=t.z.object({type:t.z.enum(["lootbox"]),status:t.z.enum(["notEligible","win","loss","disabled"]),prizes:t.z.array(o).nullable().optional()}),e=t.z.object({transactionState:t.z.enum(["submitted","rejected"]).optional(),transactionHash:t.z.string(),rejectReason:t.z.string().nullable().optional(),promotions:t.z.array(n).nullable().optional()});exports.transactionExecutionResponseSchema=e;exports.transactionPromotionPrizeSchema=o;exports.transactionPromotionSchema=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("zod"),o=t.z.object({tokenType:t.z.string(),tokenAddress:t.z.string(),tokenAmount:t.z.string()}),n=t.z.object({type:t.z.enum(["lootbox"]),status:t.z.enum(["notEligible","win","loss","disabled"]),prizes:t.z.array(o).nullable().optional(),prizeTierLevel:t.z.number().nullable().optional(),prizeUsdAmount:t.z.number().nullable().optional()}),e=t.z.object({transactionState:t.z.enum(["submitted","rejected"]).optional(),transactionHash:t.z.string(),rejectReason:t.z.string().nullable().optional(),promotions:t.z.array(n).nullable().optional()});exports.transactionExecutionResponseSchema=e;exports.transactionPromotionPrizeSchema=o;exports.transactionPromotionSchema=n;
@@ -28,6 +28,8 @@ export declare const transactionPromotionSchema: z.ZodObject<{
28
28
  tokenType: string;
29
29
  tokenAmount: string;
30
30
  }>, "many">>>;
31
+ prizeTierLevel: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
32
+ prizeUsdAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
31
33
  }, "strip", z.ZodTypeAny, {
32
34
  type: "lootbox";
33
35
  status: "notEligible" | "win" | "loss" | "disabled";
@@ -36,6 +38,8 @@ export declare const transactionPromotionSchema: z.ZodObject<{
36
38
  tokenType: string;
37
39
  tokenAmount: string;
38
40
  }[] | null | undefined;
41
+ prizeTierLevel?: number | null | undefined;
42
+ prizeUsdAmount?: number | null | undefined;
39
43
  }, {
40
44
  type: "lootbox";
41
45
  status: "notEligible" | "win" | "loss" | "disabled";
@@ -44,6 +48,8 @@ export declare const transactionPromotionSchema: z.ZodObject<{
44
48
  tokenType: string;
45
49
  tokenAmount: string;
46
50
  }[] | null | undefined;
51
+ prizeTierLevel?: number | null | undefined;
52
+ prizeUsdAmount?: number | null | undefined;
47
53
  }>;
48
54
  export declare const transactionExecutionResponseSchema: z.ZodObject<{
49
55
  transactionState: z.ZodOptional<z.ZodEnum<["submitted", "rejected"]>>;
@@ -65,6 +71,8 @@ export declare const transactionExecutionResponseSchema: z.ZodObject<{
65
71
  tokenType: string;
66
72
  tokenAmount: string;
67
73
  }>, "many">>>;
74
+ prizeTierLevel: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
75
+ prizeUsdAmount: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
68
76
  }, "strip", z.ZodTypeAny, {
69
77
  type: "lootbox";
70
78
  status: "notEligible" | "win" | "loss" | "disabled";
@@ -73,6 +81,8 @@ export declare const transactionExecutionResponseSchema: z.ZodObject<{
73
81
  tokenType: string;
74
82
  tokenAmount: string;
75
83
  }[] | null | undefined;
84
+ prizeTierLevel?: number | null | undefined;
85
+ prizeUsdAmount?: number | null | undefined;
76
86
  }, {
77
87
  type: "lootbox";
78
88
  status: "notEligible" | "win" | "loss" | "disabled";
@@ -81,6 +91,8 @@ export declare const transactionExecutionResponseSchema: z.ZodObject<{
81
91
  tokenType: string;
82
92
  tokenAmount: string;
83
93
  }[] | null | undefined;
94
+ prizeTierLevel?: number | null | undefined;
95
+ prizeUsdAmount?: number | null | undefined;
84
96
  }>, "many">>>;
85
97
  }, "strip", z.ZodTypeAny, {
86
98
  transactionHash: string;
@@ -92,6 +104,8 @@ export declare const transactionExecutionResponseSchema: z.ZodObject<{
92
104
  tokenType: string;
93
105
  tokenAmount: string;
94
106
  }[] | null | undefined;
107
+ prizeTierLevel?: number | null | undefined;
108
+ prizeUsdAmount?: number | null | undefined;
95
109
  }[] | null | undefined;
96
110
  transactionState?: "rejected" | "submitted" | undefined;
97
111
  rejectReason?: string | null | undefined;
@@ -105,6 +119,8 @@ export declare const transactionExecutionResponseSchema: z.ZodObject<{
105
119
  tokenType: string;
106
120
  tokenAmount: string;
107
121
  }[] | null | undefined;
122
+ prizeTierLevel?: number | null | undefined;
123
+ prizeUsdAmount?: number | null | undefined;
108
124
  }[] | null | undefined;
109
125
  transactionState?: "rejected" | "submitted" | undefined;
110
126
  rejectReason?: string | null | undefined;
@@ -6,8 +6,10 @@ const o = t.object({
6
6
  }), n = t.object({
7
7
  type: t.enum(["lootbox"]),
8
8
  status: t.enum(["notEligible", "win", "loss", "disabled"]),
9
- prizes: t.array(o).nullable().optional()
9
+ prizes: t.array(o).nullable().optional(),
10
10
  // need to support null values too
11
+ prizeTierLevel: t.number().nullable().optional(),
12
+ prizeUsdAmount: t.number().nullable().optional()
11
13
  }), a = t.object({
12
14
  transactionState: t.enum(["submitted", "rejected"]).optional(),
13
15
  transactionHash: t.string(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@argent/x-shared",
3
- "version": "1.66.0",
3
+ "version": "1.66.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/argentlabs/x-shared.git"