From 7d1353964e4a7c4ad285ef16fb5728474fae6944 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Mon, 2 Dec 2024 15:07:13 -0800 Subject: [PATCH 01/17] Update dependencies --- yarn.lock | 165 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 100 insertions(+), 65 deletions(-) diff --git a/yarn.lock b/yarn.lock index 39cfd48..a7e3ae8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1303,30 +1303,32 @@ "@typescript-eslint/types" "5.41.0" eslint-visitor-keys "^3.3.0" -"@wharfkit/abicache@^1.1.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@wharfkit/abicache/-/abicache-1.1.1.tgz#03624d03d9466e7def278786aaf074d274fc5650" - integrity sha512-CfpHzCLxFATcfReqdJDUxEDSHIeBF3jFx0cP8RcTDyhC2jX4cd+Q/wqjw/kCni3xrBM7cIGUp9c9NZdvdTK9Cg== +"@wharfkit/abicache@^1.2.0", "@wharfkit/abicache@^1.2.1": + version "1.2.2" + resolved "https://registry.yarnpkg.com/@wharfkit/abicache/-/abicache-1.2.2.tgz#c3d83485e3e3782ac94ced460915bad1ceee0be9" + integrity sha512-yOsYz2qQpQy7Nb8XZj62pZqp8YnmWDqFlrenYksBb9jl+1aWIpFhWd+14VEez4tUAezRH4UWW+w1SX5vhmUY9A== dependencies: - "@wharfkit/antelope" "^0.7.3" - "@wharfkit/signing-request" "^3.0.0" + "@wharfkit/antelope" "^1.0.2" + "@wharfkit/signing-request" "^3.1.0" pako "^2.0.4" tslib "^2.1.0" -"@wharfkit/abicache@^1.2.0": - version "1.2.0" - resolved "https://registry.yarnpkg.com/@wharfkit/abicache/-/abicache-1.2.0.tgz#f67f7bbd854adc443c3e363d5fbe3d27ac4f8383" - integrity sha512-1+564ODM1KhUs7chE8KpYhnxShuPLC1MvqYcXVuLosxXXwcYC4IiJ1V3VuikLG+xfBDp1GZivGjHQwv1awE2Zw== - dependencies: - "@wharfkit/antelope" "^1.0.0" - "@wharfkit/signing-request" "^3.1.0" - pako "^2.0.4" +"@wharfkit/account@^1.0.0": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@wharfkit/account/-/account-1.2.1.tgz#80015dd84d91fbce17ff94c623cfa102ddc34a71" + integrity sha512-y65KKy2foeG7wZSCEqoSuax4HY2du9HjqKhCQQny3+3SW0tJwcqLUN06+VJ1+jCOZGGOqfnEaZgxEKHT8S8ymQ== + dependencies: + "@wharfkit/antelope" "^1.0.7" + "@wharfkit/common" "^1.2.0" + "@wharfkit/contract" "^1.0.0" + "@wharfkit/resources" "^1.2.3" + "@wharfkit/token" "^1.1.2" tslib "^2.1.0" -"@wharfkit/antelope@^0.7.3", "@wharfkit/antelope@^1.0.0", "@wharfkit/antelope@^1.0.4": - version "1.0.4" - resolved "https://registry.yarnpkg.com/@wharfkit/antelope/-/antelope-1.0.4.tgz#f88305957c82fac41862a973581797ed29b5c287" - integrity sha512-FGB7YiTRz86T2V8XJNJGrrNBnIx9y+DV9MqXNwEHBwxzmXdA8Gurk7AQ5RfIQEllJeZbeMd6BeRT1nxQUUTRwQ== +"@wharfkit/antelope@^1.0.0", "@wharfkit/antelope@^1.0.11", "@wharfkit/antelope@^1.0.2", "@wharfkit/antelope@^1.0.4", "@wharfkit/antelope@^1.0.5", "@wharfkit/antelope@^1.0.7": + version "1.0.13" + resolved "https://registry.yarnpkg.com/@wharfkit/antelope/-/antelope-1.0.13.tgz#216b28da9d9a91ece9db273447f4419aa770657f" + integrity sha512-f4O5O8+6Bd5BHpMUHTmlWQmlhX5xYb4AfzT2NJweyqIPqQOstm+aInF42AtUhSALDa8fvoY80YZoqwM0L8TUyw== dependencies: bn.js "^4.11.9" brorand "^1.1.0" @@ -1335,56 +1337,79 @@ pako "^2.1.0" tslib "^2.0.3" -"@wharfkit/common@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@wharfkit/common/-/common-1.1.0.tgz#1ee9dd1ba9e202002fadd20593f5f42a3e67c827" - integrity sha512-A1Ta8zrEXkuEQcEiEexG0BVrYOxqm75qbLYU9tGNhyw4z/vQiF6rzmCOqhmWGg6nE2J2GYPvrPZPZzDmRGtG+w== +"@wharfkit/common@^1.2.0": + version "1.4.1" + resolved "https://registry.yarnpkg.com/@wharfkit/common/-/common-1.4.1.tgz#6574627a01b9105626c6c95c737df664440fc8fa" + integrity sha512-rYtlsDM+U//xynlIfN17QrfAiDq7lTTkvsgTn+yUgomKCI0Tku6YSTtC2BJrJs7dfxTpCPZ200kIdaYEHwJP7w== dependencies: tslib "^2.1.0" +"@wharfkit/contract@^1.0.0", "@wharfkit/contract@^1.1.4": + version "1.1.5" + resolved "https://registry.yarnpkg.com/@wharfkit/contract/-/contract-1.1.5.tgz#2ca10090330cbb458049890076089237b644eb0e" + integrity sha512-I4w2QFvD/zb4uj5z0U4uQJLRCiZEbrT+AJ9/5goGm6SU42fsRud/k55qSBzW8Ij00OAv2h1+e8rR7xzUruXC9g== + dependencies: + "@wharfkit/abicache" "^1.2.0" + "@wharfkit/antelope" "^1.0.4" + "@wharfkit/signing-request" "^3.1.0" + tslib "^2.1.0" + "@wharfkit/mock-data@^1.0.2": - version "1.0.2" - resolved "https://registry.yarnpkg.com/@wharfkit/mock-data/-/mock-data-1.0.2.tgz#81d6327c76032b40e5acf209d507cf6ca2a3ae9f" - integrity sha512-Mbf/rZX2dqj5r+h+6NcRsDfRdHZ5OWEk0oIZ6iarXEBV65jmODoLdZlS906m9ndC1bi1ewCm/276JDimIqtLkQ== + version "1.3.0" + resolved "https://registry.yarnpkg.com/@wharfkit/mock-data/-/mock-data-1.3.0.tgz#7a9caa7c7fb2ad839bc12593de1b7a546b673ae6" + integrity sha512-LkhAkrUOvG6o+lPWb2Q6JCrs9++F2XowGK42PODh35Xu9an5H+THMGjpUhTC1sPiYkfjhkmBbAzMpZbHjkXj4w== dependencies: - "@wharfkit/antelope" "^0.7.3" - "@wharfkit/session" "^1.0.0" - "@wharfkit/wallet-plugin-privatekey" "^1.0.0" + "@wharfkit/antelope" "^1.0.5" + "@wharfkit/session" "^1.2.7" + "@wharfkit/wallet-plugin-privatekey" "^1.1.0" node-fetch "^2.6.1" tslib "^2.1.0" -"@wharfkit/session@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@wharfkit/session/-/session-1.0.0.tgz#09c60d01a6185ab2e451d34462d84de2d7013220" - integrity sha512-wXmvOVBZ1Rp/9HPUzGPaD/vpGXv2FCNgl8JRLopKgKPHkkEX/u4untshHR8AwSc0ZitjOlv6ubR2h9/UW8h6ug== +"@wharfkit/resources@^1.2.3": + version "1.3.1" + resolved "https://registry.yarnpkg.com/@wharfkit/resources/-/resources-1.3.1.tgz#e411c4bd7adef56a22a0a1c2305ee0b30db86dd8" + integrity sha512-XgL/yiwcJia8chYySt2dBOxa4BRKPqMeNxaZFvvzLgBI3s7m6MUXlXpZSeBvaQH+dr9D9nlBbmgP7PCBrJITIg== dependencies: - "@wharfkit/abicache" "^1.1.1" - "@wharfkit/antelope" "^0.7.3" - "@wharfkit/common" "^1.1.0" - "@wharfkit/signing-request" "^3.0.0" - pako "^2.0.4" + "@wharfkit/antelope" "^1.0.0" + bn.js "^4.11.9" + js-big-decimal "^2.0.7" tslib "^2.1.0" -"@wharfkit/signing-request@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@wharfkit/signing-request/-/signing-request-3.0.0.tgz#3464cdc76c0690ab241d805116101e3ed63ba846" - integrity sha512-+9UaznhYlZSgdZGG/LF5GkH7P9dCVh+b32cR1PYHKG6KuOsPlLqfv1DuWkqsxQyi3kGT1fXG1i8sl39ItgwLzg== +"@wharfkit/session@^1.0.0", "@wharfkit/session@^1.2.7": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@wharfkit/session/-/session-1.4.0.tgz#13a44a0d23d5ee689755985580f943f869352987" + integrity sha512-U+K9eWbYzFeDshYwgrhyNoF47kYToKFpTe6xFAwaJO+2w0kIkP0vtJFl7ygd06muh7Hu3K1BqrZ3j6+FyyuIyA== dependencies: - "@wharfkit/antelope" "^0.7.3" - tslib "^2.0.3" + "@wharfkit/abicache" "^1.2.1" + "@wharfkit/account" "^1.0.0" + "@wharfkit/antelope" "^1.0.11" + "@wharfkit/common" "^1.2.0" + "@wharfkit/signing-request" "^3.1.0" + pako "^2.0.4" + tslib "^2.1.0" "@wharfkit/signing-request@^3.1.0": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@wharfkit/signing-request/-/signing-request-3.1.0.tgz#7883f0b2350c6fe3446d2b8733dd7d0004f01911" - integrity sha512-aVWV9Z3o77uDrFSR3wC78c1e/QNkfi3IxZbGzMizvoYTYPKHgHs1F6Go/1oe0Dlo/kEB9tgckFviccUqrK987w== + version "3.2.0" + resolved "https://registry.yarnpkg.com/@wharfkit/signing-request/-/signing-request-3.2.0.tgz#94cab97e27d1001973771056cfb9d54c02e45354" + integrity sha512-rIMzqwAKA5vb09+1BI+9fUXbj73JIkYcD1XT/Tom+k/+bqi51JcmC0trjCOjTUOK9UYDabpxYFixrf1ZvQymKw== dependencies: - "@wharfkit/antelope" "^1.0.0" + "@wharfkit/antelope" "^1.0.7" tslib "^2.0.3" -"@wharfkit/wallet-plugin-privatekey@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@wharfkit/wallet-plugin-privatekey/-/wallet-plugin-privatekey-1.0.0.tgz#2600cce1117ce9391c8078649e05ceaf93780f1d" - integrity sha512-V+/7T/cwoHM8fDaM3MZ1DFKrX2+NddBkkWJ8BIFfmEZnGR1W8Qr77t+piOP0/6UM2etmuZh98XLwZS33vORQ0A== +"@wharfkit/token@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@wharfkit/token/-/token-1.1.2.tgz#de01dc211c10e6d3ccf9948357e8373bf6067259" + integrity sha512-LYAGB7LnE3hxwjNsYYwpxbJ8APi0Y8pmh7i1SeKv13HaPVjuHisTnuPxJm3ndwU7pX9GT3hPyo/By0l3CEuLfw== + dependencies: + "@wharfkit/antelope" "^1.0.4" + "@wharfkit/contract" "^1.1.4" + bn.js "^4.11.9" + tslib "^2.1.0" + +"@wharfkit/wallet-plugin-privatekey@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@wharfkit/wallet-plugin-privatekey/-/wallet-plugin-privatekey-1.1.0.tgz#5985bff61895c54d2afbef359cd42da4f3871c7d" + integrity sha512-45LPj7AOVDm4RugDEhy0fnQX/BcMffeJPjGUCUrLazJ2S0Sti8nNk4nqiJqyme84c/0gq7d65vvwlmVfGtPVEg== dependencies: tslib "^2.1.0" @@ -1571,9 +1596,9 @@ binary-extensions@^2.0.0: integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== bn.js@^4.11.9: - version "4.12.0" - resolved "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz" - integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== + version "4.12.1" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.1.tgz#215741fe3c9dba2d7e12c001d0cfdbae43975ba7" + integrity sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg== brace-expansion@^1.1.7: version "1.1.11" @@ -1599,7 +1624,7 @@ braces@^3.0.2, braces@~3.0.2: brorand@^1.1.0: version "1.1.0" - resolved "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz" + resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" integrity sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w== browser-stdout@1.3.1: @@ -1887,9 +1912,9 @@ electron-to-chromium@^1.4.431: integrity sha512-XXRS5NFv8nCrBL74Rm3qhJjA2VCsRFx0OjHKBMPI0otij56aun8UWiKTDABmd5/7GTR021pA4wivs+Ri6XCElg== elliptic@^6.5.4: - version "6.5.4" - resolved "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz" - integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== + version "6.6.1" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.6.1.tgz#3b8ffb02670bf69e382c7f65bf524c97c5405c06" + integrity sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g== dependencies: bn.js "^4.11.9" brorand "^1.1.0" @@ -2398,7 +2423,7 @@ has@^1.0.3: hash.js@^1.0.0, hash.js@^1.0.3: version "1.1.7" - resolved "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz" + resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== dependencies: inherits "^2.0.3" @@ -2419,7 +2444,7 @@ he@1.2.0: hmac-drbg@^1.0.1: version "1.0.1" - resolved "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz" + resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" integrity sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg== dependencies: hash.js "^1.0.3" @@ -2464,7 +2489,7 @@ inflight@^1.0.4: inherits@2, inherits@^2.0.3, inherits@^2.0.4: version "2.0.4" - resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== is-arguments@^1.0.4: @@ -2665,6 +2690,11 @@ jest-worker@^26.2.1: merge-stream "^2.0.0" supports-color "^7.0.0" +js-big-decimal@^2.0.7: + version "2.1.0" + resolved "https://registry.yarnpkg.com/js-big-decimal/-/js-big-decimal-2.1.0.tgz#9e06c10590969aa1ffb8570af25072391b6973bb" + integrity sha512-6BOJi5gJ/u5KIOiRjwDnYee64wDw48/mzObV10L5ZYZ/u3ujpzJrO1JyIdIYbfxJPhIT7+oKn7d/1Fw1kOsh2w== + js-cleanup@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/js-cleanup/-/js-cleanup-1.2.0.tgz#8dbc65954b1d38b255f1e8cf02cd17b3f7a053f9" @@ -2870,12 +2900,12 @@ micromatch@^4.0.4: minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: version "1.0.1" - resolved "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz" + resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== minimalistic-crypto-utils@^1.0.1: version "1.0.1" - resolved "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz" + resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg== minimatch@5.0.1: @@ -3097,7 +3127,7 @@ package-hash@^4.0.0: pako@^2.0.4, pako@^2.1.0: version "2.1.0" - resolved "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz" + resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86" integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug== parent-module@^1.0.0: @@ -3626,7 +3656,12 @@ tslib@^1.8.1: resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@^2.0.3, tslib@^2.1.0, tslib@^2.5.0: +tslib@^2.0.3: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== + +tslib@^2.1.0, tslib@^2.5.0: version "2.6.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.1.tgz#fd8c9a0ff42590b25703c0acb3de3d3f4ede0410" integrity sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig== From 1a074d7c777874da2528015f3b36e02d1c8e1b7b Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Mon, 2 Dec 2024 15:12:18 -0800 Subject: [PATCH 02/17] Revert "Update dependencies" This reverts commit 7d1353964e4a7c4ad285ef16fb5728474fae6944. --- yarn.lock | 165 +++++++++++++++++++++--------------------------------- 1 file changed, 65 insertions(+), 100 deletions(-) diff --git a/yarn.lock b/yarn.lock index a7e3ae8..39cfd48 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1303,32 +1303,30 @@ "@typescript-eslint/types" "5.41.0" eslint-visitor-keys "^3.3.0" -"@wharfkit/abicache@^1.2.0", "@wharfkit/abicache@^1.2.1": - version "1.2.2" - resolved "https://registry.yarnpkg.com/@wharfkit/abicache/-/abicache-1.2.2.tgz#c3d83485e3e3782ac94ced460915bad1ceee0be9" - integrity sha512-yOsYz2qQpQy7Nb8XZj62pZqp8YnmWDqFlrenYksBb9jl+1aWIpFhWd+14VEez4tUAezRH4UWW+w1SX5vhmUY9A== +"@wharfkit/abicache@^1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@wharfkit/abicache/-/abicache-1.1.1.tgz#03624d03d9466e7def278786aaf074d274fc5650" + integrity sha512-CfpHzCLxFATcfReqdJDUxEDSHIeBF3jFx0cP8RcTDyhC2jX4cd+Q/wqjw/kCni3xrBM7cIGUp9c9NZdvdTK9Cg== dependencies: - "@wharfkit/antelope" "^1.0.2" - "@wharfkit/signing-request" "^3.1.0" + "@wharfkit/antelope" "^0.7.3" + "@wharfkit/signing-request" "^3.0.0" pako "^2.0.4" tslib "^2.1.0" -"@wharfkit/account@^1.0.0": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@wharfkit/account/-/account-1.2.1.tgz#80015dd84d91fbce17ff94c623cfa102ddc34a71" - integrity sha512-y65KKy2foeG7wZSCEqoSuax4HY2du9HjqKhCQQny3+3SW0tJwcqLUN06+VJ1+jCOZGGOqfnEaZgxEKHT8S8ymQ== - dependencies: - "@wharfkit/antelope" "^1.0.7" - "@wharfkit/common" "^1.2.0" - "@wharfkit/contract" "^1.0.0" - "@wharfkit/resources" "^1.2.3" - "@wharfkit/token" "^1.1.2" +"@wharfkit/abicache@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@wharfkit/abicache/-/abicache-1.2.0.tgz#f67f7bbd854adc443c3e363d5fbe3d27ac4f8383" + integrity sha512-1+564ODM1KhUs7chE8KpYhnxShuPLC1MvqYcXVuLosxXXwcYC4IiJ1V3VuikLG+xfBDp1GZivGjHQwv1awE2Zw== + dependencies: + "@wharfkit/antelope" "^1.0.0" + "@wharfkit/signing-request" "^3.1.0" + pako "^2.0.4" tslib "^2.1.0" -"@wharfkit/antelope@^1.0.0", "@wharfkit/antelope@^1.0.11", "@wharfkit/antelope@^1.0.2", "@wharfkit/antelope@^1.0.4", "@wharfkit/antelope@^1.0.5", "@wharfkit/antelope@^1.0.7": - version "1.0.13" - resolved "https://registry.yarnpkg.com/@wharfkit/antelope/-/antelope-1.0.13.tgz#216b28da9d9a91ece9db273447f4419aa770657f" - integrity sha512-f4O5O8+6Bd5BHpMUHTmlWQmlhX5xYb4AfzT2NJweyqIPqQOstm+aInF42AtUhSALDa8fvoY80YZoqwM0L8TUyw== +"@wharfkit/antelope@^0.7.3", "@wharfkit/antelope@^1.0.0", "@wharfkit/antelope@^1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@wharfkit/antelope/-/antelope-1.0.4.tgz#f88305957c82fac41862a973581797ed29b5c287" + integrity sha512-FGB7YiTRz86T2V8XJNJGrrNBnIx9y+DV9MqXNwEHBwxzmXdA8Gurk7AQ5RfIQEllJeZbeMd6BeRT1nxQUUTRwQ== dependencies: bn.js "^4.11.9" brorand "^1.1.0" @@ -1337,79 +1335,56 @@ pako "^2.1.0" tslib "^2.0.3" -"@wharfkit/common@^1.2.0": - version "1.4.1" - resolved "https://registry.yarnpkg.com/@wharfkit/common/-/common-1.4.1.tgz#6574627a01b9105626c6c95c737df664440fc8fa" - integrity sha512-rYtlsDM+U//xynlIfN17QrfAiDq7lTTkvsgTn+yUgomKCI0Tku6YSTtC2BJrJs7dfxTpCPZ200kIdaYEHwJP7w== - dependencies: - tslib "^2.1.0" - -"@wharfkit/contract@^1.0.0", "@wharfkit/contract@^1.1.4": - version "1.1.5" - resolved "https://registry.yarnpkg.com/@wharfkit/contract/-/contract-1.1.5.tgz#2ca10090330cbb458049890076089237b644eb0e" - integrity sha512-I4w2QFvD/zb4uj5z0U4uQJLRCiZEbrT+AJ9/5goGm6SU42fsRud/k55qSBzW8Ij00OAv2h1+e8rR7xzUruXC9g== +"@wharfkit/common@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@wharfkit/common/-/common-1.1.0.tgz#1ee9dd1ba9e202002fadd20593f5f42a3e67c827" + integrity sha512-A1Ta8zrEXkuEQcEiEexG0BVrYOxqm75qbLYU9tGNhyw4z/vQiF6rzmCOqhmWGg6nE2J2GYPvrPZPZzDmRGtG+w== dependencies: - "@wharfkit/abicache" "^1.2.0" - "@wharfkit/antelope" "^1.0.4" - "@wharfkit/signing-request" "^3.1.0" tslib "^2.1.0" "@wharfkit/mock-data@^1.0.2": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@wharfkit/mock-data/-/mock-data-1.3.0.tgz#7a9caa7c7fb2ad839bc12593de1b7a546b673ae6" - integrity sha512-LkhAkrUOvG6o+lPWb2Q6JCrs9++F2XowGK42PODh35Xu9an5H+THMGjpUhTC1sPiYkfjhkmBbAzMpZbHjkXj4w== + version "1.0.2" + resolved "https://registry.yarnpkg.com/@wharfkit/mock-data/-/mock-data-1.0.2.tgz#81d6327c76032b40e5acf209d507cf6ca2a3ae9f" + integrity sha512-Mbf/rZX2dqj5r+h+6NcRsDfRdHZ5OWEk0oIZ6iarXEBV65jmODoLdZlS906m9ndC1bi1ewCm/276JDimIqtLkQ== dependencies: - "@wharfkit/antelope" "^1.0.5" - "@wharfkit/session" "^1.2.7" - "@wharfkit/wallet-plugin-privatekey" "^1.1.0" + "@wharfkit/antelope" "^0.7.3" + "@wharfkit/session" "^1.0.0" + "@wharfkit/wallet-plugin-privatekey" "^1.0.0" node-fetch "^2.6.1" tslib "^2.1.0" -"@wharfkit/resources@^1.2.3": - version "1.3.1" - resolved "https://registry.yarnpkg.com/@wharfkit/resources/-/resources-1.3.1.tgz#e411c4bd7adef56a22a0a1c2305ee0b30db86dd8" - integrity sha512-XgL/yiwcJia8chYySt2dBOxa4BRKPqMeNxaZFvvzLgBI3s7m6MUXlXpZSeBvaQH+dr9D9nlBbmgP7PCBrJITIg== - dependencies: - "@wharfkit/antelope" "^1.0.0" - bn.js "^4.11.9" - js-big-decimal "^2.0.7" - tslib "^2.1.0" - -"@wharfkit/session@^1.0.0", "@wharfkit/session@^1.2.7": - version "1.4.0" - resolved "https://registry.yarnpkg.com/@wharfkit/session/-/session-1.4.0.tgz#13a44a0d23d5ee689755985580f943f869352987" - integrity sha512-U+K9eWbYzFeDshYwgrhyNoF47kYToKFpTe6xFAwaJO+2w0kIkP0vtJFl7ygd06muh7Hu3K1BqrZ3j6+FyyuIyA== +"@wharfkit/session@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@wharfkit/session/-/session-1.0.0.tgz#09c60d01a6185ab2e451d34462d84de2d7013220" + integrity sha512-wXmvOVBZ1Rp/9HPUzGPaD/vpGXv2FCNgl8JRLopKgKPHkkEX/u4untshHR8AwSc0ZitjOlv6ubR2h9/UW8h6ug== dependencies: - "@wharfkit/abicache" "^1.2.1" - "@wharfkit/account" "^1.0.0" - "@wharfkit/antelope" "^1.0.11" - "@wharfkit/common" "^1.2.0" - "@wharfkit/signing-request" "^3.1.0" + "@wharfkit/abicache" "^1.1.1" + "@wharfkit/antelope" "^0.7.3" + "@wharfkit/common" "^1.1.0" + "@wharfkit/signing-request" "^3.0.0" pako "^2.0.4" tslib "^2.1.0" -"@wharfkit/signing-request@^3.1.0": - version "3.2.0" - resolved "https://registry.yarnpkg.com/@wharfkit/signing-request/-/signing-request-3.2.0.tgz#94cab97e27d1001973771056cfb9d54c02e45354" - integrity sha512-rIMzqwAKA5vb09+1BI+9fUXbj73JIkYcD1XT/Tom+k/+bqi51JcmC0trjCOjTUOK9UYDabpxYFixrf1ZvQymKw== +"@wharfkit/signing-request@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@wharfkit/signing-request/-/signing-request-3.0.0.tgz#3464cdc76c0690ab241d805116101e3ed63ba846" + integrity sha512-+9UaznhYlZSgdZGG/LF5GkH7P9dCVh+b32cR1PYHKG6KuOsPlLqfv1DuWkqsxQyi3kGT1fXG1i8sl39ItgwLzg== dependencies: - "@wharfkit/antelope" "^1.0.7" + "@wharfkit/antelope" "^0.7.3" tslib "^2.0.3" -"@wharfkit/token@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@wharfkit/token/-/token-1.1.2.tgz#de01dc211c10e6d3ccf9948357e8373bf6067259" - integrity sha512-LYAGB7LnE3hxwjNsYYwpxbJ8APi0Y8pmh7i1SeKv13HaPVjuHisTnuPxJm3ndwU7pX9GT3hPyo/By0l3CEuLfw== +"@wharfkit/signing-request@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@wharfkit/signing-request/-/signing-request-3.1.0.tgz#7883f0b2350c6fe3446d2b8733dd7d0004f01911" + integrity sha512-aVWV9Z3o77uDrFSR3wC78c1e/QNkfi3IxZbGzMizvoYTYPKHgHs1F6Go/1oe0Dlo/kEB9tgckFviccUqrK987w== dependencies: - "@wharfkit/antelope" "^1.0.4" - "@wharfkit/contract" "^1.1.4" - bn.js "^4.11.9" - tslib "^2.1.0" + "@wharfkit/antelope" "^1.0.0" + tslib "^2.0.3" -"@wharfkit/wallet-plugin-privatekey@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@wharfkit/wallet-plugin-privatekey/-/wallet-plugin-privatekey-1.1.0.tgz#5985bff61895c54d2afbef359cd42da4f3871c7d" - integrity sha512-45LPj7AOVDm4RugDEhy0fnQX/BcMffeJPjGUCUrLazJ2S0Sti8nNk4nqiJqyme84c/0gq7d65vvwlmVfGtPVEg== +"@wharfkit/wallet-plugin-privatekey@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@wharfkit/wallet-plugin-privatekey/-/wallet-plugin-privatekey-1.0.0.tgz#2600cce1117ce9391c8078649e05ceaf93780f1d" + integrity sha512-V+/7T/cwoHM8fDaM3MZ1DFKrX2+NddBkkWJ8BIFfmEZnGR1W8Qr77t+piOP0/6UM2etmuZh98XLwZS33vORQ0A== dependencies: tslib "^2.1.0" @@ -1596,9 +1571,9 @@ binary-extensions@^2.0.0: integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== bn.js@^4.11.9: - version "4.12.1" - resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.1.tgz#215741fe3c9dba2d7e12c001d0cfdbae43975ba7" - integrity sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg== + version "4.12.0" + resolved "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz" + integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== brace-expansion@^1.1.7: version "1.1.11" @@ -1624,7 +1599,7 @@ braces@^3.0.2, braces@~3.0.2: brorand@^1.1.0: version "1.1.0" - resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" + resolved "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz" integrity sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w== browser-stdout@1.3.1: @@ -1912,9 +1887,9 @@ electron-to-chromium@^1.4.431: integrity sha512-XXRS5NFv8nCrBL74Rm3qhJjA2VCsRFx0OjHKBMPI0otij56aun8UWiKTDABmd5/7GTR021pA4wivs+Ri6XCElg== elliptic@^6.5.4: - version "6.6.1" - resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.6.1.tgz#3b8ffb02670bf69e382c7f65bf524c97c5405c06" - integrity sha512-RaddvvMatK2LJHqFJ+YA4WysVN5Ita9E35botqIYspQ4TkRAlCicdzKOjlyv/1Za5RyTNn7di//eEV0uTAfe3g== + version "6.5.4" + resolved "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz" + integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== dependencies: bn.js "^4.11.9" brorand "^1.1.0" @@ -2423,7 +2398,7 @@ has@^1.0.3: hash.js@^1.0.0, hash.js@^1.0.3: version "1.1.7" - resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" + resolved "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz" integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== dependencies: inherits "^2.0.3" @@ -2444,7 +2419,7 @@ he@1.2.0: hmac-drbg@^1.0.1: version "1.0.1" - resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" + resolved "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz" integrity sha512-Tti3gMqLdZfhOQY1Mzf/AanLiqh1WTiJgEj26ZuYQ9fbkLomzGchCws4FyrSd4VkpBfiNhaE1On+lOz894jvXg== dependencies: hash.js "^1.0.3" @@ -2489,7 +2464,7 @@ inflight@^1.0.4: inherits@2, inherits@^2.0.3, inherits@^2.0.4: version "2.0.4" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== is-arguments@^1.0.4: @@ -2690,11 +2665,6 @@ jest-worker@^26.2.1: merge-stream "^2.0.0" supports-color "^7.0.0" -js-big-decimal@^2.0.7: - version "2.1.0" - resolved "https://registry.yarnpkg.com/js-big-decimal/-/js-big-decimal-2.1.0.tgz#9e06c10590969aa1ffb8570af25072391b6973bb" - integrity sha512-6BOJi5gJ/u5KIOiRjwDnYee64wDw48/mzObV10L5ZYZ/u3ujpzJrO1JyIdIYbfxJPhIT7+oKn7d/1Fw1kOsh2w== - js-cleanup@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/js-cleanup/-/js-cleanup-1.2.0.tgz#8dbc65954b1d38b255f1e8cf02cd17b3f7a053f9" @@ -2900,12 +2870,12 @@ micromatch@^4.0.4: minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" + resolved "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz" integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== minimalistic-crypto-utils@^1.0.1: version "1.0.1" - resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" + resolved "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz" integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg== minimatch@5.0.1: @@ -3127,7 +3097,7 @@ package-hash@^4.0.0: pako@^2.0.4, pako@^2.1.0: version "2.1.0" - resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86" + resolved "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz" integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug== parent-module@^1.0.0: @@ -3656,12 +3626,7 @@ tslib@^1.8.1: resolved "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@^2.0.3: - version "2.8.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" - integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== - -tslib@^2.1.0, tslib@^2.5.0: +tslib@^2.0.3, tslib@^2.1.0, tslib@^2.5.0: version "2.6.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.1.tgz#fd8c9a0ff42590b25703c0acb3de3d3f4ede0410" integrity sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig== From 7df3e668227396345e49c85045f11e0c55ebf139 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Sat, 21 Dec 2024 11:16:03 -0800 Subject: [PATCH 03/17] Add `debug` flag to allow `json: true` on table requests --- src/contract.ts | 11 ++++- src/contract/table.ts | 13 ++++- src/kit.ts | 21 ++++++-- ...e42cd1ab2b6b573c3b13c24d5a057c979572f.json | 23 +++++++++ ...fa742787295d5854874aeb6ef78c442b50abb.json | 49 +++++++++++++++++++ test/tests/kit.ts | 12 +++++ test/tests/table.ts | 48 ++++++++++++++++++ 7 files changed, 170 insertions(+), 7 deletions(-) create mode 100644 test/data/requests/1c7e42cd1ab2b6b573c3b13c24d5a057c979572f.json create mode 100644 test/data/requests/366fa742787295d5854874aeb6ef78c442b50abb.json diff --git a/src/contract.ts b/src/contract.ts index 3768add..a5c0d73 100644 --- a/src/contract.ts +++ b/src/contract.ts @@ -22,6 +22,10 @@ export interface ContractArgs { client: APIClient } +export interface ContractOptions { + debug?: boolean +} + export interface ActionOptions { authorization?: PermissionLevelType[] } @@ -45,13 +49,14 @@ export class Contract { readonly abi: ABI readonly account: Name readonly client: APIClient + readonly debug: boolean = false /** * Constructs a new `Contract` instance. * * @param {ContractArgs} args - The required arguments for a contract. */ - constructor(args: ContractArgs) { + constructor(args: ContractArgs, options: ContractOptions = {}) { if (!args.abi) { throw new Error('Contract requires an ABI') } @@ -64,6 +69,9 @@ export class Contract { throw new Error('Contract requires an APIClient') } this.client = args.client + if (options.debug) { + this.debug = options.debug + } } public get tableNames(): string[] { @@ -82,6 +90,7 @@ export class Contract { abi: this.abi, account: this.account, client: this.client, + debug: this.debug, defaultScope: scope, name, rowType, diff --git a/src/contract/table.ts b/src/contract/table.ts index 9d675a5..9e442e0 100644 --- a/src/contract/table.ts +++ b/src/contract/table.ts @@ -30,6 +30,7 @@ interface TableParams { name: NameType rowType?: TableRow fieldToIndex?: FieldToIndex + debug?: boolean defaultRowLimit?: number defaultScope?: NameType } @@ -52,6 +53,7 @@ export class Table { readonly name: Name readonly rowType?: RowType readonly tableABI: ABI.Table + readonly debug: boolean = false private fieldToIndex?: any @@ -82,6 +84,9 @@ export class Table { } this.tableABI = tableABI this.defaultScope = args.defaultScope + if (args.debug) { + this.debug = true + } } /** @@ -118,6 +123,7 @@ export class Table { : this.defaultScope || this.account, // Response typing type: this.rowType, + json: this.debug, // Filtering index_position: params.index_position, key_type: params.key_type, @@ -174,7 +180,7 @@ export class Table { upper_bound: wrapIndexValue(value), index_position: params.index_position, key_type: params.key_type, - json: false, + json: this.debug, reverse: params.reverse, } @@ -199,6 +205,11 @@ export class Table { } let [row] = rows + // Debug mode will return a JSON result, so just return it + if (this.debug) { + return row + } + if (!this.rowType) { row = Serializer.decode({ data: row, diff --git a/src/kit.ts b/src/kit.ts index 21c347e..b381d0c 100644 --- a/src/kit.ts +++ b/src/kit.ts @@ -15,6 +15,7 @@ export interface ABIDefinition { export interface ContractKitOptions { abiCache?: ABICacheInterface abis?: ABIDefinition[] + debug?: boolean } const defaultContractKitOptions: ContractKitOptions = {} @@ -22,6 +23,7 @@ const defaultContractKitOptions: ContractKitOptions = {} export class ContractKit { readonly abiCache: ABICacheInterface readonly client: APIClient + readonly debug: boolean = false constructor(args: ContractKitArgs, options: ContractKitOptions = defaultContractKitOptions) { if (args.client) { @@ -43,6 +45,10 @@ export class ContractKit { this.abiCache.setAbi(Name.from(name), ABI.from(abi)) ) } + + if (options.debug) { + this.debug = options.debug + } } /** @@ -54,10 +60,15 @@ export class ContractKit { async load(contract: NameType): Promise { const account = Name.from(contract) const abiDef = await this.abiCache.getAbi(account) - return new Contract({ - abi: ABI.from(abiDef), - account, - client: this.client, - }) + return new Contract( + { + abi: ABI.from(abiDef), + account, + client: this.client, + }, + { + debug: this.debug, + } + ) } } diff --git a/test/data/requests/1c7e42cd1ab2b6b573c3b13c24d5a057c979572f.json b/test/data/requests/1c7e42cd1ab2b6b573c3b13c24d5a057c979572f.json new file mode 100644 index 0000000..4e62188 --- /dev/null +++ b/test/data/requests/1c7e42cd1ab2b6b573c3b13c24d5a057c979572f.json @@ -0,0 +1,23 @@ +{ + "request": { + "path": "https://eos.greymass.com/v1/chain/get_table_rows", + "params": { + "method": "POST", + "body": "{\"table\":\"namebids\",\"code\":\"eosio\",\"scope\":\"eosio\",\"limit\":1,\"key_type\":\"name\",\"json\":true}" + } + }, + "status": 200, + "json": { + "rows": [ + { + "newname": "", + "high_bidder": "guydgnjygige", + "high_bid": 3000, + "last_bid_time": "2018-06-21T03:51:50.500" + } + ], + "more": true, + "next_key": "594475150812905472" + }, + "text": "{\"rows\":[{\"newname\":\"\",\"high_bidder\":\"guydgnjygige\",\"high_bid\":3000,\"last_bid_time\":\"2018-06-21T03:51:50.500\"}],\"more\":true,\"next_key\":\"594475150812905472\"}" +} \ No newline at end of file diff --git a/test/data/requests/366fa742787295d5854874aeb6ef78c442b50abb.json b/test/data/requests/366fa742787295d5854874aeb6ef78c442b50abb.json new file mode 100644 index 0000000..f51407a --- /dev/null +++ b/test/data/requests/366fa742787295d5854874aeb6ef78c442b50abb.json @@ -0,0 +1,49 @@ +{ + "request": { + "path": "https://eos.greymass.com/v1/chain/get_table_rows", + "params": { + "method": "POST", + "body": "{\"json\":true,\"limit\":1000,\"table\":\"global\",\"code\":\"eosio\",\"scope\":\"eosio\",\"key_type\":\"name\"}" + } + }, + "status": 200, + "json": { + "rows": [ + { + "max_block_net_usage": 1048576, + "target_block_net_usage_pct": 10000, + "max_transaction_net_usage": 524288, + "base_per_transaction_net_usage": 12, + "net_usage_leeway": 500, + "context_free_discount_net_usage_num": 20, + "context_free_discount_net_usage_den": 100, + "max_block_cpu_usage": 200000, + "target_block_cpu_usage_pct": 10, + "max_transaction_cpu_usage": 150000, + "min_transaction_cpu_usage": 100, + "max_transaction_lifetime": 3600, + "deferred_trx_expiration_window": 600, + "max_transaction_delay": 3888000, + "max_inline_action_size": 524287, + "max_inline_action_depth": 10, + "max_authority_depth": 10, + "max_ram_size": "418945440768", + "total_ram_bytes_reserved": "333551148743", + "total_ram_stake": "213336801716", + "last_producer_schedule_update": "2024-12-21T19:15:00.500", + "last_pervote_bucket_fill": "2024-12-21T18:53:42.000", + "pervote_bucket": 257850978, + "perblock_bucket": 39779454, + "total_unpaid_blocks": 82609, + "total_activated_stake": "6092900115741", + "thresh_activated_stake_time": "2018-06-20T14:44:52.000", + "last_producer_schedule_size": 21, + "total_producer_vote_weight": "1410584016862351458304.00000000000000000", + "last_name_close": "2024-12-21T02:42:47.500" + } + ], + "more": false, + "next_key": "" + }, + "text": "{\"rows\":[{\"max_block_net_usage\":1048576,\"target_block_net_usage_pct\":10000,\"max_transaction_net_usage\":524288,\"base_per_transaction_net_usage\":12,\"net_usage_leeway\":500,\"context_free_discount_net_usage_num\":20,\"context_free_discount_net_usage_den\":100,\"max_block_cpu_usage\":200000,\"target_block_cpu_usage_pct\":10,\"max_transaction_cpu_usage\":150000,\"min_transaction_cpu_usage\":100,\"max_transaction_lifetime\":3600,\"deferred_trx_expiration_window\":600,\"max_transaction_delay\":3888000,\"max_inline_action_size\":524287,\"max_inline_action_depth\":10,\"max_authority_depth\":10,\"max_ram_size\":\"418945440768\",\"total_ram_bytes_reserved\":\"333551148743\",\"total_ram_stake\":\"213336801716\",\"last_producer_schedule_update\":\"2024-12-21T19:15:00.500\",\"last_pervote_bucket_fill\":\"2024-12-21T18:53:42.000\",\"pervote_bucket\":257850978,\"perblock_bucket\":39779454,\"total_unpaid_blocks\":82609,\"total_activated_stake\":\"6092900115741\",\"thresh_activated_stake_time\":\"2018-06-20T14:44:52.000\",\"last_producer_schedule_size\":21,\"total_producer_vote_weight\":\"1410584016862351458304.00000000000000000\",\"last_name_close\":\"2024-12-21T02:42:47.500\"}],\"more\":false,\"next_key\":\"\"}" +} \ No newline at end of file diff --git a/test/tests/kit.ts b/test/tests/kit.ts index c08c723..1d4ec2d 100644 --- a/test/tests/kit.ts +++ b/test/tests/kit.ts @@ -29,6 +29,18 @@ suite('Kit', function () { assert.instanceOf(kit, ContractKit) assert.instanceOf(kit.abiCache, ABICache) }) + test('options: debug', async function () { + const kit = new ContractKit(mockContractKitArgs, { + debug: true, + }) + assert.instanceOf(kit, ContractKit) + assert.isTrue(kit.debug) + const contract = await kit.load('eosio.token') + assert.instanceOf(contract, Contract) + assert.isTrue(contract.debug) + const table = contract.table('accounts') + assert.isTrue(table.debug) + }) suite('options: abis', function () { test('untyped', async function () { const kit = new ContractKit(mockContractKitArgs, { diff --git a/test/tests/table.ts b/test/tests/table.ts index a949a2c..71206ef 100644 --- a/test/tests/table.ts +++ b/test/tests/table.ts @@ -326,6 +326,18 @@ suite('Table', () => { [6, 5] ) }) + + test('should return deserialized data in debug', async function () { + const table = new Table({ + abi: eosio.abi, + account: 'eosio', + client: mockClient, + name: 'global', + debug: true, + }) + const row = await table.all() + assert.deepEqual(row, JSON.parse(JSON.stringify(row))) + }) }) suite('get', () => { @@ -418,6 +430,18 @@ suite('Table', () => { assert.isUndefined(row) }) + + test('should return deserialized data in debug', async function () { + const table = new Table({ + abi: eosio.abi, + account: 'eosio', + client: mockClient, + name: 'namebids', + debug: true, + }) + const row = await table.get() + assert.deepEqual(row, JSON.parse(JSON.stringify(row))) + }) }) suite('first', () => { @@ -485,6 +509,19 @@ suite('Table', () => { assert.instanceOf(batch[0].ref.category, Name) }) }) + + test('should return deserialized data in debug', async function () { + const table = new Table({ + abi: eosio.abi, + account: 'eosio', + client: mockClient, + name: 'global', + debug: true, + }) + const cursor = await table.query() + const row = await cursor.all() + assert.deepEqual(row, JSON.parse(JSON.stringify(row))) + }) }) suite('all', () => { @@ -496,6 +533,17 @@ suite('Table', () => { const tableRows = await nameBidTable.all() assert.instanceOf(tableRows[0].high_bidder, Name) }) + test('should return deserialized data in debug', async function () { + const table = new Table({ + abi: eosio.abi, + account: 'eosio', + client: mockClient, + name: 'global', + debug: true, + }) + const row = await table.all() + assert.deepEqual(row, JSON.parse(JSON.stringify(row))) + }) }) suite('scopes', () => { From a402273b4b4df6e0d63c9ad91e10a27f91dd0e51 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Sat, 21 Dec 2024 11:16:20 -0800 Subject: [PATCH 04/17] Version 1.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2d51da6..7677d72 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/contract", "description": "ContractKit for Wharf", - "version": "1.1.5", + "version": "1.2.0", "homepage": "https://github.com/wharfkit/contract", "license": "BSD-3-Clause", "main": "lib/contract.js", From bf9792eeb18b9223388c729ed23a2c55886425f8 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Sat, 1 Feb 2025 17:18:06 -0800 Subject: [PATCH 05/17] Helper to return next_key --- src/contract/table-cursor.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/contract/table-cursor.ts b/src/contract/table-cursor.ts index 75417e3..06bd888 100644 --- a/src/contract/table-cursor.ts +++ b/src/contract/table-cursor.ts @@ -68,6 +68,13 @@ export abstract class TableCursor { this.type = table.type } + /** + * Get the current next key value to use for the lower_bounds parameter in the next API request. + */ + get nextkey() { + return this.next_key + } + /** * Implements the async iterator protocol for the cursor. * From 1e84f06e2776e70cefce0b59ebcdbf5d638d9483 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Sat, 1 Feb 2025 17:18:34 -0800 Subject: [PATCH 06/17] Version 1.2.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7677d72..667802e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/contract", "description": "ContractKit for Wharf", - "version": "1.2.0", + "version": "1.2.1", "homepage": "https://github.com/wharfkit/contract", "license": "BSD-3-Clause", "main": "lib/contract.js", From 30b43b683fcd25b3ec02590bc43373e63af7ded2 Mon Sep 17 00:00:00 2001 From: Aaron Cox Date: Tue, 17 Jun 2025 15:53:53 -0700 Subject: [PATCH 07/17] Allow extracting nodeos API query params from cursor --- package.json | 2 +- src/contract/row-cursor.ts | 23 +++-------------------- src/contract/table-cursor.ts | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 667802e..794cb4c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/contract", "description": "ContractKit for Wharf", - "version": "1.2.1", + "version": "1.2.2-rc1", "homepage": "https://github.com/wharfkit/contract", "license": "BSD-3-Clause", "main": "lib/contract.js", diff --git a/src/contract/row-cursor.ts b/src/contract/row-cursor.ts index 3eef73f..2e0206c 100644 --- a/src/contract/row-cursor.ts +++ b/src/contract/row-cursor.ts @@ -1,5 +1,4 @@ import {API, Serializer} from '@wharfkit/antelope' -import {wrapIndexValue} from '../utils' import {TableCursor} from './table-cursor' export class TableRowCursor extends TableCursor { @@ -15,26 +14,10 @@ export class TableRowCursor extends TableCursor { return [] } - // Set the lower_bound, and override if the cursor has a next_key value - let lower_bound = this.params.lower_bound - if (this.next_key) { - lower_bound = this.next_key - } - - // Determine the maximum number of remaining rows for the cursor - const rowsRemaining = this.maxRows - this.rowsCount - - // Find the lowest amount between rows remaining, rows per request, or the provided query params limit - const limit = Math.min(rowsRemaining, rowsPerAPIRequest, this.params.limit) - - // Assemble and perform the v1/chain/get_table_rows query - const query = { - ...this.params, - limit, - lower_bound: wrapIndexValue(lower_bound), - upper_bound: wrapIndexValue(this.params.upper_bound), - } + // Assemble the query params + const query = this.getTableRowsParams(rowsPerAPIRequest) + // Execute the query const result = await this.client!.v1.chain.get_table_rows(query) // Determine if we need to decode the rows, based on if: diff --git a/src/contract/table-cursor.ts b/src/contract/table-cursor.ts index 06bd888..2c4abab 100644 --- a/src/contract/table-cursor.ts +++ b/src/contract/table-cursor.ts @@ -1,4 +1,5 @@ import {ABI, ABIDef, API, APIClient, Name} from '@wharfkit/antelope' +import {wrapIndexValue} from '../utils' /** Mashup of valid types for an APIClient call to v1.chain.get_table_rows */ export type TableRowParamsTypes = @@ -123,4 +124,30 @@ export abstract class TableCursor { } return rows } + + /** + * Build the query for the get_table_rows API endpoint. + */ + getTableRowsParams(rowsPerAPIRequest: number = Number.MAX_SAFE_INTEGER): any { + // Set the lower_bound, and override if the cursor has a next_key value + let lower_bound = this.params.lower_bound + if (this.next_key) { + lower_bound = this.next_key + } + + // Determine the maximum number of remaining rows for the cursor + const rowsRemaining = this.maxRows - this.rowsCount + + // Find the lowest amount between rows remaining, rows per request, or the provided query params limit + const limit = Math.min(rowsRemaining, rowsPerAPIRequest, this.params.limit) + + // Assemble and perform the v1/chain/get_table_rows query + const query = { + ...this.params, + limit, + lower_bound: wrapIndexValue(lower_bound), + upper_bound: wrapIndexValue(this.params.upper_bound), + } + return query + } } From 5bbb8b913bba676d4ac99f6c91e1620fa67d178c Mon Sep 17 00:00:00 2001 From: aaroncox Date: Fri, 25 Jul 2025 11:24:25 -0700 Subject: [PATCH 08/17] Catch/throw error during readonly call --- src/contract.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/contract.ts b/src/contract.ts index a5c0d73..790ebbb 100644 --- a/src/contract.ts +++ b/src/contract.ts @@ -142,6 +142,9 @@ export class Contract { }) // Execute and retrieve response const response = await this.client.v1.chain.send_read_only_transaction(transaction) + if (response.processed.except) { + throw new Error(response.processed.except.message) + } // Decode and return results const hexData = response.processed.action_traces[0].return_value_hex_data const returnType = this.abi.action_results.find((a) => Name.from(a.name).equals(name)) From 52421ef28d9bc03e28efefee0cb29b3202e4b183 Mon Sep 17 00:00:00 2001 From: aaroncox Date: Fri, 25 Jul 2025 11:25:25 -0700 Subject: [PATCH 09/17] v1.2.2-rc2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 794cb4c..07fe0b9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/contract", "description": "ContractKit for Wharf", - "version": "1.2.2-rc1", + "version": "1.2.2-rc2", "homepage": "https://github.com/wharfkit/contract", "license": "BSD-3-Clause", "main": "lib/contract.js", From 7c47d2f984ea963afbe3cae4e6c971ed664677d9 Mon Sep 17 00:00:00 2001 From: aaroncox Date: Tue, 5 May 2026 13:15:49 -0700 Subject: [PATCH 10/17] Better readonly exception handling --- src/contract.ts | 3 ++- src/utils.ts | 15 ++++++++++++ test/tests/utils.ts | 60 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 1 deletion(-) diff --git a/src/contract.ts b/src/contract.ts index 790ebbb..467a7e2 100644 --- a/src/contract.ts +++ b/src/contract.ts @@ -15,6 +15,7 @@ import { import {PlaceholderAuth} from '@wharfkit/signing-request' import {Table} from './contract/table' +import {formatExceptionMessage} from './utils' export interface ContractArgs { abi: ABIDef @@ -143,7 +144,7 @@ export class Contract { // Execute and retrieve response const response = await this.client.v1.chain.send_read_only_transaction(transaction) if (response.processed.except) { - throw new Error(response.processed.except.message) + throw new Error(formatExceptionMessage(response.processed.except)) } // Decode and return results const hexData = response.processed.action_traces[0].return_value_hex_data diff --git a/src/utils.ts b/src/utils.ts index aa2dbf8..372c097 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -89,3 +89,18 @@ export function blobStringToAbi(blobString: string): ABI { const blob = Blob.from(blobString) return ABI.from(blob) } + +export function formatExceptionMessage(except: API.v1.SendTransactionResponseException): string { + const top = except.stack?.[0] + if (top?.format) { + const data = top.data ?? {} + const substituted = top.format.replace(/\$\{(\w+)\}/g, (_, key) => + key in data ? String(data[key]) : `\${${key}}` + ) + if (substituted) return substituted + } + if (typeof top?.data?.s === 'string') { + return top.data.s + } + return except.message +} diff --git a/test/tests/utils.ts b/test/tests/utils.ts index 3062187..0b54ac9 100644 --- a/test/tests/utils.ts +++ b/test/tests/utils.ts @@ -6,6 +6,7 @@ import { abiToBlob, blobStringToAbi, capitalize, + formatExceptionMessage, indexPositionInWords, pascalCase, singularize, @@ -64,4 +65,63 @@ suite('Utility functions', function () { const result = blobStringToAbi(blobString) assert(result.equals(testABI)) }) + + suite('formatExceptionMessage', function () { + test('substitutes ${key} placeholders from stack[0]', function () { + const except: any = { + code: 3050003, + name: 'eosio_assert_message_exception', + message: 'eosio_assert_message assertion failure', + stack: [ + { + context: { + level: 'error', + file: 'cf_system.cpp', + line: 14, + method: 'eosio_assert', + }, + format: 'assertion failure with message: ${s}', + data: {s: 'container not found'}, + }, + ], + } + assert.equal( + formatExceptionMessage(except), + 'assertion failure with message: container not found' + ) + }) + + test('falls back to except.message when stack is empty', function () { + const except: any = { + code: 3080004, + name: 'tx_cpu_usage_exceeded', + message: 'transaction exceeded the current CPU usage limit', + stack: [], + } + assert.equal( + formatExceptionMessage(except), + 'transaction exceeded the current CPU usage limit' + ) + }) + + test('uses data.s when format is empty', function () { + const except: any = { + code: 3050003, + name: 'eosio_assert_message_exception', + message: 'eosio_assert_message assertion failure', + stack: [{context: {}, format: '', data: {s: 'leftover string'}}], + } + assert.equal(formatExceptionMessage(except), 'leftover string') + }) + + test('leaves unmatched placeholders intact', function () { + const except: any = { + code: 1, + name: 'whatever', + message: 'fallback', + stack: [{context: {}, format: 'oops ${missing}', data: {}}], + } + assert.equal(formatExceptionMessage(except), 'oops ${missing}') + }) + }) }) From 57457d97fa4adb1a9a8ca4d3632a70eaca2048ff Mon Sep 17 00:00:00 2001 From: aaroncox Date: Tue, 5 May 2026 13:16:53 -0700 Subject: [PATCH 11/17] 1.2.2-rc3 --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 07fe0b9..0500cf5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/contract", "description": "ContractKit for Wharf", - "version": "1.2.2-rc2", + "version": "1.2.2-rc3", "homepage": "https://github.com/wharfkit/contract", "license": "BSD-3-Clause", "main": "lib/contract.js", @@ -62,5 +62,6 @@ "typedoc": "^0.24.6", "typescript": "^4.9.5", "yarn-deduplicate": "^6.0.2" - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } From 27cadab49b2f9d2dc39e387fa324bac77c50512e Mon Sep 17 00:00:00 2001 From: aaroncox Date: Tue, 5 May 2026 13:40:39 -0700 Subject: [PATCH 12/17] Fix tests so they pass in node 20 --- test/tests/contract.ts | 8 +-- test/tests/helpers/generic.ts | 92 +++++++++++++++++++++-------------- 2 files changed, 59 insertions(+), 41 deletions(-) diff --git a/test/tests/contract.ts b/test/tests/contract.ts index 8298be7..c4acaeb 100644 --- a/test/tests/contract.ts +++ b/test/tests/contract.ts @@ -104,8 +104,8 @@ suite('Contract', async function () { suite('specific contract', function () { suite('system contract', function () { - suite('generic tests', async () => { - runGenericContractTests(systemContract) + suite('generic tests', function () { + runGenericContractTests(() => systemContract) }) suite('tableNames', function () { test('validate for contract', function () { @@ -255,8 +255,8 @@ suite('Contract', async function () { }) }) suite('token contract', function () { - suite('generic tests', async () => { - runGenericContractTests(tokenContract) + suite('generic tests', function () { + runGenericContractTests(() => tokenContract) }) suite('action', function () { suite('load', function () { diff --git a/test/tests/helpers/generic.ts b/test/tests/helpers/generic.ts index e90e02f..37ce289 100644 --- a/test/tests/helpers/generic.ts +++ b/test/tests/helpers/generic.ts @@ -39,48 +39,66 @@ export function getMockParams(contract: Contract): ActionDataType { } } -export function runGenericContractTests(contract: Contract) { - // suite: tableNames - // contains tables - assert.isArray(contract.tableNames) - assert.isTrue(contract.tableNames.length > 0) +export function runGenericContractTests(getContract: () => Contract) { + suite('tableNames', function () { + test('contains tables', function () { + const contract = getContract() + assert.isArray(contract.tableNames) + assert.isTrue(contract.tableNames.length > 0) + }) + }) - // suite: table - // load table using Name - const tableName = Name.from(contract.tableNames[0]) - const table = contract.table(tableName) - assert.instanceOf(table, Table) - assert.isTrue(table.name.equals(tableName)) + suite('table', function () { + test('loads table using Name', function () { + const contract = getContract() + const tableName = Name.from(contract.tableNames[0]) + const table = contract.table(tableName) + assert.instanceOf(table, Table) + assert.isTrue(table.name.equals(tableName)) + }) - // load table using string - const tableName2 = contract.tableNames[0] - const table2 = contract.table(tableName2) - assert.instanceOf(table2, Table) - assert.isTrue(table2.name.equals(tableName2)) + test('loads table using string', function () { + const contract = getContract() + const tableName = contract.tableNames[0] + const table = contract.table(tableName) + assert.instanceOf(table, Table) + assert.isTrue(table.name.equals(tableName)) + }) - // throws on invalid name - assert.throws(() => contract.table('foo')) + test('throws on invalid name', function () { + const contract = getContract() + assert.throws(() => contract.table('foo')) + }) + }) - // suite: actionNames - // contains actions - assert.isArray(contract.actionNames) - assert.isTrue(contract.actionNames.length > 0) + suite('actionNames', function () { + test('contains actions', function () { + const contract = getContract() + assert.isArray(contract.actionNames) + assert.isTrue(contract.actionNames.length > 0) + }) + }) - // suite: action - // load action using Name - const actionName = Name.from(contract.actionNames[0]) - const params = getMockParams(contract) - const action = contract.action(actionName, params) - assert.instanceOf(action, Action) - assert.isTrue(action.name.equals(actionName)) + suite('action', function () { + test('loads action using Name', function () { + const contract = getContract() + const actionName = Name.from(contract.actionNames[0]) + const action = contract.action(actionName, getMockParams(contract)) + assert.instanceOf(action, Action) + assert.isTrue(action.name.equals(actionName)) + }) - // load action using string - const actionName2 = contract.actionNames[0] - const params2 = getMockParams(contract) - const action2 = contract.action(actionName2, params2) - assert.instanceOf(action2, Action) - assert.isTrue(action2.name.equals(actionName2)) + test('loads action using string', function () { + const contract = getContract() + const actionName = contract.actionNames[0] + const action = contract.action(actionName, getMockParams(contract)) + assert.instanceOf(action, Action) + assert.isTrue(action.name.equals(actionName)) + }) - // throws on invalid name - assert.throws(() => contract.action('foo', {})) + test('throws on invalid name', function () { + const contract = getContract() + assert.throws(() => contract.action('foo', {})) + }) + }) } From f6dc48c6dba3e54140d9d46a8e49b7ac436887b7 Mon Sep 17 00:00:00 2001 From: aaroncox Date: Mon, 17 Aug 2026 16:57:15 -0700 Subject: [PATCH 13/17] Allow uint64 values as table scopes --- src/contract.ts | 4 +- src/contract/table.ts | 37 ++++++++++------ src/utils.ts | 34 +++++++++++++++ test/tests/table.ts | 99 ++++++++++++++++++++++++++++++++++++++++++- test/tests/utils.ts | 64 +++++++++++++++++++++++++++- 5 files changed, 220 insertions(+), 18 deletions(-) diff --git a/src/contract.ts b/src/contract.ts index 467a7e2..45bd26a 100644 --- a/src/contract.ts +++ b/src/contract.ts @@ -15,7 +15,7 @@ import { import {PlaceholderAuth} from '@wharfkit/signing-request' import {Table} from './contract/table' -import {formatExceptionMessage} from './utils' +import {formatExceptionMessage, TableScopeType} from './utils' export interface ContractArgs { abi: ABIDef @@ -83,7 +83,7 @@ export class Contract { return this.tableNames.includes(String(name)) } - public table(name: NameType, scope?: NameType, rowType?): Table { + public table(name: NameType, scope?: TableScopeType, rowType?): Table { if (!this.hasTable(name)) { throw new Error(`Contract (${this.account}) does not have a table named (${name})`) } diff --git a/src/contract/table.ts b/src/contract/table.ts index 9e442e0..c6dc6dd 100644 --- a/src/contract/table.ts +++ b/src/contract/table.ts @@ -1,5 +1,11 @@ -import {ABI, ABIDef, API, APIClient, Name, NameType, Serializer} from '@wharfkit/antelope' -import {indexPositionInWords, wrapIndexValue} from '../utils' +import {ABI, ABIDef, API, APIClient, Name, NameType, Serializer, UInt64} from '@wharfkit/antelope' +import { + indexPositionInWords, + isAbsentScope, + TableScopeType, + wrapIndexValue, + wrapScopeValue, +} from '../utils' import {TableRowCursor} from './row-cursor' import {TableScopeCursor} from './scope-cursor' import {TableCursor} from './table-cursor' @@ -7,7 +13,7 @@ import {TableCursor} from './table-cursor' export interface QueryParams { index?: string index_position?: string - scope?: NameType | number + scope?: TableScopeType key_type?: keyof API.v1.TableIndexTypes json?: boolean from?: API.v1.TableIndexType | string | number @@ -32,12 +38,12 @@ interface TableParams { fieldToIndex?: FieldToIndex debug?: boolean defaultRowLimit?: number - defaultScope?: NameType + defaultScope?: TableScopeType } export interface GetTableRowsOptions { limit?: number - scope?: NameType + scope?: TableScopeType } /** @@ -57,7 +63,7 @@ export class Table { private fieldToIndex?: any - public defaultScope?: NameType + public defaultScope?: TableScopeType public defaultRowLimit = 1000 /** @@ -117,10 +123,7 @@ export class Table { // Table query table: this.name, code: this.account, - scope: - params.scope !== undefined - ? String(params.scope) - : this.defaultScope || this.account, + scope: this.resolveScope(params.scope), // Response typing type: this.rowType, json: this.debug, @@ -170,10 +173,7 @@ export class Table { const tableRowsParams: any = { table: this.name, code: this.account, - scope: - params.scope !== undefined - ? String(params.scope) - : this.defaultScope || this.account, + scope: this.resolveScope(params.scope), type: this.rowType!, limit: 1, lower_bound: wrapIndexValue(value), @@ -247,6 +247,15 @@ export class Table { return this.query(params).all() } + /** Resolve the scope of a query, falling back to the table default and then the contract account. */ + private resolveScope(scope?: TableScopeType): Name | UInt64 | string { + const value = isAbsentScope(scope) ? this.defaultScope : scope + if (isAbsentScope(value)) { + return this.account + } + return wrapScopeValue(value) + } + getFieldToIndex() { if (this.fieldToIndex) { return this.fieldToIndex diff --git a/src/utils.ts b/src/utils.ts index 372c097..040d4cb 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -7,13 +7,18 @@ import { Float64, isInstanceOf, Name, + NameType, Serializer, UInt128, UInt64, + UInt64Type, } from '@wharfkit/antelope' export type PartialBy = Omit & Partial> +/** A table scope: a name, or any `uint64` value. Numeric scopes above 2^53 must be passed as a `UInt64`, since a `number` cannot hold them. */ +export type TableScopeType = NameType | UInt64Type + export function pascalCase(value: string): string { return value .split(/_| /) @@ -80,6 +85,35 @@ export function wrapIndexValue(value): API.v1.TableIndexType | undefined { return Name.from(value) } +/** Whether a scope is absent, meaning a query should fall back to its default. A `0` scope is present. */ +export function isAbsentScope(value?: TableScopeType | null): value is undefined | null | '' { + return value === undefined || value === null || value === '' +} + +/** Resolve a {@link TableScopeType} to the value sent as the `scope` of a table query. */ +export function wrapScopeValue(value: TableScopeType): Name | UInt64 | string { + if (value === undefined || value === null) { + throw new Error('Scope is required') + } + + if (isInstanceOf(value, Name)) { + return value + } + + // Strings reach the chain untouched, which reads an all-digit scope as a number and the rest as a name + if (typeof value === 'string') { + return value + } + + if (typeof value === 'number' && !Number.isSafeInteger(value)) { + throw new Error( + `Scope ${value} is not an integer a number can hold, use UInt64.from() to pass it instead` + ) + } + + return UInt64.from(value) +} + export function abiToBlob(abi: ABI): Blob { const serializedABI = Serializer.encode({object: abi, type: ABI}) return new Blob(serializedABI.array) diff --git a/test/tests/table.ts b/test/tests/table.ts index 71206ef..b57ba2c 100644 --- a/test/tests/table.ts +++ b/test/tests/table.ts @@ -3,7 +3,17 @@ import {assert} from 'chai' import ContractKit, {Contract, Table, TableRowCursor, TableScopeCursor} from '$lib' import {EosioGlobalState} from '$test/data/structs/eosio' -import {Asset, Int64, Name, Serializer, Struct, TimePoint, UInt32} from '@wharfkit/antelope' +import { + APIClient, + Asset, + Int64, + Name, + Serializer, + Struct, + TimePoint, + UInt32, + UInt64, +} from '@wharfkit/antelope' import {makeClient} from '@wharfkit/mock-data' const mockClient = makeClient('https://eos.greymass.com') @@ -315,6 +325,93 @@ suite('Table', () => { assert.equal(rowsBuyTxtScope.length, 144) assert.equal(rowsSellTxtScope.length, 348) }) + + test('should work with uint64 scopes', async function () { + const testKit = new ContractKit({ + client: makeClient('https://wax.greymass.com'), + }) + + const contract = await testKit.load('alcordexmain') + + const rowsBuy = await contract + .table('buyorder') + .query({scope: UInt64.from(0)}) + .all() + const rowsSell = await contract + .table('sellorder') + .query({scope: UInt64.from(0)}) + .all() + assert.equal(rowsBuy.length, 144) + assert.equal(rowsSell.length, 348) + }) + + test('should keep a uint64 scope beyond the range of a number', function () { + const cursor = producersTable.query({scope: UInt64.from('9223372036854775808')}) + assert.equal(String(cursor.params.scope), '9223372036854775808') + }) + + test('should accept a uint64 scope from the table call', function () { + const cursor = eosio.table('producers', UInt64.from('9223372036854775808')).query() + assert.equal(String(cursor.params.scope), '9223372036854775808') + }) + + test('should reject a number scope that cannot hold the value', function () { + assert.throws( + () => producersTable.query({scope: 9223372036854775808}), + /is not an integer a number can hold/ + ) + }) + + test('should still default to the contract account', function () { + const cursor = producersTable.query() + assert.equal(String(cursor.params.scope), 'eosio') + }) + + test('should keep a scope of zero from the table call', function () { + const cursor = eosio.table('producers', 0).query() + assert.equal(String(cursor.params.scope), '0') + }) + + test('should fall back to the default scope for an absent query scope', function () { + const table = eosio.table('producers', UInt64.from(42)) + assert.equal(String(table.query().params.scope), '42') + assert.equal(String(table.query({scope: null as any}).params.scope), '42') + assert.equal(String(table.query({scope: ''}).params.scope), '42') + }) + + test('should fall back to the contract account for an empty default scope', function () { + const cursor = eosio.table('producers', '').query() + assert.equal(String(cursor.params.scope), 'eosio') + }) + + test('should send a uint64 scope on a get request', async function () { + const scopes: unknown[] = [] + const client = new APIClient({ + provider: { + call: async ({params}: any) => { + // Assert against the encoded body, where a number scope would lose precision + scopes.push(JSON.parse(JSON.stringify(params)).scope) + return { + status: 200, + headers: {}, + text: '{"rows":[],"more":false}', + json: {rows: [], more: false}, + } + }, + }, + }) + const table = new Table({ + abi: eosio.abi, + account: 'eosio', + client, + name: 'producers', + }) + + await table.get(undefined, {scope: UInt64.from('9223372036854775808')}) + await table.get() + + assert.deepEqual(scopes, ['9223372036854775808', 'eosio']) + }) }) test('reverse', async function () { diff --git a/test/tests/utils.ts b/test/tests/utils.ts index 0b54ac9..65d3595 100644 --- a/test/tests/utils.ts +++ b/test/tests/utils.ts @@ -1,16 +1,18 @@ import {assert} from 'chai' import fs from 'fs' -import {ABI, Blob, Name, Serializer, UInt128, UInt64} from '@wharfkit/antelope' +import {ABI, Blob, Int64, Name, Serializer, UInt128, UInt32, UInt64} from '@wharfkit/antelope' import { abiToBlob, blobStringToAbi, capitalize, formatExceptionMessage, indexPositionInWords, + isAbsentScope, pascalCase, singularize, wrapIndexValue, + wrapScopeValue, } from '../../src/utils' suite('Utility functions', function () { @@ -43,6 +45,66 @@ suite('Utility functions', function () { assert.deepEqual(wrapIndexValue('name'), Name.from('name')) }) + suite('Wraps scope value', function () { + test('names', function () { + assert.deepEqual(wrapScopeValue(Name.from('teamgreymass')), Name.from('teamgreymass')) + }) + + test('strings pass through untouched', function () { + assert.equal(wrapScopeValue('teamgreymass'), 'teamgreymass') + assert.equal(wrapScopeValue('0'), '0') + assert.equal(wrapScopeValue('18446744073709551615'), '18446744073709551615') + }) + + test('numbers', function () { + assert.deepEqual(wrapScopeValue(0), UInt64.from(0)) + assert.deepEqual(wrapScopeValue(10), UInt64.from(10)) + }) + + test('uint64 values beyond the range of a number', function () { + const scope = UInt64.from('9223372036854775808') + assert.deepEqual(wrapScopeValue(scope), scope) + assert.equal(String(wrapScopeValue(scope)), '9223372036854775808') + }) + + test('rejects numbers that cannot hold the scope', function () { + assert.throws( + () => wrapScopeValue(9223372036854775808), + /is not an integer a number can hold/ + ) + assert.throws(() => wrapScopeValue(1.5), /is not an integer a number can hold/) + }) + + test('rejects negative values', function () { + assert.throws(() => wrapScopeValue(-1), /underflows uint64/) + assert.throws(() => wrapScopeValue(Int64.from(-5)), /underflows uint64/) + }) + + test('accepts the full uint64 range', function () { + const max = UInt64.from('18446744073709551615') + assert.equal(String(wrapScopeValue(max)), '18446744073709551615') + }) + + test('accepts other integer types', function () { + assert.deepEqual(wrapScopeValue(Int64.from(5)), UInt64.from(5)) + assert.deepEqual(wrapScopeValue(UInt32.from(7)), UInt64.from(7)) + }) + + test('rejects an absent scope rather than exhausting memory', function () { + assert.throws(() => wrapScopeValue(null as any), /Scope is required/) + assert.throws(() => wrapScopeValue(undefined as any), /Scope is required/) + }) + + test('reports which scopes are absent', function () { + assert.isTrue(isAbsentScope(undefined)) + assert.isTrue(isAbsentScope(null)) + assert.isTrue(isAbsentScope('')) + assert.isFalse(isAbsentScope(0)) + assert.isFalse(isAbsentScope('teamgreymass')) + assert.isFalse(isAbsentScope(UInt64.from(0))) + }) + }) + const testABI = ABI.from(fs.readFileSync(`test/data/abis/rewards.gm.json`, {encoding: 'utf8'})) // Blob created from the testABI From bd5e430c3aaa8b3c15e3126bab667c537ff19622 Mon Sep 17 00:00:00 2001 From: aaroncox Date: Mon, 17 Aug 2026 17:23:35 -0700 Subject: [PATCH 14/17] Add test for readonly exception handling --- test/tests/contract.ts | 96 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) diff --git a/test/tests/contract.ts b/test/tests/contract.ts index c4acaeb..42a90fe 100644 --- a/test/tests/contract.ts +++ b/test/tests/contract.ts @@ -3,7 +3,16 @@ import {assert} from 'chai' import ContractKit, {Contract, ContractArgs, Table} from '$lib' import {DelegatedBandwidth, ProducerInfo} from '$test/data/structs/eosio' -import {ABI, Action, Asset, Name, PrivateKey, Serializer, UInt64} from '@wharfkit/antelope' +import { + ABI, + Action, + APIClient, + Asset, + Name, + PrivateKey, + Serializer, + UInt64, +} from '@wharfkit/antelope' import {PlaceholderAuth} from '@wharfkit/signing-request' import {runGenericContractTests} from './helpers/generic' @@ -375,6 +384,91 @@ suite('Contract', async function () { const result = await contract.readonly('callapi') assert.instanceOf(result.foo, UInt64) }) + + suite('exceptions', () => { + function failingContract(except: unknown): Promise { + const response = { + transaction_id: 'ff'.repeat(32), + processed: { + id: 'ff'.repeat(32), + block_num: 1, + block_time: '2026-01-01T00:00:00.000', + receipt: null, + elapsed: 1, + except, + net_usage: 0, + scheduled: false, + action_traces: [], + account_ram_delta: null, + }, + } + return mockKit.load('testing.gm').then( + (loaded) => + new Contract({ + abi: loaded.abi, + account: loaded.account, + client: new APIClient({ + provider: { + call: async () => ({ + status: 200, + headers: {}, + text: JSON.stringify(response), + json: response, + }), + }, + }), + }) + ) + } + + test('throws the substituted assertion message', async () => { + const contract = await failingContract({ + code: 3050003, + name: 'eosio_assert_message_exception', + message: 'eosio_assert_message assertion failure', + stack: [ + { + context: {level: 'error'}, + format: 'assertion failure with message: ${s}', + data: {s: 'insufficient balance'}, + }, + ], + }) + + let error + try { + await contract.readonly('callapi') + } catch (err) { + error = err + } + assert.instanceOf(error, Error) + assert.equal( + (error as Error).message, + 'assertion failure with message: insufficient balance' + ) + }) + + test('falls back to the exception message with an empty stack', async () => { + const contract = await failingContract({ + code: 3080004, + name: 'tx_cpu_usage_exceeded', + message: 'transaction exceeded the current CPU usage limit', + stack: [], + }) + + let error + try { + await contract.readonly('callapi') + } catch (err) { + error = err + } + assert.instanceOf(error, Error) + assert.equal( + (error as Error).message, + 'transaction exceeded the current CPU usage limit' + ) + }) + }) }) }) }) From 885662ea95eb1f8876497605ff085191031bfe9f Mon Sep 17 00:00:00 2001 From: aaroncox Date: Mon, 17 Aug 2026 17:23:35 -0700 Subject: [PATCH 15/17] Test against node 18, 20 and 22 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa00471..06646f8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [14, 16, 18] + node-version: [18, 20, 22] name: Node.js v${{ matrix.node-version }} steps: - name: Setup Node.js From e85b8d4b1226cac96fe07cd20e9c58086a0e69cc Mon Sep 17 00:00:00 2001 From: aaroncox Date: Mon, 17 Aug 2026 17:41:44 -0700 Subject: [PATCH 16/17] Disable node's built-in type stripping when running tests --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 06646f8..5598378 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,6 +8,10 @@ jobs: matrix: node-version: [18, 20, 22] name: Node.js v${{ matrix.node-version }} + env: + # Node 22.18+ strips types itself, which leaves the decorators in the test + # suite for V8 to choke on before ts-node is ever reached + NODE_OPTIONS: ${{ matrix.node-version >= 22 && '--no-experimental-strip-types' || '' }} steps: - name: Setup Node.js uses: actions/setup-node@v2 From 2c98897fceb83dd75b1eea328b44ec7367d7847b Mon Sep 17 00:00:00 2001 From: aaroncox Date: Mon, 17 Aug 2026 17:48:15 -0700 Subject: [PATCH 17/17] v1.3.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0500cf5..2e16d41 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@wharfkit/contract", "description": "ContractKit for Wharf", - "version": "1.2.2-rc3", + "version": "1.3.0", "homepage": "https://github.com/wharfkit/contract", "license": "BSD-3-Clause", "main": "lib/contract.js",