From 12b80526d5594a9ec9b6d0a74ad9b81300bc74e0 Mon Sep 17 00:00:00 2001 From: Sayan kar Date: Tue, 21 Oct 2025 14:50:22 +0530 Subject: [PATCH 01/10] chore: adding rollup build, bundle esm only deps together with build --- client/.gitignore | 3 +- client/package-lock.json | 728 +++++++++++++++++++++++++++++++++------ client/package.json | 97 ++++-- client/rollup.config.js | 193 +++++++++++ 4 files changed, 900 insertions(+), 121 deletions(-) create mode 100644 client/rollup.config.js diff --git a/client/.gitignore b/client/.gitignore index 5014ec80..cf64cb4e 100644 --- a/client/.gitignore +++ b/client/.gitignore @@ -12,4 +12,5 @@ dist/_types /.tshy-* /__tests__ .DS_Store -/docs/typedoc \ No newline at end of file +/docs/typedoc +.rollup.cache \ No newline at end of file diff --git a/client/package-lock.json b/client/package-lock.json index 7bf32997..8c714696 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -15,6 +15,10 @@ "viem": "^2.33.3" }, "devDependencies": { + "@rollup/plugin-commonjs": "^28.0.8", + "@rollup/plugin-node-resolve": "^16.0.3", + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^12.1.4", "@types/node": "^22.15.17", "assert": "^2.1.0", "browserify-zlib": "^0.2.0", @@ -23,6 +27,7 @@ "crypto-browserify": "^3.12.0", "domain-browser": "^4.19.0", "events": "^3.3.0", + "glob": "^11.0.3", "https-browserify": "^1.0.0", "msw": "^2.10.4", "os-browserify": "^0.3.0", @@ -30,11 +35,13 @@ "process": "^0.11.10", "punycode": "^2.3.1", "querystring-es3": "^0.2.1", + "rollup": "^4.52.5", "stream-browserify": "^3.0.0", "stream-http": "^3.2.0", "string_decoder": "^1.3.0", "timers-browserify": "^2.0.12", "ts-loader": "^9.5.1", + "tslib": "^2.8.1", "tty-browserify": "^0.0.1", "typedoc": "^0.28.9", "typedoc-github-theme": "^0.3.0", @@ -641,6 +648,132 @@ } } }, + "node_modules/@isaacs/balanced-match": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@isaacs/balanced-match/-/balanced-match-4.0.1.tgz", + "integrity": "sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@isaacs/brace-expansion": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@isaacs/brace-expansion/-/brace-expansion-5.0.0.tgz", + "integrity": "sha512-ZT55BDLV0yv0RBm2czMiZ+SqCGO7AvmOM3G/w2xhVPH+te0aKgFjmBvGlL1dH+ql2tgGO3MVrbb3jCKyvpgnxA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@isaacs/balanced-match": "^4.0.1" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", + "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-styles": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", + "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@isaacs/cliui/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.2.tgz", + "integrity": "sha512-gmBGslpoQJtgnMAvOVqGZpEz9dyoKTCzy2nfz/n8aIFhN/jCE/rCmcxabB6jOOHV+0WNnylOxaxBQPSvcWklhA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.12", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.12.tgz", @@ -782,10 +915,149 @@ "dev": true, "license": "MIT" }, + "node_modules/@rollup/plugin-commonjs": { + "version": "28.0.8", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-28.0.8.tgz", + "integrity": "sha512-o1Ug9PxYsF61R7/NXO/GgMZZproLd/WH2XA53Tp9ppf6bU1lMlTtC/gUM6zM3mesi2E0rypk+PNtVrELREyWEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "commondir": "^1.0.1", + "estree-walker": "^2.0.2", + "fdir": "^6.2.0", + "is-reference": "1.2.1", + "magic-string": "^0.30.3", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=16.0.0 || 14 >= 14.17" + }, + "peerDependencies": { + "rollup": "^2.68.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.3.tgz", + "integrity": "sha512-lUYM3UBGuM93CnMPG1YocWu7X802BrNF3jW2zny5gQyLQgRFJhV1Sq0Zi74+dh/6NBx1DxFC4b4GXg9wUCG5Qg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-terser": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@rollup/plugin-terser/-/plugin-terser-0.4.4.tgz", + "integrity": "sha512-XHeJC5Bgvs8LfukDwWZp7yeqin6ns8RTl2B9avbejt6tZqsqvVoWI7ZTQrcNsfKEDWBTnTxM8nMDkO2IFFbd0A==", + "dev": true, + "license": "MIT", + "dependencies": { + "serialize-javascript": "^6.0.1", + "smob": "^1.0.0", + "terser": "^5.17.4" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-typescript": { + "version": "12.1.4", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-12.1.4.tgz", + "integrity": "sha512-s5Hx+EtN60LMlDBvl5f04bEiFZmAepk27Q+mr85L/00zPDn1jtzlTV6FWn81MaIwqfWzKxmOJrBWHU6vtQyedQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.1.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.14.0||^3.0.0||^4.0.0", + "tslib": "*", + "typescript": ">=3.7.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + }, + "tslib": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.3.0.tgz", + "integrity": "sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.40.2.tgz", - "integrity": "sha512-JkdNEq+DFxZfUwxvB58tHMHBHVgX23ew41g1OQinthJ+ryhdRk67O31S7sYw8u2lTjHUPFxwar07BBt1KHp/hg==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.52.5.tgz", + "integrity": "sha512-8c1vW4ocv3UOMp9K+gToY5zL2XiiVw3k7f1ksf4yO1FlDFQ1C2u72iACFnSOceJFsWskc2WZNqeRhFRPzv+wtQ==", "cpu": [ "arm" ], @@ -797,9 +1069,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.40.2.tgz", - "integrity": "sha512-13unNoZ8NzUmnndhPTkWPWbX3vtHodYmy+I9kuLxN+F+l+x3LdVF7UCu8TWVMt1POHLh6oDHhnOA04n8oJZhBw==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.52.5.tgz", + "integrity": "sha512-mQGfsIEFcu21mvqkEKKu2dYmtuSZOBMmAl5CFlPGLY94Vlcm+zWApK7F/eocsNzp8tKmbeBP8yXyAbx0XHsFNA==", "cpu": [ "arm64" ], @@ -811,9 +1083,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.40.2.tgz", - "integrity": "sha512-Gzf1Hn2Aoe8VZzevHostPX23U7N5+4D36WJNHK88NZHCJr7aVMG4fadqkIf72eqVPGjGc0HJHNuUaUcxiR+N/w==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.52.5.tgz", + "integrity": "sha512-takF3CR71mCAGA+v794QUZ0b6ZSrgJkArC+gUiG6LB6TQty9T0Mqh3m2ImRBOxS2IeYBo4lKWIieSvnEk2OQWA==", "cpu": [ "arm64" ], @@ -825,9 +1097,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.40.2.tgz", - "integrity": "sha512-47N4hxa01a4x6XnJoskMKTS8XZ0CZMd8YTbINbi+w03A2w4j1RTlnGHOz/P0+Bg1LaVL6ufZyNprSg+fW5nYQQ==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.52.5.tgz", + "integrity": "sha512-W901Pla8Ya95WpxDn//VF9K9u2JbocwV/v75TE0YIHNTbhqUTv9w4VuQ9MaWlNOkkEfFwkdNhXgcLqPSmHy0fA==", "cpu": [ "x64" ], @@ -839,9 +1111,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.40.2.tgz", - "integrity": "sha512-8t6aL4MD+rXSHHZUR1z19+9OFJ2rl1wGKvckN47XFRVO+QL/dUSpKA2SLRo4vMg7ELA8pzGpC+W9OEd1Z/ZqoQ==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.52.5.tgz", + "integrity": "sha512-QofO7i7JycsYOWxe0GFqhLmF6l1TqBswJMvICnRUjqCx8b47MTo46W8AoeQwiokAx3zVryVnxtBMcGcnX12LvA==", "cpu": [ "arm64" ], @@ -853,9 +1125,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.40.2.tgz", - "integrity": "sha512-C+AyHBzfpsOEYRFjztcYUFsH4S7UsE9cDtHCtma5BK8+ydOZYgMmWg1d/4KBytQspJCld8ZIujFMAdKG1xyr4Q==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.52.5.tgz", + "integrity": "sha512-jr21b/99ew8ujZubPo9skbrItHEIE50WdV86cdSoRkKtmWa+DDr6fu2c/xyRT0F/WazZpam6kk7IHBerSL7LDQ==", "cpu": [ "x64" ], @@ -867,9 +1139,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.40.2.tgz", - "integrity": "sha512-de6TFZYIvJwRNjmW3+gaXiZ2DaWL5D5yGmSYzkdzjBDS3W+B9JQ48oZEsmMvemqjtAFzE16DIBLqd6IQQRuG9Q==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.52.5.tgz", + "integrity": "sha512-PsNAbcyv9CcecAUagQefwX8fQn9LQ4nZkpDboBOttmyffnInRy8R8dSg6hxxl2Re5QhHBf6FYIDhIj5v982ATQ==", "cpu": [ "arm" ], @@ -881,9 +1153,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.40.2.tgz", - "integrity": "sha512-urjaEZubdIkacKc930hUDOfQPysezKla/O9qV+O89enqsqUmQm8Xj8O/vh0gHg4LYfv7Y7UsE3QjzLQzDYN1qg==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.52.5.tgz", + "integrity": "sha512-Fw4tysRutyQc/wwkmcyoqFtJhh0u31K+Q6jYjeicsGJJ7bbEq8LwPWV/w0cnzOqR2m694/Af6hpFayLJZkG2VQ==", "cpu": [ "arm" ], @@ -895,9 +1167,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.40.2.tgz", - "integrity": "sha512-KlE8IC0HFOC33taNt1zR8qNlBYHj31qGT1UqWqtvR/+NuCVhfufAq9fxO8BMFC22Wu0rxOwGVWxtCMvZVLmhQg==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.52.5.tgz", + "integrity": "sha512-a+3wVnAYdQClOTlyapKmyI6BLPAFYs0JM8HRpgYZQO02rMR09ZcV9LbQB+NL6sljzG38869YqThrRnfPMCDtZg==", "cpu": [ "arm64" ], @@ -909,9 +1181,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.40.2.tgz", - "integrity": "sha512-j8CgxvfM0kbnhu4XgjnCWJQyyBOeBI1Zq91Z850aUddUmPeQvuAy6OiMdPS46gNFgy8gN1xkYyLgwLYZG3rBOg==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.52.5.tgz", + "integrity": "sha512-AvttBOMwO9Pcuuf7m9PkC1PUIKsfaAJ4AYhy944qeTJgQOqJYJ9oVl2nYgY7Rk0mkbsuOpCAYSs6wLYB2Xiw0Q==", "cpu": [ "arm64" ], @@ -922,10 +1194,10 @@ "linux" ] }, - "node_modules/@rollup/rollup-linux-loongarch64-gnu": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.40.2.tgz", - "integrity": "sha512-Ybc/1qUampKuRF4tQXc7G7QY9YRyeVSykfK36Y5Qc5dmrIxwFhrOzqaVTNoZygqZ1ZieSWTibfFhQ5qK8jpWxw==", + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.52.5.tgz", + "integrity": "sha512-DkDk8pmXQV2wVrF6oq5tONK6UHLz/XcEVow4JTTerdeV1uqPeHxwcg7aFsfnSm9L+OO8WJsWotKM2JJPMWrQtA==", "cpu": [ "loong64" ], @@ -936,10 +1208,10 @@ "linux" ] }, - "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.40.2.tgz", - "integrity": "sha512-3FCIrnrt03CCsZqSYAOW/k9n625pjpuMzVfeI+ZBUSDT3MVIFDSPfSUgIl9FqUftxcUXInvFah79hE1c9abD+Q==", + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.52.5.tgz", + "integrity": "sha512-W/b9ZN/U9+hPQVvlGwjzi+Wy4xdoH2I8EjaCkMvzpI7wJUs8sWJ03Rq96jRnHkSrcHTpQe8h5Tg3ZzUPGauvAw==", "cpu": [ "ppc64" ], @@ -951,9 +1223,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.40.2.tgz", - "integrity": "sha512-QNU7BFHEvHMp2ESSY3SozIkBPaPBDTsfVNGx3Xhv+TdvWXFGOSH2NJvhD1zKAT6AyuuErJgbdvaJhYVhVqrWTg==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.52.5.tgz", + "integrity": "sha512-sjQLr9BW7R/ZiXnQiWPkErNfLMkkWIoCz7YMn27HldKsADEKa5WYdobaa1hmN6slu9oWQbB6/jFpJ+P2IkVrmw==", "cpu": [ "riscv64" ], @@ -965,9 +1237,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.40.2.tgz", - "integrity": "sha512-5W6vNYkhgfh7URiXTO1E9a0cy4fSgfE4+Hl5agb/U1sa0kjOLMLC1wObxwKxecE17j0URxuTrYZZME4/VH57Hg==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.52.5.tgz", + "integrity": "sha512-hq3jU/kGyjXWTvAh2awn8oHroCbrPm8JqM7RUpKjalIRWWXE01CQOf/tUNWNHjmbMHg/hmNCwc/Pz3k1T/j/Lg==", "cpu": [ "riscv64" ], @@ -979,9 +1251,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.40.2.tgz", - "integrity": "sha512-B7LKIz+0+p348JoAL4X/YxGx9zOx3sR+o6Hj15Y3aaApNfAshK8+mWZEf759DXfRLeL2vg5LYJBB7DdcleYCoQ==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.52.5.tgz", + "integrity": "sha512-gn8kHOrku8D4NGHMK1Y7NA7INQTRdVOntt1OCYypZPRt6skGbddska44K8iocdpxHTMMNui5oH4elPH4QOLrFQ==", "cpu": [ "s390x" ], @@ -993,9 +1265,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.40.2.tgz", - "integrity": "sha512-lG7Xa+BmBNwpjmVUbmyKxdQJ3Q6whHjMjzQplOs5Z+Gj7mxPtWakGHqzMqNER68G67kmCX9qX57aRsW5V0VOng==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.52.5.tgz", + "integrity": "sha512-hXGLYpdhiNElzN770+H2nlx+jRog8TyynpTVzdlc6bndktjKWyZyiCsuDAlpd+j+W+WNqfcyAWz9HxxIGfZm1Q==", "cpu": [ "x64" ], @@ -1007,9 +1279,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.40.2.tgz", - "integrity": "sha512-tD46wKHd+KJvsmije4bUskNuvWKFcTOIM9tZ/RrmIvcXnbi0YK/cKS9FzFtAm7Oxi2EhV5N2OpfFB348vSQRXA==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.52.5.tgz", + "integrity": "sha512-arCGIcuNKjBoKAXD+y7XomR9gY6Mw7HnFBv5Rw7wQRvwYLR7gBAgV7Mb2QTyjXfTveBNFAtPt46/36vV9STLNg==", "cpu": [ "x64" ], @@ -1020,10 +1292,24 @@ "linux" ] }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.52.5.tgz", + "integrity": "sha512-QoFqB6+/9Rly/RiPjaomPLmR/13cgkIGfA40LHly9zcH1S0bN2HVFYk3a1eAyHQyjs3ZJYlXvIGtcCs5tko9Cw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.40.2.tgz", - "integrity": "sha512-Bjv/HG8RRWLNkXwQQemdsWw4Mg+IJ29LK+bJPW2SCzPKOUaMmPEppQlu/Fqk1d7+DX3V7JbFdbkh/NMmurT6Pg==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.52.5.tgz", + "integrity": "sha512-w0cDWVR6MlTstla1cIfOGyl8+qb93FlAVutcor14Gf5Md5ap5ySfQ7R9S/NjNaMLSFdUnKGEasmVnu3lCMqB7w==", "cpu": [ "arm64" ], @@ -1035,9 +1321,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.40.2.tgz", - "integrity": "sha512-dt1llVSGEsGKvzeIO76HToiYPNPYPkmjhMHhP00T9S4rDern8P2ZWvWAQUEJ+R1UdMWJ/42i/QqJ2WV765GZcA==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.52.5.tgz", + "integrity": "sha512-Aufdpzp7DpOTULJCuvzqcItSGDH73pF3ko/f+ckJhxQyHtp67rHw3HMNxoIdDMUITJESNE6a8uh4Lo4SLouOUg==", "cpu": [ "ia32" ], @@ -1048,10 +1334,24 @@ "win32" ] }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.52.5.tgz", + "integrity": "sha512-UGBUGPFp1vkj6p8wCRraqNhqwX/4kNQPS57BCFc8wYh0g94iVIW33wJtQAx3G7vrjjNtRaxiMUylM0ktp/TRSQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.40.2.tgz", - "integrity": "sha512-bwspbWB04XJpeElvsp+DCylKfF4trJDa2Y9Go8O6A7YLX2LIKGcNK/CYImJN6ZP4DcuOHB4Utl3iCbnR62DudA==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.52.5.tgz", + "integrity": "sha512-TAcgQh2sSkykPRWLrdyy2AiceMckNf5loITqXxFI5VuQjS5tSuw3WlwdN8qv8vzjLAUTvYaH/mVjSFpbkFbpTg==", "cpu": [ "x64" ], @@ -1234,9 +1534,9 @@ } }, "node_modules/@types/estree": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz", - "integrity": "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", + "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", "dev": true, "license": "MIT" }, @@ -1263,10 +1563,18 @@ "integrity": "sha512-v1DKRfUdyW+jJhZNEI1PYy29S2YRxMV5AOO/x/SjKmW0acCIOqmbj6Haf9eHAhsPmrhlHSxEhv/1WszcLWV4cg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "undici-types": "~6.21.0" } }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/statuses": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/statuses/-/statuses-2.0.6.tgz", @@ -1650,6 +1958,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -1676,6 +1985,7 @@ "integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "fast-deep-equal": "^3.1.3", "fast-uri": "^3.0.1", @@ -2010,6 +2320,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001726", "electron-to-chromium": "^1.5.173", @@ -2307,6 +2618,13 @@ "dev": true, "license": "MIT" }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true, + "license": "MIT" + }, "node_modules/constants-browserify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", @@ -2448,6 +2766,16 @@ "node": ">=6" } }, + "node_modules/deepmerge": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", + "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/define-data-property": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", @@ -2540,6 +2868,13 @@ "node": ">= 0.4" } }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true, + "license": "MIT" + }, "node_modules/electron-to-chromium": { "version": "1.5.192", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.192.tgz", @@ -2900,6 +3235,23 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "dev": true, + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -2971,6 +3323,30 @@ "node": ">= 0.4" } }, + "node_modules/glob": { + "version": "11.0.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.3.tgz", + "integrity": "sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.3.1", + "jackspeak": "^4.1.1", + "minimatch": "^10.0.3", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/glob-to-regexp": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", @@ -2978,6 +3354,22 @@ "dev": true, "license": "BSD-2-Clause" }, + "node_modules/glob/node_modules/minimatch": { + "version": "10.0.3", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.3.tgz", + "integrity": "sha512-IPZ167aShDZZUMdRk66cyQAW3qr0WzbHkPdMYa8bzZhlHhO3jALbKdxcaak7W9FfT2rZNpQuUu4Od7ILEpXSaw==", + "dev": true, + "license": "ISC", + "dependencies": { + "@isaacs/brace-expansion": "^5.0.0" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/gopd": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", @@ -3248,6 +3640,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true, + "license": "MIT" + }, "node_modules/is-nan": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", @@ -3295,6 +3694,16 @@ "node": ">=0.10.0" } }, + "node_modules/is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "*" + } + }, "node_modules/is-regex": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", @@ -3367,6 +3776,22 @@ "ws": "*" } }, + "node_modules/jackspeak": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.1.1.tgz", + "integrity": "sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/jest-worker": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz", @@ -3462,6 +3887,16 @@ "dev": true, "license": "MIT" }, + "node_modules/lru-cache": { + "version": "11.2.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.2.tgz", + "integrity": "sha512-F9ODfyqML2coTIsQpSkRHnLSZMtkU8Q+mSfcaIyKwy58u+8k5nvAYeiNhsyMARvzNcXJ9QfWVrcPsC9e9rAxtg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "20 || >=22" + } + }, "node_modules/lunr": { "version": "2.3.9", "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", @@ -3658,6 +4093,16 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -3672,6 +4117,7 @@ "dev": true, "hasInstallScript": true, "license": "MIT", + "peer": true, "dependencies": { "@bundled-es-modules/cookie": "^2.0.1", "@bundled-es-modules/statuses": "^1.0.1", @@ -3924,6 +4370,13 @@ "node": ">=6" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, "node_modules/pako": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", @@ -3983,6 +4436,23 @@ "dev": true, "license": "MIT" }, + "node_modules/path-scurry": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/path-to-regexp": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", @@ -4384,13 +4854,14 @@ } }, "node_modules/rollup": { - "version": "4.40.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.40.2.tgz", - "integrity": "sha512-tfUOg6DTP4rhQ3VjOO6B4wyrJnGOX85requAXvqYTHsOgb2TFJdZ3aWpT8W2kPoypSGP7dZUyzxJ9ee4buM5Fg==", + "version": "4.52.5", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.52.5.tgz", + "integrity": "sha512-3GuObel8h7Kqdjt0gxkEzaifHTqLVW56Y/bjN7PSQtkKr0w3V/QYSdt6QWYtd7A1xUtYQigtdUfgj1RvWVtorw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { - "@types/estree": "1.0.7" + "@types/estree": "1.0.8" }, "bin": { "rollup": "dist/bin/rollup" @@ -4400,26 +4871,28 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.40.2", - "@rollup/rollup-android-arm64": "4.40.2", - "@rollup/rollup-darwin-arm64": "4.40.2", - "@rollup/rollup-darwin-x64": "4.40.2", - "@rollup/rollup-freebsd-arm64": "4.40.2", - "@rollup/rollup-freebsd-x64": "4.40.2", - "@rollup/rollup-linux-arm-gnueabihf": "4.40.2", - "@rollup/rollup-linux-arm-musleabihf": "4.40.2", - "@rollup/rollup-linux-arm64-gnu": "4.40.2", - "@rollup/rollup-linux-arm64-musl": "4.40.2", - "@rollup/rollup-linux-loongarch64-gnu": "4.40.2", - "@rollup/rollup-linux-powerpc64le-gnu": "4.40.2", - "@rollup/rollup-linux-riscv64-gnu": "4.40.2", - "@rollup/rollup-linux-riscv64-musl": "4.40.2", - "@rollup/rollup-linux-s390x-gnu": "4.40.2", - "@rollup/rollup-linux-x64-gnu": "4.40.2", - "@rollup/rollup-linux-x64-musl": "4.40.2", - "@rollup/rollup-win32-arm64-msvc": "4.40.2", - "@rollup/rollup-win32-ia32-msvc": "4.40.2", - "@rollup/rollup-win32-x64-msvc": "4.40.2", + "@rollup/rollup-android-arm-eabi": "4.52.5", + "@rollup/rollup-android-arm64": "4.52.5", + "@rollup/rollup-darwin-arm64": "4.52.5", + "@rollup/rollup-darwin-x64": "4.52.5", + "@rollup/rollup-freebsd-arm64": "4.52.5", + "@rollup/rollup-freebsd-x64": "4.52.5", + "@rollup/rollup-linux-arm-gnueabihf": "4.52.5", + "@rollup/rollup-linux-arm-musleabihf": "4.52.5", + "@rollup/rollup-linux-arm64-gnu": "4.52.5", + "@rollup/rollup-linux-arm64-musl": "4.52.5", + "@rollup/rollup-linux-loong64-gnu": "4.52.5", + "@rollup/rollup-linux-ppc64-gnu": "4.52.5", + "@rollup/rollup-linux-riscv64-gnu": "4.52.5", + "@rollup/rollup-linux-riscv64-musl": "4.52.5", + "@rollup/rollup-linux-s390x-gnu": "4.52.5", + "@rollup/rollup-linux-x64-gnu": "4.52.5", + "@rollup/rollup-linux-x64-musl": "4.52.5", + "@rollup/rollup-openharmony-arm64": "4.52.5", + "@rollup/rollup-win32-arm64-msvc": "4.52.5", + "@rollup/rollup-win32-ia32-msvc": "4.52.5", + "@rollup/rollup-win32-x64-gnu": "4.52.5", + "@rollup/rollup-win32-x64-msvc": "4.52.5", "fsevents": "~2.3.2" } }, @@ -4681,6 +5154,13 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/smob": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/smob/-/smob-1.5.0.tgz", + "integrity": "sha512-g6T+p7QO8npa+/hNx9ohv1E5pVCmWrVCUzUXJyLdMmftX6ER0oiWY/w9knEonLpnOp6b6FenKnMfR8gqwWdwig==", + "dev": true, + "license": "MIT" + }, "node_modules/source-map": { "version": "0.7.6", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.6.tgz", @@ -4832,6 +5312,22 @@ "node": ">=8" } }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -4845,6 +5341,20 @@ "node": ">=8" } }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -5081,6 +5591,14 @@ "webpack": "^5.0.0" } }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD", + "peer": true + }, "node_modules/tty-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", @@ -5122,6 +5640,7 @@ "integrity": "sha512-aw45vwtwOl3QkUAmWCnLV9QW1xY+FSX2zzlit4MAfE99wX+Jij4ycnpbAWgBXsRrxmfs9LaYktg/eX5Bpthd3g==", "dev": true, "license": "Apache-2.0", + "peer": true, "dependencies": { "@gerrit0/mini-shiki": "^3.9.0", "lunr": "^2.3.9", @@ -5159,6 +5678,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "devOptional": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -5337,6 +5857,7 @@ "integrity": "sha512-0msEVHJEScQbhkbVTb/4iHZdJ6SXp/AvxL2sjwYQFfBqleHtnCqv1J3sa9zbWz/6kW1m9Tfzn92vW+kZ1WV6QA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.4.4", @@ -5527,6 +6048,7 @@ "integrity": "sha512-B4t+nJqytPeuZlHuIKTbalhljIFXeNRqrUGAQgTGlfOl2lXXKXw+yZu6bicycP+PUlM44CxBjCFD6aciKFT3LQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@types/eslint-scope": "^3.7.7", "@types/estree": "^1.0.8", @@ -5576,6 +6098,7 @@ "integrity": "sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@discoveryjs/json-ext": "^0.5.0", "@webpack-cli/configtest": "^2.1.1", @@ -5651,13 +6174,6 @@ "node": ">=10.13.0" } }, - "node_modules/webpack/node_modules/@types/estree": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", - "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", - "dev": true, - "license": "MIT" - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -5734,11 +6250,31 @@ "node": ">=8" } }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, "node_modules/ws": { "version": "8.18.3", "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", "license": "MIT", + "peer": true, "engines": { "node": ">=10.0.0" }, diff --git a/client/package.json b/client/package.json index 5f1fcd44..6573336b 100644 --- a/client/package.json +++ b/client/package.json @@ -4,8 +4,8 @@ "update-version": "node scripts/update-version.js", "clean": "rm -rf dist src/_cjs src/_esm src/_types .tsbuildinfo", "build:all": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:types && npm run build:webpack", - "build:cjs": "tsc --project ./tsconfig.cjs.json --noEmitOnError false && printf '{\"type\":\"commonjs\"}' > ./dist/_cjs/package.json", - "build:esm": "tsc --project ./tsconfig.esm.json --noEmitOnError false && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./dist/_esm/package.json", + "build:cjs": "BUILD_FORMAT=cjs rollup --config rollup.config.js && printf '{\"type\":\"commonjs\"}' > ./dist/_cjs/package.json", + "build:esm": "BUILD_FORMAT=esm rollup --config rollup.config.js && printf '{\"type\": \"module\",\"sideEffects\":false}' > ./dist/_esm/package.json", "build:types": "npx tsc --project ./tsconfig.esm.json --declarationDir ./dist/_types --emitDeclarationOnly --declaration --declarationMap", "build:webpack": "npx webpack --config webpack.config.cjs", "generate-docs": "typedoc", @@ -51,6 +51,10 @@ "viem": "^2.33.3" }, "devDependencies": { + "@rollup/plugin-commonjs": "^28.0.8", + "@rollup/plugin-node-resolve": "^16.0.3", + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^12.1.4", "@types/node": "^22.15.17", "assert": "^2.1.0", "browserify-zlib": "^0.2.0", @@ -59,6 +63,7 @@ "crypto-browserify": "^3.12.0", "domain-browser": "^4.19.0", "events": "^3.3.0", + "glob": "^11.0.3", "https-browserify": "^1.0.0", "msw": "^2.10.4", "os-browserify": "^0.3.0", @@ -66,11 +71,13 @@ "process": "^0.11.10", "punycode": "^2.3.1", "querystring-es3": "^0.2.1", + "rollup": "^4.52.5", "stream-browserify": "^3.0.0", "stream-http": "^3.2.0", "string_decoder": "^1.3.0", "timers-browserify": "^2.0.12", "ts-loader": "^9.5.1", + "tslib": "^2.8.1", "tty-browserify": "^0.0.1", "typedoc": "^0.28.9", "typedoc-github-theme": "^0.3.0", @@ -204,27 +211,69 @@ }, "typesVersions": { "*": { - "utils": ["./dist/_types/utils/index.d.ts"], - "accounts": ["./dist/_types/accounts/index.d.ts"], - "chains": ["./dist/_types/chains/index.d.ts"], - "methods": ["./dist/_types/methods/index.d.ts"], - "methods/wallet": ["./dist/_types/methods/wallet/index.d.ts"], - "methods/wallet/cChain": ["./dist/_types/methods/wallet/cChain/index.d.ts"], - "methods/wallet/pChain": ["./dist/_types/methods/wallet/pChain/index.d.ts"], - "methods/wallet/xChain": ["./dist/_types/methods/wallet/xChain/index.d.ts"], - "methods/public": ["./dist/_types/methods/public/index.d.ts"], - "methods/pChain": ["./dist/_types/methods/pChain/index.d.ts"], - "methods/admin": ["./dist/_types/methods/admin/index.d.ts"], - "methods/cChain": ["./dist/_types/methods/cChain/index.d.ts"], - "methods/xChain": ["./dist/_types/methods/xChain/index.d.ts"], - "methods/health": ["./dist/_types/methods/health/index.d.ts"], - "methods/index": ["./dist/_types/methods/index/index.d.ts"], - "methods/info": ["./dist/_types/methods/info/index.d.ts"], - "node": ["./dist/_types/node/index.d.ts"], - "nonce": ["./dist/_types/nonce/index.d.ts"], - "serializable": ["./dist/_types/serializable/index.d.ts"], - "siwe": ["./dist/_types/siwe/index.d.ts"], - "window": ["./dist/_types/window/index.d.ts"] + "utils": [ + "./dist/_types/utils/index.d.ts" + ], + "accounts": [ + "./dist/_types/accounts/index.d.ts" + ], + "chains": [ + "./dist/_types/chains/index.d.ts" + ], + "methods": [ + "./dist/_types/methods/index.d.ts" + ], + "methods/wallet": [ + "./dist/_types/methods/wallet/index.d.ts" + ], + "methods/wallet/cChain": [ + "./dist/_types/methods/wallet/cChain/index.d.ts" + ], + "methods/wallet/pChain": [ + "./dist/_types/methods/wallet/pChain/index.d.ts" + ], + "methods/wallet/xChain": [ + "./dist/_types/methods/wallet/xChain/index.d.ts" + ], + "methods/public": [ + "./dist/_types/methods/public/index.d.ts" + ], + "methods/pChain": [ + "./dist/_types/methods/pChain/index.d.ts" + ], + "methods/admin": [ + "./dist/_types/methods/admin/index.d.ts" + ], + "methods/cChain": [ + "./dist/_types/methods/cChain/index.d.ts" + ], + "methods/xChain": [ + "./dist/_types/methods/xChain/index.d.ts" + ], + "methods/health": [ + "./dist/_types/methods/health/index.d.ts" + ], + "methods/index": [ + "./dist/_types/methods/index/index.d.ts" + ], + "methods/info": [ + "./dist/_types/methods/info/index.d.ts" + ], + "node": [ + "./dist/_types/node/index.d.ts" + ], + "nonce": [ + "./dist/_types/nonce/index.d.ts" + ], + "serializable": [ + "./dist/_types/serializable/index.d.ts" + ], + "siwe": [ + "./dist/_types/siwe/index.d.ts" + ], + "window": [ + "./dist/_types/window/index.d.ts" + ] } } -} \ No newline at end of file +} diff --git a/client/rollup.config.js b/client/rollup.config.js new file mode 100644 index 00000000..d6adffa4 --- /dev/null +++ b/client/rollup.config.js @@ -0,0 +1,193 @@ +import commonjs from '@rollup/plugin-commonjs'; +import { nodeResolve } from '@rollup/plugin-node-resolve'; +import terser from '@rollup/plugin-terser'; +import typescript from '@rollup/plugin-typescript'; +import fs from 'fs'; + +// Get all entry points +const getEntryPoints = () => { + const entries = { + 'index': 'src/index.ts' + }; + + // Add sub-path entries based on package.json exports + const subPaths = [ + 'accounts', 'chains', 'methods', 'methods/wallet', 'methods/wallet/cChain', + 'methods/wallet/pChain', 'methods/wallet/xChain', 'methods/public', 'methods/pChain', + 'methods/admin', 'methods/cChain', 'methods/xChain', 'methods/health', + 'methods/index', 'methods/info', 'node', 'nonce', 'serializable', 'siwe', 'utils', 'window' + ]; + + for (const subPath of subPaths) { + const srcPath = `src/${subPath}/index.ts`; + try { + // Check if the file exists + fs.accessSync(srcPath); + entries[subPath] = srcPath; + } catch (e) { + // File doesn't exist, skip + } + } + + return entries; +}; + +const baseConfig = { + external: [ + // Keep these as external dependencies + '@avalabs/avalanchejs', + // '@noble/hashes', // Bundle this ES module dependency + // '@noble/secp256k1', // Bundle this ES module dependency + 'util', + 'viem', + // Node.js built-ins + 'crypto', + 'fs', + 'path', + 'url', + 'stream', + 'buffer', + 'events', + 'util', + 'assert', + 'os', + 'child_process', + 'worker_threads' + ], + plugins: [ + nodeResolve({ + preferBuiltins: true, + exportConditions: ['node'] + }), + commonjs() + ] +}; + +export default (commandLineArgs) => { + const buildFormat = process.env.BUILD_FORMAT || commandLineArgs.environment?.BUILD_FORMAT; + const entryPoints = getEntryPoints(); + + if (buildFormat === 'cjs') { + return Object.entries(entryPoints).map(([name, input]) => ({ + ...baseConfig, + input, + output: { + file: name === 'index' ? `dist/_cjs/index.js` : `dist/_cjs/${name}/index.js`, + format: 'cjs', + sourcemap: false, + exports: 'auto', + inlineDynamicImports: true + }, + plugins: [ + ...baseConfig.plugins, + typescript({ + tsconfig: './tsconfig.cjs.json', + declaration: false, + declarationMap: false, + sourceMap: false, + exclude: ['**/*.test.ts', '**/*.spec.ts'], + module: 'esnext', + target: 'es2020' + }), + terser({ + compress: { + drop_console: true, + drop_debugger: true + } + }) + ] + })); + } + + if (buildFormat === 'esm') { + return Object.entries(entryPoints).map(([name, input]) => ({ + ...baseConfig, + input, + output: { + file: name === 'index' ? `dist/_esm/index.js` : `dist/_esm/${name}/index.js`, + format: 'esm', + sourcemap: false, + inlineDynamicImports: true + }, + plugins: [ + ...baseConfig.plugins, + typescript({ + tsconfig: './tsconfig.esm.json', + declaration: false, + declarationMap: false, + sourceMap: false, + exclude: ['**/*.test.ts', '**/*.spec.ts'], + module: 'esnext', + target: 'es2020' + }), + terser({ + compress: { + drop_console: true, + drop_debugger: true + } + }) + ] + })); + } + + // Default: build both formats + return [ + ...Object.entries(entryPoints).map(([name, input]) => ({ + ...baseConfig, + input, + output: { + file: `dist/_cjs/${name}/index.js`, + format: 'cjs', + sourcemap: false, + exports: 'auto', + inlineDynamicImports: true + }, + plugins: [ + ...baseConfig.plugins, + typescript({ + tsconfig: './tsconfig.cjs.json', + declaration: false, + declarationMap: false, + sourceMap: false, + exclude: ['**/*.test.ts', '**/*.spec.ts'], + module: 'esnext', + target: 'es2020' + }), + terser({ + compress: { + drop_console: true, + drop_debugger: true + } + }) + ] + })), + ...Object.entries(entryPoints).map(([name, input]) => ({ + ...baseConfig, + input, + output: { + file: `dist/_esm/${name}/index.js`, + format: 'esm', + sourcemap: false, + inlineDynamicImports: true + }, + plugins: [ + ...baseConfig.plugins, + typescript({ + tsconfig: './tsconfig.esm.json', + declaration: false, + declarationMap: false, + sourceMap: false, + exclude: ['**/*.test.ts', '**/*.spec.ts'], + module: 'esnext', + target: 'es2020' + }), + terser({ + compress: { + drop_console: true, + drop_debugger: true + } + }) + ] + })) + ]; +}; From b14b4ed589c04b59f3890693c8d0308a724c5483 Mon Sep 17 00:00:00 2001 From: Sayan kar Date: Fri, 31 Oct 2025 20:59:47 +0530 Subject: [PATCH 02/10] chore: add methods introduced in granite upgrade --- .vscode/settings.json | 2 + client/examples/package-lock.json | 826 +++++++++++++++++- client/examples/package.json | 1 + .../package-lock.json | 423 ++++++++- .../package.json | 1 + client/src/clients/createAvalancheClient.ts | 83 +- .../src/clients/createProposervmApiClient.ts | 115 +++ .../src/clients/decorators/avalanche.test.ts | 155 +++- client/src/clients/decorators/avalanche.ts | 82 +- client/src/clients/decorators/pChain.test.ts | 1 + client/src/clients/decorators/pChain.ts | 35 + .../src/clients/decorators/proposervmApi.ts | 65 ++ .../clients/types/createAvalancheClient.ts | 86 +- client/src/clients/types/types.ts | 3 + client/src/clients/utils.ts | 6 + client/src/index.ts | 11 + .../src/methods/pChain/getAllValidatorsAt.ts | 55 ++ client/src/methods/pChain/index.ts | 7 + client/src/methods/pChain/pChainRpcSchema.ts | 2 + .../pChain/types/getAllValidatorsAt.ts | 36 + .../src/methods/proposervm/getCurrentEpoch.ts | 45 + .../methods/proposervm/getProposedHeight.ts | 45 + client/src/methods/proposervm/index.ts | 11 + .../methods/proposervm/proposervmRpcSchema.ts | 15 + .../proposervm/types/getCurrentEpoch.ts | 21 + .../proposervm/types/getProposedHeight.ts | 17 + 26 files changed, 2010 insertions(+), 139 deletions(-) create mode 100644 client/src/clients/createProposervmApiClient.ts create mode 100644 client/src/clients/decorators/proposervmApi.ts create mode 100644 client/src/methods/pChain/getAllValidatorsAt.ts create mode 100644 client/src/methods/pChain/types/getAllValidatorsAt.ts create mode 100644 client/src/methods/proposervm/getCurrentEpoch.ts create mode 100644 client/src/methods/proposervm/getProposedHeight.ts create mode 100644 client/src/methods/proposervm/index.ts create mode 100644 client/src/methods/proposervm/proposervmRpcSchema.ts create mode 100644 client/src/methods/proposervm/types/getCurrentEpoch.ts create mode 100644 client/src/methods/proposervm/types/getProposedHeight.ts diff --git a/.vscode/settings.json b/.vscode/settings.json index 442133f2..231e0071 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,6 +25,7 @@ "Permissioned", "Permissionless", "POSTHOG", + "proposervm", "Sayan", "scure", "Sepk", @@ -37,6 +38,7 @@ "UTXOID", "UTXOs", "viem", + "VMAPI", "xChain" ] } diff --git a/client/examples/package-lock.json b/client/examples/package-lock.json index dc953293..b634419e 100644 --- a/client/examples/package-lock.json +++ b/client/examples/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "BSD-3-Clause", "dependencies": { + "@avalanche-sdk/client": "^0.0.4-alpha.16", "dotenv": "^16.3.1" }, "devDependencies": { @@ -17,6 +18,44 @@ "typescript": "^5.0.0" } }, + "node_modules/@adraffy/ens-normalize": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.11.1.tgz", + "integrity": "sha512-nhCBV3quEgesuf7c7KYfperqSS14T8bYuvJ8PcLJp6znkZpFc0AuW4qBtr8eKVyPPe/8RSr7sglCWPU5eaxwKQ==", + "license": "MIT" + }, + "node_modules/@avalabs/avalanchejs": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@avalabs/avalanchejs/-/avalanchejs-5.0.0.tgz", + "integrity": "sha512-0hJK/Hdf8v+q05c8+5K6arFmzq7o1W4I05/Dmr+Es1XRi8canvTu1Y0RruYd6ea2rrvX3UhKrPs3BzLhCTHDrw==", + "dependencies": { + "@noble/curves": "1.3.0", + "@noble/hashes": "1.3.3", + "@noble/secp256k1": "2.0.0", + "@scure/base": "1.1.5", + "micro-eth-signer": "0.7.2" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@avalanche-sdk/client": { + "version": "0.0.4-alpha.16", + "resolved": "https://registry.npmjs.org/@avalanche-sdk/client/-/client-0.0.4-alpha.16.tgz", + "integrity": "sha512-rpOwBURNaV62rZSyacuQfPhTsuHWhnNNcoqTWEBXrGqIkUXoIdG4YqGrjKVVvNk/c7uRC1NX7FbmpOv7fgibJw==", + "license": "BSD-3-Clause", + "dependencies": { + "@avalabs/avalanchejs": "^5.0.0", + "@noble/hashes": "1.3.3", + "@noble/secp256k1": "2.0.0", + "util": "^0.12.5", + "viem": "^2.33.3" + }, + "engines": { + "node": ">=20", + "npm": ">=10" + } + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.25.9", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.9.tgz", @@ -459,6 +498,159 @@ "node": ">=18" } }, + "node_modules/@ethereumjs/rlp": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@ethereumjs/rlp/-/rlp-5.0.0.tgz", + "integrity": "sha512-WuS1l7GJmB0n0HsXLozCoEFc9IwYgf3l0gCkKVYgR67puVF1O4OpEaN0hWmm1c+iHUHFCKt1hJrvy5toLg+6ag==", + "license": "MPL-2.0", + "bin": { + "rlp": "bin/rlp" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@noble/ciphers": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-1.3.0.tgz", + "integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/curves": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.3.0.tgz", + "integrity": "sha512-t01iSXPuN+Eqzb4eBX0S5oubSqXbK/xXa1Ne18Hj8f9pStxztHCE2gfboSp/dZRLSqfuLpRK2nDXDK+W9puocA==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.3.3" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.3.tgz", + "integrity": "sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/secp256k1": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-2.0.0.tgz", + "integrity": "sha512-rUGBd95e2a45rlmFTqQJYEFA4/gdIARFfuTuTqLglz0PZ6AKyzyXsEZZq7UZn8hZsvaBgpCzKKBJizT2cJERXw==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "license": "MIT" + }, + "node_modules/@scure/base": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.5.tgz", + "integrity": "sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.7.0.tgz", + "integrity": "sha512-E4FFX/N3f4B80AKWp5dP6ow+flD1LQZo/w8UnLGYZO674jS6YnYeepycOOksv+vLPSpgN35wgKgy+ybfTb2SMw==", + "license": "MIT", + "dependencies": { + "@noble/curves": "~1.9.0", + "@noble/hashes": "~1.8.0", + "@scure/base": "~1.2.5" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32/node_modules/@noble/curves": { + "version": "1.9.7", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz", + "integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32/node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32/node_modules/@scure/base": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.2.6.tgz", + "integrity": "sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.6.0.tgz", + "integrity": "sha512-+lF0BbLiJNwVlev4eKelw1WWLaiKXw7sSl8T6FvBlWkdX+94aGJ4o8XjUdlyhTCjd8c+B3KT3JfS8P0bLRNU6A==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "~1.8.0", + "@scure/base": "~1.2.5" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39/node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39/node_modules/@scure/base": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.2.6.tgz", + "integrity": "sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@types/node": { "version": "20.19.10", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.10.tgz", @@ -469,6 +661,106 @@ "undici-types": "~6.21.0" } }, + "node_modules/abitype": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.1.0.tgz", + "integrity": "sha512-6Vh4HcRxNMLA0puzPjM5GBgT4aAcFGKZzSgAXvuZ27shJP6NEpielTuqbBmZILR5/xd0PizkBGy5hReKz9jl5A==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/wevm" + }, + "peerDependencies": { + "typescript": ">=5.0.4", + "zod": "^3.22.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, + "node_modules/available-typed-arrays": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", + "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", + "license": "MIT", + "dependencies": { + "possible-typed-array-names": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/call-bind": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", + "integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.0", + "es-define-property": "^1.0.0", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/dotenv": { "version": "16.6.1", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", @@ -481,6 +773,50 @@ "url": "https://dotenvx.com" } }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/esbuild": { "version": "0.25.9", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.9.tgz", @@ -523,6 +859,27 @@ "@esbuild/win32-x64": "0.25.9" } }, + "node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", + "license": "MIT" + }, + "node_modules/for-each": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", + "integrity": "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==", + "license": "MIT", + "dependencies": { + "is-callable": "^1.2.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -538,6 +895,61 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/generator-function": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/generator-function/-/generator-function-2.0.1.tgz", + "integrity": "sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/get-tsconfig": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.10.1.tgz", @@ -551,6 +963,270 @@ "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" } }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/is-arguments": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.2.0.tgz", + "integrity": "sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-generator-function": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.1.2.tgz", + "integrity": "sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.4", + "generator-function": "^2.0.0", + "get-proto": "^1.0.1", + "has-tostringtag": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-regex": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", + "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.15", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.15.tgz", + "integrity": "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==", + "license": "MIT", + "dependencies": { + "which-typed-array": "^1.1.16" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/isows": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.7.tgz", + "integrity": "sha512-I1fSfDCZL5P0v33sVqeTDSpcstAg/N+wF5HS033mogOVIp4B+oHC7oOCsA3axAbBSGTJ8QubbNmnIRN/h8U7hg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "peerDependencies": { + "ws": "*" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/micro-eth-signer": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/micro-eth-signer/-/micro-eth-signer-0.7.2.tgz", + "integrity": "sha512-uFH23nqPNdg2KZ9ZdvLG4GO3bTAOWRhwGTsecY4Et2IdQOJ26x6inu8lJ9oyslnYL/0o1vnETCGhMimMvO0SqQ==", + "license": "MIT", + "dependencies": { + "@ethereumjs/rlp": "5.0.0", + "@noble/curves": "~1.3.0", + "@noble/hashes": "~1.3.3", + "@scure/base": "~1.1.5", + "micro-packed": "~0.5.1" + } + }, + "node_modules/micro-packed": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/micro-packed/-/micro-packed-0.5.3.tgz", + "integrity": "sha512-zWRoH+qUb/ZMp9gVZhexvRGCENDM5HEQF4sflqpdilUHWK2/zKR7/MT8GBctnTwbhNJwy1iuk5q6+TYP7/twYA==", + "license": "MIT", + "dependencies": { + "@scure/base": "~1.1.5" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/ox": { + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/ox/-/ox-0.9.6.tgz", + "integrity": "sha512-8SuCbHPvv2eZLYXrNmC0EC12rdzXQLdhnOMlHDW2wiCPLxBrOOJwX5L5E61by+UjTPOryqQiRSnjIKCI+GykKg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "dependencies": { + "@adraffy/ens-normalize": "^1.11.0", + "@noble/ciphers": "^1.3.0", + "@noble/curves": "1.9.1", + "@noble/hashes": "^1.8.0", + "@scure/bip32": "^1.7.0", + "@scure/bip39": "^1.6.0", + "abitype": "^1.0.9", + "eventemitter3": "5.0.1" + }, + "peerDependencies": { + "typescript": ">=5.4.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/ox/node_modules/@noble/curves": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", + "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/ox/node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/possible-typed-array-names": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", + "integrity": "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/resolve-pkg-maps": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", @@ -561,6 +1237,40 @@ "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } }, + "node_modules/safe-regex-test": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.1.0.tgz", + "integrity": "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-regex": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/tsx": { "version": "4.20.4", "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.20.4.tgz", @@ -585,8 +1295,9 @@ "version": "5.9.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz", "integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==", - "dev": true, + "devOptional": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -601,6 +1312,119 @@ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "dev": true, "license": "MIT" + }, + "node_modules/util": { + "version": "0.12.5", + "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", + "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "is-arguments": "^1.0.4", + "is-generator-function": "^1.0.7", + "is-typed-array": "^1.1.3", + "which-typed-array": "^1.1.2" + } + }, + "node_modules/viem": { + "version": "2.38.3", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.38.3.tgz", + "integrity": "sha512-By2TutLv07iNHHtWqHHzjGipevYsfGqT7KQbGEmqLco1qTJxKnvBbSviqiu6/v/9REV6Q/FpmIxf2Z7/l5AbcQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "dependencies": { + "@noble/curves": "1.9.1", + "@noble/hashes": "1.8.0", + "@scure/bip32": "1.7.0", + "@scure/bip39": "1.6.0", + "abitype": "1.1.0", + "isows": "1.0.7", + "ox": "0.9.6", + "ws": "8.18.3" + }, + "peerDependencies": { + "typescript": ">=5.0.4" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/viem/node_modules/@noble/curves": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", + "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/viem/node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.19", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.19.tgz", + "integrity": "sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw==", + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "for-each": "^0.3.5", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/ws": { + "version": "8.18.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", + "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } } } } diff --git a/client/examples/package.json b/client/examples/package.json index 62185001..3be3df70 100644 --- a/client/examples/package.json +++ b/client/examples/package.json @@ -9,6 +9,7 @@ "license": "BSD-3-Clause", "description": "", "dependencies": { + "@avalanche-sdk/client": "^0.0.4-alpha.16", "dotenv": "^16.3.1" }, "devDependencies": { diff --git a/client/examples/react-show-balance-and-cross-chain-transfers/package-lock.json b/client/examples/react-show-balance-and-cross-chain-transfers/package-lock.json index 4b83ca6f..f171aa82 100644 --- a/client/examples/react-show-balance-and-cross-chain-transfers/package-lock.json +++ b/client/examples/react-show-balance-and-cross-chain-transfers/package-lock.json @@ -8,6 +8,7 @@ "name": "react-show-balance-and-cross-chain-transfers", "version": "0.1.0", "dependencies": { + "@avalanche-sdk/client": "^0.0.4-alpha.16", "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", "@mui/icons-material": "^6.5.0", @@ -25,6 +26,12 @@ "vite": "^7.1.5" } }, + "node_modules/@adraffy/ens-normalize": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.11.1.tgz", + "integrity": "sha512-nhCBV3quEgesuf7c7KYfperqSS14T8bYuvJ8PcLJp6znkZpFc0AuW4qBtr8eKVyPPe/8RSr7sglCWPU5eaxwKQ==", + "license": "MIT" + }, "node_modules/@ampproject/remapping": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", @@ -39,6 +46,38 @@ "node": ">=6.0.0" } }, + "node_modules/@avalabs/avalanchejs": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@avalabs/avalanchejs/-/avalanchejs-5.0.0.tgz", + "integrity": "sha512-0hJK/Hdf8v+q05c8+5K6arFmzq7o1W4I05/Dmr+Es1XRi8canvTu1Y0RruYd6ea2rrvX3UhKrPs3BzLhCTHDrw==", + "dependencies": { + "@noble/curves": "1.3.0", + "@noble/hashes": "1.3.3", + "@noble/secp256k1": "2.0.0", + "@scure/base": "1.1.5", + "micro-eth-signer": "0.7.2" + }, + "engines": { + "node": ">=20" + } + }, + "node_modules/@avalanche-sdk/client": { + "version": "0.0.4-alpha.16", + "resolved": "https://registry.npmjs.org/@avalanche-sdk/client/-/client-0.0.4-alpha.16.tgz", + "integrity": "sha512-rpOwBURNaV62rZSyacuQfPhTsuHWhnNNcoqTWEBXrGqIkUXoIdG4YqGrjKVVvNk/c7uRC1NX7FbmpOv7fgibJw==", + "license": "BSD-3-Clause", + "dependencies": { + "@avalabs/avalanchejs": "^5.0.0", + "@noble/hashes": "1.3.3", + "@noble/secp256k1": "2.0.0", + "util": "^0.12.5", + "viem": "^2.33.3" + }, + "engines": { + "node": ">=20", + "npm": ">=10" + } + }, "node_modules/@babel/code-frame": { "version": "7.27.1", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.27.1.tgz", @@ -69,6 +108,7 @@ "integrity": "sha512-UlLAnTPrFdNGoFtbSXwcGFQBtQZJCNjaN6hQNP3UPvuNXT1i82N26KL3dZeIpNalWywr9IuQuncaAfUaS1g6sQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.27.1", @@ -385,6 +425,7 @@ "resolved": "https://registry.npmjs.org/@emotion/react/-/react-11.14.0.tgz", "integrity": "sha512-O000MLDBDdk/EohJPFUqvnp4qnHeYkVP5B0xEG0D/L7cOKP9kefu2DXn8dj74cQfsEzUqh+sr1RzFqiL1o+PpA==", "license": "MIT", + "peer": true, "dependencies": { "@babel/runtime": "^7.18.3", "@emotion/babel-plugin": "^11.13.5", @@ -428,6 +469,7 @@ "resolved": "https://registry.npmjs.org/@emotion/styled/-/styled-11.14.1.tgz", "integrity": "sha512-qEEJt42DuToa3gurlH4Qqc1kVpNq8wO8cJtDzU46TjlzWjDlsVyevtYCRijVq3SrHsROS+gVQ8Fnea108GnKzw==", "license": "MIT", + "peer": true, "dependencies": { "@babel/runtime": "^7.18.3", "@emotion/babel-plugin": "^11.13.5", @@ -915,6 +957,18 @@ "node": ">=18" } }, + "node_modules/@ethereumjs/rlp": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@ethereumjs/rlp/-/rlp-5.0.0.tgz", + "integrity": "sha512-WuS1l7GJmB0n0HsXLozCoEFc9IwYgf3l0gCkKVYgR67puVF1O4OpEaN0hWmm1c+iHUHFCKt1hJrvy5toLg+6ag==", + "license": "MPL-2.0", + "bin": { + "rlp": "bin/rlp" + }, + "engines": { + "node": ">=18" + } + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.12", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.12.tgz", @@ -990,6 +1044,7 @@ "resolved": "https://registry.npmjs.org/@mui/material/-/material-6.5.0.tgz", "integrity": "sha512-yjvtXoFcrPLGtgKRxFaH6OQPtcLPhkloC0BML6rBG5UeldR0nPULR/2E2BfXdo5JNV7j7lOzrrLX2Qf/iSidow==", "license": "MIT", + "peer": true, "dependencies": { "@babel/runtime": "^7.26.0", "@mui/core-downloads-tracker": "^6.5.0", @@ -1179,6 +1234,54 @@ } } }, + "node_modules/@noble/ciphers": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-1.3.0.tgz", + "integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/curves": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.3.0.tgz", + "integrity": "sha512-t01iSXPuN+Eqzb4eBX0S5oubSqXbK/xXa1Ne18Hj8f9pStxztHCE2gfboSp/dZRLSqfuLpRK2nDXDK+W9puocA==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.3.3" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.3.tgz", + "integrity": "sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/secp256k1": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-2.0.0.tgz", + "integrity": "sha512-rUGBd95e2a45rlmFTqQJYEFA4/gdIARFfuTuTqLglz0PZ6AKyzyXsEZZq7UZn8hZsvaBgpCzKKBJizT2cJERXw==", + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "license": "MIT" + }, "node_modules/@popperjs/core": { "version": "2.11.8", "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.8.tgz", @@ -1476,6 +1579,99 @@ "win32" ] }, + "node_modules/@scure/base": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.5.tgz", + "integrity": "sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.7.0.tgz", + "integrity": "sha512-E4FFX/N3f4B80AKWp5dP6ow+flD1LQZo/w8UnLGYZO674jS6YnYeepycOOksv+vLPSpgN35wgKgy+ybfTb2SMw==", + "license": "MIT", + "dependencies": { + "@noble/curves": "~1.9.0", + "@noble/hashes": "~1.8.0", + "@scure/base": "~1.2.5" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32/node_modules/@noble/curves": { + "version": "1.9.7", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz", + "integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32/node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32/node_modules/@scure/base": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.2.6.tgz", + "integrity": "sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.6.0.tgz", + "integrity": "sha512-+lF0BbLiJNwVlev4eKelw1WWLaiKXw7sSl8T6FvBlWkdX+94aGJ4o8XjUdlyhTCjd8c+B3KT3JfS8P0bLRNU6A==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "~1.8.0", + "@scure/base": "~1.2.5" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39/node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39/node_modules/@scure/base": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.2.6.tgz", + "integrity": "sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg==", + "license": "MIT", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -1545,6 +1741,7 @@ "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.23.tgz", "integrity": "sha512-/LDXMQh55EzZQ0uVAZmKKhfENivEvWz6E+EYzh+/MCjMhNsotd+ZHhBGIjFDTi6+fz0OhQQQLbTgdQIxxCsC0w==", "license": "MIT", + "peer": true, "dependencies": { "@types/prop-types": "*", "csstype": "^3.0.2" @@ -1590,6 +1787,27 @@ "vite": "^4.2.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" } }, + "node_modules/abitype": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.1.0.tgz", + "integrity": "sha512-6Vh4HcRxNMLA0puzPjM5GBgT4aAcFGKZzSgAXvuZ27shJP6NEpielTuqbBmZILR5/xd0PizkBGy5hReKz9jl5A==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/wevm" + }, + "peerDependencies": { + "typescript": ">=5.0.4", + "zod": "^3.22.0 || ^4.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, "node_modules/available-typed-arrays": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", @@ -1640,6 +1858,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001733", "electron-to-chromium": "^1.5.199", @@ -1944,6 +2163,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/eventemitter3": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", + "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", + "license": "MIT" + }, "node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -2254,6 +2479,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/isows": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.7.tgz", + "integrity": "sha512-I1fSfDCZL5P0v33sVqeTDSpcstAg/N+wF5HS033mogOVIp4B+oHC7oOCsA3axAbBSGTJ8QubbNmnIRN/h8U7hg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "peerDependencies": { + "ws": "*" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -2328,6 +2568,31 @@ "node": ">= 0.4" } }, + "node_modules/micro-eth-signer": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/micro-eth-signer/-/micro-eth-signer-0.7.2.tgz", + "integrity": "sha512-uFH23nqPNdg2KZ9ZdvLG4GO3bTAOWRhwGTsecY4Et2IdQOJ26x6inu8lJ9oyslnYL/0o1vnETCGhMimMvO0SqQ==", + "license": "MIT", + "dependencies": { + "@ethereumjs/rlp": "5.0.0", + "@noble/curves": "~1.3.0", + "@noble/hashes": "~1.3.3", + "@scure/base": "~1.1.5", + "micro-packed": "~0.5.1" + } + }, + "node_modules/micro-packed": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/micro-packed/-/micro-packed-0.5.3.tgz", + "integrity": "sha512-zWRoH+qUb/ZMp9gVZhexvRGCENDM5HEQF4sflqpdilUHWK2/zKR7/MT8GBctnTwbhNJwy1iuk5q6+TYP7/twYA==", + "license": "MIT", + "dependencies": { + "@scure/base": "~1.1.5" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -2369,6 +2634,63 @@ "node": ">=0.10.0" } }, + "node_modules/ox": { + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/ox/-/ox-0.9.6.tgz", + "integrity": "sha512-8SuCbHPvv2eZLYXrNmC0EC12rdzXQLdhnOMlHDW2wiCPLxBrOOJwX5L5E61by+UjTPOryqQiRSnjIKCI+GykKg==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "dependencies": { + "@adraffy/ens-normalize": "^1.11.0", + "@noble/ciphers": "^1.3.0", + "@noble/curves": "1.9.1", + "@noble/hashes": "^1.8.0", + "@scure/bip32": "^1.7.0", + "@scure/bip39": "^1.6.0", + "abitype": "^1.0.9", + "eventemitter3": "5.0.1" + }, + "peerDependencies": { + "typescript": ">=5.4.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/ox/node_modules/@noble/curves": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", + "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/ox/node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -2426,6 +2748,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -2502,6 +2825,7 @@ "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", "license": "MIT", + "peer": true, "dependencies": { "loose-envify": "^1.1.0" }, @@ -2514,6 +2838,7 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", "license": "MIT", + "peer": true, "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.2" @@ -2734,8 +3059,9 @@ "version": "5.9.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz", "integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==", - "dev": true, + "devOptional": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -2788,12 +3114,70 @@ "which-typed-array": "^1.1.2" } }, + "node_modules/viem": { + "version": "2.38.3", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.38.3.tgz", + "integrity": "sha512-By2TutLv07iNHHtWqHHzjGipevYsfGqT7KQbGEmqLco1qTJxKnvBbSviqiu6/v/9REV6Q/FpmIxf2Z7/l5AbcQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/wevm" + } + ], + "license": "MIT", + "dependencies": { + "@noble/curves": "1.9.1", + "@noble/hashes": "1.8.0", + "@scure/bip32": "1.7.0", + "@scure/bip39": "1.6.0", + "abitype": "1.1.0", + "isows": "1.0.7", + "ox": "0.9.6", + "ws": "8.18.3" + }, + "peerDependencies": { + "typescript": ">=5.0.4" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/viem/node_modules/@noble/curves": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", + "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/viem/node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/vite": { "version": "7.1.5", "resolved": "https://registry.npmjs.org/vite/-/vite-7.1.5.tgz", "integrity": "sha512-4cKBO9wR75r0BeIWWWId9XK9Lj6La5X846Zw9dFfzMRw38IlTk2iCcUt6hsyiDRcPidc55ZParFYDXi0nXOeLQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", @@ -2884,27 +3268,34 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/ws": { + "version": "8.18.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", + "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", + "license": "MIT", + "peer": true, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true, "license": "ISC" - }, - "node_modules/yaml": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.1.tgz", - "integrity": "sha512-lcYcMxX2PO9XMGvAJkJ3OsNMw+/7FKes7/hgerGUYWIoWu5j/+YQqcZr5JnPZWzOsEBgMbSbiSTn/dv/69Mkpw==", - "dev": true, - "license": "ISC", - "optional": true, - "peer": true, - "bin": { - "yaml": "bin.mjs" - }, - "engines": { - "node": ">= 14.6" - } } } } diff --git a/client/examples/react-show-balance-and-cross-chain-transfers/package.json b/client/examples/react-show-balance-and-cross-chain-transfers/package.json index b5c58a23..1c1bde86 100644 --- a/client/examples/react-show-balance-and-cross-chain-transfers/package.json +++ b/client/examples/react-show-balance-and-cross-chain-transfers/package.json @@ -9,6 +9,7 @@ "preview": "vite preview --port 5173" }, "dependencies": { + "@avalanche-sdk/client": "^0.0.4-alpha.16", "@emotion/react": "^11.13.3", "@emotion/styled": "^11.13.0", "@mui/icons-material": "^6.5.0", diff --git a/client/src/clients/createAvalancheClient.ts b/client/src/clients/createAvalancheClient.ts index 187fc020..ac70a2f7 100644 --- a/client/src/clients/createAvalancheClient.ts +++ b/client/src/clients/createAvalancheClient.ts @@ -15,6 +15,7 @@ import { createHealthApiClient } from "./createHealthApiClient.js"; import { createIndexApiClient } from "./createIndexApiClient.js"; import { createInfoApiClient } from "./createInfoApiClient.js"; import { createPChainClient } from "./createPChainClient.js"; +import { createProposerVMApiClient } from "./createProposervmApiClient.js"; import { createXChainClient } from "./createXChainClient.js"; import { adminAPIActions } from "./decorators/adminApi.js"; import { avalanchePublicActions } from "./decorators/avalanchePublic.js"; @@ -23,6 +24,7 @@ import { healthAPIActions } from "./decorators/healthApi.js"; import { indexAPIActions } from "./decorators/indexApi.js"; import { infoAPIActions } from "./decorators/infoApi.js"; import { pChainActions } from "./decorators/pChain.js"; +import { proposerVMAPIActions } from "./decorators/proposervmApi.js"; import { xChainActions } from "./decorators/xChain.js"; import { AvalancheClient, @@ -40,6 +42,7 @@ import { createAvalancheTransportClient } from "./utils.js"; * - Admin API * - Info API * - Health API + * - ProposerVM API * - Index API * * @param parameters - {@link AvalancheClientConfig} @@ -66,6 +69,7 @@ import { createAvalancheTransportClient } from "./utils.js"; * const adminClient = client.admin * const infoClient = client.info * const healthClient = client.health + * const proposervmClient = client.proposervm * const indexPChainBlockClient = client.indexPChainBlock * * // Get the latest block number @@ -165,34 +169,61 @@ export function createAvalancheClient< ...parameters, key: "health", name: "Health Client", - }).extend(healthAPIActions) as any, + }).extend(healthAPIActions), - indexPChainBlock: createIndexApiClient({ - ...parameters, - key: "indexPChainBlock", - name: "Index P-Chain Block Client", - clientType: "indexPChainBlock", - }).extend(indexAPIActions) as any, + proposervm: { + cChain: createProposerVMApiClient({ + ...parameters, + key: "proposervm", + name: "ProposerVM Client", + clientType: "proposervmCChain", + }).extend(proposerVMAPIActions) as any, - indexCChainBlock: createIndexApiClient({ - ...parameters, - key: "indexCChainBlock", - name: "Index C-Chain Block Client", - clientType: "indexCChainBlock", - }).extend(indexAPIActions) as any, + pChain: createProposerVMApiClient({ + ...parameters, + key: "proposervm", + name: "ProposerVM Client", + clientType: "proposervmPChain", + }).extend(proposerVMAPIActions) as any, - indexXChainBlock: createIndexApiClient({ - ...parameters, - key: "indexXChainBlock", - name: "Index X-Chain Block Client", - clientType: "indexXChainBlock", - }).extend(indexAPIActions) as any, + xChain: createProposerVMApiClient({ + ...parameters, + key: "proposervm", + name: "ProposerVM Client", + clientType: "proposervmXChain", + }).extend(proposerVMAPIActions) as any, + } as any, - indexXChainTx: createIndexApiClient({ - ...parameters, - key: "indexXChainTx", - name: "Index X-Chain Tx Client", - clientType: "indexXChainTx", - }).extend(indexAPIActions) as any, - }; + indexBlock: { + pChain: createIndexApiClient({ + ...parameters, + key: "indexPChainBlock", + name: "Index P-Chain Block Client", + clientType: "indexPChainBlock", + }).extend(indexAPIActions) as any, + + cChain: createIndexApiClient({ + ...parameters, + key: "indexCChainBlock", + name: "Index C-Chain Block Client", + clientType: "indexCChainBlock", + }).extend(indexAPIActions) as any, + + xChain: createIndexApiClient({ + ...parameters, + key: "indexXChainBlock", + name: "Index X-Chain Block Client", + clientType: "indexXChainBlock", + }).extend(indexAPIActions) as any, + } as any, + + indexTx: { + xChain: createIndexApiClient({ + ...parameters, + key: "indexXChainTx", + name: "Index X-Chain Tx Client", + clientType: "indexXChainTx", + }).extend(indexAPIActions) as any, + } as any, + } as any; } diff --git a/client/src/clients/createProposervmApiClient.ts b/client/src/clients/createProposervmApiClient.ts new file mode 100644 index 00000000..836e0cf0 --- /dev/null +++ b/client/src/clients/createProposervmApiClient.ts @@ -0,0 +1,115 @@ +import { + Account, + Address, + Chain, + ParseAccount, + Prettify, + RpcSchema, + Transport, +} from "viem"; +import { ProposerVMRpcSchema } from "../methods/proposervm/proposervmRpcSchema.js"; +import { + AvalancheCoreClient, + createAvalancheCoreClient, + CreateAvalancheCoreClientErrorType, +} from "./createAvalancheCoreClient.js"; +import { + proposerVMAPIActions, + ProposerVMAPIActions, +} from "./decorators/proposervmApi.js"; +import { AvalancheClientConfig } from "./types/createAvalancheClient.js"; + +export type ProposerVMApiClientConfig< + transport extends Transport, + chain extends Chain | undefined = Chain | undefined, + accountOrAddress extends Account | Address | undefined = undefined, + rpcSchema extends RpcSchema | undefined = undefined, + raw extends boolean = false +> = Prettify< + AvalancheClientConfig & { + clientType: "proposervmCChain" | "proposervmPChain" | "proposervmXChain"; + } +>; + +export type ProposerVMApiClient< + transport extends Transport = Transport, + chain extends Chain | undefined = Chain | undefined, + accountOrAddress extends Account | undefined = undefined, + rpcSchema extends RpcSchema | undefined = undefined +> = Prettify< + AvalancheCoreClient< + transport, + chain, + accountOrAddress, + rpcSchema extends RpcSchema + ? [...ProposerVMRpcSchema, ...rpcSchema] + : ProposerVMRpcSchema, + ProposerVMAPIActions + > +>; + +export type CreateProposerVMApiClientErrorType = + CreateAvalancheCoreClientErrorType; + +/** + * Creates a ProposerVM API Client with a given transport configured for a Chain. + * + * The ProposerVM API Client is an interface to interact with the ProposerVM API through Avalanche-specific JSON-RPC API methods. + * + * @param parameters - {@link ProposerVMApiClientConfig} + * @returns A ProposerVM API Client. {@link ProposerVMApiClient} + * + * @example + * ```ts + * import { createProposerVMApiClient} from '@avalanche-sdk/client' + * import { avalanche } from '@avalanche-sdk/client/chains' + * + * const client = createProposerVMApiClient({ + * chain: avalanche, + * transport: { + * type: "http", + * }, + * }) + * + * // Get proposer VM height + * const height = await client.getProposedHeight() + * + * // Get current epoch + * const epoch = await client.getCurrentEpoch() + * ``` + */ +export function createProposerVMApiClient< + transport extends Transport, + chain extends Chain | undefined = undefined, + accountOrAddress extends Account | Address | undefined = undefined, + rpcSchema extends RpcSchema | undefined = undefined, + raw extends boolean = false +>( + parameters: ProposerVMApiClientConfig< + transport, + chain, + accountOrAddress, + rpcSchema, + raw + > +): ProposerVMApiClient< + transport, + chain, + ParseAccount, + rpcSchema +> { + const { + key = "proposervm", + name = "ProposerVM API Client", + clientType, + } = parameters; + + const client = createAvalancheCoreClient({ + ...parameters, + key, + name, + clientType, + }); + + return client.extend(proposerVMAPIActions) as any; +} diff --git a/client/src/clients/decorators/avalanche.test.ts b/client/src/clients/decorators/avalanche.test.ts index c61013b7..abfc5ef8 100644 --- a/client/src/clients/decorators/avalanche.test.ts +++ b/client/src/clients/decorators/avalanche.test.ts @@ -275,22 +275,40 @@ const mockClient = { chain: avalanche, transport: mockTransport, }), - indexPChainBlock: createAvalancheBaseClient({ - chain: avalanche, - transport: mockTransport, - }), - indexCChainBlock: createAvalancheBaseClient({ - chain: avalanche, - transport: mockTransport, - }), - indexXChainBlock: createAvalancheBaseClient({ - chain: avalanche, - transport: mockTransport, - }), - indexXChainTx: createAvalancheBaseClient({ - chain: avalanche, - transport: mockTransport, - }), + proposervm: { + cChain: createAvalancheBaseClient({ + chain: avalanche, + transport: mockTransport, + }), + pChain: createAvalancheBaseClient({ + chain: avalanche, + transport: mockTransport, + }), + xChain: createAvalancheBaseClient({ + chain: avalanche, + transport: mockTransport, + }), + } as any, + indexBlock: { + pChain: createAvalancheBaseClient({ + chain: avalanche, + transport: mockTransport, + }), + cChain: createAvalancheBaseClient({ + chain: avalanche, + transport: mockTransport, + }), + xChain: createAvalancheBaseClient({ + chain: avalanche, + transport: mockTransport, + }), + }, + indexTx: { + xChain: createAvalancheBaseClient({ + chain: avalanche, + transport: mockTransport, + }), + }, } as any; const avalancheClient = avalancheActions(mockClient); @@ -360,37 +378,41 @@ test("default", async () => { "liveness": [Function], "readiness": [Function], }, - "indexCChainBlock": { - "getContainerByID": [Function], - "getContainerByIndex": [Function], - "getContainerRange": [Function], - "getIndex": [Function], - "getLastAccepted": [Function], - "isAccepted": [Function], - }, - "indexPChainBlock": { - "getContainerByID": [Function], - "getContainerByIndex": [Function], - "getContainerRange": [Function], - "getIndex": [Function], - "getLastAccepted": [Function], - "isAccepted": [Function], + "indexBlock": { + "cChain": { + "getContainerByID": [Function], + "getContainerByIndex": [Function], + "getContainerRange": [Function], + "getIndex": [Function], + "getLastAccepted": [Function], + "isAccepted": [Function], + }, + "pChain": { + "getContainerByID": [Function], + "getContainerByIndex": [Function], + "getContainerRange": [Function], + "getIndex": [Function], + "getLastAccepted": [Function], + "isAccepted": [Function], + }, + "xChain": { + "getContainerByID": [Function], + "getContainerByIndex": [Function], + "getContainerRange": [Function], + "getIndex": [Function], + "getLastAccepted": [Function], + "isAccepted": [Function], + }, }, - "indexXChainBlock": { - "getContainerByID": [Function], - "getContainerByIndex": [Function], - "getContainerRange": [Function], - "getIndex": [Function], - "getLastAccepted": [Function], - "isAccepted": [Function], - }, - "indexXChainTx": { - "getContainerByID": [Function], - "getContainerByIndex": [Function], - "getContainerRange": [Function], - "getIndex": [Function], - "getLastAccepted": [Function], - "isAccepted": [Function], + "indexTx": { + "xChain": { + "getContainerByID": [Function], + "getContainerByIndex": [Function], + "getContainerRange": [Function], + "getIndex": [Function], + "getLastAccepted": [Function], + "isAccepted": [Function], + }, }, "info": { "acps": [Function], @@ -410,6 +432,7 @@ test("default", async () => { "maxPriorityFeePerGas": [Function], "multicall": [Function], "pChain": { + "getAllValidatorsAt": [Function], "getBalance": [Function], "getBlock": [Function], "getBlockByHeight": [Function], @@ -440,6 +463,20 @@ test("default", async () => { "validates": [Function], }, "prepareTransactionRequest": [Function], + "proposervm": { + "cChain": { + "getCurrentEpoch": [Function], + "getProposedHeight": [Function], + }, + "pChain": { + "getCurrentEpoch": [Function], + "getProposedHeight": [Function], + }, + "xChain": { + "getCurrentEpoch": [Function], + "getProposedHeight": [Function], + }, + }, "readContract": [Function], "sendRawTransaction": [Function], "sendRawTransactionSync": [Function], @@ -648,7 +685,7 @@ describe("smoke test", () => { describe("Index API methods", () => { test("getContainerByID", async () => { - const res = await avalancheClient.indexPChainBlock!.getContainerByID({ + const res = await avalancheClient.indexBlock!.pChain!.getContainerByID({ id: "6fXf5hncR8LXvwtM8iezFQBpK5cubV6y1dWgpJCcNyzGB1EzY", encoding: "hex", }); @@ -656,7 +693,7 @@ describe("smoke test", () => { }); test("isAccepted", async () => { - const res = await avalancheClient.indexPChainBlock!.isAccepted({ + const res = await avalancheClient.indexBlock!.pChain!.isAccepted({ id: "6fXf5hncR8LXvwtM8iezFQBpK5cubV6y1dWgpJCcNyzGB1EzY", encoding: "hex", }); @@ -664,6 +701,28 @@ describe("smoke test", () => { }); }); + describe("ProposerVM API methods", () => { + test("getCurrentEpoch C-Chain", async () => { + const res = await avalancheClient.proposervm!.cChain!.getCurrentEpoch(); + expect(res).toBeDefined(); + }); + + test("getProposedHeight C-Chain", async () => { + const res = await avalancheClient.proposervm!.cChain!.getProposedHeight(); + expect(res).toBeDefined(); + }); + + test("getCurrentEpoch P-Chain", async () => { + const res = await avalancheClient.proposervm!.pChain!.getCurrentEpoch(); + expect(res).toBeDefined(); + }); + + test("getProposedHeight X-Chain", async () => { + const res = await avalancheClient.proposervm!.xChain!.getProposedHeight(); + expect(res).toBeDefined(); + }); + }); + describe("Avalanche Public methods", () => { test("baseFee", async () => { const res = await avalancheClient.baseFee(); diff --git a/client/src/clients/decorators/avalanche.ts b/client/src/clients/decorators/avalanche.ts index 1f0c0fa7..5d1abd98 100644 --- a/client/src/clients/decorators/avalanche.ts +++ b/client/src/clients/decorators/avalanche.ts @@ -10,8 +10,8 @@ import { healthAPIActions, HealthAPIActions } from "./healthApi.js"; import { IndexAPIActions, indexAPIActions } from "./indexApi.js"; import { InfoAPIActions, infoAPIActions } from "./infoApi.js"; import { pChainActions, PChainActions } from "./pChain.js"; +import { ProposerVMAPIActions, proposerVMAPIActions } from "./proposervmApi.js"; import { XChainActions, xChainActions } from "./xChain.js"; - export type AvalancheActions = PublicActions & AvalanchePublicActions & { pChain?: PChainActions; @@ -21,10 +21,19 @@ export type AvalancheActions = PublicActions & admin?: AdminAPIActions; info?: InfoAPIActions; health?: HealthAPIActions; - indexPChainBlock?: IndexAPIActions; - indexCChainBlock?: IndexAPIActions; - indexXChainBlock?: IndexAPIActions; - indexXChainTx?: IndexAPIActions; + indexBlock?: { + pChain?: IndexAPIActions; + cChain?: IndexAPIActions; + xChain?: IndexAPIActions; + }; + indexTx?: { + xChain?: IndexAPIActions; + }; + proposervm?: { + cChain?: ProposerVMAPIActions; + pChain?: ProposerVMAPIActions; + xChain?: ProposerVMAPIActions; + }; }; export function avalancheActions< @@ -38,10 +47,17 @@ export function avalancheActions< admin: adminClient, info: infoClient, health: healthClient, - indexPChainBlock: indexPChainBlockClient, - indexCChainBlock: indexCChainBlockClient, - indexXChainBlock: indexXChainBlockClient, - indexXChainTx: indexXChainTxClient, + indexBlock: { + pChain: indexPChainBlockClient, + cChain: indexCChainBlockClient, + xChain: indexXChainBlockClient, + }, + indexTx: { xChain: indexXChainTxClient }, + proposervm: { + cChain: proposervmCChainClient, + pChain: proposervmPChainClient, + xChain: proposervmXChainClient, + }, ...publicClient } = client as any; @@ -54,17 +70,45 @@ export function avalancheActions< ...(infoClient ? { info: infoAPIActions(infoClient) } : {}), ...(healthClient ? { health: healthAPIActions(healthClient) } : {}), ...(adminClient ? { admin: adminAPIActions(adminClient) } : {}), - ...(indexPChainBlockClient - ? { indexPChainBlock: indexAPIActions(indexPChainBlockClient) } - : {}), - ...(indexCChainBlockClient - ? { indexCChainBlock: indexAPIActions(indexCChainBlockClient) } - : {}), - ...(indexXChainBlockClient - ? { indexXChainBlock: indexAPIActions(indexXChainBlockClient) } + ...(indexPChainBlockClient || + indexCChainBlockClient || + indexXChainBlockClient || + indexXChainTxClient + ? { + indexBlock: { + ...(indexPChainBlockClient + ? { pChain: indexAPIActions(indexPChainBlockClient) } + : {}), + ...(indexCChainBlockClient + ? { cChain: indexAPIActions(indexCChainBlockClient) } + : {}), + ...(indexXChainBlockClient + ? { xChain: indexAPIActions(indexXChainBlockClient) } + : {}), + }, + indexTx: { + ...(indexXChainTxClient + ? { xChain: indexAPIActions(indexXChainTxClient) } + : {}), + }, + } : {}), - ...(indexXChainTxClient - ? { indexXChainTx: indexAPIActions(indexXChainTxClient) } + ...(proposervmCChainClient || + proposervmPChainClient || + proposervmXChainClient + ? { + proposervm: { + ...(proposervmCChainClient + ? { cChain: proposerVMAPIActions(proposervmCChainClient) } + : {}), + ...(proposervmPChainClient + ? { pChain: proposerVMAPIActions(proposervmPChainClient) } + : {}), + ...(proposervmXChainClient + ? { xChain: proposerVMAPIActions(proposervmXChainClient) } + : {}), + }, + } : {}), }; } diff --git a/client/src/clients/decorators/pChain.test.ts b/client/src/clients/decorators/pChain.test.ts index e8e4dfe3..2930bc0a 100644 --- a/client/src/clients/decorators/pChain.test.ts +++ b/client/src/clients/decorators/pChain.test.ts @@ -95,6 +95,7 @@ const pChainClient = pChainActions(client); test("default", async () => { expect(pChainClient).toMatchInlineSnapshot(`{ + "getAllValidatorsAt": [Function], "getBalance": [Function], "getBlock": [Function], "getBlockByHeight": [Function], diff --git a/client/src/clients/decorators/pChain.ts b/client/src/clients/decorators/pChain.ts index b0323614..ab94b977 100644 --- a/client/src/clients/decorators/pChain.ts +++ b/client/src/clients/decorators/pChain.ts @@ -1,4 +1,5 @@ import { Chain, Transport } from "viem"; +import { getAllValidatorsAt } from "../../methods/pChain/getAllValidatorsAt.js"; import { getBalance } from "../../methods/pChain/getBalance.js"; import { getBlock } from "../../methods/pChain/getBlock.js"; import { getBlockByHeight } from "../../methods/pChain/getBlockByHeight.js"; @@ -25,6 +26,10 @@ import { getUTXOs } from "../../methods/pChain/getUTXOs.js"; import { getValidatorsAt } from "../../methods/pChain/getValidatorsAt.js"; import { issueTx } from "../../methods/pChain/issueTx.js"; import { sampleValidators } from "../../methods/pChain/sampleValidators.js"; +import { + GetAllValidatorsAtParameters, + GetAllValidatorsAtReturnType, +} from "../../methods/pChain/types/getAllValidatorsAt.js"; import { GetBalanceParameters, GetBalanceReturnType, @@ -777,6 +782,35 @@ export type PChainActions = { args: GetValidatorsAtParameters ) => Promise; + /** + * Get all validators at a specific height across all Subnets and the Primary Network. + * + * - Docs: https://build.avax.network/docs/api-reference/p-chain/api#platformgetallvalidatorsat + * + * @param args - {@link GetAllValidatorsAtParameters} The height + * @returns All validators at that height across all Subnets. {@link GetAllValidatorsAtReturnType} + * + * @example + * ```ts + * import { createAvalancheClient} from '@avalanche-sdk/client' + * import { avalanche } from '@avalanche-sdk/client/chains' + * + * const client = createAvalancheClient({ + * chain: avalanche, + * transport: { + * type: "http", + * }, + * }) + * + * const validators = await client.pChain.getAllValidatorsAt({ + * height: 1000001 + * }) + * ``` + */ + getAllValidatorsAt: ( + args: GetAllValidatorsAtParameters + ) => Promise; + /** * Issue a transaction to the Platform Chain. * @@ -917,6 +951,7 @@ export function pChainActions< getTx: (args) => getTx(client, args), getTxStatus: (args) => getTxStatus(client, args), getUTXOs: (args) => getUTXOs(client, args), + getAllValidatorsAt: (args) => getAllValidatorsAt(client, args), getValidatorsAt: (args) => getValidatorsAt(client, args), issueTx: (args) => issueTx(client, args), sampleValidators: (args) => sampleValidators(client, args), diff --git a/client/src/clients/decorators/proposervmApi.ts b/client/src/clients/decorators/proposervmApi.ts new file mode 100644 index 00000000..130454fa --- /dev/null +++ b/client/src/clients/decorators/proposervmApi.ts @@ -0,0 +1,65 @@ +import { Chain, Transport } from "viem"; +import { getCurrentEpoch } from "../../methods/proposervm/getCurrentEpoch.js"; +import { getProposedHeight } from "../../methods/proposervm/getProposedHeight.js"; +import { GetCurrentEpochReturnType } from "../../methods/proposervm/types/getCurrentEpoch.js"; +import { GetProposedHeightReturnType } from "../../methods/proposervm/types/getProposedHeight.js"; +import { AvalancheCoreClient } from "../createAvalancheCoreClient.js"; + +export type ProposerVMAPIActions = { + /** + * Returns this node's current proposer VM height. + * + * - Docs: https://build.avax.network/docs/api-reference/proposervm-api#proposervmgetproposedheight + * + * @returns This node's current proposer VM height. {@link GetProposedHeightReturnType} + * + * @example + * ```ts + * import { createAvalancheClient} from '@avalanche-sdk/client' + * import { avalanche } from '@avalanche-sdk/client/chains' + * + * const client = createAvalancheClient({ + * chain: avalanche, + * transport: { + * type: "http", + * }, + * }) + * + * const height = await client.proposervm.getProposedHeight() + * ``` + */ + getProposedHeight: () => Promise; + + /** + * Returns the current epoch information. + * + * - Docs: https://build.avax.network/docs/api-reference/proposervm-api#proposervmgetcurrentepoch + * + * @returns The current epoch information. {@link GetCurrentEpochReturnType} + * + * @example + * ```ts + * import { createAvalancheClient} from '@avalanche-sdk/client' + * import { avalanche } from '@avalanche-sdk/client/chains' + * + * const client = createAvalancheClient({ + * chain: avalanche, + * transport: { + * type: "http", + * }, + * }) + * + * const epoch = await client.proposervm.getCurrentEpoch() + * ``` + */ + getCurrentEpoch: () => Promise; +}; + +export function proposerVMAPIActions< + chain extends Chain | undefined = Chain | undefined +>(client: AvalancheCoreClient): ProposerVMAPIActions { + return { + getProposedHeight: () => getProposedHeight(client), + getCurrentEpoch: () => getCurrentEpoch(client), + }; +} diff --git a/client/src/clients/types/createAvalancheClient.ts b/client/src/clients/types/createAvalancheClient.ts index 5aac5038..8731f725 100644 --- a/client/src/clients/types/createAvalancheClient.ts +++ b/client/src/clients/types/createAvalancheClient.ts @@ -15,6 +15,7 @@ import { HealthRpcSchema } from "../../methods/health/healthRpcSchema.js"; import { IndexRpcSchema } from "../../methods/index/indexRpcSchema.js"; import { InfoRpcSchema } from "../../methods/info/infoRpcSchema.js"; import { PChainRpcSchema } from "../../methods/pChain/pChainRpcSchema.js"; +import { ProposerVMRpcSchema } from "../../methods/proposervm/proposervmRpcSchema.js"; import { AvalanchePublicRpcSchema } from "../../methods/public/avalanchePublicRpcSchema.js"; import { XChainRpcSchema } from "../../methods/xChain/xChainRpcSchema.js"; import { @@ -29,6 +30,7 @@ import { HealthAPIActions } from "../decorators/healthApi.js"; import { IndexAPIActions } from "../decorators/indexApi.js"; import { InfoAPIActions } from "../decorators/infoApi.js"; import { PChainActions } from "../decorators/pChain.js"; +import { ProposerVMAPIActions } from "../decorators/proposervmApi.js"; import { XChainActions } from "../decorators/xChain.js"; export type AvalancheClientConfig< @@ -112,37 +114,63 @@ export type AvalancheClient< HealthAPIActions >; - indexPChainBlock: AvalancheCoreClient< - transport, - chain, - accountOrAddress, - IndexRpcSchema, - IndexAPIActions - >; + proposervm: { + cChain: AvalancheCoreClient< + transport, + chain, + accountOrAddress, + ProposerVMRpcSchema, + ProposerVMAPIActions + >; + pChain: AvalancheCoreClient< + transport, + chain, + accountOrAddress, + ProposerVMRpcSchema, + ProposerVMAPIActions + >; + xChain: AvalancheCoreClient< + transport, + chain, + accountOrAddress, + ProposerVMRpcSchema, + ProposerVMAPIActions + >; + }; - indexCChainBlock: AvalancheCoreClient< - transport, - chain, - accountOrAddress, - IndexRpcSchema, - IndexAPIActions - >; + indexBlock: { + pChain: AvalancheCoreClient< + transport, + chain, + accountOrAddress, + IndexRpcSchema, + IndexAPIActions + >; + cChain: AvalancheCoreClient< + transport, + chain, + accountOrAddress, + IndexRpcSchema, + IndexAPIActions + >; + xChain: AvalancheCoreClient< + transport, + chain, + accountOrAddress, + IndexRpcSchema, + IndexAPIActions + >; + }; - indexXChainBlock: AvalancheCoreClient< - transport, - chain, - accountOrAddress, - IndexRpcSchema, - IndexAPIActions - >; - - indexXChainTx: AvalancheCoreClient< - transport, - chain, - accountOrAddress, - IndexRpcSchema, - IndexAPIActions - >; + indexTx: { + xChain: AvalancheCoreClient< + transport, + chain, + accountOrAddress, + IndexRpcSchema, + IndexAPIActions + >; + }; } : {}) >; diff --git a/client/src/clients/types/types.ts b/client/src/clients/types/types.ts index 13721bc6..4ea390b0 100644 --- a/client/src/clients/types/types.ts +++ b/client/src/clients/types/types.ts @@ -51,4 +51,7 @@ export type ClientType = | "indexXChainBlock" | "indexXChainTx" | "health" + | "proposervmCChain" + | "proposervmPChain" + | "proposervmXChain" | "wallet"; diff --git a/client/src/clients/utils.ts b/client/src/clients/utils.ts index a8e44134..c9897f5a 100644 --- a/client/src/clients/utils.ts +++ b/client/src/clients/utils.ts @@ -118,6 +118,12 @@ function getClientURL( return `${origin}/ext/index/X/block`; case "indexXChainTx": return `${origin}/ext/index/X/tx`; + case "proposervmCChain": + return `${origin}/ext/bc/C/proposervm`; + case "proposervmPChain": + return `${origin}/ext/bc/P/proposervm`; + case "proposervmXChain": + return `${origin}/ext/bc/X/proposervm`; default: throw new Error(`Invalid client type` + clientType); } diff --git a/client/src/index.ts b/client/src/index.ts index 9ebca055..63764a04 100644 --- a/client/src/index.ts +++ b/client/src/index.ts @@ -1450,6 +1450,12 @@ export { type PChainClient, type PChainClientConfig, } from "./clients/createPChainClient.js"; +export { + createProposerVMApiClient, + type CreateProposerVMApiClientErrorType, + type ProposerVMApiClient, + type ProposerVMApiClientConfig, +} from "./clients/createProposervmApiClient.js"; export { createXChainClient, type CreateXChainClientErrorType, @@ -1493,6 +1499,10 @@ export { pChainActions, type PChainActions, } from "./clients/decorators/pChain.js"; +export { + proposerVMAPIActions, + type ProposerVMAPIActions, +} from "./clients/decorators/proposervmApi.js"; export { xChainActions, type XChainActions, @@ -1510,6 +1520,7 @@ export { type HealthRpcSchema } from "./methods/health/healthRpcSchema.js"; export { type IndexRpcSchema } from "./methods/index/indexRpcSchema.js"; export { type InfoRpcSchema } from "./methods/info/infoRpcSchema.js"; export { type PChainRpcSchema } from "./methods/pChain/pChainRpcSchema.js"; +export { type ProposerVMRpcSchema } from "./methods/proposervm/proposervmRpcSchema.js"; export { type AvalanchePublicRpcSchema } from "./methods/public/avalanchePublicRpcSchema.js"; export { type AvalancheWalletRpcSchema } from "./methods/wallet/avalancheWalletRPCSchema.js"; export { type XChainRpcSchema } from "./methods/xChain/xChainRpcSchema.js"; diff --git a/client/src/methods/pChain/getAllValidatorsAt.ts b/client/src/methods/pChain/getAllValidatorsAt.ts new file mode 100644 index 00000000..0fb6a40d --- /dev/null +++ b/client/src/methods/pChain/getAllValidatorsAt.ts @@ -0,0 +1,55 @@ +import { Chain, Transport } from "viem"; +import { + AvalancheCoreClient, + AvalancheCoreClient as Client, +} from "../../clients/createAvalancheCoreClient.js"; +import { PChainRpcSchema } from "./pChainRpcSchema.js"; +import { + GetAllValidatorsAtParameters, + GetAllValidatorsAtReturnType, +} from "./types/getAllValidatorsAt.js"; + +/** + * Get all validators at a specific height across all Subnets and the Primary Network. + * + * - Docs: https://build.avax.network/docs/api-reference/p-chain/api#platformgetallvalidatorsat + * + * @param client - The client to use. {@link AvalancheCoreClient} + * @param params - The height {@link GetAllValidatorsAtParameters} + * @returns All validators at that height across all Subnets. {@link GetAllValidatorsAtReturnType} + * + * @example + * ```ts + * import { createAvalancheCoreClient } from '@avalanche-sdk/client' + * import { avalanche } from '@avalanche-sdk/client/chains' + * import { getAllValidatorsAt } from '@avalanche-sdk/client/methods/pChain' + * + * const client = createAvalancheCoreClient({ + * chain: avalanche, + * transport: { + * type: "http", + * url: "", + * }, + * }) + * + * const validators = await getAllValidatorsAt(client, { + * height: 1000001 + * }) + * ``` + */ +export async function getAllValidatorsAt( + client: Client, + params: GetAllValidatorsAtParameters +): Promise { + return client.request< + PChainRpcSchema, + { + method: "platform.getAllValidatorsAt"; + params: GetAllValidatorsAtParameters; + }, + GetAllValidatorsAtReturnType + >({ + method: "platform.getAllValidatorsAt", + params, + }); +} diff --git a/client/src/methods/pChain/index.ts b/client/src/methods/pChain/index.ts index 26eb5f3a..6cf06f49 100644 --- a/client/src/methods/pChain/index.ts +++ b/client/src/methods/pChain/index.ts @@ -159,6 +159,13 @@ export { type GetUTXOsReturnType, } from "./types/getUTXOs.js"; +export { getAllValidatorsAt } from "./getAllValidatorsAt.js"; +export { + type GetAllValidatorsAtErrorType, + type GetAllValidatorsAtParameters, + type GetAllValidatorsAtReturnType, +} from "./types/getAllValidatorsAt.js"; + export { getValidatorsAt } from "./getValidatorsAt.js"; export { type GetValidatorsAtErrorType, diff --git a/client/src/methods/pChain/pChainRpcSchema.ts b/client/src/methods/pChain/pChainRpcSchema.ts index f463eb75..e3c6e482 100644 --- a/client/src/methods/pChain/pChainRpcSchema.ts +++ b/client/src/methods/pChain/pChainRpcSchema.ts @@ -1,4 +1,5 @@ import { RpcSchemaOverride } from "viem"; +import { GetAllValidatorsAtMethod } from "./types/getAllValidatorsAt.js"; import { GetBalanceMethod } from "./types/getBalance.js"; import { GetBlockMethod } from "./types/getBlock.js"; import { GetBlockByHeightMethod } from "./types/getBlockByHeight.js"; @@ -52,6 +53,7 @@ export type PChainMethods = [ GetTxMethod, GetTxStatusMethod, GetUTXOsMethod, + GetAllValidatorsAtMethod, GetValidatorsAtMethod, IssueTxMethod, SampleValidatorsMethod, diff --git a/client/src/methods/pChain/types/getAllValidatorsAt.ts b/client/src/methods/pChain/types/getAllValidatorsAt.ts new file mode 100644 index 00000000..9a057b7f --- /dev/null +++ b/client/src/methods/pChain/types/getAllValidatorsAt.ts @@ -0,0 +1,36 @@ +import { RequestErrorType } from "viem/utils"; + +/** + * Parameters for the `platform.getAllValidatorsAt` method. + * Get all validators at a given height across all Subnets and the Primary Network. + * @property height - The P-Chain height to get validators at, or "proposed" to return the validator set at the node's ProposerVM height + */ +export type GetAllValidatorsAtParameters = { + height: number | "proposed"; +}; + +/** + * Return type for the `platform.getAllValidatorsAt` method. + * @property validatorSets - A map of Subnet IDs to their validator information + */ +export type GetAllValidatorsAtReturnType = { + validatorSets: Record< + string, + { + validators: Array<{ + publicKey: string; + weight: string; + nodeIDs: string[]; + }>; + totalWeight: string; + } + >; +}; + +export type GetAllValidatorsAtErrorType = RequestErrorType; + +export type GetAllValidatorsAtMethod = { + Method: "platform.getAllValidatorsAt"; + Parameters: GetAllValidatorsAtParameters; + ReturnType: GetAllValidatorsAtReturnType; +}; diff --git a/client/src/methods/proposervm/getCurrentEpoch.ts b/client/src/methods/proposervm/getCurrentEpoch.ts new file mode 100644 index 00000000..0ff917aa --- /dev/null +++ b/client/src/methods/proposervm/getCurrentEpoch.ts @@ -0,0 +1,45 @@ +import { Chain, Transport } from "viem"; +import { + AvalancheCoreClient, + AvalancheCoreClient as Client, +} from "../../clients/createAvalancheCoreClient.js"; +import { ProposerVMRpcSchema } from "../../methods/proposervm/proposervmRpcSchema.js"; +import { GetCurrentEpochReturnType } from "./types/getCurrentEpoch.js"; + +/** + * Returns the current epoch information. + * + * - Docs: https://build.avax.network/docs/api-reference/proposervm-api#proposervmgetcurrentepoch + * + * @param client - The client to use. {@link AvalancheCoreClient} + * @returns The current epoch information. {@link GetCurrentEpochReturnType} + * + * @example + * ```ts + * import { createAvalancheCoreClient } from '@avalanche-sdk/client' + * import { avalanche } from '@avalanche-sdk/client/chains' + * import { getCurrentEpoch } from '@avalanche-sdk/client/methods/proposervm' + * + * const client = createAvalancheCoreClient({ + * chain: avalanche, + * transport: { + * type: "http", + * url: "", + * }, + * }) + * + * const epoch = await getCurrentEpoch(client) + * ``` + */ +export async function getCurrentEpoch( + client: Client +): Promise { + return client.request< + ProposerVMRpcSchema, + { method: "proposervm.getCurrentEpoch"; params: {} }, + GetCurrentEpochReturnType + >({ + method: "proposervm.getCurrentEpoch", + params: {}, + }); +} diff --git a/client/src/methods/proposervm/getProposedHeight.ts b/client/src/methods/proposervm/getProposedHeight.ts new file mode 100644 index 00000000..76c7fbf3 --- /dev/null +++ b/client/src/methods/proposervm/getProposedHeight.ts @@ -0,0 +1,45 @@ +import { Chain, Transport } from "viem"; +import { + AvalancheCoreClient, + AvalancheCoreClient as Client, +} from "../../clients/createAvalancheCoreClient.js"; +import { ProposerVMRpcSchema } from "../../methods/proposervm/proposervmRpcSchema.js"; +import { GetProposedHeightReturnType } from "./types/getProposedHeight.js"; + +/** + * Returns this node's current proposer VM height. + * + * - Docs: https://build.avax.network/docs/api-reference/proposervm-api#proposervmgetproposedheight + * + * @param client - The client to use. {@link AvalancheCoreClient} + * @returns This node's current proposer VM height. {@link GetProposedHeightReturnType} + * + * @example + * ```ts + * import { createAvalancheCoreClient } from '@avalanche-sdk/client' + * import { avalanche } from '@avalanche-sdk/client/chains' + * import { getProposedHeight } from '@avalanche-sdk/client/methods/proposervm' + * + * const client = createAvalancheCoreClient({ + * chain: avalanche, + * transport: { + * type: "http", + * url: "", + * }, + * }) + * + * const height = await getProposedHeight(client) + * ``` + */ +export async function getProposedHeight( + client: Client +): Promise { + return client.request< + ProposerVMRpcSchema, + { method: "proposervm.getProposedHeight"; params: {} }, + GetProposedHeightReturnType + >({ + method: "proposervm.getProposedHeight", + params: {}, + }); +} diff --git a/client/src/methods/proposervm/index.ts b/client/src/methods/proposervm/index.ts new file mode 100644 index 00000000..e4a92586 --- /dev/null +++ b/client/src/methods/proposervm/index.ts @@ -0,0 +1,11 @@ +export { getProposedHeight } from "./getProposedHeight.js"; +export type { + GetProposedHeightErrorType, + GetProposedHeightReturnType, +} from "./types/getProposedHeight.js"; + +export { getCurrentEpoch } from "./getCurrentEpoch.js"; +export type { + GetCurrentEpochErrorType, + GetCurrentEpochReturnType, +} from "./types/getCurrentEpoch.js"; diff --git a/client/src/methods/proposervm/proposervmRpcSchema.ts b/client/src/methods/proposervm/proposervmRpcSchema.ts new file mode 100644 index 00000000..9a0ebe5a --- /dev/null +++ b/client/src/methods/proposervm/proposervmRpcSchema.ts @@ -0,0 +1,15 @@ +import { RpcSchemaOverride } from "viem"; +import { GetCurrentEpochMethod } from "./types/getCurrentEpoch.js"; +import { GetProposedHeightMethod } from "./types/getProposedHeight.js"; + +export type ProposerVMMethods = [ + GetProposedHeightMethod, + GetCurrentEpochMethod +]; + +/** + * The RPC schema for the ProposerVM methods. + * + * @see {@link ProposerVMMethods} + */ +export type ProposerVMRpcSchema = RpcSchemaOverride & ProposerVMMethods; diff --git a/client/src/methods/proposervm/types/getCurrentEpoch.ts b/client/src/methods/proposervm/types/getCurrentEpoch.ts new file mode 100644 index 00000000..a9cf180c --- /dev/null +++ b/client/src/methods/proposervm/types/getCurrentEpoch.ts @@ -0,0 +1,21 @@ +import { RequestErrorType } from "viem/utils"; + +/** + * Return type for the proposervm.getCurrentEpoch method. + * @property number - The current epoch number + * @property startTime - The epoch start time (Unix timestamp) + * @property pChainHeight - The P-Chain height at the start of this epoch + */ +export type GetCurrentEpochReturnType = { + number: string; + startTime: string; + pChainHeight: string; +}; + +export type GetCurrentEpochErrorType = RequestErrorType; + +export type GetCurrentEpochMethod = { + Method: "proposervm.getCurrentEpoch"; + Parameters: {}; + ReturnType: GetCurrentEpochReturnType; +}; diff --git a/client/src/methods/proposervm/types/getProposedHeight.ts b/client/src/methods/proposervm/types/getProposedHeight.ts new file mode 100644 index 00000000..d70fe39a --- /dev/null +++ b/client/src/methods/proposervm/types/getProposedHeight.ts @@ -0,0 +1,17 @@ +import { RequestErrorType } from "viem/utils"; + +/** + * Return type for the proposervm.getProposedHeight method. + * @property height - This node's current proposer VM height + */ +export type GetProposedHeightReturnType = { + height: string; +}; + +export type GetProposedHeightErrorType = RequestErrorType; + +export type GetProposedHeightMethod = { + Method: "proposervm.getProposedHeight"; + Parameters: {}; + ReturnType: GetProposedHeightReturnType; +}; From 5d1246d19f3f5788d0229c6bd5c4ca1b5c7240d4 Mon Sep 17 00:00:00 2001 From: Sayan kar Date: Mon, 3 Nov 2025 17:02:48 +0530 Subject: [PATCH 03/10] chore: add avalanche specific block types --- client/package-lock.json | 3 +- client/src/index.ts | 4 +- client/src/types/block.ts | 117 +++++++++++++++++++++++++++++++++++ client/src/types/global.d.ts | 19 ++++++ client/tsconfig.json | 3 +- 5 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 client/src/types/block.ts create mode 100644 client/src/types/global.d.ts diff --git a/client/package-lock.json b/client/package-lock.json index 35fc67f7..0e476918 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -5596,7 +5596,8 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "dev": true, - "license": "0BSD" + "license": "0BSD", + "peer": true }, "node_modules/tty-browserify": { "version": "0.0.1", diff --git a/client/src/index.ts b/client/src/index.ts index 63764a04..d1a4fa98 100644 --- a/client/src/index.ts +++ b/client/src/index.ts @@ -899,7 +899,7 @@ export type { AuthorizationRequest, BlobSidecar, BlobSidecars, - Block, + // Block is exported separately below from our augmented type (includes Avalanche-specific fields) BlockIdentifier, BlockNumber, BlockTag, @@ -1524,3 +1524,5 @@ export { type ProposerVMRpcSchema } from "./methods/proposervm/proposervmRpcSche export { type AvalanchePublicRpcSchema } from "./methods/public/avalanchePublicRpcSchema.js"; export { type AvalancheWalletRpcSchema } from "./methods/wallet/avalancheWalletRPCSchema.js"; export { type XChainRpcSchema } from "./methods/xChain/xChainRpcSchema.js"; +// Augment viem's Block type with Avalanche-specific fields +export type { Block } from "./types/block.js"; diff --git a/client/src/types/block.ts b/client/src/types/block.ts new file mode 100644 index 00000000..9dc19d0f --- /dev/null +++ b/client/src/types/block.ts @@ -0,0 +1,117 @@ +/** + * Extended Block type that includes Avalanche-specific fields in addition to all viem Block fields. + * + * This type extends viem's Block type with Avalanche-specific fields that are present in + * Avalanche network blocks. All existing viem Block fields are preserved, and the following + * Avalanche-specific fields are added as optional properties: + * + * **Timing Fields:** + * - `timestampMilliseconds?: Hex` - Block timestamp in milliseconds (Avalanche-specific) + * - `minDelayExcess?: Hex` - Minimum delay excess in the Avalanche network + * + * **Gas / Data Fields:** + * - `blockGasCost?: bigint` - The block gas cost in the Avalanche network + * - `extDataGasUsed?: bigint` - The external data gas used in the Avalanche network + * - `extDataHash?: Hex` - The hash of external data in the Avalanche network + * + * **Metadata Fields:** + * - `blockExtraData?: Hex` - Extra block data in the Avalanche network + * + * @example + * ```ts + * import { Block } from '@avalanche-sdk/client/types' + * import { getBlock } from 'viem' + * + * const block: Block = await getBlock(client, { blockNumber: 123n }) + * // block now includes all viem Block fields plus: + * // block.blockGasCost, block.extDataGasUsed, block.extDataHash, + * // block.blockExtraData, block.timestampMilliseconds, block.minDelayExcess + * ``` + */ +import type { + Address, + BlockTag, + Hash, + Hex, + Transaction, + Withdrawal, +} from "viem"; +// Import viem's Block type directly from its internal module path to avoid circular reference +// This bypasses the module augmentation in global.d.ts that would cause a circular dependency + +export type Block< + quantity = bigint, + includeTransactions extends boolean = boolean, + blockTag extends BlockTag = BlockTag, + transaction = Transaction< + bigint, + number, + blockTag extends "pending" ? true : false + > +> = { + /** Base fee per gas */ + baseFeePerGas: quantity | null; + /** Total used blob gas by all transactions in this block */ + blobGasUsed: quantity; + /** Difficulty for this block */ + difficulty: quantity; + /** Excess blob gas */ + excessBlobGas: quantity; + /** "Extra data" field of this block */ + extraData: Hex; + /** Maximum gas allowed in this block */ + gasLimit: quantity; + /** Total used gas by all transactions in this block */ + gasUsed: quantity; + /** Block hash or `null` if pending */ + hash: blockTag extends "pending" ? null : Hash; + /** Logs bloom filter or `null` if pending */ + logsBloom: blockTag extends "pending" ? null : Hex; + /** Address that received this block’s mining rewards, COINBASE address */ + miner: Address; + /** Unique identifier for the block. */ + mixHash: Hash; + /** Proof-of-work hash or `null` if pending */ + nonce: blockTag extends "pending" ? null : Hex; + /** Block number or `null` if pending */ + number: blockTag extends "pending" ? null : quantity; + /** Root of the parent beacon chain block */ + parentBeaconBlockRoot?: Hex | undefined; + /** Parent block hash */ + parentHash: Hash; + /** Root of the this block’s receipts trie */ + receiptsRoot: Hex; + sealFields: Hex[]; + /** SHA3 of the uncles data in this block */ + sha3Uncles: Hash; + /** Size of this block in bytes */ + size: quantity; + /** Root of this block’s final state trie */ + stateRoot: Hash; + /** Unix timestamp of when this block was collated */ + timestamp: quantity; + /** Total difficulty of the chain until this block */ + totalDifficulty: quantity | null; + /** List of transaction objects or hashes */ + transactions: includeTransactions extends true ? transaction[] : Hash[]; + /** Root of this block’s transaction trie */ + transactionsRoot: Hash; + /** List of uncle hashes */ + uncles: Hash[]; + /** List of withdrawal objects */ + withdrawals?: Withdrawal[] | undefined; + /** Root of the this block’s withdrawals trie */ + withdrawalsRoot?: Hex | undefined; + /** Block gas cost in the Avalanche network. */ + blockGasCost?: bigint; + /** External data gas used in the Avalanche network. */ + extDataGasUsed?: bigint; + /** Hash of external data in the Avalanche network. */ + extDataHash?: Hex; + /** Extra block data in the Avalanche network. */ + blockExtraData?: Hex; + /** Block timestamp in milliseconds (Avalanche-specific). */ + timestampMilliseconds?: Hex; + /** Minimum delay excess in the Avalanche network. */ + minDelayExcess?: Hex; +}; diff --git a/client/src/types/global.d.ts b/client/src/types/global.d.ts new file mode 100644 index 00000000..3dd7376b --- /dev/null +++ b/client/src/types/global.d.ts @@ -0,0 +1,19 @@ +// Type augmentation for viem's Block module to use Avalanche-specific Block type +import "viem"; +import type { BlockTag, Transaction } from "viem"; +import type { Block as AvalancheBlock } from "./block.js"; + +declare module "viem" { + export type Block< + quantity = bigint, + includeTransactions extends boolean = boolean, + blockTag extends BlockTag = BlockTag, + transaction = Transaction< + bigint, + number, + blockTag extends "pending" ? true : false + > + > = AvalancheBlock; +} + +export {}; diff --git a/client/tsconfig.json b/client/tsconfig.json index 77d7ccd5..91332ee6 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -36,7 +36,8 @@ "forceConsistentCasingInFileNames": true, "rootDir": "src", "baseUrl": ".", - "moduleDetection": "force" + "moduleDetection": "force", + "types": ["./src/types/global.d.ts"] }, "include": ["src/**/*"], "exclude": ["node_modules/", "dist", "**/*.test.ts", "node_modules/viem/**/*"] From e9feb27daa7716983f455fec80c85d1dc707b304 Mon Sep 17 00:00:00 2001 From: Sayan kar Date: Mon, 3 Nov 2025 17:09:52 +0530 Subject: [PATCH 04/10] chore: modify codeowners file to include data-platform team --- .github/CODEOWNERS | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index fbffbcfc..62fddbb4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1,6 @@ -* @SayanKar \ No newline at end of file +# CODEOWNERS file for Avalanche SDK TypeScript +# This file defines code owners who will be automatically requested for review +# when changes are made to the corresponding paths. +# +# Default owners for the entire repository +* @SayanKar @rajranjan0608 @ava-labs/data-platform \ No newline at end of file From 6926408901ed83ed864764381bb555b97a898111 Mon Sep 17 00:00:00 2001 From: Sayan kar Date: Mon, 3 Nov 2025 17:45:45 +0530 Subject: [PATCH 05/10] chore: modify naming to be consistent and add docs to readme --- client/README.md | 31 +++++++++++++- client/package.json | 8 ++++ client/src/clients/createAvalancheClient.ts | 33 ++++++++------- .../src/clients/createProposervmApiClient.ts | 40 +++++++++---------- .../src/clients/decorators/avalanche.test.ts | 2 +- client/src/clients/decorators/avalanche.ts | 14 +++---- .../src/clients/decorators/proposervmApi.ts | 6 +-- .../clients/types/createAvalancheClient.ts | 16 ++++---- client/src/index.ts | 14 +++---- .../pChain/types/getAllValidatorsAt.ts | 2 +- .../src/methods/proposervm/getCurrentEpoch.ts | 4 +- .../methods/proposervm/getProposedHeight.ts | 4 +- .../methods/proposervm/proposervmRpcSchema.ts | 8 ++-- 13 files changed, 111 insertions(+), 71 deletions(-) diff --git a/client/README.md b/client/README.md index ef1d21a5..1265899d 100644 --- a/client/README.md +++ b/client/README.md @@ -37,7 +37,8 @@ const cChainClient = client.cChain const adminClient = client.admin const infoClient = client.info const healthClient = client.health -const indexPChainBlockClient = client.indexPChainBlock +const indexPChainBlockClient = client.indexBlock.pChain +const proposervmCChainClient = client.proposervm // Example: Get the latest block number const blockNumber = await pChainClient.getBlockNumber() @@ -176,6 +177,7 @@ const exportTx = await cChainWallet.prepareExportTxn({ - Index C-Chain Block - Index X-Chain Block - Index X-Chain Transaction +- **proposervm Client**: Proposer VM Information ### Wallet Clients @@ -208,6 +210,7 @@ const client = createAvalancheClient({ The SDK supports multiple transport types for connecting to Avalanche nodes. Each transport type has specific configuration options: #### HTTP Transport (Recommended) + ```typescript const client = createAvalancheClient({ chain: avalanche, @@ -230,12 +233,14 @@ const client = createAvalancheClient({ ``` **HTTP Transport Features:** + - **Automatic URL Resolution**: If no URL is provided, uses the chain's default RPC endpoint - **Custom Headers**: Support for custom HTTP headers via `fetchOptions.headers` - **API Key Support**: Automatically adds `x-glacier-api-key` header when `apiKey` is provided - **Rate Limit Support**: Automatically adds `rlToken` header when `rlToken` is provided #### WebSocket Transport + ```typescript const client = createAvalancheClient({ chain: avalanche, @@ -252,11 +257,13 @@ const client = createAvalancheClient({ ``` **WebSocket Transport Features:** + - **Real-time Updates**: Supports WebSocket connections for live data - **Automatic Reconnection**: Built-in retry logic with configurable retry count and delay - **Event-driven**: Ideal for subscribing to blockchain events and real-time updates #### Custom Transport + ```typescript const client = createAvalancheClient({ chain: avalanche, @@ -271,11 +278,13 @@ const client = createAvalancheClient({ ``` **Custom Transport Features:** + - **Provider Integration**: Integrate with custom RPC providers or middleware - **Flexible Configuration**: Full control over transport behavior - **Wallet Support**: Special handling for wallet clients #### Fallback Transport + ```typescript const client = createAvalancheClient({ chain: avalanche, @@ -295,11 +304,13 @@ const client = createAvalancheClient({ ``` **Fallback Transport Features:** + - **High Availability**: Automatic failover between multiple RPC endpoints ### Advanced Configuration Examples #### Custom HTTP Headers and Timeouts + ```typescript const client = createAvalancheClient({ chain: avalanche, @@ -317,6 +328,7 @@ const client = createAvalancheClient({ ``` #### Multiple Fallback Endpoints + ```typescript const client = createAvalancheClient({ chain: avalanche, @@ -336,6 +348,7 @@ const client = createAvalancheClient({ ``` #### WebSocket with Custom Configuration + ```typescript const client = createAvalancheClient({ chain: avalanche, @@ -436,6 +449,9 @@ import { /* Health methods */ } from '@avalanche-sdk/client/methods/health' // Index methods import { /* Index methods */ } from '@avalanche-sdk/client/methods/index' + +// proposervm methods +import { /* proposervm methods */ } from '@avalanche-sdk/client/methods/proposervm' ``` ### Utilities @@ -507,6 +523,7 @@ import { /* Window utilities */ } from '@avalanche-sdk/client/window' - [`sampleValidators`](./src/methods/pChain/sampleValidators.ts) - Samples validators from the specified Subnet. [Docs](https://build.avax.network/docs/api-reference/p-chain/api#platformsamplevalidators) - [`validatedBy`](./src/methods/pChain/validatedBy.ts) - Gets the Subnet that validates a given blockchain. [Docs](https://build.avax.network/docs/api-reference/p-chain/api#platformvalidatedby) - [`validates`](./src/methods/pChain/validates.ts) - Gets the IDs of the blockchains a Subnet validates. [Docs](https://build.avax.network/docs/api-reference/p-chain/api#platformvalidates) +- [`getAllValidatorsAt`](./src/methods/pChain/getAllValidatorsAt.ts) - Get the validators and their weights of all L1s and the Primary Network at a given P-Chain height. [Docs](https://build.avax.network/docs/api-reference/p-chain/api#platformgetallvalidatorsat) ### X-Chain Methods @@ -619,6 +636,10 @@ import { /* Window utilities */ } from '@avalanche-sdk/client/window' - [`getLastAccepted`](./src/methods/index/getLastAccepted.ts) - Get the last accepted container. [Docs](https://build.avax.network/docs/api-reference/index-api#indexgetlastaccepted) - [`isAccepted`](./src/methods/index/isAccepted.ts) - Returns true if the container is in this index. [Docs](https://build.avax.network/docs/api-reference/index-api#indexisaccepted) +### proposervm Methods +- [`getCurrentEpoch`](./src/methods/proposervm/getCurrentEpoch.ts) - Returns the current epoch information. [Docs](https://build.avax.network/docs/api-reference/proposervm-api#proposervmgetcurrentepoch) +- [`getProposedHeight`](./src/methods/proposervm/getProposedHeight.ts) - Returns this node's current proposer VM height. [Docs](https://build.avax.network/docs/api-reference/proposervm-api#proposervmgetproposedheight) + ## Examples > **Note:** Make sure to create your own `.env` file by copying the `.env.example` file and updating the values. You'll also need to modify the `config.ts` file to point to your `.env` file path. By default, the examples use the values from `.env.example`, and the test addresses mentioned in the examples as comments (like `0x76Dd3d7b2f635c2547B861e55aE8A374E587742D` and `X-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz`) are derived from the private key values in that file. @@ -626,12 +647,15 @@ import { /* Window utilities */ } from '@avalanche-sdk/client/window' Check out the [examples](./examples) folder for comprehensive usage examples: ### Basic Examples + - [`sendAvax.ts`](./examples/sendAvax.ts) - Basic example of sending AVAX using the SDK ### Primary Network Transaction Examples + The [`prepare-primary-network-txns`](./examples/prepare-primary-network-txns) folder contains examples for preparing various types of transactions: #### Cross-Chain Transfer Examples + - [`transfer-avax-from-x-chain-to-p-chain.ts`](./examples/prepare-primary-network-txns/transfer-avax-from-x-chain-to-p-chain.ts) - Transfer AVAX from X-Chain to P-Chain - [`transfer-avax-from-p-chain-to-x-chain.ts`](./examples/prepare-primary-network-txns/transfer-avax-from-p-chain-to-x-chain.ts) - Transfer AVAX from P-Chain to X-Chain - [`transfer-avax-from-x-chain-to-c-chain.ts`](./examples/prepare-primary-network-txns/transfer-avax-from-x-chain-to-c-chain.ts) - Transfer AVAX from X-Chain to C-Chain @@ -640,10 +664,12 @@ The [`prepare-primary-network-txns`](./examples/prepare-primary-network-txns) fo - [`transfer-avax-from-c-chain-to-p-chain.ts`](./examples/prepare-primary-network-txns/transfer-avax-from-c-chain-to-p-chain.ts) - Transfer AVAX from C-Chain to P-Chain #### X-Chain Transaction Examples + - [`exportTx.ts`](./examples/prepare-primary-network-txns/x-chain/exportTx.ts) - Prepare X-Chain export transaction - [`importTx.ts`](./examples/prepare-primary-network-txns/x-chain/importTx.ts) - Prepare X-Chain import transaction #### P-Chain Transaction Examples + - [`addSubnetValidatorTx.ts`](./examples/prepare-primary-network-txns/p-chain/addSubnetValidatorTx.ts) - Add subnet validator transaction - [`baseTx.ts`](./examples/prepare-primary-network-txns/p-chain/baseTx.ts) - Base transaction example - [`convertSubnetToL1Tx.ts`](./examples/prepare-primary-network-txns/p-chain/convertSubnetToL1Tx.ts) - Convert subnet to L1 transaction @@ -654,6 +680,7 @@ The [`prepare-primary-network-txns`](./examples/prepare-primary-network-txns) fo - [`removeSubnetValidatorTx.ts`](./examples/prepare-primary-network-txns/p-chain/removeSubnetValidatorTx.ts) - Remove subnet validator transaction #### C-Chain Transaction Examples + - [`exportTx.ts`](./examples/prepare-primary-network-txns/c-chain/exportTx.ts) - Prepare C-Chain export transaction - [`importTx.ts`](./examples/prepare-primary-network-txns/c-chain/importTx.ts) - Prepare C-Chain import transaction @@ -679,4 +706,4 @@ If you encounter any issues or have questions, please: - [GitHub Repository](https://github.com/ava-labs/avalanche-sdk-typescript) - [Documentation](https://github.com/ava-labs/avalanche-sdk-typescript/tree/main/client#readme) -- [Issue Tracker](https://github.com/ava-labs/avalanche-sdk-typescript/issues) \ No newline at end of file +- [Issue Tracker](https://github.com/ava-labs/avalanche-sdk-typescript/issues) diff --git a/client/package.json b/client/package.json index 6573336b..391016fc 100644 --- a/client/package.json +++ b/client/package.json @@ -165,6 +165,11 @@ "import": "./dist/_esm/methods/index/index.js", "require": "./dist/_cjs/methods/index/index.js" }, + "./methods/proposervm": { + "types": "./dist/_types/methods/proposervm/index.d.ts", + "import": "./dist/_esm/methods/proposervm/index.js", + "require": "./dist/_cjs/methods/proposervm/index.js" + }, "./methods/info": { "types": "./dist/_types/methods/info/index.d.ts", "import": "./dist/_esm/methods/info/index.js", @@ -256,6 +261,9 @@ "methods/index": [ "./dist/_types/methods/index/index.d.ts" ], + "methods/proposervm": [ + "./dist/_types/methods/proposervm/index.d.ts" + ], "methods/info": [ "./dist/_types/methods/info/index.d.ts" ], diff --git a/client/src/clients/createAvalancheClient.ts b/client/src/clients/createAvalancheClient.ts index ac70a2f7..d80f21ee 100644 --- a/client/src/clients/createAvalancheClient.ts +++ b/client/src/clients/createAvalancheClient.ts @@ -15,7 +15,7 @@ import { createHealthApiClient } from "./createHealthApiClient.js"; import { createIndexApiClient } from "./createIndexApiClient.js"; import { createInfoApiClient } from "./createInfoApiClient.js"; import { createPChainClient } from "./createPChainClient.js"; -import { createProposerVMApiClient } from "./createProposervmApiClient.js"; +import { createProposervmApiClient } from "./createProposervmApiClient.js"; import { createXChainClient } from "./createXChainClient.js"; import { adminAPIActions } from "./decorators/adminApi.js"; import { avalanchePublicActions } from "./decorators/avalanchePublic.js"; @@ -24,7 +24,7 @@ import { healthAPIActions } from "./decorators/healthApi.js"; import { indexAPIActions } from "./decorators/indexApi.js"; import { infoAPIActions } from "./decorators/infoApi.js"; import { pChainActions } from "./decorators/pChain.js"; -import { proposerVMAPIActions } from "./decorators/proposervmApi.js"; +import { proposervmAPIActions } from "./decorators/proposervmApi.js"; import { xChainActions } from "./decorators/xChain.js"; import { AvalancheClient, @@ -42,7 +42,7 @@ import { createAvalancheTransportClient } from "./utils.js"; * - Admin API * - Info API * - Health API - * - ProposerVM API + * - proposervm API * - Index API * * @param parameters - {@link AvalancheClientConfig} @@ -69,8 +69,13 @@ import { createAvalancheTransportClient } from "./utils.js"; * const adminClient = client.admin * const infoClient = client.info * const healthClient = client.health - * const proposervmClient = client.proposervm - * const indexPChainBlockClient = client.indexPChainBlock + * const proposervmCChainClient = client.proposervm.cChain + * const proposervmPChainClient = client.proposervm.pChain + * const proposervmXChainClient = client.proposervm.xChain + * const indexPChainBlockClient = client.indexBlock.pChain + * const indexCChainBlockClient = client.indexBlock.cChain + * const indexXChainBlockClient = client.indexBlock.xChain + * const indexXChainTxClient = client.indexTx.xChain * * // Get the latest block number * const blockNumber = await client.pChain.getBlockNumber() @@ -172,26 +177,26 @@ export function createAvalancheClient< }).extend(healthAPIActions), proposervm: { - cChain: createProposerVMApiClient({ + cChain: createProposervmApiClient({ ...parameters, key: "proposervm", - name: "ProposerVM Client", + name: "proposervm Client", clientType: "proposervmCChain", - }).extend(proposerVMAPIActions) as any, + }).extend(proposervmAPIActions) as any, - pChain: createProposerVMApiClient({ + pChain: createProposervmApiClient({ ...parameters, key: "proposervm", - name: "ProposerVM Client", + name: "proposervm Client", clientType: "proposervmPChain", - }).extend(proposerVMAPIActions) as any, + }).extend(proposervmAPIActions) as any, - xChain: createProposerVMApiClient({ + xChain: createProposervmApiClient({ ...parameters, key: "proposervm", - name: "ProposerVM Client", + name: "proposervm Client", clientType: "proposervmXChain", - }).extend(proposerVMAPIActions) as any, + }).extend(proposervmAPIActions) as any, } as any, indexBlock: { diff --git a/client/src/clients/createProposervmApiClient.ts b/client/src/clients/createProposervmApiClient.ts index 836e0cf0..c0987d28 100644 --- a/client/src/clients/createProposervmApiClient.ts +++ b/client/src/clients/createProposervmApiClient.ts @@ -7,19 +7,19 @@ import { RpcSchema, Transport, } from "viem"; -import { ProposerVMRpcSchema } from "../methods/proposervm/proposervmRpcSchema.js"; +import { ProposervmRpcSchema } from "../methods/proposervm/proposervmRpcSchema.js"; import { AvalancheCoreClient, createAvalancheCoreClient, CreateAvalancheCoreClientErrorType, } from "./createAvalancheCoreClient.js"; import { - proposerVMAPIActions, - ProposerVMAPIActions, + proposervmAPIActions, + ProposervmAPIActions, } from "./decorators/proposervmApi.js"; import { AvalancheClientConfig } from "./types/createAvalancheClient.js"; -export type ProposerVMApiClientConfig< +export type ProposervmApiClientConfig< transport extends Transport, chain extends Chain | undefined = Chain | undefined, accountOrAddress extends Account | Address | undefined = undefined, @@ -31,7 +31,7 @@ export type ProposerVMApiClientConfig< } >; -export type ProposerVMApiClient< +export type ProposervmApiClient< transport extends Transport = Transport, chain extends Chain | undefined = Chain | undefined, accountOrAddress extends Account | undefined = undefined, @@ -42,29 +42,29 @@ export type ProposerVMApiClient< chain, accountOrAddress, rpcSchema extends RpcSchema - ? [...ProposerVMRpcSchema, ...rpcSchema] - : ProposerVMRpcSchema, - ProposerVMAPIActions + ? [...ProposervmRpcSchema, ...rpcSchema] + : ProposervmRpcSchema, + ProposervmAPIActions > >; -export type CreateProposerVMApiClientErrorType = +export type CreateProposervmApiClientErrorType = CreateAvalancheCoreClientErrorType; /** - * Creates a ProposerVM API Client with a given transport configured for a Chain. + * Creates a proposervm API Client with a given transport configured for a Chain. * - * The ProposerVM API Client is an interface to interact with the ProposerVM API through Avalanche-specific JSON-RPC API methods. + * The proposervm API Client is an interface to interact with the proposervm API through Avalanche-specific JSON-RPC API methods. * - * @param parameters - {@link ProposerVMApiClientConfig} - * @returns A ProposerVM API Client. {@link ProposerVMApiClient} + * @param parameters - {@link ProposervmApiClientConfig} + * @returns A proposervm API Client. {@link ProposervmApiClient} * * @example * ```ts - * import { createProposerVMApiClient} from '@avalanche-sdk/client' + * import { createProposervmApiClient} from '@avalanche-sdk/client' * import { avalanche } from '@avalanche-sdk/client/chains' * - * const client = createProposerVMApiClient({ + * const client = createProposervmApiClient({ * chain: avalanche, * transport: { * type: "http", @@ -78,21 +78,21 @@ export type CreateProposerVMApiClientErrorType = * const epoch = await client.getCurrentEpoch() * ``` */ -export function createProposerVMApiClient< +export function createProposervmApiClient< transport extends Transport, chain extends Chain | undefined = undefined, accountOrAddress extends Account | Address | undefined = undefined, rpcSchema extends RpcSchema | undefined = undefined, raw extends boolean = false >( - parameters: ProposerVMApiClientConfig< + parameters: ProposervmApiClientConfig< transport, chain, accountOrAddress, rpcSchema, raw > -): ProposerVMApiClient< +): ProposervmApiClient< transport, chain, ParseAccount, @@ -100,7 +100,7 @@ export function createProposerVMApiClient< > { const { key = "proposervm", - name = "ProposerVM API Client", + name = "proposervm API Client", clientType, } = parameters; @@ -111,5 +111,5 @@ export function createProposerVMApiClient< clientType, }); - return client.extend(proposerVMAPIActions) as any; + return client.extend(proposervmAPIActions) as any; } diff --git a/client/src/clients/decorators/avalanche.test.ts b/client/src/clients/decorators/avalanche.test.ts index abfc5ef8..cfd0da8d 100644 --- a/client/src/clients/decorators/avalanche.test.ts +++ b/client/src/clients/decorators/avalanche.test.ts @@ -701,7 +701,7 @@ describe("smoke test", () => { }); }); - describe("ProposerVM API methods", () => { + describe("proposervm API methods", () => { test("getCurrentEpoch C-Chain", async () => { const res = await avalancheClient.proposervm!.cChain!.getCurrentEpoch(); expect(res).toBeDefined(); diff --git a/client/src/clients/decorators/avalanche.ts b/client/src/clients/decorators/avalanche.ts index 5d1abd98..0656ac4e 100644 --- a/client/src/clients/decorators/avalanche.ts +++ b/client/src/clients/decorators/avalanche.ts @@ -10,7 +10,7 @@ import { healthAPIActions, HealthAPIActions } from "./healthApi.js"; import { IndexAPIActions, indexAPIActions } from "./indexApi.js"; import { InfoAPIActions, infoAPIActions } from "./infoApi.js"; import { pChainActions, PChainActions } from "./pChain.js"; -import { ProposerVMAPIActions, proposerVMAPIActions } from "./proposervmApi.js"; +import { proposervmAPIActions, ProposervmAPIActions } from "./proposervmApi.js"; import { XChainActions, xChainActions } from "./xChain.js"; export type AvalancheActions = PublicActions & AvalanchePublicActions & { @@ -30,9 +30,9 @@ export type AvalancheActions = PublicActions & xChain?: IndexAPIActions; }; proposervm?: { - cChain?: ProposerVMAPIActions; - pChain?: ProposerVMAPIActions; - xChain?: ProposerVMAPIActions; + cChain?: ProposervmAPIActions; + pChain?: ProposervmAPIActions; + xChain?: ProposervmAPIActions; }; }; @@ -99,13 +99,13 @@ export function avalancheActions< ? { proposervm: { ...(proposervmCChainClient - ? { cChain: proposerVMAPIActions(proposervmCChainClient) } + ? { cChain: proposervmAPIActions(proposervmCChainClient) } : {}), ...(proposervmPChainClient - ? { pChain: proposerVMAPIActions(proposervmPChainClient) } + ? { pChain: proposervmAPIActions(proposervmPChainClient) } : {}), ...(proposervmXChainClient - ? { xChain: proposerVMAPIActions(proposervmXChainClient) } + ? { xChain: proposervmAPIActions(proposervmXChainClient) } : {}), }, } diff --git a/client/src/clients/decorators/proposervmApi.ts b/client/src/clients/decorators/proposervmApi.ts index 130454fa..5b6b868d 100644 --- a/client/src/clients/decorators/proposervmApi.ts +++ b/client/src/clients/decorators/proposervmApi.ts @@ -5,7 +5,7 @@ import { GetCurrentEpochReturnType } from "../../methods/proposervm/types/getCur import { GetProposedHeightReturnType } from "../../methods/proposervm/types/getProposedHeight.js"; import { AvalancheCoreClient } from "../createAvalancheCoreClient.js"; -export type ProposerVMAPIActions = { +export type ProposervmAPIActions = { /** * Returns this node's current proposer VM height. * @@ -55,9 +55,9 @@ export type ProposerVMAPIActions = { getCurrentEpoch: () => Promise; }; -export function proposerVMAPIActions< +export function proposervmAPIActions< chain extends Chain | undefined = Chain | undefined ->(client: AvalancheCoreClient): ProposerVMAPIActions { +>(client: AvalancheCoreClient): ProposervmAPIActions { return { getProposedHeight: () => getProposedHeight(client), getCurrentEpoch: () => getCurrentEpoch(client), diff --git a/client/src/clients/types/createAvalancheClient.ts b/client/src/clients/types/createAvalancheClient.ts index 8731f725..52f447c3 100644 --- a/client/src/clients/types/createAvalancheClient.ts +++ b/client/src/clients/types/createAvalancheClient.ts @@ -15,7 +15,7 @@ import { HealthRpcSchema } from "../../methods/health/healthRpcSchema.js"; import { IndexRpcSchema } from "../../methods/index/indexRpcSchema.js"; import { InfoRpcSchema } from "../../methods/info/infoRpcSchema.js"; import { PChainRpcSchema } from "../../methods/pChain/pChainRpcSchema.js"; -import { ProposerVMRpcSchema } from "../../methods/proposervm/proposervmRpcSchema.js"; +import { ProposervmRpcSchema } from "../../methods/proposervm/proposervmRpcSchema.js"; import { AvalanchePublicRpcSchema } from "../../methods/public/avalanchePublicRpcSchema.js"; import { XChainRpcSchema } from "../../methods/xChain/xChainRpcSchema.js"; import { @@ -30,7 +30,7 @@ import { HealthAPIActions } from "../decorators/healthApi.js"; import { IndexAPIActions } from "../decorators/indexApi.js"; import { InfoAPIActions } from "../decorators/infoApi.js"; import { PChainActions } from "../decorators/pChain.js"; -import { ProposerVMAPIActions } from "../decorators/proposervmApi.js"; +import { ProposervmAPIActions } from "../decorators/proposervmApi.js"; import { XChainActions } from "../decorators/xChain.js"; export type AvalancheClientConfig< @@ -119,22 +119,22 @@ export type AvalancheClient< transport, chain, accountOrAddress, - ProposerVMRpcSchema, - ProposerVMAPIActions + ProposervmRpcSchema, + ProposervmAPIActions >; pChain: AvalancheCoreClient< transport, chain, accountOrAddress, - ProposerVMRpcSchema, - ProposerVMAPIActions + ProposervmRpcSchema, + ProposervmAPIActions >; xChain: AvalancheCoreClient< transport, chain, accountOrAddress, - ProposerVMRpcSchema, - ProposerVMAPIActions + ProposervmRpcSchema, + ProposervmAPIActions >; }; diff --git a/client/src/index.ts b/client/src/index.ts index d1a4fa98..fbafd764 100644 --- a/client/src/index.ts +++ b/client/src/index.ts @@ -1451,10 +1451,10 @@ export { type PChainClientConfig, } from "./clients/createPChainClient.js"; export { - createProposerVMApiClient, - type CreateProposerVMApiClientErrorType, - type ProposerVMApiClient, - type ProposerVMApiClientConfig, + createProposervmApiClient, + type CreateProposervmApiClientErrorType, + type ProposervmApiClient, + type ProposervmApiClientConfig, } from "./clients/createProposervmApiClient.js"; export { createXChainClient, @@ -1500,8 +1500,8 @@ export { type PChainActions, } from "./clients/decorators/pChain.js"; export { - proposerVMAPIActions, - type ProposerVMAPIActions, + proposervmAPIActions, + type ProposervmAPIActions, } from "./clients/decorators/proposervmApi.js"; export { xChainActions, @@ -1520,7 +1520,7 @@ export { type HealthRpcSchema } from "./methods/health/healthRpcSchema.js"; export { type IndexRpcSchema } from "./methods/index/indexRpcSchema.js"; export { type InfoRpcSchema } from "./methods/info/infoRpcSchema.js"; export { type PChainRpcSchema } from "./methods/pChain/pChainRpcSchema.js"; -export { type ProposerVMRpcSchema } from "./methods/proposervm/proposervmRpcSchema.js"; +export { type ProposervmRpcSchema } from "./methods/proposervm/proposervmRpcSchema.js"; export { type AvalanchePublicRpcSchema } from "./methods/public/avalanchePublicRpcSchema.js"; export { type AvalancheWalletRpcSchema } from "./methods/wallet/avalancheWalletRPCSchema.js"; export { type XChainRpcSchema } from "./methods/xChain/xChainRpcSchema.js"; diff --git a/client/src/methods/pChain/types/getAllValidatorsAt.ts b/client/src/methods/pChain/types/getAllValidatorsAt.ts index 9a057b7f..ecb0dc8a 100644 --- a/client/src/methods/pChain/types/getAllValidatorsAt.ts +++ b/client/src/methods/pChain/types/getAllValidatorsAt.ts @@ -3,7 +3,7 @@ import { RequestErrorType } from "viem/utils"; /** * Parameters for the `platform.getAllValidatorsAt` method. * Get all validators at a given height across all Subnets and the Primary Network. - * @property height - The P-Chain height to get validators at, or "proposed" to return the validator set at the node's ProposerVM height + * @property height - The P-Chain height to get validators at, or "proposed" to return the validator set at the node's proposervm height */ export type GetAllValidatorsAtParameters = { height: number | "proposed"; diff --git a/client/src/methods/proposervm/getCurrentEpoch.ts b/client/src/methods/proposervm/getCurrentEpoch.ts index 0ff917aa..89c1a8fb 100644 --- a/client/src/methods/proposervm/getCurrentEpoch.ts +++ b/client/src/methods/proposervm/getCurrentEpoch.ts @@ -3,7 +3,7 @@ import { AvalancheCoreClient, AvalancheCoreClient as Client, } from "../../clients/createAvalancheCoreClient.js"; -import { ProposerVMRpcSchema } from "../../methods/proposervm/proposervmRpcSchema.js"; +import { ProposervmRpcSchema } from "../../methods/proposervm/proposervmRpcSchema.js"; import { GetCurrentEpochReturnType } from "./types/getCurrentEpoch.js"; /** @@ -35,7 +35,7 @@ export async function getCurrentEpoch( client: Client ): Promise { return client.request< - ProposerVMRpcSchema, + ProposervmRpcSchema, { method: "proposervm.getCurrentEpoch"; params: {} }, GetCurrentEpochReturnType >({ diff --git a/client/src/methods/proposervm/getProposedHeight.ts b/client/src/methods/proposervm/getProposedHeight.ts index 76c7fbf3..309984cd 100644 --- a/client/src/methods/proposervm/getProposedHeight.ts +++ b/client/src/methods/proposervm/getProposedHeight.ts @@ -3,7 +3,7 @@ import { AvalancheCoreClient, AvalancheCoreClient as Client, } from "../../clients/createAvalancheCoreClient.js"; -import { ProposerVMRpcSchema } from "../../methods/proposervm/proposervmRpcSchema.js"; +import { ProposervmRpcSchema } from "../../methods/proposervm/proposervmRpcSchema.js"; import { GetProposedHeightReturnType } from "./types/getProposedHeight.js"; /** @@ -35,7 +35,7 @@ export async function getProposedHeight( client: Client ): Promise { return client.request< - ProposerVMRpcSchema, + ProposervmRpcSchema, { method: "proposervm.getProposedHeight"; params: {} }, GetProposedHeightReturnType >({ diff --git a/client/src/methods/proposervm/proposervmRpcSchema.ts b/client/src/methods/proposervm/proposervmRpcSchema.ts index 9a0ebe5a..522cd21c 100644 --- a/client/src/methods/proposervm/proposervmRpcSchema.ts +++ b/client/src/methods/proposervm/proposervmRpcSchema.ts @@ -2,14 +2,14 @@ import { RpcSchemaOverride } from "viem"; import { GetCurrentEpochMethod } from "./types/getCurrentEpoch.js"; import { GetProposedHeightMethod } from "./types/getProposedHeight.js"; -export type ProposerVMMethods = [ +export type ProposervmMethods = [ GetProposedHeightMethod, GetCurrentEpochMethod ]; /** - * The RPC schema for the ProposerVM methods. + * The RPC schema for the proposervm methods. * - * @see {@link ProposerVMMethods} + * @see {@link ProposervmMethods} */ -export type ProposerVMRpcSchema = RpcSchemaOverride & ProposerVMMethods; +export type ProposervmRpcSchema = RpcSchemaOverride & ProposervmMethods; From 162d67062e4a3264f5ee38ce54bda8c9f5de4612 Mon Sep 17 00:00:00 2001 From: Sayan kar Date: Mon, 3 Nov 2025 18:13:21 +0530 Subject: [PATCH 06/10] chore: add build path for proposervm to rollup config --- client/rollup.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/rollup.config.js b/client/rollup.config.js index d6adffa4..59f51c61 100644 --- a/client/rollup.config.js +++ b/client/rollup.config.js @@ -14,7 +14,7 @@ const getEntryPoints = () => { const subPaths = [ 'accounts', 'chains', 'methods', 'methods/wallet', 'methods/wallet/cChain', 'methods/wallet/pChain', 'methods/wallet/xChain', 'methods/public', 'methods/pChain', - 'methods/admin', 'methods/cChain', 'methods/xChain', 'methods/health', + 'methods/admin', 'methods/cChain', 'methods/xChain', 'methods/health', 'methods/proposervm', 'methods/index', 'methods/info', 'node', 'nonce', 'serializable', 'siwe', 'utils', 'window' ]; From f4134d72413f79dc59d379fa415bff7f9c6b00b7 Mon Sep 17 00:00:00 2001 From: Sayan kar Date: Mon, 3 Nov 2025 21:17:38 +0530 Subject: [PATCH 07/10] chore: fix dev docs for the new methods --- client/src/clients/createIndexApiClient.ts | 5 +++-- .../src/clients/createProposervmApiClient.ts | 19 ++++++++++++++----- client/src/clients/decorators/indexApi.ts | 12 ++++++------ .../clients/decorators/proposervmApi.test.ts | 18 ++++++++++++++++++ .../src/clients/decorators/proposervmApi.ts | 16 ++++++++++------ .../src/methods/pChain/getAllValidatorsAt.ts | 3 +++ 6 files changed, 54 insertions(+), 19 deletions(-) create mode 100644 client/src/clients/decorators/proposervmApi.test.ts diff --git a/client/src/clients/createIndexApiClient.ts b/client/src/clients/createIndexApiClient.ts index 915b8786..8406d97e 100644 --- a/client/src/clients/createIndexApiClient.ts +++ b/client/src/clients/createIndexApiClient.ts @@ -69,10 +69,11 @@ export type CreateIndexApiClientErrorType = CreateAvalancheCoreClientErrorType; * transport: { * type: "http", * }, + * clientType: "indexPChainBlock", * }) * - * // Get index P-Chain block - * const block = await client.indexPChainBlock.getContainerByID({ + * // Get container by ID for P-Chain block + * const block = await client.getContainerByID({ * id: '0x1', * encoding: 'hex' * }) diff --git a/client/src/clients/createProposervmApiClient.ts b/client/src/clients/createProposervmApiClient.ts index c0987d28..df216ed2 100644 --- a/client/src/clients/createProposervmApiClient.ts +++ b/client/src/clients/createProposervmApiClient.ts @@ -64,18 +64,27 @@ export type CreateProposervmApiClientErrorType = * import { createProposervmApiClient} from '@avalanche-sdk/client' * import { avalanche } from '@avalanche-sdk/client/chains' * - * const client = createProposervmApiClient({ + * const cChainClient = createProposervmApiClient({ * chain: avalanche, * transport: { * type: "http", * }, + * clientType: "proposervmCChain", * }) * - * // Get proposer VM height - * const height = await client.getProposedHeight() + * // Get proposer VM height for C-Chain + * const cChainHeight = await cChainClient.getProposedHeight() * - * // Get current epoch - * const epoch = await client.getCurrentEpoch() + * const pChainClient = createProposervmApiClient({ + * chain: avalanche, + * transport: { + * type: "http", + * }, + * clientType: "proposervmPChain", + * }) + * + * // Get proposer VM height for P-Chain + * const pChainHeight = await pChainClient.getProposedHeight() * ``` */ export function createProposervmApiClient< diff --git a/client/src/clients/decorators/indexApi.ts b/client/src/clients/decorators/indexApi.ts index 7bcb0fdd..c59f2120 100644 --- a/client/src/clients/decorators/indexApi.ts +++ b/client/src/clients/decorators/indexApi.ts @@ -52,7 +52,7 @@ export type IndexAPIActions = { * }, * }) * - * const container = await client.indexPChainBlock.getContainerByID({ + * const container = await client.indexBlock.pChain.getContainerByID({ * id: "6fXf5hncR8LXvwtM8iezFQBpK5cubV6y1dWgpJCcNyzGB1EzY", * encoding: "hex" * }) @@ -82,7 +82,7 @@ export type IndexAPIActions = { * }, * }) * - * const container = await client.indexPChainBlock.getContainerByIndex({ + * const container = await client.indexBlock.pChain.getContainerByIndex({ * index: 1, * encoding: "hex" * }) @@ -112,7 +112,7 @@ export type IndexAPIActions = { * }, * }) * - * const containers = await client.indexPChainBlock.getContainerRange({ + * const containers = await client.indexBlock.pChain.getContainerRange({ * startIndex: 0, * endIndex: 10, * encoding: "hex" @@ -143,7 +143,7 @@ export type IndexAPIActions = { * }, * }) * - * const index = await client.indexPChainBlock.getIndex({ + * const index = await client.indexBlock.pChain.getIndex({ * id: "6fXf5hncR8LXvwtM8iezFQBpK5cubV6y1dWgpJCcNyzGB1EzY", * encoding: "hex" * }) @@ -171,7 +171,7 @@ export type IndexAPIActions = { * }, * }) * - * const lastAccepted = await client.indexPChainBlock.getLastAccepted({ + * const lastAccepted = await client.indexBlock.pChain.getLastAccepted({ * encoding: "hex" * }) * ``` @@ -200,7 +200,7 @@ export type IndexAPIActions = { * }, * }) * - * const isAccepted = await client.indexPChainBlock.isAccepted({ + * const isAccepted = await client.indexBlock.pChain.isAccepted({ * id: "6fXf5hncR8LXvwtM8iezFQBpK5cubV6y1dWgpJCcNyzGB1EzY", * encoding: "hex" * }) diff --git a/client/src/clients/decorators/proposervmApi.test.ts b/client/src/clients/decorators/proposervmApi.test.ts new file mode 100644 index 00000000..d5dc3764 --- /dev/null +++ b/client/src/clients/decorators/proposervmApi.test.ts @@ -0,0 +1,18 @@ +import { expect, test } from "vitest"; +import { avalanche } from "../../chains/index.js"; +import { createAvalancheCoreClient } from "../createAvalancheCoreClient.js"; +import { proposervmAPIActions } from "./proposervmApi.js"; + +const client = createAvalancheCoreClient({ + chain: avalanche, + transport: { type: "http" }, +} as any); + +const proposervmApiClient = proposervmAPIActions(client); + +test("default", async () => { + expect(proposervmApiClient).toMatchInlineSnapshot(`{ + "getCurrentEpoch": [Function], + "getProposedHeight": [Function], +}`); +}); diff --git a/client/src/clients/decorators/proposervmApi.ts b/client/src/clients/decorators/proposervmApi.ts index 5b6b868d..33b2b242 100644 --- a/client/src/clients/decorators/proposervmApi.ts +++ b/client/src/clients/decorators/proposervmApi.ts @@ -7,11 +7,11 @@ import { AvalancheCoreClient } from "../createAvalancheCoreClient.js"; export type ProposervmAPIActions = { /** - * Returns this node's current proposer VM height. + * Returns this node's current proposer VM height for the requested chain (C-Chain, P-Chain, X-Chain). * * - Docs: https://build.avax.network/docs/api-reference/proposervm-api#proposervmgetproposedheight * - * @returns This node's current proposer VM height. {@link GetProposedHeightReturnType} + * @returns This node's current proposer VM height for the requested chain. {@link GetProposedHeightReturnType} * * @example * ```ts @@ -25,17 +25,19 @@ export type ProposervmAPIActions = { * }, * }) * - * const height = await client.proposervm.getProposedHeight() + * const cChainHeight = await client.proposervm.cChain.getProposedHeight() + * const pChainHeight = await client.proposervm.pChain.getProposedHeight() + * const xChainHeight = await client.proposervm.xChain.getProposedHeight() * ``` */ getProposedHeight: () => Promise; /** - * Returns the current epoch information. + * Returns the current epoch information for the requested chain (C-Chain, P-Chain, X-Chain). * * - Docs: https://build.avax.network/docs/api-reference/proposervm-api#proposervmgetcurrentepoch * - * @returns The current epoch information. {@link GetCurrentEpochReturnType} + * @returns The current epoch information for the requested chain. {@link GetCurrentEpochReturnType} * * @example * ```ts @@ -49,7 +51,9 @@ export type ProposervmAPIActions = { * }, * }) * - * const epoch = await client.proposervm.getCurrentEpoch() + * const cChainEpoch = await client.proposervm.cChain.getCurrentEpoch() + * const pChainEpoch = await client.proposervm.pChain.getCurrentEpoch() + * const xChainEpoch = await client.proposervm.xChain.getCurrentEpoch() * ``` */ getCurrentEpoch: () => Promise; diff --git a/client/src/methods/pChain/getAllValidatorsAt.ts b/client/src/methods/pChain/getAllValidatorsAt.ts index 0fb6a40d..6cb5f2e5 100644 --- a/client/src/methods/pChain/getAllValidatorsAt.ts +++ b/client/src/methods/pChain/getAllValidatorsAt.ts @@ -12,6 +12,9 @@ import { /** * Get all validators at a specific height across all Subnets and the Primary Network. * + * Note: The public API (api.avax.network) only support height within 1000 blocks + * from the P-Chain tip. + * * - Docs: https://build.avax.network/docs/api-reference/p-chain/api#platformgetallvalidatorsat * * @param client - The client to use. {@link AvalancheCoreClient} From 816554a014b732bdb952ef23e4f8d647d85fecf2 Mon Sep 17 00:00:00 2001 From: Sayan kar Date: Mon, 3 Nov 2025 21:22:56 +0530 Subject: [PATCH 08/10] chore: modify dev docs in pChain getAllValidatorsAt decorator to add note --- client/src/clients/decorators/pChain.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/src/clients/decorators/pChain.ts b/client/src/clients/decorators/pChain.ts index ab94b977..93e6a217 100644 --- a/client/src/clients/decorators/pChain.ts +++ b/client/src/clients/decorators/pChain.ts @@ -785,6 +785,9 @@ export type PChainActions = { /** * Get all validators at a specific height across all Subnets and the Primary Network. * + * Note: The public API (api.avax.network) only support height within 1000 blocks + * from the P-Chain tip. + * * - Docs: https://build.avax.network/docs/api-reference/p-chain/api#platformgetallvalidatorsat * * @param args - {@link GetAllValidatorsAtParameters} The height From 9ddaee51adee968f1c51ea7890b019effd0ca066 Mon Sep 17 00:00:00 2001 From: Sayan kar Date: Tue, 4 Nov 2025 03:11:03 +0530 Subject: [PATCH 09/10] chore: fix typos, add avalanche provider and expose public methods to wallet client --- client/README.md | 2 +- client/TYPEDOC.md | 2 +- client/src/accounts/index.ts | 2 +- ...ount.ts => mnemonicsToAvalancheAccount.ts} | 12 +-- client/src/clients/createAvalancheClient.ts | 34 +++---- .../clients/createAvalancheWalletClient.ts | 95 ++++++++++++------- client/src/window/index.ts | 9 +- 7 files changed, 93 insertions(+), 63 deletions(-) rename client/src/accounts/{memonicsToAvalancheAccount.ts => mnemonicsToAvalancheAccount.ts} (67%) diff --git a/client/README.md b/client/README.md index 1265899d..3c907ea8 100644 --- a/client/README.md +++ b/client/README.md @@ -400,7 +400,7 @@ import { ```typescript import { privateKeyToAvalancheAccount, - memonicsToAvalancheAccount, + mnemonicsToAvalancheAccount, hdKeyToAvalancheAccount, privateKeyToXPAddress, publicKeyToXPAddress, diff --git a/client/TYPEDOC.md b/client/TYPEDOC.md index f13d33d9..cd2f1445 100644 --- a/client/TYPEDOC.md +++ b/client/TYPEDOC.md @@ -386,7 +386,7 @@ import { ```typescript import { privateKeyToAvalancheAccount, - memonicsToAvalancheAccount, + mnemonicsToAvalancheAccount, hdKeyToAvalancheAccount, privateKeyToXPAddress, publicKeyToXPAddress, diff --git a/client/src/accounts/index.ts b/client/src/accounts/index.ts index 5ac3ff50..c0eb6d7e 100644 --- a/client/src/accounts/index.ts +++ b/client/src/accounts/index.ts @@ -87,7 +87,7 @@ export type { export { privateKeyToAvalancheAccount } from "./privateKeyToAvalancheAccount.js"; -export { memonicsToAvalancheAccount } from "./memonicsToAvalancheAccount.js"; +export { mnemonicsToAvalancheAccount } from "./mnemonicsToAvalancheAccount.js"; export { privateKeyToXPAddress } from "./utils/privateKeyToXPAddress.js"; diff --git a/client/src/accounts/memonicsToAvalancheAccount.ts b/client/src/accounts/mnemonicsToAvalancheAccount.ts similarity index 67% rename from client/src/accounts/memonicsToAvalancheAccount.ts rename to client/src/accounts/mnemonicsToAvalancheAccount.ts index feac70f2..aa825a16 100644 --- a/client/src/accounts/memonicsToAvalancheAccount.ts +++ b/client/src/accounts/mnemonicsToAvalancheAccount.ts @@ -7,20 +7,20 @@ import { hdKeyToAvalancheAccount } from "./hdKeyToAvalancheAccount.js"; /** * Converts a mnemonic to an Avalanche account. * - * @param memonics - The mnemonic to convert. + * @param mnemonics - The mnemonic to convert. * @param options - The options for the account. {@link MnemonicToAccountOptions} * @returns The Avalanche account {@link AvalancheAccount}. * * @example * ```ts - * import { memonicsToAvalancheAccount } from "@avalanche-sdk/client/accounts"; + * import { mnemonicsToAvalancheAccount } from "@avalanche-sdk/client/accounts"; * - * const account = memonicsToAvalancheAccount("test test t.."); + * const account = mnemonicsToAvalancheAccount("test test t.."); */ -export function memonicsToAvalancheAccount( - memonics: string, +export function mnemonicsToAvalancheAccount( + mnemonics: string, options: MnemonicToAccountOptions = {} ): AvalancheAccount { - const seed = mnemonicToSeedSync(memonics); + const seed = mnemonicToSeedSync(mnemonics); return hdKeyToAvalancheAccount(HDKey.fromMasterSeed(seed), options); } diff --git a/client/src/clients/createAvalancheClient.ts b/client/src/clients/createAvalancheClient.ts index d80f21ee..cece0210 100644 --- a/client/src/clients/createAvalancheClient.ts +++ b/client/src/clients/createAvalancheClient.ts @@ -17,15 +17,7 @@ import { createInfoApiClient } from "./createInfoApiClient.js"; import { createPChainClient } from "./createPChainClient.js"; import { createProposervmApiClient } from "./createProposervmApiClient.js"; import { createXChainClient } from "./createXChainClient.js"; -import { adminAPIActions } from "./decorators/adminApi.js"; import { avalanchePublicActions } from "./decorators/avalanchePublic.js"; -import { cChainActions } from "./decorators/cChain.js"; -import { healthAPIActions } from "./decorators/healthApi.js"; -import { indexAPIActions } from "./decorators/indexApi.js"; -import { infoAPIActions } from "./decorators/infoApi.js"; -import { pChainActions } from "./decorators/pChain.js"; -import { proposervmAPIActions } from "./decorators/proposervmApi.js"; -import { xChainActions } from "./decorators/xChain.js"; import { AvalancheClient, AvalancheClientConfig, @@ -144,37 +136,37 @@ export function createAvalancheClient< ...parameters, key: "pChain", name: "P-Chain Client", - }).extend(pChainActions) as any, + }), cChain: createCChainClient({ ...parameters, key: "cChain", name: "C-Chain Client", - }).extend(cChainActions) as any, + }), xChain: createXChainClient({ ...parameters, key: "xChain", name: "X-Chain Client", - }).extend(xChainActions) as any, + }), admin: createAdminApiClient({ ...parameters, key: "admin", name: "Admin Client", - }).extend(adminAPIActions) as any, + }), info: createInfoApiClient({ ...parameters, key: "info", name: "Info Client", - }).extend(infoAPIActions) as any, + }), health: createHealthApiClient({ ...parameters, key: "health", name: "Health Client", - }).extend(healthAPIActions), + }), proposervm: { cChain: createProposervmApiClient({ @@ -182,21 +174,21 @@ export function createAvalancheClient< key: "proposervm", name: "proposervm Client", clientType: "proposervmCChain", - }).extend(proposervmAPIActions) as any, + }), pChain: createProposervmApiClient({ ...parameters, key: "proposervm", name: "proposervm Client", clientType: "proposervmPChain", - }).extend(proposervmAPIActions) as any, + }), xChain: createProposervmApiClient({ ...parameters, key: "proposervm", name: "proposervm Client", clientType: "proposervmXChain", - }).extend(proposervmAPIActions) as any, + }), } as any, indexBlock: { @@ -205,21 +197,21 @@ export function createAvalancheClient< key: "indexPChainBlock", name: "Index P-Chain Block Client", clientType: "indexPChainBlock", - }).extend(indexAPIActions) as any, + }), cChain: createIndexApiClient({ ...parameters, key: "indexCChainBlock", name: "Index C-Chain Block Client", clientType: "indexCChainBlock", - }).extend(indexAPIActions) as any, + }), xChain: createIndexApiClient({ ...parameters, key: "indexXChainBlock", name: "Index X-Chain Block Client", clientType: "indexXChainBlock", - }).extend(indexAPIActions) as any, + }), } as any, indexTx: { @@ -228,7 +220,7 @@ export function createAvalancheClient< key: "indexXChainTx", name: "Index X-Chain Tx Client", clientType: "indexXChainTx", - }).extend(indexAPIActions) as any, + }), } as any, } as any; } diff --git a/client/src/clients/createAvalancheWalletClient.ts b/client/src/clients/createAvalancheWalletClient.ts index 972e48f5..657fe14f 100644 --- a/client/src/clients/createAvalancheWalletClient.ts +++ b/client/src/clients/createAvalancheWalletClient.ts @@ -1,9 +1,15 @@ +import { CChainRpcSchema } from "src/methods/cChain/cChainRpcSchema.js"; +import { PChainRpcSchema } from "src/methods/pChain/pChainRpcSchema.js"; +import { XChainRpcSchema } from "src/methods/xChain/xChainRpcSchema.js"; import { Account, Chain, Client, CreatePublicClientErrorType, Prettify, + PublicActions, + publicActions, + PublicRpcSchema, rpcSchema, RpcSchema, Transport, @@ -12,6 +18,7 @@ import { WalletRpcSchema, } from "viem"; import { XPAccount } from "../accounts/avalancheAccount.js"; +import { AvalanchePublicRpcSchema } from "../methods/public/avalanchePublicRpcSchema.js"; import { AvalancheWalletRpcSchema } from "../methods/wallet/avalancheWalletRPCSchema.js"; import { AvalancheCoreClient } from "./createAvalancheCoreClient.js"; import { @@ -19,19 +26,25 @@ import { AvalancheWalletCoreClientConfig, createAvalancheWalletCoreClient, } from "./createAvalancheWalletCoreClient.js"; +import { + AvalanchePublicActions, + avalanchePublicActions, +} from "./decorators/avalanchePublic.js"; import { avalancheWalletActions, AvalancheWalletActions, } from "./decorators/avalancheWallet.js"; +import { CChainActions, cChainActions } from "./decorators/cChain.js"; import { cChainWalletActions, CChainWalletActions, } from "./decorators/cChainWallet.js"; -import { Erc20Actions, erc20Actions } from "./decorators/erc20.js"; +import { PChainActions, pChainActions } from "./decorators/pChain.js"; import { pChainWalletActions, PChainWalletActions, } from "./decorators/pChainWallet.js"; +import { XChainActions, xChainActions } from "./decorators/xChain.js"; import { xChainWalletActions, XChainWalletActions, @@ -58,42 +71,55 @@ export type AvalancheWalletClient< chain, account, rpcSchema extends RpcSchema - ? [...WalletRpcSchema, ...AvalancheWalletRpcSchema, ...rpcSchema] - : [...WalletRpcSchema, ...AvalancheWalletRpcSchema], - WalletActions & AvalancheWalletActions + ? [ + ...WalletRpcSchema, + ...AvalancheWalletRpcSchema, + ...PublicRpcSchema, + ...AvalanchePublicRpcSchema, + ...rpcSchema + ] + : [ + ...WalletRpcSchema, + ...AvalancheWalletRpcSchema, + ...PublicRpcSchema, + ...AvalanchePublicRpcSchema + ], + WalletActions & + AvalancheWalletActions & + AvalanchePublicActions & + PublicActions > & { xpAccount?: XPAccount; pChainClient: AvalancheCoreClient; cChainClient: AvalancheCoreClient; xChainClient: AvalancheCoreClient; } & { - erc20: AvalancheWalletCoreClient< - transport, - chain, - account, - rpcSchema, - Erc20Actions - >; cChain: AvalancheWalletCoreClient< transport, chain, account, - rpcSchema, - CChainWalletActions + rpcSchema extends RpcSchema + ? [...CChainRpcSchema, ...rpcSchema] + : [...CChainRpcSchema], + CChainWalletActions & CChainActions >; pChain: AvalancheWalletCoreClient< transport, chain, account, - rpcSchema, - PChainWalletActions + rpcSchema extends RpcSchema + ? [...PChainRpcSchema, ...rpcSchema] + : [...PChainRpcSchema], + PChainWalletActions & PChainActions >; xChain: AvalancheWalletCoreClient< transport, chain, account, - rpcSchema, - XChainWalletActions + rpcSchema extends RpcSchema + ? [...XChainRpcSchema, ...rpcSchema] + : [...XChainRpcSchema], + XChainWalletActions & XChainActions >; } >; @@ -141,27 +167,32 @@ export function createAvalancheWalletClient< rpcSchema: rpcSchema(), }); - const avalancheWalletClient = client - .extend(walletActions) - .extend(avalancheWalletActions as any); - - const erc20Client = client.extend(walletActions).extend(erc20Actions as any); + const avalancheWalletClient = ( + client.extend(walletActions).extend(avalancheWalletActions as any) as any + ) + .extend(publicActions as any) + .extend(avalanchePublicActions as any); - const cChainClient = client - .extend(walletActions) - .extend(cChainWalletActions as any); + const cChainClient = ( + client.extend(walletActions).extend(cChainWalletActions as any) as any + ).extend((client: AvalancheWalletCoreClient) => + cChainActions(client.cChainClient) + ); - const pChainClient = client - .extend(walletActions) - .extend(pChainWalletActions as any); + const pChainClient = ( + client.extend(walletActions).extend(pChainWalletActions as any) as any + ).extend((client: AvalancheWalletCoreClient) => + pChainActions(client.pChainClient) + ); - const xChainClient = client - .extend(walletActions) - .extend(xChainWalletActions as any); + const xChainClient = ( + client.extend(walletActions).extend(xChainWalletActions as any) as any + ).extend((client: AvalancheWalletCoreClient) => + xChainActions(client.xChainClient) + ); return { ...(avalancheWalletClient as any), - erc20: erc20Client, cChain: cChainClient, pChain: pChainClient, xChain: xChainClient, diff --git a/client/src/window/index.ts b/client/src/window/index.ts index cba58c92..f472ce69 100644 --- a/client/src/window/index.ts +++ b/client/src/window/index.ts @@ -1 +1,8 @@ -export * from "viem/window"; +import type { EIP1193Provider } from "viem"; + +declare global { + interface Window { + ethereum?: EIP1193Provider | undefined; + avalanche?: EIP1193Provider | undefined; + } +} From 30f0aed0241cc1bf545634f0d9b12eb801802e63 Mon Sep 17 00:00:00 2001 From: Sayan kar Date: Wed, 5 Nov 2025 02:43:06 +0530 Subject: [PATCH 10/10] chore: modify avalanche specific methods to take nano avax as amount --- client/examples/package-lock.json | 826 +--------- .../c-chain/exportTx.ts | 4 +- .../p-chain/baseTx.ts | 3 +- .../p-chain/convertSubnetToL1Tx.ts | 4 +- .../p-chain/exportTx.ts | 4 +- .../transfer-avax-from-c-chain-to-p-chain.ts | 4 +- .../transfer-avax-from-c-chain-to-x-chain.ts | 3 +- .../transfer-avax-from-p-chain-to-c-chain.ts | 3 +- .../transfer-avax-from-p-chain-to-x-chain.ts | 3 +- .../transfer-avax-from-x-chain-to-c-chain.ts | 3 +- .../transfer-avax-from-x-chain-to-p-chain.ts | 3 +- .../x-chain/exportTx.ts | 3 +- .../package-lock.json | 1339 ++++++++++++++++- .../package.json | 7 +- .../src/components/TransferCard.tsx | 7 +- .../vite.config.ts | 52 +- client/examples/sendAvax.ts | 9 +- client/package-lock.json | 8 +- client/package.json | 2 +- .../src/clients/decorators/avalancheWallet.ts | 31 +- client/src/clients/decorators/cChainWallet.ts | 3 +- client/src/clients/decorators/pChainWallet.ts | 24 +- client/src/clients/decorators/xChainWallet.ts | 64 + .../wallet/cChain/prepareExportTxn.test.ts | 17 +- .../methods/wallet/cChain/prepareExportTxn.ts | 11 +- .../wallet/cChain/types/prepareExportTxn.ts | 6 +- .../wallet/fixtures/transactions/cChain.ts | 8 +- .../wallet/fixtures/transactions/pChain.ts | 8 +- .../wallet/fixtures/transactions/xChain.ts | 8 +- client/src/methods/wallet/fixtures/utils.ts | 2 +- ...epareAddPermissionlessDelegatorTxn.test.ts | 26 +- .../prepareAddPermissionlessDelegatorTxn.ts | 11 +- ...epareAddPermissionlessValidatorTxn.test.ts | 22 +- .../prepareAddPermissionlessValidatorTxn.ts | 9 +- .../prepareAddSubnetValidatorTxn.test.ts | 8 +- .../wallet/pChain/prepareBaseTxn.test.ts | 36 +- .../methods/wallet/pChain/prepareBaseTxn.ts | 3 +- .../prepareConvertSubnetToL1Txn.test.ts | 23 +- .../pChain/prepareConvertSubnetToL1Txn.ts | 11 +- .../pChain/prepareCreateChainTxn.test.ts | 8 +- .../pChain/prepareCreateSubnetTxn.test.ts | 8 +- .../prepareDisableL1ValidatorTxn.test.ts | 8 +- .../wallet/pChain/prepareExportTxn.test.ts | 18 +- .../methods/wallet/pChain/prepareExportTxn.ts | 3 +- .../wallet/pChain/prepareImportTxn.test.ts | 15 +- ...epareIncreaseL1ValidatorBalanceTxn.test.ts | 14 +- .../prepareIncreaseL1ValidatorBalanceTxn.ts | 7 +- .../prepareRegisterL1ValidatorTxn.test.ts | 20 +- .../pChain/prepareRegisterL1ValidatorTxn.ts | 7 +- .../prepareRemoveSubnetValidatorTxn.test.ts | 8 +- .../prepareSetL1ValidatorWeightTxn.test.ts | 8 +- .../prepareAddPermissionlessDelegatorTxn.ts | 6 +- .../prepareAddPermissionlessValidatorTxn.ts | 6 +- .../types/prepareConvertSubnetToL1Txn.ts | 4 +- .../wallet/pChain/types/prepareImportTxn.ts | 2 +- .../prepareIncreaseL1ValidatorBalanceTxn.ts | 4 +- .../types/prepareRegisterL1ValidatorTxn.ts | 4 +- .../wallet/transferUtils/transferCtoCChain.ts | 39 +- .../wallet/transferUtils/transferCtoPChain.ts | 78 +- .../wallet/transferUtils/transferPtoCChain.ts | 46 +- .../wallet/transferUtils/transferPtoPChain.ts | 48 +- client/src/methods/wallet/types/common.ts | 6 +- client/src/methods/wallet/types/send.ts | 4 +- client/src/methods/wallet/utils.ts | 29 +- .../wallet/xChain/prepareBaseTxn.test.ts | 36 +- .../methods/wallet/xChain/prepareBaseTxn.ts | 3 +- .../wallet/xChain/prepareExportTxn.test.ts | 18 +- .../methods/wallet/xChain/prepareExportTxn.ts | 3 +- .../wallet/xChain/prepareImportTxn.test.ts | 11 +- .../methods/wallet/xChain/prepareImportTxn.ts | 3 +- .../wallet/xChain/types/prepareImportTxn.ts | 2 +- client/src/utils/index.ts | 11 +- client/src/window/index.ts | 1 - 73 files changed, 1867 insertions(+), 1239 deletions(-) diff --git a/client/examples/package-lock.json b/client/examples/package-lock.json index b634419e..dc953293 100644 --- a/client/examples/package-lock.json +++ b/client/examples/package-lock.json @@ -9,7 +9,6 @@ "version": "1.0.0", "license": "BSD-3-Clause", "dependencies": { - "@avalanche-sdk/client": "^0.0.4-alpha.16", "dotenv": "^16.3.1" }, "devDependencies": { @@ -18,44 +17,6 @@ "typescript": "^5.0.0" } }, - "node_modules/@adraffy/ens-normalize": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.11.1.tgz", - "integrity": "sha512-nhCBV3quEgesuf7c7KYfperqSS14T8bYuvJ8PcLJp6znkZpFc0AuW4qBtr8eKVyPPe/8RSr7sglCWPU5eaxwKQ==", - "license": "MIT" - }, - "node_modules/@avalabs/avalanchejs": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@avalabs/avalanchejs/-/avalanchejs-5.0.0.tgz", - "integrity": "sha512-0hJK/Hdf8v+q05c8+5K6arFmzq7o1W4I05/Dmr+Es1XRi8canvTu1Y0RruYd6ea2rrvX3UhKrPs3BzLhCTHDrw==", - "dependencies": { - "@noble/curves": "1.3.0", - "@noble/hashes": "1.3.3", - "@noble/secp256k1": "2.0.0", - "@scure/base": "1.1.5", - "micro-eth-signer": "0.7.2" - }, - "engines": { - "node": ">=20" - } - }, - "node_modules/@avalanche-sdk/client": { - "version": "0.0.4-alpha.16", - "resolved": "https://registry.npmjs.org/@avalanche-sdk/client/-/client-0.0.4-alpha.16.tgz", - "integrity": "sha512-rpOwBURNaV62rZSyacuQfPhTsuHWhnNNcoqTWEBXrGqIkUXoIdG4YqGrjKVVvNk/c7uRC1NX7FbmpOv7fgibJw==", - "license": "BSD-3-Clause", - "dependencies": { - "@avalabs/avalanchejs": "^5.0.0", - "@noble/hashes": "1.3.3", - "@noble/secp256k1": "2.0.0", - "util": "^0.12.5", - "viem": "^2.33.3" - }, - "engines": { - "node": ">=20", - "npm": ">=10" - } - }, "node_modules/@esbuild/aix-ppc64": { "version": "0.25.9", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.9.tgz", @@ -498,159 +459,6 @@ "node": ">=18" } }, - "node_modules/@ethereumjs/rlp": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/@ethereumjs/rlp/-/rlp-5.0.0.tgz", - "integrity": "sha512-WuS1l7GJmB0n0HsXLozCoEFc9IwYgf3l0gCkKVYgR67puVF1O4OpEaN0hWmm1c+iHUHFCKt1hJrvy5toLg+6ag==", - "license": "MPL-2.0", - "bin": { - "rlp": "bin/rlp" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@noble/ciphers": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@noble/ciphers/-/ciphers-1.3.0.tgz", - "integrity": "sha512-2I0gnIVPtfnMw9ee9h1dJG7tp81+8Ob3OJb3Mv37rx5L40/b0i7djjCVvGOVqc9AEIQyvyu1i6ypKdFw8R8gQw==", - "license": "MIT", - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@noble/curves": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.3.0.tgz", - "integrity": "sha512-t01iSXPuN+Eqzb4eBX0S5oubSqXbK/xXa1Ne18Hj8f9pStxztHCE2gfboSp/dZRLSqfuLpRK2nDXDK+W9puocA==", - "license": "MIT", - "dependencies": { - "@noble/hashes": "1.3.3" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@noble/hashes": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.3.tgz", - "integrity": "sha512-V7/fPHgl+jsVPXqqeOzT8egNj2iBIVt+ECeMMG8TdcnTikP3oaBtUVqpT/gYCR68aEBJSF+XbYUxStjbFMqIIA==", - "license": "MIT", - "engines": { - "node": ">= 16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@noble/secp256k1": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-2.0.0.tgz", - "integrity": "sha512-rUGBd95e2a45rlmFTqQJYEFA4/gdIARFfuTuTqLglz0PZ6AKyzyXsEZZq7UZn8hZsvaBgpCzKKBJizT2cJERXw==", - "funding": [ - { - "type": "individual", - "url": "https://paulmillr.com/funding/" - } - ], - "license": "MIT" - }, - "node_modules/@scure/base": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.5.tgz", - "integrity": "sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==", - "license": "MIT", - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip32": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.7.0.tgz", - "integrity": "sha512-E4FFX/N3f4B80AKWp5dP6ow+flD1LQZo/w8UnLGYZO674jS6YnYeepycOOksv+vLPSpgN35wgKgy+ybfTb2SMw==", - "license": "MIT", - "dependencies": { - "@noble/curves": "~1.9.0", - "@noble/hashes": "~1.8.0", - "@scure/base": "~1.2.5" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip32/node_modules/@noble/curves": { - "version": "1.9.7", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz", - "integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==", - "license": "MIT", - "dependencies": { - "@noble/hashes": "1.8.0" - }, - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip32/node_modules/@noble/hashes": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", - "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", - "license": "MIT", - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip32/node_modules/@scure/base": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.2.6.tgz", - "integrity": "sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg==", - "license": "MIT", - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip39": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.6.0.tgz", - "integrity": "sha512-+lF0BbLiJNwVlev4eKelw1WWLaiKXw7sSl8T6FvBlWkdX+94aGJ4o8XjUdlyhTCjd8c+B3KT3JfS8P0bLRNU6A==", - "license": "MIT", - "dependencies": { - "@noble/hashes": "~1.8.0", - "@scure/base": "~1.2.5" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip39/node_modules/@noble/hashes": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", - "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", - "license": "MIT", - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@scure/bip39/node_modules/@scure/base": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.2.6.tgz", - "integrity": "sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg==", - "license": "MIT", - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/@types/node": { "version": "20.19.10", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.19.10.tgz", @@ -661,106 +469,6 @@ "undici-types": "~6.21.0" } }, - "node_modules/abitype": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/abitype/-/abitype-1.1.0.tgz", - "integrity": "sha512-6Vh4HcRxNMLA0puzPjM5GBgT4aAcFGKZzSgAXvuZ27shJP6NEpielTuqbBmZILR5/xd0PizkBGy5hReKz9jl5A==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/wevm" - }, - "peerDependencies": { - "typescript": ">=5.0.4", - "zod": "^3.22.0 || ^4.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - }, - "zod": { - "optional": true - } - } - }, - "node_modules/available-typed-arrays": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", - "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", - "license": "MIT", - "dependencies": { - "possible-typed-array-names": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/call-bind": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", - "integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.0", - "es-define-property": "^1.0.0", - "get-intrinsic": "^1.2.4", - "set-function-length": "^1.2.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/call-bind-apply-helpers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", - "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/call-bound": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", - "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "get-intrinsic": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/define-data-property": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", - "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", - "license": "MIT", - "dependencies": { - "es-define-property": "^1.0.0", - "es-errors": "^1.3.0", - "gopd": "^1.0.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/dotenv": { "version": "16.6.1", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", @@ -773,50 +481,6 @@ "url": "https://dotenvx.com" } }, - "node_modules/dunder-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", - "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.1", - "es-errors": "^1.3.0", - "gopd": "^1.2.0" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-define-property": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", - "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-errors": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", - "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-object-atoms": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", - "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/esbuild": { "version": "0.25.9", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.9.tgz", @@ -859,27 +523,6 @@ "@esbuild/win32-x64": "0.25.9" } }, - "node_modules/eventemitter3": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", - "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", - "license": "MIT" - }, - "node_modules/for-each": { - "version": "0.3.5", - "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", - "integrity": "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==", - "license": "MIT", - "dependencies": { - "is-callable": "^1.2.7" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/fsevents": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", @@ -895,61 +538,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/generator-function": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/generator-function/-/generator-function-2.0.1.tgz", - "integrity": "sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/get-intrinsic": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", - "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", - "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "es-define-property": "^1.0.1", - "es-errors": "^1.3.0", - "es-object-atoms": "^1.1.1", - "function-bind": "^1.1.2", - "get-proto": "^1.0.1", - "gopd": "^1.2.0", - "has-symbols": "^1.1.0", - "hasown": "^2.0.2", - "math-intrinsics": "^1.1.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", - "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", - "license": "MIT", - "dependencies": { - "dunder-proto": "^1.0.1", - "es-object-atoms": "^1.0.0" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/get-tsconfig": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.10.1.tgz", @@ -963,270 +551,6 @@ "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" } }, - "node_modules/gopd": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", - "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-property-descriptors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", - "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", - "license": "MIT", - "dependencies": { - "es-define-property": "^1.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-symbols": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", - "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/has-tostringtag": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", - "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", - "license": "MIT", - "dependencies": { - "has-symbols": "^1.0.3" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "license": "MIT", - "dependencies": { - "function-bind": "^1.1.2" - }, - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "license": "ISC" - }, - "node_modules/is-arguments": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.2.0.tgz", - "integrity": "sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.2", - "has-tostringtag": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-callable": { - "version": "1.2.7", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", - "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-generator-function": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.1.2.tgz", - "integrity": "sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.4", - "generator-function": "^2.0.0", - "get-proto": "^1.0.1", - "has-tostringtag": "^1.0.2", - "safe-regex-test": "^1.1.0" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-regex": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", - "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.2", - "gopd": "^1.2.0", - "has-tostringtag": "^1.0.2", - "hasown": "^2.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/is-typed-array": { - "version": "1.1.15", - "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.15.tgz", - "integrity": "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==", - "license": "MIT", - "dependencies": { - "which-typed-array": "^1.1.16" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/isows": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.7.tgz", - "integrity": "sha512-I1fSfDCZL5P0v33sVqeTDSpcstAg/N+wF5HS033mogOVIp4B+oHC7oOCsA3axAbBSGTJ8QubbNmnIRN/h8U7hg==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/wevm" - } - ], - "license": "MIT", - "peerDependencies": { - "ws": "*" - } - }, - "node_modules/math-intrinsics": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", - "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, - "node_modules/micro-eth-signer": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/micro-eth-signer/-/micro-eth-signer-0.7.2.tgz", - "integrity": "sha512-uFH23nqPNdg2KZ9ZdvLG4GO3bTAOWRhwGTsecY4Et2IdQOJ26x6inu8lJ9oyslnYL/0o1vnETCGhMimMvO0SqQ==", - "license": "MIT", - "dependencies": { - "@ethereumjs/rlp": "5.0.0", - "@noble/curves": "~1.3.0", - "@noble/hashes": "~1.3.3", - "@scure/base": "~1.1.5", - "micro-packed": "~0.5.1" - } - }, - "node_modules/micro-packed": { - "version": "0.5.3", - "resolved": "https://registry.npmjs.org/micro-packed/-/micro-packed-0.5.3.tgz", - "integrity": "sha512-zWRoH+qUb/ZMp9gVZhexvRGCENDM5HEQF4sflqpdilUHWK2/zKR7/MT8GBctnTwbhNJwy1iuk5q6+TYP7/twYA==", - "license": "MIT", - "dependencies": { - "@scure/base": "~1.1.5" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/ox": { - "version": "0.9.6", - "resolved": "https://registry.npmjs.org/ox/-/ox-0.9.6.tgz", - "integrity": "sha512-8SuCbHPvv2eZLYXrNmC0EC12rdzXQLdhnOMlHDW2wiCPLxBrOOJwX5L5E61by+UjTPOryqQiRSnjIKCI+GykKg==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/wevm" - } - ], - "license": "MIT", - "dependencies": { - "@adraffy/ens-normalize": "^1.11.0", - "@noble/ciphers": "^1.3.0", - "@noble/curves": "1.9.1", - "@noble/hashes": "^1.8.0", - "@scure/bip32": "^1.7.0", - "@scure/bip39": "^1.6.0", - "abitype": "^1.0.9", - "eventemitter3": "5.0.1" - }, - "peerDependencies": { - "typescript": ">=5.4.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/ox/node_modules/@noble/curves": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", - "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", - "license": "MIT", - "dependencies": { - "@noble/hashes": "1.8.0" - }, - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/ox/node_modules/@noble/hashes": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", - "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", - "license": "MIT", - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/possible-typed-array-names": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", - "integrity": "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } - }, "node_modules/resolve-pkg-maps": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", @@ -1237,40 +561,6 @@ "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" } }, - "node_modules/safe-regex-test": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.1.0.tgz", - "integrity": "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==", - "license": "MIT", - "dependencies": { - "call-bound": "^1.0.2", - "es-errors": "^1.3.0", - "is-regex": "^1.2.1" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/set-function-length": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", - "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", - "license": "MIT", - "dependencies": { - "define-data-property": "^1.1.4", - "es-errors": "^1.3.0", - "function-bind": "^1.1.2", - "get-intrinsic": "^1.2.4", - "gopd": "^1.0.1", - "has-property-descriptors": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - } - }, "node_modules/tsx": { "version": "4.20.4", "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.20.4.tgz", @@ -1295,9 +585,8 @@ "version": "5.9.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz", "integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==", - "devOptional": true, + "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -1312,119 +601,6 @@ "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", "dev": true, "license": "MIT" - }, - "node_modules/util": { - "version": "0.12.5", - "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", - "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", - "license": "MIT", - "dependencies": { - "inherits": "^2.0.3", - "is-arguments": "^1.0.4", - "is-generator-function": "^1.0.7", - "is-typed-array": "^1.1.3", - "which-typed-array": "^1.1.2" - } - }, - "node_modules/viem": { - "version": "2.38.3", - "resolved": "https://registry.npmjs.org/viem/-/viem-2.38.3.tgz", - "integrity": "sha512-By2TutLv07iNHHtWqHHzjGipevYsfGqT7KQbGEmqLco1qTJxKnvBbSviqiu6/v/9REV6Q/FpmIxf2Z7/l5AbcQ==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/wevm" - } - ], - "license": "MIT", - "dependencies": { - "@noble/curves": "1.9.1", - "@noble/hashes": "1.8.0", - "@scure/bip32": "1.7.0", - "@scure/bip39": "1.6.0", - "abitype": "1.1.0", - "isows": "1.0.7", - "ox": "0.9.6", - "ws": "8.18.3" - }, - "peerDependencies": { - "typescript": ">=5.0.4" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/viem/node_modules/@noble/curves": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.1.tgz", - "integrity": "sha512-k11yZxZg+t+gWvBbIswW0yoJlu8cHOC7dhunwOzoWH/mXGBiYyR4YY6hAEK/3EUs4UpB8la1RfdRpeGsFHkWsA==", - "license": "MIT", - "dependencies": { - "@noble/hashes": "1.8.0" - }, - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/viem/node_modules/@noble/hashes": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", - "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", - "license": "MIT", - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/which-typed-array": { - "version": "1.1.19", - "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.19.tgz", - "integrity": "sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw==", - "license": "MIT", - "dependencies": { - "available-typed-arrays": "^1.0.7", - "call-bind": "^1.0.8", - "call-bound": "^1.0.4", - "for-each": "^0.3.5", - "get-proto": "^1.0.1", - "gopd": "^1.2.0", - "has-tostringtag": "^1.0.2" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/ws": { - "version": "8.18.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.3.tgz", - "integrity": "sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==", - "license": "MIT", - "peer": true, - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } } } } diff --git a/client/examples/prepare-primary-network-txns/c-chain/exportTx.ts b/client/examples/prepare-primary-network-txns/c-chain/exportTx.ts index e6421a18..eb1201d5 100644 --- a/client/examples/prepare-primary-network-txns/c-chain/exportTx.ts +++ b/client/examples/prepare-primary-network-txns/c-chain/exportTx.ts @@ -2,8 +2,8 @@ import { createAvalancheWalletClient } from "@avalanche-sdk/client"; import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; import { avalancheFuji } from "@avalanche-sdk/client/chains"; import { issueTx as issueCChainTx } from "@avalanche-sdk/client/methods/cChain"; +import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; import { loadConfig } from "../../config"; - async function run() { const { privateKeyAccount1 } = loadConfig(); const account = privateKeyToAvalancheAccount(privateKeyAccount1); @@ -22,7 +22,7 @@ async function run() { fromAddress: account.getEVMAddress(), // 0x76Dd3d7b2f635c2547B861e55aE8A374E587742D exportedOutput: { addresses: [account.getXPAddress("P", "fuji")], // P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz - amount: 0.0001, + amount: avaxToNanoAvax(0.0001), // 0.0001 AVAX = 100_000 nAVAX }, }); diff --git a/client/examples/prepare-primary-network-txns/p-chain/baseTx.ts b/client/examples/prepare-primary-network-txns/p-chain/baseTx.ts index 82731034..42e8c514 100644 --- a/client/examples/prepare-primary-network-txns/p-chain/baseTx.ts +++ b/client/examples/prepare-primary-network-txns/p-chain/baseTx.ts @@ -2,6 +2,7 @@ import { createAvalancheWalletClient } from "@avalanche-sdk/client"; import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; import { avalancheFuji } from "@avalanche-sdk/client/chains"; import { issueTx as issuePChainTx } from "@avalanche-sdk/client/methods/pChain"; +import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; import { loadConfig } from "../../config"; async function run() { @@ -21,7 +22,7 @@ async function run() { outputs: [ { addresses: [account.getXPAddress("P", "fuji")], // P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz - amount: 0.00001, + amount: avaxToNanoAvax(0.00001), // 0.00001 AVAX = 10_000 nAVAX }, ], }); diff --git a/client/examples/prepare-primary-network-txns/p-chain/convertSubnetToL1Tx.ts b/client/examples/prepare-primary-network-txns/p-chain/convertSubnetToL1Tx.ts index e7c0fc12..75f4060f 100644 --- a/client/examples/prepare-primary-network-txns/p-chain/convertSubnetToL1Tx.ts +++ b/client/examples/prepare-primary-network-txns/p-chain/convertSubnetToL1Tx.ts @@ -1,8 +1,8 @@ import { createAvalancheWalletClient } from "@avalanche-sdk/client"; import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; import { avalancheFuji } from "@avalanche-sdk/client/chains"; +import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; import { loadConfig } from "../../config"; - async function run() { // The account that will be used to sign the transaction const { privateKeyAccount1 } = loadConfig(); @@ -37,7 +37,7 @@ async function run() { "0x985b38c12afbe3ff90161f451bf2290cd6c03c3acd0a7346e346820ab4d27c200036cd9c7a828548eec5c6a5304339c400d1eb6f73e381479c4356df57938d4792f7fb9256a5817c16fb514bd27e8d9fc5c5a02470d721bb34064e90a19174df", }, weight: 100n, - initialBalanceInAvax: 0.1, + initialBalanceInAvax: avaxToNanoAvax(0.1), // 0.1 AVAX = 100_000_000 nAVAX remainingBalanceOwner: { addresses: [account.getXPAddress("P", "fuji")], threshold: 1, diff --git a/client/examples/prepare-primary-network-txns/p-chain/exportTx.ts b/client/examples/prepare-primary-network-txns/p-chain/exportTx.ts index 43bb1c9a..32f04ffe 100644 --- a/client/examples/prepare-primary-network-txns/p-chain/exportTx.ts +++ b/client/examples/prepare-primary-network-txns/p-chain/exportTx.ts @@ -2,8 +2,8 @@ import { createAvalancheWalletClient } from "@avalanche-sdk/client"; import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; import { avalancheFuji } from "@avalanche-sdk/client/chains"; import { issueTx as issuePChainTx } from "@avalanche-sdk/client/methods/pChain"; +import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; import { loadConfig } from "../../config"; - async function run() { const { privateKeyAccount1 } = loadConfig(); const account = privateKeyToAvalancheAccount(privateKeyAccount1); @@ -21,7 +21,7 @@ async function run() { exportedOutputs: [ { addresses: [account.getXPAddress("P", "fuji")], // P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz - amount: 0.00001, + amount: avaxToNanoAvax(0.00001), // 0.00001 AVAX = 10_000 nAVAX }, ], destinationChain: "C", diff --git a/client/examples/prepare-primary-network-txns/transfer-avax-from-c-chain-to-p-chain.ts b/client/examples/prepare-primary-network-txns/transfer-avax-from-c-chain-to-p-chain.ts index 98655731..8dd88228 100644 --- a/client/examples/prepare-primary-network-txns/transfer-avax-from-c-chain-to-p-chain.ts +++ b/client/examples/prepare-primary-network-txns/transfer-avax-from-c-chain-to-p-chain.ts @@ -1,8 +1,8 @@ import { createAvalancheWalletClient } from "@avalanche-sdk/client"; import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; import { avalancheFuji } from "@avalanche-sdk/client/chains"; +import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; import { loadConfig } from "../config"; - async function run() { const { privateKeyAccount1 } = loadConfig(); // This is the private key of the account that will be used to export the avax from the C-chain to the P-chain @@ -24,7 +24,7 @@ async function run() { fromAddress: account.getEVMAddress(), // 0x76Dd3d7b2f635c2547B861e55aE8A374E587742D exportedOutput: { addresses: [account.getXPAddress("P", "fuji")], // P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz - amount: 0.0001, + amount: avaxToNanoAvax(0.0001), // 0.0001 AVAX = 100_000 nAVAX }, }); diff --git a/client/examples/prepare-primary-network-txns/transfer-avax-from-c-chain-to-x-chain.ts b/client/examples/prepare-primary-network-txns/transfer-avax-from-c-chain-to-x-chain.ts index 9d4601dd..aaca26a4 100644 --- a/client/examples/prepare-primary-network-txns/transfer-avax-from-c-chain-to-x-chain.ts +++ b/client/examples/prepare-primary-network-txns/transfer-avax-from-c-chain-to-x-chain.ts @@ -1,6 +1,7 @@ import { createAvalancheWalletClient } from "@avalanche-sdk/client"; import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; import { avalancheFuji } from "@avalanche-sdk/client/chains"; +import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; import { loadConfig } from "../config"; async function run() { @@ -23,7 +24,7 @@ async function run() { fromAddress: account.getEVMAddress(), // 0x76Dd3d7b2f635c2547B861e55aE8A374E587742D exportedOutput: { addresses: [account.getXPAddress("X", "fuji")], // X-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz - amount: 0.0011, + amount: avaxToNanoAvax(0.0011), // 0.0011 AVAX = 1_100_000 nAVAX }, }); diff --git a/client/examples/prepare-primary-network-txns/transfer-avax-from-p-chain-to-c-chain.ts b/client/examples/prepare-primary-network-txns/transfer-avax-from-p-chain-to-c-chain.ts index e326f894..ef38c491 100644 --- a/client/examples/prepare-primary-network-txns/transfer-avax-from-p-chain-to-c-chain.ts +++ b/client/examples/prepare-primary-network-txns/transfer-avax-from-p-chain-to-c-chain.ts @@ -1,6 +1,7 @@ import { createAvalancheWalletClient } from "@avalanche-sdk/client"; import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; import { avalancheFuji } from "@avalanche-sdk/client/chains"; +import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; import { loadConfig } from "../config"; async function run() { @@ -24,7 +25,7 @@ async function run() { exportedOutputs: [ { addresses: [account.getXPAddress("P", "fuji")], // P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz - amount: 0.0001, + amount: avaxToNanoAvax(0.0001), // 0.0001 AVAX = 100_000 nAVAX }, ], destinationChain: "C", diff --git a/client/examples/prepare-primary-network-txns/transfer-avax-from-p-chain-to-x-chain.ts b/client/examples/prepare-primary-network-txns/transfer-avax-from-p-chain-to-x-chain.ts index 90086a7c..1ced66e7 100644 --- a/client/examples/prepare-primary-network-txns/transfer-avax-from-p-chain-to-x-chain.ts +++ b/client/examples/prepare-primary-network-txns/transfer-avax-from-p-chain-to-x-chain.ts @@ -1,6 +1,7 @@ import { createAvalancheWalletClient } from "@avalanche-sdk/client"; import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; import { avalancheFuji } from "@avalanche-sdk/client/chains"; +import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; import { loadConfig } from "../config"; async function run() { @@ -24,7 +25,7 @@ async function run() { exportedOutputs: [ { addresses: [account.getXPAddress("P", "fuji")], // P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz - amount: 0.0111, + amount: avaxToNanoAvax(0.0111), // 0.0111 AVAX = 11_100_000 nAVAX }, ], destinationChain: "X", diff --git a/client/examples/prepare-primary-network-txns/transfer-avax-from-x-chain-to-c-chain.ts b/client/examples/prepare-primary-network-txns/transfer-avax-from-x-chain-to-c-chain.ts index 5f2b60bb..2e71fc87 100644 --- a/client/examples/prepare-primary-network-txns/transfer-avax-from-x-chain-to-c-chain.ts +++ b/client/examples/prepare-primary-network-txns/transfer-avax-from-x-chain-to-c-chain.ts @@ -1,6 +1,7 @@ import { createAvalancheWalletClient } from "@avalanche-sdk/client"; import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; import { avalancheFuji } from "@avalanche-sdk/client/chains"; +import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; import { loadConfig } from "../config"; async function run() { @@ -24,7 +25,7 @@ async function run() { exportedOutputs: [ { addresses: [account.getXPAddress("X", "fuji")], // X-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz - amount: 0.0001, + amount: avaxToNanoAvax(0.0001), // 0.0001 AVAX = 100_000 nAVAX }, ], destinationChain: "C", diff --git a/client/examples/prepare-primary-network-txns/transfer-avax-from-x-chain-to-p-chain.ts b/client/examples/prepare-primary-network-txns/transfer-avax-from-x-chain-to-p-chain.ts index ace6393a..00e3179c 100644 --- a/client/examples/prepare-primary-network-txns/transfer-avax-from-x-chain-to-p-chain.ts +++ b/client/examples/prepare-primary-network-txns/transfer-avax-from-x-chain-to-p-chain.ts @@ -1,6 +1,7 @@ import { createAvalancheWalletClient } from "@avalanche-sdk/client"; import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; import { avalancheFuji } from "@avalanche-sdk/client/chains"; +import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; import { loadConfig } from "../config"; async function run() { @@ -24,7 +25,7 @@ async function run() { exportedOutputs: [ { addresses: [account.getXPAddress("X", "fuji")], // X-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz - amount: 0.001, + amount: avaxToNanoAvax(0.001), // 0.001 AVAX = 1_000_000 nAVAX }, ], destinationChain: "P", diff --git a/client/examples/prepare-primary-network-txns/x-chain/exportTx.ts b/client/examples/prepare-primary-network-txns/x-chain/exportTx.ts index 29b77236..579f9223 100644 --- a/client/examples/prepare-primary-network-txns/x-chain/exportTx.ts +++ b/client/examples/prepare-primary-network-txns/x-chain/exportTx.ts @@ -2,6 +2,7 @@ import { createAvalancheWalletClient } from "@avalanche-sdk/client"; import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; import { avalancheFuji } from "@avalanche-sdk/client/chains"; import { issueTx as issueXChainTx } from "@avalanche-sdk/client/methods/xChain"; +import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; import { loadConfig } from "../../config"; async function run() { @@ -21,7 +22,7 @@ async function run() { exportedOutputs: [ { addresses: [account.getXPAddress("X", "fuji")], // X-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz - amount: 0.00001, + amount: avaxToNanoAvax(0.00001), // 0.00001 AVAX = 10_000 nAVAX }, ], destinationChain: "C", diff --git a/client/examples/react-show-balance-and-cross-chain-transfers/package-lock.json b/client/examples/react-show-balance-and-cross-chain-transfers/package-lock.json index 50b4a9f2..6f3d0d0e 100644 --- a/client/examples/react-show-balance-and-cross-chain-transfers/package-lock.json +++ b/client/examples/react-show-balance-and-cross-chain-transfers/package-lock.json @@ -13,9 +13,13 @@ "@emotion/styled": "^11.13.0", "@mui/icons-material": "^6.5.0", "@mui/material": "^6.1.7", + "assert": "^2.1.0", + "buffer": "^6.0.3", + "crypto-browserify": "^3.12.1", "process": "^0.11.10", "react": "^18.2.0", "react-dom": "^18.2.0", + "stream-browserify": "^3.0.0", "util": "^0.12.5" }, "devDependencies": { @@ -23,7 +27,8 @@ "@types/react-dom": "^18.2.17", "@vitejs/plugin-react": "^4.2.1", "typescript": "^5.4.0", - "vite": "^7.1.11" + "vite": "^7.1.11", + "vite-plugin-node-polyfills": "^0.24.0" } }, "node_modules/@adraffy/ens-normalize": { @@ -989,9 +994,9 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.4.tgz", - "integrity": "sha512-VT2+G1VQs/9oz078bLrYbecdZKs912zQlkelYpuf+SXF+QvZDYJlbx/LSx+meSAwdDFnF8FVXW92AVjjkVmgFw==", + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", "license": "MIT" }, "node_modules/@jridgewell/trace-mapping": { @@ -1299,6 +1304,76 @@ "dev": true, "license": "MIT" }, + "node_modules/@rollup/plugin-inject": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@rollup/plugin-inject/-/plugin-inject-5.0.5.tgz", + "integrity": "sha512-2+DEJbNBoPROPkgTDNe8/1YXWcqxbN5DTjASVIOx8HS+pITXushyNiBV56RB08zuptzz8gT3YfkqriTBVycepg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "estree-walker": "^2.0.2", + "magic-string": "^0.30.3" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-inject/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@rollup/plugin-inject/node_modules/magic-string": { + "version": "0.30.21", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", + "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.5" + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.3.0.tgz", + "integrity": "sha512-5EdhGZtnu3V88ces7s53hhfK5KSASnJZv8Lulpc04cWO3REESroJXg73DFsOmgbU2BhwV0E20bu2IDZb3VKW4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.46.2", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.46.2.tgz", @@ -1808,6 +1883,36 @@ } } }, + "node_modules/asn1.js": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", + "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", + "license": "MIT", + "dependencies": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "node_modules/asn1.js/node_modules/bn.js": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.2.tgz", + "integrity": "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw==", + "license": "MIT" + }, + "node_modules/assert": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-2.1.0.tgz", + "integrity": "sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.2", + "is-nan": "^1.3.2", + "object-is": "^1.1.5", + "object.assign": "^4.1.4", + "util": "^0.12.5" + } + }, "node_modules/available-typed-arrays": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", @@ -1838,6 +1943,129 @@ "npm": ">=6" } }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/bn.js": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.2.tgz", + "integrity": "sha512-v2YAxEmKaBLahNwE1mjp4WON6huMNeuDvagFZW+ASCuA/ku0bXR9hSMw0XpiqMoA3+rmnyck/tPRSFQkoC9Cuw==", + "license": "MIT" + }, + "node_modules/brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==", + "license": "MIT" + }, + "node_modules/browser-resolve": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-2.0.0.tgz", + "integrity": "sha512-7sWsQlYL2rGLy2IWm8WL8DCTJvYLc/qlOnsakDac87SOoCd16WLsaAMdCiAqsTNHIe+SXfaqyxyo6THoWqs8WQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve": "^1.17.0" + } + }, + "node_modules/browserify-aes": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", + "license": "MIT", + "dependencies": { + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/browserify-cipher": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", + "license": "MIT", + "dependencies": { + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" + } + }, + "node_modules/browserify-des": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", + "license": "MIT", + "dependencies": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/browserify-rsa": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.1.tgz", + "integrity": "sha512-YBjSAiTqM04ZVei6sXighu679a3SqWORA3qZTEqZImnlkDIFtKc6pNutpjyZ8RJTjQtuYfeetkxM11GwoYXMIQ==", + "license": "MIT", + "dependencies": { + "bn.js": "^5.2.1", + "randombytes": "^2.1.0", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/browserify-sign": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.5.tgz", + "integrity": "sha512-C2AUdAJg6rlM2W5QMp2Q4KGQMVBwR1lIimTsUnutJ8bMpW5B52pGpR2gEnNBNwijumDo5FojQ0L9JrXA8m4YEw==", + "license": "ISC", + "dependencies": { + "bn.js": "^5.2.2", + "browserify-rsa": "^4.1.1", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "elliptic": "^6.6.1", + "inherits": "^2.0.4", + "parse-asn1": "^5.1.9", + "readable-stream": "^2.3.8", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/browserify-zlib": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "pako": "~1.0.5" + } + }, "node_modules/browserslist": { "version": "4.25.2", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.25.2.tgz", @@ -1872,6 +2100,43 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/buffer-xor": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", + "integrity": "sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==", + "license": "MIT" + }, + "node_modules/builtin-status-codes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", + "integrity": "sha512-HpGFw18DgFWlncDfjTa2rcQ4W88O1mC8e8yZ2AvQY5KDaktSTwo+KRf6nHK6FRI5FyRyb/5T6+TSxfP7QyGsmQ==", + "dev": true, + "license": "MIT" + }, "node_modules/call-bind": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", @@ -1949,6 +2214,20 @@ ], "license": "CC-BY-4.0" }, + "node_modules/cipher-base": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.7.tgz", + "integrity": "sha512-Mz9QMT5fJe7bKI7MH31UilT5cEK5EHHRCccw/YRFsRY47AuNgaV6HY3rscp0/I4Q+tTW/5zoqpSeRRI54TkDWA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.4", + "safe-buffer": "^5.2.1", + "to-buffer": "^1.2.2" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/clsx": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", @@ -1958,12 +2237,31 @@ "node": ">=6" } }, + "node_modules/console-browserify": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz", + "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==", + "dev": true + }, + "node_modules/constants-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", + "integrity": "sha512-xFxOwqIzR/e1k1gLiWEophSCMqXcwVHIH7akf7b/vxcUeGunlj3hvZaaqxwHsTgn+IndtkQJgSztIDWeumWJDQ==", + "dev": true, + "license": "MIT" + }, "node_modules/convert-source-map": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==", "license": "MIT" }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "license": "MIT" + }, "node_modules/cosmiconfig": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.1.0.tgz", @@ -1989,6 +2287,82 @@ "node": ">= 6" } }, + "node_modules/create-ecdh": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", + "integrity": "sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==", + "license": "MIT", + "dependencies": { + "bn.js": "^4.1.0", + "elliptic": "^6.5.3" + } + }, + "node_modules/create-ecdh/node_modules/bn.js": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.2.tgz", + "integrity": "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw==", + "license": "MIT" + }, + "node_modules/create-hash": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", + "license": "MIT", + "dependencies": { + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", + "sha.js": "^2.4.0" + } + }, + "node_modules/create-hmac": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", + "license": "MIT", + "dependencies": { + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, + "node_modules/create-require": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", + "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/crypto-browserify": { + "version": "3.12.1", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.1.tgz", + "integrity": "sha512-r4ESw/IlusD17lgQi1O20Fa3qNnsckR126TdUuBgAu7GBYSIPvdNyONd3Zrxh0xCwA4+6w/TDArBPsMvhur+KQ==", + "license": "MIT", + "dependencies": { + "browserify-cipher": "^1.0.1", + "browserify-sign": "^4.2.3", + "create-ecdh": "^4.0.4", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "diffie-hellman": "^5.0.3", + "hash-base": "~3.0.4", + "inherits": "^2.0.4", + "pbkdf2": "^3.1.2", + "public-encrypt": "^4.0.3", + "randombytes": "^2.1.0", + "randomfill": "^1.0.4" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/csstype": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", @@ -2029,6 +2403,50 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "license": "MIT", + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/des.js": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.1.0.tgz", + "integrity": "sha512-r17GxjhUCjSRy8aiJpr8/UadFIzMzJGexI3Nmz4ADi9LYSFx4gTBp80+NaX/YsXWWLhpZ7v/v/ubEc/bCNfKwg==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "node_modules/diffie-hellman": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", + "license": "MIT", + "dependencies": { + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" + } + }, + "node_modules/diffie-hellman/node_modules/bn.js": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.2.tgz", + "integrity": "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw==", + "license": "MIT" + }, "node_modules/dom-helpers": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz", @@ -2039,6 +2457,19 @@ "csstype": "^3.0.2" } }, + "node_modules/domain-browser": { + "version": "4.22.0", + "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-4.22.0.tgz", + "integrity": "sha512-IGBwjF7tNk3cwypFNH/7bfzBcgSCbaMOD3GsaY1AU/JRrnHnYgEM0+9kQt52iZxjNsjBtJYtao146V+f8jFZNw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://bevry.me/fund" + } + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", @@ -2060,6 +2491,27 @@ "dev": true, "license": "ISC" }, + "node_modules/elliptic": { + "version": "6.6.1", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.6.1.tgz", + "integrity": "sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g==", + "license": "MIT", + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/elliptic/node_modules/bn.js": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.2.tgz", + "integrity": "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw==", + "license": "MIT" + }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -2169,6 +2621,26 @@ "integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==", "license": "MIT" }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/evp_bytestokey": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", + "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", + "license": "MIT", + "dependencies": { + "md5.js": "^1.3.4", + "safe-buffer": "^5.1.1" + } + }, "node_modules/fdir": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", @@ -2193,6 +2665,23 @@ "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", "license": "MIT" }, + "node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/for-each": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", @@ -2330,6 +2819,29 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/hash-base": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.5.tgz", + "integrity": "sha512-vXm0l45VbcHEVlTCzs8M+s0VeYsB2lnlAaThoLKGXr3bE/VWDOelNUnycUPEhKEaXARL2TEFjBOyUiM6+55KBg==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.4", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", @@ -2342,6 +2854,17 @@ "node": ">= 0.4" } }, + "node_modules/hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg==", + "license": "MIT", + "dependencies": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, "node_modules/hoist-non-react-statics": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", @@ -2357,6 +2880,33 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", "license": "MIT" }, + "node_modules/https-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", + "integrity": "sha512-J+FkSdyD+0mA0N+81tMotaRMfSL9SGi+xpD3T6YApKsc3bGSXJlfXri3VyFOeYkfLRQisDk1W+jIFFKBeUBbBg==", + "dev": true, + "license": "MIT" + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "BSD-3-Clause" + }, "node_modules/import-fresh": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", @@ -2446,10 +2996,26 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-regex": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", - "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", + "node_modules/is-nan": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", + "integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-regex": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", + "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", "license": "MIT", "dependencies": { "call-bound": "^1.0.2", @@ -2479,6 +3045,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "license": "MIT" + }, + "node_modules/isomorphic-timers-promises": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/isomorphic-timers-promises/-/isomorphic-timers-promises-1.0.1.tgz", + "integrity": "sha512-u4sej9B1LPSxTGKB/HiuzvEQnXH0ECYkSVQU39koSwmFAxhlEAFl9RdTvLv4TOTQUgBS5O3O5fwUxk6byBZ+IQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, "node_modules/isows": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/isows/-/isows-1.0.7.tgz", @@ -2537,6 +3119,22 @@ "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", "license": "MIT" }, + "node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -2568,6 +3166,17 @@ "node": ">= 0.4" } }, + "node_modules/md5.js": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", + "license": "MIT", + "dependencies": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, "node_modules/micro-eth-signer": { "version": "0.7.2", "resolved": "https://registry.npmjs.org/micro-eth-signer/-/micro-eth-signer-0.7.2.tgz", @@ -2593,6 +3202,37 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/miller-rabin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", + "license": "MIT", + "dependencies": { + "bn.js": "^4.0.0", + "brorand": "^1.0.1" + }, + "bin": { + "miller-rabin": "bin/miller-rabin" + } + }, + "node_modules/miller-rabin/node_modules/bn.js": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.2.tgz", + "integrity": "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw==", + "license": "MIT" + }, + "node_modules/minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", + "license": "ISC" + }, + "node_modules/minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==", + "license": "MIT" + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -2625,6 +3265,85 @@ "dev": true, "license": "MIT" }, + "node_modules/node-stdlib-browser": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/node-stdlib-browser/-/node-stdlib-browser-1.3.1.tgz", + "integrity": "sha512-X75ZN8DCLftGM5iKwoYLA3rjnrAEs97MkzvSd4q2746Tgpg8b8XWiBGiBG4ZpgcAqBgtgPHTiAc8ZMCvZuikDw==", + "dev": true, + "license": "MIT", + "dependencies": { + "assert": "^2.0.0", + "browser-resolve": "^2.0.0", + "browserify-zlib": "^0.2.0", + "buffer": "^5.7.1", + "console-browserify": "^1.1.0", + "constants-browserify": "^1.0.0", + "create-require": "^1.1.1", + "crypto-browserify": "^3.12.1", + "domain-browser": "4.22.0", + "events": "^3.0.0", + "https-browserify": "^1.0.0", + "isomorphic-timers-promises": "^1.0.1", + "os-browserify": "^0.3.0", + "path-browserify": "^1.0.1", + "pkg-dir": "^5.0.0", + "process": "^0.11.10", + "punycode": "^1.4.1", + "querystring-es3": "^0.2.1", + "readable-stream": "^3.6.0", + "stream-browserify": "^3.0.0", + "stream-http": "^3.2.0", + "string_decoder": "^1.0.0", + "timers-browserify": "^2.0.4", + "tty-browserify": "0.0.1", + "url": "^0.11.4", + "util": "^0.12.4", + "vm-browserify": "^1.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/node-stdlib-browser/node_modules/buffer": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "node_modules/node-stdlib-browser/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -2634,6 +3353,71 @@ "node": ">=0.10.0" } }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-is": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.6.tgz", + "integrity": "sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.7.tgz", + "integrity": "sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==", + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0", + "has-symbols": "^1.1.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/os-browserify": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", + "integrity": "sha512-gjcpUc3clBf9+210TRaDWbf+rZZZEshZ+DlXMRCeAjp0xhTrnQsKHypIy1J3d5hKdUzj69t708EHtU8P6bUn0A==", + "dev": true, + "license": "MIT" + }, "node_modules/ox": { "version": "0.9.6", "resolved": "https://registry.npmjs.org/ox/-/ox-0.9.6.tgz", @@ -2691,6 +3475,45 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", + "dev": true, + "license": "(MIT AND Zlib)" + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -2703,6 +3526,22 @@ "node": ">=6" } }, + "node_modules/parse-asn1": { + "version": "5.1.9", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.9.tgz", + "integrity": "sha512-fIYNuZ/HastSb80baGOuPRo1O9cf4baWw5WsAp7dBuUzeTD/BoaG8sVTdlPFksBE2lF21dN+A1AnrpIjSWqHHg==", + "license": "ISC", + "dependencies": { + "asn1.js": "^4.10.1", + "browserify-aes": "^1.2.0", + "evp_bytestokey": "^1.0.3", + "pbkdf2": "^3.1.5", + "safe-buffer": "^5.2.1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", @@ -2721,6 +3560,23 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", + "dev": true, + "license": "MIT" + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", @@ -2736,6 +3592,23 @@ "node": ">=8" } }, + "node_modules/pbkdf2": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.5.tgz", + "integrity": "sha512-Q3CG/cYvCO1ye4QKkuH7EXxs3VC/rI1/trd+qX2+PolbaKG0H+bgcZzrTt96mMyRtejk+JMCiLUn3y29W8qmFQ==", + "license": "MIT", + "dependencies": { + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "ripemd160": "^2.0.3", + "safe-buffer": "^5.2.1", + "sha.js": "^2.4.12", + "to-buffer": "^1.2.1" + }, + "engines": { + "node": ">= 0.10" + } + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -2756,6 +3629,19 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pkg-dir": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-5.0.0.tgz", + "integrity": "sha512-NPE8TDbzl/3YQYY7CSS228s3g2ollTFnc+Qi3tqmqJp9Vg2ovUpixcJEo2HJScN2Ez+kEaal6y70c0ehqJBJeA==", + "dev": true, + "license": "MIT", + "dependencies": { + "find-up": "^5.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/possible-typed-array-names": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", @@ -2803,6 +3689,12 @@ "node": ">= 0.6.0" } }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "license": "MIT" + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -2820,6 +3712,77 @@ "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", "license": "MIT" }, + "node_modules/public-encrypt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", + "license": "MIT", + "dependencies": { + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/public-encrypt/node_modules/bn.js": { + "version": "4.12.2", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.2.tgz", + "integrity": "sha512-n4DSx829VRTRByMRGdjQ9iqsN0Bh4OolPsFnaZBLcbi8iXcB+kJ9s7EnRt4wILZNV3kPLHkRVfOc/HvhC3ovDw==", + "license": "MIT" + }, + "node_modules/punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/qs": { + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz", + "integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/querystring-es3": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", + "integrity": "sha512-773xhDQnZBMFobEiztv8LIl70ch5MSF/jUQVlhwFyBILqq96anmoctVIYz+ZRp0qbCKATTn6ev02M3r7Ga5vqA==", + "dev": true, + "engines": { + "node": ">=0.4.x" + } + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "license": "MIT", + "dependencies": { + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" + } + }, "node_modules/react": { "version": "18.3.1", "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", @@ -2879,6 +3842,27 @@ "react-dom": ">=16.6.0" } }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readable-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, "node_modules/resolve": { "version": "1.22.10", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", @@ -2908,6 +3892,34 @@ "node": ">=4" } }, + "node_modules/ripemd160": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.3.tgz", + "integrity": "sha512-5Di9UC0+8h1L6ZD2d7awM7E/T4uA1fJRlx6zk/NvdCCVEoAnFqvHmCuNeIKoCeIixBX/q8uM+6ycDvF8woqosA==", + "license": "MIT", + "dependencies": { + "hash-base": "^3.1.2", + "inherits": "^2.0.4" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/ripemd160/node_modules/hash-base": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.2.tgz", + "integrity": "sha512-Bb33KbowVTIj5s7Ked1OsqHUeCpz//tPwR+E2zJgJKo9Z5XolZ9b6bdUgjmYlwnWhoOQKoTd1TYToZGn5mAYOg==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.4", + "readable-stream": "^2.3.8", + "safe-buffer": "^5.2.1", + "to-buffer": "^1.2.1" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/rollup": { "version": "4.46.2", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.46.2.tgz", @@ -2948,6 +3960,26 @@ "fsevents": "~2.3.2" } }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/safe-regex-test": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.1.0.tgz", @@ -3001,6 +4033,109 @@ "node": ">= 0.4" } }, + "node_modules/setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", + "dev": true, + "license": "MIT" + }, + "node_modules/sha.js": { + "version": "2.4.12", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.12.tgz", + "integrity": "sha512-8LzC5+bvI45BjpfXU8V5fdU2mfeKiQe1D1gIMn7XUlF3OTUrpdJpPPH4EMAnF0DsHHdSZqCdSss5qCmJKuiO3w==", + "license": "(MIT AND BSD-3-Clause)", + "dependencies": { + "inherits": "^2.0.4", + "safe-buffer": "^5.2.1", + "to-buffer": "^1.2.0" + }, + "bin": { + "sha.js": "bin.js" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/source-map": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", @@ -3020,6 +4155,73 @@ "node": ">=0.10.0" } }, + "node_modules/stream-browserify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz", + "integrity": "sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA==", + "license": "MIT", + "dependencies": { + "inherits": "~2.0.4", + "readable-stream": "^3.5.0" + } + }, + "node_modules/stream-browserify/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/stream-http": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.2.0.tgz", + "integrity": "sha512-Oq1bLqisTyK3TSCXpPbT4sdeYNdmyZJv1LxpEm2vu1ZhK89kSE5YXwZc3cWk0MagGaKriBh9mCFbVGtO+vY29A==", + "dev": true, + "license": "MIT", + "dependencies": { + "builtin-status-codes": "^3.0.0", + "inherits": "^2.0.4", + "readable-stream": "^3.6.0", + "xtend": "^4.0.2" + } + }, + "node_modules/stream-http/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dev": true, + "license": "MIT", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/string_decoder/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, "node_modules/stylis": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.2.0.tgz", @@ -3038,6 +4240,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/timers-browserify": { + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.12.tgz", + "integrity": "sha512-9phl76Cqm6FhSX9Xe1ZUAMLtm1BLkKj2Qd5ApyWkXzsMRaA7dgr81kf4wJmQf/hAvg8EEyJxDo3du/0KlhPiKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "setimmediate": "^1.0.4" + }, + "engines": { + "node": ">=0.6.0" + } + }, "node_modules/tinyglobby": { "version": "0.2.15", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", @@ -3055,6 +4270,47 @@ "url": "https://github.com/sponsors/SuperchupuDev" } }, + "node_modules/to-buffer": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.2.2.tgz", + "integrity": "sha512-db0E3UJjcFhpDhAF4tLo03oli3pwl3dbnzXOUIlRKrp+ldk/VUxzpWYZENsw2SZiuBjHAk7DfB0VU7NKdpb6sw==", + "license": "MIT", + "dependencies": { + "isarray": "^2.0.5", + "safe-buffer": "^5.2.1", + "typed-array-buffer": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/to-buffer/node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", + "license": "MIT" + }, + "node_modules/tty-browserify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", + "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", + "dev": true, + "license": "MIT" + }, + "node_modules/typed-array-buffer": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz", + "integrity": "sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/typescript": { "version": "5.9.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz", @@ -3101,6 +4357,20 @@ "browserslist": ">= 4.21.0" } }, + "node_modules/url": { + "version": "0.11.4", + "resolved": "https://registry.npmjs.org/url/-/url-0.11.4.tgz", + "integrity": "sha512-oCwdVC7mTuWiPyjLUz/COz5TLk6wgp0RCsN+wHZ2Ekneac9w8uuV0njcbbie2ME+Vs+d6duwmYuR3HgQXs1fOg==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^1.4.1", + "qs": "^6.12.3" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/util": { "version": "0.12.5", "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", @@ -3114,6 +4384,12 @@ "which-typed-array": "^1.1.2" } }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" + }, "node_modules/viem": { "version": "2.38.3", "resolved": "https://registry.npmjs.org/viem/-/viem-2.38.3.tgz", @@ -3247,6 +4523,30 @@ } } }, + "node_modules/vite-plugin-node-polyfills": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/vite-plugin-node-polyfills/-/vite-plugin-node-polyfills-0.24.0.tgz", + "integrity": "sha512-GA9QKLH+vIM8NPaGA+o2t8PDfFUl32J8rUp1zQfMKVJQiNkOX4unE51tR6ppl6iKw5yOrDAdSH7r/UIFLCVhLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/plugin-inject": "^5.0.5", + "node-stdlib-browser": "^1.2.0" + }, + "funding": { + "url": "https://github.com/sponsors/davidmyersdev" + }, + "peerDependencies": { + "vite": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0" + } + }, + "node_modules/vm-browserify": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", + "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", + "dev": true, + "license": "MIT" + }, "node_modules/which-typed-array": { "version": "1.1.19", "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.19.tgz", @@ -3290,12 +4590,35 @@ } } }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.4" + } + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", "dev": true, "license": "ISC" + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } } } } diff --git a/client/examples/react-show-balance-and-cross-chain-transfers/package.json b/client/examples/react-show-balance-and-cross-chain-transfers/package.json index 4d18fd13..f9ffef37 100644 --- a/client/examples/react-show-balance-and-cross-chain-transfers/package.json +++ b/client/examples/react-show-balance-and-cross-chain-transfers/package.json @@ -14,9 +14,13 @@ "@emotion/styled": "^11.13.0", "@mui/icons-material": "^6.5.0", "@mui/material": "^6.1.7", + "assert": "^2.1.0", + "buffer": "^6.0.3", + "crypto-browserify": "^3.12.1", "process": "^0.11.10", "react": "^18.2.0", "react-dom": "^18.2.0", + "stream-browserify": "^3.0.0", "util": "^0.12.5" }, "devDependencies": { @@ -24,6 +28,7 @@ "@types/react-dom": "^18.2.17", "@vitejs/plugin-react": "^4.2.1", "typescript": "^5.4.0", - "vite": "^7.1.11" + "vite": "^7.1.11", + "vite-plugin-node-polyfills": "^0.24.0" } } diff --git a/client/examples/react-show-balance-and-cross-chain-transfers/src/components/TransferCard.tsx b/client/examples/react-show-balance-and-cross-chain-transfers/src/components/TransferCard.tsx index 541ba464..88956995 100644 --- a/client/examples/react-show-balance-and-cross-chain-transfers/src/components/TransferCard.tsx +++ b/client/examples/react-show-balance-and-cross-chain-transfers/src/components/TransferCard.tsx @@ -1,5 +1,6 @@ import { Address, createAvalancheWalletClient } from '@avalanche-sdk/client' import type { Chain } from '@avalanche-sdk/client/chains' +import { avaxToWei } from '@avalanche-sdk/client/utils' import { ArrowForward, CheckCircle, Error as ErrorIcon, Send } from '@mui/icons-material' import { Alert, Avatar, Box, Button, Card, CardContent, Chip, LinearProgress, Stack, TextField, Typography } from '@mui/material' import { useMemo, useState } from 'react' @@ -65,7 +66,7 @@ export function TransferCard({ // This requires specifying both source and destination chains const res = await client.send({ to: toAddress as Address, - amount: value, // AVAX amount (SDK utils handle conversion) + amount: avaxToWei(value), // AVAX amount (SDK utils handle conversion) sourceChain: "P", // Source: Platform Chain destinationChain: "C", // Destination: Contract Chain }) @@ -77,7 +78,7 @@ export function TransferCard({ // For C → P, we only need to specify the destination chain const res = await client.send({ to: toAddress, - amount: value, + amount: avaxToWei(value), destinationChain: "P", // Destination: Platform Chain }) @@ -301,4 +302,4 @@ export function TransferCard({ ) -} \ No newline at end of file +} diff --git a/client/examples/react-show-balance-and-cross-chain-transfers/vite.config.ts b/client/examples/react-show-balance-and-cross-chain-transfers/vite.config.ts index afdbcb1d..99b16c14 100644 --- a/client/examples/react-show-balance-and-cross-chain-transfers/vite.config.ts +++ b/client/examples/react-show-balance-and-cross-chain-transfers/vite.config.ts @@ -1,21 +1,65 @@ import react from "@vitejs/plugin-react"; import { defineConfig } from "vite"; +import { nodePolyfills } from "vite-plugin-node-polyfills"; export default defineConfig({ - plugins: [react()], + plugins: [ + react(), + nodePolyfills({ + // Specify which Node.js globals and modules to polyfill + globals: { + Buffer: true, + global: true, + process: true, + }, + // Include specific modules + include: [ + "util", + "crypto", + "stream", + "buffer", + "events", + "string_decoder", + ], + // Exclude optional native dependencies + exclude: [], + }), + // Plugin to stub optional native dependencies + { + name: "stub-optional-deps", + enforce: "pre", // Run before other plugins + resolveId(id) { + // Stub out optional native dependencies that don't work in browser + if (id === "bufferutil" || id === "utf-8-validate") { + return `\0${id}`; // Virtual module ID + } + return null; + }, + load(id) { + // Return empty module for optional dependencies + if (id === "\0bufferutil" || id === "\0utf-8-validate") { + return "export default {};"; + } + return null; + }, + }, + ], define: { - // Polyfill Node.js globals for browser environment global: "globalThis", "process.env": {}, + "process.browser": JSON.stringify(true), + "process.version": JSON.stringify("v16.0.0"), }, resolve: { alias: { - // Polyfill Node.js modules process: "process/browser", util: "util", + crypto: "crypto-browserify", + stream: "stream-browserify", }, }, optimizeDeps: { - include: ["process", "util"], + include: ["process", "util", "crypto-browserify", "stream-browserify"], + exclude: ["bufferutil", "utf-8-validate"], }, }); diff --git a/client/examples/sendAvax.ts b/client/examples/sendAvax.ts index a286cef5..fe821120 100644 --- a/client/examples/sendAvax.ts +++ b/client/examples/sendAvax.ts @@ -1,6 +1,7 @@ import { createAvalancheWalletClient } from "@avalanche-sdk/client"; import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; import { avalancheFuji } from "@avalanche-sdk/client/chains"; +import { avaxToWei } from "@avalanche-sdk/client/utils"; import { loadConfig } from "./config"; async function run() { @@ -27,7 +28,7 @@ async function run() { // be confirmed on C-chain const sendC2CResponse = await walletClient.send({ to: CChainReceiverAddress, - amount: 0.001, + amount: avaxToWei(0.001), }); console.log("sendC2CResponse", sendC2CResponse); @@ -36,7 +37,7 @@ async function run() { // the transaction to be confirmed on C-chain and P-chain const sendC2PResponse = await walletClient.send({ to: PChainReceiverAddress, - amount: 0.001, + amount: avaxToWei(0.001), destinationChain: "P", }); console.log("sendC2PResponse", sendC2PResponse); @@ -46,7 +47,7 @@ async function run() { // the transaction to be confirmed on C-chain and P-chain const sendP2CResponse = await walletClient.send({ to: CChainReceiverAddress, - amount: 0.001, + amount: avaxToWei(0.001), sourceChain: "P", destinationChain: "C", }); @@ -55,7 +56,7 @@ async function run() { // 4. Send avax to another address on P-chain from P-chain const sendP2PResponse = await walletClient.send({ to: PChainReceiverAddress, - amount: 0.001, + amount: avaxToWei(0.001), sourceChain: "P", destinationChain: "P", }); diff --git a/client/package-lock.json b/client/package-lock.json index 0e476918..384e5bc2 100644 --- a/client/package-lock.json +++ b/client/package-lock.json @@ -12,7 +12,7 @@ "@noble/hashes": "1.3.3", "@noble/secp256k1": "2.0.0", "util": "^0.12.5", - "viem": "^2.33.3" + "viem": "^2.38.5" }, "devDependencies": { "@rollup/plugin-commonjs": "^28.0.8", @@ -5795,9 +5795,9 @@ "license": "MIT" }, "node_modules/viem": { - "version": "2.38.2", - "resolved": "https://registry.npmjs.org/viem/-/viem-2.38.2.tgz", - "integrity": "sha512-MJDiTDD9gfOT7lPQRimdmw+g46hU/aWJ3loqb+tN6UBOO00XEd0O4LJx+Kp5/uCRnMlJr8zJ1bNzCK7eG6gMjg==", + "version": "2.38.6", + "resolved": "https://registry.npmjs.org/viem/-/viem-2.38.6.tgz", + "integrity": "sha512-aqO6P52LPXRjdnP6rl5Buab65sYa4cZ6Cpn+k4OLOzVJhGIK8onTVoKMFMT04YjDfyDICa/DZyV9HmvLDgcjkw==", "funding": [ { "type": "github", diff --git a/client/package.json b/client/package.json index 391016fc..59934615 100644 --- a/client/package.json +++ b/client/package.json @@ -48,7 +48,7 @@ "@noble/hashes": "1.3.3", "@noble/secp256k1": "2.0.0", "util": "^0.12.5", - "viem": "^2.33.3" + "viem": "^2.38.5" }, "devDependencies": { "@rollup/plugin-commonjs": "^28.0.8", diff --git a/client/src/clients/decorators/avalancheWallet.ts b/client/src/clients/decorators/avalancheWallet.ts index 83ec8265..c2b167f0 100644 --- a/client/src/clients/decorators/avalancheWallet.ts +++ b/client/src/clients/decorators/avalancheWallet.ts @@ -27,9 +27,9 @@ import { AvalancheWalletCoreClient } from "../createAvalancheWalletCoreClient.js export type AvalancheWalletActions = { /** - * Sends an XP transaction to the network. + * Sends an P-Chain or X-Chain or C-Chain Atomic transaction to the network. * - * - Docs: https://build.avax.network/docs/api-reference/x-chain/api#avm_send + * - Docs: https://docs.core.app/docs/reference/avalanche_sendtransaction * * @param args - The parameters for sending the transaction. {@link SendXPTransactionParameters} * @returns A promise that resolves to the transaction result. {@link SendXPTransactionReturnType} @@ -38,6 +38,7 @@ export type AvalancheWalletActions = { * ```ts * import { createAvalancheWalletClient } from '@avalanche-sdk/client' * import { avalanche } from '@avalanche-sdk/client/chains' + * import "@avalanche-sdk/client/window" * * // You can pass a local account otherwise a custom provider can be used * const account = privateKeyToAvalancheAccount("0x...") @@ -48,9 +49,7 @@ export type AvalancheWalletActions = { * }) * * const result = await walletClient.sendXPTransaction({ - * amount: "1000000000", - * to: "X-avax1...", - * assetID: "AVAX" + * ... * }) * * // Or you can use a custom provider (e.g. window.avalanche, window.ethereum, etc.) @@ -60,9 +59,7 @@ export type AvalancheWalletActions = { * }) * * const result = await walletClient.sendXPTransaction({ - * amount: "1000000000", - * to: "X-avax1...", - * assetID: "AVAX" + * ... * }) * ``` */ @@ -73,7 +70,7 @@ export type AvalancheWalletActions = { /** * Signs a message using the wallet's private key. * - * - Docs: https://build.avax.network/docs/api-reference/x-chain/api#avm_signmessage + * - Docs: https://docs.core.app/docs/reference/avalanche_signmessage * * @param args - The parameters for signing the message. {@link SignXPMessageParameters} * @returns A promise that resolves to the signed message. {@link SignXPMessageReturnType} @@ -115,7 +112,7 @@ export type AvalancheWalletActions = { /** * Signs an XP transaction using the wallet's private key. * - * - Docs: https://build.avax.network/docs/api-reference/x-chain/api#avm_signtx + * - Docs: https://docs.core.app/docs/reference/avalanche_signtransaction * * @param args - The parameters for signing the transaction. {@link SignXPTransactionParameters} * @returns A promise that resolves to the signed transaction. {@link SignXPTransactionReturnType} @@ -134,8 +131,7 @@ export type AvalancheWalletActions = { * }) * * const signedTx = await walletClient.signXPTransaction({ - * tx: "0x...", - * address: "X-avax1..." + * ... * }) * * // Or you can use a custom provider (e.g. window.avalanche, window.ethereum, etc.) @@ -145,9 +141,8 @@ export type AvalancheWalletActions = { * }) * * const signedTx = await walletClient.signXPTransaction({ - * tx: "0x...", - * address: "X-avax1..." - * }) + * ... +\ * }) * ``` */ signXPTransaction: ( @@ -157,7 +152,7 @@ export type AvalancheWalletActions = { /** * Gets the public key associated with the wallet account. * - * - Docs: https://build.avax.network/docs/api-reference/x-chain/api#avm_getaccountpubkey + * - Docs: https://docs.core.app/docs/reference/avalanche_getaccountpubkey * * @returns A promise that resolves to the account's public key. {@link GetAccountPubKeyReturnType} * @@ -190,7 +185,6 @@ export type AvalancheWalletActions = { /** * Waits for a transaction to be confirmed on the network. * - * - Docs: https://build.avax.network/docs/api-reference/x-chain/api#avm_waittx * * @param args - The parameters for waiting for the transaction. {@link WaitForTxnParameters} * @returns A promise that resolves when the transaction is confirmed. @@ -223,6 +217,7 @@ export type AvalancheWalletActions = { * ```ts * import { createAvalancheWalletClient } from '@avalanche-sdk/client' * import { avalanche } from '@avalanche-sdk/client/chains' + * import { avaxToWei } from '@avalanche-sdk/client/utils' * * const walletClient = createAvalancheWalletClient({ * chain: avalanche, @@ -230,7 +225,7 @@ export type AvalancheWalletActions = { * }) * * const result = await walletClient.send({ - * amount: 1, + * amount: avaxToWei(1), // 1 AVAX = 1_000_000_000_000_000_000 wei * to: "0x0000000000000000000000000000000000000000", * }); */ diff --git a/client/src/clients/decorators/cChainWallet.ts b/client/src/clients/decorators/cChainWallet.ts index ac67cc7f..6860bbd9 100644 --- a/client/src/clients/decorators/cChainWallet.ts +++ b/client/src/clients/decorators/cChainWallet.ts @@ -23,6 +23,7 @@ export type CChainWalletActions = { * ```ts * import { createAvalancheWalletClient } from '@avalanche-sdk/client' * import { avalanche } from '@avalanche-sdk/client/chains' + * import { avaxToNanoAvax } from '@avalanche-sdk/client/utils' * * const client = createAvalancheWalletClient({ * chain: avalanche, @@ -33,7 +34,7 @@ export type CChainWalletActions = { * * const exportTxn = await client.cChain.prepareExportTxn({ * to: "P-fuji1j2zllfqv4mgg7ytn9m2u2x0q3h3jqkzq8q8q8q8", - * amount: "1", // 1 AVAX + * amount: avaxToNanoAvax(1), // 1 AVAX = 1_000_000_000 nAVAX * destinationChain: "X" * }) * ``` diff --git a/client/src/clients/decorators/pChainWallet.ts b/client/src/clients/decorators/pChainWallet.ts index 916dc09f..a2818798 100644 --- a/client/src/clients/decorators/pChainWallet.ts +++ b/client/src/clients/decorators/pChainWallet.ts @@ -60,6 +60,7 @@ export type PChainWalletActions = { * import { createAvalancheWalletClient } from '@avalanche-sdk/client' * import { privateKeyToAvalancheAccount } from '@avalanche-sdk/client/accounts' * import { avalanche } from '@avalanche-sdk/client/chains' + * import { avaxToNanoAvax } from '@avalanche-sdk/client/utils' * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890") * const client = createAvalancheWalletClient({ @@ -72,8 +73,8 @@ export type PChainWalletActions = { * * const delegatorTx = await client.pChain.prepareAddPermissionlessDelegatorTxn({ * nodeId: "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg", - * stakeInAvax: 1, - * end: 1716441600, + * stakeInAvax: avaxToNanoAvax(1), + * end: 1716441600n, * rewardAddresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"], * threshold: 1, * }) @@ -97,6 +98,7 @@ export type PChainWalletActions = { * import { createAvalancheWalletClient } from '@avalanche-sdk/client' * import { privateKeyToAvalancheAccount } from '@avalanche-sdk/client/accounts' * import { avalanche } from '@avalanche-sdk/client/chains' + * import { avaxToNanoAvax } from '@avalanche-sdk/client/utils' * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890") * const client = createAvalancheWalletClient({ @@ -109,8 +111,8 @@ export type PChainWalletActions = { * * const validatorTx = await client.pChain.prepareAddPermissionlessValidatorTxn({ * nodeId: "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg", - * stakeInAvax: 1, - * end: 1716441600, + * stakeInAvax: avaxToNanoAvax(1), + * end: 1716441600n, * rewardAddresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"], * threshold: 1, * publicKey: "0x1234567890123456789012345678901234567890", @@ -176,6 +178,7 @@ export type PChainWalletActions = { * import { createAvalancheWalletClient } from '@avalanche-sdk/client' * import { privateKeyToAvalancheAccount } from '@avalanche-sdk/client/accounts' * import { avalanche } from '@avalanche-sdk/client/chains' + * import { avaxToNanoAvax } from '@avalanche-sdk/client/utils' * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890") * const client = createAvalancheWalletClient({ @@ -189,7 +192,7 @@ export type PChainWalletActions = { * const baseTx = await client.pChain.prepareBaseTxn({ * outputs: [{ * addresses: "P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz", - * amount: 1, + * amount: avaxToNanoAvax(1), * }], * }) * ``` @@ -212,6 +215,7 @@ export type PChainWalletActions = { * import { createAvalancheWalletClient } from '@avalanche-sdk/client' * import { privateKeyToAvalancheAccount } from '@avalanche-sdk/client/accounts' * import { avalanche } from '@avalanche-sdk/client/chains' + * import { avaxToNanoAvax } from '@avalanche-sdk/client/utils' * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890") * const client = createAvalancheWalletClient({ @@ -231,7 +235,7 @@ export type PChainWalletActions = { * { * nodeId: "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg", * weight: 1n, - * initialBalanceInAvax: 1, + * initialBalanceInAvax: avaxToNanoAvax(1), * nodePoP: { * publicKey: "0x1234567890123456789012345678901234567890", * proofOfPossession: "0x1234567890123456789012345678901234567890", @@ -375,6 +379,7 @@ export type PChainWalletActions = { * import { createAvalancheWalletClient } from '@avalanche-sdk/client' * import { privateKeyToAvalancheAccount } from '@avalanche-sdk/client/accounts' * import { avalanche } from '@avalanche-sdk/client/chains' + * import { avaxToNanoAvax } from '@avalanche-sdk/client/utils' * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890") * const client = createAvalancheWalletClient({ @@ -389,7 +394,7 @@ export type PChainWalletActions = { * destinationChain: "P", * exportedOutputs: [{ * addresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"], - * amount: 0.0001, + * amount: avaxToNanoAvax(0.0001), * }], * }) * ``` @@ -459,7 +464,7 @@ export type PChainWalletActions = { * }) * * const pChainIncreaseL1ValidatorBalanceTxnRequest = await client.pChain.prepareIncreaseL1ValidatorBalanceTxn({ - * balanceInAvax: 1, + * balanceInAvax: avaxToNanoAvax(1), * validationId: "11111111111111111111111111111111LpoYY", * }) * ``` @@ -482,6 +487,7 @@ export type PChainWalletActions = { * import { createAvalancheWalletClient } from '@avalanche-sdk/client' * import { privateKeyToAvalancheAccount } from '@avalanche-sdk/client/accounts' * import { avalanche } from '@avalanche-sdk/client/chains' + * import { avaxToNanoAvax } from '@avalanche-sdk/client/utils' * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890") * const client = createAvalancheWalletClient({ @@ -493,7 +499,7 @@ export type PChainWalletActions = { * }) * * const pChainRegisterL1ValidatorTxnRequest = await client.pChain.prepareRegisterL1ValidatorTxn({ - * initialBalanceInAvax: 1, + * initialBalanceInAvax: avaxToNanoAvax(1), * blsSignature: "0x1234567890123456789012345678901234567890", * message: "0x1234567890123456789012345678901234567890", * }) diff --git a/client/src/clients/decorators/xChainWallet.ts b/client/src/clients/decorators/xChainWallet.ts index b8cd2e5e..bfdf8496 100644 --- a/client/src/clients/decorators/xChainWallet.ts +++ b/client/src/clients/decorators/xChainWallet.ts @@ -25,6 +25,27 @@ export type XChainWalletActions = { * @param client - The client to use for the transaction. {@link AvalancheWalletCoreClient} * @param params - The parameters for the transaction. {@link PrepareBaseTxnParameters} * @returns The unsigned transaction. {@link PrepareBaseTxnReturnType} + * + * @example + * ```ts + * import { createAvalancheWalletClient } from '@avalanche-sdk/client' + * import { avalanche } from '@avalanche-sdk/client/chains' + * import { avaxToNanoAvax } from '@avalanche-sdk/client/utils' + * + * const client = createAvalancheWalletClient({ + * chain: avalanche, + * transport: { + * type: "http", + * }, + * }) + * + * const baseTxn = await client.xChain.prepareBaseTxn({ + * outputs: [{ + * addresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"], + * amount: avaxToNanoAvax(0.0001), + * }], + * }) + * ``` */ prepareBaseTxn: ( args: PrepareBaseTxnParameters @@ -38,6 +59,28 @@ export type XChainWalletActions = { * @param client - The client to use for the transaction. {@link AvalancheWalletCoreClient} * @param params - The parameters for the transaction. {@link PrepareExportTxnParameters} * @returns The unsigned transaction. {@link PrepareExportTxnReturnType} + * + * @example + * ```ts + * import { createAvalancheWalletClient } from '@avalanche-sdk/client' + * import { avalanche } from '@avalanche-sdk/client/chains' + * import { avaxToNanoAvax } from '@avalanche-sdk/client/utils' + * + * const client = createAvalancheWalletClient({ + * chain: avalanche, + * transport: { + * type: "http", + * }, + * }) + * + * const exportTxn = await client.xChain.prepareExportTxn({ + * destinationChain: "P", + * exportedOutput: { + * addresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"], + * amount: avaxToNanoAvax(0.0001), + * }, + * }) + * ``` */ prepareExportTxn: ( args: PrepareExportTxnParameters @@ -51,6 +94,27 @@ export type XChainWalletActions = { * @param client - The client to use for the transaction. {@link AvalancheWalletCoreClient} * @param params - The parameters for the transaction. {@link PrepareImportTxnParameters} * @returns The unsigned transaction. {@link PrepareImportTxnReturnType} + * + * @example + * ```ts + * import { createAvalancheWalletClient } from '@avalanche-sdk/client' + * import { avalanche } from '@avalanche-sdk/client/chains' + * import { avaxToNanoAvax } from '@avalanche-sdk/client/utils' + * + * const client = createAvalancheWalletClient({ + * chain: avalanche, + * transport: { + * type: "http", + * }, + * }) + * + * const importTxn = await client.xChain.prepareImportTxn({ + * sourceChain: "P", + * importedOutput: { + * addresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"], + * }, + * }) + * ``` */ prepareImportTxn: ( args: PrepareImportTxnParameters diff --git a/client/src/methods/wallet/cChain/prepareExportTxn.test.ts b/client/src/methods/wallet/cChain/prepareExportTxn.test.ts index 328f1105..1ce405bb 100644 --- a/client/src/methods/wallet/cChain/prepareExportTxn.test.ts +++ b/client/src/methods/wallet/cChain/prepareExportTxn.test.ts @@ -4,13 +4,14 @@ import { PrepareExportTxnParameters } from "."; import { avalancheFuji } from "../../../chains"; import { createAvalancheWalletClient } from "../../../clients/createAvalancheWalletClient"; import { testContext } from "../fixtures/testContext"; -import { - getCChainMockServer, - TEST_BASE_FEE, -} from "../fixtures/transactions/cChain"; +import { getCChainMockServer } from "../fixtures/transactions/cChain"; import { account1, account2, account3 } from "../fixtures/transactions/common"; import { checkOutputs } from "../fixtures/utils"; -import { getChainIdFromAlias, toTransferableOutput } from "../utils"; +import { + avaxToNanoAvax, + getChainIdFromAlias, + toTransferableOutput, +} from "../utils"; const cChainWorker = getCChainMockServer({}); @@ -38,7 +39,7 @@ describe("prepareExportTxn", () => { account3.getXPAddress("P", "fuji"), ]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const testOutputs = [ { addresses: receiverAddresses, @@ -84,7 +85,7 @@ describe("prepareExportTxn", () => { account3.getXPAddress("P", "fuji"), ]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const mockTxParamsPChain: PrepareExportTxnParameters = { fromAddress: account1.getEVMAddress(), exportedOutput: { @@ -141,7 +142,7 @@ describe("prepareExportTxn", () => { account2.getXPAddress("P", "fuji"), account3.getXPAddress("P", "fuji"), ]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const mockTxParamsPChain: PrepareExportTxnParameters = { fromAddress: account1.getEVMAddress(), exportedOutput: { diff --git a/client/src/methods/wallet/cChain/prepareExportTxn.ts b/client/src/methods/wallet/cChain/prepareExportTxn.ts index 0f55ab6f..42ab3bf8 100644 --- a/client/src/methods/wallet/cChain/prepareExportTxn.ts +++ b/client/src/methods/wallet/cChain/prepareExportTxn.ts @@ -3,11 +3,7 @@ import { getTransactionCount } from "viem/actions"; import { AvalancheWalletCoreClient } from "../../../clients/createAvalancheWalletCoreClient.js"; import { baseFee as getBaseFee } from "../../public/index.js"; import { getContextFromURI } from "../getContextFromURI.js"; -import { - avaxToNanoAvax, - bech32AddressToBytes, - getChainIdFromAlias, -} from "../utils.js"; +import { bech32AddressToBytes, getChainIdFromAlias } from "../utils.js"; import { PrepareExportTxnParameters, PrepareExportTxnReturnType, @@ -29,6 +25,7 @@ import { newExportTxFromBaseFee } from "./utils.js"; * import { createAvalancheWalletClient } from "@avalanche-sdk/client/clients/createAvalancheWalletClient"; * import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; * import { avalanche } from "@avalanche-sdk/client/chains"; + * import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890"); * const walletClient = createAvalancheWalletClient({ @@ -41,7 +38,7 @@ import { newExportTxFromBaseFee } from "./utils.js"; * fromAddress: "0x76Dd3d7b2f635c2547B861e55aE8A374E587742D", * exportedOutput: { * addresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"], - * amount: 0.0001, + * amount: avaxToNanoAvax(0.0001), * }, * }); * @@ -66,7 +63,7 @@ export async function prepareExportTxn( const unsignedTx = newExportTxFromBaseFee( context, BigInt(baseFeeInWei), - avaxToNanoAvax(params.exportedOutput.amount), + params.exportedOutput.amount, getChainIdFromAlias(params.destinationChain, context.networkID), utils.hexToBuffer(params.fromAddress), pAddressBytes, diff --git a/client/src/methods/wallet/cChain/types/prepareExportTxn.ts b/client/src/methods/wallet/cChain/types/prepareExportTxn.ts index 54ab7d04..ef275b93 100644 --- a/client/src/methods/wallet/cChain/types/prepareExportTxn.ts +++ b/client/src/methods/wallet/cChain/types/prepareExportTxn.ts @@ -27,13 +27,13 @@ export type PrepareExportTxnParameters = { */ addresses: string[]; /** - * The amount (in AVAX) held by this exported output. + * The amount (in nano AVAX) held by this exported output. */ - amount: number; + amount: bigint; /** * Optional. Timestamp in seconds after which this UTXO can be consumed. */ - locktime?: number; + locktime?: bigint; /** * Optional. Threshold of `addresses`' signatures required to consume this UTXO. */ diff --git a/client/src/methods/wallet/fixtures/transactions/cChain.ts b/client/src/methods/wallet/fixtures/transactions/cChain.ts index a4504f6e..f1dfca35 100644 --- a/client/src/methods/wallet/fixtures/transactions/cChain.ts +++ b/client/src/methods/wallet/fixtures/transactions/cChain.ts @@ -18,7 +18,7 @@ import { privateKey1ForTest, privateKey2ForTest } from "./common.js"; export const TEST_BASE_FEE = "0x2BF2"; export const getUTXOStrings = ( - amt = 50, + amt: bigint = BigInt(50 * 1e9), assetId: string, owners: string[], locktime = 0, @@ -43,14 +43,14 @@ export const getUTXOStrings = ( }; export const getValidUTXO = ( - amt = 50, + amt: bigint = BigInt(50 * 1e9), assetId: string, owners: string[], locktime = 0, threshold = 1, utxoId = "2R5bJqAd6evMJAuV4TYGqfaHkdCEQfYUx4GoHpJZxsFeor6wMi" ) => { - const bigIntAmount = new BigIntPr(BigInt(amt * 1e9)); + const bigIntAmount = new BigIntPr(amt); const ownerAddresses = owners.map((owner) => Address.fromString(owner)); return new Utxo( @@ -151,7 +151,7 @@ export const getCChainMockServer = (params: { export const getDefaultGetUTXOsMockResponse = ( reqBody: Record | DefaultRequestMultipartBody, - testInputAmount: number = 1 + testInputAmount: bigint = BigInt(1 * 1e9) ) => { return HttpResponse.json({ jsonrpc: "2.0", diff --git a/client/src/methods/wallet/fixtures/transactions/pChain.ts b/client/src/methods/wallet/fixtures/transactions/pChain.ts index d669de45..4ad1cab3 100644 --- a/client/src/methods/wallet/fixtures/transactions/pChain.ts +++ b/client/src/methods/wallet/fixtures/transactions/pChain.ts @@ -21,7 +21,7 @@ import { } from "./common"; export const getUTXOStrings = ( - amt = 50, + amt = BigInt(50 * 1e9), assetId: string, owners: string[], locktime = 0, @@ -46,14 +46,14 @@ export const getUTXOStrings = ( }; export const getValidUTXO = ( - amt = 50, + amt = BigInt(50 * 1e9), assetId: string, owners: string[], locktime = 0, threshold = 1, utxoId = "2R5bJqAd6evMJAuV4TYGqfaHkdCEQfYUx4GoHpJZxsFeor6wMi" ) => { - const bigIntAmount = new BigIntPr(BigInt(amt * 1e9)); + const bigIntAmount = new BigIntPr(amt); const ownerAddresses = owners.map((owner) => Address.fromString(owner)); return new Utxo( @@ -132,7 +132,7 @@ export const getPChainMockServer = (params: { export const getDefaultGetUTXOsMockResponse = ( reqBody: Record | DefaultRequestMultipartBody, - testInputAmount: number = 1 + testInputAmount: bigint = BigInt(1 * 1e9) ) => { return HttpResponse.json({ jsonrpc: "2.0", diff --git a/client/src/methods/wallet/fixtures/transactions/xChain.ts b/client/src/methods/wallet/fixtures/transactions/xChain.ts index 88049c28..41cc3dbc 100644 --- a/client/src/methods/wallet/fixtures/transactions/xChain.ts +++ b/client/src/methods/wallet/fixtures/transactions/xChain.ts @@ -18,7 +18,7 @@ import { privateKey1ForTest, privateKey2ForTest } from "./common.js"; export const TEST_BASE_FEE = "0x2BF2"; export const getUTXOStrings = ( - amt = 50, + amt: bigint = BigInt(50 * 1e9), assetId: string, owners: string[], locktime = 0, @@ -43,14 +43,14 @@ export const getUTXOStrings = ( }; export const getValidUTXO = ( - amt = 50, + amt: bigint = BigInt(50 * 1e9), assetId: string, owners: string[], locktime = 0, threshold = 1, utxoId = "2R5bJqAd6evMJAuV4TYGqfaHkdCEQfYUx4GoHpJZxsFeor6wMi" ) => { - const bigIntAmount = new BigIntPr(BigInt(amt * 1e9)); + const bigIntAmount = new BigIntPr(amt); const ownerAddresses = owners.map((owner) => Address.fromString(owner)); return new Utxo( @@ -113,7 +113,7 @@ export const getXChainMockServer = (params: { export const getDefaultGetUTXOsMockResponse = ( reqBody: Record | DefaultRequestMultipartBody, - testInputAmount: number = 1 + testInputAmount: bigint = BigInt(1 * 1e9) ) => { return HttpResponse.json({ jsonrpc: "2.0", diff --git a/client/src/methods/wallet/fixtures/utils.ts b/client/src/methods/wallet/fixtures/utils.ts index eed9ccb5..aa543ff0 100644 --- a/client/src/methods/wallet/fixtures/utils.ts +++ b/client/src/methods/wallet/fixtures/utils.ts @@ -21,7 +21,7 @@ export function checkOutputs( expect( actual?.amount().valueOf(), `output amount did not match for index ${index}` - ).toBe(BigInt(expected.amount * 1e9)); + ).toBe(expected.amount); // check owners const expectedOwners = expected.addresses.map((address) => diff --git a/client/src/methods/wallet/pChain/prepareAddPermissionlessDelegatorTxn.test.ts b/client/src/methods/wallet/pChain/prepareAddPermissionlessDelegatorTxn.test.ts index 145febf9..63ca55a1 100644 --- a/client/src/methods/wallet/pChain/prepareAddPermissionlessDelegatorTxn.test.ts +++ b/client/src/methods/wallet/pChain/prepareAddPermissionlessDelegatorTxn.test.ts @@ -13,8 +13,8 @@ import { import { getPChainMockServer } from "../fixtures/transactions/pChain"; import { checkOutputs } from "../fixtures/utils"; import { Output } from "../types/common"; -import { toTransferableOutput } from "../utils"; -const testInputAmount = 1; +import { avaxToNanoAvax, toTransferableOutput } from "../utils"; +const testInputAmount = avaxToNanoAvax(1); const pChainWorker = getPChainMockServer({}); @@ -43,14 +43,14 @@ describe("prepareAddPermissionlessDelegatorTxn", () => { ]; const changeAddresses = [account3.getXPAddress("P", "fuji")]; - const stakeAmount = 0.5; + const stakeAmount = avaxToNanoAvax(0.5); const endTime = 1234356770; const txnRequest = await walletClient.pChain.prepareAddPermissionlessDelegatorTxn({ changeAddresses, stakeInAvax: stakeAmount, nodeId: "NodeID-LbijL9cqXkmq2Q8oQYYGs8LmcSRhnrDWJ", - end: Math.floor(endTime / 1000), + end: BigInt(Math.floor(endTime / 1000)), rewardAddresses, context: testContext, }); @@ -83,7 +83,7 @@ describe("prepareAddPermissionlessDelegatorTxn", () => { testContext.platformFeeConfig.weights, feeState().price ); - const expectedFeesInAvax = Number(fee) / 1e9; + const expectedFeesInAvax = fee; const expectedChangeAmount = testInputAmount - stakeAmount - expectedFeesInAvax; @@ -109,7 +109,7 @@ describe("prepareAddPermissionlessDelegatorTxn", () => { expect( allInputAmounts - allOutputAmounts, "expected and actual burned amount mismatch" - ).toBe(BigInt(expectedFeesInAvax * 1e9)); + ).toBe(expectedFeesInAvax); }); it("should create correct staking details", async () => { @@ -119,16 +119,16 @@ describe("prepareAddPermissionlessDelegatorTxn", () => { ]; const changeAddresses = [account3.getXPAddress("P", "fuji")]; - const stakeAmount = 0.5; + const stakeAmount = avaxToNanoAvax(0.5); const endTime = 1234356770; const mockTxParams = { changeAddresses, // staked outputs will be owned by these addresses stakeInAvax: stakeAmount, nodeId: "NodeID-LbijL9cqXkmq2Q8oQYYGs8LmcSRhnrDWJ", - end: Math.floor(endTime / 1000), + end: BigInt(Math.floor(endTime / 1000)), rewardAddresses, threshold: 3, - locktime: 1234567890, + locktime: BigInt(1234567890), context: testContext, }; const txnRequest = @@ -145,7 +145,7 @@ describe("prepareAddPermissionlessDelegatorTxn", () => { BigInt(mockTxParams.end) ); expect(vldr.weight.value(), "weight mismatch").toBe( - BigInt(mockTxParams.stakeInAvax * 1e9) + mockTxParams.stakeInAvax ); // check delegator rewards owner @@ -171,16 +171,16 @@ describe("prepareAddPermissionlessDelegatorTxn", () => { ]; const changeAddresses = [account3.getXPAddress("P", "fuji")]; - const stakeAmount = 0.5; + const stakeAmount = avaxToNanoAvax(0.5); const endTime = 1234356770; const mockTxParams = { changeAddresses, // staked outputs will be owned by these addresses stakeInAvax: stakeAmount, nodeId: "NodeID-LbijL9cqXkmq2Q8oQYYGs8LmcSRhnrDWJ", - end: Math.floor(endTime / 1000), + end: BigInt(Math.floor(endTime / 1000)), rewardAddresses, threshold: 3, - locktime: 1234567890, + locktime: BigInt(1234567890), context: testContext, }; const txnRequest = diff --git a/client/src/methods/wallet/pChain/prepareAddPermissionlessDelegatorTxn.ts b/client/src/methods/wallet/pChain/prepareAddPermissionlessDelegatorTxn.ts index cf2c14fd..663ab930 100644 --- a/client/src/methods/wallet/pChain/prepareAddPermissionlessDelegatorTxn.ts +++ b/client/src/methods/wallet/pChain/prepareAddPermissionlessDelegatorTxn.ts @@ -23,6 +23,7 @@ import { * import { createAvalancheWalletClient } from "@avalanche-sdk/client/clients/createAvalancheWalletClient"; * import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; * import { avalanche } from "@avalanche-sdk/client/chains"; + * import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890"); * const walletClient = createAvalancheWalletClient({ @@ -32,8 +33,8 @@ import { * * const pChainAddPermissionlessDelegatorTxnRequest = await prepareAddPermissionlessDelegatorTxn(walletClient, { * nodeId: "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg", - * stakeInAvax: 1, - * end: 1716441600, + * stakeInAvax: avaxToNanoAvax(1), + * end: 1716441600n, * rewardAddresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"], * threshold: 1, * }); @@ -55,13 +56,13 @@ export async function prepareAddPermissionlessDelegatorTxn( const unsignedTx = pvm.newAddPermissionlessDelegatorTx( { ...commonTxParams, - weight: BigInt(params.stakeInAvax * 1e9), + weight: params.stakeInAvax, nodeId: params.nodeId, start: 0n, // start time is not relevant after Durango upgrade - end: BigInt(params.end), + end: params.end, rewardAddresses: params.rewardAddresses.map(bech32AddressToBytes), threshold: params.threshold ?? 1, - locktime: BigInt(params.locktime ?? 0n), + locktime: params.locktime ?? 0n, subnetId: "11111111111111111111111111111111LpoYY", // accept only Primary Network staking for permissionless validators }, context diff --git a/client/src/methods/wallet/pChain/prepareAddPermissionlessValidatorTxn.test.ts b/client/src/methods/wallet/pChain/prepareAddPermissionlessValidatorTxn.test.ts index 8822698d..86deeb30 100644 --- a/client/src/methods/wallet/pChain/prepareAddPermissionlessValidatorTxn.test.ts +++ b/client/src/methods/wallet/pChain/prepareAddPermissionlessValidatorTxn.test.ts @@ -20,8 +20,8 @@ import { import { getPChainMockServer } from "../fixtures/transactions/pChain"; import { checkOutputs } from "../fixtures/utils"; import { Output } from "../types/common"; -import { toTransferableOutput } from "../utils"; -const testInputAmount = 1; +import { avaxToNanoAvax, toTransferableOutput } from "../utils"; +const testInputAmount = avaxToNanoAvax(1); const pChainWorker = getPChainMockServer({}); @@ -51,13 +51,13 @@ describe("prepareAddPermissionlessValidatorTxn", () => { const delegatorRewardAddresses = [account3.getXPAddress("P", "fuji")]; const changeAddresses = [account4.getXPAddress("P", "fuji")]; - const stakeAmount = 0.5; + const stakeAmount = avaxToNanoAvax(0.5); const endTime = 1234356770; const mockTxParams = { changeAddresses, // staked outputs will be owned by these addresses stakeInAvax: stakeAmount, nodeId: "NodeID-LbijL9cqXkmq2Q8oQYYGs8LmcSRhnrDWJ", - end: Math.floor(endTime / 1000), + end: BigInt(Math.floor(endTime / 1000)), rewardAddresses, delegatorRewardAddresses, delegatorRewardPercentage: 4, @@ -94,7 +94,7 @@ describe("prepareAddPermissionlessValidatorTxn", () => { testContext.platformFeeConfig.weights, feeState().price ); - const expectedFeesInAvax = Number(fee) / 1e9; + const expectedFeesInAvax = fee; const expectedChangeAmount = testInputAmount - stakeAmount - expectedFeesInAvax; @@ -118,7 +118,7 @@ describe("prepareAddPermissionlessValidatorTxn", () => { expect( allInputAmounts - allOutputAmounts, "expected and actual burned amount mismatch" - ).toBe(BigInt(expectedFeesInAvax * 1e9)); + ).toBe(expectedFeesInAvax); }); it("should create correct staking details", async () => { @@ -129,13 +129,13 @@ describe("prepareAddPermissionlessValidatorTxn", () => { const delegatorRewardAddresses = [account3.getXPAddress("P", "fuji")]; const changeAddresses = [account4.getXPAddress("P", "fuji")]; - const stakeAmount = 0.5; + const stakeAmount = avaxToNanoAvax(0.5); const endTime = 1234356770; const mockTxParams = { changeAddresses, // staked outputs will be owned by these addresses stakeInAvax: stakeAmount, nodeId: "NodeID-LbijL9cqXkmq2Q8oQYYGs8LmcSRhnrDWJ", - end: Math.floor(endTime / 1000), + end: BigInt(Math.floor(endTime / 1000)), rewardAddresses, delegatorRewardAddresses, delegatorRewardPercentage: 4, @@ -155,7 +155,7 @@ describe("prepareAddPermissionlessValidatorTxn", () => { BigInt(mockTxParams.end) ); expect(vldr.weight.value(), "weight mismatch").toBe( - BigInt(mockTxParams.stakeInAvax * 1e9) + mockTxParams.stakeInAvax ); expect( ( @@ -197,13 +197,13 @@ describe("prepareAddPermissionlessValidatorTxn", () => { const delegatorRewardAddresses = [account3.getXPAddress("P", "fuji")]; const changeAddresses = [account4.getXPAddress("P", "fuji")]; - const stakeAmount = 0.5; + const stakeAmount = avaxToNanoAvax(0.5); const endTime = 1234356770; const mockTxParams = { changeAddresses, // staked outputs will be owned by these addresses stakeInAvax: stakeAmount, nodeId: "NodeID-LbijL9cqXkmq2Q8oQYYGs8LmcSRhnrDWJ", - end: Math.floor(endTime / 1000), + end: BigInt(Math.floor(endTime / 1000)), rewardAddresses, delegatorRewardAddresses, delegatorRewardPercentage: 4, diff --git a/client/src/methods/wallet/pChain/prepareAddPermissionlessValidatorTxn.ts b/client/src/methods/wallet/pChain/prepareAddPermissionlessValidatorTxn.ts index 1999de30..e6d28f85 100644 --- a/client/src/methods/wallet/pChain/prepareAddPermissionlessValidatorTxn.ts +++ b/client/src/methods/wallet/pChain/prepareAddPermissionlessValidatorTxn.ts @@ -23,6 +23,7 @@ import { * import { createAvalancheWalletClient } from "@avalanche-sdk/client/clients/createAvalancheWalletClient"; * import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; * import { avalanche } from "@avalanche-sdk/client/chains"; + * import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890"); * const walletClient = createAvalancheWalletClient({ @@ -32,13 +33,13 @@ import { * * const pChainAddPermissionlessValidatorTxnRequest = await prepareAddPermissionlessValidatorTxn(walletClient, { * nodeId: "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg", - * stakeInAvax: 1, - * end: 1716441600, + * stakeInAvax: avaxToNanoAvax(1), + * end: 1716441600n, * rewardAddresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"], * threshold: 1, * publicKey: "0x1234567890123456789012345678901234567890", * signature: "0x1234567890123456789012345678901234567890", - * locktime: 1716441600, + * locktime: 1716441600n, * delegatorRewardPercentage: 2.5, * delegatorRewardAddresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"], * }); @@ -59,7 +60,7 @@ export async function prepareAddPermissionlessValidatorTxn( const unsignedTx = pvm.newAddPermissionlessValidatorTx( { ...commonTxParams, - weight: BigInt(params.stakeInAvax * 1e9), + weight: params.stakeInAvax, nodeId: params.nodeId, start: 0n, // start time is not relevant after Durango upgrade end: BigInt(params.end), diff --git a/client/src/methods/wallet/pChain/prepareAddSubnetValidatorTxn.test.ts b/client/src/methods/wallet/pChain/prepareAddSubnetValidatorTxn.test.ts index 4a6e810a..8531b4b9 100644 --- a/client/src/methods/wallet/pChain/prepareAddSubnetValidatorTxn.test.ts +++ b/client/src/methods/wallet/pChain/prepareAddSubnetValidatorTxn.test.ts @@ -8,8 +8,8 @@ import { account1, account2, feeState } from "../fixtures/transactions/common"; import { getPChainMockServer } from "../fixtures/transactions/pChain"; import { checkOutputs } from "../fixtures/utils"; import { Output } from "../types/common"; -import { toTransferableOutput } from "../utils"; -const testInputAmount = 1; +import { avaxToNanoAvax, toTransferableOutput } from "../utils"; +const testInputAmount = avaxToNanoAvax(1); const pChainWorker = getPChainMockServer({}); @@ -58,7 +58,7 @@ describe("addSubnetValidatorTx", () => { testContext.platformFeeConfig.weights, feeState().price ); - const expectedFeesInAvax = Number(fee) / 1e9; + const expectedFeesInAvax = fee; const expectedChangeAmount = testInputAmount - expectedFeesInAvax; // expected change output @@ -81,7 +81,7 @@ describe("addSubnetValidatorTx", () => { expect( allInputAmounts - allOutputAmounts, "expected and actual burned amount mismatch" - ).toBe(BigInt(expectedFeesInAvax * 1e9)); + ).toBe(expectedFeesInAvax); }); it("should create correct staking details", async () => { diff --git a/client/src/methods/wallet/pChain/prepareBaseTxn.test.ts b/client/src/methods/wallet/pChain/prepareBaseTxn.test.ts index 596c68c2..cde74efd 100644 --- a/client/src/methods/wallet/pChain/prepareBaseTxn.test.ts +++ b/client/src/methods/wallet/pChain/prepareBaseTxn.test.ts @@ -8,7 +8,7 @@ import { import { afterAll, beforeAll, describe, expect, it } from "vitest"; import { avalancheFuji } from "../../../chains"; import { createAvalancheWalletClient } from "../../../clients/createAvalancheWalletClient"; -import { getTxFromBytes } from "../../../utils"; +import { avaxToNanoAvax, getTxFromBytes } from "../../../utils"; import { testContext } from "../fixtures/testContext"; import { account1, @@ -25,7 +25,7 @@ import { checkOutputs } from "../fixtures/utils"; import { Output } from "../types/common"; import { toTransferableOutput } from "../utils"; import { PrepareBaseTxnParameters } from "./types/prepareBaseTxn"; -const testInputAmount = 1; +const testInputAmount = avaxToNanoAvax(1); const pChainWorker = getPChainMockServer({}); @@ -53,7 +53,7 @@ describe("newBaseTx", () => { account3.getXPAddress("P", "fuji"), ]; const changeAddresses = [account2.getXPAddress("P", "fuji")]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -80,7 +80,7 @@ describe("newBaseTx", () => { testContext.platformFeeConfig.weights, feeState().price ); - const expectedFeesInAvax = Number(fee) / 1e9; + const expectedFeesInAvax = fee; const expectedChangeAmount = testInputAmount - testOutputAmount - expectedFeesInAvax; @@ -108,7 +108,7 @@ describe("newBaseTx", () => { expect( allInputAmounts - allOutputAmounts, "expected and actual burned amount mismatch" - ).toBe(BigInt(expectedFeesInAvax * 1e9)); + ).toBe(expectedFeesInAvax); }); it("should only use utxos passed in params", async () => { @@ -118,8 +118,8 @@ describe("newBaseTx", () => { ]; const changeAddresses = [account2.getXPAddress("P", "fuji")]; - const testOutputAmount = 0.1234; - const testInputAmount = 0.5; + const testOutputAmount = avaxToNanoAvax(0.1234); + const testInputAmount = avaxToNanoAvax(0.5); const testOutputs = [ { amount: testOutputAmount, @@ -153,7 +153,7 @@ describe("newBaseTx", () => { testContext.platformFeeConfig.weights, feeState().price ); - const expectedFeesInAvax = Number(fee) / 1e9; + const expectedFeesInAvax = fee; // if utxos passed in params are only used, then testInputAmount will be 0.5 instead of default 1 const expectedChangeAmount = testInputAmount - testOutputAmount - expectedFeesInAvax; @@ -179,20 +179,18 @@ describe("newBaseTx", () => { const allOutputAmounts = ( txnRequest.tx.getTx() as pvmSerial.BaseTx ).baseTx.outputs.reduce((acc, i) => acc + i.amount(), 0n); - expect(allInputAmounts - allOutputAmounts).toBe( - BigInt(expectedFeesInAvax * 1e9) - ); + expect(allInputAmounts - allOutputAmounts).toBe(expectedFeesInAvax); }); it("should use `fromAddresses` for fetching utxos and change addresses", async () => { - const testSpentAmount = 1; + const testSpentAmount = avaxToNanoAvax(1); const spenderAddresses = [account1.getXPAddress("P", "fuji")]; const receiverAddresses = [ account4.getXPAddress("P", "fuji"), account3.getXPAddress("P", "fuji"), ]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -215,7 +213,7 @@ describe("newBaseTx", () => { testContext.platformFeeConfig.weights, feeState().price ); - const expectedFeesInAvax = Number(fee) / 1e9; + const expectedFeesInAvax = fee; const expectedChangeAmount = testSpentAmount - testOutputAmount - expectedFeesInAvax; @@ -245,7 +243,7 @@ describe("newBaseTx", () => { expect( allInputAmounts - allOutputAmounts, "expected and actual burned amount mismatch" - ).toBe(BigInt(expectedFeesInAvax * 1e9)); + ).toBe(expectedFeesInAvax); }); it("should sign the tx properly", async () => { @@ -255,7 +253,7 @@ describe("newBaseTx", () => { ]; const changeAddresses = [account2.getXPAddress("P", "fuji")]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -287,7 +285,7 @@ describe("newBaseTx", () => { const receiverAddresses = [account3.getXPAddress("P", "fuji")]; const changeAddresses = [account4.getXPAddress("P", "fuji")]; - const testOutputAmount = 1.5; + const testOutputAmount = avaxToNanoAvax(1.5); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -348,7 +346,7 @@ describe("newBaseTx", () => { ]; const changeAddresses = [account2.getXPAddress("P", "fuji")]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -373,7 +371,7 @@ describe("newBaseTx", () => { fromAddresses: [account1.getXPAddress("P", "fuji")], outputs: [ { - amount: 40, + amount: avaxToNanoAvax(40), addresses: [account1.getXPAddress("P", "fuji")], }, ], diff --git a/client/src/methods/wallet/pChain/prepareBaseTxn.ts b/client/src/methods/wallet/pChain/prepareBaseTxn.ts index 2791270b..1648deb5 100644 --- a/client/src/methods/wallet/pChain/prepareBaseTxn.ts +++ b/client/src/methods/wallet/pChain/prepareBaseTxn.ts @@ -23,6 +23,7 @@ import { * import { createAvalancheWalletClient } from "@avalanche-sdk/client/clients/createAvalancheWalletClient"; * import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; * import { avalanche } from "@avalanche-sdk/client/chains"; + * import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890"); * const walletClient = createAvalancheWalletClient({ @@ -33,7 +34,7 @@ import { * const pChainBaseTxnRequest = await prepareBaseTxn(walletClient, { * outputs: [{ * addresses: "P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz", - * amount: 1, + * amount: avaxToNanoAvax(1), * }], * }); * diff --git a/client/src/methods/wallet/pChain/prepareConvertSubnetToL1Txn.test.ts b/client/src/methods/wallet/pChain/prepareConvertSubnetToL1Txn.test.ts index 503e8ce7..27164d9a 100644 --- a/client/src/methods/wallet/pChain/prepareConvertSubnetToL1Txn.test.ts +++ b/client/src/methods/wallet/pChain/prepareConvertSubnetToL1Txn.test.ts @@ -14,9 +14,9 @@ import { import { getPChainMockServer } from "../fixtures/transactions/pChain"; import { checkOutputs } from "../fixtures/utils"; import { Output } from "../types/common"; -import { avaxToNanoAvax, nanoAvaxToAvax, toTransferableOutput } from "../utils"; +import { avaxToNanoAvax, toTransferableOutput } from "../utils"; -const testInputAmount = 1; +const testInputAmount = avaxToNanoAvax(1); const popPublicKeyHex = "0x94ab445df7ca4158cf63b66b6c463e9995b380441863f89231d3cd468ecdf7a96b080d3e96e20d74d9f2cd4f96d9dc40"; const popSignatureHex = @@ -53,7 +53,7 @@ describe("convertSubnetToL1Tx", () => { proofOfPossession: popSignatureHex, }, weight: 12345n, - initialBalanceInAvax: 0.123, + initialBalanceInAvax: avaxToNanoAvax(0.123), // 0.123 AVAX = 123_000_000 nAVAX remainingBalanceOwner: { addresses: [account2.getXPAddress("P", "fuji")], threshold: 1, @@ -70,7 +70,7 @@ describe("convertSubnetToL1Tx", () => { proofOfPossession: popSignatureHex, }, weight: 12345n, - initialBalanceInAvax: 0.456, + initialBalanceInAvax: avaxToNanoAvax(0.456), // 0.456 AVAX = 456_000_000_000_000 nAVAX remainingBalanceOwner: { addresses: [account2.getXPAddress("P", "fuji")], threshold: 1, @@ -106,16 +106,15 @@ describe("convertSubnetToL1Tx", () => { feeState().price ); const l1ValidatorBurnedFees = l1Validators.reduce( - (acc, v) => acc + avaxToNanoAvax(v.initialBalanceInAvax), + (acc, v) => acc + v.initialBalanceInAvax, 0n ); const totalBurnedFees = fee + l1ValidatorBurnedFees; - const expectedChangeAmount = - avaxToNanoAvax(testInputAmount) - totalBurnedFees; + const expectedChangeAmount = testInputAmount - totalBurnedFees; // expected change output testOutputs.push({ - amount: nanoAvaxToAvax(expectedChangeAmount), + amount: expectedChangeAmount, addresses: changeAddresses, }); @@ -146,7 +145,7 @@ describe("convertSubnetToL1Tx", () => { proofOfPossession: popSignatureHex, }, weight: 12345n, - initialBalanceInAvax: 0.123, + initialBalanceInAvax: avaxToNanoAvax(0.123), // 0.123 AVAX = 123_000_000 nAVAX remainingBalanceOwner: { addresses: [account2.getXPAddress("P", "fuji")], threshold: 1, @@ -163,7 +162,7 @@ describe("convertSubnetToL1Tx", () => { proofOfPossession: popSignatureHex, }, weight: 12345n, - initialBalanceInAvax: 0.456, + initialBalanceInAvax: avaxToNanoAvax(0.456), // 0.456 AVAX = 456_000_000 nAVAX remainingBalanceOwner: { addresses: [ account2.getXPAddress("P", "fuji"), @@ -212,7 +211,7 @@ describe("convertSubnetToL1Tx", () => { BigInt(a.weight) ); expect(e.getBalance().value(), "balance mismatch").toBe( - avaxToNanoAvax(a.initialBalanceInAvax) + a.initialBalanceInAvax ); expect( e.getDeactivationOwner().threshold.value(), @@ -267,7 +266,7 @@ describe("convertSubnetToL1Tx", () => { proofOfPossession: popSignatureHex, }, weight: 12345n, - initialBalanceInAvax: 0.123, + initialBalanceInAvax: avaxToNanoAvax(0.123), // 0.123 AVAX = 123_000_000 nAVAX remainingBalanceOwner: { addresses: [account2.getXPAddress("P", "fuji")], threshold: 1, diff --git a/client/src/methods/wallet/pChain/prepareConvertSubnetToL1Txn.ts b/client/src/methods/wallet/pChain/prepareConvertSubnetToL1Txn.ts index 762d82f3..7eba43b3 100644 --- a/client/src/methods/wallet/pChain/prepareConvertSubnetToL1Txn.ts +++ b/client/src/methods/wallet/pChain/prepareConvertSubnetToL1Txn.ts @@ -8,11 +8,7 @@ import { import { AvalancheWalletCoreClient } from "../../../clients/createAvalancheWalletCoreClient.js"; import { P_CHAIN_ALIAS } from "../../consts.js"; import { getContextFromURI } from "../getContextFromURI.js"; -import { - avaxToNanoAvax, - bech32AddressToBytes, - fetchCommonPVMTxParams, -} from "../utils.js"; +import { bech32AddressToBytes, fetchCommonPVMTxParams } from "../utils.js"; import { PrepareConvertSubnetToL1TxnParameters, PrepareConvertSubnetToL1TxnReturnType, @@ -33,6 +29,7 @@ import { * import { createAvalancheWalletClient } from "@avalanche-sdk/client/clients/createAvalancheWalletClient"; * import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; * import { avalanche } from "@avalanche-sdk/client/chains"; + * import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890"); * const walletClient = createAvalancheWalletClient({ @@ -49,7 +46,7 @@ import { * { * nodeId: "NodeID-7Xhw2mDxuDS44j42TCB6U5579esbSt3Lg", * weight: 1n, - * initialBalanceInAvax: 1, + * initialBalanceInAvax: avaxToNanoAvax(1), * nodePoP: { * publicKey: "0x1234567890123456789012345678901234567890", * proofOfPossession: "0x1234567890123456789012345678901234567890", @@ -93,7 +90,7 @@ export async function prepareConvertSubnetToL1Txn( FormattedL1Validator.fromNative( validator.nodeId, validator.weight, - avaxToNanoAvax(validator.initialBalanceInAvax), + validator.initialBalanceInAvax, new pvmSerial.ProofOfPossession( utils.hexToBuffer(validator.nodePoP.publicKey), utils.hexToBuffer(validator.nodePoP.proofOfPossession) diff --git a/client/src/methods/wallet/pChain/prepareCreateChainTxn.test.ts b/client/src/methods/wallet/pChain/prepareCreateChainTxn.test.ts index 9ad1b20a..6516e2ea 100644 --- a/client/src/methods/wallet/pChain/prepareCreateChainTxn.test.ts +++ b/client/src/methods/wallet/pChain/prepareCreateChainTxn.test.ts @@ -8,8 +8,8 @@ import { account1, account2, feeState } from "../fixtures/transactions/common"; import { getPChainMockServer } from "../fixtures/transactions/pChain"; import { checkOutputs } from "../fixtures/utils"; import { Output } from "../types/common"; -import { toTransferableOutput } from "../utils"; -const testInputAmount = 1; +import { avaxToNanoAvax, toTransferableOutput } from "../utils"; +const testInputAmount = avaxToNanoAvax(1); const pChainWorker = getPChainMockServer({}); @@ -60,7 +60,7 @@ describe("createChainTxn", () => { testContext.platformFeeConfig.weights, feeState().price ); - const expectedFeesInAvax = Number(fee) / 1e9; + const expectedFeesInAvax = fee; const expectedChangeAmount = testInputAmount - expectedFeesInAvax; // expected change output @@ -82,7 +82,7 @@ describe("createChainTxn", () => { expect( allInputAmounts - allOutputAmounts, "expected and actual burned amount mismatch" - ).toBe(BigInt(expectedFeesInAvax * 1e9)); + ).toBe(expectedFeesInAvax); }); it("should create correct chain details", async () => { diff --git a/client/src/methods/wallet/pChain/prepareCreateSubnetTxn.test.ts b/client/src/methods/wallet/pChain/prepareCreateSubnetTxn.test.ts index 18daf938..bd84545f 100644 --- a/client/src/methods/wallet/pChain/prepareCreateSubnetTxn.test.ts +++ b/client/src/methods/wallet/pChain/prepareCreateSubnetTxn.test.ts @@ -13,8 +13,8 @@ import { import { getPChainMockServer } from "../fixtures/transactions/pChain"; import { checkOutputs } from "../fixtures/utils"; import { Output } from "../types/common"; -import { toTransferableOutput } from "../utils"; -const testInputAmount = 1; +import { avaxToNanoAvax, toTransferableOutput } from "../utils"; +const testInputAmount = avaxToNanoAvax(1); const pChainWorker = getPChainMockServer({}); describe("createSubnetTx", () => { @@ -59,7 +59,7 @@ describe("createSubnetTx", () => { testContext.platformFeeConfig.weights, feeState().price ); - const expectedFeesInAvax = Number(fee) / 1e9; + const expectedFeesInAvax = fee; const expectedChangeAmount = testInputAmount - expectedFeesInAvax; // expected change output @@ -81,7 +81,7 @@ describe("createSubnetTx", () => { expect( allInputAmounts - allOutputAmounts, "expected and actual burned amount mismatch" - ).toBe(BigInt(expectedFeesInAvax * 1e9)); + ).toBe(expectedFeesInAvax); }); it("should create correct validator removal details", async () => { diff --git a/client/src/methods/wallet/pChain/prepareDisableL1ValidatorTxn.test.ts b/client/src/methods/wallet/pChain/prepareDisableL1ValidatorTxn.test.ts index 01357bb1..1d643cd6 100644 --- a/client/src/methods/wallet/pChain/prepareDisableL1ValidatorTxn.test.ts +++ b/client/src/methods/wallet/pChain/prepareDisableL1ValidatorTxn.test.ts @@ -3,14 +3,14 @@ import { afterAll, beforeAll, describe, expect, it } from "vitest"; import { PrepareDisableL1ValidatorTxnParameters } from "."; import { avalancheFuji } from "../../../chains"; import { createAvalancheWalletClient } from "../../../clients/createAvalancheWalletClient"; -import { getTxFromBytes } from "../../../utils"; +import { avaxToNanoAvax, getTxFromBytes } from "../../../utils"; import { testContext } from "../fixtures/testContext"; import { account1, account2, feeState } from "../fixtures/transactions/common"; import { getPChainMockServer } from "../fixtures/transactions/pChain"; import { checkOutputs } from "../fixtures/utils"; import { Output } from "../types/common"; import { toTransferableOutput } from "../utils"; -const testInputAmount = 1; +const testInputAmount = avaxToNanoAvax(1); const pChainWorker = getPChainMockServer({}); describe("prepareDisableL1ValidatorTxn", () => { @@ -54,7 +54,7 @@ describe("prepareDisableL1ValidatorTxn", () => { testContext.platformFeeConfig.weights, feeState().price ); - const expectedFeesInAvax = Number(fee) / 1e9; + const expectedFeesInAvax = fee; const expectedChangeAmount = testInputAmount - expectedFeesInAvax; // expected change output @@ -76,7 +76,7 @@ describe("prepareDisableL1ValidatorTxn", () => { expect( allInputAmounts - allOutputAmounts, "expected and actual burned amount mismatch" - ).toBe(BigInt(expectedFeesInAvax * 1e9)); + ).toBe(expectedFeesInAvax); }); it("should create correct validator removal details", async () => { diff --git a/client/src/methods/wallet/pChain/prepareExportTxn.test.ts b/client/src/methods/wallet/pChain/prepareExportTxn.test.ts index 86fdc0e7..aeb97d17 100644 --- a/client/src/methods/wallet/pChain/prepareExportTxn.test.ts +++ b/client/src/methods/wallet/pChain/prepareExportTxn.test.ts @@ -17,11 +17,10 @@ import { Output } from "../types/common"; import { avaxToNanoAvax, getChainIdFromAlias, - nanoAvaxToAvax, toTransferableOutput, } from "../utils"; -const testInputAmount = 1; +const testInputAmount = avaxToNanoAvax(1); const pChainWorker = getPChainMockServer({}); @@ -51,8 +50,8 @@ describe("prepareExportTxn", () => { const receiverAddresses2 = [account4.getXPAddress("P", "fuji")]; const changeAddresses = [account2.getXPAddress("P", "fuji")]; - const testOutputAmount = 0.1234; - const testOutputAmount2 = 0.2345; + const testOutputAmount = avaxToNanoAvax(0.1234); + const testOutputAmount2 = avaxToNanoAvax(0.2345); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -82,14 +81,11 @@ describe("prepareExportTxn", () => { feeState().price ); const expectedChangeAmount = - avaxToNanoAvax(testInputAmount) - - avaxToNanoAvax(testOutputAmount) - - avaxToNanoAvax(testOutputAmount2) - - fee; + testInputAmount - testOutputAmount - testOutputAmount2 - fee; // expected change output testOutputs.push({ - amount: nanoAvaxToAvax(expectedChangeAmount), + amount: expectedChangeAmount, addresses: changeAddresses, }); @@ -117,7 +113,7 @@ describe("prepareExportTxn", () => { ]; const changeAddresses = [account2.getXPAddress("P", "fuji")]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -172,7 +168,7 @@ describe("prepareExportTxn", () => { ]; const changeAddresses = [account2.getXPAddress("P", "fuji")]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const testOutputs: Output[] = [ { amount: testOutputAmount, diff --git a/client/src/methods/wallet/pChain/prepareExportTxn.ts b/client/src/methods/wallet/pChain/prepareExportTxn.ts index 693d3be3..f44644e9 100644 --- a/client/src/methods/wallet/pChain/prepareExportTxn.ts +++ b/client/src/methods/wallet/pChain/prepareExportTxn.ts @@ -27,6 +27,7 @@ import { * import { createAvalancheWalletClient } from "@avalanche-sdk/client/clients/createAvalancheWalletClient"; * import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; * import { avalanche } from "@avalanche-sdk/client/chains"; + * import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890"); * const walletClient = createAvalancheWalletClient({ @@ -38,7 +39,7 @@ import { * destinationChain: "P", * exportedOutputs: [{ * addresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"], - * amount: 0.0001, + * amount: avaxToNanoAvax(0.0001), * }], * }); */ diff --git a/client/src/methods/wallet/pChain/prepareImportTxn.test.ts b/client/src/methods/wallet/pChain/prepareImportTxn.test.ts index 4086f65e..ece08690 100644 --- a/client/src/methods/wallet/pChain/prepareImportTxn.test.ts +++ b/client/src/methods/wallet/pChain/prepareImportTxn.test.ts @@ -11,12 +11,11 @@ import { Output } from "../types/common"; import { avaxToNanoAvax, getChainIdFromAlias, - nanoAvaxToAvax, toTransferableOutput, } from "../utils"; import { ImportedOutput } from "../xChain/types/prepareImportTxn"; -const testInputAmount = 1; +const testInputAmount = avaxToNanoAvax(1); const pChainWorker = getPChainMockServer({}); @@ -46,7 +45,7 @@ describe("prepareImportTxn", () => { const importedOutput: ImportedOutput = { addresses: receiverAddresses, - locktime: 1000, + locktime: 1000n, threshold: 1, }; const testOutputs: Output[] = []; @@ -68,11 +67,11 @@ describe("prepareImportTxn", () => { ); // imported output as the only change output - const testImportedOutputAmount = avaxToNanoAvax(testInputAmount) - fee; + const testImportedOutputAmount = testInputAmount - fee; testOutputs.push({ - amount: nanoAvaxToAvax(testImportedOutputAmount), + amount: testImportedOutputAmount, addresses: importedOutput.addresses, - locktime: importedOutput.locktime ?? 0, + locktime: importedOutput.locktime ?? 0n, threshold: importedOutput.threshold ?? 1, }); @@ -101,7 +100,7 @@ describe("prepareImportTxn", () => { const importedOutput: ImportedOutput = { addresses: receiverAddresses, - locktime: 1000, + locktime: 1000n, threshold: 1, }; const mockTxParams: PrepareImportTxnParameters = { @@ -126,7 +125,7 @@ describe("prepareImportTxn", () => { const importedOutput: ImportedOutput = { addresses: receiverAddresses, - locktime: 1000, + locktime: 1000n, threshold: 1, }; const mockTxParams: PrepareImportTxnParameters = { diff --git a/client/src/methods/wallet/pChain/prepareIncreaseL1ValidatorBalanceTxn.test.ts b/client/src/methods/wallet/pChain/prepareIncreaseL1ValidatorBalanceTxn.test.ts index fcf89a7b..5c7b3d48 100644 --- a/client/src/methods/wallet/pChain/prepareIncreaseL1ValidatorBalanceTxn.test.ts +++ b/client/src/methods/wallet/pChain/prepareIncreaseL1ValidatorBalanceTxn.test.ts @@ -13,7 +13,7 @@ import { import { getPChainMockServer } from "../fixtures/transactions/pChain"; import { checkOutputs } from "../fixtures/utils"; import { Output } from "../types/common"; -import { avaxToNanoAvax, nanoAvaxToAvax, toTransferableOutput } from "../utils"; +import { avaxToNanoAvax, toTransferableOutput } from "../utils"; const testInputAmount = 1; @@ -42,7 +42,7 @@ describe("prepareIncreaseL1ValidatorBalanceTxn", () => { const mockTxParams: PrepareIncreaseL1ValidatorBalanceTxnParameters = { changeAddresses, - balanceInAvax: 0.123, + balanceInAvax: avaxToNanoAvax(0.123), validationId: "FFqpTFRtYPDgHFCEd2n8KQQVnH2FC9j9vdjU5Vx1mHTCkYkAu", context: testContext, }; @@ -61,13 +61,13 @@ describe("prepareIncreaseL1ValidatorBalanceTxn", () => { testContext.platformFeeConfig.weights, feeState().price ); - const totalBurnedAmount = fee + avaxToNanoAvax(mockTxParams.balanceInAvax); + const totalBurnedAmount = fee + mockTxParams.balanceInAvax; const expectedChangeAmount = avaxToNanoAvax(testInputAmount) - totalBurnedAmount; // expected change output testOutputs.push({ - amount: nanoAvaxToAvax(expectedChangeAmount), + amount: expectedChangeAmount, addresses: changeAddresses, }); @@ -96,7 +96,7 @@ describe("prepareIncreaseL1ValidatorBalanceTxn", () => { const mockTxParams: PrepareIncreaseL1ValidatorBalanceTxnParameters = { changeAddresses, - balanceInAvax: 0.123, + balanceInAvax: avaxToNanoAvax(0.123), validationId: "FFqpTFRtYPDgHFCEd2n8KQQVnH2FC9j9vdjU5Vx1mHTCkYkAu", context: testContext, }; @@ -111,7 +111,7 @@ describe("prepareIncreaseL1ValidatorBalanceTxn", () => { txnRequest.tx.getTx() as pvmSerial.IncreaseL1ValidatorBalanceTx ).balance.value(), "balance mismatch" - ).toBe(avaxToNanoAvax(mockTxParams.balanceInAvax)); + ).toBe(mockTxParams.balanceInAvax); expect( utils.base58check.encode( ( @@ -127,7 +127,7 @@ describe("prepareIncreaseL1ValidatorBalanceTxn", () => { const mockTxParams: PrepareIncreaseL1ValidatorBalanceTxnParameters = { changeAddresses, - balanceInAvax: 0.123, + balanceInAvax: avaxToNanoAvax(0.123), validationId: "FFqpTFRtYPDgHFCEd2n8KQQVnH2FC9j9vdjU5Vx1mHTCkYkAu", context: testContext, }; diff --git a/client/src/methods/wallet/pChain/prepareIncreaseL1ValidatorBalanceTxn.ts b/client/src/methods/wallet/pChain/prepareIncreaseL1ValidatorBalanceTxn.ts index 1641f160..a7b25683 100644 --- a/client/src/methods/wallet/pChain/prepareIncreaseL1ValidatorBalanceTxn.ts +++ b/client/src/methods/wallet/pChain/prepareIncreaseL1ValidatorBalanceTxn.ts @@ -2,7 +2,7 @@ import { pvm, pvmSerial } from "@avalabs/avalanchejs"; import { AvalancheWalletCoreClient } from "../../../clients/createAvalancheWalletCoreClient.js"; import { P_CHAIN_ALIAS } from "../../consts.js"; import { getContextFromURI } from "../getContextFromURI.js"; -import { avaxToNanoAvax, fetchCommonPVMTxParams } from "../utils.js"; +import { fetchCommonPVMTxParams } from "../utils.js"; import { PrepareIncreaseL1ValidatorBalanceTxnParameters, PrepareIncreaseL1ValidatorBalanceTxnReturnType, @@ -23,6 +23,7 @@ import { * import { createAvalancheWalletClient } from "@avalanche-sdk/client/clients/createAvalancheWalletClient"; * import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; * import { avalanche } from "@avalanche-sdk/client/chains"; + * import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890"); * const walletClient = createAvalancheWalletClient({ @@ -31,7 +32,7 @@ import { * }); * * const pChainIncreaseL1ValidatorBalanceTxnRequest = await prepareIncreaseL1ValidatorBalanceTxn(walletClient, { - * balanceInAvax: 1, + * balanceInAvax: avaxToNanoAvax(1), * validationId: "11111111111111111111111111111111LpoYY", * }); * @@ -51,7 +52,7 @@ export async function prepareIncreaseL1ValidatorBalanceTxn( const unsignedTx = pvm.newIncreaseL1ValidatorBalanceTx( { ...commonTxParams, - balance: avaxToNanoAvax(params.balanceInAvax), + balance: params.balanceInAvax, validationId: params.validationId, }, context diff --git a/client/src/methods/wallet/pChain/prepareRegisterL1ValidatorTxn.test.ts b/client/src/methods/wallet/pChain/prepareRegisterL1ValidatorTxn.test.ts index a6905a07..1285cd8e 100644 --- a/client/src/methods/wallet/pChain/prepareRegisterL1ValidatorTxn.test.ts +++ b/client/src/methods/wallet/pChain/prepareRegisterL1ValidatorTxn.test.ts @@ -15,9 +15,9 @@ import { import { getPChainMockServer } from "../fixtures/transactions/pChain"; import { checkOutputs } from "../fixtures/utils"; import { Output } from "../types/common"; -import { avaxToNanoAvax, nanoAvaxToAvax, toTransferableOutput } from "../utils"; +import { avaxToNanoAvax, toTransferableOutput } from "../utils"; -const testInputAmount = 1; +const testInputAmount = avaxToNanoAvax(1); const pChainWorker = getPChainMockServer({}); @@ -44,7 +44,7 @@ describe("prepareRegisterL1ValidatorTxn", () => { const mockTxParams: PrepareRegisterL1ValidatorTxnParameters = { changeAddresses, - initialBalanceInAvax: 0.123, + initialBalanceInAvax: avaxToNanoAvax(0.123), blsSignature: popSignatureHex, message: signedWarpMsgRegisterL1ValidatorHex, context: testContext, @@ -64,14 +64,12 @@ describe("prepareRegisterL1ValidatorTxn", () => { testContext.platformFeeConfig.weights, feeState().price ); - const totalBurnedAmount = - fee + avaxToNanoAvax(mockTxParams.initialBalanceInAvax); - const expectedChangeAmount = - avaxToNanoAvax(testInputAmount) - totalBurnedAmount; + const totalBurnedAmount = fee + mockTxParams.initialBalanceInAvax; + const expectedChangeAmount = testInputAmount - totalBurnedAmount; // expected change output testOutputs.push({ - amount: nanoAvaxToAvax(expectedChangeAmount), + amount: expectedChangeAmount, addresses: changeAddresses, }); @@ -102,7 +100,7 @@ describe("prepareRegisterL1ValidatorTxn", () => { const mockTxParams: PrepareRegisterL1ValidatorTxnParameters = { changeAddresses, - initialBalanceInAvax: 0.123, + initialBalanceInAvax: avaxToNanoAvax(0.123), blsSignature: popSignatureHex, message: signedWarpMsgRegisterL1ValidatorHex, context: testContext, @@ -117,7 +115,7 @@ describe("prepareRegisterL1ValidatorTxn", () => { txnRequest.tx.getTx() as pvmSerial.RegisterL1ValidatorTx ).balance.value(), "balance mismatch" - ).toBe(avaxToNanoAvax(mockTxParams.initialBalanceInAvax)); + ).toBe(mockTxParams.initialBalanceInAvax); expect( utils.bufferToHex( ( @@ -139,7 +137,7 @@ describe("prepareRegisterL1ValidatorTxn", () => { const mockTxParams: PrepareRegisterL1ValidatorTxnParameters = { changeAddresses, - initialBalanceInAvax: 0.123, + initialBalanceInAvax: avaxToNanoAvax(0.123), blsSignature: popSignatureHex, message: signedWarpMsgRegisterL1ValidatorHex, context: testContext, diff --git a/client/src/methods/wallet/pChain/prepareRegisterL1ValidatorTxn.ts b/client/src/methods/wallet/pChain/prepareRegisterL1ValidatorTxn.ts index b94739cc..5637194d 100644 --- a/client/src/methods/wallet/pChain/prepareRegisterL1ValidatorTxn.ts +++ b/client/src/methods/wallet/pChain/prepareRegisterL1ValidatorTxn.ts @@ -2,7 +2,7 @@ import { pvm, pvmSerial, utils } from "@avalabs/avalanchejs"; import { AvalancheWalletCoreClient } from "../../../clients/createAvalancheWalletCoreClient.js"; import { P_CHAIN_ALIAS } from "../../consts.js"; import { getContextFromURI } from "../getContextFromURI.js"; -import { avaxToNanoAvax, fetchCommonPVMTxParams } from "../utils.js"; +import { fetchCommonPVMTxParams } from "../utils.js"; import { PrepareRegisterL1ValidatorTxnParameters, PrepareRegisterL1ValidatorTxnReturnType, @@ -23,6 +23,7 @@ import { * import { createAvalancheWalletClient } from "@avalanche-sdk/client/clients/createAvalancheWalletClient"; * import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; * import { avalanche } from "@avalanche-sdk/client/chains"; + * import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; * * const account = privateKeyToAvalancheAccount("0x1234567890123456789012345678901234567890"); * const walletClient = createAvalancheWalletClient({ @@ -31,7 +32,7 @@ import { * }); * * const pChainRegisterL1ValidatorTxnRequest = await prepareRegisterL1ValidatorTxn(walletClient, { - * initialBalanceInAvax: 1, + * initialBalanceInAvax: avaxToNanoAvax(1), * blsSignature: "0x1234567890123456789012345678901234567890", * message: "0x1234567890123456789012345678901234567890", * }); @@ -52,7 +53,7 @@ export async function prepareRegisterL1ValidatorTxn( const unsignedTx = pvm.newRegisterL1ValidatorTx( { ...commonTxParams, - balance: avaxToNanoAvax(params.initialBalanceInAvax), + balance: params.initialBalanceInAvax, blsSignature: utils.hexToBuffer(params.blsSignature), message: utils.hexToBuffer(params.message), }, diff --git a/client/src/methods/wallet/pChain/prepareRemoveSubnetValidatorTxn.test.ts b/client/src/methods/wallet/pChain/prepareRemoveSubnetValidatorTxn.test.ts index 4a49cb87..2190690d 100644 --- a/client/src/methods/wallet/pChain/prepareRemoveSubnetValidatorTxn.test.ts +++ b/client/src/methods/wallet/pChain/prepareRemoveSubnetValidatorTxn.test.ts @@ -8,8 +8,8 @@ import { account1, account2, feeState } from "../fixtures/transactions/common"; import { getPChainMockServer } from "../fixtures/transactions/pChain"; import { checkOutputs } from "../fixtures/utils"; import { Output } from "../types/common"; -import { toTransferableOutput } from "../utils"; -const testInputAmount = 1; +import { avaxToNanoAvax, toTransferableOutput } from "../utils"; +const testInputAmount = avaxToNanoAvax(1); const pChainWorker = getPChainMockServer({}); @@ -54,7 +54,7 @@ describe("prepareRemoveSubnetValidatorTxn", () => { testContext.platformFeeConfig.weights, feeState().price ); - const expectedFeesInAvax = Number(fee) / 1e9; + const expectedFeesInAvax = fee; const expectedChangeAmount = testInputAmount - expectedFeesInAvax; // expected change output @@ -76,7 +76,7 @@ describe("prepareRemoveSubnetValidatorTxn", () => { expect( allInputAmounts - allOutputAmounts, "expected and actual burned amount mismatch" - ).toBe(BigInt(expectedFeesInAvax * 1e9)); + ).toBe(expectedFeesInAvax); }); it("should create correct validator removal details", async () => { diff --git a/client/src/methods/wallet/pChain/prepareSetL1ValidatorWeightTxn.test.ts b/client/src/methods/wallet/pChain/prepareSetL1ValidatorWeightTxn.test.ts index cadb93f7..7c3d6a68 100644 --- a/client/src/methods/wallet/pChain/prepareSetL1ValidatorWeightTxn.test.ts +++ b/client/src/methods/wallet/pChain/prepareSetL1ValidatorWeightTxn.test.ts @@ -14,9 +14,9 @@ import { import { getPChainMockServer } from "../fixtures/transactions/pChain"; import { checkOutputs } from "../fixtures/utils"; import { Output } from "../types/common"; -import { avaxToNanoAvax, nanoAvaxToAvax, toTransferableOutput } from "../utils"; +import { avaxToNanoAvax, toTransferableOutput } from "../utils"; -const testInputAmount = 1; +const testInputAmount = avaxToNanoAvax(1); const pChainWorker = getPChainMockServer({}); @@ -60,11 +60,11 @@ describe("prepareSetL1ValidatorWeightTxn", () => { testContext.platformFeeConfig.weights, feeState().price ); - const expectedChangeAmount = avaxToNanoAvax(testInputAmount) - fee; + const expectedChangeAmount = testInputAmount - fee; // expected change output testOutputs.push({ - amount: nanoAvaxToAvax(expectedChangeAmount), + amount: expectedChangeAmount, addresses: changeAddresses, }); diff --git a/client/src/methods/wallet/pChain/types/prepareAddPermissionlessDelegatorTxn.ts b/client/src/methods/wallet/pChain/types/prepareAddPermissionlessDelegatorTxn.ts index 55dc16bf..8af1382e 100644 --- a/client/src/methods/wallet/pChain/types/prepareAddPermissionlessDelegatorTxn.ts +++ b/client/src/methods/wallet/pChain/types/prepareAddPermissionlessDelegatorTxn.ts @@ -12,7 +12,7 @@ export type PrepareAddPermissionlessDelegatorTxnParameters = CommonTxParams & { * consolidated into a single output and owned by the * `changeAddresses` or the `fromAddresses` array. */ - stakeInAvax: number; + stakeInAvax: bigint; /** * NodeID of the validator to delegate AVAX to. */ @@ -21,7 +21,7 @@ export type PrepareAddPermissionlessDelegatorTxnParameters = CommonTxParams & { * The Unix time in seconds when the delegation stops * (and staked AVAX is returned). */ - end: number; + end: bigint; /** * The addresses which will receive the rewards from the delegated stake. * Given addresses will share the reward UTXO. @@ -38,7 +38,7 @@ export type PrepareAddPermissionlessDelegatorTxnParameters = CommonTxParams & { * can be spent, once they are created after the staking period ends. * @default 0 */ - locktime?: number; + locktime?: bigint; /** * Optional. The context to use for the transaction. If not provided, the context will be fetched. */ diff --git a/client/src/methods/wallet/pChain/types/prepareAddPermissionlessValidatorTxn.ts b/client/src/methods/wallet/pChain/types/prepareAddPermissionlessValidatorTxn.ts index 57217660..c82b6a0b 100644 --- a/client/src/methods/wallet/pChain/types/prepareAddPermissionlessValidatorTxn.ts +++ b/client/src/methods/wallet/pChain/types/prepareAddPermissionlessValidatorTxn.ts @@ -13,7 +13,7 @@ export type PrepareAddPermissionlessValidatorTxnParameters = CommonTxParams & { * The staked outputs will be consolidated into a single output * and owned by the `changeAddresses` or the `fromAddresses` array. */ - stakeInAvax: number; + stakeInAvax: bigint; /** * The NodeID of the validator being added. */ @@ -30,7 +30,7 @@ export type PrepareAddPermissionlessValidatorTxnParameters = CommonTxParams & { * The Unix time in seconds when the validator will be removed from staking set. * (and staked AVAX is returned). */ - end: number; + end: bigint; /** * The addresses which will receive the validator rewards. Given addresses * will share the reward UTXO. @@ -59,7 +59,7 @@ export type PrepareAddPermissionlessValidatorTxnParameters = CommonTxParams & { * (both validator and delegator fee rewards). * @default 0 */ - locktime?: number; + locktime?: bigint; /** * Optional. The context to use for the transaction. If not provided, the context will be fetched. */ diff --git a/client/src/methods/wallet/pChain/types/prepareConvertSubnetToL1Txn.ts b/client/src/methods/wallet/pChain/types/prepareConvertSubnetToL1Txn.ts index 0c3bcf5c..419db736 100644 --- a/client/src/methods/wallet/pChain/types/prepareConvertSubnetToL1Txn.ts +++ b/client/src/methods/wallet/pChain/types/prepareConvertSubnetToL1Txn.ts @@ -76,10 +76,10 @@ export type L1Validator = { */ weight: bigint; /** - * Initial balance (in AVAX) of the L1 validator required for paying + * Initial balance (in nAVAX) of the L1 validator required for paying * a contiguous fee to the Primary Network to validate the L1. */ - initialBalanceInAvax: number; + initialBalanceInAvax: bigint; /** * Owner information to which the remaining L1 validator balance will be assigned, in case * the validator is removed or disabled from the L1 validator set. diff --git a/client/src/methods/wallet/pChain/types/prepareImportTxn.ts b/client/src/methods/wallet/pChain/types/prepareImportTxn.ts index 9ac84cd9..d814d63c 100644 --- a/client/src/methods/wallet/pChain/types/prepareImportTxn.ts +++ b/client/src/methods/wallet/pChain/types/prepareImportTxn.ts @@ -19,7 +19,7 @@ export type ImportedOutput = { /** * Optional. Timestamp in seconds after which this UTXO can be consumed. */ - locktime?: number; + locktime?: bigint; /** * Optional. The number of signatures required out of the total `addresses` * to spend the imported output. diff --git a/client/src/methods/wallet/pChain/types/prepareIncreaseL1ValidatorBalanceTxn.ts b/client/src/methods/wallet/pChain/types/prepareIncreaseL1ValidatorBalanceTxn.ts index 1c362f60..743aaa6c 100644 --- a/client/src/methods/wallet/pChain/types/prepareIncreaseL1ValidatorBalanceTxn.ts +++ b/client/src/methods/wallet/pChain/types/prepareIncreaseL1ValidatorBalanceTxn.ts @@ -7,9 +7,9 @@ import { CommonTxParams } from "../../types/common"; export type PrepareIncreaseL1ValidatorBalanceTxnParameters = CommonTxParams & { /** - * Amount of AVAX to increase the L1 validator balance by. + * Amount of AVAX to increase the L1 validator balance by (in nano AVAX). */ - balanceInAvax: number; + balanceInAvax: bigint; /** * Validation ID of the L1 validator. */ diff --git a/client/src/methods/wallet/pChain/types/prepareRegisterL1ValidatorTxn.ts b/client/src/methods/wallet/pChain/types/prepareRegisterL1ValidatorTxn.ts index b9b9b2cb..256f1be3 100644 --- a/client/src/methods/wallet/pChain/types/prepareRegisterL1ValidatorTxn.ts +++ b/client/src/methods/wallet/pChain/types/prepareRegisterL1ValidatorTxn.ts @@ -7,11 +7,11 @@ import { CommonTxParams } from "../../types/common.js"; export type PrepareRegisterL1ValidatorTxnParameters = CommonTxParams & { /** - * Initial balance (in AVAX) of the L1 validator getting registered, + * Initial balance (in nano AVAX) of the L1 validator getting registered, * Balance is required for paying a contiguous fee to the Primary * Network to validate the L1. */ - initialBalanceInAvax: number; + initialBalanceInAvax: bigint; /** * BLS signature of the validator. */ diff --git a/client/src/methods/wallet/transferUtils/transferCtoCChain.ts b/client/src/methods/wallet/transferUtils/transferCtoCChain.ts index a349d05f..68a616b4 100644 --- a/client/src/methods/wallet/transferUtils/transferCtoCChain.ts +++ b/client/src/methods/wallet/transferUtils/transferCtoCChain.ts @@ -1,4 +1,4 @@ -import { Address, formatEther, parseEther } from "viem"; +import { Address } from "viem"; import { estimateGas, getBalance, @@ -28,30 +28,23 @@ export async function transferCtoCChain( params.from || (await getEVMAddressFromAccountOrClient(client, params.account)); - const [estimateGasResponse, gasPrice, balance] = await Promise.all([ - formatEther( - await estimateGas(client, { - to: params.to as Address, - value: parseEther(params.amount.toString()), - account: currentAccountEVMAddress as Address, - } as any) - ), - formatEther(await getGasPrice(client)), - formatEther( - await getBalance(client, { - address: currentAccountEVMAddress as Address, - }) - ), + const [estimateGasResponse, gasPrice, balanceInWei] = await Promise.all([ + await estimateGas(client, { + to: params.to as Address, + value: params.amount, + account: currentAccountEVMAddress as Address, + } as any), + await getGasPrice(client), + await getBalance(client, { + address: currentAccountEVMAddress as Address, + }), ]); - const estimatedFee = Number(estimateGasResponse) * Number(gasPrice); + const estimatedFee = estimateGasResponse * gasPrice; - if ( - Number(balance) < Number(estimatedFee) || - Number(balance) < Number(params.amount) - ) { + if (balanceInWei < estimatedFee || balanceInWei < params.amount) { throw new Error( - `Insufficient balance: ${estimatedFee} AVAX is required, but only ${balance} AVAX is available` + `Insufficient balance: ${estimatedFee} AVAX (in wei) is required, but only ${balanceInWei} AVAX (in wei) is available` ); } @@ -63,13 +56,13 @@ export async function transferCtoCChain( if (!isAccountProvided) { txnHash = await sendTransaction(client, { to: params.to as Address, - value: parseEther(params.amount.toString()), + value: params.amount, account: currentAccountEVMAddress as Address, } as any); } else { const request = await prepareTransactionRequest(client, { to: params.to as Address, - value: parseEther(params.amount.toString()), + value: params.amount, account: currentAccountEVMAddress as Address, } as any); diff --git a/client/src/methods/wallet/transferUtils/transferCtoPChain.ts b/client/src/methods/wallet/transferUtils/transferCtoPChain.ts index ad44c047..7c52364f 100644 --- a/client/src/methods/wallet/transferUtils/transferCtoPChain.ts +++ b/client/src/methods/wallet/transferUtils/transferCtoPChain.ts @@ -1,5 +1,4 @@ import { evm, pvm, utils } from "@avalabs/avalanchejs"; -import { formatEther } from "viem"; import { getBalance, getTransactionCount } from "viem/actions"; import { AvalancheWalletCoreClient } from "../../../clients/createAvalancheWalletCoreClient.js"; import { P_CHAIN_ALIAS } from "../../consts.js"; @@ -11,12 +10,11 @@ import { prepareImportTxn as prepareImportTxnPChain } from "../pChain/prepareImp import { sendXPTransaction } from "../sendXPTransaction.js"; import { SendParameters, SendReturnType } from "../types/send.js"; import { - avaxToNanoAvax, bech32AddressToBytes, getBech32AddressFromAccountOrClient, getChainIdFromAlias, getEVMAddressFromAccountOrClient, - nanoAvaxToAvax, + weiToNanoAvax, } from "../utils.js"; import { waitForTxn } from "../waitForTxn.js"; @@ -49,41 +47,44 @@ export async function transferCtoPChain( } // Prepare the C chain export txn and get the fee for each - const [cChainExportTxnRequest, pChainFeeState, baseFee, txCount, balance] = - await Promise.all([ - prepareExportTxnCChain(client, { - destinationChain: "P", - fromAddress: currentAccountEVMAddress, - exportedOutput: { - addresses: [currentAccountPChainBech32Address], - amount: params.amount, - }, - context, - }), - getFeeState(client.pChainClient), - getBaseFee(client), - getTransactionCount(client, { - address: `0x${utils.strip0x(currentAccountEVMAddress)}`, - }), - formatEther( - await getBalance(client, { - address: `0x${utils.strip0x(currentAccountEVMAddress)}`, - }) - ), - ]); + const [ + cChainExportTxnRequest, + pChainFeeState, + baseFee, + txCount, + balanceInWei, + ] = await Promise.all([ + prepareExportTxnCChain(client, { + destinationChain: "P", + fromAddress: currentAccountEVMAddress, + exportedOutput: { + addresses: [currentAccountPChainBech32Address], + amount: weiToNanoAvax(params.amount), + }, + context, + }), + getFeeState(client.pChainClient), + getBaseFee(client), + getTransactionCount(client, { + address: `0x${utils.strip0x(currentAccountEVMAddress)}`, + }), + await getBalance(client, { + address: `0x${utils.strip0x(currentAccountEVMAddress)}`, + }), + ]); // Check if user has enough balance - if (Number(balance) < params.amount) { + if (balanceInWei < params.amount) { throw new Error( - `Insufficient balance: ${params.amount} AVAX is required, but only ${balance} AVAX is available` + `Insufficient balance: ${params.amount} ${params.token} (in wei) is required, but only ${balanceInWei} ${params.token} (in wei) is available` ); } // Calculate the fee for the C chain export txn - const cChainExportTxnFee = evm.estimateExportCost( + const cChainExportTxnFeeInNanoAvax = evm.estimateExportCost( context, BigInt(baseFee), - avaxToNanoAvax(params.amount), + weiToNanoAvax(params.amount), getChainIdFromAlias("P", context.networkID), utils.hexToBuffer(currentAccountEVMAddress), [bech32AddressToBytes(params.to)], @@ -91,13 +92,11 @@ export async function transferCtoPChain( ); // Check if the fee for the C chain export txn is too high - if (cChainExportTxnFee > avaxToNanoAvax(params.amount)) { + if (cChainExportTxnFeeInNanoAvax > weiToNanoAvax(params.amount)) { throw new Error( - `Transfer amount is too low: ${nanoAvaxToAvax( - cChainExportTxnFee - )} AVAX Fee is required for C chain export txn, but only ${ + `Transfer amount is too low: ${cChainExportTxnFeeInNanoAvax} nAVAX Fee is required for C chain export txn, but only ${weiToNanoAvax( params.amount - } AVAX is being transferred, try sending a higher amount.` + )} nAVAX is being transferred, try sending a higher amount.` ); } @@ -118,19 +117,18 @@ export async function transferCtoPChain( }); // Calculate the fee for the P chain import txn - const pChainImportTxnFee = pvm.calculateFee( + const pChainImportTxnFeeInNanoAvax = pvm.calculateFee( pChainImportTxnRequest.tx.getTx(), context.platformFeeConfig.weights, pChainFeeState.price ); // Calculate the total fee - const totalFee = pChainImportTxnFee + cChainExportTxnFee; - if (totalFee > avaxToNanoAvax(params.amount)) { + const totalFeeInNanoAvax = + pChainImportTxnFeeInNanoAvax + cChainExportTxnFeeInNanoAvax; + if (totalFeeInNanoAvax > weiToNanoAvax(params.amount)) { throw new Error( - `Transfer amount is too low: ${nanoAvaxToAvax( - pChainImportTxnFee - )} AVAX Fee is required for P chain import txn, + `Transfer amount is too low: ${pChainImportTxnFeeInNanoAvax} nAVAX Fee is required for P chain import txn, try sending a higher amount. C chain export txn hash: ${sendCChainExportTxn.txHash}` ); diff --git a/client/src/methods/wallet/transferUtils/transferPtoCChain.ts b/client/src/methods/wallet/transferUtils/transferPtoCChain.ts index 5f4fa540..ec448ed6 100644 --- a/client/src/methods/wallet/transferUtils/transferPtoCChain.ts +++ b/client/src/methods/wallet/transferUtils/transferPtoCChain.ts @@ -11,9 +11,8 @@ import { prepareExportTxn as prepareExportTxnPChain } from "../pChain/prepareExp import { sendXPTransaction } from "../sendXPTransaction.js"; import { SendParameters, SendReturnType } from "../types/send.js"; import { - avaxToNanoAvax, getBech32AddressFromAccountOrClient, - nanoAvaxToAvax, + weiToNanoAvax, } from "../utils.js"; import { waitForTxn } from "../waitForTxn.js"; @@ -59,13 +58,13 @@ export async function transferPtoCChain( } // Prepare the P chain export txn and C chain import txn and get the fee for each - const [pChainExportTxnRequest, pChainFeeState, baseFee, balance] = + const [pChainExportTxnRequest, pChainFeeState, baseFee, balanceInNanoAvax] = await Promise.all([ await prepareExportTxnPChain(client, { exportedOutputs: [ { addresses: [currentAccountCChainBech32Address], - amount: params.amount, + amount: weiToNanoAvax(params.amount), }, ], destinationChain: "C", @@ -73,36 +72,34 @@ export async function transferPtoCChain( }), getFeeState(client.pChainClient), getBaseFee(client), - nanoAvaxToAvax( - ( - await getBalance(client.pChainClient, { - addresses: [currentAccountPChainBech32Address], - }) - ).balance - ), + ( + await getBalance(client.pChainClient, { + addresses: [currentAccountPChainBech32Address], + }) + ).balance, ]); // Check if user has enough balance - if (Number(balance) < params.amount) { + if (balanceInNanoAvax < weiToNanoAvax(params.amount)) { throw new Error( - `Insufficient balance: ${params.amount} AVAX is required, but only ${balance} AVAX is available` + `Insufficient balance: ${weiToNanoAvax( + params.amount + )} nAVAX is required, but only ${balanceInNanoAvax} nAVAX is available` ); } // Calculate the fee for the P chain import txn - const pChainExportTxnFee = pvm.calculateFee( + const pChainExportTxnFeeInNanoAvax = pvm.calculateFee( pChainExportTxnRequest.tx.getTx(), context.platformFeeConfig.weights, pChainFeeState.price ); - if (pChainExportTxnFee > avaxToNanoAvax(params.amount)) { + if (pChainExportTxnFeeInNanoAvax > weiToNanoAvax(params.amount)) { throw new Error( - `Transfer amount is too low: ${nanoAvaxToAvax( - pChainExportTxnFee - )} AVAX Fee is required for P chain export txn, but only ${ + `Transfer amount is too low: ${pChainExportTxnFeeInNanoAvax} nAVAX Fee is required for P chain export txn, but only ${weiToNanoAvax( params.amount - } AVAX is being transferred, try sending a higher amount` + )} nAVAX is being transferred, try sending a higher amount` ); } @@ -122,16 +119,15 @@ export async function transferPtoCChain( }); // Calculate the fee for the C chain import txn - const cChainImportTxnFee = + const cChainImportTxnFeeInNanoAvax = BigInt(baseFee) * BigInt(utils.costCorethTx(cChainImportTxnRequest.tx)); // Calculate the total fee - const totalFee = pChainExportTxnFee + cChainImportTxnFee; - if (totalFee > avaxToNanoAvax(params.amount)) { + const totalFeeInNanoAvax = + pChainExportTxnFeeInNanoAvax + cChainImportTxnFeeInNanoAvax; + if (totalFeeInNanoAvax > weiToNanoAvax(params.amount)) { throw new Error( - `Transfer amount is too low: ${nanoAvaxToAvax( - cChainImportTxnFee - )} AVAX Fee is required for C chain import txn, + `Transfer amount is too low: ${cChainImportTxnFeeInNanoAvax} nAVAX Fee is required for C chain import txn, try sending a higher amount. P chain export txn hash: ${sendPChainExportTxn.txHash}` ); diff --git a/client/src/methods/wallet/transferUtils/transferPtoPChain.ts b/client/src/methods/wallet/transferUtils/transferPtoPChain.ts index 36bbe553..8915b818 100644 --- a/client/src/methods/wallet/transferUtils/transferPtoPChain.ts +++ b/client/src/methods/wallet/transferUtils/transferPtoPChain.ts @@ -8,7 +8,7 @@ import { sendXPTransaction } from "../sendXPTransaction.js"; import { SendParameters, SendReturnType } from "../types/send.js"; import { getBech32AddressFromAccountOrClient, - nanoAvaxToAvax, + weiToNanoAvax, } from "../utils.js"; import { waitForTxn } from "../waitForTxn.js"; @@ -37,26 +37,26 @@ export async function transferPtoPChain( } // Prepare the base transaction and get the fee state and balance - const [baseTxnRequest, pChainFeeState, balance] = await Promise.all([ - prepareBaseTxn(client, { - fromAddresses: [currentAccountPChainAddress], - outputs: [ - { - addresses: [params.to], - amount: params.amount, - }, - ], - context, - }), - getFeeState(client.pChainClient), - nanoAvaxToAvax( + const [baseTxnRequest, pChainFeeState, balanceInNanoAvax] = await Promise.all( + [ + prepareBaseTxn(client, { + fromAddresses: [currentAccountPChainAddress], + outputs: [ + { + addresses: [params.to], + amount: weiToNanoAvax(params.amount), + }, + ], + context, + }), + getFeeState(client.pChainClient), ( await getBalance(client.pChainClient, { addresses: [currentAccountPChainAddress], }) - ).balance - ), - ]); + ).balance, + ] + ); // Calculate the fee for the base transaction const baseTxnFee = pvm.calculateFee( @@ -65,19 +65,19 @@ export async function transferPtoPChain( pChainFeeState.price ); - if (Number(balance) < params.amount) { + if (balanceInNanoAvax < weiToNanoAvax(params.amount)) { throw new Error( - `Insufficient balance: ${params.amount} AVAX is required, but only ${balance} AVAX is available` + `Insufficient balance: ${weiToNanoAvax( + params.amount + )} nAVAX is required, but only ${balanceInNanoAvax} nAVAX is available` ); } - if (nanoAvaxToAvax(baseTxnFee) > params.amount) { + if (baseTxnFee > weiToNanoAvax(params.amount)) { throw new Error( - `Transfer amount is too low: ${nanoAvaxToAvax( - baseTxnFee - )} AVAX Fee is required, but only ${ + `Transfer amount is too low: ${baseTxnFee} nAVAX Fee is required, but only ${weiToNanoAvax( params.amount - } AVAX is being transferred` + )} nAVAX is being transferred` ); } diff --git a/client/src/methods/wallet/types/common.ts b/client/src/methods/wallet/types/common.ts index 83f1c95c..ab64ea90 100644 --- a/client/src/methods/wallet/types/common.ts +++ b/client/src/methods/wallet/types/common.ts @@ -58,9 +58,9 @@ export type FormattedCommonAVMTxParams = { export type Output = { /** - * Amount holding in this UTXO. + * Amount holding in this UTXO (in nano AVAX). */ - amount: number; + amount: bigint; /** * Addresses who can sign the consuming of this UTXO. */ @@ -72,7 +72,7 @@ export type Output = { /** * Optional. Timestamp in seconds after which this UTXO can be consumed. */ - locktime?: number; + locktime?: bigint; /** * Optional. Threshold of `addresses`' signatures required to consume this UTXO. */ diff --git a/client/src/methods/wallet/types/send.ts b/client/src/methods/wallet/types/send.ts index 5f213ed5..2591a20b 100644 --- a/client/src/methods/wallet/types/send.ts +++ b/client/src/methods/wallet/types/send.ts @@ -14,9 +14,9 @@ export type SendParameters = { */ account?: AvalancheAccount; /** - * The amount of tokens to send in AVAX. + * The amount of AVAX tokens to send in wei. */ - amount: number; + amount: bigint; /** * The address to send the tokens to. If the destination chain is P, this should be a P chain address. If the destination chain is C, this should be a C chain address. */ diff --git a/client/src/methods/wallet/utils.ts b/client/src/methods/wallet/utils.ts index f86761b3..19334d80 100644 --- a/client/src/methods/wallet/utils.ts +++ b/client/src/methods/wallet/utils.ts @@ -139,6 +139,24 @@ export function evmOrBech32AddressToBytes(address: string) { } } +/** + * Convert AVAX to wei + * @param amount - The amount of AVAX to convert + * @returns The amount in wei + */ +export function avaxToWei(amount: number) { + return BigInt(amount * 1e18); +} + +/** + * Convert wei to AVAX + * @param amount - The amount of wei to convert + * @returns The amount in AVAX + */ +export function weiToAvax(amount: bigint) { + return amount / BigInt(1e18); +} + /** * Convert AVAX to nanoAVAX * @param amount - The amount of AVAX to convert @@ -157,6 +175,15 @@ export function weiToNanoAvax(amount: bigint) { return amount / BigInt(1e9); } +/** + * Convert nanoAVAX to wei + * @param amount - The amount of nanoAVAX to convert + * @returns The amount in wei + */ +export function nanoAvaxToWei(amount: bigint) { + return amount * BigInt(1e9); +} + /** * Convert nanoAVAX to AVAX * @param amount - The amount of nanoAVAX to convert @@ -380,7 +407,7 @@ export async function fetchCommonAVMTxParams( export function formatOutput(output: Output, context: ContextType.Context) { return TransferableOutput.fromNative( output.assetId ?? context.avaxAssetID, - BigInt(output.amount * 1e9), + output.amount, output.addresses.map(utils.bech32ToBytes), BigInt(output.locktime ?? 0), output.threshold ?? 1 diff --git a/client/src/methods/wallet/xChain/prepareBaseTxn.test.ts b/client/src/methods/wallet/xChain/prepareBaseTxn.test.ts index fd13f601..63443cf9 100644 --- a/client/src/methods/wallet/xChain/prepareBaseTxn.test.ts +++ b/client/src/methods/wallet/xChain/prepareBaseTxn.test.ts @@ -22,9 +22,9 @@ import { } from "../fixtures/transactions/xChain"; import { checkOutputs } from "../fixtures/utils"; import { Output } from "../types/common"; -import { toTransferableOutput } from "../utils"; +import { avaxToNanoAvax, toTransferableOutput } from "../utils"; import { PrepareBaseTxnParameters } from "./types/prepareBaseTxn"; -const testInputAmount = 1; +const testInputAmount = avaxToNanoAvax(1); const xChainWorker = getXChainMockServer({}); @@ -52,7 +52,7 @@ describe("newBaseTx", () => { account3.getXPAddress("X", "fuji"), ]; const changeAddresses = [account2.getXPAddress("X", "fuji")]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -71,7 +71,7 @@ describe("newBaseTx", () => { ).baseTx.outputs.map(toTransferableOutput); const fee = testContext.baseTxFee; - const expectedFeesInAvax = Number(fee) / 1e9; + const expectedFeesInAvax = fee; const expectedChangeAmount = testInputAmount - testOutputAmount - expectedFeesInAvax; @@ -99,7 +99,7 @@ describe("newBaseTx", () => { expect( allInputAmounts - allOutputAmounts, "expected and actual burned amount mismatch" - ).toBe(BigInt(expectedFeesInAvax * 1e9)); + ).toBe(expectedFeesInAvax); }); it("should only use utxos passed in params", async () => { @@ -109,8 +109,8 @@ describe("newBaseTx", () => { ]; const changeAddresses = [account2.getXPAddress("X", "fuji")]; - const testOutputAmount = 0.1234; - const testInputAmount = 0.5; + const testOutputAmount = avaxToNanoAvax(0.1234); + const testInputAmount = avaxToNanoAvax(0.5); const testOutputs = [ { amount: testOutputAmount, @@ -140,7 +140,7 @@ describe("newBaseTx", () => { // calculate fees as per AvalancheJS method const fee = testContext.baseTxFee; - const expectedFeesInAvax = Number(fee) / 1e9; + const expectedFeesInAvax = fee; // if utxos passed in params are only used, then testInputAmount will be 0.5 instead of default 1 const expectedChangeAmount = testInputAmount - testOutputAmount - expectedFeesInAvax; @@ -166,20 +166,18 @@ describe("newBaseTx", () => { const allOutputAmounts = ( txnRequest.tx.getTx() as avmSerial.BaseTx ).baseTx.outputs.reduce((acc, i) => acc + i.amount(), 0n); - expect(allInputAmounts - allOutputAmounts).toBe( - BigInt(expectedFeesInAvax * 1e9) - ); + expect(allInputAmounts - allOutputAmounts).toBe(expectedFeesInAvax); }); it("should use `fromAddresses` for fetching utxos and change addresses", async () => { - const testSpentAmount = 1; + const testSpentAmount = avaxToNanoAvax(1); const spenderAddresses = [account1.getXPAddress("X", "fuji")]; const receiverAddresses = [ account4.getXPAddress("X", "fuji"), account3.getXPAddress("X", "fuji"), ]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -198,7 +196,7 @@ describe("newBaseTx", () => { ).baseTx.outputs.map(toTransferableOutput); const fee = testContext.baseTxFee; - const expectedFeesInAvax = Number(fee) / 1e9; + const expectedFeesInAvax = fee; const expectedChangeAmount = testSpentAmount - testOutputAmount - expectedFeesInAvax; @@ -228,7 +226,7 @@ describe("newBaseTx", () => { expect( allInputAmounts - allOutputAmounts, "expected and actual burned amount mismatch" - ).toBe(BigInt(expectedFeesInAvax * 1e9)); + ).toBe(expectedFeesInAvax); }); it("should sign the tx properly", async () => { @@ -238,7 +236,7 @@ describe("newBaseTx", () => { ]; const changeAddresses = [account2.getXPAddress("X", "fuji")]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -270,7 +268,7 @@ describe("newBaseTx", () => { const receiverAddresses = [account3.getXPAddress("X", "fuji")]; const changeAddresses = [account4.getXPAddress("X", "fuji")]; - const testOutputAmount = 1.5; + const testOutputAmount = avaxToNanoAvax(1.5); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -331,7 +329,7 @@ describe("newBaseTx", () => { ]; const changeAddresses = [account2.getXPAddress("X", "fuji")]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -356,7 +354,7 @@ describe("newBaseTx", () => { fromAddresses: [account1.getXPAddress("X", "fuji")], outputs: [ { - amount: 40, + amount: avaxToNanoAvax(40), addresses: [account1.getXPAddress("X", "fuji")], }, ], diff --git a/client/src/methods/wallet/xChain/prepareBaseTxn.ts b/client/src/methods/wallet/xChain/prepareBaseTxn.ts index 9eab7ef3..81e8443a 100644 --- a/client/src/methods/wallet/xChain/prepareBaseTxn.ts +++ b/client/src/methods/wallet/xChain/prepareBaseTxn.ts @@ -22,6 +22,7 @@ import { * import { prepareBaseTxn } from "@avalanche-sdk/client/methods/wallet/xChain"; * import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; * import { avalanche } from "@avalanche-sdk/client/chains"; + * import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; * * const account = privateKeyToAvalancheAccount(privateKeyForTest); * const walletClient = new AvalancheWalletCoreClient({ @@ -35,7 +36,7 @@ import { * const xChainBaseTxnRequest = await prepareBaseTxn(walletClient, { * outputs: [ * { - * amount: 1000000000000000000, + * amount: avaxToNanoAvax(0.0001), // 0.0001 AVAX = 100_000 nAVAX * to: "P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz", * }, * ], diff --git a/client/src/methods/wallet/xChain/prepareExportTxn.test.ts b/client/src/methods/wallet/xChain/prepareExportTxn.test.ts index 06203f13..161be3eb 100644 --- a/client/src/methods/wallet/xChain/prepareExportTxn.test.ts +++ b/client/src/methods/wallet/xChain/prepareExportTxn.test.ts @@ -16,11 +16,10 @@ import { Output } from "../types/common"; import { avaxToNanoAvax, getChainIdFromAlias, - nanoAvaxToAvax, toTransferableOutput, } from "../utils"; -const testInputAmount = 1; +const testInputAmount = avaxToNanoAvax(1); const xChainWorker = getXChainMockServer({}); @@ -50,8 +49,8 @@ describe("prepareExportTxn", () => { const receiverAddresses2 = [account4.getXPAddress("X", "fuji")]; const changeAddresses = [account2.getXPAddress("X", "fuji")]; - const testOutputAmount = 0.1234; - const testOutputAmount2 = 0.2345; + const testOutputAmount = avaxToNanoAvax(0.1234); + const testOutputAmount2 = avaxToNanoAvax(0.2345); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -77,14 +76,11 @@ describe("prepareExportTxn", () => { const fee = testContext.baseTxFee; const expectedChangeAmount = - avaxToNanoAvax(testInputAmount) - - avaxToNanoAvax(testOutputAmount) - - avaxToNanoAvax(testOutputAmount2) - - fee; + testInputAmount - testOutputAmount - testOutputAmount2 - fee; // expected change output testOutputs.push({ - amount: nanoAvaxToAvax(expectedChangeAmount), + amount: expectedChangeAmount, addresses: changeAddresses, }); @@ -112,7 +108,7 @@ describe("prepareExportTxn", () => { ]; const changeAddresses = [account2.getXPAddress("X", "fuji")]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const testOutputs: Output[] = [ { amount: testOutputAmount, @@ -167,7 +163,7 @@ describe("prepareExportTxn", () => { ]; const changeAddresses = [account2.getXPAddress("X", "fuji")]; - const testOutputAmount = 0.1234; + const testOutputAmount = avaxToNanoAvax(0.1234); const testOutputs: Output[] = [ { amount: testOutputAmount, diff --git a/client/src/methods/wallet/xChain/prepareExportTxn.ts b/client/src/methods/wallet/xChain/prepareExportTxn.ts index 376372c3..bc3534b0 100644 --- a/client/src/methods/wallet/xChain/prepareExportTxn.ts +++ b/client/src/methods/wallet/xChain/prepareExportTxn.ts @@ -26,6 +26,7 @@ import { * import { prepareExportTxn } from "@avalanche-sdk/client/methods/wallet/xChain"; * import { privateKeyToAvalancheAccount } from "@avalanche-sdk/client/accounts"; * import { avalanche } from "@avalanche-sdk/client/chains"; + * import { avaxToNanoAvax } from "@avalanche-sdk/client/utils"; * * const account = privateKeyToAvalancheAccount(privateKeyForTest); * const walletClient = new AvalancheWalletCoreClient({ @@ -40,7 +41,7 @@ import { * destinationChain: "P", * exportedOutputs: [ * { - * amount: 1000000000000000000, + * amount: avaxToNanoAvax(0.0001), // 0.0001 AVAX = 100_000 nAVAX * to: "P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz", * }, * ], diff --git a/client/src/methods/wallet/xChain/prepareImportTxn.test.ts b/client/src/methods/wallet/xChain/prepareImportTxn.test.ts index f123e000..0334a7b3 100644 --- a/client/src/methods/wallet/xChain/prepareImportTxn.test.ts +++ b/client/src/methods/wallet/xChain/prepareImportTxn.test.ts @@ -11,7 +11,6 @@ import { Output } from "../types/common"; import { avaxToNanoAvax, getChainIdFromAlias, - nanoAvaxToAvax, toTransferableOutput, } from "../utils"; import { ImportedOutput } from "../xChain/types/prepareImportTxn"; @@ -46,7 +45,7 @@ describe("prepareImportTxn", () => { const importedOutput: ImportedOutput = { addresses: receiverAddresses, - locktime: 1000, + locktime: 1000n, threshold: 1, }; const testOutputs: Output[] = []; @@ -66,9 +65,9 @@ describe("prepareImportTxn", () => { // imported output as the only change output const testImportedOutputAmount = avaxToNanoAvax(testInputAmount) - fee; testOutputs.push({ - amount: nanoAvaxToAvax(testImportedOutputAmount), + amount: testImportedOutputAmount, addresses: importedOutput.addresses, - locktime: importedOutput.locktime ?? 0, + locktime: importedOutput.locktime ?? 0n, threshold: importedOutput.threshold ?? 1, }); @@ -97,7 +96,7 @@ describe("prepareImportTxn", () => { const importedOutput: ImportedOutput = { addresses: receiverAddresses, - locktime: 1000, + locktime: 1000n, threshold: 1, }; const mockTxParams: PrepareImportTxnParameters = { @@ -122,7 +121,7 @@ describe("prepareImportTxn", () => { const importedOutput: ImportedOutput = { addresses: receiverAddresses, - locktime: 1000, + locktime: 1000n, threshold: 1, }; const mockTxParams: PrepareImportTxnParameters = { diff --git a/client/src/methods/wallet/xChain/prepareImportTxn.ts b/client/src/methods/wallet/xChain/prepareImportTxn.ts index 7a513118..8d0982f4 100644 --- a/client/src/methods/wallet/xChain/prepareImportTxn.ts +++ b/client/src/methods/wallet/xChain/prepareImportTxn.ts @@ -35,8 +35,7 @@ import { * const xChainImportTxnRequest = await prepareImportTxn(walletClient, { * sourceChain: "P", * importedOutput: { - * amount: 1000000000000000000, - * to: "P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz", + * addresses: ["P-fuji19fc97zn3mzmwr827j4d3n45refkksgms4y2yzz"], * }, * }); */ diff --git a/client/src/methods/wallet/xChain/types/prepareImportTxn.ts b/client/src/methods/wallet/xChain/types/prepareImportTxn.ts index 7d947915..205ffe28 100644 --- a/client/src/methods/wallet/xChain/types/prepareImportTxn.ts +++ b/client/src/methods/wallet/xChain/types/prepareImportTxn.ts @@ -19,7 +19,7 @@ export type ImportedOutput = { /** * Optional. Timestamp in seconds after which this UTXO can be consumed. */ - locktime?: number; + locktime?: bigint; /** * Optional. The number of signatures required out of the total `addresses` * to spend the imported output. diff --git a/client/src/utils/index.ts b/client/src/utils/index.ts index c98ac4ad..08be6647 100644 --- a/client/src/utils/index.ts +++ b/client/src/utils/index.ts @@ -1,7 +1,15 @@ export { bls, secp256k1, utils } from "@avalabs/avalanchejs"; export { utf8ToBytes } from "@noble/hashes/utils"; export { buildRequest, type RequestErrorType } from "viem/utils"; -export { avaxToNanoAvax, nanoAvaxToAvax } from "../methods/wallet/utils.js"; +export { + avaxToNanoAvax, + avaxToWei, + nanoAvaxToAvax, + nanoAvaxToWei, + weiToAvax, + weiToNanoAvax, +} from "../methods/wallet/utils.js"; +export { buildUtxoBytes } from "./buildUtxoBytes.js"; export { CB58ToHex, hexToCB58 } from "./common.js"; export { getTxFromBytes, getUnsignedTxFromBytes } from "./getTxFromBytes.js"; export { getUtxoFromBytes } from "./getUtxoFromBytes.js"; @@ -9,7 +17,6 @@ export { getUtxosForAddress, type GetUtxosForAddressParams, } from "./getUtxosForAddress.js"; -export { buildUtxoBytes } from "./buildUtxoBytes.js"; export { /** @deprecated Use `ccipRequest`. */ diff --git a/client/src/window/index.ts b/client/src/window/index.ts index f472ce69..0fddd7b0 100644 --- a/client/src/window/index.ts +++ b/client/src/window/index.ts @@ -1,5 +1,4 @@ import type { EIP1193Provider } from "viem"; - declare global { interface Window { ethereum?: EIP1193Provider | undefined;