@argent/x-shared 1.48.2 → 1.49.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.
Files changed (40) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.js +457 -455
  3. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/_shortw_utils.js +3 -3
  4. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/modular.js +5 -5
  5. package/dist/node_modules/.pnpm/@noble_curves@1.0.0/node_modules/@noble/curves/esm/abstract/weierstrass.js +2 -2
  6. package/dist/node_modules/.pnpm/@noble_hashes@1.3.3/node_modules/@noble/hashes/esm/sha3.js +2 -2
  7. package/dist/node_modules/.pnpm/@noble_hashes@1.5.0/node_modules/@noble/hashes/esm/_md.cjs +1 -0
  8. package/dist/node_modules/.pnpm/@noble_hashes@1.5.0/node_modules/@noble/hashes/esm/_md.js +64 -0
  9. package/dist/node_modules/.pnpm/@noble_hashes@1.5.0/node_modules/@noble/hashes/esm/sha256.cjs +1 -0
  10. package/dist/node_modules/.pnpm/@noble_hashes@1.5.0/node_modules/@noble/hashes/esm/sha256.js +115 -0
  11. package/dist/node_modules/.pnpm/@noble_hashes@1.5.0/node_modules/@noble/hashes/esm/sha3.js +2 -2
  12. package/dist/node_modules/.pnpm/@noble_hashes@1.5.0/node_modules/@noble/hashes/esm/utils.cjs +1 -1
  13. package/dist/node_modules/.pnpm/@noble_hashes@1.5.0/node_modules/@noble/hashes/esm/utils.js +12 -10
  14. package/dist/node_modules/.pnpm/micro-starknet@0.2.3/node_modules/micro-starknet/lib/esm/index.cjs +1 -1
  15. package/dist/node_modules/.pnpm/micro-starknet@0.2.3/node_modules/micro-starknet/lib/esm/index.js +55 -58
  16. package/dist/src/accountNameGenerator/colors.cjs +1 -0
  17. package/dist/src/accountNameGenerator/colors.d.ts +2 -0
  18. package/dist/src/accountNameGenerator/colors.js +25 -0
  19. package/dist/src/accountNameGenerator/index.cjs +1 -0
  20. package/dist/src/accountNameGenerator/index.d.ts +9 -0
  21. package/dist/src/accountNameGenerator/index.js +24 -0
  22. package/dist/src/accountNameGenerator/types.d.ts +18 -0
  23. package/dist/src/accountNameGenerator/x-names.json.cjs +1 -0
  24. package/dist/src/accountNameGenerator/x-names.json.js +1926 -0
  25. package/dist/src/chains/starknet/services/deploymentData/findImplementationForAccount.js +1 -1
  26. package/dist/src/features/simulation/activity/schema.js +3 -3
  27. package/dist/src/features/simulation/activity/utils/createNativeActivity.js +3 -3
  28. package/dist/src/features/simulation/transactionReview/schema.js +4 -4
  29. package/dist/src/features/swap/models/trade.model.js +3 -3
  30. package/dist/src/index.d.ts +1 -0
  31. package/dist/src/nfts/BackendNftService.cjs +1 -1
  32. package/dist/src/nfts/BackendNftService.js +3 -3
  33. package/dist/src/tokens/service/types/backend.model.js +1 -1
  34. package/dist/src/transactions/estimate/utils.js +1 -1
  35. package/dist/src/transactions/transactionVersion.js +1 -1
  36. package/dist/src/transactions/txv3.cjs +1 -1
  37. package/dist/src/transactions/txv3.js +4 -4
  38. package/dist/src/utils/number/prettifyNumber.cjs +1 -1
  39. package/dist/src/utils/number/prettifyNumber.js +27 -22
  40. package/package.json +25 -25
@@ -1,5 +1,5 @@
1
1
  import g from "../../../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/uniqWith.js";
2
- import { CallData as f, CairoOption as p, CairoOptionVariant as u, hash as h } from "starknet";
2
+ import { CairoOption as p, CairoOptionVariant as u, CallData as f, hash as h } from "starknet";
3
3
  import { z as H } from "zod";
4
4
  import { getSignerForMultiSigner as d, MultiSigner as A } from "../../../../signer/multisigner.js";
5
5
  import { AccountError as D } from "../../../../errors/account.js";
@@ -1,5 +1,5 @@
1
1
  import { z as t } from "zod";
2
- import { stakingActionSchema as m, stakerInfoSchema as d, investmentMetaSchema as g } from "../../../staking/schema.js";
2
+ import { stakerInfoSchema as m, stakingActionSchema as d, investmentMetaSchema as g } from "../../../staking/schema.js";
3
3
  import { actionSchema as y, targetedDappSchema as b } from "../transactionReview/schema.js";
4
4
  import { addressSchemaArgentBackend as e } from "../../../chains/starknet/address.js";
5
5
  const r = t.object({
@@ -105,10 +105,10 @@ const r = t.object({
105
105
  }),
106
106
  t.object({
107
107
  type: t.literal("staking"),
108
- stakingAction: m,
108
+ stakingAction: d,
109
109
  counterparty: e,
110
110
  asset: a,
111
- stakerInfo: d
111
+ stakerInfo: m
112
112
  })
113
113
  ]), w = t.union([
114
114
  o,
@@ -1,6 +1,6 @@
1
1
  import { isEmpty as f } from "lodash-es";
2
2
  import { normalizeActivitySummaryCollection as y } from "../normalize.js";
3
- import { NativeActivityTypeNative as v, nativeActivitySchema as u } from "../schema.js";
3
+ import { nativeActivitySchema as v, NativeActivityTypeNative as u } from "../schema.js";
4
4
  function S(t) {
5
5
  var n, o;
6
6
  const a = (o = (n = t.transactions) == null ? void 0 : n[0].reviewOfTransaction) == null ? void 0 : o.reviews;
@@ -9,7 +9,7 @@ function S(t) {
9
9
  function z({ simulateAndReview: t, ...a }) {
10
10
  var n, o, c;
11
11
  const r = {
12
- type: v,
12
+ type: u,
13
13
  ...a
14
14
  };
15
15
  if (t && !f(t.transactions)) {
@@ -23,7 +23,7 @@ function z({ simulateAndReview: t, ...a }) {
23
23
  const m = S(t);
24
24
  m && (r.actions = m);
25
25
  }
26
- return u.parse(r);
26
+ return v.parse(r);
27
27
  }
28
28
  export {
29
29
  z as createNativeActivity,
@@ -1,7 +1,7 @@
1
1
  import { z as t } from "zod";
2
2
  import { estimatedFeesSchema as b } from "../fees/schema.js";
3
- import { reasonsSchema as u, severitySchema as S } from "../warning/schema.js";
4
- import { addressSchema as f, addressSchemaArgentBackend as o } from "../../../chains/starknet/address.js";
3
+ import { severitySchema as u, reasonsSchema as S } from "../warning/schema.js";
4
+ import { addressSchemaArgentBackend as o, addressSchema as f } from "../../../chains/starknet/address.js";
5
5
  const h = t.object({
6
6
  name: t.string(),
7
7
  url: t.string(),
@@ -73,9 +73,9 @@ const h = t.object({
73
73
  reason: t.string().optional(),
74
74
  value: t.string().or(t.number()).optional()
75
75
  }), l = t.object({
76
- reason: u,
76
+ reason: S,
77
77
  details: k.optional(),
78
- severity: S
78
+ severity: u
79
79
  }), v = t.object({
80
80
  assessment: y,
81
81
  warnings: t.array(l).optional(),
@@ -1,6 +1,6 @@
1
1
  import { z as e } from "zod";
2
2
  import { webTokenSchema as n } from "../../../tokens/service/types/webToken.model.js";
3
- import { SwapQuoteRouteSchema as o, SwapDataSchema as a } from "./quote.model.js";
3
+ import { SwapDataSchema as o, SwapQuoteRouteSchema as a } from "./quote.model.js";
4
4
  var t;
5
5
  (function(r) {
6
6
  r.EXACT_PAY = "EXACT_PAY", r.EXACT_RECEIVE = "EXACT_RECEIVE";
@@ -18,8 +18,8 @@ const m = e.nativeEnum(t), p = e.object({
18
18
  totalFeePercentage: e.number(),
19
19
  expiresAt: e.number(),
20
20
  expiresIn: e.number(),
21
- route: o,
22
- data: a
21
+ route: a,
22
+ data: o
23
23
  });
24
24
  export {
25
25
  p as TradeSchema,
@@ -16,4 +16,5 @@ export * from './storage';
16
16
  export * from './tokens';
17
17
  export * from './transactions';
18
18
  export * from './utils';
19
+ export * from './accountNameGenerator';
19
20
  export type { BigDecimal } from './bigdecimal/types';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("url-join"),f=require("./BackendPaginationError.cjs"),A=require("../utils/address.cjs"),P=require("../chains/starknet/address.cjs"),u=32;class S{constructor(e,t){this.apiBase=e,this.httpService=t}async getNfts(e,t,r,s=1){const a=this.normalizeAddress(r),c=o(this.apiBase,"pandora",e,t),m=this.pageToPageIndex(s),l=`${o(c,"profile",a,"nfts")}?page=${m}&size=${u}`,i=await this.httpService.get(l),n=i.content.map(p=>this.mapItem(p,r));return{totalPages:i.totalPages,page:i.number+1,count:n.length,nfts:n}}async getCollection(e,t,r){const s=this.normalizeAddress(r),a=o(this.apiBase,"pandora",e,t),c=o(a,"collection",s),m=`${a}/collection/${s}`,[g,l]=await Promise.all([this.httpService.get(c),this.httpService.get(m)]),i=h(g),n=l.content.map(p=>this.mapItem(p));return{...i,nfts:{totalPages:l.totalPages,page:l.number,count:n.length,data:n}}}async getNft(e,t,r,s){const a=this.normalizeAddress(r),c=o(this.apiBase,"pandora",e,t),m=o(c,"nft",a,s),g=await this.httpService.get(m);return this.mapItem(g)}async getProfileCollections(e,t,r,s=1,a=!1){const c=this.pageToPageIndex(s),m=this.normalizeAddress(r),g=o(this.apiBase,"pandora",e,t),l=o(g,"profile",m,"collections",`?page=${c}&size=${u}`),i=await this.httpService.get(l),n=[];for(const p of i.content)if(a){const b=await this.getCollectionMetrics(e,t,p.contractAddress);n.push(h(p,b))}else n.push(h(p));return{totalPages:i.totalPages,page:i.number+1,count:n.length,collections:n}}async getCollectionMetrics(e,t,r){const s=this.normalizeAddress(r),a=o(this.apiBase,"pandora",e,t),c=o(a,"collection",s,"metrics");return this.httpService.get(c)}normalizeAddress(e){return P.addressSchemaArgentBackend.parse(e)}pageToPageIndex(e){if(!Number.isInteger(e))throw new f.BackendPaginationError("notANumber");const t=e-1;if(t<0)throw new f.BackendPaginationError("tooLow");return t}mapItem(e,t){var s;const r=e.name??e.tokenId;return{token_id:e.tokenId,contract_address:e.contractAddress,name:r,spec:"spec"in e?v(e.spec):void 0,description:"",best_bid_order:{payment_amount:"bestListPrice"in e?BigInt(e.bestListPrice):void 0},properties:"properties"in e&&e.properties.map(a=>({key:a.key,value:a.value}))||[],image_uri:e.imageUrls.preview,image_url_copy:e.imageUrls.full,owner:{account_address:((s=e.owner)==null?void 0:s.address)||t},contract_name:A.formatAddress(e.contractAddress)}}}function v(d){switch(d){case"erc721":case"starknetErc721":return"ERC721";case"erc1155":case"starknetErc1155":return"ERC1155"}}function h(d,e){return{contractAddress:P.addressSchema.parse(d.contractAddress),name:d.name||A.formatAddress(d.contractAddress),description:d.description??"",imageUri:d.imageUrls.preview,...e&&{owners:{total:e.numberOfItems,unique:e.uniqueOwners},...e.floorPrice&&{floorPrice:BigInt(e.floorPrice)}}}}exports.BackendNftService=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("url-join"),f=require("./BackendPaginationError.cjs"),A=require("../chains/starknet/address.cjs"),P=require("../utils/address.cjs"),u=32;class S{constructor(e,t){this.apiBase=e,this.httpService=t}async getNfts(e,t,r,s=1){const a=this.normalizeAddress(r),c=o(this.apiBase,"pandora",e,t),m=this.pageToPageIndex(s),l=`${o(c,"profile",a,"nfts")}?page=${m}&size=${u}`,i=await this.httpService.get(l),n=i.content.map(p=>this.mapItem(p,r));return{totalPages:i.totalPages,page:i.number+1,count:n.length,nfts:n}}async getCollection(e,t,r){const s=this.normalizeAddress(r),a=o(this.apiBase,"pandora",e,t),c=o(a,"collection",s),m=`${a}/collection/${s}`,[g,l]=await Promise.all([this.httpService.get(c),this.httpService.get(m)]),i=h(g),n=l.content.map(p=>this.mapItem(p));return{...i,nfts:{totalPages:l.totalPages,page:l.number,count:n.length,data:n}}}async getNft(e,t,r,s){const a=this.normalizeAddress(r),c=o(this.apiBase,"pandora",e,t),m=o(c,"nft",a,s),g=await this.httpService.get(m);return this.mapItem(g)}async getProfileCollections(e,t,r,s=1,a=!1){const c=this.pageToPageIndex(s),m=this.normalizeAddress(r),g=o(this.apiBase,"pandora",e,t),l=o(g,"profile",m,"collections",`?page=${c}&size=${u}`),i=await this.httpService.get(l),n=[];for(const p of i.content)if(a){const b=await this.getCollectionMetrics(e,t,p.contractAddress);n.push(h(p,b))}else n.push(h(p));return{totalPages:i.totalPages,page:i.number+1,count:n.length,collections:n}}async getCollectionMetrics(e,t,r){const s=this.normalizeAddress(r),a=o(this.apiBase,"pandora",e,t),c=o(a,"collection",s,"metrics");return this.httpService.get(c)}normalizeAddress(e){return A.addressSchemaArgentBackend.parse(e)}pageToPageIndex(e){if(!Number.isInteger(e))throw new f.BackendPaginationError("notANumber");const t=e-1;if(t<0)throw new f.BackendPaginationError("tooLow");return t}mapItem(e,t){var s;const r=e.name??e.tokenId;return{token_id:e.tokenId,contract_address:e.contractAddress,name:r,spec:"spec"in e?v(e.spec):void 0,description:"",best_bid_order:{payment_amount:"bestListPrice"in e?BigInt(e.bestListPrice):void 0},properties:"properties"in e&&e.properties.map(a=>({key:a.key,value:a.value}))||[],image_uri:e.imageUrls.preview,image_url_copy:e.imageUrls.full,owner:{account_address:((s=e.owner)==null?void 0:s.address)||t},contract_name:P.formatAddress(e.contractAddress)}}}function v(d){switch(d){case"erc721":case"starknetErc721":return"ERC721";case"erc1155":case"starknetErc1155":return"ERC1155"}}function h(d,e){return{contractAddress:A.addressSchema.parse(d.contractAddress),name:d.name||P.formatAddress(d.contractAddress),description:d.description??"",imageUri:d.imageUrls.preview,...e&&{owners:{total:e.numberOfItems,unique:e.uniqueOwners},...e.floorPrice&&{floorPrice:BigInt(e.floorPrice)}}}}exports.BackendNftService=S;
@@ -1,7 +1,7 @@
1
1
  import n from "url-join";
2
2
  import { BackendPaginationError as f } from "./BackendPaginationError.js";
3
+ import { addressSchema as P, addressSchemaArgentBackend as S } from "../chains/starknet/address.js";
3
4
  import { formatAddress as b } from "../utils/address.js";
4
- import { addressSchemaArgentBackend as P, addressSchema as S } from "../chains/starknet/address.js";
5
5
  const A = 32;
6
6
  class k {
7
7
  constructor(e, t) {
@@ -55,7 +55,7 @@ class k {
55
55
  return this.httpService.get(c);
56
56
  }
57
57
  normalizeAddress(e) {
58
- return P.parse(e);
58
+ return S.parse(e);
59
59
  }
60
60
  pageToPageIndex(e) {
61
61
  if (!Number.isInteger(e))
@@ -99,7 +99,7 @@ function w(d) {
99
99
  }
100
100
  function h(d, e) {
101
101
  return {
102
- contractAddress: S.parse(d.contractAddress),
102
+ contractAddress: P.parse(d.contractAddress),
103
103
  name: d.name || b(d.contractAddress),
104
104
  description: d.description ?? "",
105
105
  imageUri: d.imageUrls.preview,
@@ -1,5 +1,5 @@
1
1
  import { z as t } from "zod";
2
- import { addressSchemaArgentBackend as o, addressSchema as a } from "../../../chains/starknet/address.js";
2
+ import { addressSchema as a, addressSchemaArgentBackend as o } from "../../../chains/starknet/address.js";
3
3
  import { defiPositionTypeSchema as d } from "./defiPositionType.model.js";
4
4
  import { createSchemaWithWarnings as g } from "../../../utils/schemas.js";
5
5
  const f = t.object({
@@ -1,5 +1,5 @@
1
1
  import { upperCase as T } from "lodash-es";
2
- import { CallData as C, uint256 as U, num as r } from "starknet";
2
+ import { num as r, CallData as C, uint256 as U } from "starknet";
3
3
  import { isEqualAddress as I } from "../../chains/starknet/address.js";
4
4
  import { STRK_TOKEN_ADDRESS as y, ETH_TOKEN_ADDRESS as A } from "../../chains/starknet/constants.js";
5
5
  import { argentMaxFee as h } from "./argentMaxFee.js";
@@ -1,4 +1,4 @@
1
- import { constants as r, num as n } from "starknet";
1
+ import { num as n, constants as r } from "starknet";
2
2
  import { z as s } from "zod";
3
3
  const i = Object.values(r.TRANSACTION_VERSION), m = s.string().default("0x3").refine((t) => {
4
4
  const o = n.toBigInt(t);
@@ -1 +1 @@
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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chains/starknet/constants.cjs"),o=require("../chains/starknet/services/deploymentData/getAccountClassHash.cjs"),t=require("../chains/starknet/address.cjs"),u=[r.STRK_TOKEN_ADDRESS];function n({address:e}){return u.some(s=>t.isEqualAddress(e,s))}function a(e){return e?o.getArgentAccountClassHashesWithTxV3Support().some(s=>t.isEqualAddress(s,e)):!1}exports.classHashSupportsTxV3=a;exports.feeTokenNeedsTxV3Support=n;
@@ -1,12 +1,12 @@
1
- import { getArgentAccountClassHashesWithTxV3Support as t } from "../chains/starknet/services/deploymentData/getAccountClassHash.js";
2
- import { STRK_TOKEN_ADDRESS as s } from "../chains/starknet/constants.js";
1
+ import { STRK_TOKEN_ADDRESS as t } from "../chains/starknet/constants.js";
2
+ import { getArgentAccountClassHashesWithTxV3Support as s } from "../chains/starknet/services/deploymentData/getAccountClassHash.js";
3
3
  import { isEqualAddress as o } from "../chains/starknet/address.js";
4
- const n = [s];
4
+ const n = [t];
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 ? t().some((e) => o(e, r)) : !1;
9
+ return r ? s().some((e) => o(e, r)) : !1;
10
10
  }
11
11
  export {
12
12
  m as classHashSupportsTxV3,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../../../node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.cjs"),D=require("./isNumeric.cjs"),n={CURRENCY:{minDecimalPlaces:2,maxDecimalPlaces:10,minDecimalSignificantDigits:2,decimalPlacesWhenZero:2,allowLeadingZerosInDecimalPart:!0},TOKEN:{minDecimalPlaces:4,maxDecimalPlaces:16,minDecimalSignificantDigits:2,decimalPlacesWhenZero:1,allowLeadingZerosInDecimalPart:!0}},d=(e,t)=>o(e,{...n.CURRENCY,...t||{}}),P=(e,t)=>o(e,{...n.TOKEN,...t||{}}),o=(e,{minDecimalPlaces:t,maxDecimalPlaces:g,minDecimalSignificantDigits:f,decimalPlacesWhenZero:a,allowLeadingZerosInDecimalPart:s}=n.CURRENCY)=>{if(!D.isNumeric(e))return null;const r=new u.BigNumber(typeof e=="bigint"?e.toString():e);let i;const N=`0.${"".padStart(a-1,"0")}1`;if(r.lt(new u.BigNumber(N))&&!s)i=`0.${"".padStart(a,"0")}`;else if(r.gte(1))i=r.toFormat(t);else{const m=r.toFormat(g).split(".")[1].match(/^0+/),b=s&&m&&m.length?m[0].length:0,y=Math.max(b+f,t);i=r.toFormat(y)}let c=i.replace(/0+$/,"");const l=1+i.indexOf(".")+a;return c.length<l&&(c=i.substring(0,l)),c};exports.prettifyCurrencyNumber=d;exports.prettifyNumber=o;exports.prettifyNumberConfig=n;exports.prettifyTokenNumber=P;
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,6 +1,6 @@
1
- import { BigNumber as s } from "../../../node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.js";
2
- import { isNumeric as P } from "./isNumeric.js";
3
- const m = {
1
+ import { BigNumber as f } from "../../../node_modules/.pnpm/bignumber.js@9.1.2/node_modules/bignumber.js/bignumber.js";
2
+ import { isNumeric as C } from "./isNumeric.js";
3
+ const l = {
4
4
  CURRENCY: {
5
5
  minDecimalPlaces: 2,
6
6
  maxDecimalPlaces: 10,
@@ -15,33 +15,38 @@ const m = {
15
15
  decimalPlacesWhenZero: 1,
16
16
  allowLeadingZerosInDecimalPart: !0
17
17
  }
18
- }, x = (t, e) => g(t, {
19
- ...m.CURRENCY,
18
+ }, R = (t, e) => p(t, {
19
+ ...l.CURRENCY,
20
20
  ...e || {}
21
- }), y = (t, e) => g(t, {
22
- ...m.TOKEN,
21
+ }), b = (t, e) => p(t, {
22
+ ...l.TOKEN,
23
23
  ...e || {}
24
- }), g = (t, { minDecimalPlaces: e, maxDecimalPlaces: f, minDecimalSignificantDigits: u, decimalPlacesWhenZero: n, allowLeadingZerosInDecimalPart: o } = m.CURRENCY) => {
25
- if (!P(t))
24
+ }), p = (t, { minDecimalPlaces: e, maxDecimalPlaces: u, minDecimalSignificantDigits: D, decimalPlacesWhenZero: c, allowLeadingZerosInDecimalPart: o } = l.CURRENCY) => {
25
+ if (!C(t))
26
26
  return null;
27
- const r = new s(typeof t == "bigint" ? t.toString() : t);
27
+ const r = new f(typeof t == "bigint" ? t.toString() : t);
28
28
  let i;
29
- const p = `0.${"".padStart(n - 1, "0")}1`;
30
- if (r.lt(new s(p)) && !o)
31
- i = `0.${"".padStart(n, "0")}`;
29
+ const d = `0.${"".padStart(c - 1, "0")}1`;
30
+ if (r.lt(new f(d)) && !o)
31
+ i = `0.${"".padStart(c, "0")}`;
32
32
  else if (r.gte(1))
33
33
  i = r.toFormat(e);
34
34
  else {
35
- const c = r.toFormat(f).split(".")[1].match(/^0+/), N = o && c && c.length ? c[0].length : 0, d = Math.max(N + u, e);
36
- i = r.toFormat(d);
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);
37
37
  }
38
- let a = i.replace(/0+$/, "");
39
- const l = 1 + i.indexOf(".") + n;
40
- return a.length < l && (a = i.substring(0, l)), a;
38
+ const [N, s] = i.split(".");
39
+ let n = N;
40
+ if (s) {
41
+ const a = s.replace(/0+$/, "");
42
+ n += a ? `.${a}` : "";
43
+ }
44
+ const g = 1 + i.indexOf(".") + c;
45
+ return n.length < g && (n = i.substring(0, g)), n;
41
46
  };
42
47
  export {
43
- x as prettifyCurrencyNumber,
44
- g as prettifyNumber,
45
- m as prettifyNumberConfig,
46
- y as prettifyTokenNumber
48
+ R as prettifyCurrencyNumber,
49
+ p as prettifyNumber,
50
+ l as prettifyNumberConfig,
51
+ b as prettifyTokenNumber
47
52
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@argent/x-shared",
3
- "version": "1.48.2",
3
+ "version": "1.49.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/argentlabs/x-shared.git"
@@ -43,29 +43,29 @@
43
43
  "format:fix": "prettier . --ignore-unknown --write"
44
44
  },
45
45
  "devDependencies": {
46
- "@amplitude/analytics-types": "^2.7.0",
47
- "@commitlint/cli": "^19.0.0",
48
- "@commitlint/config-conventional": "^19.0.0",
49
- "@rollup/plugin-typescript": "^12.0.0",
50
- "@semantic-release/git": "^10.0.1",
51
- "@types/async-retry": "^1.4.8",
52
- "@types/lodash-es": "^4.17.6",
53
- "@types/ua-parser-js": "^0.7.39",
54
- "@typescript-eslint/eslint-plugin": "^8.0.0",
55
- "@typescript-eslint/parser": "^8.0.0",
56
- "eslint": "^8.7.0",
57
- "eslint-config-prettier": "^9.1.0",
58
- "eslint-plugin-import": "^2.29.1",
59
- "husky": ">=7",
60
- "lint-staged": ">=10",
61
- "msw": "^2.0.0",
62
- "prettier": "^3.2.5",
63
- "semantic-release": "^24.0.0",
64
- "ts-to-zod": "^3.2.0",
65
- "typescript": "^5.0.4",
66
- "vite": "^5.0.0",
67
- "vite-plugin-dts": "^4.0.0",
68
- "vitest": "2.1.4"
46
+ "@amplitude/analytics-types": "2.8.4",
47
+ "@commitlint/cli": "19.5.0",
48
+ "@commitlint/config-conventional": "19.5.0",
49
+ "@rollup/plugin-typescript": "12.1.1",
50
+ "@semantic-release/git": "10.0.1",
51
+ "@types/async-retry": "1.4.9",
52
+ "@types/lodash-es": "4.17.12",
53
+ "@types/ua-parser-js": "0.7.39",
54
+ "@typescript-eslint/eslint-plugin": "8.14.0",
55
+ "@typescript-eslint/parser": "8.14.0",
56
+ "eslint": "8.57.1",
57
+ "eslint-config-prettier": "9.1.0",
58
+ "eslint-plugin-import": "2.31.0",
59
+ "husky": "9.1.6",
60
+ "lint-staged": "15.2.10",
61
+ "msw": "2.6.5",
62
+ "prettier": "3.3.3",
63
+ "semantic-release": "24.2.0",
64
+ "ts-to-zod": "3.13.0",
65
+ "typescript": "5.6.3",
66
+ "vite": "5.4.11",
67
+ "vite-plugin-dts": "4.3.0",
68
+ "vitest": "2.1.5"
69
69
  },
70
70
  "dependencies": {
71
71
  "@argent/x-multicall": "^7.1.0",
@@ -82,7 +82,7 @@
82
82
  "@scure/bip39": "^1.2.1",
83
83
  "async-retry": "^1.3.3",
84
84
  "lodash-es": "^4.17.21",
85
- "ua-parser-js": "^1.0.38",
85
+ "ua-parser-js": "^1.0.38 || ^2.0.0",
86
86
  "url-join": "^5.0.0",
87
87
  "zod": "^3.23.8"
88
88
  },