@avalabs/evm-module 0.0.2 → 0.0.5
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/.turbo/turbo-build.log +10 -10
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +12 -3
- package/CHANGELOG.md +22 -0
- package/dist/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -3
- package/dist/index.d.ts +13 -3
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/package.json +17 -4
- package/src/handlers/get-network-fee.test.ts +38 -0
- package/src/handlers/get-network-fee.ts +41 -0
- package/src/handlers/get-transaction-history/converters/etherscan-transaction-converter/convert-transaction-erc20.ts +51 -0
- package/src/handlers/get-transaction-history/converters/etherscan-transaction-converter/convert-transaction-normal.ts +58 -0
- package/src/handlers/get-transaction-history/converters/etherscan-transaction-converter/get-transaction-from-etherscan.test.ts +116 -0
- package/src/handlers/get-transaction-history/converters/etherscan-transaction-converter/get-transaction-from-etherscan.ts +65 -0
- package/src/handlers/get-transaction-history/converters/evm-transaction-converter/convert-transaction.ts +47 -0
- package/src/handlers/get-transaction-history/converters/evm-transaction-converter/get-nft-metadata.ts +35 -0
- package/src/handlers/get-transaction-history/converters/evm-transaction-converter/get-sender-info.ts +38 -0
- package/src/handlers/get-transaction-history/converters/evm-transaction-converter/get-tokens.ts +107 -0
- package/src/handlers/get-transaction-history/converters/evm-transaction-converter/get-transaction-from-glacier.test.ts +213 -0
- package/src/handlers/get-transaction-history/converters/evm-transaction-converter/get-transactions-from-glacier.ts +60 -0
- package/src/handlers/get-transaction-history/converters/evm-transaction-converter/get-tx-type.ts +48 -0
- package/src/handlers/get-transaction-history/index.test.ts +50 -0
- package/src/handlers/get-transaction-history/index.ts +37 -0
- package/src/handlers/get-transaction-history/utils/get-explorer-address-by-network.ts +7 -0
- package/src/handlers/get-transaction-history/utils/get-small-image-for-nft.ts +16 -0
- package/src/handlers/get-transaction-history/utils/ipfs-resolver-with-fallback.ts +18 -0
- package/src/handlers/get-transaction-history/utils/is-ethereum-chain-id.ts +15 -0
- package/src/handlers/get-transaction-history/utils/resolve.ts +7 -0
- package/src/index.ts +32 -20
- package/src/manifest.json +1 -1
- package/src/types.ts +3 -0
- package/tsconfig.json +5 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @avalabs/evm-module@0.0.
|
|
2
|
+
> @avalabs/evm-module@0.0.5 build /home/runner/work/vm-modules/vm-modules/packages/evm-module
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: ./src/index.ts
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mCJS[39m Build start
|
|
12
12
|
[34mESM[39m Build start
|
|
13
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m9.17 KB[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m36.22 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 1258ms
|
|
16
|
+
[32mESM[39m [1mdist/index.js [22m[32m8.54 KB[39m
|
|
17
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m36.22 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 1258ms
|
|
13
19
|
[34mDTS[39m Build start
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[32mESM[39m [1mdist/index.js [22m[32m50.84 KB[39m
|
|
18
|
-
[32mESM[39m [1mdist/index.js.map [22m[32m225.48 KB[39m
|
|
19
|
-
[32mESM[39m ⚡️ Build success in 1484ms
|
|
20
|
-
[32mDTS[39m ⚡️ Build success in 2138ms
|
|
21
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[32m87.00 B[39m
|
|
22
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m87.00 B[39m
|
|
20
|
+
[32mDTS[39m ⚡️ Build success in 8382ms
|
|
21
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m612.00 B[39m
|
|
22
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m612.00 B[39m
|
package/.turbo/turbo-lint.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
|
|
2
|
-
> @avalabs/evm-module@0.0.
|
|
3
|
-
> jest
|
|
2
|
+
> @avalabs/evm-module@0.0.5 test /home/runner/work/vm-modules/vm-modules/packages/evm-module
|
|
3
|
+
> jest
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
PASS src/handlers/get-transaction-history/converters/evm-transaction-converter/get-transaction-from-glacier.test.ts (10.073 s)
|
|
6
|
+
PASS src/handlers/get-transaction-history/converters/etherscan-transaction-converter/get-transaction-from-etherscan.test.ts
|
|
7
|
+
PASS src/handlers/get-transaction-history/index.test.ts
|
|
8
|
+
PASS src/handlers/get-network-fee.test.ts
|
|
9
|
+
|
|
10
|
+
Test Suites: 4 passed, 4 total
|
|
11
|
+
Tests: 12 passed, 12 total
|
|
12
|
+
Snapshots: 0 total
|
|
13
|
+
Time: 11.187 s
|
|
14
|
+
Ran all test suites.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @avalabs/evm-module
|
|
2
2
|
|
|
3
|
+
## 0.0.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0b0c52e: Move types to @avalabs/vm-module-types
|
|
8
|
+
- Updated dependencies [0b0c52e]
|
|
9
|
+
- @avalabs/vm-module-types@0.0.3
|
|
10
|
+
|
|
11
|
+
## 0.0.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 4b7d5e9: Move types from packages-internal/types to packages/types
|
|
16
|
+
- Updated dependencies [4b7d5e9]
|
|
17
|
+
- @avalabs/vm-module-types@0.0.2
|
|
18
|
+
|
|
19
|
+
## 0.0.3
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- 5d5e2e2: Add GetNetworkFee and GetTransactionHistory to evm module
|
|
24
|
+
|
|
3
25
|
## 0.0.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var Pe=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var $e=Pe((Lt,rt)=>{rt.exports={name:"EVM",description:"",version:"0.0.1",sources:{module:{checksum:"",location:{npm:{filePath:"dist/bundle.js",packageName:"@avalabs/evm-module",registry:"https://registry.npmjs.org"}}},provider:{checksum:"",location:{npm:{filePath:"dist/provider.js",packageName:"@avalabs/evm-module",registry:"https://registry.npmjs.org"}}}},network:{chainIds:["eip155:1","eip155:43114","eip155:43113"],namespaces:["eip155"]},cointype:"60",permissions:{rpc:{dapps:!0,methods:["eth_sendTransaction","eth_*"]}},manifestVersion:"0.0"};});var g;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{let a={};for(let i of n)a[i]=i;return a},r.getValidEnumValues=n=>{let a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(let o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(let i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a;})(g||(g={}));var Se;(function(r){r.mergeShapes=(e,t)=>({...e,...t});})(Se||(Se={}));var l=g.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),$=r=>{switch(typeof r){case"undefined":return l.undefined;case"string":return l.string;case"number":return isNaN(r)?l.nan:l.number;case"boolean":return l.boolean;case"function":return l.function;case"bigint":return l.bigint;case"symbol":return l.symbol;case"object":return Array.isArray(r)?l.array:r===null?l.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?l.promise:typeof Map<"u"&&r instanceof Map?l.map:typeof Set<"u"&&r instanceof Set?l.set:typeof Date<"u"&&r instanceof Date?l.date:l.object;default:return l.unknown}},c=g.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);var S=class r extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s];},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s];};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e;}get errors(){return this.issues}format(e){let t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else {let o=s,f=0;for(;f<i.path.length;){let d=i.path[f];f===i.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(t(i))):o[d]=o[d]||{_errors:[]},o=o[d],f++;}}};return n(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,g.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},s=[];for(let n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return {formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};S.create=r=>new S(r);var ee=(r,e)=>{let t;switch(r.code){case c.invalid_type:r.received===l.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,g.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${g.joinValues(r.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${g.joinValues(r.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${g.joinValues(r.options)}, received '${r.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:g.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case c.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case c.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,g.assertNever(r);}return {message:t}},Ve=ee;function _e(){return Ve}var ge=r=>{let{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};if(n.message!==void 0)return {...n,path:a,message:n.message};let o="",f=s.filter(d=>!!d).slice().reverse();for(let d of f)o=d(i,{data:e,defaultError:o}).message;return {...n,path:a,message:o}};function u(r,e){let t=_e(),s=ge({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===ee?void 0:ee].filter(n=>!!n)});r.common.issues.push(s);}var x=class r{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(e,t){let s=[];for(let n of t){if(n.status==="aborted")return y;n.status==="dirty"&&e.dirty(),s.push(n.value);}return {status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let n of t){let a=await n.key,i=await n.value;s.push({key:a,value:i});}return r.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let n of t){let{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return y;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value);}return {status:e.value,value:s}}},y=Object.freeze({status:"aborted"}),Q=r=>({status:"dirty",value:r}),k=r=>({status:"valid",value:r}),Oe=r=>r.status==="aborted",Ce=r=>r.status==="dirty",le=r=>r.status==="valid",fe=r=>typeof Promise<"u"&&r instanceof Promise;function he(r,e,t,s){if(t==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?r!==e||!s:!e.has(r))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?s:t==="a"?s.call(r):s?s.value:e.get(r)}function Ne(r,e,t,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?r!==e||!n:!e.has(r))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(r,t):n?n.value=t:e.set(r,t),t}var h;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message;})(h||(h={}));var K,F,O=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n;}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Ee=(r,e)=>{if(le(e))return {success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:!1,get error(){if(this._error)return this._error;let t=new S(r.common.issues);return this._error=t,this._error}}};function v(r){if(!r)return {};let{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{var f,d;let{message:m}=r;return i.code==="invalid_enum_value"?{message:m??o.defaultError}:typeof o.data>"u"?{message:(f=m??s)!==null&&f!==void 0?f:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(d=m??t)!==null&&d!==void 0?d:o.defaultError}},description:n}}var _=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this);}get description(){return this._def.description}_getType(e){return $(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return {status:new x,ctx:{common:e.parent.common,data:e.data,parsedType:$(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(fe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;let n={common:{issues:[],async:(s=t?.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)},a=this._parseSync({data:e,path:n.path,parent:n});return Ee(n,a)}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:$(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(fe(n)?n:Promise.resolve(n));return Ee(s,a)}refine(e,t){let s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{let i=e(n),o=()=>a.addIssue({code:c.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(f=>f?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new E({schema:this,typeName:p.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return C.create(this,this._def)}nullable(){return R.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return M.create(this,this._def)}promise(){return P.create(this,this._def)}or(e){return U.create([this,e],this._def)}and(e){return B.create(this,e,this._def)}transform(e){return new E({...v(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new J({...v(this._def),innerType:this,defaultValue:t,typeName:p.ZodDefault})}brand(){return new pe({typeName:p.ZodBranded,type:this,...v(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new G({...v(this._def),innerType:this,catchValue:t,typeName:p.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return me.create(this,e)}readonly(){return X.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},De=/^c[^\s-]{8,}$/i,Le=/^[0-9a-z]+$/,ze=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ue=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Be=/^[a-z0-9_-]{21}$/i,We=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,qe=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ye="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",ve,He=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Je=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Ge=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,je="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Xe=new RegExp(`^${je}$`);function Ze(r){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Qe(r){return new RegExp(`^${Ze(r)}$`)}function Ke(r){let e=`${je}T${Ze(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Fe(r,e){return !!((e==="v4"||!e)&&He.test(r)||(e==="v6"||!e)&&Je.test(r))}var D=class r extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==l.string){let a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_type,expected:l.string,received:a.parsedType}),y}let s=new x,n;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?u(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&u(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty());}else if(a.kind==="email")qe.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"email",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")ve||(ve=new RegExp(Ye,"u")),ve.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"emoji",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Ue.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"uuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Be.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"nanoid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")De.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"cuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")Le.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"cuid2",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")ze.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"ulid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data);}catch{n=this._getOrReturnCtx(e,n),u(n,{validation:"url",code:c.invalid_string,message:a.message}),s.dirty();}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"regex",code:c.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?Ke(a).test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Xe.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Qe(a).test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?We.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"duration",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Fe(e.data,a.version)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"ip",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Ge.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"base64",code:c.invalid_string,message:a.message}),s.dirty()):g.assertNever(a);return {status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:c.invalid_string,...h.errToObj(s)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}datetime(e){var t,s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(s=e?.local)!==null&&s!==void 0?s:!1,...h.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...h.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...h.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return !!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return !!this._def.checks.find(e=>e.kind==="date")}get isTime(){return !!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return !!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return !!this._def.checks.find(e=>e.kind==="email")}get isURL(){return !!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return !!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return !!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return !!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return !!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return !!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return !!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return !!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return !!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};D.create=r=>{var e;return new D({checks:[],typeName:p.ZodString,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...v(r)})};function et(r,e){let t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}var te=class r extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf;}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==l.number){let a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_type,expected:l.number,received:a.parsedType}),y}let s,n=new x;for(let a of this._def.checks)a.kind==="int"?g.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:c.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?et(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:c.not_finite,message:a.message}),n.dirty()):g.assertNever(a);return {status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:h.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return !!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&g.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return !0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);}return Number.isFinite(t)&&Number.isFinite(e)}};te.create=r=>new te({checks:[],typeName:p.ZodNumber,coerce:r?.coerce||!1,...v(r)});var re=class r extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte;}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==l.bigint){let a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_type,expected:l.bigint,received:a.parsedType}),y}let s,n=new x;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):g.assertNever(a);return {status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:h.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};re.create=r=>{var e;return new re({checks:[],typeName:p.ZodBigInt,coerce:(e=r?.coerce)!==null&&e!==void 0?e:!1,...v(r)})};var se=class extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==l.boolean){let s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:l.boolean,received:s.parsedType}),y}return k(e.data)}};se.create=r=>new se({typeName:p.ZodBoolean,coerce:r?.coerce||!1,...v(r)});var ne=class r extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==l.date){let a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_type,expected:l.date,received:a.parsedType}),y}if(isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_date}),y}let s=new x,n;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):g.assertNever(a);return {status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};ne.create=r=>new ne({checks:[],coerce:r?.coerce||!1,typeName:p.ZodDate,...v(r)});var ae=class extends _{_parse(e){if(this._getType(e)!==l.symbol){let s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:l.symbol,received:s.parsedType}),y}return k(e.data)}};ae.create=r=>new ae({typeName:p.ZodSymbol,...v(r)});var L=class extends _{_parse(e){if(this._getType(e)!==l.undefined){let s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:l.undefined,received:s.parsedType}),y}return k(e.data)}};L.create=r=>new L({typeName:p.ZodUndefined,...v(r)});var z=class extends _{_parse(e){if(this._getType(e)!==l.null){let s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:l.null,received:s.parsedType}),y}return k(e.data)}};z.create=r=>new z({typeName:p.ZodNull,...v(r)});var ie=class extends _{constructor(){super(...arguments),this._any=!0;}_parse(e){return k(e.data)}};ie.create=r=>new ie({typeName:p.ZodAny,...v(r)});var A=class extends _{constructor(){super(...arguments),this._unknown=!0;}_parse(e){return k(e.data)}};A.create=r=>new A({typeName:p.ZodUnknown,...v(r)});var N=class extends _{_parse(e){let t=this._getOrReturnCtx(e);return u(t,{code:c.invalid_type,expected:l.never,received:t.parsedType}),y}};N.create=r=>new N({typeName:p.ZodNever,...v(r)});var oe=class extends _{_parse(e){if(this._getType(e)!==l.undefined){let s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:l.void,received:s.parsedType}),y}return k(e.data)}};oe.create=r=>new oe({typeName:p.ZodVoid,...v(r)});var M=class r extends _{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==l.array)return u(t,{code:c.invalid_type,expected:l.array,received:t.parsedType}),y;if(n.exactLength!==null){let i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(u(t,{code:i?c.too_big:c.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty());}if(n.minLength!==null&&t.data.length<n.minLength.value&&(u(t,{code:c.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(u(t,{code:c.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new O(t,i,t.path,o)))).then(i=>x.mergeArray(s,i));let a=[...t.data].map((i,o)=>n.type._parseSync(new O(t,i,t.path,o)));return x.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}};M.create=(r,e)=>new M({type:r,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...v(e)});function V(r){if(r instanceof b){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=C.create(V(s));}return new b({...r._def,shape:()=>e})}else return r instanceof M?new M({...r._def,type:V(r.element)}):r instanceof C?C.create(V(r.unwrap())):r instanceof R?R.create(V(r.unwrap())):r instanceof Z?Z.create(r.items.map(e=>V(e))):r}var b=class r extends _{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend;}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=g.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==l.object){let d=this._getOrReturnCtx(e);return u(d,{code:c.invalid_type,expected:l.object,received:d.parsedType}),y}let{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof N&&this._def.unknownKeys==="strip"))for(let d in n.data)i.includes(d)||o.push(d);let f=[];for(let d of i){let m=a[d],T=n.data[d];f.push({key:{status:"valid",value:d},value:m._parse(new O(n,T,n.path,d)),alwaysSet:d in n.data});}if(this._def.catchall instanceof N){let d=this._def.unknownKeys;if(d==="passthrough")for(let m of o)f.push({key:{status:"valid",value:m},value:{status:"valid",value:n.data[m]}});else if(d==="strict")o.length>0&&(u(n,{code:c.unrecognized_keys,keys:o}),s.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let d=this._def.catchall;for(let m of o){let T=n.data[m];f.push({key:{status:"valid",value:m},value:d._parse(new O(n,T,n.path,m)),alwaysSet:m in n.data});}}return n.common.async?Promise.resolve().then(async()=>{let d=[];for(let m of f){let T=await m.key,Te=await m.value;d.push({key:T,value:Te,alwaysSet:m.alwaysSet});}return d}).then(d=>x.mergeObjectSync(s,d)):x.mergeObjectSync(s,f)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;let f=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=h.errToObj(e).message)!==null&&o!==void 0?o:f}:{message:f}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:p.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};return g.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s]);}),new r({...this._def,shape:()=>t})}omit(e){let t={};return g.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s]);}),new r({...this._def,shape:()=>t})}deepPartial(){return V(this)}partial(e){let t={};return g.objectKeys(this.shape).forEach(s=>{let n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional();}),new r({...this._def,shape:()=>t})}required(e){let t={};return g.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else {let a=this.shape[s];for(;a instanceof C;)a=a._def.innerType;t[s]=a;}}),new r({...this._def,shape:()=>t})}keyof(){return Re(g.objectKeys(this.shape))}};b.create=(r,e)=>new b({shape:()=>r,unknownKeys:"strip",catchall:N.create(),typeName:p.ZodObject,...v(e)});b.strictCreate=(r,e)=>new b({shape:()=>r,unknownKeys:"strict",catchall:N.create(),typeName:p.ZodObject,...v(e)});b.lazycreate=(r,e)=>new b({shape:r,unknownKeys:"strip",catchall:N.create(),typeName:p.ZodObject,...v(e)});var U=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new S(o.ctx.common.issues));return u(t,{code:c.invalid_union,unionErrors:i}),y}if(t.common.async)return Promise.all(s.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return {result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a,i=[];for(let f of s){let d={...t,common:{...t.common,issues:[]},parent:null},m=f._parseSync({data:t.data,path:t.path,parent:d});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:d}),d.common.issues.length&&i.push(d.common.issues);}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(f=>new S(f));return u(t,{code:c.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}};U.create=(r,e)=>new U({options:r,typeName:p.ZodUnion,...v(e)});function ke(r,e){let t=$(r),s=$(e);if(r===e)return {valid:!0,data:r};if(t===l.object&&s===l.object){let n=g.objectKeys(e),a=g.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(let o of a){let f=ke(r[o],e[o]);if(!f.valid)return {valid:!1};i[o]=f.data;}return {valid:!0,data:i}}else if(t===l.array&&s===l.array){if(r.length!==e.length)return {valid:!1};let n=[];for(let a=0;a<r.length;a++){let i=r[a],o=e[a],f=ke(i,o);if(!f.valid)return {valid:!1};n.push(f.data);}return {valid:!0,data:n}}else return t===l.date&&s===l.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var B=class extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(Oe(a)||Oe(i))return y;let o=ke(a.value,i.value);return o.valid?((Ce(a)||Ce(i))&&t.dirty(),{status:t.value,value:o.data}):(u(s,{code:c.invalid_intersection_types}),y)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};B.create=(r,e,t)=>new B({left:r,right:e,typeName:p.ZodIntersection,...v(t)});var Z=class r extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==l.array)return u(s,{code:c.invalid_type,expected:l.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return u(s,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(u(s,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...s.data].map((i,o)=>{let f=this._def.items[o]||this._def.rest;return f?f._parse(new O(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>x.mergeArray(t,i)):x.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};Z.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Z({items:r,typeName:p.ZodTuple,rest:null,...v(e)})};var ce=class extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==l.map)return u(s,{code:c.invalid_type,expected:l.map,received:s.parsedType}),y;let n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,f],d)=>({key:n._parse(new O(s,o,s.path,[d,"key"])),value:a._parse(new O(s,f,s.path,[d,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let f of i){let d=await f.key,m=await f.value;if(d.status==="aborted"||m.status==="aborted")return y;(d.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(d.value,m.value);}return {status:t.value,value:o}})}else {let o=new Map;for(let f of i){let d=f.key,m=f.value;if(d.status==="aborted"||m.status==="aborted")return y;(d.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(d.value,m.value);}return {status:t.value,value:o}}}};ce.create=(r,e,t)=>new ce({valueType:e,keyType:r,typeName:p.ZodMap,...v(t)});var de=class r extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==l.set)return u(s,{code:c.invalid_type,expected:l.set,received:s.parsedType}),y;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(u(s,{code:c.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(u(s,{code:c.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function i(f){let d=new Set;for(let m of f){if(m.status==="aborted")return y;m.status==="dirty"&&t.dirty(),d.add(m.value);}return {status:t.value,value:d}}let o=[...s.data.values()].map((f,d)=>a._parse(new O(s,f,s.path,d)));return s.common.async?Promise.all(o).then(f=>i(f)):i(o)}min(e,t){return new r({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};de.create=(r,e)=>new de({valueType:r,minSize:null,maxSize:null,typeName:p.ZodSet,...v(e)});var W=class extends _{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};W.create=(r,e)=>new W({getter:r,typeName:p.ZodLazy,...v(e)});var q=class extends _{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),y}return {status:"valid",value:e.data}}get value(){return this._def.value}};q.create=(r,e)=>new q({value:r,typeName:p.ZodLiteral,...v(e)});function Re(r,e){return new Y({values:r,typeName:p.ZodEnum,...v(e)})}var Y=class r extends _{constructor(){super(...arguments),K.set(this,void 0);}_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{expected:g.joinValues(s),received:t.parsedType,code:c.invalid_type}),y}if(he(this,K,"f")||Ne(this,K,new Set(this._def.values),"f"),!he(this,K,"f").has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{received:t.data,code:c.invalid_enum_value,options:s}),y}return k(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};K=new WeakMap;Y.create=Re;var H=class extends _{constructor(){super(...arguments),F.set(this,void 0);}_parse(e){let t=g.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==l.string&&s.parsedType!==l.number){let n=g.objectValues(t);return u(s,{expected:g.joinValues(n),received:s.parsedType,code:c.invalid_type}),y}if(he(this,F,"f")||Ne(this,F,new Set(g.getValidEnumValues(this._def.values)),"f"),!he(this,F,"f").has(e.data)){let n=g.objectValues(t);return u(s,{received:s.data,code:c.invalid_enum_value,options:n}),y}return k(e.data)}get enum(){return this._def.values}};F=new WeakMap;H.create=(r,e)=>new H({values:r,typeName:p.ZodNativeEnum,...v(e)});var P=class extends _{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==l.promise&&t.common.async===!1)return u(t,{code:c.invalid_type,expected:l.promise,received:t.parsedType}),y;let s=t.parsedType===l.promise?t.data:Promise.resolve(t.data);return k(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};P.create=(r,e)=>new P({type:r,typeName:p.ZodPromise,...v(e)});var E=class extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{u(s,i),i.fatal?t.abort():t.dirty();},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let i=n.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return y;let f=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return f.status==="aborted"?y:f.status==="dirty"||t.value==="dirty"?Q(f.value):f});{if(t.value==="aborted")return y;let o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?y:o.status==="dirty"||t.value==="dirty"?Q(o.value):o}}if(n.type==="refinement"){let i=o=>{let f=n.refinement(o,a);if(s.common.async)return Promise.resolve(f);if(f instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!le(i))return i;let o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>le(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);g.assertNever(n);}};E.create=(r,e,t)=>new E({schema:r,typeName:p.ZodEffects,effect:e,...v(t)});E.createWithPreprocess=(r,e,t)=>new E({schema:e,effect:{type:"preprocess",transform:r},typeName:p.ZodEffects,...v(t)});var C=class extends _{_parse(e){return this._getType(e)===l.undefined?k(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};C.create=(r,e)=>new C({innerType:r,typeName:p.ZodOptional,...v(e)});var R=class extends _{_parse(e){return this._getType(e)===l.null?k(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};R.create=(r,e)=>new R({innerType:r,typeName:p.ZodNullable,...v(e)});var J=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===l.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};J.create=(r,e)=>new J({innerType:r,typeName:p.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});var G=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return fe(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new S(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new S(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};G.create=(r,e)=>new G({innerType:r,typeName:p.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});var ue=class extends _{_parse(e){if(this._getType(e)!==l.nan){let s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:l.nan,received:s.parsedType}),y}return {status:"valid",value:e.data}}};ue.create=r=>new ue({typeName:p.ZodNaN,...v(r)});var pe=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},me=class r extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return (async()=>{let a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?y:a.status==="dirty"?(t.dirty(),Q(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?y:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new r({in:e,out:t,typeName:p.ZodPipeline})}},X=class extends _{_parse(e){let t=this._def.innerType._parse(e),s=n=>(le(n)&&(n.value=Object.freeze(n.value)),n);return fe(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}};X.create=(r,e)=>new X({innerType:r,typeName:p.ZodReadonly,...v(e)});({object:b.lazycreate});var p;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly";})(p||(p={}));var w=D.create,Ie=se.create;N.create;M.create;var I=b.create;b.strictCreate;U.create;B.create;Z.create;Y.create;P.create;C.create;R.create;var Ae=I({checksum:w(),location:I({npm:I({filePath:w(),packageName:w(),registry:w()})})}),tt=I({name:w(),version:w(),description:w(),sources:I({module:Ae,provider:Ae.optional()}),network:I({chainIds:w().array(),namespaces:w().array()}),cointype:w(),permissions:I({rpc:I({dapps:Ie(),methods:w()})}),manifestVersion:w()}),Me=r=>tt.safeParse(r);var Ut={getManifest:()=>{let r=$e(),e=Me(r);return e.success?e.data:void 0},getBalances:()=>Promise.resolve("EVM balances"),getTransactionHistory:()=>Promise.resolve("EVM transaction history"),getNetworkFee:()=>Promise.resolve("EVM network fee"),getAddress:()=>Promise.resolve("EVM address")};
|
|
3
|
+
var vmModuleTypes = require('@avalabs/vm-module-types');
|
|
4
|
+
require('ethers');
|
|
5
|
+
var utilsSdk = require('@avalabs/utils-sdk');
|
|
6
|
+
var bn_js = require('bn.js');
|
|
7
|
+
var etherscanSdk = require('@avalabs/etherscan-sdk');
|
|
8
|
+
var glacierSdk = require('@avalabs/glacier-sdk');
|
|
9
|
+
var lt = require('lodash.startcase');
|
|
4
10
|
|
|
5
|
-
|
|
11
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
|
|
13
|
+
var lt__default = /*#__PURE__*/_interopDefault(lt);
|
|
14
|
+
|
|
15
|
+
var b=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var w=(t,e,r)=>(b(t,e,"read from private field"),r?r.call(t):e.get(t)),F=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r);},I=(t,e,r,n)=>(b(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);var R={LOW:1n,MEDIUM:4n,HIGH:6n},x=500000000n;async function C(t){let{maxFeePerGas:e}=await t.getFeeData();if(!e)throw new Error("Pre-EIP-1559 networks are not supported");let r=x*R.LOW,n=x*R.MEDIUM,s=x*R.HIGH;return {baseFee:e,low:{maxFeePerGas:e+r,maxPriorityFeePerGas:r},medium:{maxFeePerGas:e+n,maxPriorityFeePerGas:n},high:{maxFeePerGas:e+s,maxPriorityFeePerGas:s}}}function E(t,e,r="tx"){return `${t}/${r}/${e}`}var M=({tx:t,networkToken:e,chainId:r,explorerUrl:n,address:s})=>{let a=t.from.toLowerCase()===s.toLowerCase(),o=parseInt(t.timeStamp)*1e3,i=e.decimals,m=new bn_js.BN(t.value),c=utilsSdk.balanceToDisplayValue(m,i),T=a?vmModuleTypes.TransactionType.SEND:vmModuleTypes.TransactionType.RECEIVE,{from:p,to:l,gasPrice:f,gasUsed:g,hash:u}=t,y=E(n,u);return {isIncoming:!a,isOutgoing:a,isContractCall:st(t),timestamp:o,hash:u,isSender:a,from:p,to:l,tokens:[{decimal:i.toString(),name:e.name,symbol:e.symbol,amount:c,type:vmModuleTypes.TokenType.NATIVE}],gasUsed:g,gasPrice:f,chainId:r.toString(),txType:T,explorerLink:y}};function st(t){return t.input!=="0x"}function O({tx:t,address:e,explorerUrl:r,chainId:n}){let s=t.from.toLowerCase()===e.toLowerCase(),a=parseInt(t.timeStamp)*1e3,o=parseInt(t.tokenDecimal),i=new bn_js.BN(t.value),m=utilsSdk.balanceToDisplayValue(i,o),{from:c,to:T,gasPrice:p,gasUsed:l,hash:f,tokenDecimal:g,tokenName:u,tokenSymbol:y}=t,k=s?vmModuleTypes.TransactionType.SEND:vmModuleTypes.TransactionType.RECEIVE,et=E(r,f);return {isIncoming:!s,isOutgoing:s,isContractCall:!1,timestamp:a,hash:f,isSender:s,from:c,to:T,tokens:[{decimal:g,name:u,symbol:y,type:vmModuleTypes.TokenType.ERC20,amount:m}],gasUsed:l,gasPrice:p,chainId:n.toString(),txType:k,explorerLink:et}}var _=async({isTestnet:t,chainId:e,networkToken:r,explorerUrl:n,address:s,nextPageToken:a,offset:o})=>{let i=a?JSON.parse(a):void 0,m=i?.page||1,c=i?.queries||["normal","erc20"],T=(c.includes("normal")?await etherscanSdk.getNormalTxs(s,!t,{page:m,offset:o}):[]).map(u=>M({tx:u,chainId:e,networkToken:r,explorerUrl:n,address:s})),p=(c.includes("erc20")?await etherscanSdk.getErc20Txs(s,!t,void 0,{page:m,offset:o}):[]).map(u=>O({tx:u,address:s,explorerUrl:n,chainId:e})),l=p.map(u=>u.hash),f=T.filter(u=>!l.includes(u.hash)),g={queries:[],page:m+1};return T.length&&g.queries.push("normal"),p.length&&g.queries.push("erc20"),{transactions:[...f,...p],nextPageToken:g.queries.length?JSON.stringify(g):""}};var A=t=>t===1||t===5||t===4||t===11155111;var U=({nativeTransaction:t,erc20Transfers:e,erc721Transfers:r},n,s)=>{let a=!e&&!r,o=ut(t.method?.methodName),i=o.toLowerCase().includes("swap"),m=a&&t.from.address===n,c=a&&t.to.address===n,T=o==="Market Buy Orders With Eth"||o==="Buy NFT",p=o==="Approve",l=o.toLowerCase().includes("transfer"),f=o.toLowerCase().includes("airdrop"),g=o.toLowerCase().includes("unwrap"),u=o==="Fill Order",y=l&&!!s[0]&&L(s[0].type)&&s[0].from?.address===n,k=l&&!!s[0]&&L(s[0].type)&&s[0].to?.address===n;return i?vmModuleTypes.TransactionType.SWAP:m?vmModuleTypes.TransactionType.SEND:c?vmModuleTypes.TransactionType.RECEIVE:T?vmModuleTypes.TransactionType.NFT_BUY:p?vmModuleTypes.TransactionType.APPROVE:y?vmModuleTypes.TransactionType.NFT_SEND:k?vmModuleTypes.TransactionType.NFT_RECEIVE:l?vmModuleTypes.TransactionType.TRANSFER:f?vmModuleTypes.TransactionType.AIRDROP:g?vmModuleTypes.TransactionType.UNWRAP:u?vmModuleTypes.TransactionType.FILL_ORDER:vmModuleTypes.TransactionType.UNKNOWN};function L(t){return t===vmModuleTypes.TokenType.ERC721||t===vmModuleTypes.TokenType.ERC1155}var ut=(t="")=>t.includes("(")?lt__default.default(t.split("(",1)[0]):t;var V=(t,{nativeTransaction:e,erc20Transfers:r,erc721Transfers:n},s)=>{let a=t===vmModuleTypes.TransactionType.TRANSFER,o=t===vmModuleTypes.TransactionType.SEND,i=t===vmModuleTypes.TransactionType.RECEIVE,m=e?.from?.address,c=e?.to?.address;return a&&r&&r[0]&&(m=r[0].from.address,c=r[0].to.address),a&&n&&n[0]&&(m=n[0].from.address,c=n[0].to.address),{isOutgoing:o||a&&m===s,isIncoming:i||a&&c===s,isSender:m===s,from:m,to:c}};async function B(t){try{return t.then(e=>[e,null]).catch(e=>[null,e])}catch(e){return Promise.resolve([null,e])}}var gt="https://cloudflare-ipfs.com";function N(t,e=gt){if(!t)return "";try{return utilsSdk.ipfsResolver(t,e)}catch{return t}}async function dt(t,e=5e3){let r=new AbortController;return setTimeout(()=>r.abort(),e),fetch(t,{signal:r.signal})}async function W(t){let e={};if(t)if(t.startsWith("data:application/json;base64,")){let r=t.substring(29);try{let n=Buffer.from(r,"base64").toString();e=JSON.parse(n);}catch{e={};}}else e=await dt(N(t)).then(r=>r.json()).catch(()=>({}));else return {};return e}var ft="https://image-proxy.svc.prod.covalenthq.com/cdn-cgi/image";function q(t,e="256"){let r=N(t);return `${ft}/width=${e},fit/${r}`}var $=async({nativeTransaction:t,erc20Transfers:e,erc721Transfers:r,erc1155Transfers:n},s)=>{let a=[];if(t.value!=="0"){let o=s.decimals,i=new bn_js.BN(t.value),m=utilsSdk.balanceToDisplayValue(i,o);a.push({decimal:o.toString(),name:s.name,symbol:s.symbol,amount:m,from:t.from,to:t.to,type:vmModuleTypes.TokenType.NATIVE});}return e?.forEach(o=>{let i=o.erc20Token.decimals,m=new bn_js.BN(o.value),c=utilsSdk.balanceToDisplayValue(m,i);a.push({decimal:i.toString(),name:o.erc20Token.name,symbol:o.erc20Token.symbol,amount:c,from:o.from,to:o.to,imageUri:o.erc20Token.logoUri,type:vmModuleTypes.TokenType.ERC20});}),r&&await Promise.allSettled(r.map(async o=>{let i=o.erc721Token,m=await Y(i.tokenUri,i.metadata.imageUri);a.push({name:o.erc721Token.name,symbol:o.erc721Token.symbol,amount:"1",imageUri:m,from:o.from,to:o.to,collectableTokenId:o.erc721Token.tokenId,type:vmModuleTypes.TokenType.ERC721});})),n&&await Promise.allSettled(n.map(async o=>{let i=o.erc1155Token,m=await Y(i.tokenUri,i.metadata.imageUri);a.push({name:o.erc1155Token.metadata.name??"",symbol:o.erc1155Token.metadata.symbol??"",amount:o.value,imageUri:m,from:o.from,to:o.to,collectableTokenId:o.erc1155Token.tokenId,type:vmModuleTypes.TokenType.ERC1155});})),a},Y=async(t,e)=>{if(e)return e.startsWith("ipfs://")?N(e):e;{let[r,n]=await B(W(t));return n?"":r.image?q(r.image):""}};var K=[vmModuleTypes.TransactionType.SEND,vmModuleTypes.TransactionType.RECEIVE,vmModuleTypes.TransactionType.TRANSFER];var z=async({transactions:t,explorerUrl:e,networkToken:r,chainId:n,address:s})=>{let a=await $(t,r),o=U(t,s,a),{isOutgoing:i,isIncoming:m,isSender:c,from:T,to:p}=V(o,t,s),{blockTimestamp:l,txHash:f,gasPrice:g,gasUsed:u}=t.nativeTransaction,y=E(e,f);return {isContractCall:!K.includes(o),isIncoming:m,isOutgoing:i,isSender:c,timestamp:l*1e3,hash:f,from:T,to:p,tokens:a,gasPrice:g,gasUsed:u,chainId:n.toString(),txType:o,explorerLink:y}};var Z=async({chainId:t,explorerUrl:e,networkToken:r,address:n,nextPageToken:s,offset:a,glacierApiUrl:o})=>{if(!o)throw new Error("Glacier API URL is required");let i=new glacierSdk.Glacier({BASE:o});try{let m=await i.evmTransactions.listTransactions({chainId:t.toString(),address:n,pageToken:s,pageSize:a});return {transactions:(await Promise.all(m.transactions.filter(p=>p.nativeTransaction.txStatus==="1").map(p=>z({transactions:p,explorerUrl:e,networkToken:r,chainId:t,address:n}).then(l=>l)))).filter(p=>p.tokens.find(l=>Number(l.amount)!==0)),nextPageToken:m.nextPageToken}}catch{return {transactions:[],nextPageToken:""}}};var Q=async({chainId:t,isTestnet:e,networkToken:r,explorerUrl:n,address:s,nextPageToken:a,offset:o,glacierApiUrl:i})=>A(t)?_({isTestnet:e,networkToken:r,explorerUrl:n,chainId:t,address:s,nextPageToken:a,offset:o}):Z({isTestnet:e,networkToken:r,explorerUrl:n,chainId:t,address:s,nextPageToken:a,offset:o,glacierApiUrl:i});var X={name:"EVM",description:"",version:"0.0.1",sources:{module:{checksum:"",location:{npm:{filePath:"dist/bundle.js",packageName:"@avalabs/evm-module",registry:"https://registry.npmjs.org"}}},provider:{checksum:"",location:{npm:{filePath:"dist/provider.js",packageName:"@avalabs/evm-module",registry:"https://registry.npmjs.org"}}}},network:{chainIds:["eip155:1","eip155:43114","eip155:43113"],namespaces:["eip155"]},cointype:"60",permissions:{rpc:{dapps:!0,methods:["eth_sendTransaction","eth_*","getTransactionHistory"]}},manifestVersion:"0.0"};var h,tt=class{constructor(e){F(this,h,void 0);I(this,h,e);}getAddress(){return Promise.resolve("EVM address")}getBalances(){return Promise.resolve("EVM balances")}getManifest(){let e=vmModuleTypes.parseManifest(X);return e.success?e.data:void 0}getNetworkFee(){return C(w(this,h))}getTransactionHistory(e){return Q(e)}};h=new WeakMap;
|
|
16
|
+
|
|
17
|
+
exports.EvmModule = tt;
|
|
6
18
|
//# sourceMappingURL=out.js.map
|
|
7
19
|
//# sourceMappingURL=index.cjs.map
|