diff --git a/package-lock.json b/package-lock.json index 8235042..c224f49 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "hasInstallScript": true, "dependencies": { "@algorandfoundation/algorand-typescript": "^0.0.1-alpha.23", - "@algorandfoundation/puya-ts": "^1.0.0-alpha.35", + "@algorandfoundation/puya-ts": "^1.0.0-alpha.36", "elliptic": "^6.5.7", "js-sha256": "^0.11.0", "js-sha3": "^0.9.3", @@ -81,9 +81,9 @@ } }, "node_modules/@algorandfoundation/puya-ts": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/@algorandfoundation/puya-ts/-/puya-ts-1.0.0-beta.2.tgz", - "integrity": "sha512-kHIWCOmsU18ceLMKrzTa6Q4hfHp7+Ai58rcxdqNNKtDfzvffWuPLI6oMP2gj6wP+ZTrIdoLNGMhJVOlvtCYpew==", + "version": "1.0.0-alpha.36", + "resolved": "https://registry.npmjs.org/@algorandfoundation/puya-ts/-/puya-ts-1.0.0-alpha.36.tgz", + "integrity": "sha512-HHjRTvVMK3/9Oa1YRcKg/d1t9bsTnU3EdhF3rJyRSLOBDl87U5g3MUYgUuxzTbFDfUgqYNKfftL6m75EVpQ0og==", "bundleDependencies": [ "typescript" ], @@ -1644,9 +1644,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.28.1.tgz", - "integrity": "sha512-2aZp8AES04KI2dy3Ss6/MDjXbwBzj+i0GqKtWXgw2/Ma6E4jJvujryO6gJAghIRVz7Vwr9Gtl/8na3nDUKpraQ==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.29.1.tgz", + "integrity": "sha512-ssKhA8RNltTZLpG6/QNkCSge+7mBQGUqJRisZ2MDQcEGaK93QESEgWK2iOpIDZ7k9zPVkG5AS3ksvD5ZWxmItw==", "cpu": [ "arm" ], @@ -1658,9 +1658,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.28.1.tgz", - "integrity": "sha512-EbkK285O+1YMrg57xVA+Dp0tDBRB93/BZKph9XhMjezf6F4TpYjaUSuPt5J0fZXlSag0LmZAsTmdGGqPp4pQFA==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.29.1.tgz", + "integrity": "sha512-CaRfrV0cd+NIIcVVN/jx+hVLN+VRqnuzLRmfmlzpOzB87ajixsN/+9L5xNmkaUUvEbI5BmIKS+XTwXsHEb65Ew==", "cpu": [ "arm64" ], @@ -1672,9 +1672,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.28.1.tgz", - "integrity": "sha512-prduvrMKU6NzMq6nxzQw445zXgaDBbMQvmKSJaxpaZ5R1QDM8w+eGxo6Y/jhT/cLoCvnZI42oEqf9KQNYz1fqQ==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.29.1.tgz", + "integrity": "sha512-2ORr7T31Y0Mnk6qNuwtyNmy14MunTAMx06VAPI6/Ju52W10zk1i7i5U3vlDRWjhOI5quBcrvhkCHyF76bI7kEw==", "cpu": [ "arm64" ], @@ -1686,9 +1686,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.28.1.tgz", - "integrity": "sha512-WsvbOunsUk0wccO/TV4o7IKgloJ942hVFK1CLatwv6TJspcCZb9umQkPdvB7FihmdxgaKR5JyxDjWpCOp4uZlQ==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.29.1.tgz", + "integrity": "sha512-j/Ej1oanzPjmN0tirRd5K2/nncAhS9W6ICzgxV+9Y5ZsP0hiGhHJXZ2JQ53iSSjj8m6cRY6oB1GMzNn2EUt6Ng==", "cpu": [ "x64" ], @@ -1700,9 +1700,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.28.1.tgz", - "integrity": "sha512-HTDPdY1caUcU4qK23FeeGxCdJF64cKkqajU0iBnTVxS8F7H/7BewvYoG+va1KPSL63kQ1PGNyiwKOfReavzvNA==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.29.1.tgz", + "integrity": "sha512-91C//G6Dm/cv724tpt7nTyP+JdN12iqeXGFM1SqnljCmi5yTXriH7B1r8AD9dAZByHpKAumqP1Qy2vVNIdLZqw==", "cpu": [ "arm64" ], @@ -1714,9 +1714,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.28.1.tgz", - "integrity": "sha512-m/uYasxkUevcFTeRSM9TeLyPe2QDuqtjkeoTpP9SW0XxUWfcYrGDMkO/m2tTw+4NMAF9P2fU3Mw4ahNvo7QmsQ==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.29.1.tgz", + "integrity": "sha512-hEioiEQ9Dec2nIRoeHUP6hr1PSkXzQaCUyqBDQ9I9ik4gCXQZjJMIVzoNLBRGet+hIUb3CISMh9KXuCcWVW/8w==", "cpu": [ "x64" ], @@ -1728,9 +1728,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.28.1.tgz", - "integrity": "sha512-QAg11ZIt6mcmzpNE6JZBpKfJaKkqTm1A9+y9O+frdZJEuhQxiugM05gnCWiANHj4RmbgeVJpTdmKRmH/a+0QbA==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.29.1.tgz", + "integrity": "sha512-Py5vFd5HWYN9zxBv3WMrLAXY3yYJ6Q/aVERoeUFwiDGiMOWsMs7FokXihSOaT/PMWUty/Pj60XDQndK3eAfE6A==", "cpu": [ "arm" ], @@ -1742,9 +1742,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.28.1.tgz", - "integrity": "sha512-dRP9PEBfolq1dmMcFqbEPSd9VlRuVWEGSmbxVEfiq2cs2jlZAl0YNxFzAQS2OrQmsLBLAATDMb3Z6MFv5vOcXg==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.29.1.tgz", + "integrity": "sha512-RiWpGgbayf7LUcuSNIbahr0ys2YnEERD4gYdISA06wa0i8RALrnzflh9Wxii7zQJEB2/Eh74dX4y/sHKLWp5uQ==", "cpu": [ "arm" ], @@ -1756,9 +1756,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.28.1.tgz", - "integrity": "sha512-uGr8khxO+CKT4XU8ZUH1TTEUtlktK6Kgtv0+6bIFSeiSlnGJHG1tSFSjm41uQ9sAO/5ULx9mWOz70jYLyv1QkA==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.29.1.tgz", + "integrity": "sha512-Z80O+taYxTQITWMjm/YqNoe9d10OX6kDh8X5/rFCMuPqsKsSyDilvfg+vd3iXIqtfmp+cnfL1UrYirkaF8SBZA==", "cpu": [ "arm64" ], @@ -1770,9 +1770,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.28.1.tgz", - "integrity": "sha512-QF54q8MYGAqMLrX2t7tNpi01nvq5RI59UBNx+3+37zoKX5KViPo/gk2QLhsuqok05sSCRluj0D00LzCwBikb0A==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.29.1.tgz", + "integrity": "sha512-fOHRtF9gahwJk3QVp01a/GqS4hBEZCV1oKglVVq13kcK3NeVlS4BwIFzOHDbmKzt3i0OuHG4zfRP0YoG5OF/rA==", "cpu": [ "arm64" ], @@ -1784,9 +1784,9 @@ ] }, "node_modules/@rollup/rollup-linux-loongarch64-gnu": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.28.1.tgz", - "integrity": "sha512-vPul4uodvWvLhRco2w0GcyZcdyBfpfDRgNKU+p35AWEbJ/HPs1tOUrkSueVbBS0RQHAf/A+nNtDpvw95PeVKOA==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.29.1.tgz", + "integrity": "sha512-5a7q3tnlbcg0OodyxcAdrrCxFi0DgXJSoOuidFUzHZ2GixZXQs6Tc3CHmlvqKAmOs5eRde+JJxeIf9DonkmYkw==", "cpu": [ "loong64" ], @@ -1798,9 +1798,9 @@ ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.28.1.tgz", - "integrity": "sha512-pTnTdBuC2+pt1Rmm2SV7JWRqzhYpEILML4PKODqLz+C7Ou2apEV52h19CR7es+u04KlqplggmN9sqZlekg3R1A==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.29.1.tgz", + "integrity": "sha512-9b4Mg5Yfz6mRnlSPIdROcfw1BU22FQxmfjlp/CShWwO3LilKQuMISMTtAu/bxmmrE6A902W2cZJuzx8+gJ8e9w==", "cpu": [ "ppc64" ], @@ -1812,9 +1812,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.28.1.tgz", - "integrity": "sha512-vWXy1Nfg7TPBSuAncfInmAI/WZDd5vOklyLJDdIRKABcZWojNDY0NJwruY2AcnCLnRJKSaBgf/GiJfauu8cQZA==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.29.1.tgz", + "integrity": "sha512-G5pn0NChlbRM8OJWpJFMX4/i8OEU538uiSv0P6roZcbpe/WfhEO+AT8SHVKfp8qhDQzaz7Q+1/ixMy7hBRidnQ==", "cpu": [ "riscv64" ], @@ -1826,9 +1826,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.28.1.tgz", - "integrity": "sha512-/yqC2Y53oZjb0yz8PVuGOQQNOTwxcizudunl/tFs1aLvObTclTwZ0JhXF2XcPT/zuaymemCDSuuUPXJJyqeDOg==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.29.1.tgz", + "integrity": "sha512-WM9lIkNdkhVwiArmLxFXpWndFGuOka4oJOZh8EP3Vb8q5lzdSCBuhjavJsw68Q9AKDGeOOIHYzYm4ZFvmWez5g==", "cpu": [ "s390x" ], @@ -1840,9 +1840,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.28.1.tgz", - "integrity": "sha512-fzgeABz7rrAlKYB0y2kSEiURrI0691CSL0+KXwKwhxvj92VULEDQLpBYLHpF49MSiPG4sq5CK3qHMnb9tlCjBw==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.29.1.tgz", + "integrity": "sha512-87xYCwb0cPGZFoGiErT1eDcssByaLX4fc0z2nRM6eMtV9njAfEE6OW3UniAoDhX4Iq5xQVpE6qO9aJbCFumKYQ==", "cpu": [ "x64" ], @@ -1854,9 +1854,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.28.1.tgz", - "integrity": "sha512-xQTDVzSGiMlSshpJCtudbWyRfLaNiVPXt1WgdWTwWz9n0U12cI2ZVtWe/Jgwyv/6wjL7b66uu61Vg0POWVfz4g==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.29.1.tgz", + "integrity": "sha512-xufkSNppNOdVRCEC4WKvlR1FBDyqCSCpQeMMgv9ZyXqqtKBfkw1yfGMTUTs9Qsl6WQbJnsGboWCp7pJGkeMhKA==", "cpu": [ "x64" ], @@ -1868,9 +1868,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.28.1.tgz", - "integrity": "sha512-wSXmDRVupJstFP7elGMgv+2HqXelQhuNf+IS4V+nUpNVi/GUiBgDmfwD0UGN3pcAnWsgKG3I52wMOBnk1VHr/A==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.29.1.tgz", + "integrity": "sha512-F2OiJ42m77lSkizZQLuC+jiZ2cgueWQL5YC9tjo3AgaEw+KJmVxHGSyQfDUoYR9cci0lAywv2Clmckzulcq6ig==", "cpu": [ "arm64" ], @@ -1882,9 +1882,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.28.1.tgz", - "integrity": "sha512-ZkyTJ/9vkgrE/Rk9vhMXhf8l9D+eAhbAVbsGsXKy2ohmJaWg0LPQLnIxRdRp/bKyr8tXuPlXhIoGlEB5XpJnGA==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.29.1.tgz", + "integrity": "sha512-rYRe5S0FcjlOBZQHgbTKNrqxCBUmgDJem/VQTCcTnA2KCabYSWQDrytOzX7avb79cAAweNmMUb/Zw18RNd4mng==", "cpu": [ "ia32" ], @@ -1896,9 +1896,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.28.1.tgz", - "integrity": "sha512-ZvK2jBafvttJjoIdKm/Q/Bh7IJ1Ose9IBOwpOXcOvW3ikGTQGmKDgxTC6oCAzW6PynbkKP8+um1du81XJHZ0JA==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.29.1.tgz", + "integrity": "sha512-+10CMg9vt1MoHj6x1pxyjPSMjHTIlqs8/tBztXvPAx24SKs9jwVnKqHJumlH/IzhaPUaj3T6T6wfZr8okdXaIg==", "cpu": [ "x64" ], @@ -3240,9 +3240,9 @@ } }, "node_modules/chalk": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.0.tgz", - "integrity": "sha512-ZkD35Mx92acjB2yNJgziGqT9oKHEOxjTBTDRpOsRWtdecL/0jM3z5kM/CTzHWvHIen1GvkM85p6TuFfDGfc8/Q==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", + "integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==", "license": "MIT", "engines": { "node": "^12.17.0 || ^14.13 || >=16.0.0" @@ -4573,28 +4573,28 @@ } }, "node_modules/es-abstract": { - "version": "1.23.6", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.6.tgz", - "integrity": "sha512-Ifco6n3yj2tMZDWNLyloZrytt9lqqlwvS83P3HtaETR0NUOYnIULGGHpktqYGObGy+8wc1okO25p8TjemhImvA==", + "version": "1.23.7", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.7.tgz", + "integrity": "sha512-OygGC8kIcDhXX+6yAZRGLqwi2CmEXCbLQixeGUgYeR+Qwlppqmo7DIDr8XibtEBZp+fJcoYpoatp5qwLMEdcqQ==", "dev": true, "license": "MIT", "dependencies": { - "array-buffer-byte-length": "^1.0.1", + "array-buffer-byte-length": "^1.0.2", "arraybuffer.prototype.slice": "^1.0.4", "available-typed-arrays": "^1.0.7", "call-bind": "^1.0.8", "call-bound": "^1.0.3", - "data-view-buffer": "^1.0.1", - "data-view-byte-length": "^1.0.1", - "data-view-byte-offset": "^1.0.0", + "data-view-buffer": "^1.0.2", + "data-view-byte-length": "^1.0.2", + "data-view-byte-offset": "^1.0.1", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", "es-object-atoms": "^1.0.0", "es-set-tostringtag": "^2.0.3", "es-to-primitive": "^1.3.0", - "function.prototype.name": "^1.1.7", + "function.prototype.name": "^1.1.8", "get-intrinsic": "^1.2.6", - "get-symbol-description": "^1.0.2", + "get-symbol-description": "^1.1.0", "globalthis": "^1.0.4", "gopd": "^1.2.0", "has-property-descriptors": "^1.0.2", @@ -4602,31 +4602,30 @@ "has-symbols": "^1.1.0", "hasown": "^2.0.2", "internal-slot": "^1.1.0", - "is-array-buffer": "^3.0.4", + "is-array-buffer": "^3.0.5", "is-callable": "^1.2.7", "is-data-view": "^1.0.2", - "is-negative-zero": "^2.0.3", "is-regex": "^1.2.1", - "is-shared-array-buffer": "^1.0.3", + "is-shared-array-buffer": "^1.0.4", "is-string": "^1.1.1", - "is-typed-array": "^1.1.13", + "is-typed-array": "^1.1.15", "is-weakref": "^1.1.0", - "math-intrinsics": "^1.0.0", + "math-intrinsics": "^1.1.0", "object-inspect": "^1.13.3", "object-keys": "^1.1.1", - "object.assign": "^4.1.5", + "object.assign": "^4.1.7", "regexp.prototype.flags": "^1.5.3", "safe-array-concat": "^1.1.3", "safe-regex-test": "^1.1.0", "string.prototype.trim": "^1.2.10", "string.prototype.trimend": "^1.0.9", "string.prototype.trimstart": "^1.0.8", - "typed-array-buffer": "^1.0.2", - "typed-array-byte-length": "^1.0.1", - "typed-array-byte-offset": "^1.0.3", + "typed-array-buffer": "^1.0.3", + "typed-array-byte-length": "^1.0.3", + "typed-array-byte-offset": "^1.0.4", "typed-array-length": "^1.0.7", - "unbox-primitive": "^1.0.2", - "which-typed-array": "^1.1.16" + "unbox-primitive": "^1.1.0", + "which-typed-array": "^1.1.18" }, "engines": { "node": ">= 0.4" @@ -6380,9 +6379,9 @@ } }, "node_modules/is-core-module": { - "version": "2.16.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.0.tgz", - "integrity": "sha512-urTSINYfAYgcbLb0yDQ6egFm6h3Mo1DcF9EkyXSRjjzdHbsulg01qhwWuXdOoUBuTkbQ80KDboXa0vFJ+BDH+g==", + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", "dev": true, "license": "MIT", "dependencies": { @@ -6530,19 +6529,6 @@ "dev": true, "license": "MIT" }, - "node_modules/is-negative-zero": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.3.tgz", - "integrity": "sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", @@ -6997,9 +6983,9 @@ "license": "MIT" }, "node_modules/json-stable-stringify": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.2.0.tgz", - "integrity": "sha512-ex8jk9BZHBolvbd5cRnAgwyaYcYB0qZldy1e+LCOdcF6+AUmVZ6LcGUMzsRTW83QMeu+GxZGrcLqxqrgfXGvIw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.2.1.tgz", + "integrity": "sha512-Lp6HbbBgosLmJbjx0pBLbgvx68FaFU1sdkmBuckmhhJ88kL13OA51CDtR2yJB50eCNMH9wRqtQNNiAqQH4YXnA==", "dev": true, "license": "MIT", "dependencies": { @@ -11743,9 +11729,9 @@ } }, "node_modules/rollup": { - "version": "4.28.1", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.28.1.tgz", - "integrity": "sha512-61fXYl/qNVinKmGSTHAZ6Yy8I3YIJC/r2m9feHo6SwVAVcLT5MPwOUFe7EuURA/4m0NR8lXG4BBXuo/IZEsjMg==", + "version": "4.29.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.29.1.tgz", + "integrity": "sha512-RaJ45M/kmJUzSWDs1Nnd5DdV4eerC98idtUOVr6FfKcgxqvjwHmxc5upLF9qZU9EpsVzzhleFahrT3shLuJzIw==", "dev": true, "license": "MIT", "dependencies": { @@ -11759,25 +11745,25 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.28.1", - "@rollup/rollup-android-arm64": "4.28.1", - "@rollup/rollup-darwin-arm64": "4.28.1", - "@rollup/rollup-darwin-x64": "4.28.1", - "@rollup/rollup-freebsd-arm64": "4.28.1", - "@rollup/rollup-freebsd-x64": "4.28.1", - "@rollup/rollup-linux-arm-gnueabihf": "4.28.1", - "@rollup/rollup-linux-arm-musleabihf": "4.28.1", - "@rollup/rollup-linux-arm64-gnu": "4.28.1", - "@rollup/rollup-linux-arm64-musl": "4.28.1", - "@rollup/rollup-linux-loongarch64-gnu": "4.28.1", - "@rollup/rollup-linux-powerpc64le-gnu": "4.28.1", - "@rollup/rollup-linux-riscv64-gnu": "4.28.1", - "@rollup/rollup-linux-s390x-gnu": "4.28.1", - "@rollup/rollup-linux-x64-gnu": "4.28.1", - "@rollup/rollup-linux-x64-musl": "4.28.1", - "@rollup/rollup-win32-arm64-msvc": "4.28.1", - "@rollup/rollup-win32-ia32-msvc": "4.28.1", - "@rollup/rollup-win32-x64-msvc": "4.28.1", + "@rollup/rollup-android-arm-eabi": "4.29.1", + "@rollup/rollup-android-arm64": "4.29.1", + "@rollup/rollup-darwin-arm64": "4.29.1", + "@rollup/rollup-darwin-x64": "4.29.1", + "@rollup/rollup-freebsd-arm64": "4.29.1", + "@rollup/rollup-freebsd-x64": "4.29.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.29.1", + "@rollup/rollup-linux-arm-musleabihf": "4.29.1", + "@rollup/rollup-linux-arm64-gnu": "4.29.1", + "@rollup/rollup-linux-arm64-musl": "4.29.1", + "@rollup/rollup-linux-loongarch64-gnu": "4.29.1", + "@rollup/rollup-linux-powerpc64le-gnu": "4.29.1", + "@rollup/rollup-linux-riscv64-gnu": "4.29.1", + "@rollup/rollup-linux-s390x-gnu": "4.29.1", + "@rollup/rollup-linux-x64-gnu": "4.29.1", + "@rollup/rollup-linux-x64-musl": "4.29.1", + "@rollup/rollup-win32-arm64-msvc": "4.29.1", + "@rollup/rollup-win32-ia32-msvc": "4.29.1", + "@rollup/rollup-win32-x64-msvc": "4.29.1", "fsevents": "~2.3.2" } }, @@ -13262,7 +13248,6 @@ "version": "5.7.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz", "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==", - "dev": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index 0e2b138..1996da5 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ }, "dependencies": { "@algorandfoundation/algorand-typescript": "^0.0.1-alpha.23", - "@algorandfoundation/puya-ts": "^1.0.0-alpha.35", + "@algorandfoundation/puya-ts": "^1.0.0-alpha.36", "elliptic": "^6.5.7", "js-sha256": "^0.11.0", "js-sha3": "^0.9.3", diff --git a/src/impl/encoded-types.ts b/src/impl/encoded-types.ts index a9a7d26..9ff4bfa 100644 --- a/src/impl/encoded-types.ts +++ b/src/impl/encoded-types.ts @@ -24,14 +24,20 @@ import { BITS_IN_BYTE, UINT64_SIZE, } from '../constants' +import { lazyContext } from '../context-helpers/internal-context' import { fromBytes, TypeInfo } from '../encoders' import { DeliberateAny } from '../typescript-helpers' -import { asBigUint, asBigUintCls, asBytesCls, asUint64, asUint8Array, conactUint8Arrays, uint8ArrayToNumber } from '../util' +import { asBigInt, asBigUint, asBigUintCls, asBytesCls, asUint64, asUint8Array, conactUint8Arrays, uint8ArrayToNumber } from '../util' +import { AccountCls } from './account' +import { ApplicationCls } from './application' +import { AssetCls } from './asset' +import { ApplicationTransaction } from './transactions' const ABI_LENGTH_SIZE = 2 const maxBigIntValue = (bitSize: number) => 2n ** BigInt(bitSize) - 1n const maxBytesLength = (bitSize: number) => Math.floor(bitSize / BITS_IN_BYTE) const encodeLength = (length: number) => new internal.primitives.BytesCls(encodingUtil.bigIntToUint8Array(BigInt(length), ABI_LENGTH_SIZE)) + type CompatForArc4Int = N extends 8 | 16 | 32 | 64 ? Uint64Compat : BigUintCompat export class UintNImpl extends UintN { private value: Uint8Array @@ -99,7 +105,7 @@ export class UFixedNxMImpl extends UFixedNx private value: Uint8Array private bitSize: N private precision: M - private typeInfo: TypeInfo + typeInfo: TypeInfo constructor(typeInfo: TypeInfo | string, v: `${number}.${number}`) { super(v) @@ -163,7 +169,10 @@ export class UFixedNxMImpl extends UFixedNx export class ByteImpl extends Byte { private value: UintNImpl<8> - constructor(typeInfo: TypeInfo | string, v?: CompatForArc4Int<8>) { + constructor( + public typeInfo: TypeInfo | string, + v?: CompatForArc4Int<8>, + ) { super(v) this.value = new UintNImpl<8>(typeInfo, v) } @@ -202,7 +211,10 @@ export class ByteImpl extends Byte { export class StrImpl extends Str { private value: Uint8Array - constructor(_typeInfo: TypeInfo | string, s?: StringCompat) { + constructor( + public typeInfo: TypeInfo | string, + s?: StringCompat, + ) { super() const bytesValue = asBytesCls(s ?? '') const bytesLength = encodeLength(bytesValue.length.asNumber()) @@ -244,7 +256,10 @@ const FALSE_BIGINT_VALUE = 0n export class BoolImpl extends Bool { private value: Uint8Array - constructor(_typeInfo: TypeInfo | string, v?: boolean) { + constructor( + public typeInfo: TypeInfo | string, + v?: boolean, + ) { super(v) this.value = encodingUtil.bigIntToUint8Array(v ? TRUE_BIGINT_VALUE : FALSE_BIGINT_VALUE, 1) } @@ -320,8 +335,8 @@ const arrayProxyHandler = () => ({ export class StaticArrayImpl extends StaticArray { private value?: TItem[] private uint8ArrayValue?: Uint8Array - private typeInfo: TypeInfo private size: number + typeInfo: TypeInfo genericArgs: StaticArrayGenericArgs constructor(typeInfo: TypeInfo | string, ...items: TItem[] & { length: TLength }) @@ -383,6 +398,10 @@ export class StaticArrayImpl return StaticArrayImpl.fromBytesImpl(this.bytes, JSON.stringify(this.typeInfo)) as StaticArrayImpl } + get native(): TItem[] { + return this.items + } + static fromBytesImpl( value: internal.primitives.StubBytesCompat | Uint8Array, typeInfo: string | TypeInfo, @@ -425,7 +444,7 @@ export class StaticArrayImpl } export class AddressImpl extends Address { - private typeInfo: TypeInfo + typeInfo: TypeInfo private value: StaticArrayImpl constructor(typeInfo: TypeInfo | string, value?: Account | string | bytes) { @@ -499,7 +518,7 @@ const readLength = (value: Uint8Array): readonly [number, Uint8Array] => { export class DynamicArrayImpl extends DynamicArray { private value?: TItem[] private uint8ArrayValue?: Uint8Array - private typeInfo: TypeInfo + typeInfo: TypeInfo genericArgs: DynamicArrayGenericArgs constructor(typeInfo: TypeInfo | string, ...items: TItem[]) { @@ -554,6 +573,10 @@ export class DynamicArrayImpl extends DynamicArray } + get native(): TItem[] { + return this.items + } + push(...values: TItem[]) { const items = this.items items.push(...values) @@ -594,7 +617,7 @@ export class DynamicArrayImpl extends DynamicArray extends Tuple { private value?: TTuple private uint8ArrayValue?: Uint8Array - private typeInfo: TypeInfo + typeInfo: TypeInfo genericArgs: TypeInfo[] constructor(typeInfo: TypeInfo | string) @@ -691,7 +714,6 @@ export class TupleImpl extends T type StructConstraint = Record export class StructImpl extends (Struct as DeliberateAny) { private uint8ArrayValue?: Uint8Array - private typeInfo: TypeInfo genericArgs: Record constructor(typeInfo: TypeInfo | string, value: T = {} as T) { @@ -737,6 +759,10 @@ export class StructImpl extends (Struct extends (Struct constructor(typeInfo: TypeInfo | string, value?: bytes | string) { @@ -825,7 +851,7 @@ export class DynamicBytesImpl extends DynamicBytes { export class StaticBytesImpl extends StaticBytes { private value: StaticArrayImpl - private typeInfo: TypeInfo + typeInfo: TypeInfo constructor(typeInfo: TypeInfo | string, value?: bytes | string) { super(value) @@ -1161,3 +1187,85 @@ export const getArc4TypeName = (typeInfo: TypeInfo): string | undefined => { else if (typeof name === 'function') return name(typeInfo) return undefined } + +export function decodeArc4Impl(sourceTypeInfoString: string, bytes: internal.primitives.StubBytesCompat): T { + const sourceTypeInfo = JSON.parse(sourceTypeInfoString) + const encoder = getArc4Encoder(sourceTypeInfo) + const source = encoder(bytes, sourceTypeInfo) + + return getNativeValue(source) as T +} + +export function encodeArc4Impl(_targetTypeInfoString: string, source: T): bytes { + const arc4Encoded = getArc4Encoded(source) + return arc4Encoded.bytes +} + +const getNativeValue = (value: DeliberateAny): DeliberateAny => { + const native = (value as DeliberateAny).native + if (Array.isArray(native)) { + return native.map((item) => getNativeValue(item)) + } else if (native instanceof internal.primitives.AlgoTsPrimitiveCls) { + return native + } else if (typeof native === 'object') { + return Object.fromEntries(Object.entries(native).map(([key, value]) => [key, getNativeValue(value)])) + } + return native +} + +const getArc4Encoded = (value: DeliberateAny): ARC4Encoded => { + if (value instanceof ARC4Encoded) { + return value + } + if (value instanceof AccountCls) { + const index = (lazyContext.activeGroup.activeTransaction as ApplicationTransaction).apat.indexOf(value) + return new UintNImpl({ name: 'UintN<64>', genericArgs: [{ name: '64' }] }, asBigInt(index)) + } + if (value instanceof AssetCls) { + const index = (lazyContext.activeGroup.activeTransaction as ApplicationTransaction).apas.indexOf(value) + return new UintNImpl({ name: 'UintN<64>', genericArgs: [{ name: '64' }] }, asBigInt(index)) + } + if (value instanceof ApplicationCls) { + const index = (lazyContext.activeGroup.activeTransaction as ApplicationTransaction).apfa.indexOf(value) + return new UintNImpl({ name: 'UintN<64>', genericArgs: [{ name: '64' }] }, asBigInt(index)) + } + if (typeof value === 'boolean') { + return new BoolImpl({ name: 'Bool' }, value) + } + if (value instanceof internal.primitives.Uint64Cls || typeof value === 'number') { + return new UintNImpl({ name: 'UintN<64>', genericArgs: [{ name: '64' }] }, asBigInt(value)) + } + if (value instanceof internal.primitives.BigUintCls) { + return new UintNImpl({ name: 'UintN<512>', genericArgs: [{ name: '512' }] }, value.asBigInt()) + } + if (typeof value === 'bigint') { + return new UintNImpl({ name: 'UintN<512>', genericArgs: [{ name: '512' }] }, value) + } + if (value instanceof internal.primitives.BytesCls) { + return new DynamicBytesImpl( + { name: 'DynamicBytes', genericArgs: { elementType: { name: 'Byte', genericArgs: [{ name: '8' }] } } }, + value.asAlgoTs(), + ) + } + if (typeof value === 'string') { + return new StrImpl({ name: 'Str' }, value) + } + if (Array.isArray(value)) { + const result: ARC4Encoded[] = value.reduce((acc: ARC4Encoded[], cur: DeliberateAny) => { + return acc.concat(getArc4Encoded(cur)) + }, []) + const genericArgs: TypeInfo[] = result.map((x) => (x as DeliberateAny).typeInfo) + const typeInfo = { name: `Tuple<[${genericArgs.map((x) => x.name).join(',')}]>`, genericArgs } + return new TupleImpl(typeInfo, ...(result as [])) + } + if (typeof value === 'object') { + const result = Object.values(value).reduce((acc: ARC4Encoded[], cur: DeliberateAny) => { + return acc.concat(getArc4Encoded(cur)) + }, []) + const genericArgs: TypeInfo[] = result.map((x) => (x as DeliberateAny).typeInfo) + const typeInfo = { name: 'Struct', genericArgs: Object.fromEntries(Object.keys(value).map((x, i) => [x, genericArgs[i]])) } + return new StructImpl(typeInfo, Object.fromEntries(Object.keys(value).map((x, i) => [x, result[i]]))) + } + + throw internal.errors.codeError(`Unsupported type for encoding: ${typeof value}`) +} diff --git a/src/impl/transactions.ts b/src/impl/transactions.ts index 6e0b85e..fda0abd 100644 --- a/src/impl/transactions.ts +++ b/src/impl/transactions.ts @@ -307,6 +307,15 @@ export class ApplicationTransaction extends TransactionBase implements gtxn.Appl get lastLog() { return this.#appLogs.at(-1) ?? lazyContext.getApplicationData(this.appId.id).appLogs.at(-1) ?? Bytes() } + get apat() { + return this.#accounts + } + get apas() { + return this.#assets + } + get apfa() { + return this.#apps + } appArgs(index: internal.primitives.StubUint64Compat): bytes { return toBytes(this.#appArgs[asNumber(index)]) } diff --git a/src/runtime-helpers.ts b/src/runtime-helpers.ts index 48b08d6..82aab27 100644 --- a/src/runtime-helpers.ts +++ b/src/runtime-helpers.ts @@ -8,6 +8,7 @@ import { nameOfType } from './util' export { attachAbiMetadata } from './abi-metadata' export * from './impl/encoded-types' +export { decodeArc4Impl, encodeArc4Impl } from './impl/encoded-types' export { ensureBudgetImpl } from './impl/ensure-budget' export { TemplateVarImpl } from './impl/template-var' diff --git a/src/test-transformer/node-factory.ts b/src/test-transformer/node-factory.ts index 684c734..faec9ad 100644 --- a/src/test-transformer/node-factory.ts +++ b/src/test-transformer/node-factory.ts @@ -94,17 +94,19 @@ export const nodeFactory = { ) }, - callStubbedFunction(functionName: string, node: ts.CallExpression, typeInfo?: TypeInfo) { - const infoString = JSON.stringify(typeInfo) + callStubbedFunction(functionName: string, node: ts.CallExpression, ...typeInfos: (TypeInfo | undefined)[]) { + const infoStringArray = typeInfos.length ? typeInfos.map((typeInfo) => JSON.stringify(typeInfo)) : undefined const updatedPropertyAccessExpression = factory.createPropertyAccessExpression( factory.createIdentifier('runtimeHelpers'), `${functionName}Impl`, ) - + const typeInfoArgs = infoStringArray + ? infoStringArray?.filter((s) => !!s).map((infoString) => factory.createStringLiteral(infoString)) + : undefined return factory.createCallExpression( updatedPropertyAccessExpression, node.typeArguments, - [infoString ? factory.createStringLiteral(infoString) : undefined, ...(node.arguments ?? [])].filter((arg) => !!arg), + [...(typeInfoArgs ?? []), ...(node.arguments ?? [])].filter((arg) => !!arg), ) }, } satisfies Record ts.Node> diff --git a/src/test-transformer/visitors.ts b/src/test-transformer/visitors.ts index 8275563..d621436 100644 --- a/src/test-transformer/visitors.ts +++ b/src/test-transformer/visitors.ts @@ -111,7 +111,13 @@ class ExpressionVisitor { } if (ts.isCallExpression(updatedNode)) { const stubbedFunctionName = tryGetStubbedFunctionName(updatedNode, this.helper) - updatedNode = stubbedFunctionName ? nodeFactory.callStubbedFunction(stubbedFunctionName, updatedNode, info) : updatedNode + const infos = [info] + if (isCallingDecodeArc4(stubbedFunctionName)) { + const targetType = ptypes.ptypeToArc4EncodedType(type, this.helper.sourceLocation(node)) + const targetTypeInfo = getGenericTypeInfo(targetType) + infos[0] = targetTypeInfo + } + updatedNode = stubbedFunctionName ? nodeFactory.callStubbedFunction(stubbedFunctionName, updatedNode, ...infos) : updatedNode } return isGeneric ? nodeFactory.captureGenericTypeInfo(ts.visitEachChild(updatedNode, this.visit, this.context), JSON.stringify(info)) @@ -289,6 +295,7 @@ const isGenericType = (type: ptypes.PType): boolean => ptypes.StaticArrayType, ptypes.UFixedNxMType, ptypes.UintNType, + ptypes.TuplePType, ) const isArc4EncodedType = (type: ptypes.PType): boolean => @@ -356,3 +363,5 @@ const tryGetStubbedFunctionName = (node: ts.CallExpression, helper: VisitorHelpe const stubbedFunctionNames = ['interpretAsArc4', 'decodeArc4', 'encodeArc4', 'TemplateVar', 'ensureBudget'] return stubbedFunctionNames.includes(functionName) ? functionName : undefined } + +const isCallingDecodeArc4 = (functionName: string | undefined): boolean => ['decodeArc4', 'encodeArc4'].includes(functionName ?? '') diff --git a/src/value-generators/arc4.ts b/src/value-generators/arc4.ts index e9df2ad..9b16093 100644 --- a/src/value-generators/arc4.ts +++ b/src/value-generators/arc4.ts @@ -11,7 +11,10 @@ export class Arc4ValueGenerator { * */ address(): arc4.Address { const source = new AvmValueGenerator().account() - const result = new AddressImpl({ name: 'StaticArray', genericArgs: { elementType: { name: 'Byte' }, size: { name: '32' } } }, source) + const result = new AddressImpl( + { name: 'StaticArray', genericArgs: { elementType: { name: 'Byte', genericArgs: [{ name: '8' }] }, size: { name: '32' } } }, + source, + ) return result } @@ -93,7 +96,7 @@ export class Arc4ValueGenerator { * */ dynamicBytes(n: number): arc4.DynamicBytes { return new DynamicBytesImpl( - { name: 'DynamicArray', genericArgs: { elementType: { name: 'Byte' } } }, + { name: 'DynamicBytes', genericArgs: { elementType: { name: 'Byte', genericArgs: [{ name: '8' }] } } }, getRandomBytes(n / BITS_IN_BYTE).asAlgoTs(), ) } diff --git a/tests/arc4/encode-decode-arc4.spec.ts b/tests/arc4/encode-decode-arc4.spec.ts new file mode 100644 index 0000000..bf368fc --- /dev/null +++ b/tests/arc4/encode-decode-arc4.spec.ts @@ -0,0 +1,130 @@ +import { biguint, bytes, Bytes, internal, uint64 } from '@algorandfoundation/algorand-typescript' +import { Bool, decodeArc4, DynamicBytes, encodeArc4, Str, Struct, Tuple, UintN } from '@algorandfoundation/algorand-typescript/arc4' +import { describe, expect, test } from 'vitest' +import { MAX_UINT128 } from '../../src/constants' +import { DeliberateAny } from '../../src/typescript-helpers' +import { asBytes } from '../../src/util' + +const nativeString = 'hello' +const nativeNumber = 42 +const nativeBigInt = MAX_UINT128 +const nativeBool = true +const nativeBytes = Bytes('hello') + +const abiString = new Str('hello') +const abiUint64 = new UintN<64>(42) +const abiUint512 = new UintN<512>(MAX_UINT128) +const abiBool = new Bool(true) +const abiBytes = new DynamicBytes(Bytes('hello')) + +class Swapped1 extends Struct<{ + b: UintN<64> + c: Bool + d: Str + a: Tuple<[UintN<64>, Bool, Bool]> +}> {} + +const testData = [ + { + nativeValues() { + return [nativeNumber, nativeNumber, nativeBigInt, nativeBytes] + }, + abiValues() { + return [abiUint64, abiUint64, abiUint512, abiBytes] as readonly [UintN<64>, UintN<64>, UintN<512>, DynamicBytes] + }, + arc4Value() { + return new Tuple<[UintN<64>, UintN<64>, UintN<512>, DynamicBytes]>(abiUint64, abiUint64, abiUint512, abiBytes) + }, + decode(value: internal.primitives.StubBytesCompat) { + return decodeArc4<[uint64, uint64, biguint, bytes]>(asBytes(value)) + }, + }, + { + nativeValues() { + return [ + [nativeBool, [nativeString, nativeBool]], + [nativeNumber, nativeNumber], + [nativeBigInt, nativeBytes, { b: nativeNumber, c: nativeBool, d: nativeString, a: [nativeNumber, nativeBool, nativeBool] }], + ] + }, + abiValues() { + return [ + new Tuple<[Bool, Tuple<[Str, Bool]>]>(abiBool, new Tuple<[Str, Bool]>(abiString, abiBool)), + new Tuple<[UintN<64>, UintN<64>]>(abiUint64, abiUint64), + new Tuple<[UintN<512>, DynamicBytes, Swapped1]>( + abiUint512, + abiBytes, + new Swapped1({ b: abiUint64, c: abiBool, d: abiString, a: new Tuple<[UintN<64>, Bool, Bool]>(abiUint64, abiBool, abiBool) }), + ), + ] as readonly [Tuple<[Bool, Tuple<[Str, Bool]>]>, Tuple<[UintN<64>, UintN<64>]>, Tuple<[UintN<512>, DynamicBytes, Swapped1]>] + }, + arc4Value() { + return new Tuple<[Tuple<[Bool, Tuple<[Str, Bool]>]>, Tuple<[UintN<64>, UintN<64>]>, Tuple<[UintN<512>, DynamicBytes, Swapped1]>]>( + ...this.abiValues(), + ) + }, + decode(value: internal.primitives.StubBytesCompat) { + return decodeArc4< + [ + [boolean, [string, boolean]], + [uint64, uint64], + [ + biguint, + bytes, + { + b: uint64 + c: boolean + d: string + a: [uint64, boolean, boolean] + }, + ], + ] + >(asBytes(value)) + }, + }, + { + nativeValues() { + return { b: nativeNumber, c: nativeBool, d: nativeString, a: [nativeNumber, nativeBool, nativeBool] } + }, + abiValues() { + return { b: abiUint64, c: abiBool, d: abiString, a: new Tuple<[UintN<64>, Bool, Bool]>(abiUint64, abiBool, abiBool) } + }, + arc4Value() { + return new Swapped1(this.abiValues()) + }, + decode(value: internal.primitives.StubBytesCompat) { + return decodeArc4<{ b: uint64; c: boolean; d: string; a: [uint64, boolean, boolean] }>(asBytes(value)) + }, + }, +] + +describe('decodeArc4', () => { + test.each(testData)('should decode ABI values', (data) => { + const nativeValues = data.nativeValues() + const arc4Value = data.arc4Value() + + const result = data.decode(arc4Value.bytes) + + compareNativeValues(result, nativeValues) + }) +}) + +describe('encodeArc4', () => { + test.each(testData)('should encode native values', (data) => { + const nativeValues = data.nativeValues() + const arc4Value = data.arc4Value() + + const result = encodeArc4(nativeValues) + + expect(result).toEqual(arc4Value.bytes) + }) +}) + +const compareNativeValues = (a: DeliberateAny, b: DeliberateAny) => { + if (Array.isArray(a)) { + for (let i = 0; i < a.length; i++) { + compareNativeValues(a[i], b[i]) + } + } + expect(a).toEqual(b) +}