diff --git a/basics/counter/native/package.json b/basics/counter/native/package.json index 69dc2b9de..53ec22293 100644 --- a/basics/counter/native/package.json +++ b/basics/counter/native/package.json @@ -18,12 +18,13 @@ "@types/chai": "^4.3.1", "@types/mocha": "^9.1.1", "chai": "^4.3.4", + "litesvm": "^0.3.3", "mocha": "^9.0.3", - "solana-bankrun": "^0.3.0", "ts-mocha": "^10.0.0", "typescript": "^4.3.5" }, "dependencies": { - "@solana/web3.js": "^1.91.4" + "@solana/web3.js": "^1.91.4", + "bn.js": "^5.2.0" } } diff --git a/basics/counter/native/pnpm-lock.yaml b/basics/counter/native/pnpm-lock.yaml index 5d5d40850..a9e97327a 100644 --- a/basics/counter/native/pnpm-lock.yaml +++ b/basics/counter/native/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@solana/web3.js': specifier: ^1.91.4 version: 1.91.8(bufferutil@4.0.8)(utf-8-validate@5.0.10) + bn.js: + specifier: ^5.2.0 + version: 5.2.1 devDependencies: '@types/bn.js': specifier: ^5.1.0 @@ -24,12 +27,12 @@ importers: chai: specifier: ^4.3.4 version: 4.4.1 + litesvm: + specifier: ^0.3.3 + version: 0.3.3(bufferutil@4.0.8)(typescript@4.9.5)(utf-8-validate@5.0.10) mocha: specifier: ^9.0.3 version: 9.2.2 - solana-bankrun: - specifier: ^0.3.0 - version: 0.3.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) ts-mocha: specifier: ^10.0.0 version: 10.0.0(mocha@9.2.2) @@ -43,20 +46,57 @@ packages: resolution: {integrity: sha512-Nms86NXrsaeU9vbBJKni6gXiEXZ4CVpYVzEjDH9Sb8vmZ3UljyA1GSOJl/6LGPO8EHLuSF9H+IxNXHPX8QHJ4g==} engines: {node: '>=6.9.0'} + '@babel/runtime@7.28.6': + resolution: {integrity: sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA==} + engines: {node: '>=6.9.0'} + '@noble/curves@1.4.0': resolution: {integrity: sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg==} + '@noble/curves@1.9.7': + resolution: {integrity: sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==} + engines: {node: ^14.21.3 || >=16} + '@noble/hashes@1.4.0': resolution: {integrity: sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==} engines: {node: '>= 16'} + '@noble/hashes@1.8.0': + resolution: {integrity: sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==} + engines: {node: ^14.21.3 || >=16} + '@solana/buffer-layout@4.0.1': resolution: {integrity: sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==} engines: {node: '>=5.10'} + '@solana/codecs-core@2.3.0': + resolution: {integrity: sha512-oG+VZzN6YhBHIoSKgS5ESM9VIGzhWjEHEGNPSibiDTxFhsFWxNaz8LbMDPjBUE69r9wmdGLkrQ+wVPbnJcZPvw==} + engines: {node: '>=20.18.0'} + peerDependencies: + typescript: '>=5.3.3' + + '@solana/codecs-numbers@2.3.0': + resolution: {integrity: sha512-jFvvwKJKffvG7Iz9dmN51OGB7JBcy2CJ6Xf3NqD/VP90xak66m/Lg48T01u5IQ/hc15mChVHiBm+HHuOFDUrQg==} + engines: {node: '>=20.18.0'} + peerDependencies: + typescript: '>=5.3.3' + + '@solana/errors@2.3.0': + resolution: {integrity: sha512-66RI9MAbwYV0UtP7kGcTBVLxJgUxoZGm8Fbc0ah+lGiAw17Gugco6+9GrJCV83VyF2mDWyYnYM9qdI3yjgpnaQ==} + engines: {node: '>=20.18.0'} + hasBin: true + peerDependencies: + typescript: '>=5.3.3' + '@solana/web3.js@1.91.8': resolution: {integrity: sha512-USa6OS1jbh8zOapRJ/CBZImZ8Xb7AJjROZl5adql9TpOoBN9BUzyyouS5oPuZHft7S7eB8uJPuXWYjMi6BHgOw==} + '@solana/web3.js@1.98.4': + resolution: {integrity: sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw==} + + '@swc/helpers@0.5.18': + resolution: {integrity: sha512-TXTnIcNJQEKwThMMqBXsZ4VGAza6bvN4pa41Rkqoio6QBKMvo+5lexeTMScGCIxtzgQJzElcvIltani+adC5PQ==} + '@types/bn.js@5.1.5': resolution: {integrity: sha512-V46N0zwKRF5Q00AZ6hWtN0T8gGmDUaUzLWQvHFo5yThtVwK/VCenFY3wXVbOvNfajEpsTfQM4IN9k/d6gUVX3A==} @@ -78,9 +118,15 @@ packages: '@types/node@20.12.11': resolution: {integrity: sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==} + '@types/uuid@8.3.4': + resolution: {integrity: sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==} + '@types/ws@7.4.7': resolution: {integrity: sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==} + '@types/ws@8.18.1': + resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==} + '@ungap/promise-all-settled@1.1.2': resolution: {integrity: sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==} @@ -124,6 +170,9 @@ packages: base-x@3.0.9: resolution: {integrity: sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==} + base-x@5.0.1: + resolution: {integrity: sha512-M7uio8Zt++eg3jPj+rHMfCC+IuygQHHCOU+IYsVtik6FWjuYpVt/+MRKcgsAMHh8mMFAwnB+Bs+mTrFiXjMzKg==} + base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} @@ -157,6 +206,9 @@ packages: bs58@4.0.1: resolution: {integrity: sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==} + bs58@6.0.0: + resolution: {integrity: sha512-PD0wEnEYg6ijszw/u8s+iI3H17cTymlrwkKhDhPZq+Sokl3AU4htyBFTjAeNAlCCmg0f53g6ih3jATyCKftTfw==} + buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} @@ -179,6 +231,10 @@ packages: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} + chalk@5.6.2: + resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + check-error@1.0.3: resolution: {integrity: sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==} @@ -196,6 +252,10 @@ packages: color-name@1.1.4: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + commander@14.0.2: + resolution: {integrity: sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ==} + engines: {node: '>=20'} + commander@2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} @@ -251,6 +311,9 @@ packages: eventemitter3@4.0.7: resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==} + eventemitter3@5.0.1: + resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==} + eyes@0.1.8: resolution: {integrity: sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==} engines: {node: '> 0.1.90'} @@ -258,6 +321,9 @@ packages: fast-stable-stringify@1.0.0: resolution: {integrity: sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==} + fastestsmallesttextencoderdecoder@1.0.22: + resolution: {integrity: sha512-Pb8d48e+oIuY4MaM64Cd7OW1gt4nxCHs7/ddPPZ/Ic3sg8yVGM7O9wDvZ7us6ScaUupzM+pfBolwtYhN1IxBIw==} + file-uri-to-path@1.0.0: resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} @@ -360,6 +426,11 @@ packages: engines: {node: '>=8'} hasBin: true + jayson@4.3.0: + resolution: {integrity: sha512-AauzHcUcqs8OBnCHOkJY280VaTiCm57AbuO7lqzcw7JapGj50BisE3xhksye4zlTSR1+1tAz67wLTl8tEH1obQ==} + engines: {node: '>=8'} + hasBin: true + js-yaml@4.1.0: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} hasBin: true @@ -375,6 +446,40 @@ packages: resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==} engines: {'0': node >= 0.2.0} + litesvm-darwin-arm64@0.3.3: + resolution: {integrity: sha512-81YimsV3ezWjWLgoKixsXfVznaaecbURE3RtECgNb6Din6Za03pKGKGEN4gkyecHkv8uoPaEZv5cl6ARsgeN1Q==} + engines: {node: '>= 20'} + cpu: [arm64] + os: [darwin] + + litesvm-darwin-x64@0.3.3: + resolution: {integrity: sha512-pYietuU165Bl+2eDnVp2Eidiedfjt+pljyyBAfJPbYriaFyG577mU364NiNcsfQ8ZZWbe+ygIEAVq4Ol247+1g==} + engines: {node: '>= 20'} + cpu: [x64] + os: [darwin] + + litesvm-linux-arm64-musl@0.3.3: + resolution: {integrity: sha512-mkI15rWtNbaJxVFUfh+qnolqnDCZEqhwSZo/XZ48TZNsQ69vAqY00KhyFhTVJ+jeaYCAZTSNamuFIiRBxqVmNg==} + engines: {node: '>= 20'} + cpu: [arm64] + os: [linux] + + litesvm-linux-x64-gnu@0.3.3: + resolution: {integrity: sha512-Qai2/E8Eq03w8VKnJDREyiWxwavjykW/H6onE179ayMnBjVVmkj5fN7XF50VV4z73kasx5bpDzBNK8fcaxMdzA==} + engines: {node: '>= 20'} + cpu: [x64] + os: [linux] + + litesvm-linux-x64-musl@0.3.3: + resolution: {integrity: sha512-bpWZ2f506hbfu1y6bkmuZf+qqtnLDxggpOMTQbibjd+q6faEO3sETWwKGlIgHB99P8wyU+aXKwLSGQX2sJEw6Q==} + engines: {node: '>= 20'} + cpu: [x64] + os: [linux] + + litesvm@0.3.3: + resolution: {integrity: sha512-QHXjAIXzvG0uAMOza6aJcYl19yTKz3guwq/z0Zml4KnQxyQvPhjaBpUFc5sf2ey/NxMVdqFhoXmL02CXOOomjw==} + engines: {node: '>= 20'} + locate-path@6.0.0: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} @@ -479,45 +584,15 @@ packages: rpc-websockets@7.11.0: resolution: {integrity: sha512-IkLYjayPv6Io8C/TdCL5gwgzd1hFz2vmBZrjMw/SPEXo51ETOhnzgS4Qy5GWi2JQN7HKHa66J3+2mv0fgNh/7w==} + rpc-websockets@9.3.2: + resolution: {integrity: sha512-VuW2xJDnl1k8n8kjbdRSWawPRkwaVqUQNjE1TdeTawf0y0abGhtVJFTXCLfgpgGDBkO/Fj6kny8Dc/nvOW78MA==} + safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} serialize-javascript@6.0.0: resolution: {integrity: sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==} - solana-bankrun-darwin-arm64@0.3.0: - resolution: {integrity: sha512-+NbDncf0U6l3knuacRBiqpjZ2DSp+5lZaAU518gH7/x6qubbui/d000STaIBK+uNTPBS/AL/bCN+7PkXqmA3lA==} - engines: {node: '>= 10'} - cpu: [arm64] - os: [darwin] - - solana-bankrun-darwin-universal@0.3.0: - resolution: {integrity: sha512-1/F0xdMa4qvc5o6z16FCCbZ5jbdvKvxpx5kyPcMWRiRPwyvi+zltMxciPAYMlg3wslQqGz88uFhrBEzq2eTumQ==} - engines: {node: '>= 10'} - os: [darwin] - - solana-bankrun-darwin-x64@0.3.0: - resolution: {integrity: sha512-U6CANjkmMl+lgNA7UH0GKs5V7LtVIUDzJBZefGGqLfqUNv3EjA/PrrToM0hAOWJgkxSwdz6zW+p5sw5FmnbXtg==} - engines: {node: '>= 10'} - cpu: [x64] - os: [darwin] - - solana-bankrun-linux-x64-gnu@0.3.0: - resolution: {integrity: sha512-qJSkCFs0k2n4XtTnyxGMiZsuqO2TiqTYgWjQ+3mZhGNUAMys/Vq8bd7/SyBm6RR7EfVuRXRxZvh+F8oKZ77V4w==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - - solana-bankrun-linux-x64-musl@0.3.0: - resolution: {integrity: sha512-xsS2CS2xb1Sw4ivNXM0gPz/qpW9BX0neSvt/pnok5L330Nu9xlTnKAY8FhzzqOP9P9sJlGRM787Y6d0yYwt6xQ==} - engines: {node: '>= 10'} - cpu: [x64] - os: [linux] - - solana-bankrun@0.3.0: - resolution: {integrity: sha512-YkH7sa8TB/AoRPzG17CXJtYsRIQHEkEqGLz1Vwc13taXhDBkjO7z6NI5JYw7n0ybRymDHwMYTc7sd+5J40TyVQ==} - engines: {node: '>= 10'} - source-map-support@0.5.21: resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} @@ -525,6 +600,12 @@ packages: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} + stream-chain@2.2.5: + resolution: {integrity: sha512-1TJmBx6aSWqZ4tx7aTpBDXK0/e2hhcNSTV8+CbFJtDjbb+I1mZ8lHit0Grw9GRT+6JbIrrDd8esncgBi8aBXGA==} + + stream-json@1.9.1: + resolution: {integrity: sha512-uWkjJ+2Nt/LO9Z/JyKZbMusL8Dkh97uUBTv3AJQ74y07lVahLY4eEFsPsE97pxYBwr8nnjMAIch5eqI0gPShyw==} + string-width@4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} engines: {node: '>=8'} @@ -544,6 +625,10 @@ packages: superstruct@0.14.2: resolution: {integrity: sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ==} + superstruct@2.0.2: + resolution: {integrity: sha512-uV+TFRZdXsqXTL2pRvujROjdZQ4RAlBUS5BTh9IGm+jTqQntYThciG/qu57Gs69yjnVUSqdxF9YLmSnpupBW9A==} + engines: {node: '>=14.0.0'} + supports-color@7.2.0: resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} engines: {node: '>=8'} @@ -580,6 +665,9 @@ packages: tsconfig-paths@3.15.0: resolution: {integrity: sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==} + tslib@2.8.1: + resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + type-detect@4.0.8: resolution: {integrity: sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==} engines: {node: '>=4'} @@ -621,6 +709,18 @@ packages: wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + ws@7.5.10: + resolution: {integrity: sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==} + engines: {node: '>=8.3.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: ^5.0.2 + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + ws@7.5.9: resolution: {integrity: sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==} engines: {node: '>=8.3.0'} @@ -675,16 +775,41 @@ snapshots: dependencies: regenerator-runtime: 0.14.1 + '@babel/runtime@7.28.6': {} + '@noble/curves@1.4.0': dependencies: '@noble/hashes': 1.4.0 + '@noble/curves@1.9.7': + dependencies: + '@noble/hashes': 1.8.0 + '@noble/hashes@1.4.0': {} + '@noble/hashes@1.8.0': {} + '@solana/buffer-layout@4.0.1': dependencies: buffer: 6.0.3 + '@solana/codecs-core@2.3.0(typescript@4.9.5)': + dependencies: + '@solana/errors': 2.3.0(typescript@4.9.5) + typescript: 4.9.5 + + '@solana/codecs-numbers@2.3.0(typescript@4.9.5)': + dependencies: + '@solana/codecs-core': 2.3.0(typescript@4.9.5) + '@solana/errors': 2.3.0(typescript@4.9.5) + typescript: 4.9.5 + + '@solana/errors@2.3.0(typescript@4.9.5)': + dependencies: + chalk: 5.6.2 + commander: 14.0.2 + typescript: 4.9.5 + '@solana/web3.js@1.91.8(bufferutil@4.0.8)(utf-8-validate@5.0.10)': dependencies: '@babel/runtime': 7.24.5 @@ -707,6 +832,33 @@ snapshots: - encoding - utf-8-validate + '@solana/web3.js@1.98.4(bufferutil@4.0.8)(typescript@4.9.5)(utf-8-validate@5.0.10)': + dependencies: + '@babel/runtime': 7.28.6 + '@noble/curves': 1.9.7 + '@noble/hashes': 1.4.0 + '@solana/buffer-layout': 4.0.1 + '@solana/codecs-numbers': 2.3.0(typescript@4.9.5) + agentkeepalive: 4.5.0 + bn.js: 5.2.1 + borsh: 0.7.0 + bs58: 4.0.1 + buffer: 6.0.3 + fast-stable-stringify: 1.0.0 + jayson: 4.3.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + node-fetch: 2.7.0 + rpc-websockets: 9.3.2 + superstruct: 2.0.2 + transitivePeerDependencies: + - bufferutil + - encoding + - typescript + - utf-8-validate + + '@swc/helpers@0.5.18': + dependencies: + tslib: 2.8.1 + '@types/bn.js@5.1.5': dependencies: '@types/node': 20.12.11 @@ -728,10 +880,16 @@ snapshots: dependencies: undici-types: 5.26.5 + '@types/uuid@8.3.4': {} + '@types/ws@7.4.7': dependencies: '@types/node': 12.20.55 + '@types/ws@8.18.1': + dependencies: + '@types/node': 20.12.11 + '@ungap/promise-all-settled@1.1.2': {} JSONStream@1.3.5: @@ -768,6 +926,8 @@ snapshots: dependencies: safe-buffer: 5.2.1 + base-x@5.0.1: {} + base64-js@1.5.1: {} bigint-buffer@1.1.5: @@ -803,6 +963,10 @@ snapshots: dependencies: base-x: 3.0.9 + bs58@6.0.0: + dependencies: + base-x: 5.0.1 + buffer-from@1.1.2: {} buffer@6.0.3: @@ -832,6 +996,8 @@ snapshots: ansi-styles: 4.3.0 supports-color: 7.2.0 + chalk@5.6.2: {} + check-error@1.0.3: dependencies: get-func-name: 2.0.2 @@ -860,6 +1026,8 @@ snapshots: color-name@1.1.4: {} + commander@14.0.2: {} + commander@2.20.3: {} concat-map@0.0.1: {} @@ -896,10 +1064,14 @@ snapshots: eventemitter3@4.0.7: {} + eventemitter3@5.0.1: {} + eyes@0.1.8: {} fast-stable-stringify@1.0.0: {} + fastestsmallesttextencoderdecoder@1.0.22: {} + file-uri-to-path@1.0.0: {} fill-range@7.0.1: @@ -974,6 +1146,10 @@ snapshots: isexe@2.0.0: {} + isomorphic-ws@4.0.1(ws@7.5.10(bufferutil@4.0.8)(utf-8-validate@5.0.10)): + dependencies: + ws: 7.5.10(bufferutil@4.0.8)(utf-8-validate@5.0.10) + isomorphic-ws@4.0.1(ws@7.5.9(bufferutil@4.0.8)(utf-8-validate@5.0.10)): dependencies: ws: 7.5.9(bufferutil@4.0.8)(utf-8-validate@5.0.10) @@ -996,6 +1172,24 @@ snapshots: - bufferutil - utf-8-validate + jayson@4.3.0(bufferutil@4.0.8)(utf-8-validate@5.0.10): + dependencies: + '@types/connect': 3.4.38 + '@types/node': 12.20.55 + '@types/ws': 7.4.7 + commander: 2.20.3 + delay: 5.0.0 + es6-promisify: 5.0.0 + eyes: 0.1.8 + isomorphic-ws: 4.0.1(ws@7.5.10(bufferutil@4.0.8)(utf-8-validate@5.0.10)) + json-stringify-safe: 5.0.1 + stream-json: 1.9.1 + uuid: 8.3.2 + ws: 7.5.10(bufferutil@4.0.8)(utf-8-validate@5.0.10) + transitivePeerDependencies: + - bufferutil + - utf-8-validate + js-yaml@4.1.0: dependencies: argparse: 2.0.1 @@ -1009,6 +1203,38 @@ snapshots: jsonparse@1.3.1: {} + litesvm-darwin-arm64@0.3.3: + optional: true + + litesvm-darwin-x64@0.3.3: + optional: true + + litesvm-linux-arm64-musl@0.3.3: + optional: true + + litesvm-linux-x64-gnu@0.3.3: + optional: true + + litesvm-linux-x64-musl@0.3.3: + optional: true + + litesvm@0.3.3(bufferutil@4.0.8)(typescript@4.9.5)(utf-8-validate@5.0.10): + dependencies: + '@solana/web3.js': 1.98.4(bufferutil@4.0.8)(typescript@4.9.5)(utf-8-validate@5.0.10) + bs58: 6.0.0 + fastestsmallesttextencoderdecoder: 1.0.22 + optionalDependencies: + litesvm-darwin-arm64: 0.3.3 + litesvm-darwin-x64: 0.3.3 + litesvm-linux-arm64-musl: 0.3.3 + litesvm-linux-x64-gnu: 0.3.3 + litesvm-linux-x64-musl: 0.3.3 + transitivePeerDependencies: + - bufferutil + - encoding + - typescript + - utf-8-validate + locate-path@6.0.0: dependencies: p-locate: 5.0.0 @@ -1121,42 +1347,25 @@ snapshots: bufferutil: 4.0.8 utf-8-validate: 5.0.10 + rpc-websockets@9.3.2: + dependencies: + '@swc/helpers': 0.5.18 + '@types/uuid': 8.3.4 + '@types/ws': 8.18.1 + buffer: 6.0.3 + eventemitter3: 5.0.1 + uuid: 8.3.2 + ws: 8.17.0(bufferutil@4.0.8)(utf-8-validate@5.0.10) + optionalDependencies: + bufferutil: 4.0.8 + utf-8-validate: 5.0.10 + safe-buffer@5.2.1: {} serialize-javascript@6.0.0: dependencies: randombytes: 2.1.0 - solana-bankrun-darwin-arm64@0.3.0: - optional: true - - solana-bankrun-darwin-universal@0.3.0: - optional: true - - solana-bankrun-darwin-x64@0.3.0: - optional: true - - solana-bankrun-linux-x64-gnu@0.3.0: - optional: true - - solana-bankrun-linux-x64-musl@0.3.0: - optional: true - - solana-bankrun@0.3.0(bufferutil@4.0.8)(utf-8-validate@5.0.10): - dependencies: - '@solana/web3.js': 1.91.8(bufferutil@4.0.8)(utf-8-validate@5.0.10) - bs58: 4.0.1 - optionalDependencies: - solana-bankrun-darwin-arm64: 0.3.0 - solana-bankrun-darwin-universal: 0.3.0 - solana-bankrun-darwin-x64: 0.3.0 - solana-bankrun-linux-x64-gnu: 0.3.0 - solana-bankrun-linux-x64-musl: 0.3.0 - transitivePeerDependencies: - - bufferutil - - encoding - - utf-8-validate - source-map-support@0.5.21: dependencies: buffer-from: 1.1.2 @@ -1164,6 +1373,12 @@ snapshots: source-map@0.6.1: {} + stream-chain@2.2.5: {} + + stream-json@1.9.1: + dependencies: + stream-chain: 2.2.5 + string-width@4.2.3: dependencies: emoji-regex: 8.0.0 @@ -1181,6 +1396,8 @@ snapshots: superstruct@0.14.2: {} + superstruct@2.0.2: {} + supports-color@7.2.0: dependencies: has-flag: 4.0.0 @@ -1225,6 +1442,8 @@ snapshots: strip-bom: 3.0.0 optional: true + tslib@2.8.1: {} + type-detect@4.0.8: {} typescript@4.9.5: {} @@ -1259,6 +1478,11 @@ snapshots: wrappy@1.0.2: {} + ws@7.5.10(bufferutil@4.0.8)(utf-8-validate@5.0.10): + optionalDependencies: + bufferutil: 4.0.8 + utf-8-validate: 5.0.10 + ws@7.5.9(bufferutil@4.0.8)(utf-8-validate@5.0.10): optionalDependencies: bufferutil: 4.0.8 diff --git a/basics/counter/native/tests/counter.test.ts b/basics/counter/native/tests/counter.test.ts index 44c2056bf..d36b50525 100644 --- a/basics/counter/native/tests/counter.test.ts +++ b/basics/counter/native/tests/counter.test.ts @@ -1,19 +1,37 @@ +import { readFileSync } from 'node:fs'; import { describe, test } from 'node:test'; -import { Keypair, SystemProgram, Transaction, type TransactionInstruction } from '@solana/web3.js'; +import { Keypair, PublicKey, SystemProgram, Transaction, type TransactionInstruction } from '@solana/web3.js'; import { assert } from 'chai'; -import { start } from 'solana-bankrun'; -import { COUNTER_ACCOUNT_SIZE, createIncrementInstruction, deserializeCounterAccount, PROGRAM_ID } from '../ts'; - -describe('Counter Solana Native', async () => { - // Randomly generate the program keypair and load the program to solana-bankrun - const context = await start([{ name: 'counter_solana_native', programId: PROGRAM_ID }], []); - const client = context.banksClient; +import { LiteSVM } from 'litesvm'; +import { COUNTER_ACCOUNT_SIZE, createIncrementInstruction, deserializeCounterAccount } from '../ts/index.ts'; + +describe('Counter Solana Native', () => { + // Load the program keypair + const programKeypairPath = new URL( + './fixtures/counter_solana_native-keypair.json', + // @ts-ignore + import.meta.url, + ).pathname; + const programKeypairData = JSON.parse(readFileSync(programKeypairPath, 'utf-8')); + const programKeypair = Keypair.fromSecretKey(new Uint8Array(programKeypairData)); + const PROGRAM_ID = programKeypair.publicKey; + + const litesvm = new LiteSVM(); // Get the payer keypair from the context, this will be used to sign transactions with enough lamports - const payer = context.payer; - // Get the rent object to calculate rent for the accounts - const rent = await client.getRent(); + const payer = Keypair.generate(); + + // Load the program + const programPath = new URL( + './fixtures/counter_solana_native.so', + // @ts-ignore + import.meta.url, + ).pathname; + litesvm.addProgramFromFile(PROGRAM_ID, programPath); + + // Fund the payer account + litesvm.airdrop(payer.publicKey, BigInt(100000000000)); - test('Test allocate counter + increment tx', async () => { + test('Test allocate counter + increment tx', () => { // Randomly generate the account key // to sign for setting up the Counter state const counterKeypair = Keypair.generate(); @@ -23,28 +41,27 @@ describe('Counter Solana Native', async () => { const allocIx: TransactionInstruction = SystemProgram.createAccount({ fromPubkey: payer.publicKey, newAccountPubkey: counter, - lamports: Number(rent.minimumBalance(BigInt(COUNTER_ACCOUNT_SIZE))), + lamports: Number(litesvm.minimumBalanceForRentExemption(BigInt(COUNTER_ACCOUNT_SIZE))), space: COUNTER_ACCOUNT_SIZE, programId: PROGRAM_ID, }); - const incrementIx: TransactionInstruction = createIncrementInstruction({ counter }, {}); + const incrementIx: TransactionInstruction = createIncrementInstruction({ counter }, PROGRAM_ID); const tx = new Transaction().add(allocIx).add(incrementIx); // Explicitly set the feePayer to be our wallet (this is set to first signer by default) tx.feePayer = payer.publicKey; // Fetch a "timestamp" so validators know this is a recent transaction - const blockhash = context.lastBlockhash; - tx.recentBlockhash = blockhash; + tx.recentBlockhash = litesvm.latestBlockhash(); // Sign the transaction with the payer's keypair tx.sign(payer, counterKeypair); - // Send transaction to bankrun - await client.processTransaction(tx); + // Send transaction to litesvm + litesvm.sendTransaction(tx); // Get the counter account info from network - const counterAccountInfo = await client.getAccount(counter); + const counterAccountInfo = litesvm.getAccount(counter); assert(counterAccountInfo, 'Expected counter account to have been created'); // Deserialize the counter & check count has been incremented @@ -53,7 +70,7 @@ describe('Counter Solana Native', async () => { console.log(`[alloc+increment] count is: ${counterAccount.count.toNumber()}`); }); - test('Test allocate tx and increment tx', async () => { + test('Test allocate tx and increment tx', () => { const counterKeypair = Keypair.generate(); const counter = counterKeypair.publicKey; @@ -61,19 +78,18 @@ describe('Counter Solana Native', async () => { const allocIx: TransactionInstruction = SystemProgram.createAccount({ fromPubkey: payer.publicKey, newAccountPubkey: counter, - lamports: Number(rent.minimumBalance(BigInt(COUNTER_ACCOUNT_SIZE))), + lamports: Number(litesvm.minimumBalanceForRentExemption(BigInt(COUNTER_ACCOUNT_SIZE))), space: COUNTER_ACCOUNT_SIZE, programId: PROGRAM_ID, }); let tx = new Transaction().add(allocIx); - const blockhash = context.lastBlockhash; tx.feePayer = payer.publicKey; - tx.recentBlockhash = blockhash; + tx.recentBlockhash = litesvm.latestBlockhash(); tx.sign(payer, counterKeypair); - await client.processTransaction(tx); + litesvm.sendTransaction(tx); - let counterAccountInfo = await client.getAccount(counter); + let counterAccountInfo = litesvm.getAccount(counter); assert(counterAccountInfo, 'Expected counter account to have been created'); let counterAccount = deserializeCounterAccount(Buffer.from(counterAccountInfo.data)); @@ -81,15 +97,15 @@ describe('Counter Solana Native', async () => { console.log(`[allocate] count is: ${counterAccount.count.toNumber()}`); // Check increment tx - const incrementIx: TransactionInstruction = createIncrementInstruction({ counter }, {}); + const incrementIx: TransactionInstruction = createIncrementInstruction({ counter }, PROGRAM_ID); tx = new Transaction().add(incrementIx); tx.feePayer = payer.publicKey; - tx.recentBlockhash = blockhash; + tx.recentBlockhash = litesvm.latestBlockhash(); tx.sign(payer); - await client.processTransaction(tx); + litesvm.sendTransaction(tx); - counterAccountInfo = await client.getAccount(counter); + counterAccountInfo = litesvm.getAccount(counter); assert(counterAccountInfo, 'Expected counter account to have been created'); counterAccount = deserializeCounterAccount(Buffer.from(counterAccountInfo.data)); diff --git a/basics/counter/native/tests/tsconfig.test.json b/basics/counter/native/tests/tsconfig.test.json index cd5d2e3d0..24aa54195 100644 --- a/basics/counter/native/tests/tsconfig.test.json +++ b/basics/counter/native/tests/tsconfig.test.json @@ -3,8 +3,9 @@ "types": ["mocha", "chai"], "typeRoots": ["./node_modules/@types"], "lib": ["es2015"], - "module": "commonjs", + "module": "esnext", "target": "es6", - "esModuleInterop": true + "esModuleInterop": true, + "moduleResolution": "node" } } diff --git a/basics/counter/native/ts/accounts/index.ts b/basics/counter/native/ts/accounts/index.ts index 0ab63758b..0bd7a081f 100644 --- a/basics/counter/native/ts/accounts/index.ts +++ b/basics/counter/native/ts/accounts/index.ts @@ -1 +1 @@ -export * from './counter'; +export * from './counter.ts'; diff --git a/basics/counter/native/ts/index.ts b/basics/counter/native/ts/index.ts index 2322a115f..997ba6173 100644 --- a/basics/counter/native/ts/index.ts +++ b/basics/counter/native/ts/index.ts @@ -1,6 +1,6 @@ import { PublicKey } from '@solana/web3.js'; -export * from './accounts'; -export * from './instructions'; +export * from './accounts/index.ts'; +export * from './instructions/index.ts'; export const PROGRAM_ID = new PublicKey('Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS'); diff --git a/basics/counter/native/ts/instructions/createIncrementInstruction.ts b/basics/counter/native/ts/instructions/createIncrementInstruction.ts index 6e0bf48c4..2513e92e5 100644 --- a/basics/counter/native/ts/instructions/createIncrementInstruction.ts +++ b/basics/counter/native/ts/instructions/createIncrementInstruction.ts @@ -1,13 +1,13 @@ import { type PublicKey, TransactionInstruction } from '@solana/web3.js'; -import { PROGRAM_ID } from '../'; +import { PROGRAM_ID as DEFAULT_PROGRAM_ID } from '../index.ts'; export type IncrementInstructionAccounts = { counter: PublicKey; }; -export function createIncrementInstruction(accounts: IncrementInstructionAccounts): TransactionInstruction { +export function createIncrementInstruction(accounts: IncrementInstructionAccounts, programId: PublicKey = DEFAULT_PROGRAM_ID): TransactionInstruction { return new TransactionInstruction({ - programId: PROGRAM_ID, + programId: programId, keys: [ { pubkey: accounts.counter, diff --git a/basics/counter/native/ts/instructions/index.ts b/basics/counter/native/ts/instructions/index.ts index a0249a40c..0b492903e 100644 --- a/basics/counter/native/ts/instructions/index.ts +++ b/basics/counter/native/ts/instructions/index.ts @@ -1 +1 @@ -export * from './createIncrementInstruction'; +export * from './createIncrementInstruction.ts';