@argent/x-shared 1.34.5 → 1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bips-CP71ZN9a.js +1 -0
- package/dist/bips-zBtnMbia.mjs +114 -0
- package/dist/chains/starknet/address.d.ts +2 -2
- package/dist/errors/swap.d.ts +12 -0
- package/dist/features/swap/index.d.ts +3 -0
- package/dist/features/swap/models/index.d.ts +3 -0
- package/dist/features/swap/models/order.model.d.ts +48 -0
- package/dist/features/swap/models/quote.model.d.ts +82 -0
- package/dist/features/swap/models/trade.model.d.ts +186 -0
- package/dist/features/swap/services/implementation.d.ts +14 -0
- package/dist/features/swap/services/index.d.ts +2 -0
- package/dist/features/swap/services/interface.d.ts +8 -0
- package/dist/features/swap/services/order.mock.d.ts +7 -0
- package/dist/features/swap/services/quote.mock.d.ts +29 -0
- package/dist/features/swap/tests/token.mock.d.ts +2 -0
- package/dist/features/swap/tests/trade.mock.d.ts +2 -0
- package/dist/features/swap/tests/walletAccount.mock.d.ts +43 -0
- package/dist/features/swap/utils/index.d.ts +2 -0
- package/dist/features/swap/utils/slippage.d.ts +16 -0
- package/dist/features/swap/utils/totalFee.d.ts +5 -0
- package/dist/index.js +2 -2
- package/dist/index.mjs +1326 -1407
- package/dist/nfts/BackendNftService.d.ts +2 -4
- package/dist/nfts/INFTService.d.ts +1 -1
- package/dist/simulation.js +1 -1
- package/dist/simulation.mjs +101 -100
- package/dist/swap.d.ts +2 -0
- package/dist/swap.js +1 -0
- package/dist/swap.mjs +183 -0
- package/dist/tokens/service/implementation.d.ts +3 -3
- package/dist/tokens/service/interface.d.ts +2 -2
- package/dist/tokens/service/types/defiPosition.model.d.ts +117 -0
- package/dist/tokens/service/types/index.d.ts +1 -0
- package/dist/tokens/service/types/{token.model.d.ts → webToken.model.d.ts} +27 -18
- package/dist/transactionVersion-CACUj2ch.mjs +793 -0
- package/dist/transactionVersion-CaRQ5Df4.js +1 -0
- package/dist/utils/bips.d.ts +7 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/webToken.model-Cl4dvcmj.mjs +1881 -0
- package/dist/webToken.model-Dsd8Rd3e.js +1 -0
- package/package.json +9 -2
- package/dist/transactionVersion-CL9JUEKt.js +0 -1
- package/dist/transactionVersion-CpEa4gsg.mjs +0 -2661
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const t=require("zod"),a=require("./webToken.model-Dsd8Rd3e.js"),l=require("starknet"),C=require("lodash-es");require("@scure/base");require("react");require("object-hash");require("swr");const vt="0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",Et="0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",kt="0x1a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003",It="0x036078334509b514626504edc9fb252328d1a240e4e948bef8d0c08dff45927f",Nt="0x737ee2f87ce571a58c6c8da558ec18a07ceb64a6172d5ec46171fbc80077a48",wt="0x6e150953b26271a740bf2b6e9bca17cc52c68d765f761295de51ceb8526ee72",jt="0x4d07e40e93398ed3c76981e72dd1fd22557a78ce36c0515f679e27f0bb5bc5f";var B={};function m(e,n){typeof n=="boolean"&&(n={forever:n}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=n||{},this._maxRetryTime=n&&n.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}var Dt=m;m.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)};m.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null};m.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var n=new Date().getTime();if(e&&n-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var i=this._timeouts.shift();if(i===void 0)if(this._cachedTimeouts)this._errors.splice(0,this._errors.length-1),i=this._cachedTimeouts.slice(-1);else return!1;var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},i),this._options.unref&&this._timer.unref(),!0};m.prototype.attempt=function(e,n){this._fn=e,n&&(n.timeout&&(this._operationTimeout=n.timeout),n.cb&&(this._operationTimeoutCb=n.cb));var i=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){i._operationTimeoutCb()},i._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};m.prototype.try=function(e){this.attempt(e)};m.prototype.start=function(e){this.attempt(e)};m.prototype.start=m.prototype.try;m.prototype.errors=function(){return this._errors};m.prototype.attempts=function(){return this._attempts};m.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},n=null,i=0,r=0;r<this._errors.length;r++){var s=this._errors[r],c=s.message,o=(e[c]||0)+1;e[c]=o,o>=i&&(n=s,i=o)}return n};(function(e){var n=Dt;e.operation=function(i){var r=e.timeouts(i);return new n(r,{forever:i&&(i.forever||i.retries===1/0),unref:i&&i.unref,maxRetryTime:i&&i.maxRetryTime})},e.timeouts=function(i){if(i instanceof Array)return[].concat(i);var r={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var s in i)r[s]=i[s];if(r.minTimeout>r.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var c=[],o=0;o<r.retries;o++)c.push(this.createTimeout(o,r));return i&&i.forever&&!c.length&&c.push(this.createTimeout(o,r)),c.sort(function(u,g){return u-g}),c},e.createTimeout=function(i,r){var s=r.randomize?Math.random()+1:1,c=Math.round(s*Math.max(r.minTimeout,1)*Math.pow(r.factor,i));return c=Math.min(c,r.maxTimeout),c},e.wrap=function(i,r,s){if(r instanceof Array&&(s=r,r=null),!s){s=[];for(var c in i)typeof i[c]=="function"&&s.push(c)}for(var o=0;o<s.length;o++){var u=s[o],g=i[u];i[u]=(function(_t){var h=e.operation(r),S=Array.prototype.slice.call(arguments,1),Tt=S.pop();S.push(function(P){h.retry(P)||(P&&(arguments[0]=h.mainError()),Tt.apply(this,arguments))}),h.attempt(function(){_t.apply(i,S)})}).bind(i,g),i[u].options=r}}})(B);exports.TOKEN_ERROR_MESSAGES=void 0;(function(e){e.NO_TOKEN_API_URL="NO_TOKEN_API_URL is not defined",e.NO_TOKEN_PRICE_API_URL="NO_TOKEN_PRICE_API_URL is not defined",e.TOKENS_DEFI_DECOMPOSITION_URL="TOKENS_DEFI_DECOMPOSITION_URL is not defined",e.TOKENS_AIRDROPS_API_URL="TOKENS_AIRDROPS_API_URL is not defined",e.TOKEN_PARSING_ERROR="Unable to parse token data response",e.TOKEN_PRICE_PARSING_ERROR="Unable to parse token price response",e.TOKEN_DEFI_DECOMPOSITION_PARSING_ERROR="Unable to parse token defi decomposition response",e.TOKEN_PRICE_NOT_FOUND="Token price not found",e.TOKEN_NOT_FOUND="Token not found",e.TOKEN_DETAILS_NOT_FOUND="Token details not found",e.FEE_TOKEN_NOT_FOUND="Fee token not found",e.UNABLE_TO_CALCULATE_CURRENCY_VALUE="Unable to calculate currency value",e.UNSAFE_DECIMALS="Unsafe decimals in token"})(exports.TOKEN_ERROR_MESSAGES||(exports.TOKEN_ERROR_MESSAGES={}));class Ot extends a.BaseError{constructor(n){super(n,exports.TOKEN_ERROR_MESSAGES),this.name="TokenError"}}const U=a.webTokenWithBalanceAndPriceSchema.extend({accruedFees:t.z.string(),currentPrice:t.z.string(),maxPrice:t.z.string(),minPrice:t.z.string(),principal:t.z.string()}),L=t.z.object({address:a.addressSchema.optional(),currencyValue:t.z.string().default("0")}),T=L.extend({poolFeePercentage:t.z.string(),tickSpacingPercentage:t.z.string().optional(),tokenId:t.z.string().optional(),unitCurrencyValueToken0:t.z.string().optional(),unitCurrencyValueToken1:t.z.string().optional(),token0:U,token1:U}),Rt=t.z.array(T),Pt=t.z.object({name:t.z.string().optional(),healthRatio:t.z.string().optional(),accountAddress:a.addressSchema.optional()}),v=L.extend({totalBalances:t.z.record(t.z.string()),collateral:t.z.boolean(),debt:t.z.boolean(),lending:t.z.boolean(),apy:t.z.string().optional(),group:t.z.string().optional(),unitCurrencyValue:t.z.string().optional(),positionToken:a.apiTokenInfoSchema.or(t.z.undefined()),token:a.webTokenWithBalanceAndPriceSchema.optional(),accountAddress:a.addressSchema.optional(),accountAddressGroup:t.z.string().optional()}),Ct=t.z.array(v),V=T.or(v),H=t.z.record(t.z.object({name:t.z.string().optional(),healthRatio:t.z.string().optional(),accountAddress:a.addressSchema.optional()})),M=t.z.object({type:a.defiPositionTypeSchema,manageUrl:t.z.string().url().optional(),name:t.z.string(),positions:t.z.array(V),positionsTotalValue:t.z.string(),brandColor:t.z.string().optional(),groups:H.optional(),accountAddress:a.addressSchema}),K=t.z.array(M),Ut=t.z.object({dappId:t.z.string(),products:K}),G=t.z.object({name:t.z.string().optional(),tokenAddress:a.addressSchema,token:a.apiTokenInfoSchema.optional(),amount:t.z.string().optional(),claimUrl:t.z.string().optional(),claimStart:t.z.number(),claimEnd:t.z.number().optional()}),Ft=t.z.array(G),q=(e,n=18)=>a.parseUnits(e.replace(",","."),Number(n)),X=t.z.string().trim().refine(e=>e!=="",{message:"Amount is required"}).refine(e=>{try{const n=q(e).value;if(n<0n)throw new Error("Amount must be positive");if(n===0n)throw new Error("Amount can not be zero");if(n>l.uint256.UINT_256_MAX)throw new Error("Amount is too big")}catch{throw new Error("Amount should be a number")}return!0},{message:"Invalid amount"}),xt=e=>!!X.parse(e),W=t.z.object({data:t.z.object({code:t.z.string().optional(),name:t.z.string().optional(),message:t.z.string()})}),Bt=e=>{const n=W.safeParse(e);if(n.success)return n.data.data.message},Lt=3,E=process.env.FEE_OVERHEAD?parseFloat(process.env.FEE_OVERHEAD):Lt,Vt=1.5,z=10,J=({estimatedFee:e,overheadMultiplier:n=E})=>{const r=l.num.toBigInt(e)*BigInt(n*z)/BigInt(z);return l.num.toHex(r)},Ht=({suggestedMaxFee:e,overheadMultiplier:n=E,starknetJsOverheadMultiplier:i=Vt})=>{const s=l.num.toBigInt(e)*BigInt(z)/BigInt(i*z);return J({estimatedFee:s,overheadMultiplier:n})};exports.ESTIMATE_ERROR_MESSAGES=void 0;(function(e){e.SIMULATE_AND_REVIEW_FAILED="Missing simulation"})(exports.ESTIMATE_ERROR_MESSAGES||(exports.ESTIMATE_ERROR_MESSAGES={}));class Mt extends a.BaseError{constructor(n){super(n,exports.ESTIMATE_ERROR_MESSAGES),this.name="EstimateError"}}const Kt=t.z.object({type:t.z.enum(["DECLARE","DEPLOY","DEPLOY_ACCOUNT","INVOKE"]).default("INVOKE"),calls:t.z.array(a.callSchema).or(a.callSchema).optional(),calldata:t.z.array(t.z.string()).optional(),classHash:a.hexSchema.optional(),salt:a.hexSchema.optional(),signature:t.z.array(t.z.string()).optional()}),Gt=t.z.object({amount:t.z.bigint(),pricePerUnit:t.z.bigint()}).or(t.z.object({maxFee:t.z.bigint()})),y=t.z.object({feeTokenAddress:a.addressSchema,amount:t.z.bigint(),pricePerUnit:t.z.bigint(),max:Gt.optional(),dataGasConsumed:t.z.bigint().optional(),dataGasPrice:t.z.bigint().optional()}),Y=t.z.object({deployment:y.optional(),transactions:y}),Q=t.z.union([t.z.literal("critical"),t.z.literal("high"),t.z.literal("caution"),t.z.literal("info")]),$=t.z.string(),qt=t.z.object({name:t.z.string(),url:t.z.string(),position:t.z.number()}),f=t.z.object({address:t.z.string(),name:t.z.string(),symbol:t.z.string().optional(),decimals:t.z.number().optional(),unknown:t.z.boolean(),iconUrl:t.z.string().optional(),type:t.z.string()}),b=t.z.discriminatedUnion("type",[t.z.object({type:t.z.literal("amount"),label:t.z.string(),token:f,amount:t.z.string(),usd:t.z.string(),editable:t.z.boolean()}),t.z.object({type:t.z.literal("address"),label:t.z.string(),address:t.z.string(),addressName:t.z.string().optional(),verified:t.z.boolean().optional()}),t.z.object({type:t.z.literal("timestamp"),label:t.z.string(),value:t.z.string()}),t.z.object({type:t.z.literal("token_address"),label:t.z.string(),token:f}),t.z.object({type:t.z.literal("calldata"),label:t.z.string(),entrypoint:t.z.string(),calldata:t.z.array(t.z.string())}),t.z.object({type:t.z.literal("text"),label:t.z.string(),text:t.z.string()}),t.z.object({type:t.z.literal("nft"),label:t.z.string(),token:f})]),k=t.z.object({name:t.z.string(),properties:t.z.array(b),defaultProperties:t.z.array(b).optional()}),Z=t.z.union([t.z.literal("verified"),t.z.literal("neutral"),t.z.literal("partial"),t.z.literal("warn")]),tt=t.z.object({unknown_token:t.z.unknown().optional(),date_of_addition:t.z.string().optional(),contract_address:a.addressSchema.optional(),reason:t.z.string().optional(),value:t.z.string().or(t.z.number()).optional()}),I=t.z.object({reason:$,details:tt.optional(),severity:Q}),et=t.z.object({assessment:Z,warnings:t.z.array(I).optional(),assessmentReasons:t.z.array(t.z.string()).optional(),assessmentDetails:t.z.object({contract_address:t.z.string()}).optional(),action:k}),N=t.z.object({name:t.z.string(),description:t.z.string(),logoUrl:t.z.string(),iconUrl:t.z.string(),argentVerified:t.z.boolean(),links:t.z.array(qt)}),nt=t.z.object({assessment:t.z.union([t.z.literal("verified"),t.z.literal("neutral"),t.z.literal("partial"),t.z.literal("warn")]),warnings:t.z.array(I).optional(),assessmentDetails:t.z.object({contract_address:t.z.string()}).optional(),targetedDapp:N.optional(),reviews:t.z.array(et)}).optional(),at=t.z.object({banner:t.z.string().nullable().optional(),preview:t.z.string().nullable().optional(),full:t.z.string().nullable().optional(),original:t.z.string().nullable().optional()}),Xt=t.z.object({twitter:t.z.string().optional(),external:t.z.string().optional(),discord:t.z.string().optional()}),w=t.z.object({address:a.addressSchemaArgentBackend,decimals:t.z.number().optional(),symbol:t.z.string().optional(),name:t.z.string(),description:t.z.string().optional(),type:t.z.string().optional(),usdValue:t.z.string().optional(),iconUrl:t.z.string().optional(),unknown:t.z.boolean().optional(),imageUrls:at.optional(),links:Xt.optional()}),Wt=t.z.object({tokenAddress:a.addressSchemaArgentBackend,owner:a.addressSchemaArgentBackend,spender:a.addressSchemaArgentBackend,value:t.z.string().optional(),approvalForAll:t.z.boolean(),details:w.optional()}),Jt=t.z.object({tokenAddress:a.addressSchemaArgentBackend,from:a.addressSchemaArgentBackend,to:a.addressSchemaArgentBackend,tokenId:t.z.string().optional(),value:t.z.string().optional(),details:w.optional()}),d=t.z.union([t.z.string(),t.z.number(),t.z.bigint()]).transform(e=>parseInt(e.toString(),10)),F={overallFee:d,gasPrice:d,gasUsage:d,dataGasPrice:d.optional(),dataGasConsumed:d.optional()},it=t.z.object({...F,unit:t.z.string().transform(e=>e.toUpperCase()).pipe(t.z.literal("WEI")),maxFee:d}).or(t.z.object({...F,unit:t.z.string().transform(e=>e.toUpperCase()).pipe(t.z.literal("FRI")),maxAmount:d,maxPricePerUnit:d})),Yt=t.z.object({type:t.z.string(),label:t.z.string(),tokenId:t.z.string().optional(),value:t.z.string().optional(),usdValue:t.z.string().optional(),token:w,sent:t.z.boolean().optional(),tokenIdDetails:t.z.object({name:t.z.string().optional(),description:t.z.string().optional(),imageUrls:at.optional()}).optional()}),Qt=t.z.object({approvals:t.z.array(Wt).optional(),transfers:t.z.array(Jt).optional(),calculatedNonce:t.z.string().optional(),feeEstimation:it,summary:t.z.array(Yt).optional()}),$t=t.z.object({label:t.z.string().optional(),code:t.z.number().optional(),message:t.z.string().optional(),error:t.z.string().optional()}),rt=t.z.object({reviewOfTransaction:nt,simulation:Qt,simulationError:t.z.undefined()}),ot=t.z.object({reviewOfTransaction:nt,simulation:t.z.undefined(),simulationError:$t}),st=rt.or(ot),Zt=t.z.object({transactions:t.z.array(st)}),te=t.z.object({transactions:t.z.array(st),enrichedFeeEstimation:Y.optional(),isBackendDown:t.z.boolean().default(!1).optional()});function ee(e){return rt.safeParse(e).success}function ne(e){return ot.safeParse(e).success}const ct=t.z.object({network:t.z.string(),hash:t.z.string(),status:t.z.string(),blockNumber:t.z.number().optional(),transactionIndex:t.z.number()}),p=t.z.object({type:t.z.enum(["token","nft"]),tokenAddress:a.addressSchemaArgentBackend,amount:t.z.string().optional(),fiatAmount:t.z.object({currency:t.z.string(),currencyAmount:t.z.number()}).optional().nullable()}),j=t.z.enum(["ethereum","starknet","zksync","zksync2"]),lt=t.z.object({type:t.z.enum(["payment","gasFee"]),leg:t.z.enum(["credit","debit"]),asset:p,counterParty:a.addressSchemaArgentBackend.optional(),counterPartyNetwork:j.optional()}),ae=t.z.object({address:a.addressSchemaArgentBackend,network:j,type:t.z.enum(["wallet","token"])}),ie=t.z.object({chainId:t.z.enum(["TESTNET","MAINNET","SEPOLIA"]),ethereumNetwork:t.z.enum(["mainnet","sepolia"])}),re=t.z.enum(["approval","changePubKey","dappInteraction","deploy","gift","multicall","payment","security","trade"]),mt=t.z.enum(["triggerEscapeGuardian","triggerEscapeSigner","escapeGuardian","escapeSigner","guardianChanged","guardianBackupChanged","signerChanged","cancelEscape","accountUpgraded","multisigConfigurationUpdated"]),oe=t.z.object({name:t.z.string(),parameters:t.z.array(t.z.unknown()).optional()}),se=t.z.object({guid:t.z.string().optional(),signerType:t.z.string().optional(),signer:t.z.object({publicKey:t.z.string().optional()}).optional()}),ce=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(se).optional()}),x=t.z.discriminatedUnion("type",[t.z.object({type:t.z.literal("deploy"),deployer:a.addressSchemaArgentBackend,contractAddress:a.addressSchemaArgentBackend}),t.z.object({type:t.z.literal("approval"),spender:a.addressSchemaArgentBackend,asset:p,approvalType:t.z.string()}),t.z.object({type:t.z.literal("payment"),counterparty:a.addressSchemaArgentBackend,leg:t.z.string(),asset:p,counterpartyNetwork:j.optional()}),t.z.object({type:t.z.literal("trade"),srcAsset:p,destAsset:p}),t.z.object({type:t.z.literal("security"),action:mt,context:ce.optional()}),t.z.object({type:t.z.literal("dappInteraction"),dappAddress:a.addressSchemaArgentBackend,function:oe.optional().nullable()})]),ut=t.z.union([x,t.z.object({type:t.z.literal("multicall"),calls:t.z.array(t.z.object({details:x}))})]),dt=t.z.object({dappId:t.z.string(),name:t.z.string().optional().nullable()}),D=t.z.object({sent:t.z.boolean(),asset:t.z.discriminatedUnion("type",[t.z.object({type:t.z.literal("nft"),tokenAddress:a.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:a.addressSchemaArgentBackend,amount:t.z.string().optional(),fiatAmount:t.z.object({currency:t.z.string(),currencyAmount:t.z.coerce.string()}).optional().nullable()})])}),pt=t.z.object({type:t.z.string(),to:a.addressSchemaArgentBackend,actualFee:t.z.object({type:t.z.string(),tokenAddress:a.addressSchemaArgentBackend,amount:t.z.string().optional(),fiatAmount:t.z.object({currency:t.z.string(),currencyAmount:t.z.number()}).optional().nullable()})}),zt=t.z.enum(["pending","success","failure"]),O=t.z.object({compositeId:t.z.string(),id:t.z.string().uuid(),status:zt,wallet:a.addressSchemaArgentBackend,txSender:a.addressSchemaArgentBackend,source:t.z.string(),type:re,group:t.z.enum(["finance","security"]),submitted:t.z.number(),lastModified:t.z.number(),transaction:ct,transfers:t.z.array(lt),fees:t.z.array(pt).optional(),relatedAddresses:t.z.array(ae).nullable(),network:t.z.string(),networkDetails:ie.optional(),details:ut,transferSummary:t.z.array(D).optional(),dapp:dt.optional(),actions:t.z.array(k).optional(),title:t.z.string().optional(),multisigDetails:t.z.object({signers:t.z.array(a.addressSchemaArgentBackend)}).optional()}),gt=t.z.object({title:t.z.string().optional(),shortTitle:t.z.string().optional(),subtitle:t.z.string().optional(),icon:t.z.string().optional()}),ht="native",St="rejected",ft="cancelled",yt="queued",le=O.pick({status:!0,actions:!0,submitted:!0,lastModified:!0,transferSummary:!0,fees:!0,multisigDetails:!0}).extend({status:t.z.union([zt,t.z.enum([St,ft,yt])]),type:t.z.literal(ht),transaction:ct.pick({hash:!0}),dapp:N.optional(),meta:gt.optional()}),bt=t.z.array(O),me=t.z.object({activities:bt,page:t.z.number(),pageSize:t.z.number(),totalElements:t.z.number(),totalPages:t.z.number()});function ue(e){return mt.safeParse(e).success}const R=e=>D.safeParse(e).success,de=e=>R(e)&&e.asset.type==="token",pe=e=>R(e)&&e.asset.type==="nft",A={Transfer:l.hash.getSelectorFromName("Transfer"),Approval:l.hash.getSelectorFromName("Approval")},At=(e,n,i)=>{for(const r of e){const{events:s,internal_calls:c}=r;for(const o of s)for(const u of o.keys)u===A.Approval&&n.push({tokenAddress:a.addressSchema.parse(r.contract_address),owner:o.data[0],spender:o.data[1],value:l.uint256.uint256ToBN({low:o.data[2],high:o.data[3]}).toString()}),u===A.Transfer&&i.push({tokenAddress:a.addressSchema.parse(r.contract_address),from:o.data[0],to:o.data[1],value:l.uint256.uint256ToBN({low:o.data[2],high:o.data[3]}).toString()});c&&At(c,n,i)}return{approvals:n,transfers:i}},ze=/(0x[a-fA-F0-9]+)\s*\('(.*?)'\)/,ge=e=>{if(!C.isString(e))return;const n=e.match(ze);if(n&&!C.isEmpty(n[2]))return n[2]};var _;(function(e){e.SIMULATE_AND_REVIEW_FAILED="Something went wrong fetching review",e.NO_CALLS_FOUND="No calls found",e.ONCHAIN_FEE_ESTIMATION_FAILED="Failed to estimate fees onchain"})(_||(_={}));class he extends a.BaseError{constructor(n){super(n,_),this.name="ReviewError"}}const Se=t.z.object({reason:t.z.string(),severity:t.z.string().optional(),title:t.z.string(),description:t.z.string().optional()}),fe=Object.values(l.constants.TRANSACTION_VERSION),ye=t.z.string().default("0x3").refine(e=>{const n=l.num.toBigInt(e);return fe.map(i=>l.num.toBigInt(i)).includes(n)}).transform(e=>l.num.toHex(e));function be(e){if(e===l.constants.TRANSACTION_VERSION.V3||e===l.constants.TRANSACTION_VERSION.F3)throw Error("Only txv1 is supported")}exports.ETH_TOKEN_ADDRESS=vt;exports.EstimateError=Mt;exports.EventsBySelector=A;exports.FEE_OVERHEAD=E;exports.NativeActivityStatusCancelled=ft;exports.NativeActivityStatusQueued=yt;exports.NativeActivityStatusRejected=St;exports.NativeActivityTypeNative=ht;exports.ReviewError=he;exports.STANDARD_DEVNET_ACCOUNT_CLASS_HASH=jt;exports.STRK_TOKEN_ADDRESS=Et;exports.TXV1_ACCOUNT_CLASS_HASH=kt;exports.TXV1_MULTISIG_CLASS_HASH=Nt;exports.TXV3_ACCOUNT_CLASS_HASH=It;exports.TXV3_MULTISIG_CLASS_HASH=wt;exports.TokenError=Ot;exports.actionSchema=k;exports.activitiesSchema=bt;exports.activityDappSchema=dt;exports.activityDetailsSchema=ut;exports.activityResponseSchema=me;exports.activitySchema=O;exports.activitySummarySchema=D;exports.activityTransferSchema=lt;exports.airdropSchema=G;exports.argentMaxFee=J;exports.assessmentSchema=Z;exports.collateralizedDebtGroupSchema=Pt;exports.collateralizedDebtPositionSchema=v;exports.collateralizedDebtPositionsSchema=Ct;exports.concentratedLiquidityPositionSchema=T;exports.concentratedLiquidityPositionsSchema=Rt;exports.defiDappsProductsSchema=Ut;exports.defiPositionSchema=V;exports.defiProductSchema=M;exports.defiProductsSchema=K;exports.denyTxV3=be;exports.enrichedSimulateAndReviewSchema=te;exports.estimatedFeeSchema=y;exports.estimatedFeesSchema=Y;exports.feeEstimationSchema=it;exports.feeSchema=pt;exports.findTransfersAndApprovals=At;exports.getMessageFromTrpcError=Bt;exports.getPrettyRpcError=ge;exports.inputAmountSchema=X;exports.isActivityDetailsAction=ue;exports.isActivitySummary=R;exports.isNftActivitySummary=pe;exports.isNotTransactionSimulationError=ee;exports.isTokenActivitySummary=de;exports.isTransactionSimulationError=ne;exports.isValidInputAmount=xt;exports.modifySnjsFeeOverhead=Ht;exports.nativeActivityMetaSchema=gt;exports.nativeActivitySchema=le;exports.parseAmount=q;exports.productGroupsSchema=H;exports.propertySchema=b;exports.reasonsSchema=$;exports.retry=B;exports.reviewSchema=et;exports.severitySchema=Q;exports.simulateAndReviewSchema=Zt;exports.targetedDappSchema=N;exports.transactionReviewTransactionsSchema=Kt;exports.transactionReviewWarningSchema=Se;exports.trpcErrorSchema=W;exports.txVersionSchema=ye;exports.unclaimedRewardsSchema=Ft;exports.warningDetailsSchema=tt;exports.warningSchema=I;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BigDecimal } from '../bigdecimal';
|
|
2
|
+
/**
|
|
3
|
+
* Converts basis points to a percentage representation.
|
|
4
|
+
* @param bips - The number of basis points.
|
|
5
|
+
* @returns {BigDecimal} - The percentage representation of the basis points.
|
|
6
|
+
*/
|
|
7
|
+
export declare function bipsToPercent(bips: number): BigDecimal;
|
package/dist/utils/index.d.ts
CHANGED