@argent/x-shared 1.49.1 → 1.50.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("zod"),i=require("../../../staking/schema.cjs"),u=require("../transactionReview/schema.cjs"),e=require("../../../chains/starknet/address.cjs"),d=t.z.object({network:t.z.string(),hash:t.z.string(),status:t.z.string(),blockNumber:t.z.number().optional(),transactionIndex:t.z.number()}),n=t.z.object({type:t.z.enum(["token","nft"]),tokenAddress:e.addressSchemaArgentBackend,amount:t.z.string().optional(),fiatAmount:t.z.object({currency:t.z.string(),currencyAmount:t.z.number()}).optional().nullable()}),s=t.z.enum(["ethereum","starknet","zksync","zksync2"]),m=t.z.object({type:t.z.enum(["payment","gasFee"]),leg:t.z.enum(["credit","debit"]),asset:n,counterParty:e.addressSchemaArgentBackend.optional(),counterPartyNetwork:s.optional()}),f=t.z.object({address:e.addressSchemaArgentBackend,network:s,type:t.z.enum(["wallet","token"])}),N=t.z.object({chainId:t.z.enum(["TESTNET","MAINNET","SEPOLIA"]),ethereumNetwork:t.z.enum(["mainnet","sepolia"])}),w=t.z.enum(["approval","changePubKey","dappInteraction","deploy","gift","multicall","payment","security","trade","staking"]),p=t.z.enum(["triggerEscapeGuardian","triggerEscapeSigner","escapeGuardian","escapeSigner","guardianChanged","guardianBackupChanged","signerChanged","cancelEscape","accountUpgraded","multisigConfigurationUpdated"]),B=t.z.object({name:t.z.string(),parameters:t.z.array(t.z.unknown()).optional()}),I=t.z.object({guid:t.z.string().optional(),signerType:t.z.string().optional(),signer:t.z.object({publicKey:t.z.string().optional()}).optional()}),T=t.z.object({activeAt:t.z.string().optional(),newGuardian:t.z.string().optional(),newImplementation:t.z.string().optional(),newVersion:t.z.string().optional(),signerGuid:t.z.string().optional(),signers:t.z.array(I).optional()}),l=t.z.discriminatedUnion("type",[t.z.object({type:t.z.literal("deploy"),deployer:e.addressSchemaArgentBackend,contractAddress:e.addressSchemaArgentBackend}),t.z.object({type:t.z.literal("approval"),spender:e.addressSchemaArgentBackend,asset:n,approvalType:t.z.string()}),t.z.object({type:t.z.literal("payment"),counterparty:e.addressSchemaArgentBackend,leg:t.z.string(),asset:n,counterpartyNetwork:s.optional()}),t.z.object({type:t.z.literal("trade"),srcAsset:n,destAsset:n}),t.z.object({type:t.z.literal("security"),action:p,context:T.optional()}),t.z.object({type:t.z.literal("dappInteraction"),dappAddress:e.addressSchemaArgentBackend,function:B.optional().nullable()}),t.z.object({type:t.z.literal("staking"),stakingAction:i.stakingActionSchema,counterparty:e.addressSchemaArgentBackend,asset:n,stakerInfo:i.stakerInfoSchema})]),z=t.z.union([l,t.z.object({type:t.z.literal("multicall"),calls:t.z.array(t.z.object({details:l}))})]),y=t.z.object({dappId:t.z.string(),name:t.z.string().optional().nullable()}),c=t.z.object({sent:t.z.boolean(),asset:t.z.discriminatedUnion("type",[t.z.object({type:t.z.literal("nft"),tokenAddress:e.addressSchemaArgentBackend,tokenId:t.z.coerce.number().optional(),amount:t.z.string().optional(),collectionName:t.z.string().optional(),collectionPreviewImage:t.z.string().optional().nullable(),nftName:t.z.string().optional().nullable(),nftPreviewImage:t.z.string().optional().nullable()}),t.z.object({type:t.z.literal("token"),tokenAddress:e.addressSchemaArgentBackend,amount:t.z.string().optional(),fiatAmount:t.z.object({currency:t.z.string(),currencyAmount:t.z.coerce.string()}).optional().nullable()})])}),g=t.z.object({type:t.z.string(),to:e.addressSchemaArgentBackend,actualFee:t.z.object({type:t.z.string(),tokenAddress:e.addressSchemaArgentBackend,amount:t.z.string().optional(),fiatAmount:t.z.object({currency:t.z.string(),currencyAmount:t.z.number()}).optional().nullable()})}),S=t.z.enum(["pending","success","failure"]),r=t.z.object({compositeId:t.z.string(),id:t.z.string().uuid(),status:S,wallet:e.addressSchemaArgentBackend,txSender:e.addressSchemaArgentBackend,source:t.z.string(),type:w,group:t.z.enum(["finance","security"]),submitted:t.z.number(),lastModified:t.z.number(),transaction:d,transfers:t.z.array(m),fees:t.z.array(g).optional(),relatedAddresses:t.z.array(f).nullable(),network:t.z.string(),networkDetails:N.optional(),details:z,transferSummary:t.z.array(c).optional(),dapp:y.optional(),actions:t.z.array(u.actionSchema).optional(),title:t.z.string().optional(),multisigDetails:t.z.object({signers:t.z.array(e.addressSchemaArgentBackend)}).optional()}),h=t.z.object({title:t.z.string().optional(),shortTitle:t.z.string().optional(),subtitle:t.z.string().optional(),icon:t.z.string().optional(),investment:i.investmentMetaSchema.optional()}),b="native",v="rejected",A="cancelled",k="queued",D=r.pick({status:!0,actions:!0,submitted:!0,lastModified:!0,transferSummary:!0,fees:!0,multisigDetails:!0}).extend({status:t.z.union([S,t.z.enum([v,A,k])]),type:t.z.literal(b),transaction:d.pick({hash:!0}),dapp:u.targetedDappSchema.optional(),meta:h.optional()}),j=t.z.array(r),P=t.z.object({activities:j,page:t.z.number(),pageSize:t.z.number(),totalElements:t.z.number(),totalPages:t.z.number()});function E(a){return p.safeParse(a).success}const o=a=>c.safeParse(a).success,M=a=>o(a)&&a.asset.type==="token",x=a=>o(a)&&a.asset.type==="nft";exports.NativeActivityStatusCancelled=A;exports.NativeActivityStatusQueued=k;exports.NativeActivityStatusRejected=v;exports.NativeActivityTypeNative=b;exports.activitiesSchema=j;exports.activityDappSchema=y;exports.activityDetailsSchema=z;exports.activityResponseSchema=P;exports.activitySchema=r;exports.activitySummarySchema=c;exports.activityTransferSchema=m;exports.feeSchema=g;exports.isActivityDetailsAction=E;exports.isActivitySummary=o;exports.isNftActivitySummary=x;exports.isTokenActivitySummary=M;exports.nativeActivityMetaSchema=h;exports.nativeActivitySchema=D;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("zod"),i=require("../../../staking/schema.cjs"),u=require("../transactionReview/schema.cjs"),e=require("../../../chains/starknet/address.cjs"),d=t.z.object({network:t.z.string(),hash:t.z.string(),status:t.z.string(),blockNumber:t.z.number().optional(),transactionIndex:t.z.number()}),n=t.z.object({type:t.z.enum(["token","nft"]),tokenAddress:e.addressSchemaArgentBackend,amount:t.z.string().optional(),fiatAmount:t.z.object({currency:t.z.string(),currencyAmount:t.z.number()}).optional().nullable()}),s=t.z.enum(["ethereum","starknet","zksync","zksync2"]),m=t.z.object({type:t.z.enum(["payment","gasFee"]),leg:t.z.enum(["credit","debit"]),asset:n,counterParty:e.addressSchemaArgentBackend.optional(),counterPartyNetwork:s.optional()}),f=t.z.object({address:e.addressSchemaArgentBackend,network:s,type:t.z.enum(["wallet","token"])}),N=t.z.object({chainId:t.z.enum(["TESTNET","MAINNET","SEPOLIA"]),ethereumNetwork:t.z.enum(["mainnet","sepolia"])}),w=t.z.enum(["approval","changePubKey","dappInteraction","deploy","gift","multicall","payment","security","trade","staking"]),p=t.z.enum(["triggerEscapeGuardian","triggerEscapeSigner","escapeGuardian","escapeSigner","guardianChanged","guardianBackupChanged","signerChanged","cancelEscape","accountUpgraded","multisigConfigurationUpdated"]),B=t.z.object({name:t.z.string(),parameters:t.z.array(t.z.unknown()).optional()}),I=t.z.object({guid:t.z.string().optional(),signerType:t.z.string().optional(),signer:t.z.object({publicKey:t.z.string().optional()}).optional()}),T=t.z.object({activeAt:t.z.string().optional(),newGuardian:t.z.string().optional(),newImplementation:t.z.string().optional(),newVersion:t.z.string().optional(),signerGuid:t.z.string().optional(),signers:t.z.array(I).optional()}),l=t.z.discriminatedUnion("type",[t.z.object({type:t.z.literal("deploy"),deployer:e.addressSchemaArgentBackend,contractAddress:e.addressSchemaArgentBackend}),t.z.object({type:t.z.literal("approval"),spender:e.addressSchemaArgentBackend,asset:n,approvalType:t.z.string()}),t.z.object({type:t.z.literal("payment"),counterparty:e.addressSchemaArgentBackend,leg:t.z.string(),asset:n,counterpartyNetwork:s.optional()}),t.z.object({type:t.z.literal("trade"),srcAsset:n,destAsset:n}),t.z.object({type:t.z.literal("security"),action:p,context:T.optional()}),t.z.object({type:t.z.literal("dappInteraction"),dappAddress:e.addressSchemaArgentBackend,function:B.optional().nullable()}),t.z.object({type:t.z.literal("staking"),stakingAction:i.stakingActionSchema,counterparty:e.addressSchemaArgentBackend,asset:n,stakerInfo:i.stakerInfoSchema})]),z=t.z.union([l,t.z.object({type:t.z.literal("multicall"),calls:t.z.array(t.z.object({details:l}))})]),y=t.z.object({dappId:t.z.string(),name:t.z.string().optional().nullable()}),c=t.z.object({sent:t.z.boolean(),asset:t.z.discriminatedUnion("type",[t.z.object({type:t.z.literal("nft"),tokenAddress:e.addressSchemaArgentBackend,tokenId:t.z.coerce.number().optional(),amount:t.z.string().optional(),collectionName:t.z.string().optional(),collectionPreviewImage:t.z.string().optional().nullable(),nftName:t.z.string().optional().nullable(),nftPreviewImage:t.z.string().optional().nullable()}),t.z.object({type:t.z.literal("token"),tokenAddress:e.addressSchemaArgentBackend,amount:t.z.string().optional(),fiatAmount:t.z.object({currency:t.z.string(),currencyAmount:t.z.coerce.string()}).optional().nullable()})])}),g=t.z.object({type:t.z.string(),to:e.addressSchemaArgentBackend,actualFee:t.z.object({type:t.z.string(),tokenAddress:e.addressSchemaArgentBackend,amount:t.z.string().optional(),fiatAmount:t.z.object({currency:t.z.string(),currencyAmount:t.z.number()}).optional().nullable()})}),S=t.z.enum(["pending","success","failure"]),r=t.z.object({compositeId:t.z.string(),id:t.z.string().uuid(),status:S,wallet:e.addressSchemaArgentBackend,txSender:e.addressSchemaArgentBackend,source:t.z.string(),type:w,group:t.z.enum(["finance","security"]),submitted:t.z.number(),lastModified:t.z.number(),transaction:d,transfers:t.z.array(m),fees:t.z.array(g).optional(),relatedAddresses:t.z.array(f).nullable(),network:t.z.string(),networkDetails:N.optional(),details:z,transferSummary:t.z.array(c).optional(),dapp:y.optional(),actions:t.z.array(u.actionSchema).optional(),title:t.z.string().optional(),multisigDetails:t.z.object({signers:t.z.array(e.addressSchemaArgentBackend)}).optional()}),h=t.z.object({title:t.z.string().optional(),shortTitle:t.z.string().optional(),subtitle:t.z.string().optional(),icon:t.z.string().optional(),investment:i.investmentMetaSchema.optional(),isExecuteFromOutside:t.z.boolean().optional()}),b="native",v="rejected",A="cancelled",k="queued",D=r.pick({status:!0,actions:!0,submitted:!0,lastModified:!0,transferSummary:!0,fees:!0,multisigDetails:!0}).extend({status:t.z.union([S,t.z.enum([v,A,k])]),type:t.z.literal(b),transaction:d.pick({hash:!0}),dapp:u.targetedDappSchema.optional(),meta:h.optional()}),j=t.z.array(r),E=t.z.object({activities:j,page:t.z.number(),pageSize:t.z.number(),totalElements:t.z.number(),totalPages:t.z.number()});function P(a){return p.safeParse(a).success}const o=a=>c.safeParse(a).success,x=a=>o(a)&&a.asset.type==="token",M=a=>o(a)&&a.asset.type==="nft";exports.NativeActivityStatusCancelled=A;exports.NativeActivityStatusQueued=k;exports.NativeActivityStatusRejected=v;exports.NativeActivityTypeNative=b;exports.activitiesSchema=j;exports.activityDappSchema=y;exports.activityDetailsSchema=z;exports.activityResponseSchema=E;exports.activitySchema=r;exports.activitySummarySchema=c;exports.activityTransferSchema=m;exports.feeSchema=g;exports.isActivityDetailsAction=P;exports.isActivitySummary=o;exports.isNftActivitySummary=M;exports.isTokenActivitySummary=x;exports.nativeActivityMetaSchema=h;exports.nativeActivitySchema=D;
@@ -4628,6 +4628,7 @@ export declare const nativeActivityMetaSchema: z.ZodObject<{
4628
4628
  };
4629
4629
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
4630
4630
  }>>;
4631
+ isExecuteFromOutside: z.ZodOptional<z.ZodBoolean>;
4631
4632
  }, "strip", z.ZodTypeAny, {
4632
4633
  icon?: string | undefined;
4633
4634
  title?: string | undefined;
@@ -4643,6 +4644,7 @@ export declare const nativeActivityMetaSchema: z.ZodObject<{
4643
4644
  };
4644
4645
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
4645
4646
  } | undefined;
4647
+ isExecuteFromOutside?: boolean | undefined;
4646
4648
  }, {
4647
4649
  icon?: string | undefined;
4648
4650
  title?: string | undefined;
@@ -4658,6 +4660,7 @@ export declare const nativeActivityMetaSchema: z.ZodObject<{
4658
4660
  };
4659
4661
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
4660
4662
  } | undefined;
4663
+ isExecuteFromOutside?: boolean | undefined;
4661
4664
  }>;
4662
4665
  export type NativeActivityMeta = z.infer<typeof nativeActivityMetaSchema>;
4663
4666
  export declare const NativeActivityTypeNative = "native";
@@ -7030,6 +7033,7 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7030
7033
  };
7031
7034
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
7032
7035
  }>>;
7036
+ isExecuteFromOutside: z.ZodOptional<z.ZodBoolean>;
7033
7037
  }, "strip", z.ZodTypeAny, {
7034
7038
  icon?: string | undefined;
7035
7039
  title?: string | undefined;
@@ -7045,6 +7049,7 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7045
7049
  };
7046
7050
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
7047
7051
  } | undefined;
7052
+ isExecuteFromOutside?: boolean | undefined;
7048
7053
  }, {
7049
7054
  icon?: string | undefined;
7050
7055
  title?: string | undefined;
@@ -7060,6 +7065,7 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7060
7065
  };
7061
7066
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
7062
7067
  } | undefined;
7068
+ isExecuteFromOutside?: boolean | undefined;
7063
7069
  }>>;
7064
7070
  }>, "strip", z.ZodTypeAny, {
7065
7071
  status: "rejected" | "pending" | "success" | "failure" | "cancelled" | "queued";
@@ -7254,6 +7260,7 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7254
7260
  };
7255
7261
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
7256
7262
  } | undefined;
7263
+ isExecuteFromOutside?: boolean | undefined;
7257
7264
  } | undefined;
7258
7265
  }, {
7259
7266
  status: "rejected" | "pending" | "success" | "failure" | "cancelled" | "queued";
@@ -7448,6 +7455,7 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7448
7455
  };
7449
7456
  stakingAction: "deposit" | "stake" | "initiateWithdraw" | "withdraw" | "claim";
7450
7457
  } | undefined;
7458
+ isExecuteFromOutside?: boolean | undefined;
7451
7459
  } | undefined;
7452
7460
  }>;
7453
7461
  export type NativeActivity = z.infer<typeof nativeActivitySchema>;
@@ -183,14 +183,15 @@ const r = t.object({
183
183
  multisigDetails: t.object({
184
184
  signers: t.array(e)
185
185
  }).optional()
186
- }), T = t.object({
186
+ }), E = t.object({
187
187
  title: t.string().optional(),
188
188
  shortTitle: t.string().optional(),
189
189
  subtitle: t.string().optional(),
190
190
  /** let's not import the keys from x-ui here */
191
191
  icon: t.string().optional(),
192
- investment: g.optional()
193
- }), D = "native", E = "rejected", P = "cancelled", x = "queued", B = p.pick({
192
+ investment: g.optional(),
193
+ isExecuteFromOutside: t.boolean().optional()
194
+ }), T = "native", x = "rejected", D = "cancelled", P = "queued", F = p.pick({
194
195
  status: !0,
195
196
  actions: !0,
196
197
  submitted: !0,
@@ -202,18 +203,18 @@ const r = t.object({
202
203
  status: t.union([
203
204
  l,
204
205
  t.enum([
205
- E,
206
- P,
207
- x
206
+ x,
207
+ D,
208
+ P
208
209
  ])
209
210
  ]),
210
- type: t.literal(D),
211
+ type: t.literal(T),
211
212
  transaction: r.pick({
212
213
  hash: !0
213
214
  }),
214
215
  dapp: b.optional(),
215
- meta: T.optional()
216
- }), M = t.array(p), F = t.object({
216
+ meta: E.optional()
217
+ }), M = t.array(p), B = t.object({
217
218
  activities: M,
218
219
  page: t.number(),
219
220
  pageSize: t.number(),
@@ -223,24 +224,24 @@ const r = t.object({
223
224
  function K(n) {
224
225
  return s.safeParse(n).success;
225
226
  }
226
- const u = (n) => c.safeParse(n).success, R = (n) => u(n) && n.asset.type === "token", q = (n) => u(n) && n.asset.type === "nft";
227
+ const u = (n) => c.safeParse(n).success, O = (n) => u(n) && n.asset.type === "token", R = (n) => u(n) && n.asset.type === "nft";
227
228
  export {
228
- P as NativeActivityStatusCancelled,
229
- x as NativeActivityStatusQueued,
230
- E as NativeActivityStatusRejected,
231
- D as NativeActivityTypeNative,
229
+ D as NativeActivityStatusCancelled,
230
+ P as NativeActivityStatusQueued,
231
+ x as NativeActivityStatusRejected,
232
+ T as NativeActivityTypeNative,
232
233
  M as activitiesSchema,
233
234
  N as activityDappSchema,
234
235
  w as activityDetailsSchema,
235
- F as activityResponseSchema,
236
+ B as activityResponseSchema,
236
237
  p as activitySchema,
237
238
  c as activitySummarySchema,
238
239
  S as activityTransferSchema,
239
240
  I as feeSchema,
240
241
  K as isActivityDetailsAction,
241
242
  u as isActivitySummary,
242
- q as isNftActivitySummary,
243
- R as isTokenActivitySummary,
244
- T as nativeActivityMetaSchema,
245
- B as nativeActivitySchema
243
+ R as isNftActivitySummary,
244
+ O as isTokenActivitySummary,
245
+ E as nativeActivityMetaSchema,
246
+ F as nativeActivitySchema
246
247
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../../node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.cjs"),P=require("./isNumeric.cjs"),c={CURRENCY:{minDecimalPlaces:2,maxDecimalPlaces:10,minDecimalSignificantDigits:2,decimalPlacesWhenZero:2,allowLeadingZerosInDecimalPart:!0},TOKEN:{minDecimalPlaces:4,maxDecimalPlaces:16,minDecimalSignificantDigits:2,decimalPlacesWhenZero:1,allowLeadingZerosInDecimalPart:!0}},C=(t,e)=>l(t,{...c.CURRENCY,...e||{}}),S=(t,e)=>l(t,{...c.TOKEN,...e||{}}),l=(t,{minDecimalPlaces:e,maxDecimalPlaces:N,minDecimalSignificantDigits:p,decimalPlacesWhenZero:m,allowLeadingZerosInDecimalPart:o}=c.CURRENCY)=>{if(!P.isNumeric(t))return null;const r=new f.BigNumber(typeof t=="bigint"?t.toString():t);let i;const b=`0.${"".padStart(m-1,"0")}1`;if(r.lt(new f.BigNumber(b))&&!o)i=`0.${"".padStart(m,"0")}`;else if(r.gte(1))i=r.toFormat(e);else{const s=r.toFormat(N).split(".")[1].match(/^0+/),y=o&&s&&s.length?s[0].length:0,D=Math.max(y+p,e);i=r.toFormat(D)}const[d,u]=i.split(".");let n=d;if(u){const a=u.replace(/0+$/,"");n+=a?`.${a}`:""}const g=1+i.indexOf(".")+m;return n.length<g&&(n=i.substring(0,g)),n};exports.prettifyCurrencyNumber=C;exports.prettifyNumber=l;exports.prettifyNumberConfig=c;exports.prettifyTokenNumber=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../../node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.cjs"),P=require("./isNumeric.cjs"),c={CURRENCY:{minDecimalPlaces:2,maxDecimalPlaces:10,minDecimalSignificantDigits:2,decimalPlacesWhenZero:2,allowLeadingZerosInDecimalPart:!0},TOKEN:{minDecimalPlaces:4,maxDecimalPlaces:16,minDecimalSignificantDigits:2,decimalPlacesWhenZero:1,allowLeadingZerosInDecimalPart:!0}},h=(t,e)=>l(t,{...c.CURRENCY,...e||{}}),C=(t,e)=>l(t,{...c.TOKEN,...e||{}}),l=(t,{minDecimalPlaces:e,maxDecimalPlaces:N,minDecimalSignificantDigits:p,decimalPlacesWhenZero:m,allowLeadingZerosInDecimalPart:u}=c.CURRENCY)=>{if(!P.isNumeric(t))return null;const r=new s.BigNumber(typeof t=="bigint"?t.toString():t);let i;const b=`0.${"".padStart(m-1,"0")}1`;if(r.lt(new s.BigNumber(b))&&!u)i=`0.${"".padStart(m,"0")}`;else if(r.gte(1))i=e!==0?r.toFormat(e):r.toFormat(e,s.BigNumber.ROUND_FLOOR);else{const o=r.toFormat(N).split(".")[1].match(/^0+/),d=u&&o&&o.length?o[0].length:0,y=Math.max(d+p,e);i=r.toFormat(y)}const[D,g]=i.split(".");let a=D;if(g){const n=g.replace(/0+$/,"");a+=n?`.${n}`:""}const f=1+i.indexOf(".")+m;return a.length<f&&(a=i.substring(0,f)),a};exports.prettifyCurrencyNumber=h;exports.prettifyNumber=l;exports.prettifyNumberConfig=c;exports.prettifyTokenNumber=C;
@@ -1,6 +1,6 @@
1
- import { BigNumber as f } from "../../../node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.js";
1
+ import { BigNumber as m } from "../../../node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.js";
2
2
  import { isNumeric as C } from "./isNumeric.js";
3
- const l = {
3
+ const s = {
4
4
  CURRENCY: {
5
5
  minDecimalPlaces: 2,
6
6
  maxDecimalPlaces: 10,
@@ -15,38 +15,38 @@ const l = {
15
15
  decimalPlacesWhenZero: 1,
16
16
  allowLeadingZerosInDecimalPart: !0
17
17
  }
18
- }, R = (t, e) => p(t, {
19
- ...l.CURRENCY,
18
+ }, y = (t, e) => D(t, {
19
+ ...s.CURRENCY,
20
20
  ...e || {}
21
- }), b = (t, e) => p(t, {
22
- ...l.TOKEN,
21
+ }), O = (t, e) => D(t, {
22
+ ...s.TOKEN,
23
23
  ...e || {}
24
- }), p = (t, { minDecimalPlaces: e, maxDecimalPlaces: u, minDecimalSignificantDigits: D, decimalPlacesWhenZero: c, allowLeadingZerosInDecimalPart: o } = l.CURRENCY) => {
24
+ }), D = (t, { minDecimalPlaces: e, maxDecimalPlaces: p, minDecimalSignificantDigits: u, decimalPlacesWhenZero: c, allowLeadingZerosInDecimalPart: l } = s.CURRENCY) => {
25
25
  if (!C(t))
26
26
  return null;
27
- const r = new f(typeof t == "bigint" ? t.toString() : t);
28
- let i;
29
- const d = `0.${"".padStart(c - 1, "0")}1`;
30
- if (r.lt(new f(d)) && !o)
31
- i = `0.${"".padStart(c, "0")}`;
32
- else if (r.gte(1))
33
- i = r.toFormat(e);
27
+ const i = new m(typeof t == "bigint" ? t.toString() : t);
28
+ let r;
29
+ const N = `0.${"".padStart(c - 1, "0")}1`;
30
+ if (i.lt(new m(N)) && !l)
31
+ r = `0.${"".padStart(c, "0")}`;
32
+ else if (i.gte(1))
33
+ r = e !== 0 ? i.toFormat(e) : i.toFormat(e, m.ROUND_FLOOR);
34
34
  else {
35
- const m = r.toFormat(u).split(".")[1].match(/^0+/), P = o && m && m.length ? m[0].length : 0, h = Math.max(P + D, e);
36
- i = r.toFormat(h);
35
+ const o = i.toFormat(p).split(".")[1].match(/^0+/), P = l && o && o.length ? o[0].length : 0, h = Math.max(P + u, e);
36
+ r = i.toFormat(h);
37
37
  }
38
- const [N, s] = i.split(".");
39
- let n = N;
40
- if (s) {
41
- const a = s.replace(/0+$/, "");
38
+ const [d, g] = r.split(".");
39
+ let n = d;
40
+ if (g) {
41
+ const a = g.replace(/0+$/, "");
42
42
  n += a ? `.${a}` : "";
43
43
  }
44
- const g = 1 + i.indexOf(".") + c;
45
- return n.length < g && (n = i.substring(0, g)), n;
44
+ const f = 1 + r.indexOf(".") + c;
45
+ return n.length < f && (n = r.substring(0, f)), n;
46
46
  };
47
47
  export {
48
- R as prettifyCurrencyNumber,
49
- p as prettifyNumber,
50
- l as prettifyNumberConfig,
51
- b as prettifyTokenNumber
48
+ y as prettifyCurrencyNumber,
49
+ D as prettifyNumber,
50
+ s as prettifyNumberConfig,
51
+ O as prettifyTokenNumber
52
52
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@argent/x-shared",
3
- "version": "1.49.1",
3
+ "version": "1.50.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/argentlabs/x-shared.git"