diff --git a/.vscode/settings.json b/.vscode/settings.json index 231e0071..d4ba3242 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,7 +17,7 @@ "Keccak", "labelhash", "locktime", - "memonics", + "mnemonics", "multicall", "nhpjar", "offchain", 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/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/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/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 cba58c92..0fddd7b0 100644 --- a/client/src/window/index.ts +++ b/client/src/window/index.ts @@ -1 +1,7 @@ -export * from "viem/window"; +import type { EIP1193Provider } from "viem"; +declare global { + interface Window { + ethereum?: EIP1193Provider | undefined; + avalanche?: EIP1193Provider | undefined; + } +}