diff --git a/clients/js/package.json b/clients/js/package.json index 5fe85e0..d2ea545 100644 --- a/clients/js/package.json +++ b/clients/js/package.json @@ -34,13 +34,13 @@ }, "license": "MIT", "peerDependencies": { - "@solana/web3.js": "2.0.0-rc.1" + "@solana/web3.js": "^2.0.0" }, "devDependencies": { "@ava/typescript": "^4.1.0", "@solana/eslint-config-solana": "^3.0.3", - "@solana/web3.js": "2.0.0-rc.1", - "@solana/webcrypto-ed25519-polyfill": "2.0.0-rc.1", + "@solana/web3.js": "^2.0.0", + "@solana/webcrypto-ed25519-polyfill": "^2.0.0", "@types/node": "^20", "@typescript-eslint/eslint-plugin": "^7.16.1", "@typescript-eslint/parser": "^7.16.1", diff --git a/clients/js/pnpm-lock.yaml b/clients/js/pnpm-lock.yaml index 6ef2ec7..9ef4c6c 100644 --- a/clients/js/pnpm-lock.yaml +++ b/clients/js/pnpm-lock.yaml @@ -15,11 +15,11 @@ importers: specifier: ^3.0.3 version: 3.0.6(@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1)(typescript@5.6.3))(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint-plugin-jest@27.9.0(@typescript-eslint/eslint-plugin@7.18.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1)(typescript@5.6.3))(eslint-plugin-react-hooks@4.6.2(eslint@8.57.1))(eslint-plugin-simple-import-sort@12.1.1(eslint@8.57.1))(eslint-plugin-sort-keys-fix@1.1.2)(eslint-plugin-typescript-sort-keys@3.3.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1)(typescript@5.6.3) '@solana/web3.js': - specifier: 2.0.0-rc.1 - version: 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0) + specifier: ^2.0.0 + version: 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0) '@solana/webcrypto-ed25519-polyfill': - specifier: 2.0.0-rc.1 - version: 2.0.0-rc.1(typescript@5.6.3) + specifier: ^2.0.0 + version: 2.0.0(typescript@5.6.3) '@types/node': specifier: ^20 version: 20.16.12 @@ -365,49 +365,58 @@ packages: resolution: {integrity: sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==} engines: {node: '>=18'} - '@solana/accounts@2.0.0-rc.1': - resolution: {integrity: sha512-au6grz6iIgepKIbN2HUHKatFhg7mvIvdjFMDYpuEx+AGwK7vHnN5PsJqSCGQydthC2nVQwSZC9IgA5MF5wUHdw==} + '@solana/accounts@2.0.0': + resolution: {integrity: sha512-1CE4P3QSDH5x+ZtSthMY2mn/ekROBnlT3/4f3CHDJicDvLQsgAq2yCvGHsYkK3ZA0mxhFLuhJVjuKASPnmG1rQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/addresses@2.0.0-rc.1': - resolution: {integrity: sha512-g31KrLZdECjAKceShlGoYxnWDmEVklpjPs8xOtnj/HWupEk+Mds4vtmTACTAeJkWZW/3x+z0aexMtO86MKA47g==} + '@solana/addresses@2.0.0': + resolution: {integrity: sha512-8n3c/mUlH1/z+pM8e7OJ6uDSXw26Be0dgYiokiqblO66DGQ0d+7pqFUFZ5pEGjJ9PU2lDTSfY8rHf4cemOqwzQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/assertions@2.0.0-rc.1': - resolution: {integrity: sha512-dvxYCUB7ftZa5lWcsyMYLsGm204H6yVN8Q3ngluMG0rhTtScMBRklVg7Vs39ISwJOkJWJPGToaZ7DjNJ83bm1Q==} + '@solana/assertions@2.0.0': + resolution: {integrity: sha512-NyPPqZRNGXs/GAjfgsw7YS6vCTXWt4ibXveS+ciy5sdmp/0v3pA6DlzYjleF9Sljrew0IiON15rjaXamhDxYfQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/codecs-core@2.0.0-rc.1': - resolution: {integrity: sha512-bauxqMfSs8EHD0JKESaNmNuNvkvHSuN3bbWAF5RjOfDu2PugxHrvRebmYauvSumZ3cTfQ4HJJX6PG5rN852qyQ==} + '@solana/codecs-core@2.0.0': + resolution: {integrity: sha512-qCG+3hDU5Pm8V6joJjR4j4Zv9md1z0RaecniNDIkEglnxmOUODnmPLWbtOjnDylfItyuZeDihK8hkewdj8cUtw==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/codecs-data-structures@2.0.0-rc.1': - resolution: {integrity: sha512-rinCv0RrAVJ9rE/rmaibWJQxMwC5lSaORSZuwjopSUE6T0nb/MVg6Z1siNCXhh/HFTOg0l8bNvZHgBcN/yvXog==} + '@solana/codecs-data-structures@2.0.0': + resolution: {integrity: sha512-N98Y4jsrC/XeOgqrfsGqcOFIaOoMsKdAxOmy5oqVaEN67YoGSLNC9ROnqamOAOrsZdicTWx9/YLKFmQi9DPh1A==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/codecs-numbers@2.0.0-rc.1': - resolution: {integrity: sha512-J5i5mOkvukXn8E3Z7sGIPxsThRCgSdgTWJDQeZvucQ9PT6Y3HiVXJ0pcWiOWAoQ3RX8e/f4I3IC+wE6pZiJzDQ==} + '@solana/codecs-numbers@2.0.0': + resolution: {integrity: sha512-r66i7VzJO1MZkQWZIAI6jjJOFVpnq0+FIabo2Z2ZDtrArFus/SbSEv543yCLeD2tdR/G/p+1+P5On10qF50Y1Q==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/codecs-strings@2.0.0-rc.1': - resolution: {integrity: sha512-9/wPhw8TbGRTt6mHC4Zz1RqOnuPTqq1Nb4EyuvpZ39GW6O2t2Q7Q0XxiB3+BdoEjwA2XgPw6e2iRfvYgqty44g==} + '@solana/codecs-strings@2.0.0': + resolution: {integrity: sha512-dNqeCypsvaHcjW86H0gYgAZGGkKVBeKVeh7WXlOZ9kno7PeQ2wNkpccyzDfuzaIsKv+HZUD3v/eo86GCvnKazQ==} + engines: {node: '>=20.18.0'} peerDependencies: fastestsmallesttextencoderdecoder: ^1.0.22 typescript: '>=5' - '@solana/codecs@2.0.0-rc.1': - resolution: {integrity: sha512-qxoR7VybNJixV51L0G1RD2boZTcxmwUWnKCaJJExQ5qNKwbpSyDdWfFJfM5JhGyKe9DnPVOZB+JHWXnpbZBqrQ==} + '@solana/codecs@2.0.0': + resolution: {integrity: sha512-xneIG5ppE6WIGaZCK7JTys0uLhzlnEJUdBO8nRVIyerwH6aqCfb0fGe7q5WNNYAVDRSxC0Pc1TDe1hpdx3KWmQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/errors@2.0.0-rc.1': - resolution: {integrity: sha512-ejNvQ2oJ7+bcFAYWj225lyRkHnixuAeb7RQCixm+5mH4n1IA4Qya/9Bmfy5RAAHQzxK43clu3kZmL5eF9VGtYQ==} + '@solana/errors@2.0.0': + resolution: {integrity: sha512-IHlaPFSy4lvYco1oHJ3X8DbchWwAwJaL/4wZKnF1ugwZ0g0re8wbABrqNOe/jyZ84VU9Z14PYM8W9oDAebdJbw==} + engines: {node: '>=20.18.0'} hasBin: true peerDependencies: typescript: '>=5' @@ -425,134 +434,166 @@ packages: eslint-plugin-typescript-sort-keys: ^3.2.0 typescript: ^5.1.6 - '@solana/fast-stable-stringify@2.0.0-rc.1': - resolution: {integrity: sha512-TN8JY+Sbh5NNq4TqdWil8hXKx2d84bTHvY6jfBXNjM29S0fwpUpVRHUzOkuK1mjjWFNkMpfgJfozC0TjdUbkvA==} + '@solana/fast-stable-stringify@2.0.0': + resolution: {integrity: sha512-EsIx9z+eoxOmC+FpzhEb+H67CCYTbs/omAqXD4EdEYnCHWrI1li1oYBV+NoKzfx8fKlX+nzNB7S/9kc4u7Etpw==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/functional@2.0.0-rc.1': - resolution: {integrity: sha512-BmedS5o8HTlU8/NA22I6urJqat9QYIw0oH6rKdMMBisDwX7MtgJhe38W8iLP7QCcxoJeS4526qaD8uD62+Pheg==} + '@solana/functional@2.0.0': + resolution: {integrity: sha512-Sj+sLiUTimnMEyGnSLGt0lbih2xPDUhxhonnrIkPwA+hjQ3ULGHAxeevHU06nqiVEgENQYUJ5rCtHs4xhUFAkQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/instructions@2.0.0-rc.1': - resolution: {integrity: sha512-zkfL4WBHPbkMrYsuGZc/sekPa/oALIVvVGUw/gwAervMeLZ34cWCUE6WC2uUUh+bq3OFq0/FSFhAg2YbHHDyUw==} + '@solana/instructions@2.0.0': + resolution: {integrity: sha512-MiTEiNF7Pzp+Y+x4yadl2VUcNHboaW5WP52psBuhHns3GpbbruRv5efMpM9OEQNe1OsN+Eg39vjEidX55+P+DQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/keys@2.0.0-rc.1': - resolution: {integrity: sha512-ls3B0KOvfdiBH3/fnEjHhicfXsLLb4zApJlSX4X8NZ+2TmTJ2Jqa+MakgAzrsxL1FJkTJ1RDboR9xx2CHQtKzw==} + '@solana/keys@2.0.0': + resolution: {integrity: sha512-SSLSX8BXRvfLKBqsmBghmlhMKpwHeWd5CHi5zXgTS1BRrtiU6lcrTVC9ie6B+WaNNq7oe3e6K5bdbhu3fFZ+0g==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/options@2.0.0-rc.1': - resolution: {integrity: sha512-mLUcR9mZ3qfHlmMnREdIFPf9dpMc/Bl66tLSOOWxw4ml5xMT2ohFn7WGqoKcu/UHkT9CrC6+amEdqCNvUqI7AA==} + '@solana/options@2.0.0': + resolution: {integrity: sha512-OVc4KnYosB8oAukQ/htgrxXSxlUP6gUu5Aau6d/BgEkPQzWd/Pr+w91VWw3i3zZuu2SGpedbyh05RoJBe/hSXA==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/programs@2.0.0-rc.1': - resolution: {integrity: sha512-wF49DychwSz3sVmTF51R6DTHBGMP7Uhe7EdmCNu+Ef9EgKBJZFfrViOD6M8Q0b3WH//TV63HNlX/2QmHtJjQHg==} + '@solana/programs@2.0.0': + resolution: {integrity: sha512-JPIKB61pWfODnsvEAaPALc6vR5rn7kmHLpFaviWhBtfUlEVgB8yVTR0MURe4+z+fJCPRV5wWss+svA4EeGDYzQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/promises@2.0.0-rc.1': - resolution: {integrity: sha512-iIaC52Ka+omGabGn2LHOSgEm9N2gI7Iyik6LE3DDxZ4MuYmGcJ4E315XuE/UVXWnc9qOfOjgtSaaOYhde0vyrQ==} + '@solana/promises@2.0.0': + resolution: {integrity: sha512-4teQ52HDjK16ORrZe1zl+Q9WcZdQ+YEl0M1gk59XG7D0P9WqaVEQzeXGnKSCs+Y9bnB1u5xCJccwpUhHYWq6gg==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/rpc-api@2.0.0-rc.1': - resolution: {integrity: sha512-pg/w+0pgj3msBCC/hkZa9/qZHRdqh7MLsHMJInXnenO+Rzj6IyE47Ig6rt6GuI4OxYy+1d714jcPXVMA8p2YWw==} + '@solana/rpc-api@2.0.0': + resolution: {integrity: sha512-1FwitYxwADMF/6zKP2kNXg8ESxB6GhNBNW1c4f5dEmuXuBbeD/enLV3WMrpg8zJkIaaYarEFNbt7R7HyFzmURQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/rpc-parsed-types@2.0.0-rc.1': - resolution: {integrity: sha512-5/AYNiZvR9do56VJgmTscRwnd9myt6x9uG7b0S3V+K5e0xzA9yJF68SzI4TQSNmLfWXCaVC90xGCWWkM19lLIQ==} + '@solana/rpc-parsed-types@2.0.0': + resolution: {integrity: sha512-VCeY/oKVEtBnp8EDOc5LSSiOeIOLFIgLndcxqU0ij/cZaQ01DOoHbhluvhZtU80Z3dUeicec8TiMgkFzed+WhQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/rpc-spec-types@2.0.0-rc.1': - resolution: {integrity: sha512-Z0gOrzasTYU+kNNnDDG2snZxBoBPMN8oFc0EE9HiDKN9JEsc+asexzKeq+Nea7JVqVFcN5V3bjqrpD86V5EOiQ==} + '@solana/rpc-spec-types@2.0.0': + resolution: {integrity: sha512-G2lmhFhgtxMQd/D6B04BHGE7bm5dMZdIPQNOqVGhzNAVjrmyapD3JN2hKAbmaYPe97wLfZERw0Ux1u4Y6q7TqA==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/rpc-spec@2.0.0-rc.1': - resolution: {integrity: sha512-E81IoNzLbp24T633klEqlRujd2i/rd8xVkJGt04DL/LGS4/cCWJEhkmOnfljxWafCPUundRXlPtNG3ZmHzEYqA==} + '@solana/rpc-spec@2.0.0': + resolution: {integrity: sha512-1uIDzj7vocCUqfOifjv1zAuxQ53ugiup/42edVFoQLOnJresoEZLL6WjnsJq4oCTccEAvGhUBI1WWKeZTGNxFQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/rpc-subscriptions-api@2.0.0-rc.1': - resolution: {integrity: sha512-HmuJmB+RnpYzpiwDWncYFey0lrdFt8KbFvH0JvxEB7NX6V9NgGQIwRY1bfoaeSwX6t93p4nBWr2ckJWLNjXzCw==} + '@solana/rpc-subscriptions-api@2.0.0': + resolution: {integrity: sha512-NAJQvSFXYIIf8zxsMFBCkSbZNZgT32pzPZ1V6ZAd+U2iDEjx3L+yFwoJgfOcHp8kAV+alsF2lIsGBlG4u+ehvw==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/rpc-subscriptions-spec@2.0.0-rc.1': - resolution: {integrity: sha512-eXRVlMr9zw4JlBoJgVhFRxFs3Iaowhtt35ZIMD+OoTqgKniL62iGiZ3hXsuMDToMvQCBd0UfI+ZVdF2gLQdg9A==} + '@solana/rpc-subscriptions-channel-websocket@2.0.0': + resolution: {integrity: sha512-hSQDZBmcp2t+gLZsSBqs/SqVw4RuNSC7njiP46azyzW7oGg8X2YPV36AHGsHD12KPsc0UpT1OAZ4+AN9meVKww==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' + ws: ^8.18.0 - '@solana/rpc-subscriptions-transport-websocket@2.0.0-rc.1': - resolution: {integrity: sha512-NxheQmG6Ku9gjF3TyGbM8Nxx6fOU3m89LdfH9SQNu6yME6VXKWuT1LaY24T707yDOoKZJsOWabRrQtNfJ+3HZA==} + '@solana/rpc-subscriptions-spec@2.0.0': + resolution: {integrity: sha512-VXMiI3fYtU1PkVVTXL87pcY48ZY8aCi1N6FqtxSP2xg/GASL01j1qbwyIL1OvoCqGyRgIxdd/YfaByW9wmWBhA==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - ws: ^8.14.0 - '@solana/rpc-subscriptions@2.0.0-rc.1': - resolution: {integrity: sha512-gHrVNWEbMi8uDO8BzpJkuDiHMcfD4SrfLRohROnHx0SfSlEGxvIkBjPnwOYIoS7IkWk95e19s7hJoBNn2TX4kw==} + '@solana/rpc-subscriptions@2.0.0': + resolution: {integrity: sha512-AdwMJHMrhlj7q1MPjZmVcKq3iLqMW3N0MT8kzIAP2vP+8o/d6Fn4aqGxoz2Hlfn3OYIZoYStN2VBtwzbcfEgMA==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/rpc-transformers@2.0.0-rc.1': - resolution: {integrity: sha512-YM25X4Eeh39UR2AoSrCFn74W99bQk0/DLqyPgZpNBRbszzEifGHqu83NNFwBuPMVc9q7ilf5s6r6pqhWP+5JJw==} + '@solana/rpc-transformers@2.0.0': + resolution: {integrity: sha512-H6tN0qcqzUangowsLLQtYXKJsf1Roe3/qJ1Cy0gv9ojY9uEvNbJqpeEj+7blv0MUZfEe+rECAwBhxxRKPMhYGw==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/rpc-transport-http@2.0.0-rc.1': - resolution: {integrity: sha512-Byvn2LnaCgTnEyr78wcgh8SrVHo+L6/l1kXQW05cNAjjbS8d8z4meBUBrXDWHmCsWy7RdnrTcBixPPtE+pUebw==} + '@solana/rpc-transport-http@2.0.0': + resolution: {integrity: sha512-UJLhKhhxDd1OPi8hb2AenHsDm1mofCBbhWn4bDCnH2Q3ulwYadUhcNqNbxjJPQ774VNhAf53SSI5A6PQo8IZSQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/rpc-types@2.0.0-rc.1': - resolution: {integrity: sha512-EcGx9VXqA0+uYEdaa1lKTaGBVxLyNL8nkecE4GkqQ+ntRyYlNBPecd4b8siQGSleUQa+Tk/VSPUawSkHqNTLug==} + '@solana/rpc-types@2.0.0': + resolution: {integrity: sha512-o1ApB9PYR0A3XjVSOh//SOVWgjDcqMlR3UNmtqciuREIBmWqnvPirdOa5EJxD3iPhfA4gnNnhGzT+tMDeDW/Kw==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/rpc@2.0.0-rc.1': - resolution: {integrity: sha512-upqR/Ae5syzQDZkffTdU/09k1Vx073Gt4xkkpcWaTBmW0obVhrlvJvH2k5jrOQ13BZd2NVg1MWMEOBcy3+nJjQ==} + '@solana/rpc@2.0.0': + resolution: {integrity: sha512-TumQ9DFRpib/RyaIqLVfr7UjqSo7ldfzpae0tgjM93YjbItB4Z0VcUXc3uAFvkeYw2/HIMb46Zg43mkUwozjDg==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/signers@2.0.0-rc.1': - resolution: {integrity: sha512-dv3oKSF+AIaHKpnSkmzEf+jXVcA3nl015+Mp/WQZYzQJS01dlrmnd4N5DOSn2CaPRJ0TLujHkupxkOFXbe149A==} + '@solana/signers@2.0.0': + resolution: {integrity: sha512-JEYJS3x/iKkqPV/3b1nLpX9lHib21wQKV3fOuu1aDLQqmX9OYKrnIIITYdnFDhmvGhpEpkkbPnqu7yVaFIBYsQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/sysvars@2.0.0-rc.1': - resolution: {integrity: sha512-nLiuisgbRw7FkJrxPJOBzf0ro7ZCk0gWgMyLQexe9oPoTzdZnWbHI4ldYDmtfdy2dkPBsNTz6sZ6o75HwnGu0A==} + '@solana/subscribable@2.0.0': + resolution: {integrity: sha512-Ex7d2GnTSNVMZDU3z6nKN4agRDDgCgBDiLnmn1hmt0iFo3alr3gRAqiqa7qGouAtYh9/29pyc8tVJCijHWJPQQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/transaction-confirmation@2.0.0-rc.1': - resolution: {integrity: sha512-ES671CZUDLaXV46Vv3Kxd22coSQE4DlE7y0s9ChzQ7t4bLGv6DeHlHXU9kQBtou9koLR25wiDUWtvwNUyzUbHw==} + '@solana/sysvars@2.0.0': + resolution: {integrity: sha512-8D4ajKcCYQsTG1p4k30lre2vjxLR6S5MftUGJnIaQObDCzGmaeA9GRti4Kk4gSPWVYFTBoj1ASx8EcEXaB3eIQ==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/transaction-messages@2.0.0-rc.1': - resolution: {integrity: sha512-pZTetOtRDwfuK/fyE8FKbtRsLQOTgEIQld3tskB85npUHaEgrnCYzp3nJtMhKOLel3w3f/27VtWLNSrRyyAiew==} + '@solana/transaction-confirmation@2.0.0': + resolution: {integrity: sha512-JkTw5gXLiqQjf6xK0fpVcoJ/aMp2kagtFSD/BAOazdJ3UYzOzbzqvECt6uWa3ConcMswQ2vXalVtI7ZjmYuIeg==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/transactions@2.0.0-rc.1': - resolution: {integrity: sha512-u9MH2Kk4P0E5rNxATdx/ljR2rp34S9VuC3Jzj9nCMKJ0XwvCD+ddTmIDop5Vs+96Ls9SGj0XaKAJtT+9S7SDpw==} + '@solana/transaction-messages@2.0.0': + resolution: {integrity: sha512-Uc6Fw1EJLBrmgS1lH2ZfLAAKFvprWPQQzOVwZS78Pv8Whsk7tweYTK6S0Upv0nHr50rGpnORJfmdBrXE6OfNGg==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/web3.js@2.0.0-rc.1': - resolution: {integrity: sha512-0fE40ZsJuqSOYOWbt8haHBIbhSfGckxJbwWEK+xRQaWr1sY1+MPUDnBawsLf818g9KRSNnS2Y3+/Sve7A3yfBA==} + '@solana/transactions@2.0.0': + resolution: {integrity: sha512-VfdTE+59WKvuBG//6iE9RPjAB+ZT2kLgY2CDHabaz6RkH6OjOkMez9fWPVa3Xtcus+YQWN1SnQoryjF/xSx04w==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/webcrypto-ed25519-polyfill@2.0.0-rc.1': - resolution: {integrity: sha512-e3bu5/kREsCoQGFLCUZ9P+bTOsS0pwQhNQ6Gj3rWelt05skYB4iHGZf1hdqEwPA4DNcKvQwccbILXMhpdexong==} + '@solana/web3.js@2.0.0': + resolution: {integrity: sha512-x+ZRB2/r5tVK/xw8QRbAfgPcX51G9f2ifEyAQ/J5npOO+6+MPeeCjtr5UxHNDAYs9Ypo0PN+YJATCO4vhzQJGg==} + engines: {node: '>=20.18.0'} + peerDependencies: + typescript: '>=5' + + '@solana/webcrypto-ed25519-polyfill@2.0.0': + resolution: {integrity: sha512-NGoAmBe6/OOSTtDqq44nzad2Qx/lv5YdpHbkU5jykFivc7t2o9Ig6E+PcKjGuM3eTIeo11xoAN8ePA6DefyL1Q==} + engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' @@ -2211,71 +2252,71 @@ snapshots: '@sindresorhus/merge-streams@2.3.0': {} - '@solana/accounts@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/accounts@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/addresses': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/codecs-core': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-strings': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-spec': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-types': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/addresses': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/codecs-core': 2.0.0(typescript@5.6.3) + '@solana/codecs-strings': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/rpc-spec': 2.0.0(typescript@5.6.3) + '@solana/rpc-types': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/addresses@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/addresses@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/assertions': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-core': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-strings': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) + '@solana/assertions': 2.0.0(typescript@5.6.3) + '@solana/codecs-core': 2.0.0(typescript@5.6.3) + '@solana/codecs-strings': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/assertions@2.0.0-rc.1(typescript@5.6.3)': + '@solana/assertions@2.0.0(typescript@5.6.3)': dependencies: - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) typescript: 5.6.3 - '@solana/codecs-core@2.0.0-rc.1(typescript@5.6.3)': + '@solana/codecs-core@2.0.0(typescript@5.6.3)': dependencies: - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) typescript: 5.6.3 - '@solana/codecs-data-structures@2.0.0-rc.1(typescript@5.6.3)': + '@solana/codecs-data-structures@2.0.0(typescript@5.6.3)': dependencies: - '@solana/codecs-core': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-numbers': 2.0.0-rc.1(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) + '@solana/codecs-core': 2.0.0(typescript@5.6.3) + '@solana/codecs-numbers': 2.0.0(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) typescript: 5.6.3 - '@solana/codecs-numbers@2.0.0-rc.1(typescript@5.6.3)': + '@solana/codecs-numbers@2.0.0(typescript@5.6.3)': dependencies: - '@solana/codecs-core': 2.0.0-rc.1(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) + '@solana/codecs-core': 2.0.0(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) typescript: 5.6.3 - '@solana/codecs-strings@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/codecs-strings@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/codecs-core': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-numbers': 2.0.0-rc.1(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) + '@solana/codecs-core': 2.0.0(typescript@5.6.3) + '@solana/codecs-numbers': 2.0.0(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) fastestsmallesttextencoderdecoder: 1.0.22 typescript: 5.6.3 - '@solana/codecs@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/codecs@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/codecs-core': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-data-structures': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-numbers': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-strings': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/options': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/codecs-core': 2.0.0(typescript@5.6.3) + '@solana/codecs-data-structures': 2.0.0(typescript@5.6.3) + '@solana/codecs-numbers': 2.0.0(typescript@5.6.3) + '@solana/codecs-strings': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/options': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/errors@2.0.0-rc.1(typescript@5.6.3)': + '@solana/errors@2.0.0(typescript@5.6.3)': dependencies: chalk: 5.3.0 commander: 12.1.0 @@ -2293,263 +2334,277 @@ snapshots: eslint-plugin-typescript-sort-keys: 3.3.0(@typescript-eslint/parser@7.18.0(eslint@8.57.1)(typescript@5.6.3))(eslint@8.57.1)(typescript@5.6.3) typescript: 5.6.3 - '@solana/fast-stable-stringify@2.0.0-rc.1(typescript@5.6.3)': + '@solana/fast-stable-stringify@2.0.0(typescript@5.6.3)': dependencies: typescript: 5.6.3 - '@solana/functional@2.0.0-rc.1(typescript@5.6.3)': + '@solana/functional@2.0.0(typescript@5.6.3)': dependencies: typescript: 5.6.3 - '@solana/instructions@2.0.0-rc.1(typescript@5.6.3)': + '@solana/instructions@2.0.0(typescript@5.6.3)': dependencies: - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) typescript: 5.6.3 - '@solana/keys@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/keys@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/assertions': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-core': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-strings': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) + '@solana/assertions': 2.0.0(typescript@5.6.3) + '@solana/codecs-core': 2.0.0(typescript@5.6.3) + '@solana/codecs-strings': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/options@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/options@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/codecs-core': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-data-structures': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-numbers': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-strings': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) + '@solana/codecs-core': 2.0.0(typescript@5.6.3) + '@solana/codecs-data-structures': 2.0.0(typescript@5.6.3) + '@solana/codecs-numbers': 2.0.0(typescript@5.6.3) + '@solana/codecs-strings': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/programs@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/programs@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/addresses': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) + '@solana/addresses': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/promises@2.0.0-rc.1(typescript@5.6.3)': + '@solana/promises@2.0.0(typescript@5.6.3)': dependencies: typescript: 5.6.3 - '@solana/rpc-api@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': - dependencies: - '@solana/addresses': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/codecs-core': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-strings': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/keys': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/rpc-parsed-types': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-spec': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-transformers': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/rpc-types': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/transaction-messages': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/transactions': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc-api@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + dependencies: + '@solana/addresses': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/codecs-core': 2.0.0(typescript@5.6.3) + '@solana/codecs-strings': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/keys': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc-parsed-types': 2.0.0(typescript@5.6.3) + '@solana/rpc-spec': 2.0.0(typescript@5.6.3) + '@solana/rpc-transformers': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc-types': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/transaction-messages': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/transactions': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/rpc-parsed-types@2.0.0-rc.1(typescript@5.6.3)': + '@solana/rpc-parsed-types@2.0.0(typescript@5.6.3)': dependencies: typescript: 5.6.3 - '@solana/rpc-spec-types@2.0.0-rc.1(typescript@5.6.3)': + '@solana/rpc-spec-types@2.0.0(typescript@5.6.3)': dependencies: typescript: 5.6.3 - '@solana/rpc-spec@2.0.0-rc.1(typescript@5.6.3)': + '@solana/rpc-spec@2.0.0(typescript@5.6.3)': dependencies: - '@solana/rpc-spec-types': 2.0.0-rc.1(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/rpc-spec-types': 2.0.0(typescript@5.6.3) typescript: 5.6.3 - '@solana/rpc-subscriptions-api@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/rpc-subscriptions-api@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/addresses': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/keys': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/rpc-subscriptions-spec': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-transformers': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/rpc-types': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/transaction-messages': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/transactions': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/addresses': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/keys': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc-subscriptions-spec': 2.0.0(typescript@5.6.3) + '@solana/rpc-transformers': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc-types': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/transaction-messages': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/transactions': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/rpc-subscriptions-spec@2.0.0-rc.1(typescript@5.6.3)': + '@solana/rpc-subscriptions-channel-websocket@2.0.0(typescript@5.6.3)(ws@8.18.0)': dependencies: - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-spec-types': 2.0.0-rc.1(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/functional': 2.0.0(typescript@5.6.3) + '@solana/rpc-subscriptions-spec': 2.0.0(typescript@5.6.3) + '@solana/subscribable': 2.0.0(typescript@5.6.3) typescript: 5.6.3 + ws: 8.18.0 - '@solana/rpc-subscriptions-transport-websocket@2.0.0-rc.1(typescript@5.6.3)(ws@8.18.0)': + '@solana/rpc-subscriptions-spec@2.0.0(typescript@5.6.3)': dependencies: - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-subscriptions-spec': 2.0.0-rc.1(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/promises': 2.0.0(typescript@5.6.3) + '@solana/rpc-spec-types': 2.0.0(typescript@5.6.3) + '@solana/subscribable': 2.0.0(typescript@5.6.3) typescript: 5.6.3 - ws: 8.18.0 - '@solana/rpc-subscriptions@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0)': - dependencies: - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/fast-stable-stringify': 2.0.0-rc.1(typescript@5.6.3) - '@solana/functional': 2.0.0-rc.1(typescript@5.6.3) - '@solana/promises': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-subscriptions-api': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/rpc-subscriptions-spec': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-subscriptions-transport-websocket': 2.0.0-rc.1(typescript@5.6.3)(ws@8.18.0) - '@solana/rpc-transformers': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/rpc-types': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc-subscriptions@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0)': + dependencies: + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/fast-stable-stringify': 2.0.0(typescript@5.6.3) + '@solana/functional': 2.0.0(typescript@5.6.3) + '@solana/promises': 2.0.0(typescript@5.6.3) + '@solana/rpc-spec-types': 2.0.0(typescript@5.6.3) + '@solana/rpc-subscriptions-api': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc-subscriptions-channel-websocket': 2.0.0(typescript@5.6.3)(ws@8.18.0) + '@solana/rpc-subscriptions-spec': 2.0.0(typescript@5.6.3) + '@solana/rpc-transformers': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc-types': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/subscribable': 2.0.0(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - ws - '@solana/rpc-transformers@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/rpc-transformers@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/functional': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-spec': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-subscriptions-spec': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-types': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/functional': 2.0.0(typescript@5.6.3) + '@solana/rpc-spec-types': 2.0.0(typescript@5.6.3) + '@solana/rpc-types': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/rpc-transport-http@2.0.0-rc.1(typescript@5.6.3)': + '@solana/rpc-transport-http@2.0.0(typescript@5.6.3)': dependencies: - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-spec': 2.0.0-rc.1(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/rpc-spec': 2.0.0(typescript@5.6.3) + '@solana/rpc-spec-types': 2.0.0(typescript@5.6.3) typescript: 5.6.3 undici-types: 6.20.0 - '@solana/rpc-types@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/rpc-types@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/addresses': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/codecs-core': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-numbers': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-strings': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) + '@solana/addresses': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/codecs-core': 2.0.0(typescript@5.6.3) + '@solana/codecs-numbers': 2.0.0(typescript@5.6.3) + '@solana/codecs-strings': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/rpc@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': - dependencies: - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/fast-stable-stringify': 2.0.0-rc.1(typescript@5.6.3) - '@solana/functional': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-api': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/rpc-spec': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-transformers': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/rpc-transport-http': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-types': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + dependencies: + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/fast-stable-stringify': 2.0.0(typescript@5.6.3) + '@solana/functional': 2.0.0(typescript@5.6.3) + '@solana/rpc-api': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc-spec': 2.0.0(typescript@5.6.3) + '@solana/rpc-spec-types': 2.0.0(typescript@5.6.3) + '@solana/rpc-transformers': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc-transport-http': 2.0.0(typescript@5.6.3) + '@solana/rpc-types': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/signers@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/signers@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/addresses': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/codecs-core': 2.0.0-rc.1(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/instructions': 2.0.0-rc.1(typescript@5.6.3) - '@solana/keys': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/transaction-messages': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/transactions': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/addresses': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/codecs-core': 2.0.0(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/instructions': 2.0.0(typescript@5.6.3) + '@solana/keys': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/transaction-messages': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/transactions': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/sysvars@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/subscribable@2.0.0(typescript@5.6.3)': + dependencies: + '@solana/errors': 2.0.0(typescript@5.6.3) + typescript: 5.6.3 + + '@solana/sysvars@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/accounts': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/codecs': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-types': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/accounts': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/codecs': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/rpc-types': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/transaction-confirmation@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0)': - dependencies: - '@solana/addresses': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/codecs-strings': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/keys': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/promises': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/rpc-subscriptions': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0) - '@solana/rpc-types': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/transaction-messages': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/transactions': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/transaction-confirmation@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0)': + dependencies: + '@solana/addresses': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/codecs-strings': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/keys': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/promises': 2.0.0(typescript@5.6.3) + '@solana/rpc': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc-subscriptions': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0) + '@solana/rpc-types': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/transaction-messages': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/transactions': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - ws - '@solana/transaction-messages@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/transaction-messages@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/addresses': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/codecs-core': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-data-structures': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-numbers': 2.0.0-rc.1(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/functional': 2.0.0-rc.1(typescript@5.6.3) - '@solana/instructions': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-types': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/addresses': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/codecs-core': 2.0.0(typescript@5.6.3) + '@solana/codecs-data-structures': 2.0.0(typescript@5.6.3) + '@solana/codecs-numbers': 2.0.0(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/functional': 2.0.0(typescript@5.6.3) + '@solana/instructions': 2.0.0(typescript@5.6.3) + '@solana/rpc-types': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/transactions@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': - dependencies: - '@solana/addresses': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/codecs-core': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-data-structures': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-numbers': 2.0.0-rc.1(typescript@5.6.3) - '@solana/codecs-strings': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/functional': 2.0.0-rc.1(typescript@5.6.3) - '@solana/instructions': 2.0.0-rc.1(typescript@5.6.3) - '@solana/keys': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/rpc-types': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/transaction-messages': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/transactions@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + dependencies: + '@solana/addresses': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/codecs-core': 2.0.0(typescript@5.6.3) + '@solana/codecs-data-structures': 2.0.0(typescript@5.6.3) + '@solana/codecs-numbers': 2.0.0(typescript@5.6.3) + '@solana/codecs-strings': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/functional': 2.0.0(typescript@5.6.3) + '@solana/instructions': 2.0.0(typescript@5.6.3) + '@solana/keys': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc-types': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/transaction-messages': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - '@solana/web3.js@2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0)': - dependencies: - '@solana/accounts': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/addresses': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/codecs': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.1(typescript@5.6.3) - '@solana/functional': 2.0.0-rc.1(typescript@5.6.3) - '@solana/instructions': 2.0.0-rc.1(typescript@5.6.3) - '@solana/keys': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/programs': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/rpc': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/rpc-parsed-types': 2.0.0-rc.1(typescript@5.6.3) - '@solana/rpc-subscriptions': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0) - '@solana/rpc-types': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/signers': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/sysvars': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/transaction-confirmation': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0) - '@solana/transaction-messages': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) - '@solana/transactions': 2.0.0-rc.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/web3.js@2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0)': + dependencies: + '@solana/accounts': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/addresses': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/codecs': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/errors': 2.0.0(typescript@5.6.3) + '@solana/functional': 2.0.0(typescript@5.6.3) + '@solana/instructions': 2.0.0(typescript@5.6.3) + '@solana/keys': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/programs': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/rpc-parsed-types': 2.0.0(typescript@5.6.3) + '@solana/rpc-spec-types': 2.0.0(typescript@5.6.3) + '@solana/rpc-subscriptions': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0) + '@solana/rpc-types': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/signers': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/sysvars': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/transaction-confirmation': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)(ws@8.18.0) + '@solana/transaction-messages': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@solana/transactions': 2.0.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) typescript: 5.6.3 transitivePeerDependencies: - fastestsmallesttextencoderdecoder - ws - '@solana/webcrypto-ed25519-polyfill@2.0.0-rc.1(typescript@5.6.3)': + '@solana/webcrypto-ed25519-polyfill@2.0.0(typescript@5.6.3)': dependencies: '@noble/ed25519': 2.1.0 typescript: 5.6.3 diff --git a/clients/js/src/generated/accounts/index.ts b/clients/js/src/generated/accounts/index.ts new file mode 100644 index 0000000..a9dd592 --- /dev/null +++ b/clients/js/src/generated/accounts/index.ts @@ -0,0 +1,9 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +export * from './stakeStateAccount'; diff --git a/clients/js/src/generated/accounts/stakeStateAccount.ts b/clients/js/src/generated/accounts/stakeStateAccount.ts new file mode 100644 index 0000000..c2ea4a9 --- /dev/null +++ b/clients/js/src/generated/accounts/stakeStateAccount.ts @@ -0,0 +1,119 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + getStructDecoder, + getStructEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, +} from '@solana/web3.js'; +import { + getStakeStateV2Decoder, + getStakeStateV2Encoder, + type StakeStateV2, + type StakeStateV2Args, +} from '../types'; + +export type StakeStateAccount = { state: StakeStateV2 }; + +export type StakeStateAccountArgs = { state: StakeStateV2Args }; + +export function getStakeStateAccountEncoder(): Encoder { + return getStructEncoder([['state', getStakeStateV2Encoder()]]); +} + +export function getStakeStateAccountDecoder(): Decoder { + return getStructDecoder([['state', getStakeStateV2Decoder()]]); +} + +export function getStakeStateAccountCodec(): Codec< + StakeStateAccountArgs, + StakeStateAccount +> { + return combineCodec( + getStakeStateAccountEncoder(), + getStakeStateAccountDecoder() + ); +} + +export function decodeStakeStateAccount( + encodedAccount: EncodedAccount +): Account; +export function decodeStakeStateAccount( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeStakeStateAccount( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getStakeStateAccountDecoder() + ); +} + +export async function fetchStakeStateAccount( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeStakeStateAccount(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeStakeStateAccount< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeStakeStateAccount(maybeAccount); +} + +export async function fetchAllStakeStateAccount( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeStakeStateAccount( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeStakeStateAccount( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeStakeStateAccount(maybeAccount) + ); +} diff --git a/clients/js/src/generated/errors/index.ts b/clients/js/src/generated/errors/index.ts new file mode 100644 index 0000000..073faf0 --- /dev/null +++ b/clients/js/src/generated/errors/index.ts @@ -0,0 +1,9 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +export * from './stake'; diff --git a/clients/js/src/generated/errors/stake.ts b/clients/js/src/generated/errors/stake.ts new file mode 100644 index 0000000..9332baf --- /dev/null +++ b/clients/js/src/generated/errors/stake.ts @@ -0,0 +1,115 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + isProgramError, + type Address, + type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, + type SolanaError, +} from '@solana/web3.js'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; + +export const STAKE_ERROR__NO_CREDITS_TO_REDEEM = 0x0; // 0 + +export const STAKE_ERROR__LOCKUP_IN_FORCE = 0x1; // 1 + +export const STAKE_ERROR__ALREADY_DEACTIVATED = 0x2; // 2 + +export const STAKE_ERROR__TOO_SOON_TO_REDELEGATE = 0x3; // 3 + +export const STAKE_ERROR__INSUFFICIENT_STAKE = 0x4; // 4 + +export const STAKE_ERROR__MERGE_TRANSIENT_STAKE = 0x5; // 5 + +export const STAKE_ERROR__MERGE_MISMATCH = 0x6; // 6 + +export const STAKE_ERROR__CUSTODIAN_MISSING = 0x7; // 7 + +export const STAKE_ERROR__CUSTODIAN_SIGNATURE_MISSING = 0x8; // 8 + +export const STAKE_ERROR__INSUFFICIENT_REFERENCE_VOTES = 0x9; // 9 + +export const STAKE_ERROR__VOTE_ADDRESS_MISMATCH = 0xa; // 10 + +export const STAKE_ERROR__MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION_NOT_MET = 0xb; // 11 + +export const STAKE_ERROR__INSUFFICIENT_DELEGATION = 0xc; // 12 + +export const STAKE_ERROR__REDELEGATE_TRANSIENT_OR_INACTIVE_STAKE = 0xd; // 13 + +export const STAKE_ERROR__REDELEGATE_TO_SAME_VOTE_ACCOUNT = 0xe; // 14 + +export const STAKE_ERROR__REDELEGATED_STAKE_MUST_FULLY_ACTIVATE_BEFORE_DEACTIVATION_IS_PERMITTED = 0xf; // 15 + +export const STAKE_ERROR__EPOCH_REWARDS_ACTIVE = 0x10; // 16 + +export type StakeError = + | typeof STAKE_ERROR__ALREADY_DEACTIVATED + | typeof STAKE_ERROR__CUSTODIAN_MISSING + | typeof STAKE_ERROR__CUSTODIAN_SIGNATURE_MISSING + | typeof STAKE_ERROR__EPOCH_REWARDS_ACTIVE + | typeof STAKE_ERROR__INSUFFICIENT_DELEGATION + | typeof STAKE_ERROR__INSUFFICIENT_REFERENCE_VOTES + | typeof STAKE_ERROR__INSUFFICIENT_STAKE + | typeof STAKE_ERROR__LOCKUP_IN_FORCE + | typeof STAKE_ERROR__MERGE_MISMATCH + | typeof STAKE_ERROR__MERGE_TRANSIENT_STAKE + | typeof STAKE_ERROR__MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION_NOT_MET + | typeof STAKE_ERROR__NO_CREDITS_TO_REDEEM + | typeof STAKE_ERROR__REDELEGATED_STAKE_MUST_FULLY_ACTIVATE_BEFORE_DEACTIVATION_IS_PERMITTED + | typeof STAKE_ERROR__REDELEGATE_TO_SAME_VOTE_ACCOUNT + | typeof STAKE_ERROR__REDELEGATE_TRANSIENT_OR_INACTIVE_STAKE + | typeof STAKE_ERROR__TOO_SOON_TO_REDELEGATE + | typeof STAKE_ERROR__VOTE_ADDRESS_MISMATCH; + +let stakeErrorMessages: Record | undefined; +if (process.env.NODE_ENV !== 'production') { + stakeErrorMessages = { + [STAKE_ERROR__ALREADY_DEACTIVATED]: `Stake already deactivated`, + [STAKE_ERROR__CUSTODIAN_MISSING]: `Custodian address not present`, + [STAKE_ERROR__CUSTODIAN_SIGNATURE_MISSING]: `Custodian signature not present`, + [STAKE_ERROR__EPOCH_REWARDS_ACTIVE]: `Stake action is not permitted while the epoch rewards period is active`, + [STAKE_ERROR__INSUFFICIENT_DELEGATION]: `Delegation amount is less than the minimum`, + [STAKE_ERROR__INSUFFICIENT_REFERENCE_VOTES]: `Insufficient voting activity in the reference vote account`, + [STAKE_ERROR__INSUFFICIENT_STAKE]: `Split amount is more than is staked`, + [STAKE_ERROR__LOCKUP_IN_FORCE]: `Lockup has not yet expired`, + [STAKE_ERROR__MERGE_MISMATCH]: `Stake account merge failed due to different authority, lockups or state`, + [STAKE_ERROR__MERGE_TRANSIENT_STAKE]: `Stake account with transient stake cannot be merged`, + [STAKE_ERROR__MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION_NOT_MET]: `Stake account has not been delinquent for the minimum epochs required for deactivation`, + [STAKE_ERROR__NO_CREDITS_TO_REDEEM]: `Not enough credits to redeem`, + [STAKE_ERROR__REDELEGATED_STAKE_MUST_FULLY_ACTIVATE_BEFORE_DEACTIVATION_IS_PERMITTED]: `Redelegated stake must be fully activated before deactivation`, + [STAKE_ERROR__REDELEGATE_TO_SAME_VOTE_ACCOUNT]: `Stake redelegation to the same vote account is not permitted`, + [STAKE_ERROR__REDELEGATE_TRANSIENT_OR_INACTIVE_STAKE]: `Stake account with transient or inactive stake cannot be redelegated`, + [STAKE_ERROR__TOO_SOON_TO_REDELEGATE]: `One re-delegation permitted per epoch`, + [STAKE_ERROR__VOTE_ADDRESS_MISMATCH]: `Stake account is not delegated to the provided vote account`, + }; +} + +export function getStakeErrorMessage(code: StakeError): string { + if (process.env.NODE_ENV !== 'production') { + return (stakeErrorMessages as Record)[code]; + } + + return 'Error message not available in production bundles.'; +} + +export function isStakeError( + error: unknown, + transactionMessage: { + instructions: Record; + }, + code?: TProgramErrorCode +): error is SolanaError & + Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { + return isProgramError( + error, + transactionMessage, + STAKE_PROGRAM_ADDRESS, + code + ); +} diff --git a/clients/js/src/generated/index.ts b/clients/js/src/generated/index.ts index 29d4ac0..02964a6 100644 --- a/clients/js/src/generated/index.ts +++ b/clients/js/src/generated/index.ts @@ -6,6 +6,8 @@ * @see https://github.com/codama-idl/codama */ +export * from './accounts'; +export * from './errors'; export * from './instructions'; export * from './programs'; export * from './types'; diff --git a/clients/js/src/generated/instructions/authorize.ts b/clients/js/src/generated/instructions/authorize.ts index eaf7c2f..c06314a 100644 --- a/clients/js/src/generated/instructions/authorize.ts +++ b/clients/js/src/generated/instructions/authorize.ts @@ -8,14 +8,12 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, getAddressDecoder, getAddressEncoder, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, + getU8Decoder, + getU8Encoder, transformEncoder, type Address, type Codec, @@ -28,11 +26,10 @@ import { type IInstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, - type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { getStakeAuthorizeDecoder, @@ -41,19 +38,20 @@ import { type StakeAuthorizeArgs, } from '../types'; -export const AUTHORIZE_DISCRIMINATOR = new Uint8Array([ - 173, 193, 102, 210, 219, 137, 113, 120, -]); +export const AUTHORIZE_DISCRIMINATOR = 1; export function getAuthorizeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(AUTHORIZE_DISCRIMINATOR); + return getU8Encoder().encode(AUTHORIZE_DISCRIMINATOR); } export type AuthorizeInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | IAccountMeta = string, - TAccountClock extends string | IAccountMeta = string, + TAccountClockSysvar extends + | string + | IAccountMeta = 'SysvarC1ock11111111111111111111111111111111', TAccountAuthority extends string | IAccountMeta = string, + TAccountLockupAuthority extends string | IAccountMeta = string, TRemainingAccounts extends readonly IAccountMeta[] = [], > = IInstruction & IInstructionWithData & @@ -62,34 +60,38 @@ export type AuthorizeInstruction< TAccountStake extends string ? WritableAccount : TAccountStake, - TAccountClock extends string - ? ReadonlyAccount - : TAccountClock, + TAccountClockSysvar extends string + ? ReadonlyAccount + : TAccountClockSysvar, TAccountAuthority extends string ? ReadonlySignerAccount & IAccountSignerMeta : TAccountAuthority, + TAccountLockupAuthority extends string + ? ReadonlySignerAccount & + IAccountSignerMeta + : TAccountLockupAuthority, ...TRemainingAccounts, ] >; export type AuthorizeInstructionData = { - discriminator: ReadonlyUint8Array; - newAuthority: Address; - stakeAuthorize: StakeAuthorize; + discriminator: number; + arg0: Address; + arg1: StakeAuthorize; }; export type AuthorizeInstructionDataArgs = { - newAuthority: Address; - stakeAuthorize: StakeAuthorizeArgs; + arg0: Address; + arg1: StakeAuthorizeArgs; }; export function getAuthorizeInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newAuthority', getAddressEncoder()], - ['stakeAuthorize', getStakeAuthorizeEncoder()], + ['discriminator', getU8Encoder()], + ['arg0', getAddressEncoder()], + ['arg1', getStakeAuthorizeEncoder()], ]), (value) => ({ ...value, discriminator: AUTHORIZE_DISCRIMINATOR }) ); @@ -97,9 +99,9 @@ export function getAuthorizeInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newAuthority', getAddressDecoder()], - ['stakeAuthorize', getStakeAuthorizeDecoder()], + ['discriminator', getU8Decoder()], + ['arg0', getAddressDecoder()], + ['arg1', getStakeAuthorizeDecoder()], ]); } @@ -115,42 +117,55 @@ export function getAuthorizeInstructionDataCodec(): Codec< export type AuthorizeInput< TAccountStake extends string = string, - TAccountClock extends string = string, + TAccountClockSysvar extends string = string, TAccountAuthority extends string = string, + TAccountLockupAuthority extends string = string, > = { - /** The stake account to be updated */ + /** Stake account to be updated */ stake: Address; /** Clock sysvar */ - clock: Address; - /** stake's current stake or withdraw authority to change away from. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer */ + clockSysvar?: Address; + /** Stake or withdraw authority */ authority: TransactionSigner; - newAuthority: AuthorizeInstructionDataArgs['newAuthority']; - stakeAuthorize: AuthorizeInstructionDataArgs['stakeAuthorize']; + /** Lockup authority */ + lockupAuthority?: TransactionSigner; + arg0: AuthorizeInstructionDataArgs['arg0']; + arg1: AuthorizeInstructionDataArgs['arg1']; }; export function getAuthorizeInstruction< TAccountStake extends string, - TAccountClock extends string, + TAccountClockSysvar extends string, TAccountAuthority extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TAccountLockupAuthority extends string, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( - input: AuthorizeInput, + input: AuthorizeInput< + TAccountStake, + TAccountClockSysvar, + TAccountAuthority, + TAccountLockupAuthority + >, config?: { programAddress?: TProgramAddress } ): AuthorizeInstruction< TProgramAddress, TAccountStake, - TAccountClock, - TAccountAuthority + TAccountClockSysvar, + TAccountAuthority, + TAccountLockupAuthority > { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, - clock: { value: input.clock ?? null, isWritable: false }, + clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, authority: { value: input.authority ?? null, isWritable: false }, + lockupAuthority: { + value: input.lockupAuthority ?? null, + isWritable: false, + }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -160,12 +175,19 @@ export function getAuthorizeInstruction< // Original args. const args = { ...input }; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); const instruction = { accounts: [ getAccountMeta(accounts.stake), - getAccountMeta(accounts.clock), + getAccountMeta(accounts.clockSysvar), getAccountMeta(accounts.authority), + getAccountMeta(accounts.lockupAuthority), ], programAddress, data: getAuthorizeInstructionDataEncoder().encode( @@ -174,25 +196,28 @@ export function getAuthorizeInstruction< } as AuthorizeInstruction< TProgramAddress, TAccountStake, - TAccountClock, - TAccountAuthority + TAccountClockSysvar, + TAccountAuthority, + TAccountLockupAuthority >; return instruction; } export type ParsedAuthorizeInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The stake account to be updated */ + /** Stake account to be updated */ stake: TAccountMetas[0]; /** Clock sysvar */ - clock: TAccountMetas[1]; - /** stake's current stake or withdraw authority to change away from. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer */ + clockSysvar: TAccountMetas[1]; + /** Stake or withdraw authority */ authority: TAccountMetas[2]; + /** Lockup authority */ + lockupAuthority?: TAccountMetas[3] | undefined; }; data: AuthorizeInstructionData; }; @@ -205,7 +230,7 @@ export function parseAuthorizeInstruction< IInstructionWithAccounts & IInstructionWithData ): ParsedAuthorizeInstruction { - if (instruction.accounts.length < 3) { + if (instruction.accounts.length < 4) { // TODO: Coded error. throw new Error('Not enough accounts'); } @@ -215,12 +240,19 @@ export function parseAuthorizeInstruction< accountIndex += 1; return accountMeta; }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === STAKE_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; return { programAddress: instruction.programAddress, accounts: { stake: getNextAccount(), - clock: getNextAccount(), + clockSysvar: getNextAccount(), authority: getNextAccount(), + lockupAuthority: getNextOptionalAccount(), }, data: getAuthorizeInstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/js/src/generated/instructions/authorizeChecked.ts b/clients/js/src/generated/instructions/authorizeChecked.ts index b166026..d86aa58 100644 --- a/clients/js/src/generated/instructions/authorizeChecked.ts +++ b/clients/js/src/generated/instructions/authorizeChecked.ts @@ -8,12 +8,10 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, + getU8Decoder, + getU8Encoder, transformEncoder, type Address, type Codec, @@ -26,11 +24,10 @@ import { type IInstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, - type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { getStakeAuthorizeDecoder, @@ -39,22 +36,21 @@ import { type StakeAuthorizeArgs, } from '../types'; -export const AUTHORIZE_CHECKED_DISCRIMINATOR = new Uint8Array([ - 147, 97, 67, 26, 230, 107, 45, 242, -]); +export const AUTHORIZE_CHECKED_DISCRIMINATOR = 10; export function getAuthorizeCheckedDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - AUTHORIZE_CHECKED_DISCRIMINATOR - ); + return getU8Encoder().encode(AUTHORIZE_CHECKED_DISCRIMINATOR); } export type AuthorizeCheckedInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | IAccountMeta = string, - TAccountClock extends string | IAccountMeta = string, + TAccountClockSysvar extends + | string + | IAccountMeta = 'SysvarC1ock11111111111111111111111111111111', TAccountAuthority extends string | IAccountMeta = string, TAccountNewAuthority extends string | IAccountMeta = string, + TAccountLockupAuthority extends string | IAccountMeta = string, TRemainingAccounts extends readonly IAccountMeta[] = [], > = IInstruction & IInstructionWithData & @@ -63,9 +59,9 @@ export type AuthorizeCheckedInstruction< TAccountStake extends string ? WritableAccount : TAccountStake, - TAccountClock extends string - ? ReadonlyAccount - : TAccountClock, + TAccountClockSysvar extends string + ? ReadonlyAccount + : TAccountClockSysvar, TAccountAuthority extends string ? ReadonlySignerAccount & IAccountSignerMeta @@ -74,12 +70,16 @@ export type AuthorizeCheckedInstruction< ? ReadonlySignerAccount & IAccountSignerMeta : TAccountNewAuthority, + TAccountLockupAuthority extends string + ? ReadonlySignerAccount & + IAccountSignerMeta + : TAccountLockupAuthority, ...TRemainingAccounts, ] >; export type AuthorizeCheckedInstructionData = { - discriminator: ReadonlyUint8Array; + discriminator: number; stakeAuthorize: StakeAuthorize; }; @@ -90,7 +90,7 @@ export type AuthorizeCheckedInstructionDataArgs = { export function getAuthorizeCheckedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['discriminator', getU8Encoder()], ['stakeAuthorize', getStakeAuthorizeEncoder()], ]), (value) => ({ ...value, discriminator: AUTHORIZE_CHECKED_DISCRIMINATOR }) @@ -99,7 +99,7 @@ export function getAuthorizeCheckedInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['discriminator', getU8Decoder()], ['stakeAuthorize', getStakeAuthorizeDecoder()], ]); } @@ -116,52 +116,61 @@ export function getAuthorizeCheckedInstructionDataCodec(): Codec< export type AuthorizeCheckedInput< TAccountStake extends string = string, - TAccountClock extends string = string, + TAccountClockSysvar extends string = string, TAccountAuthority extends string = string, TAccountNewAuthority extends string = string, + TAccountLockupAuthority extends string = string, > = { - /** The stake account to be updated */ + /** Stake account to be updated */ stake: Address; /** Clock sysvar */ - clock: Address; - /** stake's current stake or withdraw authority to change away from */ + clockSysvar?: Address; + /** The stake or withdraw authority */ authority: TransactionSigner; - /** stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. */ + /** The new stake or withdraw authority */ newAuthority: TransactionSigner; + /** Lockup authority */ + lockupAuthority?: TransactionSigner; stakeAuthorize: AuthorizeCheckedInstructionDataArgs['stakeAuthorize']; }; export function getAuthorizeCheckedInstruction< TAccountStake extends string, - TAccountClock extends string, + TAccountClockSysvar extends string, TAccountAuthority extends string, TAccountNewAuthority extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TAccountLockupAuthority extends string, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: AuthorizeCheckedInput< TAccountStake, - TAccountClock, + TAccountClockSysvar, TAccountAuthority, - TAccountNewAuthority + TAccountNewAuthority, + TAccountLockupAuthority >, config?: { programAddress?: TProgramAddress } ): AuthorizeCheckedInstruction< TProgramAddress, TAccountStake, - TAccountClock, + TAccountClockSysvar, TAccountAuthority, - TAccountNewAuthority + TAccountNewAuthority, + TAccountLockupAuthority > { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, - clock: { value: input.clock ?? null, isWritable: false }, + clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, authority: { value: input.authority ?? null, isWritable: false }, newAuthority: { value: input.newAuthority ?? null, isWritable: false }, + lockupAuthority: { + value: input.lockupAuthority ?? null, + isWritable: false, + }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -171,13 +180,20 @@ export function getAuthorizeCheckedInstruction< // Original args. const args = { ...input }; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); const instruction = { accounts: [ getAccountMeta(accounts.stake), - getAccountMeta(accounts.clock), + getAccountMeta(accounts.clockSysvar), getAccountMeta(accounts.authority), getAccountMeta(accounts.newAuthority), + getAccountMeta(accounts.lockupAuthority), ], programAddress, data: getAuthorizeCheckedInstructionDataEncoder().encode( @@ -186,28 +202,31 @@ export function getAuthorizeCheckedInstruction< } as AuthorizeCheckedInstruction< TProgramAddress, TAccountStake, - TAccountClock, + TAccountClockSysvar, TAccountAuthority, - TAccountNewAuthority + TAccountNewAuthority, + TAccountLockupAuthority >; return instruction; } export type ParsedAuthorizeCheckedInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The stake account to be updated */ + /** Stake account to be updated */ stake: TAccountMetas[0]; /** Clock sysvar */ - clock: TAccountMetas[1]; - /** stake's current stake or withdraw authority to change away from */ + clockSysvar: TAccountMetas[1]; + /** The stake or withdraw authority */ authority: TAccountMetas[2]; - /** stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. */ + /** The new stake or withdraw authority */ newAuthority: TAccountMetas[3]; + /** Lockup authority */ + lockupAuthority?: TAccountMetas[4] | undefined; }; data: AuthorizeCheckedInstructionData; }; @@ -220,7 +239,7 @@ export function parseAuthorizeCheckedInstruction< IInstructionWithAccounts & IInstructionWithData ): ParsedAuthorizeCheckedInstruction { - if (instruction.accounts.length < 4) { + if (instruction.accounts.length < 5) { // TODO: Coded error. throw new Error('Not enough accounts'); } @@ -230,13 +249,20 @@ export function parseAuthorizeCheckedInstruction< accountIndex += 1; return accountMeta; }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === STAKE_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; return { programAddress: instruction.programAddress, accounts: { stake: getNextAccount(), - clock: getNextAccount(), + clockSysvar: getNextAccount(), authority: getNextAccount(), newAuthority: getNextAccount(), + lockupAuthority: getNextOptionalAccount(), }, data: getAuthorizeCheckedInstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts index 8365466..5e21a93 100644 --- a/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeCheckedWithSeed.ts @@ -10,16 +10,14 @@ import { addDecoderSizePrefix, addEncoderSizePrefix, combineCodec, - fixDecoderSize, - fixEncoderSize, getAddressDecoder, getAddressEncoder, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, + getU8Decoder, + getU8Encoder, getUtf8Decoder, getUtf8Encoder, transformEncoder, @@ -34,11 +32,10 @@ import { type IInstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, - type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { getStakeAuthorizeDecoder, @@ -47,22 +44,21 @@ import { type StakeAuthorizeArgs, } from '../types'; -export const AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR = new Uint8Array([ - 14, 230, 154, 165, 225, 209, 194, 210, -]); +export const AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR = 11; export function getAuthorizeCheckedWithSeedDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR - ); + return getU8Encoder().encode(AUTHORIZE_CHECKED_WITH_SEED_DISCRIMINATOR); } export type AuthorizeCheckedWithSeedInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | IAccountMeta = string, - TAccountAuthorityBase extends string | IAccountMeta = string, - TAccountClock extends string | IAccountMeta = string, + TAccountBase extends string | IAccountMeta = string, + TAccountClockSysvar extends + | string + | IAccountMeta = 'SysvarC1ock11111111111111111111111111111111', TAccountNewAuthority extends string | IAccountMeta = string, + TAccountLockupAuthority extends string | IAccountMeta = string, TRemainingAccounts extends readonly IAccountMeta[] = [], > = IInstruction & IInstructionWithData & @@ -71,23 +67,26 @@ export type AuthorizeCheckedWithSeedInstruction< TAccountStake extends string ? WritableAccount : TAccountStake, - TAccountAuthorityBase extends string - ? ReadonlySignerAccount & - IAccountSignerMeta - : TAccountAuthorityBase, - TAccountClock extends string - ? ReadonlyAccount - : TAccountClock, + TAccountBase extends string + ? ReadonlySignerAccount & IAccountSignerMeta + : TAccountBase, + TAccountClockSysvar extends string + ? ReadonlyAccount + : TAccountClockSysvar, TAccountNewAuthority extends string ? ReadonlySignerAccount & IAccountSignerMeta : TAccountNewAuthority, + TAccountLockupAuthority extends string + ? ReadonlySignerAccount & + IAccountSignerMeta + : TAccountLockupAuthority, ...TRemainingAccounts, ] >; export type AuthorizeCheckedWithSeedInstructionData = { - discriminator: ReadonlyUint8Array; + discriminator: number; stakeAuthorize: StakeAuthorize; authoritySeed: string; authorityOwner: Address; @@ -102,7 +101,7 @@ export type AuthorizeCheckedWithSeedInstructionDataArgs = { export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['discriminator', getU8Encoder()], ['stakeAuthorize', getStakeAuthorizeEncoder()], [ 'authoritySeed', @@ -119,7 +118,7 @@ export function getAuthorizeCheckedWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['discriminator', getU8Decoder()], ['stakeAuthorize', getStakeAuthorizeDecoder()], ['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], ['authorityOwner', getAddressDecoder()], @@ -138,18 +137,21 @@ export function getAuthorizeCheckedWithSeedInstructionDataCodec(): Codec< export type AuthorizeCheckedWithSeedInput< TAccountStake extends string = string, - TAccountAuthorityBase extends string = string, - TAccountClock extends string = string, + TAccountBase extends string = string, + TAccountClockSysvar extends string = string, TAccountNewAuthority extends string = string, + TAccountLockupAuthority extends string = string, > = { - /** The stake account to be updated */ + /** Stake account to be updated */ stake: Address; - /** Base account of stake's authority to be updated */ - authorityBase: TransactionSigner; + /** Base key of stake or withdraw authority */ + base: TransactionSigner; /** Clock sysvar */ - clock: Address; - /** stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. */ + clockSysvar?: Address; + /** The new stake or withdraw authority */ newAuthority: TransactionSigner; + /** Lockup authority */ + lockupAuthority?: TransactionSigner; stakeAuthorize: AuthorizeCheckedWithSeedInstructionDataArgs['stakeAuthorize']; authoritySeed: AuthorizeCheckedWithSeedInstructionDataArgs['authoritySeed']; authorityOwner: AuthorizeCheckedWithSeedInstructionDataArgs['authorityOwner']; @@ -157,35 +159,41 @@ export type AuthorizeCheckedWithSeedInput< export function getAuthorizeCheckedWithSeedInstruction< TAccountStake extends string, - TAccountAuthorityBase extends string, - TAccountClock extends string, + TAccountBase extends string, + TAccountClockSysvar extends string, TAccountNewAuthority extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TAccountLockupAuthority extends string, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: AuthorizeCheckedWithSeedInput< TAccountStake, - TAccountAuthorityBase, - TAccountClock, - TAccountNewAuthority + TAccountBase, + TAccountClockSysvar, + TAccountNewAuthority, + TAccountLockupAuthority >, config?: { programAddress?: TProgramAddress } ): AuthorizeCheckedWithSeedInstruction< TProgramAddress, TAccountStake, - TAccountAuthorityBase, - TAccountClock, - TAccountNewAuthority + TAccountBase, + TAccountClockSysvar, + TAccountNewAuthority, + TAccountLockupAuthority > { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, - authorityBase: { value: input.authorityBase ?? null, isWritable: false }, - clock: { value: input.clock ?? null, isWritable: false }, + base: { value: input.base ?? null, isWritable: false }, + clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, newAuthority: { value: input.newAuthority ?? null, isWritable: false }, + lockupAuthority: { + value: input.lockupAuthority ?? null, + isWritable: false, + }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -195,13 +203,20 @@ export function getAuthorizeCheckedWithSeedInstruction< // Original args. const args = { ...input }; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); const instruction = { accounts: [ getAccountMeta(accounts.stake), - getAccountMeta(accounts.authorityBase), - getAccountMeta(accounts.clock), + getAccountMeta(accounts.base), + getAccountMeta(accounts.clockSysvar), getAccountMeta(accounts.newAuthority), + getAccountMeta(accounts.lockupAuthority), ], programAddress, data: getAuthorizeCheckedWithSeedInstructionDataEncoder().encode( @@ -210,28 +225,31 @@ export function getAuthorizeCheckedWithSeedInstruction< } as AuthorizeCheckedWithSeedInstruction< TProgramAddress, TAccountStake, - TAccountAuthorityBase, - TAccountClock, - TAccountNewAuthority + TAccountBase, + TAccountClockSysvar, + TAccountNewAuthority, + TAccountLockupAuthority >; return instruction; } export type ParsedAuthorizeCheckedWithSeedInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The stake account to be updated */ + /** Stake account to be updated */ stake: TAccountMetas[0]; - /** Base account of stake's authority to be updated */ - authorityBase: TAccountMetas[1]; + /** Base key of stake or withdraw authority */ + base: TAccountMetas[1]; /** Clock sysvar */ - clock: TAccountMetas[2]; - /** stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. */ + clockSysvar: TAccountMetas[2]; + /** The new stake or withdraw authority */ newAuthority: TAccountMetas[3]; + /** Lockup authority */ + lockupAuthority?: TAccountMetas[4] | undefined; }; data: AuthorizeCheckedWithSeedInstructionData; }; @@ -244,7 +262,7 @@ export function parseAuthorizeCheckedWithSeedInstruction< IInstructionWithAccounts & IInstructionWithData ): ParsedAuthorizeCheckedWithSeedInstruction { - if (instruction.accounts.length < 4) { + if (instruction.accounts.length < 5) { // TODO: Coded error. throw new Error('Not enough accounts'); } @@ -254,13 +272,20 @@ export function parseAuthorizeCheckedWithSeedInstruction< accountIndex += 1; return accountMeta; }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === STAKE_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; return { programAddress: instruction.programAddress, accounts: { stake: getNextAccount(), - authorityBase: getNextAccount(), - clock: getNextAccount(), + base: getNextAccount(), + clockSysvar: getNextAccount(), newAuthority: getNextAccount(), + lockupAuthority: getNextOptionalAccount(), }, data: getAuthorizeCheckedWithSeedInstructionDataDecoder().decode( instruction.data diff --git a/clients/js/src/generated/instructions/authorizeWithSeed.ts b/clients/js/src/generated/instructions/authorizeWithSeed.ts index 07c717b..d6ce71c 100644 --- a/clients/js/src/generated/instructions/authorizeWithSeed.ts +++ b/clients/js/src/generated/instructions/authorizeWithSeed.ts @@ -10,16 +10,14 @@ import { addDecoderSizePrefix, addEncoderSizePrefix, combineCodec, - fixDecoderSize, - fixEncoderSize, getAddressDecoder, getAddressEncoder, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, + getU8Decoder, + getU8Encoder, getUtf8Decoder, getUtf8Encoder, transformEncoder, @@ -34,11 +32,10 @@ import { type IInstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, - type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; import { getStakeAuthorizeDecoder, @@ -47,21 +44,20 @@ import { type StakeAuthorizeArgs, } from '../types'; -export const AUTHORIZE_WITH_SEED_DISCRIMINATOR = new Uint8Array([ - 7, 18, 211, 41, 76, 83, 115, 61, -]); +export const AUTHORIZE_WITH_SEED_DISCRIMINATOR = 8; export function getAuthorizeWithSeedDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - AUTHORIZE_WITH_SEED_DISCRIMINATOR - ); + return getU8Encoder().encode(AUTHORIZE_WITH_SEED_DISCRIMINATOR); } export type AuthorizeWithSeedInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | IAccountMeta = string, - TAccountAuthorityBase extends string | IAccountMeta = string, - TAccountClock extends string | IAccountMeta = string, + TAccountBase extends string | IAccountMeta = string, + TAccountClockSysvar extends + | string + | IAccountMeta = 'SysvarC1ock11111111111111111111111111111111', + TAccountLockupAuthority extends string | IAccountMeta = string, TRemainingAccounts extends readonly IAccountMeta[] = [], > = IInstruction & IInstructionWithData & @@ -70,27 +66,30 @@ export type AuthorizeWithSeedInstruction< TAccountStake extends string ? WritableAccount : TAccountStake, - TAccountAuthorityBase extends string - ? ReadonlySignerAccount & - IAccountSignerMeta - : TAccountAuthorityBase, - TAccountClock extends string - ? ReadonlyAccount - : TAccountClock, + TAccountBase extends string + ? ReadonlySignerAccount & IAccountSignerMeta + : TAccountBase, + TAccountClockSysvar extends string + ? ReadonlyAccount + : TAccountClockSysvar, + TAccountLockupAuthority extends string + ? ReadonlySignerAccount & + IAccountSignerMeta + : TAccountLockupAuthority, ...TRemainingAccounts, ] >; export type AuthorizeWithSeedInstructionData = { - discriminator: ReadonlyUint8Array; - newAuthority: Address; + discriminator: number; + newAuthorizedPubkey: Address; stakeAuthorize: StakeAuthorize; authoritySeed: string; authorityOwner: Address; }; export type AuthorizeWithSeedInstructionDataArgs = { - newAuthority: Address; + newAuthorizedPubkey: Address; stakeAuthorize: StakeAuthorizeArgs; authoritySeed: string; authorityOwner: Address; @@ -99,8 +98,8 @@ export type AuthorizeWithSeedInstructionDataArgs = { export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newAuthority', getAddressEncoder()], + ['discriminator', getU8Encoder()], + ['newAuthorizedPubkey', getAddressEncoder()], ['stakeAuthorize', getStakeAuthorizeEncoder()], [ 'authoritySeed', @@ -114,8 +113,8 @@ export function getAuthorizeWithSeedInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newAuthority', getAddressDecoder()], + ['discriminator', getU8Decoder()], + ['newAuthorizedPubkey', getAddressDecoder()], ['stakeAuthorize', getStakeAuthorizeDecoder()], ['authoritySeed', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())], ['authorityOwner', getAddressDecoder()], @@ -134,16 +133,19 @@ export function getAuthorizeWithSeedInstructionDataCodec(): Codec< export type AuthorizeWithSeedInput< TAccountStake extends string = string, - TAccountAuthorityBase extends string = string, - TAccountClock extends string = string, + TAccountBase extends string = string, + TAccountClockSysvar extends string = string, + TAccountLockupAuthority extends string = string, > = { - /** The stake account to be updated, with the authority to be updated being an account created with Pubkey::create_with_seed() */ + /** Stake account to be updated */ stake: Address; - /** Base account of stake's authority to be updated */ - authorityBase: TransactionSigner; - /** Clock sysvar. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. */ - clock: Address; - newAuthority: AuthorizeWithSeedInstructionDataArgs['newAuthority']; + /** Base key of stake or withdraw authority */ + base: TransactionSigner; + /** Clock sysvar */ + clockSysvar?: Address; + /** Lockup authority */ + lockupAuthority?: TransactionSigner; + newAuthorizedPubkey: AuthorizeWithSeedInstructionDataArgs['newAuthorizedPubkey']; stakeAuthorize: AuthorizeWithSeedInstructionDataArgs['stakeAuthorize']; authoritySeed: AuthorizeWithSeedInstructionDataArgs['authoritySeed']; authorityOwner: AuthorizeWithSeedInstructionDataArgs['authorityOwner']; @@ -151,31 +153,37 @@ export type AuthorizeWithSeedInput< export function getAuthorizeWithSeedInstruction< TAccountStake extends string, - TAccountAuthorityBase extends string, - TAccountClock extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TAccountBase extends string, + TAccountClockSysvar extends string, + TAccountLockupAuthority extends string, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: AuthorizeWithSeedInput< TAccountStake, - TAccountAuthorityBase, - TAccountClock + TAccountBase, + TAccountClockSysvar, + TAccountLockupAuthority >, config?: { programAddress?: TProgramAddress } ): AuthorizeWithSeedInstruction< TProgramAddress, TAccountStake, - TAccountAuthorityBase, - TAccountClock + TAccountBase, + TAccountClockSysvar, + TAccountLockupAuthority > { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, - authorityBase: { value: input.authorityBase ?? null, isWritable: false }, - clock: { value: input.clock ?? null, isWritable: false }, + base: { value: input.base ?? null, isWritable: false }, + clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, + lockupAuthority: { + value: input.lockupAuthority ?? null, + isWritable: false, + }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -185,12 +193,19 @@ export function getAuthorizeWithSeedInstruction< // Original args. const args = { ...input }; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); const instruction = { accounts: [ getAccountMeta(accounts.stake), - getAccountMeta(accounts.authorityBase), - getAccountMeta(accounts.clock), + getAccountMeta(accounts.base), + getAccountMeta(accounts.clockSysvar), + getAccountMeta(accounts.lockupAuthority), ], programAddress, data: getAuthorizeWithSeedInstructionDataEncoder().encode( @@ -199,25 +214,28 @@ export function getAuthorizeWithSeedInstruction< } as AuthorizeWithSeedInstruction< TProgramAddress, TAccountStake, - TAccountAuthorityBase, - TAccountClock + TAccountBase, + TAccountClockSysvar, + TAccountLockupAuthority >; return instruction; } export type ParsedAuthorizeWithSeedInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The stake account to be updated, with the authority to be updated being an account created with Pubkey::create_with_seed() */ + /** Stake account to be updated */ stake: TAccountMetas[0]; - /** Base account of stake's authority to be updated */ - authorityBase: TAccountMetas[1]; - /** Clock sysvar. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. */ - clock: TAccountMetas[2]; + /** Base key of stake or withdraw authority */ + base: TAccountMetas[1]; + /** Clock sysvar */ + clockSysvar: TAccountMetas[2]; + /** Lockup authority */ + lockupAuthority?: TAccountMetas[3] | undefined; }; data: AuthorizeWithSeedInstructionData; }; @@ -230,7 +248,7 @@ export function parseAuthorizeWithSeedInstruction< IInstructionWithAccounts & IInstructionWithData ): ParsedAuthorizeWithSeedInstruction { - if (instruction.accounts.length < 3) { + if (instruction.accounts.length < 4) { // TODO: Coded error. throw new Error('Not enough accounts'); } @@ -240,12 +258,19 @@ export function parseAuthorizeWithSeedInstruction< accountIndex += 1; return accountMeta; }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === STAKE_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; return { programAddress: instruction.programAddress, accounts: { stake: getNextAccount(), - authorityBase: getNextAccount(), - clock: getNextAccount(), + base: getNextAccount(), + clockSysvar: getNextAccount(), + lockupAuthority: getNextOptionalAccount(), }, data: getAuthorizeWithSeedInstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/js/src/generated/instructions/deactivate.ts b/clients/js/src/generated/instructions/deactivate.ts index 6422b36..61dd116 100644 --- a/clients/js/src/generated/instructions/deactivate.ts +++ b/clients/js/src/generated/instructions/deactivate.ts @@ -8,12 +8,10 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, + getU8Decoder, + getU8Encoder, transformEncoder, type Address, type Codec, @@ -26,25 +24,24 @@ import { type IInstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, - type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -export const DEACTIVATE_DISCRIMINATOR = new Uint8Array([ - 44, 112, 33, 172, 113, 28, 142, 13, -]); +export const DEACTIVATE_DISCRIMINATOR = 5; export function getDeactivateDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(DEACTIVATE_DISCRIMINATOR); + return getU8Encoder().encode(DEACTIVATE_DISCRIMINATOR); } export type DeactivateInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | IAccountMeta = string, - TAccountClock extends string | IAccountMeta = string, + TAccountClockSysvar extends + | string + | IAccountMeta = 'SysvarC1ock11111111111111111111111111111111', TAccountStakeAuthority extends string | IAccountMeta = string, TRemainingAccounts extends readonly IAccountMeta[] = [], > = IInstruction & @@ -54,9 +51,9 @@ export type DeactivateInstruction< TAccountStake extends string ? WritableAccount : TAccountStake, - TAccountClock extends string - ? ReadonlyAccount - : TAccountClock, + TAccountClockSysvar extends string + ? ReadonlyAccount + : TAccountClockSysvar, TAccountStakeAuthority extends string ? ReadonlySignerAccount & IAccountSignerMeta @@ -65,21 +62,19 @@ export type DeactivateInstruction< ] >; -export type DeactivateInstructionData = { discriminator: ReadonlyUint8Array }; +export type DeactivateInstructionData = { discriminator: number }; export type DeactivateInstructionDataArgs = {}; export function getDeactivateInstructionDataEncoder(): Encoder { return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: DEACTIVATE_DISCRIMINATOR }) ); } export function getDeactivateInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); + return getStructDecoder([['discriminator', getU8Decoder()]]); } export function getDeactivateInstructionDataCodec(): Codec< @@ -94,39 +89,42 @@ export function getDeactivateInstructionDataCodec(): Codec< export type DeactivateInput< TAccountStake extends string = string, - TAccountClock extends string = string, + TAccountClockSysvar extends string = string, TAccountStakeAuthority extends string = string, > = { - /** The stake account to deactivate */ + /** Delegated stake account */ stake: Address; /** Clock sysvar */ - clock: Address; - /** stake's stake authority */ + clockSysvar?: Address; + /** Stake authority */ stakeAuthority: TransactionSigner; }; export function getDeactivateInstruction< TAccountStake extends string, - TAccountClock extends string, + TAccountClockSysvar extends string, TAccountStakeAuthority extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( - input: DeactivateInput, + input: DeactivateInput< + TAccountStake, + TAccountClockSysvar, + TAccountStakeAuthority + >, config?: { programAddress?: TProgramAddress } ): DeactivateInstruction< TProgramAddress, TAccountStake, - TAccountClock, + TAccountClockSysvar, TAccountStakeAuthority > { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, - clock: { value: input.clock ?? null, isWritable: false }, + clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< @@ -134,11 +132,17 @@ export function getDeactivateInstruction< ResolvedAccount >; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); const instruction = { accounts: [ getAccountMeta(accounts.stake), - getAccountMeta(accounts.clock), + getAccountMeta(accounts.clockSysvar), getAccountMeta(accounts.stakeAuthority), ], programAddress, @@ -146,7 +150,7 @@ export function getDeactivateInstruction< } as DeactivateInstruction< TProgramAddress, TAccountStake, - TAccountClock, + TAccountClockSysvar, TAccountStakeAuthority >; @@ -154,16 +158,16 @@ export function getDeactivateInstruction< } export type ParsedDeactivateInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The stake account to deactivate */ + /** Delegated stake account */ stake: TAccountMetas[0]; /** Clock sysvar */ - clock: TAccountMetas[1]; - /** stake's stake authority */ + clockSysvar: TAccountMetas[1]; + /** Stake authority */ stakeAuthority: TAccountMetas[2]; }; data: DeactivateInstructionData; @@ -191,7 +195,7 @@ export function parseDeactivateInstruction< programAddress: instruction.programAddress, accounts: { stake: getNextAccount(), - clock: getNextAccount(), + clockSysvar: getNextAccount(), stakeAuthority: getNextAccount(), }, data: getDeactivateInstructionDataDecoder().decode(instruction.data), diff --git a/clients/js/src/generated/instructions/deactivateDelinquent.ts b/clients/js/src/generated/instructions/deactivateDelinquent.ts index 7c7bc3a..84e7750 100644 --- a/clients/js/src/generated/instructions/deactivateDelinquent.ts +++ b/clients/js/src/generated/instructions/deactivateDelinquent.ts @@ -8,12 +8,10 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, + getU8Decoder, + getU8Encoder, transformEncoder, type Address, type Codec, @@ -24,26 +22,21 @@ import { type IInstructionWithAccounts, type IInstructionWithData, type ReadonlyAccount, - type ReadonlyUint8Array, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -export const DEACTIVATE_DELINQUENT_DISCRIMINATOR = new Uint8Array([ - 6, 113, 198, 138, 228, 163, 159, 221, -]); +export const DEACTIVATE_DELINQUENT_DISCRIMINATOR = 14; export function getDeactivateDelinquentDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - DEACTIVATE_DELINQUENT_DISCRIMINATOR - ); + return getU8Encoder().encode(DEACTIVATE_DELINQUENT_DISCRIMINATOR); } export type DeactivateDelinquentInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | IAccountMeta = string, - TAccountVote extends string | IAccountMeta = string, + TAccountDelinquentVote extends string | IAccountMeta = string, TAccountReferenceVote extends string | IAccountMeta = string, TRemainingAccounts extends readonly IAccountMeta[] = [], > = IInstruction & @@ -53,9 +46,9 @@ export type DeactivateDelinquentInstruction< TAccountStake extends string ? WritableAccount : TAccountStake, - TAccountVote extends string - ? ReadonlyAccount - : TAccountVote, + TAccountDelinquentVote extends string + ? ReadonlyAccount + : TAccountDelinquentVote, TAccountReferenceVote extends string ? ReadonlyAccount : TAccountReferenceVote, @@ -63,15 +56,13 @@ export type DeactivateDelinquentInstruction< ] >; -export type DeactivateDelinquentInstructionData = { - discriminator: ReadonlyUint8Array; -}; +export type DeactivateDelinquentInstructionData = { discriminator: number }; export type DeactivateDelinquentInstructionDataArgs = {}; export function getDeactivateDelinquentInstructionDataEncoder(): Encoder { return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: DEACTIVATE_DELINQUENT_DISCRIMINATOR, @@ -80,9 +71,7 @@ export function getDeactivateDelinquentInstructionDataEncoder(): Encoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); + return getStructDecoder([['discriminator', getU8Decoder()]]); } export function getDeactivateDelinquentInstructionDataCodec(): Codec< @@ -97,43 +86,42 @@ export function getDeactivateDelinquentInstructionDataCodec(): Codec< export type DeactivateDelinquentInput< TAccountStake extends string = string, - TAccountVote extends string = string, + TAccountDelinquentVote extends string = string, TAccountReferenceVote extends string = string, > = { - /** The delinquent stake account to deactivate */ + /** Delegated stake account */ stake: Address; - /** stake's delinquent vote account */ - vote: Address; - /** Reference vote account that has voted at least once in the last MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION epochs */ + /** Delinquent vote account */ + delinquentVote: Address; + /** Reference vote account */ referenceVote: Address; }; export function getDeactivateDelinquentInstruction< TAccountStake extends string, - TAccountVote extends string, + TAccountDelinquentVote extends string, TAccountReferenceVote extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: DeactivateDelinquentInput< TAccountStake, - TAccountVote, + TAccountDelinquentVote, TAccountReferenceVote >, config?: { programAddress?: TProgramAddress } ): DeactivateDelinquentInstruction< TProgramAddress, TAccountStake, - TAccountVote, + TAccountDelinquentVote, TAccountReferenceVote > { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, - vote: { value: input.vote ?? null, isWritable: false }, + delinquentVote: { value: input.delinquentVote ?? null, isWritable: false }, referenceVote: { value: input.referenceVote ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< @@ -145,7 +133,7 @@ export function getDeactivateDelinquentInstruction< const instruction = { accounts: [ getAccountMeta(accounts.stake), - getAccountMeta(accounts.vote), + getAccountMeta(accounts.delinquentVote), getAccountMeta(accounts.referenceVote), ], programAddress, @@ -153,7 +141,7 @@ export function getDeactivateDelinquentInstruction< } as DeactivateDelinquentInstruction< TProgramAddress, TAccountStake, - TAccountVote, + TAccountDelinquentVote, TAccountReferenceVote >; @@ -161,16 +149,16 @@ export function getDeactivateDelinquentInstruction< } export type ParsedDeactivateDelinquentInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The delinquent stake account to deactivate */ + /** Delegated stake account */ stake: TAccountMetas[0]; - /** stake's delinquent vote account */ - vote: TAccountMetas[1]; - /** Reference vote account that has voted at least once in the last MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION epochs */ + /** Delinquent vote account */ + delinquentVote: TAccountMetas[1]; + /** Reference vote account */ referenceVote: TAccountMetas[2]; }; data: DeactivateDelinquentInstructionData; @@ -198,7 +186,7 @@ export function parseDeactivateDelinquentInstruction< programAddress: instruction.programAddress, accounts: { stake: getNextAccount(), - vote: getNextAccount(), + delinquentVote: getNextAccount(), referenceVote: getNextAccount(), }, data: getDeactivateDelinquentInstructionDataDecoder().decode( diff --git a/clients/js/src/generated/instructions/delegateStake.ts b/clients/js/src/generated/instructions/delegateStake.ts index 9f912b3..0ae521f 100644 --- a/clients/js/src/generated/instructions/delegateStake.ts +++ b/clients/js/src/generated/instructions/delegateStake.ts @@ -8,12 +8,10 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, + getU8Decoder, + getU8Encoder, transformEncoder, type Address, type Codec, @@ -26,30 +24,27 @@ import { type IInstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, - type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -export const DELEGATE_STAKE_DISCRIMINATOR = new Uint8Array([ - 50, 110, 95, 179, 194, 75, 140, 246, -]); +export const DELEGATE_STAKE_DISCRIMINATOR = 2; export function getDelegateStakeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - DELEGATE_STAKE_DISCRIMINATOR - ); + return getU8Encoder().encode(DELEGATE_STAKE_DISCRIMINATOR); } export type DelegateStakeInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | IAccountMeta = string, TAccountVote extends string | IAccountMeta = string, - TAccountClock extends string | IAccountMeta = string, + TAccountClockSysvar extends + | string + | IAccountMeta = 'SysvarC1ock11111111111111111111111111111111', TAccountStakeHistory extends string | IAccountMeta = string, - TAccountStakeConfig extends string | IAccountMeta = string, + TAccountUnused extends string | IAccountMeta = string, TAccountStakeAuthority extends string | IAccountMeta = string, TRemainingAccounts extends readonly IAccountMeta[] = [], > = IInstruction & @@ -62,15 +57,15 @@ export type DelegateStakeInstruction< TAccountVote extends string ? ReadonlyAccount : TAccountVote, - TAccountClock extends string - ? ReadonlyAccount - : TAccountClock, + TAccountClockSysvar extends string + ? ReadonlyAccount + : TAccountClockSysvar, TAccountStakeHistory extends string ? ReadonlyAccount : TAccountStakeHistory, - TAccountStakeConfig extends string - ? ReadonlyAccount - : TAccountStakeConfig, + TAccountUnused extends string + ? ReadonlyAccount + : TAccountUnused, TAccountStakeAuthority extends string ? ReadonlySignerAccount & IAccountSignerMeta @@ -79,23 +74,19 @@ export type DelegateStakeInstruction< ] >; -export type DelegateStakeInstructionData = { - discriminator: ReadonlyUint8Array; -}; +export type DelegateStakeInstructionData = { discriminator: number }; export type DelegateStakeInstructionDataArgs = {}; export function getDelegateStakeInstructionDataEncoder(): Encoder { return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: DELEGATE_STAKE_DISCRIMINATOR }) ); } export function getDelegateStakeInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); + return getStructDecoder([['discriminator', getU8Decoder()]]); } export function getDelegateStakeInstructionDataCodec(): Codec< @@ -111,40 +102,40 @@ export function getDelegateStakeInstructionDataCodec(): Codec< export type DelegateStakeInput< TAccountStake extends string = string, TAccountVote extends string = string, - TAccountClock extends string = string, + TAccountClockSysvar extends string = string, TAccountStakeHistory extends string = string, - TAccountStakeConfig extends string = string, + TAccountUnused extends string = string, TAccountStakeAuthority extends string = string, > = { - /** The stake account to be delegated */ + /** Initialized stake account to be delegated */ stake: Address; - /** Vote account to which stake will be delegated */ + /** Vote account to which this stake will be delegated */ vote: Address; /** Clock sysvar */ - clock: Address; + clockSysvar?: Address; /** Stake history sysvar */ stakeHistory: Address; - /** Stake config native program */ - stakeConfig: Address; - /** stake's stake authority */ + /** Unused account, formerly the stake config */ + unused: Address; + /** Stake authority */ stakeAuthority: TransactionSigner; }; export function getDelegateStakeInstruction< TAccountStake extends string, TAccountVote extends string, - TAccountClock extends string, + TAccountClockSysvar extends string, TAccountStakeHistory extends string, - TAccountStakeConfig extends string, + TAccountUnused extends string, TAccountStakeAuthority extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: DelegateStakeInput< TAccountStake, TAccountVote, - TAccountClock, + TAccountClockSysvar, TAccountStakeHistory, - TAccountStakeConfig, + TAccountUnused, TAccountStakeAuthority >, config?: { programAddress?: TProgramAddress } @@ -152,22 +143,21 @@ export function getDelegateStakeInstruction< TProgramAddress, TAccountStake, TAccountVote, - TAccountClock, + TAccountClockSysvar, TAccountStakeHistory, - TAccountStakeConfig, + TAccountUnused, TAccountStakeAuthority > { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, vote: { value: input.vote ?? null, isWritable: false }, - clock: { value: input.clock ?? null, isWritable: false }, + clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, stakeHistory: { value: input.stakeHistory ?? null, isWritable: false }, - stakeConfig: { value: input.stakeConfig ?? null, isWritable: false }, + unused: { value: input.unused ?? null, isWritable: false }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< @@ -175,14 +165,20 @@ export function getDelegateStakeInstruction< ResolvedAccount >; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); const instruction = { accounts: [ getAccountMeta(accounts.stake), getAccountMeta(accounts.vote), - getAccountMeta(accounts.clock), + getAccountMeta(accounts.clockSysvar), getAccountMeta(accounts.stakeHistory), - getAccountMeta(accounts.stakeConfig), + getAccountMeta(accounts.unused), getAccountMeta(accounts.stakeAuthority), ], programAddress, @@ -191,9 +187,9 @@ export function getDelegateStakeInstruction< TProgramAddress, TAccountStake, TAccountVote, - TAccountClock, + TAccountClockSysvar, TAccountStakeHistory, - TAccountStakeConfig, + TAccountUnused, TAccountStakeAuthority >; @@ -201,22 +197,22 @@ export function getDelegateStakeInstruction< } export type ParsedDelegateStakeInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The stake account to be delegated */ + /** Initialized stake account to be delegated */ stake: TAccountMetas[0]; - /** Vote account to which stake will be delegated */ + /** Vote account to which this stake will be delegated */ vote: TAccountMetas[1]; /** Clock sysvar */ - clock: TAccountMetas[2]; + clockSysvar: TAccountMetas[2]; /** Stake history sysvar */ stakeHistory: TAccountMetas[3]; - /** Stake config native program */ - stakeConfig: TAccountMetas[4]; - /** stake's stake authority */ + /** Unused account, formerly the stake config */ + unused: TAccountMetas[4]; + /** Stake authority */ stakeAuthority: TAccountMetas[5]; }; data: DelegateStakeInstructionData; @@ -245,9 +241,9 @@ export function parseDelegateStakeInstruction< accounts: { stake: getNextAccount(), vote: getNextAccount(), - clock: getNextAccount(), + clockSysvar: getNextAccount(), stakeHistory: getNextAccount(), - stakeConfig: getNextAccount(), + unused: getNextAccount(), stakeAuthority: getNextAccount(), }, data: getDelegateStakeInstructionDataDecoder().decode(instruction.data), diff --git a/clients/js/src/generated/instructions/getMinimumDelegation.ts b/clients/js/src/generated/instructions/getMinimumDelegation.ts index fdfb3e2..b4c44a7 100644 --- a/clients/js/src/generated/instructions/getMinimumDelegation.ts +++ b/clients/js/src/generated/instructions/getMinimumDelegation.ts @@ -8,12 +8,10 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, + getU8Decoder, + getU8Encoder, transformEncoder, type Address, type Codec, @@ -23,36 +21,29 @@ import { type IInstruction, type IInstructionWithAccounts, type IInstructionWithData, - type ReadonlyUint8Array, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; -export const GET_MINIMUM_DELEGATION_DISCRIMINATOR = new Uint8Array([ - 197, 65, 7, 73, 151, 105, 133, 105, -]); +export const GET_MINIMUM_DELEGATION_DISCRIMINATOR = 13; export function getGetMinimumDelegationDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - GET_MINIMUM_DELEGATION_DISCRIMINATOR - ); + return getU8Encoder().encode(GET_MINIMUM_DELEGATION_DISCRIMINATOR); } export type GetMinimumDelegationInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TRemainingAccounts extends readonly IAccountMeta[] = [], > = IInstruction & IInstructionWithData & IInstructionWithAccounts; -export type GetMinimumDelegationInstructionData = { - discriminator: ReadonlyUint8Array; -}; +export type GetMinimumDelegationInstructionData = { discriminator: number }; export type GetMinimumDelegationInstructionDataArgs = {}; export function getGetMinimumDelegationInstructionDataEncoder(): Encoder { return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: GET_MINIMUM_DELEGATION_DISCRIMINATOR, @@ -61,9 +52,7 @@ export function getGetMinimumDelegationInstructionDataEncoder(): Encoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); + return getStructDecoder([['discriminator', getU8Decoder()]]); } export function getGetMinimumDelegationInstructionDataCodec(): Codec< @@ -79,13 +68,12 @@ export function getGetMinimumDelegationInstructionDataCodec(): Codec< export type GetMinimumDelegationInput = {}; export function getGetMinimumDelegationInstruction< - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >(config?: { programAddress?: TProgramAddress; }): GetMinimumDelegationInstruction { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; const instruction = { programAddress, @@ -96,7 +84,7 @@ export function getGetMinimumDelegationInstruction< } export type ParsedGetMinimumDelegationInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, > = { programAddress: Address; data: GetMinimumDelegationInstructionData; diff --git a/clients/js/src/generated/instructions/index.ts b/clients/js/src/generated/instructions/index.ts index dd8e662..237b624 100644 --- a/clients/js/src/generated/instructions/index.ts +++ b/clients/js/src/generated/instructions/index.ts @@ -17,6 +17,8 @@ export * from './getMinimumDelegation'; export * from './initialize'; export * from './initializeChecked'; export * from './merge'; +export * from './moveLamports'; +export * from './moveStake'; export * from './setLockup'; export * from './setLockupChecked'; export * from './split'; diff --git a/clients/js/src/generated/instructions/initialize.ts b/clients/js/src/generated/instructions/initialize.ts index 31337f3..48229a1 100644 --- a/clients/js/src/generated/instructions/initialize.ts +++ b/clients/js/src/generated/instructions/initialize.ts @@ -8,18 +8,10 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getI64Decoder, - getI64Encoder, getStructDecoder, getStructEncoder, - getU64Decoder, - getU64Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type Address, type Codec, @@ -30,24 +22,31 @@ import { type IInstructionWithAccounts, type IInstructionWithData, type ReadonlyAccount, - type ReadonlyUint8Array, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const INITIALIZE_DISCRIMINATOR = new Uint8Array([ - 175, 175, 109, 31, 13, 152, 155, 237, -]); +import { + getAuthorizedDecoder, + getAuthorizedEncoder, + getLockupDecoder, + getLockupEncoder, + type Authorized, + type AuthorizedArgs, + type Lockup, + type LockupArgs, +} from '../types'; + +export const INITIALIZE_DISCRIMINATOR = 0; export function getInitializeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_DISCRIMINATOR); + return getU8Encoder().encode(INITIALIZE_DISCRIMINATOR); } export type InitializeInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | IAccountMeta = string, - TAccountRent extends + TAccountRentSysvar extends | string | IAccountMeta = 'SysvarRent111111111111111111111111111111111', TRemainingAccounts extends readonly IAccountMeta[] = [], @@ -58,39 +57,30 @@ export type InitializeInstruction< TAccountStake extends string ? WritableAccount : TAccountStake, - TAccountRent extends string - ? ReadonlyAccount - : TAccountRent, + TAccountRentSysvar extends string + ? ReadonlyAccount + : TAccountRentSysvar, ...TRemainingAccounts, ] >; export type InitializeInstructionData = { - discriminator: ReadonlyUint8Array; - staker: Address; - withdrawer: Address; - unixTimestamp: bigint; - epoch: bigint; - custodian: Address; + discriminator: number; + arg0: Authorized; + arg1: Lockup; }; export type InitializeInstructionDataArgs = { - staker: Address; - withdrawer: Address; - unixTimestamp: number | bigint; - epoch: number | bigint; - custodian: Address; + arg0: AuthorizedArgs; + arg1: LockupArgs; }; export function getInitializeInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['staker', getAddressEncoder()], - ['withdrawer', getAddressEncoder()], - ['unixTimestamp', getI64Encoder()], - ['epoch', getU64Encoder()], - ['custodian', getAddressEncoder()], + ['discriminator', getU8Encoder()], + ['arg0', getAuthorizedEncoder()], + ['arg1', getLockupEncoder()], ]), (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) ); @@ -98,12 +88,9 @@ export function getInitializeInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['staker', getAddressDecoder()], - ['withdrawer', getAddressDecoder()], - ['unixTimestamp', getI64Decoder()], - ['epoch', getU64Decoder()], - ['custodian', getAddressDecoder()], + ['discriminator', getU8Decoder()], + ['arg0', getAuthorizedDecoder()], + ['arg1', getLockupDecoder()], ]); } @@ -119,35 +106,31 @@ export function getInitializeInstructionDataCodec(): Codec< export type InitializeInput< TAccountStake extends string = string, - TAccountRent extends string = string, + TAccountRentSysvar extends string = string, > = { - /** The stake account to initialize */ + /** Uninitialized stake account */ stake: Address; /** Rent sysvar */ - rent?: Address; - staker: InitializeInstructionDataArgs['staker']; - withdrawer: InitializeInstructionDataArgs['withdrawer']; - unixTimestamp: InitializeInstructionDataArgs['unixTimestamp']; - epoch: InitializeInstructionDataArgs['epoch']; - custodian: InitializeInstructionDataArgs['custodian']; + rentSysvar?: Address; + arg0: InitializeInstructionDataArgs['arg0']; + arg1: InitializeInstructionDataArgs['arg1']; }; export function getInitializeInstruction< TAccountStake extends string, - TAccountRent extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TAccountRentSysvar extends string, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( - input: InitializeInput, + input: InitializeInput, config?: { programAddress?: TProgramAddress } -): InitializeInstruction { +): InitializeInstruction { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, - rent: { value: input.rent ?? null, isWritable: false }, + rentSysvar: { value: input.rentSysvar ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -158,33 +141,40 @@ export function getInitializeInstruction< const args = { ...input }; // Resolve default values. - if (!accounts.rent.value) { - accounts.rent.value = + if (!accounts.rentSysvar.value) { + accounts.rentSysvar.value = 'SysvarRent111111111111111111111111111111111' as Address<'SysvarRent111111111111111111111111111111111'>; } const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); const instruction = { - accounts: [getAccountMeta(accounts.stake), getAccountMeta(accounts.rent)], + accounts: [ + getAccountMeta(accounts.stake), + getAccountMeta(accounts.rentSysvar), + ], programAddress, data: getInitializeInstructionDataEncoder().encode( args as InitializeInstructionDataArgs ), - } as InitializeInstruction; + } as InitializeInstruction< + TProgramAddress, + TAccountStake, + TAccountRentSysvar + >; return instruction; } export type ParsedInitializeInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The stake account to initialize */ + /** Uninitialized stake account */ stake: TAccountMetas[0]; /** Rent sysvar */ - rent: TAccountMetas[1]; + rentSysvar: TAccountMetas[1]; }; data: InitializeInstructionData; }; @@ -211,7 +201,7 @@ export function parseInitializeInstruction< programAddress: instruction.programAddress, accounts: { stake: getNextAccount(), - rent: getNextAccount(), + rentSysvar: getNextAccount(), }, data: getInitializeInstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/js/src/generated/instructions/initializeChecked.ts b/clients/js/src/generated/instructions/initializeChecked.ts index ae1634f..c0fe721 100644 --- a/clients/js/src/generated/instructions/initializeChecked.ts +++ b/clients/js/src/generated/instructions/initializeChecked.ts @@ -8,12 +8,10 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, + getU8Decoder, + getU8Encoder, transformEncoder, type Address, type Codec, @@ -26,27 +24,22 @@ import { type IInstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, - type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -export const INITIALIZE_CHECKED_DISCRIMINATOR = new Uint8Array([ - 219, 90, 58, 161, 139, 88, 246, 28, -]); +export const INITIALIZE_CHECKED_DISCRIMINATOR = 9; export function getInitializeCheckedDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - INITIALIZE_CHECKED_DISCRIMINATOR - ); + return getU8Encoder().encode(INITIALIZE_CHECKED_DISCRIMINATOR); } export type InitializeCheckedInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | IAccountMeta = string, - TAccountRent extends + TAccountRentSysvar extends | string | IAccountMeta = 'SysvarRent111111111111111111111111111111111', TAccountStakeAuthority extends string | IAccountMeta = string, @@ -59,9 +52,9 @@ export type InitializeCheckedInstruction< TAccountStake extends string ? WritableAccount : TAccountStake, - TAccountRent extends string - ? ReadonlyAccount - : TAccountRent, + TAccountRentSysvar extends string + ? ReadonlyAccount + : TAccountRentSysvar, TAccountStakeAuthority extends string ? ReadonlyAccount : TAccountStakeAuthority, @@ -73,23 +66,19 @@ export type InitializeCheckedInstruction< ] >; -export type InitializeCheckedInstructionData = { - discriminator: ReadonlyUint8Array; -}; +export type InitializeCheckedInstructionData = { discriminator: number }; export type InitializeCheckedInstructionDataArgs = {}; export function getInitializeCheckedInstructionDataEncoder(): Encoder { return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: INITIALIZE_CHECKED_DISCRIMINATOR }) ); } export function getInitializeCheckedInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); + return getStructDecoder([['discriminator', getU8Decoder()]]); } export function getInitializeCheckedInstructionDataCodec(): Codec< @@ -104,30 +93,30 @@ export function getInitializeCheckedInstructionDataCodec(): Codec< export type InitializeCheckedInput< TAccountStake extends string = string, - TAccountRent extends string = string, + TAccountRentSysvar extends string = string, TAccountStakeAuthority extends string = string, TAccountWithdrawAuthority extends string = string, > = { - /** The stake account to initialize */ + /** Uninitialized stake account */ stake: Address; /** Rent sysvar */ - rent?: Address; - /** stake's new stake authority */ + rentSysvar?: Address; + /** The stake authority */ stakeAuthority: Address; - /** stake's new withdraw authority */ + /** The withdraw authority */ withdrawAuthority: TransactionSigner; }; export function getInitializeCheckedInstruction< TAccountStake extends string, - TAccountRent extends string, + TAccountRentSysvar extends string, TAccountStakeAuthority extends string, TAccountWithdrawAuthority extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: InitializeCheckedInput< TAccountStake, - TAccountRent, + TAccountRentSysvar, TAccountStakeAuthority, TAccountWithdrawAuthority >, @@ -135,18 +124,17 @@ export function getInitializeCheckedInstruction< ): InitializeCheckedInstruction< TProgramAddress, TAccountStake, - TAccountRent, + TAccountRentSysvar, TAccountStakeAuthority, TAccountWithdrawAuthority > { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, - rent: { value: input.rent ?? null, isWritable: false }, + rentSysvar: { value: input.rentSysvar ?? null, isWritable: false }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, withdrawAuthority: { value: input.withdrawAuthority ?? null, @@ -159,8 +147,8 @@ export function getInitializeCheckedInstruction< >; // Resolve default values. - if (!accounts.rent.value) { - accounts.rent.value = + if (!accounts.rentSysvar.value) { + accounts.rentSysvar.value = 'SysvarRent111111111111111111111111111111111' as Address<'SysvarRent111111111111111111111111111111111'>; } @@ -168,7 +156,7 @@ export function getInitializeCheckedInstruction< const instruction = { accounts: [ getAccountMeta(accounts.stake), - getAccountMeta(accounts.rent), + getAccountMeta(accounts.rentSysvar), getAccountMeta(accounts.stakeAuthority), getAccountMeta(accounts.withdrawAuthority), ], @@ -177,7 +165,7 @@ export function getInitializeCheckedInstruction< } as InitializeCheckedInstruction< TProgramAddress, TAccountStake, - TAccountRent, + TAccountRentSysvar, TAccountStakeAuthority, TAccountWithdrawAuthority >; @@ -186,18 +174,18 @@ export function getInitializeCheckedInstruction< } export type ParsedInitializeCheckedInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The stake account to initialize */ + /** Uninitialized stake account */ stake: TAccountMetas[0]; /** Rent sysvar */ - rent: TAccountMetas[1]; - /** stake's new stake authority */ + rentSysvar: TAccountMetas[1]; + /** The stake authority */ stakeAuthority: TAccountMetas[2]; - /** stake's new withdraw authority */ + /** The withdraw authority */ withdrawAuthority: TAccountMetas[3]; }; data: InitializeCheckedInstructionData; @@ -225,7 +213,7 @@ export function parseInitializeCheckedInstruction< programAddress: instruction.programAddress, accounts: { stake: getNextAccount(), - rent: getNextAccount(), + rentSysvar: getNextAccount(), stakeAuthority: getNextAccount(), withdrawAuthority: getNextAccount(), }, diff --git a/clients/js/src/generated/instructions/merge.ts b/clients/js/src/generated/instructions/merge.ts index e9ee879..c31d975 100644 --- a/clients/js/src/generated/instructions/merge.ts +++ b/clients/js/src/generated/instructions/merge.ts @@ -8,12 +8,10 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, + getU8Decoder, + getU8Encoder, transformEncoder, type Address, type Codec, @@ -26,26 +24,25 @@ import { type IInstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, - type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -export const MERGE_DISCRIMINATOR = new Uint8Array([ - 148, 141, 236, 47, 174, 126, 69, 111, -]); +export const MERGE_DISCRIMINATOR = 7; export function getMergeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(MERGE_DISCRIMINATOR); + return getU8Encoder().encode(MERGE_DISCRIMINATOR); } export type MergeInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, - TAccountTo extends string | IAccountMeta = string, - TAccountFrom extends string | IAccountMeta = string, - TAccountClock extends string | IAccountMeta = string, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, + TAccountDestinationStake extends string | IAccountMeta = string, + TAccountSourceStake extends string | IAccountMeta = string, + TAccountClockSysvar extends + | string + | IAccountMeta = 'SysvarC1ock11111111111111111111111111111111', TAccountStakeHistory extends string | IAccountMeta = string, TAccountStakeAuthority extends string | IAccountMeta = string, TRemainingAccounts extends readonly IAccountMeta[] = [], @@ -53,13 +50,15 @@ export type MergeInstruction< IInstructionWithData & IInstructionWithAccounts< [ - TAccountTo extends string ? WritableAccount : TAccountTo, - TAccountFrom extends string - ? WritableAccount - : TAccountFrom, - TAccountClock extends string - ? ReadonlyAccount - : TAccountClock, + TAccountDestinationStake extends string + ? WritableAccount + : TAccountDestinationStake, + TAccountSourceStake extends string + ? WritableAccount + : TAccountSourceStake, + TAccountClockSysvar extends string + ? ReadonlyAccount + : TAccountClockSysvar, TAccountStakeHistory extends string ? ReadonlyAccount : TAccountStakeHistory, @@ -71,21 +70,19 @@ export type MergeInstruction< ] >; -export type MergeInstructionData = { discriminator: ReadonlyUint8Array }; +export type MergeInstructionData = { discriminator: number }; export type MergeInstructionDataArgs = {}; export function getMergeInstructionDataEncoder(): Encoder { return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + getStructEncoder([['discriminator', getU8Encoder()]]), (value) => ({ ...value, discriminator: MERGE_DISCRIMINATOR }) ); } export function getMergeInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); + return getStructDecoder([['discriminator', getU8Decoder()]]); } export function getMergeInstructionDataCodec(): Codec< @@ -99,57 +96,59 @@ export function getMergeInstructionDataCodec(): Codec< } export type MergeInput< - TAccountTo extends string = string, - TAccountFrom extends string = string, - TAccountClock extends string = string, + TAccountDestinationStake extends string = string, + TAccountSourceStake extends string = string, + TAccountClockSysvar extends string = string, TAccountStakeHistory extends string = string, TAccountStakeAuthority extends string = string, > = { - /** The destination stake account to merge into */ - to: Address; - /** The stake account to merge from. Must have exact same lockup and authority as to. This account will be drained. */ - from: Address; + /** Destination stake account */ + destinationStake: Address; + /** Source stake account */ + sourceStake: Address; /** Clock sysvar */ - clock: Address; + clockSysvar?: Address; /** Stake history sysvar */ stakeHistory: Address; - /** Both from and to's stake authority */ + /** Stake authority */ stakeAuthority: TransactionSigner; }; export function getMergeInstruction< - TAccountTo extends string, - TAccountFrom extends string, - TAccountClock extends string, + TAccountDestinationStake extends string, + TAccountSourceStake extends string, + TAccountClockSysvar extends string, TAccountStakeHistory extends string, TAccountStakeAuthority extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: MergeInput< - TAccountTo, - TAccountFrom, - TAccountClock, + TAccountDestinationStake, + TAccountSourceStake, + TAccountClockSysvar, TAccountStakeHistory, TAccountStakeAuthority >, config?: { programAddress?: TProgramAddress } ): MergeInstruction< TProgramAddress, - TAccountTo, - TAccountFrom, - TAccountClock, + TAccountDestinationStake, + TAccountSourceStake, + TAccountClockSysvar, TAccountStakeHistory, TAccountStakeAuthority > { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { - to: { value: input.to ?? null, isWritable: true }, - from: { value: input.from ?? null, isWritable: true }, - clock: { value: input.clock ?? null, isWritable: false }, + destinationStake: { + value: input.destinationStake ?? null, + isWritable: true, + }, + sourceStake: { value: input.sourceStake ?? null, isWritable: true }, + clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, stakeHistory: { value: input.stakeHistory ?? null, isWritable: false }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; @@ -158,12 +157,18 @@ export function getMergeInstruction< ResolvedAccount >; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); const instruction = { accounts: [ - getAccountMeta(accounts.to), - getAccountMeta(accounts.from), - getAccountMeta(accounts.clock), + getAccountMeta(accounts.destinationStake), + getAccountMeta(accounts.sourceStake), + getAccountMeta(accounts.clockSysvar), getAccountMeta(accounts.stakeHistory), getAccountMeta(accounts.stakeAuthority), ], @@ -171,9 +176,9 @@ export function getMergeInstruction< data: getMergeInstructionDataEncoder().encode({}), } as MergeInstruction< TProgramAddress, - TAccountTo, - TAccountFrom, - TAccountClock, + TAccountDestinationStake, + TAccountSourceStake, + TAccountClockSysvar, TAccountStakeHistory, TAccountStakeAuthority >; @@ -182,20 +187,20 @@ export function getMergeInstruction< } export type ParsedMergeInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The destination stake account to merge into */ - to: TAccountMetas[0]; - /** The stake account to merge from. Must have exact same lockup and authority as to. This account will be drained. */ - from: TAccountMetas[1]; + /** Destination stake account */ + destinationStake: TAccountMetas[0]; + /** Source stake account */ + sourceStake: TAccountMetas[1]; /** Clock sysvar */ - clock: TAccountMetas[2]; + clockSysvar: TAccountMetas[2]; /** Stake history sysvar */ stakeHistory: TAccountMetas[3]; - /** Both from and to's stake authority */ + /** Stake authority */ stakeAuthority: TAccountMetas[4]; }; data: MergeInstructionData; @@ -222,9 +227,9 @@ export function parseMergeInstruction< return { programAddress: instruction.programAddress, accounts: { - to: getNextAccount(), - from: getNextAccount(), - clock: getNextAccount(), + destinationStake: getNextAccount(), + sourceStake: getNextAccount(), + clockSysvar: getNextAccount(), stakeHistory: getNextAccount(), stakeAuthority: getNextAccount(), }, diff --git a/clients/js/src/generated/instructions/moveLamports.ts b/clients/js/src/generated/instructions/moveLamports.ts new file mode 100644 index 0000000..c2e29cb --- /dev/null +++ b/clients/js/src/generated/instructions/moveLamports.ts @@ -0,0 +1,214 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type IAccountMeta, + type IAccountSignerMeta, + type IInstruction, + type IInstructionWithAccounts, + type IInstructionWithData, + type ReadonlySignerAccount, + type TransactionSigner, + type WritableAccount, +} from '@solana/web3.js'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const MOVE_LAMPORTS_DISCRIMINATOR = 17; + +export function getMoveLamportsDiscriminatorBytes() { + return getU8Encoder().encode(MOVE_LAMPORTS_DISCRIMINATOR); +} + +export type MoveLamportsInstruction< + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, + TAccountSourceStake extends string | IAccountMeta = string, + TAccountDestinationStake extends string | IAccountMeta = string, + TAccountStakeAuthority extends string | IAccountMeta = string, + TRemainingAccounts extends readonly IAccountMeta[] = [], +> = IInstruction & + IInstructionWithData & + IInstructionWithAccounts< + [ + TAccountSourceStake extends string + ? WritableAccount + : TAccountSourceStake, + TAccountDestinationStake extends string + ? WritableAccount + : TAccountDestinationStake, + TAccountStakeAuthority extends string + ? ReadonlySignerAccount & + IAccountSignerMeta + : TAccountStakeAuthority, + ...TRemainingAccounts, + ] + >; + +export type MoveLamportsInstructionData = { + discriminator: number; + args: bigint; +}; + +export type MoveLamportsInstructionDataArgs = { args: number | bigint }; + +export function getMoveLamportsInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', getU8Encoder()], + ['args', getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: MOVE_LAMPORTS_DISCRIMINATOR }) + ); +} + +export function getMoveLamportsInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', getU8Decoder()], + ['args', getU64Decoder()], + ]); +} + +export function getMoveLamportsInstructionDataCodec(): Codec< + MoveLamportsInstructionDataArgs, + MoveLamportsInstructionData +> { + return combineCodec( + getMoveLamportsInstructionDataEncoder(), + getMoveLamportsInstructionDataDecoder() + ); +} + +export type MoveLamportsInput< + TAccountSourceStake extends string = string, + TAccountDestinationStake extends string = string, + TAccountStakeAuthority extends string = string, +> = { + /** Active or inactive source stake account */ + sourceStake: Address; + /** Mergeable destination stake account */ + destinationStake: Address; + /** Stake authority */ + stakeAuthority: TransactionSigner; + args: MoveLamportsInstructionDataArgs['args']; +}; + +export function getMoveLamportsInstruction< + TAccountSourceStake extends string, + TAccountDestinationStake extends string, + TAccountStakeAuthority extends string, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, +>( + input: MoveLamportsInput< + TAccountSourceStake, + TAccountDestinationStake, + TAccountStakeAuthority + >, + config?: { programAddress?: TProgramAddress } +): MoveLamportsInstruction< + TProgramAddress, + TAccountSourceStake, + TAccountDestinationStake, + TAccountStakeAuthority +> { + // Program address. + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + sourceStake: { value: input.sourceStake ?? null, isWritable: true }, + destinationStake: { + value: input.destinationStake ?? null, + isWritable: true, + }, + stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.sourceStake), + getAccountMeta(accounts.destinationStake), + getAccountMeta(accounts.stakeAuthority), + ], + programAddress, + data: getMoveLamportsInstructionDataEncoder().encode( + args as MoveLamportsInstructionDataArgs + ), + } as MoveLamportsInstruction< + TProgramAddress, + TAccountSourceStake, + TAccountDestinationStake, + TAccountStakeAuthority + >; + + return instruction; +} + +export type ParsedMoveLamportsInstruction< + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], +> = { + programAddress: Address; + accounts: { + /** Active or inactive source stake account */ + sourceStake: TAccountMetas[0]; + /** Mergeable destination stake account */ + destinationStake: TAccountMetas[1]; + /** Stake authority */ + stakeAuthority: TAccountMetas[2]; + }; + data: MoveLamportsInstructionData; +}; + +export function parseMoveLamportsInstruction< + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[], +>( + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedMoveLamportsInstruction { + if (instruction.accounts.length < 3) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = instruction.accounts![accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + sourceStake: getNextAccount(), + destinationStake: getNextAccount(), + stakeAuthority: getNextAccount(), + }, + data: getMoveLamportsInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/js/src/generated/instructions/moveStake.ts b/clients/js/src/generated/instructions/moveStake.ts new file mode 100644 index 0000000..c525ba8 --- /dev/null +++ b/clients/js/src/generated/instructions/moveStake.ts @@ -0,0 +1,211 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type IAccountMeta, + type IAccountSignerMeta, + type IInstruction, + type IInstructionWithAccounts, + type IInstructionWithData, + type ReadonlySignerAccount, + type TransactionSigner, + type WritableAccount, +} from '@solana/web3.js'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const MOVE_STAKE_DISCRIMINATOR = 16; + +export function getMoveStakeDiscriminatorBytes() { + return getU8Encoder().encode(MOVE_STAKE_DISCRIMINATOR); +} + +export type MoveStakeInstruction< + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, + TAccountSourceStake extends string | IAccountMeta = string, + TAccountDestinationStake extends string | IAccountMeta = string, + TAccountStakeAuthority extends string | IAccountMeta = string, + TRemainingAccounts extends readonly IAccountMeta[] = [], +> = IInstruction & + IInstructionWithData & + IInstructionWithAccounts< + [ + TAccountSourceStake extends string + ? WritableAccount + : TAccountSourceStake, + TAccountDestinationStake extends string + ? WritableAccount + : TAccountDestinationStake, + TAccountStakeAuthority extends string + ? ReadonlySignerAccount & + IAccountSignerMeta + : TAccountStakeAuthority, + ...TRemainingAccounts, + ] + >; + +export type MoveStakeInstructionData = { discriminator: number; args: bigint }; + +export type MoveStakeInstructionDataArgs = { args: number | bigint }; + +export function getMoveStakeInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', getU8Encoder()], + ['args', getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: MOVE_STAKE_DISCRIMINATOR }) + ); +} + +export function getMoveStakeInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', getU8Decoder()], + ['args', getU64Decoder()], + ]); +} + +export function getMoveStakeInstructionDataCodec(): Codec< + MoveStakeInstructionDataArgs, + MoveStakeInstructionData +> { + return combineCodec( + getMoveStakeInstructionDataEncoder(), + getMoveStakeInstructionDataDecoder() + ); +} + +export type MoveStakeInput< + TAccountSourceStake extends string = string, + TAccountDestinationStake extends string = string, + TAccountStakeAuthority extends string = string, +> = { + /** Active source stake account */ + sourceStake: Address; + /** Active or inactive destination stake account */ + destinationStake: Address; + /** Stake authority */ + stakeAuthority: TransactionSigner; + args: MoveStakeInstructionDataArgs['args']; +}; + +export function getMoveStakeInstruction< + TAccountSourceStake extends string, + TAccountDestinationStake extends string, + TAccountStakeAuthority extends string, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, +>( + input: MoveStakeInput< + TAccountSourceStake, + TAccountDestinationStake, + TAccountStakeAuthority + >, + config?: { programAddress?: TProgramAddress } +): MoveStakeInstruction< + TProgramAddress, + TAccountSourceStake, + TAccountDestinationStake, + TAccountStakeAuthority +> { + // Program address. + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + sourceStake: { value: input.sourceStake ?? null, isWritable: true }, + destinationStake: { + value: input.destinationStake ?? null, + isWritable: true, + }, + stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.sourceStake), + getAccountMeta(accounts.destinationStake), + getAccountMeta(accounts.stakeAuthority), + ], + programAddress, + data: getMoveStakeInstructionDataEncoder().encode( + args as MoveStakeInstructionDataArgs + ), + } as MoveStakeInstruction< + TProgramAddress, + TAccountSourceStake, + TAccountDestinationStake, + TAccountStakeAuthority + >; + + return instruction; +} + +export type ParsedMoveStakeInstruction< + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], +> = { + programAddress: Address; + accounts: { + /** Active source stake account */ + sourceStake: TAccountMetas[0]; + /** Active or inactive destination stake account */ + destinationStake: TAccountMetas[1]; + /** Stake authority */ + stakeAuthority: TAccountMetas[2]; + }; + data: MoveStakeInstructionData; +}; + +export function parseMoveStakeInstruction< + TProgram extends string, + TAccountMetas extends readonly IAccountMeta[], +>( + instruction: IInstruction & + IInstructionWithAccounts & + IInstructionWithData +): ParsedMoveStakeInstruction { + if (instruction.accounts.length < 3) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = instruction.accounts![accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + sourceStake: getNextAccount(), + destinationStake: getNextAccount(), + stakeAuthority: getNextAccount(), + }, + data: getMoveStakeInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/clients/js/src/generated/instructions/setLockup.ts b/clients/js/src/generated/instructions/setLockup.ts index 3b8cefd..f4633a5 100644 --- a/clients/js/src/generated/instructions/setLockup.ts +++ b/clients/js/src/generated/instructions/setLockup.ts @@ -8,12 +8,8 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, getAddressDecoder, getAddressEncoder, - getBytesDecoder, - getBytesEncoder, getI64Decoder, getI64Encoder, getOptionDecoder, @@ -22,6 +18,8 @@ import { getStructEncoder, getU64Decoder, getU64Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type Address, type Codec, @@ -35,23 +33,20 @@ import { type Option, type OptionOrNullable, type ReadonlySignerAccount, - type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -export const SET_LOCKUP_DISCRIMINATOR = new Uint8Array([ - 44, 170, 189, 40, 128, 123, 252, 201, -]); +export const SET_LOCKUP_DISCRIMINATOR = 6; export function getSetLockupDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(SET_LOCKUP_DISCRIMINATOR); + return getU8Encoder().encode(SET_LOCKUP_DISCRIMINATOR); } export type SetLockupInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | IAccountMeta = string, TAccountAuthority extends string | IAccountMeta = string, TRemainingAccounts extends readonly IAccountMeta[] = [], @@ -71,7 +66,7 @@ export type SetLockupInstruction< >; export type SetLockupInstructionData = { - discriminator: ReadonlyUint8Array; + discriminator: number; unixTimestamp: Option; epoch: Option; custodian: Option
; @@ -86,7 +81,7 @@ export type SetLockupInstructionDataArgs = { export function getSetLockupInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['discriminator', getU8Encoder()], ['unixTimestamp', getOptionEncoder(getI64Encoder())], ['epoch', getOptionEncoder(getU64Encoder())], ['custodian', getOptionEncoder(getAddressEncoder())], @@ -97,7 +92,7 @@ export function getSetLockupInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['discriminator', getU8Decoder()], ['unixTimestamp', getOptionDecoder(getI64Decoder())], ['epoch', getOptionDecoder(getU64Decoder())], ['custodian', getOptionDecoder(getAddressDecoder())], @@ -118,9 +113,9 @@ export type SetLockupInput< TAccountStake extends string = string, TAccountAuthority extends string = string, > = { - /** The stake account to set the lockup of */ + /** Initialized stake account */ stake: Address; - /** stake's withdraw authority or lockup authority if lockup is active */ + /** Lockup authority or withdraw authority */ authority: TransactionSigner; unixTimestamp: SetLockupInstructionDataArgs['unixTimestamp']; epoch: SetLockupInstructionDataArgs['epoch']; @@ -130,14 +125,13 @@ export type SetLockupInput< export function getSetLockupInstruction< TAccountStake extends string, TAccountAuthority extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: SetLockupInput, config?: { programAddress?: TProgramAddress } ): SetLockupInstruction { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { @@ -168,14 +162,14 @@ export function getSetLockupInstruction< } export type ParsedSetLockupInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The stake account to set the lockup of */ + /** Initialized stake account */ stake: TAccountMetas[0]; - /** stake's withdraw authority or lockup authority if lockup is active */ + /** Lockup authority or withdraw authority */ authority: TAccountMetas[1]; }; data: SetLockupInstructionData; diff --git a/clients/js/src/generated/instructions/setLockupChecked.ts b/clients/js/src/generated/instructions/setLockupChecked.ts index 52cdb29..10a7e74 100644 --- a/clients/js/src/generated/instructions/setLockupChecked.ts +++ b/clients/js/src/generated/instructions/setLockupChecked.ts @@ -8,10 +8,6 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, getI64Decoder, getI64Encoder, getOptionDecoder, @@ -20,6 +16,8 @@ import { getStructEncoder, getU64Decoder, getU64Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type Address, type Codec, @@ -33,27 +31,23 @@ import { type Option, type OptionOrNullable, type ReadonlySignerAccount, - type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -export const SET_LOCKUP_CHECKED_DISCRIMINATOR = new Uint8Array([ - 22, 158, 12, 183, 118, 94, 156, 255, -]); +export const SET_LOCKUP_CHECKED_DISCRIMINATOR = 12; export function getSetLockupCheckedDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_LOCKUP_CHECKED_DISCRIMINATOR - ); + return getU8Encoder().encode(SET_LOCKUP_CHECKED_DISCRIMINATOR); } export type SetLockupCheckedInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountStake extends string | IAccountMeta = string, TAccountAuthority extends string | IAccountMeta = string, + TAccountNewAuthority extends string | IAccountMeta = string, TRemainingAccounts extends readonly IAccountMeta[] = [], > = IInstruction & IInstructionWithData & @@ -66,12 +60,16 @@ export type SetLockupCheckedInstruction< ? ReadonlySignerAccount & IAccountSignerMeta : TAccountAuthority, + TAccountNewAuthority extends string + ? ReadonlySignerAccount & + IAccountSignerMeta + : TAccountNewAuthority, ...TRemainingAccounts, ] >; export type SetLockupCheckedInstructionData = { - discriminator: ReadonlyUint8Array; + discriminator: number; unixTimestamp: Option; epoch: Option; }; @@ -84,7 +82,7 @@ export type SetLockupCheckedInstructionDataArgs = { export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['discriminator', getU8Encoder()], ['unixTimestamp', getOptionEncoder(getI64Encoder())], ['epoch', getOptionEncoder(getU64Encoder())], ]), @@ -94,7 +92,7 @@ export function getSetLockupCheckedInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['discriminator', getU8Decoder()], ['unixTimestamp', getOptionDecoder(getI64Decoder())], ['epoch', getOptionDecoder(getU64Decoder())], ]); @@ -113,11 +111,14 @@ export function getSetLockupCheckedInstructionDataCodec(): Codec< export type SetLockupCheckedInput< TAccountStake extends string = string, TAccountAuthority extends string = string, + TAccountNewAuthority extends string = string, > = { - /** The stake account to set the lockup of */ + /** Initialized stake account */ stake: Address; - /** stake's withdraw authority or lockup authority if lockup is active. If setting a new lockup authority, the signing new lockup authority must follow. */ + /** Lockup authority or withdraw authority */ authority: TransactionSigner; + /** New lockup authority */ + newAuthority?: TransactionSigner; unixTimestamp: SetLockupCheckedInstructionDataArgs['unixTimestamp']; epoch: SetLockupCheckedInstructionDataArgs['epoch']; }; @@ -125,23 +126,29 @@ export type SetLockupCheckedInput< export function getSetLockupCheckedInstruction< TAccountStake extends string, TAccountAuthority extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TAccountNewAuthority extends string, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( - input: SetLockupCheckedInput, + input: SetLockupCheckedInput< + TAccountStake, + TAccountAuthority, + TAccountNewAuthority + >, config?: { programAddress?: TProgramAddress } ): SetLockupCheckedInstruction< TProgramAddress, TAccountStake, - TAccountAuthority + TAccountAuthority, + TAccountNewAuthority > { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { stake: { value: input.stake ?? null, isWritable: true }, authority: { value: input.authority ?? null, isWritable: false }, + newAuthority: { value: input.newAuthority ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -156,6 +163,7 @@ export function getSetLockupCheckedInstruction< accounts: [ getAccountMeta(accounts.stake), getAccountMeta(accounts.authority), + getAccountMeta(accounts.newAuthority), ], programAddress, data: getSetLockupCheckedInstructionDataEncoder().encode( @@ -164,22 +172,25 @@ export function getSetLockupCheckedInstruction< } as SetLockupCheckedInstruction< TProgramAddress, TAccountStake, - TAccountAuthority + TAccountAuthority, + TAccountNewAuthority >; return instruction; } export type ParsedSetLockupCheckedInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The stake account to set the lockup of */ + /** Initialized stake account */ stake: TAccountMetas[0]; - /** stake's withdraw authority or lockup authority if lockup is active. If setting a new lockup authority, the signing new lockup authority must follow. */ + /** Lockup authority or withdraw authority */ authority: TAccountMetas[1]; + /** New lockup authority */ + newAuthority?: TAccountMetas[2] | undefined; }; data: SetLockupCheckedInstructionData; }; @@ -192,7 +203,7 @@ export function parseSetLockupCheckedInstruction< IInstructionWithAccounts & IInstructionWithData ): ParsedSetLockupCheckedInstruction { - if (instruction.accounts.length < 2) { + if (instruction.accounts.length < 3) { // TODO: Coded error. throw new Error('Not enough accounts'); } @@ -202,11 +213,18 @@ export function parseSetLockupCheckedInstruction< accountIndex += 1; return accountMeta; }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === STAKE_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; return { programAddress: instruction.programAddress, accounts: { stake: getNextAccount(), authority: getNextAccount(), + newAuthority: getNextOptionalAccount(), }, data: getSetLockupCheckedInstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/js/src/generated/instructions/split.ts b/clients/js/src/generated/instructions/split.ts index 2201acd..0fbf214 100644 --- a/clients/js/src/generated/instructions/split.ts +++ b/clients/js/src/generated/instructions/split.ts @@ -8,14 +8,12 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type Address, type Codec, @@ -27,35 +25,34 @@ import { type IInstructionWithAccounts, type IInstructionWithData, type ReadonlySignerAccount, - type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -export const SPLIT_DISCRIMINATOR = new Uint8Array([ - 124, 189, 27, 43, 216, 40, 147, 66, -]); +export const SPLIT_DISCRIMINATOR = 3; export function getSplitDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(SPLIT_DISCRIMINATOR); + return getU8Encoder().encode(SPLIT_DISCRIMINATOR); } export type SplitInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, - TAccountFrom extends string | IAccountMeta = string, - TAccountTo extends string | IAccountMeta = string, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, + TAccountStake extends string | IAccountMeta = string, + TAccountSplitStake extends string | IAccountMeta = string, TAccountStakeAuthority extends string | IAccountMeta = string, TRemainingAccounts extends readonly IAccountMeta[] = [], > = IInstruction & IInstructionWithData & IInstructionWithAccounts< [ - TAccountFrom extends string - ? WritableAccount - : TAccountFrom, - TAccountTo extends string ? WritableAccount : TAccountTo, + TAccountStake extends string + ? WritableAccount + : TAccountStake, + TAccountSplitStake extends string + ? WritableAccount + : TAccountSplitStake, TAccountStakeAuthority extends string ? ReadonlySignerAccount & IAccountSignerMeta @@ -64,18 +61,15 @@ export type SplitInstruction< ] >; -export type SplitInstructionData = { - discriminator: ReadonlyUint8Array; - lamports: bigint; -}; +export type SplitInstructionData = { discriminator: number; args: bigint }; -export type SplitInstructionDataArgs = { lamports: number | bigint }; +export type SplitInstructionDataArgs = { args: number | bigint }; export function getSplitInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['lamports', getU64Encoder()], + ['discriminator', getU8Encoder()], + ['args', getU64Encoder()], ]), (value) => ({ ...value, discriminator: SPLIT_DISCRIMINATOR }) ); @@ -83,8 +77,8 @@ export function getSplitInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['lamports', getU64Decoder()], + ['discriminator', getU8Decoder()], + ['args', getU64Decoder()], ]); } @@ -99,41 +93,40 @@ export function getSplitInstructionDataCodec(): Codec< } export type SplitInput< - TAccountFrom extends string = string, - TAccountTo extends string = string, + TAccountStake extends string = string, + TAccountSplitStake extends string = string, TAccountStakeAuthority extends string = string, > = { - /** The stake account to split. Must be in the Initialized or Stake state */ - from: Address; - /** The uninitialized stake account to split to. Must be rent-exempt starting from solana 1.17. */ - to: Address; - /** from's stake authority */ + /** Stake account to be split */ + stake: Address; + /** Uninitialized stake account */ + splitStake: Address; + /** Stake authority */ stakeAuthority: TransactionSigner; - lamports: SplitInstructionDataArgs['lamports']; + args: SplitInstructionDataArgs['args']; }; export function getSplitInstruction< - TAccountFrom extends string, - TAccountTo extends string, + TAccountStake extends string, + TAccountSplitStake extends string, TAccountStakeAuthority extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( - input: SplitInput, + input: SplitInput, config?: { programAddress?: TProgramAddress } ): SplitInstruction< TProgramAddress, - TAccountFrom, - TAccountTo, + TAccountStake, + TAccountSplitStake, TAccountStakeAuthority > { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { - from: { value: input.from ?? null, isWritable: true }, - to: { value: input.to ?? null, isWritable: true }, + stake: { value: input.stake ?? null, isWritable: true }, + splitStake: { value: input.splitStake ?? null, isWritable: true }, stakeAuthority: { value: input.stakeAuthority ?? null, isWritable: false }, }; const accounts = originalAccounts as Record< @@ -147,8 +140,8 @@ export function getSplitInstruction< const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); const instruction = { accounts: [ - getAccountMeta(accounts.from), - getAccountMeta(accounts.to), + getAccountMeta(accounts.stake), + getAccountMeta(accounts.splitStake), getAccountMeta(accounts.stakeAuthority), ], programAddress, @@ -157,8 +150,8 @@ export function getSplitInstruction< ), } as SplitInstruction< TProgramAddress, - TAccountFrom, - TAccountTo, + TAccountStake, + TAccountSplitStake, TAccountStakeAuthority >; @@ -166,16 +159,16 @@ export function getSplitInstruction< } export type ParsedSplitInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The stake account to split. Must be in the Initialized or Stake state */ - from: TAccountMetas[0]; - /** The uninitialized stake account to split to. Must be rent-exempt starting from solana 1.17. */ - to: TAccountMetas[1]; - /** from's stake authority */ + /** Stake account to be split */ + stake: TAccountMetas[0]; + /** Uninitialized stake account */ + splitStake: TAccountMetas[1]; + /** Stake authority */ stakeAuthority: TAccountMetas[2]; }; data: SplitInstructionData; @@ -202,8 +195,8 @@ export function parseSplitInstruction< return { programAddress: instruction.programAddress, accounts: { - from: getNextAccount(), - to: getNextAccount(), + stake: getNextAccount(), + splitStake: getNextAccount(), stakeAuthority: getNextAccount(), }, data: getSplitInstructionDataDecoder().decode(instruction.data), diff --git a/clients/js/src/generated/instructions/withdraw.ts b/clients/js/src/generated/instructions/withdraw.ts index b44b8cb..c0b070c 100644 --- a/clients/js/src/generated/instructions/withdraw.ts +++ b/clients/js/src/generated/instructions/withdraw.ts @@ -8,14 +8,12 @@ import { combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, + getU8Decoder, + getU8Encoder, transformEncoder, type Address, type Codec, @@ -28,40 +26,42 @@ import { type IInstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, - type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, } from '@solana/web3.js'; -import { STAKE_PROGRAM_PROGRAM_ADDRESS } from '../programs'; +import { STAKE_PROGRAM_ADDRESS } from '../programs'; import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -export const WITHDRAW_DISCRIMINATOR = new Uint8Array([ - 183, 18, 70, 156, 148, 109, 161, 34, -]); +export const WITHDRAW_DISCRIMINATOR = 4; export function getWithdrawDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(WITHDRAW_DISCRIMINATOR); + return getU8Encoder().encode(WITHDRAW_DISCRIMINATOR); } export type WithdrawInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, - TAccountFrom extends string | IAccountMeta = string, - TAccountTo extends string | IAccountMeta = string, - TAccountClock extends string | IAccountMeta = string, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, + TAccountStake extends string | IAccountMeta = string, + TAccountRecipient extends string | IAccountMeta = string, + TAccountClockSysvar extends + | string + | IAccountMeta = 'SysvarC1ock11111111111111111111111111111111', TAccountStakeHistory extends string | IAccountMeta = string, TAccountWithdrawAuthority extends string | IAccountMeta = string, + TAccountLockupAuthority extends string | IAccountMeta = string, TRemainingAccounts extends readonly IAccountMeta[] = [], > = IInstruction & IInstructionWithData & IInstructionWithAccounts< [ - TAccountFrom extends string - ? WritableAccount - : TAccountFrom, - TAccountTo extends string ? WritableAccount : TAccountTo, - TAccountClock extends string - ? ReadonlyAccount - : TAccountClock, + TAccountStake extends string + ? WritableAccount + : TAccountStake, + TAccountRecipient extends string + ? WritableAccount + : TAccountRecipient, + TAccountClockSysvar extends string + ? ReadonlyAccount + : TAccountClockSysvar, TAccountStakeHistory extends string ? ReadonlyAccount : TAccountStakeHistory, @@ -69,22 +69,23 @@ export type WithdrawInstruction< ? ReadonlySignerAccount & IAccountSignerMeta : TAccountWithdrawAuthority, + TAccountLockupAuthority extends string + ? ReadonlySignerAccount & + IAccountSignerMeta + : TAccountLockupAuthority, ...TRemainingAccounts, ] >; -export type WithdrawInstructionData = { - discriminator: ReadonlyUint8Array; - lamports: bigint; -}; +export type WithdrawInstructionData = { discriminator: number; args: bigint }; -export type WithdrawInstructionDataArgs = { lamports: number | bigint }; +export type WithdrawInstructionDataArgs = { args: number | bigint }; export function getWithdrawInstructionDataEncoder(): Encoder { return transformEncoder( getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['lamports', getU64Encoder()], + ['discriminator', getU8Encoder()], + ['args', getU64Encoder()], ]), (value) => ({ ...value, discriminator: WITHDRAW_DISCRIMINATOR }) ); @@ -92,8 +93,8 @@ export function getWithdrawInstructionDataEncoder(): Encoder { return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['lamports', getU64Decoder()], + ['discriminator', getU8Decoder()], + ['args', getU64Decoder()], ]); } @@ -108,63 +109,72 @@ export function getWithdrawInstructionDataCodec(): Codec< } export type WithdrawInput< - TAccountFrom extends string = string, - TAccountTo extends string = string, - TAccountClock extends string = string, + TAccountStake extends string = string, + TAccountRecipient extends string = string, + TAccountClockSysvar extends string = string, TAccountStakeHistory extends string = string, TAccountWithdrawAuthority extends string = string, + TAccountLockupAuthority extends string = string, > = { - /** The stake account to withdraw from */ - from: Address; + /** Stake account from which to withdraw */ + stake: Address; /** Recipient account */ - to: Address; + recipient: Address; /** Clock sysvar */ - clock: Address; + clockSysvar?: Address; /** Stake history sysvar */ stakeHistory: Address; - /** from's withdraw authority. If stake Lockup is active, the signing lockup authority must follow. */ + /** Withdraw authority */ withdrawAuthority: TransactionSigner; - lamports: WithdrawInstructionDataArgs['lamports']; + /** Lockup authority */ + lockupAuthority?: TransactionSigner; + args: WithdrawInstructionDataArgs['args']; }; export function getWithdrawInstruction< - TAccountFrom extends string, - TAccountTo extends string, - TAccountClock extends string, + TAccountStake extends string, + TAccountRecipient extends string, + TAccountClockSysvar extends string, TAccountStakeHistory extends string, TAccountWithdrawAuthority extends string, - TProgramAddress extends Address = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TAccountLockupAuthority extends string, + TProgramAddress extends Address = typeof STAKE_PROGRAM_ADDRESS, >( input: WithdrawInput< - TAccountFrom, - TAccountTo, - TAccountClock, + TAccountStake, + TAccountRecipient, + TAccountClockSysvar, TAccountStakeHistory, - TAccountWithdrawAuthority + TAccountWithdrawAuthority, + TAccountLockupAuthority >, config?: { programAddress?: TProgramAddress } ): WithdrawInstruction< TProgramAddress, - TAccountFrom, - TAccountTo, - TAccountClock, + TAccountStake, + TAccountRecipient, + TAccountClockSysvar, TAccountStakeHistory, - TAccountWithdrawAuthority + TAccountWithdrawAuthority, + TAccountLockupAuthority > { // Program address. - const programAddress = - config?.programAddress ?? STAKE_PROGRAM_PROGRAM_ADDRESS; + const programAddress = config?.programAddress ?? STAKE_PROGRAM_ADDRESS; // Original accounts. const originalAccounts = { - from: { value: input.from ?? null, isWritable: true }, - to: { value: input.to ?? null, isWritable: true }, - clock: { value: input.clock ?? null, isWritable: false }, + stake: { value: input.stake ?? null, isWritable: true }, + recipient: { value: input.recipient ?? null, isWritable: true }, + clockSysvar: { value: input.clockSysvar ?? null, isWritable: false }, stakeHistory: { value: input.stakeHistory ?? null, isWritable: false }, withdrawAuthority: { value: input.withdrawAuthority ?? null, isWritable: false, }, + lockupAuthority: { + value: input.lockupAuthority ?? null, + isWritable: false, + }, }; const accounts = originalAccounts as Record< keyof typeof originalAccounts, @@ -174,14 +184,21 @@ export function getWithdrawInstruction< // Original args. const args = { ...input }; + // Resolve default values. + if (!accounts.clockSysvar.value) { + accounts.clockSysvar.value = + 'SysvarC1ock11111111111111111111111111111111' as Address<'SysvarC1ock11111111111111111111111111111111'>; + } + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); const instruction = { accounts: [ - getAccountMeta(accounts.from), - getAccountMeta(accounts.to), - getAccountMeta(accounts.clock), + getAccountMeta(accounts.stake), + getAccountMeta(accounts.recipient), + getAccountMeta(accounts.clockSysvar), getAccountMeta(accounts.stakeHistory), getAccountMeta(accounts.withdrawAuthority), + getAccountMeta(accounts.lockupAuthority), ], programAddress, data: getWithdrawInstructionDataEncoder().encode( @@ -189,32 +206,35 @@ export function getWithdrawInstruction< ), } as WithdrawInstruction< TProgramAddress, - TAccountFrom, - TAccountTo, - TAccountClock, + TAccountStake, + TAccountRecipient, + TAccountClockSysvar, TAccountStakeHistory, - TAccountWithdrawAuthority + TAccountWithdrawAuthority, + TAccountLockupAuthority >; return instruction; } export type ParsedWithdrawInstruction< - TProgram extends string = typeof STAKE_PROGRAM_PROGRAM_ADDRESS, + TProgram extends string = typeof STAKE_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[], > = { programAddress: Address; accounts: { - /** The stake account to withdraw from */ - from: TAccountMetas[0]; + /** Stake account from which to withdraw */ + stake: TAccountMetas[0]; /** Recipient account */ - to: TAccountMetas[1]; + recipient: TAccountMetas[1]; /** Clock sysvar */ - clock: TAccountMetas[2]; + clockSysvar: TAccountMetas[2]; /** Stake history sysvar */ stakeHistory: TAccountMetas[3]; - /** from's withdraw authority. If stake Lockup is active, the signing lockup authority must follow. */ + /** Withdraw authority */ withdrawAuthority: TAccountMetas[4]; + /** Lockup authority */ + lockupAuthority?: TAccountMetas[5] | undefined; }; data: WithdrawInstructionData; }; @@ -227,7 +247,7 @@ export function parseWithdrawInstruction< IInstructionWithAccounts & IInstructionWithData ): ParsedWithdrawInstruction { - if (instruction.accounts.length < 5) { + if (instruction.accounts.length < 6) { // TODO: Coded error. throw new Error('Not enough accounts'); } @@ -237,14 +257,21 @@ export function parseWithdrawInstruction< accountIndex += 1; return accountMeta; }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === STAKE_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; return { programAddress: instruction.programAddress, accounts: { - from: getNextAccount(), - to: getNextAccount(), - clock: getNextAccount(), + stake: getNextAccount(), + recipient: getNextAccount(), + clockSysvar: getNextAccount(), stakeHistory: getNextAccount(), withdrawAuthority: getNextAccount(), + lockupAuthority: getNextOptionalAccount(), }, data: getWithdrawInstructionDataDecoder().decode(instruction.data), }; diff --git a/clients/js/src/generated/programs/index.ts b/clients/js/src/generated/programs/index.ts index 5a9e1cc..073faf0 100644 --- a/clients/js/src/generated/programs/index.ts +++ b/clients/js/src/generated/programs/index.ts @@ -6,4 +6,4 @@ * @see https://github.com/codama-idl/codama */ -export * from './stakeProgram'; +export * from './stake'; diff --git a/clients/js/src/generated/programs/stake.ts b/clients/js/src/generated/programs/stake.ts new file mode 100644 index 0000000..87fe123 --- /dev/null +++ b/clients/js/src/generated/programs/stake.ts @@ -0,0 +1,175 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + containsBytes, + getU8Encoder, + type Address, + type ReadonlyUint8Array, +} from '@solana/web3.js'; +import { + type ParsedAuthorizeCheckedInstruction, + type ParsedAuthorizeCheckedWithSeedInstruction, + type ParsedAuthorizeInstruction, + type ParsedAuthorizeWithSeedInstruction, + type ParsedDeactivateDelinquentInstruction, + type ParsedDeactivateInstruction, + type ParsedDelegateStakeInstruction, + type ParsedGetMinimumDelegationInstruction, + type ParsedInitializeCheckedInstruction, + type ParsedInitializeInstruction, + type ParsedMergeInstruction, + type ParsedMoveLamportsInstruction, + type ParsedMoveStakeInstruction, + type ParsedSetLockupCheckedInstruction, + type ParsedSetLockupInstruction, + type ParsedSplitInstruction, + type ParsedWithdrawInstruction, +} from '../instructions'; + +export const STAKE_PROGRAM_ADDRESS = + 'Stake11111111111111111111111111111111111111' as Address<'Stake11111111111111111111111111111111111111'>; + +export enum StakeAccount { + StakeStateAccount, +} + +export enum StakeInstruction { + Initialize, + Authorize, + DelegateStake, + Split, + Withdraw, + Deactivate, + SetLockup, + Merge, + AuthorizeWithSeed, + InitializeChecked, + AuthorizeChecked, + AuthorizeCheckedWithSeed, + SetLockupChecked, + GetMinimumDelegation, + DeactivateDelinquent, + MoveStake, + MoveLamports, +} + +export function identifyStakeInstruction( + instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): StakeInstruction { + const data = 'data' in instruction ? instruction.data : instruction; + if (containsBytes(data, getU8Encoder().encode(0), 0)) { + return StakeInstruction.Initialize; + } + if (containsBytes(data, getU8Encoder().encode(1), 0)) { + return StakeInstruction.Authorize; + } + if (containsBytes(data, getU8Encoder().encode(2), 0)) { + return StakeInstruction.DelegateStake; + } + if (containsBytes(data, getU8Encoder().encode(3), 0)) { + return StakeInstruction.Split; + } + if (containsBytes(data, getU8Encoder().encode(4), 0)) { + return StakeInstruction.Withdraw; + } + if (containsBytes(data, getU8Encoder().encode(5), 0)) { + return StakeInstruction.Deactivate; + } + if (containsBytes(data, getU8Encoder().encode(6), 0)) { + return StakeInstruction.SetLockup; + } + if (containsBytes(data, getU8Encoder().encode(7), 0)) { + return StakeInstruction.Merge; + } + if (containsBytes(data, getU8Encoder().encode(8), 0)) { + return StakeInstruction.AuthorizeWithSeed; + } + if (containsBytes(data, getU8Encoder().encode(9), 0)) { + return StakeInstruction.InitializeChecked; + } + if (containsBytes(data, getU8Encoder().encode(10), 0)) { + return StakeInstruction.AuthorizeChecked; + } + if (containsBytes(data, getU8Encoder().encode(11), 0)) { + return StakeInstruction.AuthorizeCheckedWithSeed; + } + if (containsBytes(data, getU8Encoder().encode(12), 0)) { + return StakeInstruction.SetLockupChecked; + } + if (containsBytes(data, getU8Encoder().encode(13), 0)) { + return StakeInstruction.GetMinimumDelegation; + } + if (containsBytes(data, getU8Encoder().encode(14), 0)) { + return StakeInstruction.DeactivateDelinquent; + } + if (containsBytes(data, getU8Encoder().encode(16), 0)) { + return StakeInstruction.MoveStake; + } + if (containsBytes(data, getU8Encoder().encode(17), 0)) { + return StakeInstruction.MoveLamports; + } + throw new Error( + 'The provided instruction could not be identified as a stake instruction.' + ); +} + +export type ParsedStakeInstruction< + TProgram extends string = 'Stake11111111111111111111111111111111111111', +> = + | ({ + instructionType: StakeInstruction.Initialize; + } & ParsedInitializeInstruction) + | ({ + instructionType: StakeInstruction.Authorize; + } & ParsedAuthorizeInstruction) + | ({ + instructionType: StakeInstruction.DelegateStake; + } & ParsedDelegateStakeInstruction) + | ({ + instructionType: StakeInstruction.Split; + } & ParsedSplitInstruction) + | ({ + instructionType: StakeInstruction.Withdraw; + } & ParsedWithdrawInstruction) + | ({ + instructionType: StakeInstruction.Deactivate; + } & ParsedDeactivateInstruction) + | ({ + instructionType: StakeInstruction.SetLockup; + } & ParsedSetLockupInstruction) + | ({ + instructionType: StakeInstruction.Merge; + } & ParsedMergeInstruction) + | ({ + instructionType: StakeInstruction.AuthorizeWithSeed; + } & ParsedAuthorizeWithSeedInstruction) + | ({ + instructionType: StakeInstruction.InitializeChecked; + } & ParsedInitializeCheckedInstruction) + | ({ + instructionType: StakeInstruction.AuthorizeChecked; + } & ParsedAuthorizeCheckedInstruction) + | ({ + instructionType: StakeInstruction.AuthorizeCheckedWithSeed; + } & ParsedAuthorizeCheckedWithSeedInstruction) + | ({ + instructionType: StakeInstruction.SetLockupChecked; + } & ParsedSetLockupCheckedInstruction) + | ({ + instructionType: StakeInstruction.GetMinimumDelegation; + } & ParsedGetMinimumDelegationInstruction) + | ({ + instructionType: StakeInstruction.DeactivateDelinquent; + } & ParsedDeactivateDelinquentInstruction) + | ({ + instructionType: StakeInstruction.MoveStake; + } & ParsedMoveStakeInstruction) + | ({ + instructionType: StakeInstruction.MoveLamports; + } & ParsedMoveLamportsInstruction); diff --git a/clients/js/src/generated/programs/stakeProgram.ts b/clients/js/src/generated/programs/stakeProgram.ts deleted file mode 100644 index 898ab76..0000000 --- a/clients/js/src/generated/programs/stakeProgram.ts +++ /dev/null @@ -1,276 +0,0 @@ -/** - * This code was AUTOGENERATED using the codama library. - * Please DO NOT EDIT THIS FILE, instead use visitors - * to add features, then rerun codama to update it. - * - * @see https://github.com/codama-idl/codama - */ - -import { - containsBytes, - fixEncoderSize, - getBytesEncoder, - type Address, - type ReadonlyUint8Array, -} from '@solana/web3.js'; -import { - type ParsedAuthorizeCheckedInstruction, - type ParsedAuthorizeCheckedWithSeedInstruction, - type ParsedAuthorizeInstruction, - type ParsedAuthorizeWithSeedInstruction, - type ParsedDeactivateDelinquentInstruction, - type ParsedDeactivateInstruction, - type ParsedDelegateStakeInstruction, - type ParsedGetMinimumDelegationInstruction, - type ParsedInitializeCheckedInstruction, - type ParsedInitializeInstruction, - type ParsedMergeInstruction, - type ParsedSetLockupCheckedInstruction, - type ParsedSetLockupInstruction, - type ParsedSplitInstruction, - type ParsedWithdrawInstruction, -} from '../instructions'; - -export const STAKE_PROGRAM_PROGRAM_ADDRESS = - 'Stake11111111111111111111111111111111111111' as Address<'Stake11111111111111111111111111111111111111'>; - -export enum StakeProgramInstruction { - Initialize, - Authorize, - DelegateStake, - Split, - Withdraw, - Deactivate, - SetLockup, - Merge, - AuthorizeWithSeed, - InitializeChecked, - AuthorizeChecked, - AuthorizeCheckedWithSeed, - SetLockupChecked, - GetMinimumDelegation, - DeactivateDelinquent, -} - -export function identifyStakeProgramInstruction( - instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): StakeProgramInstruction { - const data = 'data' in instruction ? instruction.data : instruction; - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237]) - ), - 0 - ) - ) { - return StakeProgramInstruction.Initialize; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([173, 193, 102, 210, 219, 137, 113, 120]) - ), - 0 - ) - ) { - return StakeProgramInstruction.Authorize; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([50, 110, 95, 179, 194, 75, 140, 246]) - ), - 0 - ) - ) { - return StakeProgramInstruction.DelegateStake; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([124, 189, 27, 43, 216, 40, 147, 66]) - ), - 0 - ) - ) { - return StakeProgramInstruction.Split; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([183, 18, 70, 156, 148, 109, 161, 34]) - ), - 0 - ) - ) { - return StakeProgramInstruction.Withdraw; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([44, 112, 33, 172, 113, 28, 142, 13]) - ), - 0 - ) - ) { - return StakeProgramInstruction.Deactivate; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([44, 170, 189, 40, 128, 123, 252, 201]) - ), - 0 - ) - ) { - return StakeProgramInstruction.SetLockup; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([148, 141, 236, 47, 174, 126, 69, 111]) - ), - 0 - ) - ) { - return StakeProgramInstruction.Merge; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([7, 18, 211, 41, 76, 83, 115, 61]) - ), - 0 - ) - ) { - return StakeProgramInstruction.AuthorizeWithSeed; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([219, 90, 58, 161, 139, 88, 246, 28]) - ), - 0 - ) - ) { - return StakeProgramInstruction.InitializeChecked; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([147, 97, 67, 26, 230, 107, 45, 242]) - ), - 0 - ) - ) { - return StakeProgramInstruction.AuthorizeChecked; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([14, 230, 154, 165, 225, 209, 194, 210]) - ), - 0 - ) - ) { - return StakeProgramInstruction.AuthorizeCheckedWithSeed; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([22, 158, 12, 183, 118, 94, 156, 255]) - ), - 0 - ) - ) { - return StakeProgramInstruction.SetLockupChecked; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([197, 65, 7, 73, 151, 105, 133, 105]) - ), - 0 - ) - ) { - return StakeProgramInstruction.GetMinimumDelegation; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([6, 113, 198, 138, 228, 163, 159, 221]) - ), - 0 - ) - ) { - return StakeProgramInstruction.DeactivateDelinquent; - } - throw new Error( - 'The provided instruction could not be identified as a stakeProgram instruction.' - ); -} - -export type ParsedStakeProgramInstruction< - TProgram extends string = 'Stake11111111111111111111111111111111111111', -> = - | ({ - instructionType: StakeProgramInstruction.Initialize; - } & ParsedInitializeInstruction) - | ({ - instructionType: StakeProgramInstruction.Authorize; - } & ParsedAuthorizeInstruction) - | ({ - instructionType: StakeProgramInstruction.DelegateStake; - } & ParsedDelegateStakeInstruction) - | ({ - instructionType: StakeProgramInstruction.Split; - } & ParsedSplitInstruction) - | ({ - instructionType: StakeProgramInstruction.Withdraw; - } & ParsedWithdrawInstruction) - | ({ - instructionType: StakeProgramInstruction.Deactivate; - } & ParsedDeactivateInstruction) - | ({ - instructionType: StakeProgramInstruction.SetLockup; - } & ParsedSetLockupInstruction) - | ({ - instructionType: StakeProgramInstruction.Merge; - } & ParsedMergeInstruction) - | ({ - instructionType: StakeProgramInstruction.AuthorizeWithSeed; - } & ParsedAuthorizeWithSeedInstruction) - | ({ - instructionType: StakeProgramInstruction.InitializeChecked; - } & ParsedInitializeCheckedInstruction) - | ({ - instructionType: StakeProgramInstruction.AuthorizeChecked; - } & ParsedAuthorizeCheckedInstruction) - | ({ - instructionType: StakeProgramInstruction.AuthorizeCheckedWithSeed; - } & ParsedAuthorizeCheckedWithSeedInstruction) - | ({ - instructionType: StakeProgramInstruction.SetLockupChecked; - } & ParsedSetLockupCheckedInstruction) - | ({ - instructionType: StakeProgramInstruction.GetMinimumDelegation; - } & ParsedGetMinimumDelegationInstruction) - | ({ - instructionType: StakeProgramInstruction.DeactivateDelinquent; - } & ParsedDeactivateDelinquentInstruction); diff --git a/clients/js/src/generated/types/authorized.ts b/clients/js/src/generated/types/authorized.ts new file mode 100644 index 0000000..2eddabd --- /dev/null +++ b/clients/js/src/generated/types/authorized.ts @@ -0,0 +1,41 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getStructDecoder, + getStructEncoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/web3.js'; + +export type Authorized = { staker: Address; withdrawer: Address }; + +export type AuthorizedArgs = Authorized; + +export function getAuthorizedEncoder(): Encoder { + return getStructEncoder([ + ['staker', getAddressEncoder()], + ['withdrawer', getAddressEncoder()], + ]); +} + +export function getAuthorizedDecoder(): Decoder { + return getStructDecoder([ + ['staker', getAddressDecoder()], + ['withdrawer', getAddressDecoder()], + ]); +} + +export function getAuthorizedCodec(): Codec { + return combineCodec(getAuthorizedEncoder(), getAuthorizedDecoder()); +} diff --git a/clients/js/src/generated/types/delegation.ts b/clients/js/src/generated/types/delegation.ts new file mode 100644 index 0000000..79a0195 --- /dev/null +++ b/clients/js/src/generated/types/delegation.ts @@ -0,0 +1,63 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getF64Decoder, + getF64Encoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/web3.js'; + +export type Delegation = { + voterPubkey: Address; + stake: bigint; + activationEpoch: bigint; + deactivationEpoch: bigint; + warmupCooldownRate: number; +}; + +export type DelegationArgs = { + voterPubkey: Address; + stake: number | bigint; + activationEpoch: number | bigint; + deactivationEpoch: number | bigint; + warmupCooldownRate: number; +}; + +export function getDelegationEncoder(): Encoder { + return getStructEncoder([ + ['voterPubkey', getAddressEncoder()], + ['stake', getU64Encoder()], + ['activationEpoch', getU64Encoder()], + ['deactivationEpoch', getU64Encoder()], + ['warmupCooldownRate', getF64Encoder()], + ]); +} + +export function getDelegationDecoder(): Decoder { + return getStructDecoder([ + ['voterPubkey', getAddressDecoder()], + ['stake', getU64Decoder()], + ['activationEpoch', getU64Decoder()], + ['deactivationEpoch', getU64Decoder()], + ['warmupCooldownRate', getF64Decoder()], + ]); +} + +export function getDelegationCodec(): Codec { + return combineCodec(getDelegationEncoder(), getDelegationDecoder()); +} diff --git a/clients/js/src/generated/types/index.ts b/clients/js/src/generated/types/index.ts index ef92917..2a99b06 100644 --- a/clients/js/src/generated/types/index.ts +++ b/clients/js/src/generated/types/index.ts @@ -6,4 +6,12 @@ * @see https://github.com/codama-idl/codama */ +export * from './authorized'; +export * from './delegation'; +export * from './lockup'; +export * from './meta'; +export * from './stake'; export * from './stakeAuthorize'; +export * from './stakeFlags'; +export * from './stakeState'; +export * from './stakeStateV2'; diff --git a/clients/js/src/generated/types/lockup.ts b/clients/js/src/generated/types/lockup.ts new file mode 100644 index 0000000..0b3b422 --- /dev/null +++ b/clients/js/src/generated/types/lockup.ts @@ -0,0 +1,55 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getAddressDecoder, + getAddressEncoder, + getI64Decoder, + getI64Encoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/web3.js'; + +export type Lockup = { + unixTimestamp: bigint; + epoch: bigint; + custodian: Address; +}; + +export type LockupArgs = { + unixTimestamp: number | bigint; + epoch: number | bigint; + custodian: Address; +}; + +export function getLockupEncoder(): Encoder { + return getStructEncoder([ + ['unixTimestamp', getI64Encoder()], + ['epoch', getU64Encoder()], + ['custodian', getAddressEncoder()], + ]); +} + +export function getLockupDecoder(): Decoder { + return getStructDecoder([ + ['unixTimestamp', getI64Decoder()], + ['epoch', getU64Decoder()], + ['custodian', getAddressDecoder()], + ]); +} + +export function getLockupCodec(): Codec { + return combineCodec(getLockupEncoder(), getLockupDecoder()); +} diff --git a/clients/js/src/generated/types/meta.ts b/clients/js/src/generated/types/meta.ts new file mode 100644 index 0000000..84c5ab9 --- /dev/null +++ b/clients/js/src/generated/types/meta.ts @@ -0,0 +1,60 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/web3.js'; +import { + getAuthorizedDecoder, + getAuthorizedEncoder, + getLockupDecoder, + getLockupEncoder, + type Authorized, + type AuthorizedArgs, + type Lockup, + type LockupArgs, +} from '.'; + +export type Meta = { + rentExemptReserve: bigint; + authorized: Authorized; + lockup: Lockup; +}; + +export type MetaArgs = { + rentExemptReserve: number | bigint; + authorized: AuthorizedArgs; + lockup: LockupArgs; +}; + +export function getMetaEncoder(): Encoder { + return getStructEncoder([ + ['rentExemptReserve', getU64Encoder()], + ['authorized', getAuthorizedEncoder()], + ['lockup', getLockupEncoder()], + ]); +} + +export function getMetaDecoder(): Decoder { + return getStructDecoder([ + ['rentExemptReserve', getU64Decoder()], + ['authorized', getAuthorizedDecoder()], + ['lockup', getLockupDecoder()], + ]); +} + +export function getMetaCodec(): Codec { + return combineCodec(getMetaEncoder(), getMetaDecoder()); +} diff --git a/clients/js/src/generated/types/stake.ts b/clients/js/src/generated/types/stake.ts new file mode 100644 index 0000000..71c8b0e --- /dev/null +++ b/clients/js/src/generated/types/stake.ts @@ -0,0 +1,49 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/web3.js'; +import { + getDelegationDecoder, + getDelegationEncoder, + type Delegation, + type DelegationArgs, +} from '.'; + +export type Stake = { delegation: Delegation; creditsObserved: bigint }; + +export type StakeArgs = { + delegation: DelegationArgs; + creditsObserved: number | bigint; +}; + +export function getStakeEncoder(): Encoder { + return getStructEncoder([ + ['delegation', getDelegationEncoder()], + ['creditsObserved', getU64Encoder()], + ]); +} + +export function getStakeDecoder(): Decoder { + return getStructDecoder([ + ['delegation', getDelegationDecoder()], + ['creditsObserved', getU64Decoder()], + ]); +} + +export function getStakeCodec(): Codec { + return combineCodec(getStakeEncoder(), getStakeDecoder()); +} diff --git a/clients/js/src/generated/types/stakeFlags.ts b/clients/js/src/generated/types/stakeFlags.ts new file mode 100644 index 0000000..45985f6 --- /dev/null +++ b/clients/js/src/generated/types/stakeFlags.ts @@ -0,0 +1,34 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/web3.js'; + +export type StakeFlags = { bits: number }; + +export type StakeFlagsArgs = StakeFlags; + +export function getStakeFlagsEncoder(): Encoder { + return getStructEncoder([['bits', getU8Encoder()]]); +} + +export function getStakeFlagsDecoder(): Decoder { + return getStructDecoder([['bits', getU8Decoder()]]); +} + +export function getStakeFlagsCodec(): Codec { + return combineCodec(getStakeFlagsEncoder(), getStakeFlagsDecoder()); +} diff --git a/clients/js/src/generated/types/stakeState.ts b/clients/js/src/generated/types/stakeState.ts new file mode 100644 index 0000000..0a26f74 --- /dev/null +++ b/clients/js/src/generated/types/stakeState.ts @@ -0,0 +1,123 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getDiscriminatedUnionDecoder, + getDiscriminatedUnionEncoder, + getStructDecoder, + getStructEncoder, + getTupleDecoder, + getTupleEncoder, + getUnitDecoder, + getUnitEncoder, + type Codec, + type Decoder, + type Encoder, + type GetDiscriminatedUnionVariant, + type GetDiscriminatedUnionVariantContent, +} from '@solana/web3.js'; +import { + getMetaDecoder, + getMetaEncoder, + getStakeDecoder, + getStakeEncoder, + type Meta, + type MetaArgs, + type Stake, + type StakeArgs, +} from '.'; + +export type StakeState = + | { __kind: 'Uninitialized' } + | { __kind: 'Initialized'; fields: readonly [Meta] } + | { __kind: 'Stake'; fields: readonly [Meta, Stake] } + | { __kind: 'RewardsPool' }; + +export type StakeStateArgs = + | { __kind: 'Uninitialized' } + | { __kind: 'Initialized'; fields: readonly [MetaArgs] } + | { __kind: 'Stake'; fields: readonly [MetaArgs, StakeArgs] } + | { __kind: 'RewardsPool' }; + +export function getStakeStateEncoder(): Encoder { + return getDiscriminatedUnionEncoder([ + ['Uninitialized', getUnitEncoder()], + [ + 'Initialized', + getStructEncoder([['fields', getTupleEncoder([getMetaEncoder()])]]), + ], + [ + 'Stake', + getStructEncoder([ + ['fields', getTupleEncoder([getMetaEncoder(), getStakeEncoder()])], + ]), + ], + ['RewardsPool', getUnitEncoder()], + ]); +} + +export function getStakeStateDecoder(): Decoder { + return getDiscriminatedUnionDecoder([ + ['Uninitialized', getUnitDecoder()], + [ + 'Initialized', + getStructDecoder([['fields', getTupleDecoder([getMetaDecoder()])]]), + ], + [ + 'Stake', + getStructDecoder([ + ['fields', getTupleDecoder([getMetaDecoder(), getStakeDecoder()])], + ]), + ], + ['RewardsPool', getUnitDecoder()], + ]); +} + +export function getStakeStateCodec(): Codec { + return combineCodec(getStakeStateEncoder(), getStakeStateDecoder()); +} + +// Data Enum Helpers. +export function stakeState( + kind: 'Uninitialized' +): GetDiscriminatedUnionVariant; +export function stakeState( + kind: 'Initialized', + data: GetDiscriminatedUnionVariantContent< + StakeStateArgs, + '__kind', + 'Initialized' + >['fields'] +): GetDiscriminatedUnionVariant; +export function stakeState( + kind: 'Stake', + data: GetDiscriminatedUnionVariantContent< + StakeStateArgs, + '__kind', + 'Stake' + >['fields'] +): GetDiscriminatedUnionVariant; +export function stakeState( + kind: 'RewardsPool' +): GetDiscriminatedUnionVariant; +export function stakeState( + kind: K, + data?: Data +) { + return Array.isArray(data) + ? { __kind: kind, fields: data } + : { __kind: kind, ...(data ?? {}) }; +} + +export function isStakeState( + kind: K, + value: StakeState +): value is StakeState & { __kind: K } { + return value.__kind === kind; +} diff --git a/clients/js/src/generated/types/stakeStateV2.ts b/clients/js/src/generated/types/stakeStateV2.ts new file mode 100644 index 0000000..f5cca40 --- /dev/null +++ b/clients/js/src/generated/types/stakeStateV2.ts @@ -0,0 +1,149 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import { + combineCodec, + getDiscriminatedUnionDecoder, + getDiscriminatedUnionEncoder, + getStructDecoder, + getStructEncoder, + getTupleDecoder, + getTupleEncoder, + getU32Decoder, + getU32Encoder, + getUnitDecoder, + getUnitEncoder, + type Codec, + type Decoder, + type Encoder, + type GetDiscriminatedUnionVariant, + type GetDiscriminatedUnionVariantContent, +} from '@solana/web3.js'; +import { + getMetaDecoder, + getMetaEncoder, + getStakeDecoder, + getStakeEncoder, + getStakeFlagsDecoder, + getStakeFlagsEncoder, + type Meta, + type MetaArgs, + type Stake, + type StakeArgs, + type StakeFlags, + type StakeFlagsArgs, +} from '.'; + +export type StakeStateV2 = + | { __kind: 'Uninitialized' } + | { __kind: 'Initialized'; fields: readonly [Meta] } + | { __kind: 'Stake'; fields: readonly [Meta, Stake, StakeFlags] } + | { __kind: 'RewardsPool' }; + +export type StakeStateV2Args = + | { __kind: 'Uninitialized' } + | { __kind: 'Initialized'; fields: readonly [MetaArgs] } + | { __kind: 'Stake'; fields: readonly [MetaArgs, StakeArgs, StakeFlagsArgs] } + | { __kind: 'RewardsPool' }; + +export function getStakeStateV2Encoder(): Encoder { + return getDiscriminatedUnionEncoder( + [ + ['Uninitialized', getUnitEncoder()], + [ + 'Initialized', + getStructEncoder([['fields', getTupleEncoder([getMetaEncoder()])]]), + ], + [ + 'Stake', + getStructEncoder([ + [ + 'fields', + getTupleEncoder([ + getMetaEncoder(), + getStakeEncoder(), + getStakeFlagsEncoder(), + ]), + ], + ]), + ], + ['RewardsPool', getUnitEncoder()], + ], + { size: getU32Encoder() } + ); +} + +export function getStakeStateV2Decoder(): Decoder { + return getDiscriminatedUnionDecoder( + [ + ['Uninitialized', getUnitDecoder()], + [ + 'Initialized', + getStructDecoder([['fields', getTupleDecoder([getMetaDecoder()])]]), + ], + [ + 'Stake', + getStructDecoder([ + [ + 'fields', + getTupleDecoder([ + getMetaDecoder(), + getStakeDecoder(), + getStakeFlagsDecoder(), + ]), + ], + ]), + ], + ['RewardsPool', getUnitDecoder()], + ], + { size: getU32Decoder() } + ); +} + +export function getStakeStateV2Codec(): Codec { + return combineCodec(getStakeStateV2Encoder(), getStakeStateV2Decoder()); +} + +// Data Enum Helpers. +export function stakeStateV2( + kind: 'Uninitialized' +): GetDiscriminatedUnionVariant; +export function stakeStateV2( + kind: 'Initialized', + data: GetDiscriminatedUnionVariantContent< + StakeStateV2Args, + '__kind', + 'Initialized' + >['fields'] +): GetDiscriminatedUnionVariant; +export function stakeStateV2( + kind: 'Stake', + data: GetDiscriminatedUnionVariantContent< + StakeStateV2Args, + '__kind', + 'Stake' + >['fields'] +): GetDiscriminatedUnionVariant; +export function stakeStateV2( + kind: 'RewardsPool' +): GetDiscriminatedUnionVariant; +export function stakeStateV2( + kind: K, + data?: Data +) { + return Array.isArray(data) + ? { __kind: kind, fields: data } + : { __kind: kind, ...(data ?? {}) }; +} + +export function isStakeStateV2( + kind: K, + value: StakeStateV2 +): value is StakeStateV2 & { __kind: K } { + return value.__kind === kind; +} diff --git a/clients/rust/Cargo.toml b/clients/rust/Cargo.toml index d1a4071..ee9bf65 100644 --- a/clients/rust/Cargo.toml +++ b/clients/rust/Cargo.toml @@ -17,7 +17,7 @@ num-derive = "^0.3" num-traits = "^0.2" serde = { version = "^1.0", features = ["derive"], optional = true } serde_with = { version = "^3.0", optional = true } -solana-program = "2.1" +solana-program = "^2.1" thiserror = "^1.0" [dev-dependencies] diff --git a/clients/rust/src/generated/errors/mod.rs b/clients/rust/src/generated/errors/mod.rs index 6172ba6..7f6b2f8 100644 --- a/clients/rust/src/generated/errors/mod.rs +++ b/clients/rust/src/generated/errors/mod.rs @@ -4,3 +4,7 @@ //! //! //! + +pub(crate) mod stake; + +pub use self::stake::StakeError; diff --git a/clients/rust/src/generated/errors/stake.rs b/clients/rust/src/generated/errors/stake.rs new file mode 100644 index 0000000..b500d13 --- /dev/null +++ b/clients/rust/src/generated/errors/stake.rs @@ -0,0 +1,71 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +use {num_derive::FromPrimitive, thiserror::Error}; + +#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] +pub enum StakeError { + /// 0 - Not enough credits to redeem + #[error("Not enough credits to redeem")] + NoCreditsToRedeem = 0x0, + /// 1 - Lockup has not yet expired + #[error("Lockup has not yet expired")] + LockupInForce = 0x1, + /// 2 - Stake already deactivated + #[error("Stake already deactivated")] + AlreadyDeactivated = 0x2, + /// 3 - One re-delegation permitted per epoch + #[error("One re-delegation permitted per epoch")] + TooSoonToRedelegate = 0x3, + /// 4 - Split amount is more than is staked + #[error("Split amount is more than is staked")] + InsufficientStake = 0x4, + /// 5 - Stake account with transient stake cannot be merged + #[error("Stake account with transient stake cannot be merged")] + MergeTransientStake = 0x5, + /// 6 - Stake account merge failed due to different authority, lockups or state + #[error("Stake account merge failed due to different authority, lockups or state")] + MergeMismatch = 0x6, + /// 7 - Custodian address not present + #[error("Custodian address not present")] + CustodianMissing = 0x7, + /// 8 - Custodian signature not present + #[error("Custodian signature not present")] + CustodianSignatureMissing = 0x8, + /// 9 - Insufficient voting activity in the reference vote account + #[error("Insufficient voting activity in the reference vote account")] + InsufficientReferenceVotes = 0x9, + /// 10 - Stake account is not delegated to the provided vote account + #[error("Stake account is not delegated to the provided vote account")] + VoteAddressMismatch = 0xA, + /// 11 - Stake account has not been delinquent for the minimum epochs required for deactivation + #[error( + "Stake account has not been delinquent for the minimum epochs required for deactivation" + )] + MinimumDelinquentEpochsForDeactivationNotMet = 0xB, + /// 12 - Delegation amount is less than the minimum + #[error("Delegation amount is less than the minimum")] + InsufficientDelegation = 0xC, + /// 13 - Stake account with transient or inactive stake cannot be redelegated + #[error("Stake account with transient or inactive stake cannot be redelegated")] + RedelegateTransientOrInactiveStake = 0xD, + /// 14 - Stake redelegation to the same vote account is not permitted + #[error("Stake redelegation to the same vote account is not permitted")] + RedelegateToSameVoteAccount = 0xE, + /// 15 - Redelegated stake must be fully activated before deactivation + #[error("Redelegated stake must be fully activated before deactivation")] + RedelegatedStakeMustFullyActivateBeforeDeactivationIsPermitted = 0xF, + /// 16 - Stake action is not permitted while the epoch rewards period is active + #[error("Stake action is not permitted while the epoch rewards period is active")] + EpochRewardsActive = 0x10, +} + +impl solana_program::program_error::PrintProgramError for StakeError { + fn print(&self) { + solana_program::msg!(&self.to_string()); + } +} diff --git a/clients/rust/src/generated/instructions/authorize.rs b/clients/rust/src/generated/instructions/authorize.rs index a9d6b54..e431a21 100644 --- a/clients/rust/src/generated/instructions/authorize.rs +++ b/clients/rust/src/generated/instructions/authorize.rs @@ -13,12 +13,14 @@ use { /// Accounts. pub struct Authorize { - /// The stake account to be updated + /// Stake account to be updated pub stake: solana_program::pubkey::Pubkey, /// Clock sysvar - pub clock: solana_program::pubkey::Pubkey, - /// stake's current stake or withdraw authority to change away from. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// Stake or withdraw authority pub authority: solana_program::pubkey::Pubkey, + /// Lockup authority + pub lockup_authority: Option, } impl Authorize { @@ -34,24 +36,36 @@ impl Authorize { args: AuthorizeInstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.clock, false, + self.clock_sysvar, + false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, true, )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + lockup_authority, + true, + )); + } else { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + crate::STAKE_ID, + false, + )); + } accounts.extend_from_slice(remaining_accounts); let mut data = AuthorizeInstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -60,14 +74,12 @@ impl Authorize { #[derive(BorshDeserialize, BorshSerialize)] pub struct AuthorizeInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl AuthorizeInstructionData { pub fn new() -> Self { - Self { - discriminator: [173, 193, 102, 210, 219, 137, 113, 120], - } + Self { discriminator: 1 } } } @@ -80,8 +92,8 @@ impl Default for AuthorizeInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeInstructionArgs { - pub new_authority: Pubkey, - pub stake_authorize: StakeAuthorize, + pub arg0: Pubkey, + pub arg1: StakeAuthorize, } /// Instruction builder for `Authorize`. @@ -89,15 +101,17 @@ pub struct AuthorizeInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` clock +/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) /// 2. `[signer]` authority +/// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeBuilder { stake: Option, - clock: Option, + clock_sysvar: Option, authority: Option, - new_authority: Option, - stake_authorize: Option, + lockup_authority: Option, + arg0: Option, + arg1: Option, __remaining_accounts: Vec, } @@ -105,32 +119,43 @@ impl AuthorizeBuilder { pub fn new() -> Self { Self::default() } - /// The stake account to be updated + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock = Some(clock); + pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + self.clock_sysvar = Some(clock_sysvar); self } - /// stake's current stake or withdraw authority to change away from. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer + /// Stake or withdraw authority #[inline(always)] pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } + /// `[optional account]` + /// Lockup authority + #[inline(always)] + pub fn lockup_authority( + &mut self, + lockup_authority: Option, + ) -> &mut Self { + self.lockup_authority = lockup_authority; + self + } #[inline(always)] - pub fn new_authority(&mut self, new_authority: Pubkey) -> &mut Self { - self.new_authority = Some(new_authority); + pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { + self.arg0 = Some(arg0); self } #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { - self.stake_authorize = Some(stake_authorize); + pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { + self.arg1 = Some(arg1); self } /// Add an additional account to the instruction. @@ -155,18 +180,15 @@ impl AuthorizeBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Authorize { stake: self.stake.expect("stake is not set"), - clock: self.clock.expect("clock is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), authority: self.authority.expect("authority is not set"), + lockup_authority: self.lockup_authority, }; let args = AuthorizeInstructionArgs { - new_authority: self - .new_authority - .clone() - .expect("new_authority is not set"), - stake_authorize: self - .stake_authorize - .clone() - .expect("stake_authorize is not set"), + arg0: self.arg0.clone().expect("arg0 is not set"), + arg1: self.arg1.clone().expect("arg1 is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -175,24 +197,28 @@ impl AuthorizeBuilder { /// `authorize` CPI accounts. pub struct AuthorizeCpiAccounts<'a, 'b> { - /// The stake account to be updated + /// Stake account to be updated pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's current stake or withdraw authority to change away from. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } /// `authorize` CPI instruction. pub struct AuthorizeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to be updated + /// Stake account to be updated pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's current stake or withdraw authority to change away from. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeInstructionArgs, } @@ -206,8 +232,9 @@ impl<'a, 'b> AuthorizeCpi<'a, 'b> { Self { __program: program, stake: accounts.stake, - clock: accounts.clock, + clock_sysvar: accounts.clock_sysvar, authority: accounts.authority, + lockup_authority: accounts.lockup_authority, __args: args, } } @@ -244,19 +271,30 @@ impl<'a, 'b> AuthorizeCpi<'a, 'b> { bool, )], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.clock.key, + *self.clock_sysvar.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.authority.key, true, )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *lockup_authority.key, + true, + )); + } else { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + crate::STAKE_ID, + false, + )); + } remaining_accounts.iter().for_each(|remaining_account| { accounts.push(solana_program::instruction::AccountMeta { pubkey: *remaining_account.0.key, @@ -269,15 +307,18 @@ impl<'a, 'b> AuthorizeCpi<'a, 'b> { data.append(&mut args); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); - account_infos.push(self.clock.clone()); + account_infos.push(self.clock_sysvar.clone()); account_infos.push(self.authority.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); + } remaining_accounts .iter() .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); @@ -295,8 +336,9 @@ impl<'a, 'b> AuthorizeCpi<'a, 'b> { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` clock +/// 1. `[]` clock_sysvar /// 2. `[signer]` authority +/// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct AuthorizeCpiBuilder<'a, 'b> { instruction: Box>, @@ -307,15 +349,16 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { let instruction = Box::new(AuthorizeCpiBuilderInstruction { __program: program, stake: None, - clock: None, + clock_sysvar: None, authority: None, - new_authority: None, - stake_authorize: None, + lockup_authority: None, + arg0: None, + arg1: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// The stake account to be updated + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); @@ -323,11 +366,14 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { } /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock = Some(clock); + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// stake's current stake or withdraw authority to change away from. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer + /// Stake or withdraw authority #[inline(always)] pub fn authority( &mut self, @@ -336,14 +382,24 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { self.instruction.authority = Some(authority); self } + /// `[optional account]` + /// Lockup authority + #[inline(always)] + pub fn lockup_authority( + &mut self, + lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self + } #[inline(always)] - pub fn new_authority(&mut self, new_authority: Pubkey) -> &mut Self { - self.instruction.new_authority = Some(new_authority); + pub fn arg0(&mut self, arg0: Pubkey) -> &mut Self { + self.instruction.arg0 = Some(arg0); self } #[inline(always)] - pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { - self.instruction.stake_authorize = Some(stake_authorize); + pub fn arg1(&mut self, arg1: StakeAuthorize) -> &mut Self { + self.instruction.arg1 = Some(arg1); self } /// Add an additional account to the instruction. @@ -388,25 +444,22 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = AuthorizeInstructionArgs { - new_authority: self - .instruction - .new_authority - .clone() - .expect("new_authority is not set"), - stake_authorize: self - .instruction - .stake_authorize - .clone() - .expect("stake_authorize is not set"), + arg0: self.instruction.arg0.clone().expect("arg0 is not set"), + arg1: self.instruction.arg1.clone().expect("arg1 is not set"), }; let instruction = AuthorizeCpi { __program: self.instruction.__program, stake: self.instruction.stake.expect("stake is not set"), - clock: self.instruction.clock.expect("clock is not set"), + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), authority: self.instruction.authority.expect("authority is not set"), + + lockup_authority: self.instruction.lockup_authority, __args: args, }; instruction.invoke_signed_with_remaining_accounts( @@ -420,10 +473,11 @@ impl<'a, 'b> AuthorizeCpiBuilder<'a, 'b> { struct AuthorizeCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock: Option<&'b solana_program::account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - new_authority: Option, - stake_authorize: Option, + lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + arg0: Option, + arg1: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/authorize_checked.rs b/clients/rust/src/generated/instructions/authorize_checked.rs index 328c0cd..0f2412a 100644 --- a/clients/rust/src/generated/instructions/authorize_checked.rs +++ b/clients/rust/src/generated/instructions/authorize_checked.rs @@ -12,14 +12,16 @@ use { /// Accounts. pub struct AuthorizeChecked { - /// The stake account to be updated + /// Stake account to be updated pub stake: solana_program::pubkey::Pubkey, /// Clock sysvar - pub clock: solana_program::pubkey::Pubkey, - /// stake's current stake or withdraw authority to change away from + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// The stake or withdraw authority pub authority: solana_program::pubkey::Pubkey, - /// stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. + /// The new stake or withdraw authority pub new_authority: solana_program::pubkey::Pubkey, + /// Lockup authority + pub lockup_authority: Option, } impl AuthorizeChecked { @@ -35,12 +37,13 @@ impl AuthorizeChecked { args: AuthorizeCheckedInstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.clock, false, + self.clock_sysvar, + false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.authority, @@ -50,13 +53,24 @@ impl AuthorizeChecked { self.new_authority, true, )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + lockup_authority, + true, + )); + } else { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + crate::STAKE_ID, + false, + )); + } accounts.extend_from_slice(remaining_accounts); let mut data = AuthorizeCheckedInstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -65,14 +79,12 @@ impl AuthorizeChecked { #[derive(BorshDeserialize, BorshSerialize)] pub struct AuthorizeCheckedInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl AuthorizeCheckedInstructionData { pub fn new() -> Self { - Self { - discriminator: [147, 97, 67, 26, 230, 107, 45, 242], - } + Self { discriminator: 10 } } } @@ -93,15 +105,17 @@ pub struct AuthorizeCheckedInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` clock +/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) /// 2. `[signer]` authority /// 3. `[signer]` new_authority +/// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeCheckedBuilder { stake: Option, - clock: Option, + clock_sysvar: Option, authority: Option, new_authority: Option, + lockup_authority: Option, stake_authorize: Option, __remaining_accounts: Vec, } @@ -110,30 +124,41 @@ impl AuthorizeCheckedBuilder { pub fn new() -> Self { Self::default() } - /// The stake account to be updated + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock = Some(clock); + pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + self.clock_sysvar = Some(clock_sysvar); self } - /// stake's current stake or withdraw authority to change away from + /// The stake or withdraw authority #[inline(always)] pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } - /// stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. + /// The new stake or withdraw authority #[inline(always)] pub fn new_authority(&mut self, new_authority: solana_program::pubkey::Pubkey) -> &mut Self { self.new_authority = Some(new_authority); self } + /// `[optional account]` + /// Lockup authority + #[inline(always)] + pub fn lockup_authority( + &mut self, + lockup_authority: Option, + ) -> &mut Self { + self.lockup_authority = lockup_authority; + self + } #[inline(always)] pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.stake_authorize = Some(stake_authorize); @@ -161,9 +186,12 @@ impl AuthorizeCheckedBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = AuthorizeChecked { stake: self.stake.expect("stake is not set"), - clock: self.clock.expect("clock is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), authority: self.authority.expect("authority is not set"), new_authority: self.new_authority.expect("new_authority is not set"), + lockup_authority: self.lockup_authority, }; let args = AuthorizeCheckedInstructionArgs { stake_authorize: self @@ -178,28 +206,32 @@ impl AuthorizeCheckedBuilder { /// `authorize_checked` CPI accounts. pub struct AuthorizeCheckedCpiAccounts<'a, 'b> { - /// The stake account to be updated + /// Stake account to be updated pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's current stake or withdraw authority to change away from + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. + /// The new stake or withdraw authority pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } /// `authorize_checked` CPI instruction. pub struct AuthorizeCheckedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to be updated + /// Stake account to be updated pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's current stake or withdraw authority to change away from + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. + /// The new stake or withdraw authority pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeCheckedInstructionArgs, } @@ -213,9 +245,10 @@ impl<'a, 'b> AuthorizeCheckedCpi<'a, 'b> { Self { __program: program, stake: accounts.stake, - clock: accounts.clock, + clock_sysvar: accounts.clock_sysvar, authority: accounts.authority, new_authority: accounts.new_authority, + lockup_authority: accounts.lockup_authority, __args: args, } } @@ -252,13 +285,13 @@ impl<'a, 'b> AuthorizeCheckedCpi<'a, 'b> { bool, )], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.clock.key, + *self.clock_sysvar.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -269,6 +302,17 @@ impl<'a, 'b> AuthorizeCheckedCpi<'a, 'b> { *self.new_authority.key, true, )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *lockup_authority.key, + true, + )); + } else { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + crate::STAKE_ID, + false, + )); + } remaining_accounts.iter().for_each(|remaining_account| { accounts.push(solana_program::instruction::AccountMeta { pubkey: *remaining_account.0.key, @@ -281,16 +325,19 @@ impl<'a, 'b> AuthorizeCheckedCpi<'a, 'b> { data.append(&mut args); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); + let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); - account_infos.push(self.clock.clone()); + account_infos.push(self.clock_sysvar.clone()); account_infos.push(self.authority.clone()); account_infos.push(self.new_authority.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); + } remaining_accounts .iter() .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); @@ -308,9 +355,10 @@ impl<'a, 'b> AuthorizeCheckedCpi<'a, 'b> { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` clock +/// 1. `[]` clock_sysvar /// 2. `[signer]` authority /// 3. `[signer]` new_authority +/// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct AuthorizeCheckedCpiBuilder<'a, 'b> { instruction: Box>, @@ -321,15 +369,16 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { let instruction = Box::new(AuthorizeCheckedCpiBuilderInstruction { __program: program, stake: None, - clock: None, + clock_sysvar: None, authority: None, new_authority: None, + lockup_authority: None, stake_authorize: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// The stake account to be updated + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); @@ -337,11 +386,14 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { } /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock = Some(clock); + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// stake's current stake or withdraw authority to change away from + /// The stake or withdraw authority #[inline(always)] pub fn authority( &mut self, @@ -350,7 +402,7 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { self.instruction.authority = Some(authority); self } - /// stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. + /// The new stake or withdraw authority #[inline(always)] pub fn new_authority( &mut self, @@ -359,6 +411,16 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { self.instruction.new_authority = Some(new_authority); self } + /// `[optional account]` + /// Lockup authority + #[inline(always)] + pub fn lockup_authority( + &mut self, + lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self + } #[inline(always)] pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.instruction.stake_authorize = Some(stake_authorize); @@ -417,7 +479,10 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { stake: self.instruction.stake.expect("stake is not set"), - clock: self.instruction.clock.expect("clock is not set"), + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), authority: self.instruction.authority.expect("authority is not set"), @@ -425,6 +490,8 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { .instruction .new_authority .expect("new_authority is not set"), + + lockup_authority: self.instruction.lockup_authority, __args: args, }; instruction.invoke_signed_with_remaining_accounts( @@ -438,9 +505,10 @@ impl<'a, 'b> AuthorizeCheckedCpiBuilder<'a, 'b> { struct AuthorizeCheckedCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock: Option<&'b solana_program::account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_authorize: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( diff --git a/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs b/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs index b13f94f..7ad9a80 100644 --- a/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_checked_with_seed.rs @@ -13,14 +13,16 @@ use { /// Accounts. pub struct AuthorizeCheckedWithSeed { - /// The stake account to be updated + /// Stake account to be updated pub stake: solana_program::pubkey::Pubkey, - /// Base account of stake's authority to be updated - pub authority_base: solana_program::pubkey::Pubkey, + /// Base key of stake or withdraw authority + pub base: solana_program::pubkey::Pubkey, /// Clock sysvar - pub clock: solana_program::pubkey::Pubkey, - /// stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// The new stake or withdraw authority pub new_authority: solana_program::pubkey::Pubkey, + /// Lockup authority + pub lockup_authority: Option, } impl AuthorizeCheckedWithSeed { @@ -36,21 +38,32 @@ impl AuthorizeCheckedWithSeed { args: AuthorizeCheckedWithSeedInstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.authority_base, - true, + self.base, true, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.clock, false, + self.clock_sysvar, + false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.new_authority, true, )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + lockup_authority, + true, + )); + } else { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + crate::STAKE_ID, + false, + )); + } accounts.extend_from_slice(remaining_accounts); let mut data = AuthorizeCheckedWithSeedInstructionData::new() .try_to_vec() @@ -59,7 +72,7 @@ impl AuthorizeCheckedWithSeed { data.append(&mut args); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -68,14 +81,12 @@ impl AuthorizeCheckedWithSeed { #[derive(BorshDeserialize, BorshSerialize)] pub struct AuthorizeCheckedWithSeedInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl AuthorizeCheckedWithSeedInstructionData { pub fn new() -> Self { - Self { - discriminator: [14, 230, 154, 165, 225, 209, 194, 210], - } + Self { discriminator: 11 } } } @@ -98,15 +109,17 @@ pub struct AuthorizeCheckedWithSeedInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[signer]` authority_base -/// 2. `[]` clock +/// 1. `[signer]` base +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) /// 3. `[signer]` new_authority +/// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeCheckedWithSeedBuilder { stake: Option, - authority_base: Option, - clock: Option, + base: Option, + clock_sysvar: Option, new_authority: Option, + lockup_authority: Option, stake_authorize: Option, authority_seed: Option, authority_owner: Option, @@ -117,30 +130,41 @@ impl AuthorizeCheckedWithSeedBuilder { pub fn new() -> Self { Self::default() } - /// The stake account to be updated + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } - /// Base account of stake's authority to be updated + /// Base key of stake or withdraw authority #[inline(always)] - pub fn authority_base(&mut self, authority_base: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority_base = Some(authority_base); + pub fn base(&mut self, base: solana_program::pubkey::Pubkey) -> &mut Self { + self.base = Some(base); self } + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock = Some(clock); + pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + self.clock_sysvar = Some(clock_sysvar); self } - /// stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. + /// The new stake or withdraw authority #[inline(always)] pub fn new_authority(&mut self, new_authority: solana_program::pubkey::Pubkey) -> &mut Self { self.new_authority = Some(new_authority); self } + /// `[optional account]` + /// Lockup authority + #[inline(always)] + pub fn lockup_authority( + &mut self, + lockup_authority: Option, + ) -> &mut Self { + self.lockup_authority = lockup_authority; + self + } #[inline(always)] pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.stake_authorize = Some(stake_authorize); @@ -178,9 +202,12 @@ impl AuthorizeCheckedWithSeedBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = AuthorizeCheckedWithSeed { stake: self.stake.expect("stake is not set"), - authority_base: self.authority_base.expect("authority_base is not set"), - clock: self.clock.expect("clock is not set"), + base: self.base.expect("base is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), new_authority: self.new_authority.expect("new_authority is not set"), + lockup_authority: self.lockup_authority, }; let args = AuthorizeCheckedWithSeedInstructionArgs { stake_authorize: self @@ -203,28 +230,32 @@ impl AuthorizeCheckedWithSeedBuilder { /// `authorize_checked_with_seed` CPI accounts. pub struct AuthorizeCheckedWithSeedCpiAccounts<'a, 'b> { - /// The stake account to be updated + /// Stake account to be updated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Base account of stake's authority to be updated - pub authority_base: &'b solana_program::account_info::AccountInfo<'a>, + /// Base key of stake or withdraw authority + pub base: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The new stake or withdraw authority pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } /// `authorize_checked_with_seed` CPI instruction. pub struct AuthorizeCheckedWithSeedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to be updated + /// Stake account to be updated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Base account of stake's authority to be updated - pub authority_base: &'b solana_program::account_info::AccountInfo<'a>, + /// Base key of stake or withdraw authority + pub base: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The new stake or withdraw authority pub new_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeCheckedWithSeedInstructionArgs, } @@ -238,9 +269,10 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { Self { __program: program, stake: accounts.stake, - authority_base: accounts.authority_base, - clock: accounts.clock, + base: accounts.base, + clock_sysvar: accounts.clock_sysvar, new_authority: accounts.new_authority, + lockup_authority: accounts.lockup_authority, __args: args, } } @@ -277,23 +309,34 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { bool, )], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); + let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.authority_base.key, + *self.base.key, true, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.clock.key, + *self.clock_sysvar.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( *self.new_authority.key, true, )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *lockup_authority.key, + true, + )); + } else { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + crate::STAKE_ID, + false, + )); + } remaining_accounts.iter().for_each(|remaining_account| { accounts.push(solana_program::instruction::AccountMeta { pubkey: *remaining_account.0.key, @@ -308,16 +351,19 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { data.append(&mut args); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; - let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); + let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); - account_infos.push(self.authority_base.clone()); - account_infos.push(self.clock.clone()); + account_infos.push(self.base.clone()); + account_infos.push(self.clock_sysvar.clone()); account_infos.push(self.new_authority.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); + } remaining_accounts .iter() .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); @@ -335,9 +381,10 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpi<'a, 'b> { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[signer]` authority_base -/// 2. `[]` clock +/// 1. `[signer]` base +/// 2. `[]` clock_sysvar /// 3. `[signer]` new_authority +/// 4. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { instruction: Box>, @@ -348,9 +395,10 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { let instruction = Box::new(AuthorizeCheckedWithSeedCpiBuilderInstruction { __program: program, stake: None, - authority_base: None, - clock: None, + base: None, + clock_sysvar: None, new_authority: None, + lockup_authority: None, stake_authorize: None, authority_seed: None, authority_owner: None, @@ -358,28 +406,28 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { }); Self { instruction } } - /// The stake account to be updated + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Base account of stake's authority to be updated + /// Base key of stake or withdraw authority #[inline(always)] - pub fn authority_base( - &mut self, - authority_base: &'b solana_program::account_info::AccountInfo<'a>, - ) -> &mut Self { - self.instruction.authority_base = Some(authority_base); + pub fn base(&mut self, base: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.base = Some(base); self } /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock = Some(clock); + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// stake's new stake or withdraw authority to change to. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. + /// The new stake or withdraw authority #[inline(always)] pub fn new_authority( &mut self, @@ -388,6 +436,16 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { self.instruction.new_authority = Some(new_authority); self } + /// `[optional account]` + /// Lockup authority + #[inline(always)] + pub fn lockup_authority( + &mut self, + lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self + } #[inline(always)] pub fn stake_authorize(&mut self, stake_authorize: StakeAuthorize) -> &mut Self { self.instruction.stake_authorize = Some(stake_authorize); @@ -466,17 +524,19 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { stake: self.instruction.stake.expect("stake is not set"), - authority_base: self - .instruction - .authority_base - .expect("authority_base is not set"), + base: self.instruction.base.expect("base is not set"), - clock: self.instruction.clock.expect("clock is not set"), + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), new_authority: self .instruction .new_authority .expect("new_authority is not set"), + + lockup_authority: self.instruction.lockup_authority, __args: args, }; instruction.invoke_signed_with_remaining_accounts( @@ -490,9 +550,10 @@ impl<'a, 'b> AuthorizeCheckedWithSeedCpiBuilder<'a, 'b> { struct AuthorizeCheckedWithSeedCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority_base: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock: Option<&'b solana_program::account_info::AccountInfo<'a>>, + base: Option<&'b solana_program::account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_authorize: Option, authority_seed: Option, authority_owner: Option, diff --git a/clients/rust/src/generated/instructions/authorize_with_seed.rs b/clients/rust/src/generated/instructions/authorize_with_seed.rs index bdfc8a6..4ac8e97 100644 --- a/clients/rust/src/generated/instructions/authorize_with_seed.rs +++ b/clients/rust/src/generated/instructions/authorize_with_seed.rs @@ -13,12 +13,14 @@ use { /// Accounts. pub struct AuthorizeWithSeed { - /// The stake account to be updated, with the authority to be updated being an account created with Pubkey::create_with_seed() + /// Stake account to be updated pub stake: solana_program::pubkey::Pubkey, - /// Base account of stake's authority to be updated - pub authority_base: solana_program::pubkey::Pubkey, - /// Clock sysvar. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. - pub clock: solana_program::pubkey::Pubkey, + /// Base key of stake or withdraw authority + pub base: solana_program::pubkey::Pubkey, + /// Clock sysvar + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// Lockup authority + pub lockup_authority: Option, } impl AuthorizeWithSeed { @@ -34,17 +36,28 @@ impl AuthorizeWithSeed { args: AuthorizeWithSeedInstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.authority_base, - true, + self.base, true, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.clock, false, + self.clock_sysvar, + false, )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + lockup_authority, + true, + )); + } else { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + crate::STAKE_ID, + false, + )); + } accounts.extend_from_slice(remaining_accounts); let mut data = AuthorizeWithSeedInstructionData::new() .try_to_vec() @@ -53,7 +66,7 @@ impl AuthorizeWithSeed { data.append(&mut args); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -62,14 +75,12 @@ impl AuthorizeWithSeed { #[derive(BorshDeserialize, BorshSerialize)] pub struct AuthorizeWithSeedInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl AuthorizeWithSeedInstructionData { pub fn new() -> Self { - Self { - discriminator: [7, 18, 211, 41, 76, 83, 115, 61], - } + Self { discriminator: 8 } } } @@ -82,7 +93,7 @@ impl Default for AuthorizeWithSeedInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthorizeWithSeedInstructionArgs { - pub new_authority: Pubkey, + pub new_authorized_pubkey: Pubkey, pub stake_authorize: StakeAuthorize, pub authority_seed: String, pub authority_owner: Pubkey, @@ -93,14 +104,16 @@ pub struct AuthorizeWithSeedInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[signer]` authority_base -/// 2. `[]` clock +/// 1. `[signer]` base +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) +/// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct AuthorizeWithSeedBuilder { stake: Option, - authority_base: Option, - clock: Option, - new_authority: Option, + base: Option, + clock_sysvar: Option, + lockup_authority: Option, + new_authorized_pubkey: Option, stake_authorize: Option, authority_seed: Option, authority_owner: Option, @@ -111,27 +124,38 @@ impl AuthorizeWithSeedBuilder { pub fn new() -> Self { Self::default() } - /// The stake account to be updated, with the authority to be updated being an account created with Pubkey::create_with_seed() + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } - /// Base account of stake's authority to be updated + /// Base key of stake or withdraw authority #[inline(always)] - pub fn authority_base(&mut self, authority_base: solana_program::pubkey::Pubkey) -> &mut Self { - self.authority_base = Some(authority_base); + pub fn base(&mut self, base: solana_program::pubkey::Pubkey) -> &mut Self { + self.base = Some(base); self } - /// Clock sysvar. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` + /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock = Some(clock); + pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + self.clock_sysvar = Some(clock_sysvar); + self + } + /// `[optional account]` + /// Lockup authority + #[inline(always)] + pub fn lockup_authority( + &mut self, + lockup_authority: Option, + ) -> &mut Self { + self.lockup_authority = lockup_authority; self } #[inline(always)] - pub fn new_authority(&mut self, new_authority: Pubkey) -> &mut Self { - self.new_authority = Some(new_authority); + pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { + self.new_authorized_pubkey = Some(new_authorized_pubkey); self } #[inline(always)] @@ -171,14 +195,17 @@ impl AuthorizeWithSeedBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = AuthorizeWithSeed { stake: self.stake.expect("stake is not set"), - authority_base: self.authority_base.expect("authority_base is not set"), - clock: self.clock.expect("clock is not set"), + base: self.base.expect("base is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), + lockup_authority: self.lockup_authority, }; let args = AuthorizeWithSeedInstructionArgs { - new_authority: self - .new_authority + new_authorized_pubkey: self + .new_authorized_pubkey .clone() - .expect("new_authority is not set"), + .expect("new_authorized_pubkey is not set"), stake_authorize: self .stake_authorize .clone() @@ -199,24 +226,28 @@ impl AuthorizeWithSeedBuilder { /// `authorize_with_seed` CPI accounts. pub struct AuthorizeWithSeedCpiAccounts<'a, 'b> { - /// The stake account to be updated, with the authority to be updated being an account created with Pubkey::create_with_seed() + /// Stake account to be updated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Base account of stake's authority to be updated - pub authority_base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. - pub clock: &'b solana_program::account_info::AccountInfo<'a>, + /// Base key of stake or withdraw authority + pub base: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } /// `authorize_with_seed` CPI instruction. pub struct AuthorizeWithSeedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to be updated, with the authority to be updated being an account created with Pubkey::create_with_seed() + /// Stake account to be updated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Base account of stake's authority to be updated - pub authority_base: &'b solana_program::account_info::AccountInfo<'a>, - /// Clock sysvar. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. - pub clock: &'b solana_program::account_info::AccountInfo<'a>, + /// Base key of stake or withdraw authority + pub base: &'b solana_program::account_info::AccountInfo<'a>, + /// Clock sysvar + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: AuthorizeWithSeedInstructionArgs, } @@ -230,8 +261,9 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { Self { __program: program, stake: accounts.stake, - authority_base: accounts.authority_base, - clock: accounts.clock, + base: accounts.base, + clock_sysvar: accounts.clock_sysvar, + lockup_authority: accounts.lockup_authority, __args: args, } } @@ -268,19 +300,30 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { bool, )], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + let mut accounts = Vec::with_capacity(4 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.authority_base.key, + *self.base.key, true, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.clock.key, + *self.clock_sysvar.key, false, )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *lockup_authority.key, + true, + )); + } else { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + crate::STAKE_ID, + false, + )); + } remaining_accounts.iter().for_each(|remaining_account| { accounts.push(solana_program::instruction::AccountMeta { pubkey: *remaining_account.0.key, @@ -295,15 +338,18 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { data.append(&mut args); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; - let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); - account_infos.push(self.authority_base.clone()); - account_infos.push(self.clock.clone()); + account_infos.push(self.base.clone()); + account_infos.push(self.clock_sysvar.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); + } remaining_accounts .iter() .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); @@ -321,8 +367,9 @@ impl<'a, 'b> AuthorizeWithSeedCpi<'a, 'b> { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[signer]` authority_base -/// 2. `[]` clock +/// 1. `[signer]` base +/// 2. `[]` clock_sysvar +/// 3. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct AuthorizeWithSeedCpiBuilder<'a, 'b> { instruction: Box>, @@ -333,9 +380,10 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { let instruction = Box::new(AuthorizeWithSeedCpiBuilderInstruction { __program: program, stake: None, - authority_base: None, - clock: None, - new_authority: None, + base: None, + clock_sysvar: None, + lockup_authority: None, + new_authorized_pubkey: None, stake_authorize: None, authority_seed: None, authority_owner: None, @@ -343,30 +391,40 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { }); Self { instruction } } - /// The stake account to be updated, with the authority to be updated being an account created with Pubkey::create_with_seed() + /// Stake account to be updated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Base account of stake's authority to be updated + /// Base key of stake or withdraw authority + #[inline(always)] + pub fn base(&mut self, base: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.base = Some(base); + self + } + /// Clock sysvar #[inline(always)] - pub fn authority_base( + pub fn clock_sysvar( &mut self, - authority_base: &'b solana_program::account_info::AccountInfo<'a>, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.authority_base = Some(authority_base); + self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// Clock sysvar. If stake Lockup is active, the signing lockup authority must follow if updating withdrawer. + /// `[optional account]` + /// Lockup authority #[inline(always)] - pub fn clock(&mut self, clock: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock = Some(clock); + pub fn lockup_authority( + &mut self, + lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; self } #[inline(always)] - pub fn new_authority(&mut self, new_authority: Pubkey) -> &mut Self { - self.instruction.new_authority = Some(new_authority); + pub fn new_authorized_pubkey(&mut self, new_authorized_pubkey: Pubkey) -> &mut Self { + self.instruction.new_authorized_pubkey = Some(new_authorized_pubkey); self } #[inline(always)] @@ -426,11 +484,11 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = AuthorizeWithSeedInstructionArgs { - new_authority: self + new_authorized_pubkey: self .instruction - .new_authority + .new_authorized_pubkey .clone() - .expect("new_authority is not set"), + .expect("new_authorized_pubkey is not set"), stake_authorize: self .instruction .stake_authorize @@ -452,12 +510,14 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { stake: self.instruction.stake.expect("stake is not set"), - authority_base: self + base: self.instruction.base.expect("base is not set"), + + clock_sysvar: self .instruction - .authority_base - .expect("authority_base is not set"), + .clock_sysvar + .expect("clock_sysvar is not set"), - clock: self.instruction.clock.expect("clock is not set"), + lockup_authority: self.instruction.lockup_authority, __args: args, }; instruction.invoke_signed_with_remaining_accounts( @@ -471,9 +531,10 @@ impl<'a, 'b> AuthorizeWithSeedCpiBuilder<'a, 'b> { struct AuthorizeWithSeedCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - authority_base: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock: Option<&'b solana_program::account_info::AccountInfo<'a>>, - new_authority: Option, + base: Option<&'b solana_program::account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, + lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + new_authorized_pubkey: Option, stake_authorize: Option, authority_seed: Option, authority_owner: Option, diff --git a/clients/rust/src/generated/instructions/deactivate.rs b/clients/rust/src/generated/instructions/deactivate.rs index 20c6ffa..988752a 100644 --- a/clients/rust/src/generated/instructions/deactivate.rs +++ b/clients/rust/src/generated/instructions/deactivate.rs @@ -9,11 +9,11 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. pub struct Deactivate { - /// The stake account to deactivate + /// Delegated stake account pub stake: solana_program::pubkey::Pubkey, /// Clock sysvar - pub clock: solana_program::pubkey::Pubkey, - /// stake's stake authority + pub clock_sysvar: solana_program::pubkey::Pubkey, + /// Stake authority pub stake_authority: solana_program::pubkey::Pubkey, } @@ -31,7 +31,8 @@ impl Deactivate { self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.clock, false, + self.clock_sysvar, + false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_authority, @@ -41,7 +42,7 @@ impl Deactivate { let data = DeactivateInstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -50,14 +51,12 @@ impl Deactivate { #[derive(BorshDeserialize, BorshSerialize)] pub struct DeactivateInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl DeactivateInstructionData { pub fn new() -> Self { - Self { - discriminator: [44, 112, 33, 172, 113, 28, 142, 13], - } + Self { discriminator: 5 } } } @@ -72,12 +71,12 @@ impl Default for DeactivateInstructionData { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` clock +/// 1. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct DeactivateBuilder { stake: Option, - clock: Option, + clock_sysvar: Option, stake_authority: Option, __remaining_accounts: Vec, } @@ -86,19 +85,20 @@ impl DeactivateBuilder { pub fn new() -> Self { Self::default() } - /// The stake account to deactivate + /// Delegated stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock = Some(clock); + pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + self.clock_sysvar = Some(clock_sysvar); self } - /// stake's stake authority + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -129,7 +129,9 @@ impl DeactivateBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Deactivate { stake: self.stake.expect("stake is not set"), - clock: self.clock.expect("clock is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; @@ -139,11 +141,11 @@ impl DeactivateBuilder { /// `deactivate` CPI accounts. pub struct DeactivateCpiAccounts<'a, 'b> { - /// The stake account to deactivate + /// Delegated stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's stake authority + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -151,11 +153,11 @@ pub struct DeactivateCpiAccounts<'a, 'b> { pub struct DeactivateCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to deactivate + /// Delegated stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's stake authority + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -167,7 +169,7 @@ impl<'a, 'b> DeactivateCpi<'a, 'b> { Self { __program: program, stake: accounts.stake, - clock: accounts.clock, + clock_sysvar: accounts.clock_sysvar, stake_authority: accounts.stake_authority, } } @@ -210,7 +212,7 @@ impl<'a, 'b> DeactivateCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.clock.key, + *self.clock_sysvar.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -227,14 +229,14 @@ impl<'a, 'b> DeactivateCpi<'a, 'b> { let data = DeactivateInstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); - account_infos.push(self.clock.clone()); + account_infos.push(self.clock_sysvar.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts .iter() @@ -253,7 +255,7 @@ impl<'a, 'b> DeactivateCpi<'a, 'b> { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` clock +/// 1. `[]` clock_sysvar /// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct DeactivateCpiBuilder<'a, 'b> { @@ -265,13 +267,13 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { let instruction = Box::new(DeactivateCpiBuilderInstruction { __program: program, stake: None, - clock: None, + clock_sysvar: None, stake_authority: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// The stake account to deactivate + /// Delegated stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); @@ -279,11 +281,14 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { } /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock = Some(clock); + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); self } - /// stake's stake authority + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -338,7 +343,10 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { stake: self.instruction.stake.expect("stake is not set"), - clock: self.instruction.clock.expect("clock is not set"), + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), stake_authority: self .instruction @@ -356,7 +364,7 @@ impl<'a, 'b> DeactivateCpiBuilder<'a, 'b> { struct DeactivateCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock: Option<&'b solana_program::account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( diff --git a/clients/rust/src/generated/instructions/deactivate_delinquent.rs b/clients/rust/src/generated/instructions/deactivate_delinquent.rs index 28814d2..3a5bc02 100644 --- a/clients/rust/src/generated/instructions/deactivate_delinquent.rs +++ b/clients/rust/src/generated/instructions/deactivate_delinquent.rs @@ -9,11 +9,11 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. pub struct DeactivateDelinquent { - /// The delinquent stake account to deactivate + /// Delegated stake account pub stake: solana_program::pubkey::Pubkey, - /// stake's delinquent vote account - pub vote: solana_program::pubkey::Pubkey, - /// Reference vote account that has voted at least once in the last MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION epochs + /// Delinquent vote account + pub delinquent_vote: solana_program::pubkey::Pubkey, + /// Reference vote account pub reference_vote: solana_program::pubkey::Pubkey, } @@ -31,7 +31,8 @@ impl DeactivateDelinquent { self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.vote, false, + self.delinquent_vote, + false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.reference_vote, @@ -43,7 +44,7 @@ impl DeactivateDelinquent { .unwrap(); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -52,14 +53,12 @@ impl DeactivateDelinquent { #[derive(BorshDeserialize, BorshSerialize)] pub struct DeactivateDelinquentInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl DeactivateDelinquentInstructionData { pub fn new() -> Self { - Self { - discriminator: [6, 113, 198, 138, 228, 163, 159, 221], - } + Self { discriminator: 14 } } } @@ -74,12 +73,12 @@ impl Default for DeactivateDelinquentInstructionData { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` vote +/// 1. `[]` delinquent_vote /// 2. `[]` reference_vote #[derive(Clone, Debug, Default)] pub struct DeactivateDelinquentBuilder { stake: Option, - vote: Option, + delinquent_vote: Option, reference_vote: Option, __remaining_accounts: Vec, } @@ -88,19 +87,22 @@ impl DeactivateDelinquentBuilder { pub fn new() -> Self { Self::default() } - /// The delinquent stake account to deactivate + /// Delegated stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } - /// stake's delinquent vote account + /// Delinquent vote account #[inline(always)] - pub fn vote(&mut self, vote: solana_program::pubkey::Pubkey) -> &mut Self { - self.vote = Some(vote); + pub fn delinquent_vote( + &mut self, + delinquent_vote: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.delinquent_vote = Some(delinquent_vote); self } - /// Reference vote account that has voted at least once in the last MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION epochs + /// Reference vote account #[inline(always)] pub fn reference_vote(&mut self, reference_vote: solana_program::pubkey::Pubkey) -> &mut Self { self.reference_vote = Some(reference_vote); @@ -128,7 +130,7 @@ impl DeactivateDelinquentBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = DeactivateDelinquent { stake: self.stake.expect("stake is not set"), - vote: self.vote.expect("vote is not set"), + delinquent_vote: self.delinquent_vote.expect("delinquent_vote is not set"), reference_vote: self.reference_vote.expect("reference_vote is not set"), }; @@ -138,11 +140,11 @@ impl DeactivateDelinquentBuilder { /// `deactivate_delinquent` CPI accounts. pub struct DeactivateDelinquentCpiAccounts<'a, 'b> { - /// The delinquent stake account to deactivate + /// Delegated stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's delinquent vote account - pub vote: &'b solana_program::account_info::AccountInfo<'a>, - /// Reference vote account that has voted at least once in the last MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION epochs + /// Delinquent vote account + pub delinquent_vote: &'b solana_program::account_info::AccountInfo<'a>, + /// Reference vote account pub reference_vote: &'b solana_program::account_info::AccountInfo<'a>, } @@ -150,11 +152,11 @@ pub struct DeactivateDelinquentCpiAccounts<'a, 'b> { pub struct DeactivateDelinquentCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The delinquent stake account to deactivate + /// Delegated stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's delinquent vote account - pub vote: &'b solana_program::account_info::AccountInfo<'a>, - /// Reference vote account that has voted at least once in the last MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION epochs + /// Delinquent vote account + pub delinquent_vote: &'b solana_program::account_info::AccountInfo<'a>, + /// Reference vote account pub reference_vote: &'b solana_program::account_info::AccountInfo<'a>, } @@ -166,7 +168,7 @@ impl<'a, 'b> DeactivateDelinquentCpi<'a, 'b> { Self { __program: program, stake: accounts.stake, - vote: accounts.vote, + delinquent_vote: accounts.delinquent_vote, reference_vote: accounts.reference_vote, } } @@ -209,7 +211,7 @@ impl<'a, 'b> DeactivateDelinquentCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.vote.key, + *self.delinquent_vote.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -228,14 +230,14 @@ impl<'a, 'b> DeactivateDelinquentCpi<'a, 'b> { .unwrap(); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); - account_infos.push(self.vote.clone()); + account_infos.push(self.delinquent_vote.clone()); account_infos.push(self.reference_vote.clone()); remaining_accounts .iter() @@ -254,7 +256,7 @@ impl<'a, 'b> DeactivateDelinquentCpi<'a, 'b> { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` vote +/// 1. `[]` delinquent_vote /// 2. `[]` reference_vote #[derive(Clone, Debug)] pub struct DeactivateDelinquentCpiBuilder<'a, 'b> { @@ -266,25 +268,28 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { let instruction = Box::new(DeactivateDelinquentCpiBuilderInstruction { __program: program, stake: None, - vote: None, + delinquent_vote: None, reference_vote: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// The delinquent stake account to deactivate + /// Delegated stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// stake's delinquent vote account + /// Delinquent vote account #[inline(always)] - pub fn vote(&mut self, vote: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.vote = Some(vote); + pub fn delinquent_vote( + &mut self, + delinquent_vote: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.delinquent_vote = Some(delinquent_vote); self } - /// Reference vote account that has voted at least once in the last MINIMUM_DELINQUENT_EPOCHS_FOR_DEACTIVATION epochs + /// Reference vote account #[inline(always)] pub fn reference_vote( &mut self, @@ -339,7 +344,10 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { stake: self.instruction.stake.expect("stake is not set"), - vote: self.instruction.vote.expect("vote is not set"), + delinquent_vote: self + .instruction + .delinquent_vote + .expect("delinquent_vote is not set"), reference_vote: self .instruction @@ -357,7 +365,7 @@ impl<'a, 'b> DeactivateDelinquentCpiBuilder<'a, 'b> { struct DeactivateDelinquentCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - vote: Option<&'b solana_program::account_info::AccountInfo<'a>>, + delinquent_vote: Option<&'b solana_program::account_info::AccountInfo<'a>>, reference_vote: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( diff --git a/clients/rust/src/generated/instructions/delegate_stake.rs b/clients/rust/src/generated/instructions/delegate_stake.rs index 9e3a081..40104fb 100644 --- a/clients/rust/src/generated/instructions/delegate_stake.rs +++ b/clients/rust/src/generated/instructions/delegate_stake.rs @@ -9,17 +9,17 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. pub struct DelegateStake { - /// The stake account to be delegated + /// Initialized stake account to be delegated pub stake: solana_program::pubkey::Pubkey, - /// Vote account to which stake will be delegated + /// Vote account to which this stake will be delegated pub vote: solana_program::pubkey::Pubkey, /// Clock sysvar - pub clock: solana_program::pubkey::Pubkey, + pub clock_sysvar: solana_program::pubkey::Pubkey, /// Stake history sysvar pub stake_history: solana_program::pubkey::Pubkey, - /// Stake config native program - pub stake_config: solana_program::pubkey::Pubkey, - /// stake's stake authority + /// Unused account, formerly the stake config + pub unused: solana_program::pubkey::Pubkey, + /// Stake authority pub stake_authority: solana_program::pubkey::Pubkey, } @@ -40,14 +40,15 @@ impl DelegateStake { self.vote, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.clock, false, + self.clock_sysvar, + false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_history, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.stake_config, + self.unused, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -58,7 +59,7 @@ impl DelegateStake { let data = DelegateStakeInstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -67,14 +68,12 @@ impl DelegateStake { #[derive(BorshDeserialize, BorshSerialize)] pub struct DelegateStakeInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl DelegateStakeInstructionData { pub fn new() -> Self { - Self { - discriminator: [50, 110, 95, 179, 194, 75, 140, 246], - } + Self { discriminator: 2 } } } @@ -90,17 +89,17 @@ impl Default for DelegateStakeInstructionData { /// /// 0. `[writable]` stake /// 1. `[]` vote -/// 2. `[]` clock +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) /// 3. `[]` stake_history -/// 4. `[]` stake_config +/// 4. `[]` unused /// 5. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct DelegateStakeBuilder { stake: Option, vote: Option, - clock: Option, + clock_sysvar: Option, stake_history: Option, - stake_config: Option, + unused: Option, stake_authority: Option, __remaining_accounts: Vec, } @@ -109,22 +108,23 @@ impl DelegateStakeBuilder { pub fn new() -> Self { Self::default() } - /// The stake account to be delegated + /// Initialized stake account to be delegated #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } - /// Vote account to which stake will be delegated + /// Vote account to which this stake will be delegated #[inline(always)] pub fn vote(&mut self, vote: solana_program::pubkey::Pubkey) -> &mut Self { self.vote = Some(vote); self } + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock = Some(clock); + pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + self.clock_sysvar = Some(clock_sysvar); self } /// Stake history sysvar @@ -133,13 +133,13 @@ impl DelegateStakeBuilder { self.stake_history = Some(stake_history); self } - /// Stake config native program + /// Unused account, formerly the stake config #[inline(always)] - pub fn stake_config(&mut self, stake_config: solana_program::pubkey::Pubkey) -> &mut Self { - self.stake_config = Some(stake_config); + pub fn unused(&mut self, unused: solana_program::pubkey::Pubkey) -> &mut Self { + self.unused = Some(unused); self } - /// stake's stake authority + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -171,9 +171,11 @@ impl DelegateStakeBuilder { let accounts = DelegateStake { stake: self.stake.expect("stake is not set"), vote: self.vote.expect("vote is not set"), - clock: self.clock.expect("clock is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), stake_history: self.stake_history.expect("stake_history is not set"), - stake_config: self.stake_config.expect("stake_config is not set"), + unused: self.unused.expect("unused is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; @@ -183,17 +185,17 @@ impl DelegateStakeBuilder { /// `delegate_stake` CPI accounts. pub struct DelegateStakeCpiAccounts<'a, 'b> { - /// The stake account to be delegated + /// Initialized stake account to be delegated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Vote account to which stake will be delegated + /// Vote account to which this stake will be delegated pub vote: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// Stake history sysvar pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake config native program - pub stake_config: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's stake authority + /// Unused account, formerly the stake config + pub unused: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -201,17 +203,17 @@ pub struct DelegateStakeCpiAccounts<'a, 'b> { pub struct DelegateStakeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to be delegated + /// Initialized stake account to be delegated pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// Vote account to which stake will be delegated + /// Vote account to which this stake will be delegated pub vote: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// Stake history sysvar pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, - /// Stake config native program - pub stake_config: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's stake authority + /// Unused account, formerly the stake config + pub unused: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -224,9 +226,9 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { __program: program, stake: accounts.stake, vote: accounts.vote, - clock: accounts.clock, + clock_sysvar: accounts.clock_sysvar, stake_history: accounts.stake_history, - stake_config: accounts.stake_config, + unused: accounts.unused, stake_authority: accounts.stake_authority, } } @@ -273,7 +275,7 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.clock.key, + *self.clock_sysvar.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -281,7 +283,7 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.stake_config.key, + *self.unused.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -298,7 +300,7 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { let data = DelegateStakeInstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; @@ -306,9 +308,9 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); account_infos.push(self.vote.clone()); - account_infos.push(self.clock.clone()); + account_infos.push(self.clock_sysvar.clone()); account_infos.push(self.stake_history.clone()); - account_infos.push(self.stake_config.clone()); + account_infos.push(self.unused.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts .iter() @@ -328,9 +330,9 @@ impl<'a, 'b> DelegateStakeCpi<'a, 'b> { /// /// 0. `[writable]` stake /// 1. `[]` vote -/// 2. `[]` clock +/// 2. `[]` clock_sysvar /// 3. `[]` stake_history -/// 4. `[]` stake_config +/// 4. `[]` unused /// 5. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct DelegateStakeCpiBuilder<'a, 'b> { @@ -343,21 +345,21 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { __program: program, stake: None, vote: None, - clock: None, + clock_sysvar: None, stake_history: None, - stake_config: None, + unused: None, stake_authority: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// The stake account to be delegated + /// Initialized stake account to be delegated #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// Vote account to which stake will be delegated + /// Vote account to which this stake will be delegated #[inline(always)] pub fn vote(&mut self, vote: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.vote = Some(vote); @@ -365,8 +367,11 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { } /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock = Some(clock); + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); self } /// Stake history sysvar @@ -378,16 +383,16 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { self.instruction.stake_history = Some(stake_history); self } - /// Stake config native program + /// Unused account, formerly the stake config #[inline(always)] - pub fn stake_config( + pub fn unused( &mut self, - stake_config: &'b solana_program::account_info::AccountInfo<'a>, + unused: &'b solana_program::account_info::AccountInfo<'a>, ) -> &mut Self { - self.instruction.stake_config = Some(stake_config); + self.instruction.unused = Some(unused); self } - /// stake's stake authority + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -444,17 +449,17 @@ impl<'a, 'b> DelegateStakeCpiBuilder<'a, 'b> { vote: self.instruction.vote.expect("vote is not set"), - clock: self.instruction.clock.expect("clock is not set"), + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), stake_history: self .instruction .stake_history .expect("stake_history is not set"), - stake_config: self - .instruction - .stake_config - .expect("stake_config is not set"), + unused: self.instruction.unused.expect("unused is not set"), stake_authority: self .instruction @@ -473,9 +478,9 @@ struct DelegateStakeCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, vote: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock: Option<&'b solana_program::account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_history: Option<&'b solana_program::account_info::AccountInfo<'a>>, - stake_config: Option<&'b solana_program::account_info::AccountInfo<'a>>, + unused: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( diff --git a/clients/rust/src/generated/instructions/get_minimum_delegation.rs b/clients/rust/src/generated/instructions/get_minimum_delegation.rs index 977de9a..869e558 100644 --- a/clients/rust/src/generated/instructions/get_minimum_delegation.rs +++ b/clients/rust/src/generated/instructions/get_minimum_delegation.rs @@ -26,7 +26,7 @@ impl GetMinimumDelegation { .unwrap(); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -35,14 +35,12 @@ impl GetMinimumDelegation { #[derive(BorshDeserialize, BorshSerialize)] pub struct GetMinimumDelegationInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl GetMinimumDelegationInstructionData { pub fn new() -> Self { - Self { - discriminator: [197, 65, 7, 73, 151, 105, 133, 105], - } + Self { discriminator: 13 } } } @@ -147,7 +145,7 @@ impl<'a, 'b> GetMinimumDelegationCpi<'a, 'b> { .unwrap(); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; diff --git a/clients/rust/src/generated/instructions/initialize.rs b/clients/rust/src/generated/instructions/initialize.rs index dc1fd2d..9718623 100644 --- a/clients/rust/src/generated/instructions/initialize.rs +++ b/clients/rust/src/generated/instructions/initialize.rs @@ -6,16 +6,16 @@ //! use { + crate::generated::types::{Authorized, Lockup}, borsh::{BorshDeserialize, BorshSerialize}, - solana_program::pubkey::Pubkey, }; /// Accounts. pub struct Initialize { - /// The stake account to initialize + /// Uninitialized stake account pub stake: solana_program::pubkey::Pubkey, /// Rent sysvar - pub rent: solana_program::pubkey::Pubkey, + pub rent_sysvar: solana_program::pubkey::Pubkey, } impl Initialize { @@ -36,7 +36,8 @@ impl Initialize { self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.rent, false, + self.rent_sysvar, + false, )); accounts.extend_from_slice(remaining_accounts); let mut data = InitializeInstructionData::new().try_to_vec().unwrap(); @@ -44,7 +45,7 @@ impl Initialize { data.append(&mut args); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -53,14 +54,12 @@ impl Initialize { #[derive(BorshDeserialize, BorshSerialize)] pub struct InitializeInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl InitializeInstructionData { pub fn new() -> Self { - Self { - discriminator: [175, 175, 109, 31, 13, 152, 155, 237], - } + Self { discriminator: 0 } } } @@ -73,11 +72,8 @@ impl Default for InitializeInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InitializeInstructionArgs { - pub staker: Pubkey, - pub withdrawer: Pubkey, - pub unix_timestamp: i64, - pub epoch: u64, - pub custodian: Pubkey, + pub arg0: Authorized, + pub arg1: Lockup, } /// Instruction builder for `Initialize`. @@ -85,16 +81,13 @@ pub struct InitializeInstructionArgs { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) +/// 1. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) #[derive(Clone, Debug, Default)] pub struct InitializeBuilder { stake: Option, - rent: Option, - staker: Option, - withdrawer: Option, - unix_timestamp: Option, - epoch: Option, - custodian: Option, + rent_sysvar: Option, + arg0: Option, + arg1: Option, __remaining_accounts: Vec, } @@ -102,7 +95,7 @@ impl InitializeBuilder { pub fn new() -> Self { Self::default() } - /// The stake account to initialize + /// Uninitialized stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); @@ -111,33 +104,18 @@ impl InitializeBuilder { /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` /// Rent sysvar #[inline(always)] - pub fn rent(&mut self, rent: solana_program::pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); - self - } - #[inline(always)] - pub fn staker(&mut self, staker: Pubkey) -> &mut Self { - self.staker = Some(staker); - self - } - #[inline(always)] - pub fn withdrawer(&mut self, withdrawer: Pubkey) -> &mut Self { - self.withdrawer = Some(withdrawer); + pub fn rent_sysvar(&mut self, rent_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + self.rent_sysvar = Some(rent_sysvar); self } #[inline(always)] - pub fn unix_timestamp(&mut self, unix_timestamp: i64) -> &mut Self { - self.unix_timestamp = Some(unix_timestamp); + pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { + self.arg0 = Some(arg0); self } #[inline(always)] - pub fn epoch(&mut self, epoch: u64) -> &mut Self { - self.epoch = Some(epoch); - self - } - #[inline(always)] - pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { - self.custodian = Some(custodian); + pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { + self.arg1 = Some(arg1); self } /// Add an additional account to the instruction. @@ -162,19 +140,13 @@ impl InitializeBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Initialize { stake: self.stake.expect("stake is not set"), - rent: self.rent.unwrap_or(solana_program::pubkey!( + rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( "SysvarRent111111111111111111111111111111111" )), }; let args = InitializeInstructionArgs { - staker: self.staker.clone().expect("staker is not set"), - withdrawer: self.withdrawer.clone().expect("withdrawer is not set"), - unix_timestamp: self - .unix_timestamp - .clone() - .expect("unix_timestamp is not set"), - epoch: self.epoch.clone().expect("epoch is not set"), - custodian: self.custodian.clone().expect("custodian is not set"), + arg0: self.arg0.clone().expect("arg0 is not set"), + arg1: self.arg1.clone().expect("arg1 is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -183,20 +155,20 @@ impl InitializeBuilder { /// `initialize` CPI accounts. pub struct InitializeCpiAccounts<'a, 'b> { - /// The stake account to initialize + /// Uninitialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Rent sysvar - pub rent: &'b solana_program::account_info::AccountInfo<'a>, + pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, } /// `initialize` CPI instruction. pub struct InitializeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to initialize + /// Uninitialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Rent sysvar - pub rent: &'b solana_program::account_info::AccountInfo<'a>, + pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: InitializeInstructionArgs, } @@ -210,7 +182,7 @@ impl<'a, 'b> InitializeCpi<'a, 'b> { Self { __program: program, stake: accounts.stake, - rent: accounts.rent, + rent_sysvar: accounts.rent_sysvar, __args: args, } } @@ -253,7 +225,7 @@ impl<'a, 'b> InitializeCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.rent.key, + *self.rent_sysvar.key, false, )); remaining_accounts.iter().for_each(|remaining_account| { @@ -268,14 +240,14 @@ impl<'a, 'b> InitializeCpi<'a, 'b> { data.append(&mut args); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); - account_infos.push(self.rent.clone()); + account_infos.push(self.rent_sysvar.clone()); remaining_accounts .iter() .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); @@ -293,7 +265,7 @@ impl<'a, 'b> InitializeCpi<'a, 'b> { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` rent +/// 1. `[]` rent_sysvar #[derive(Clone, Debug)] pub struct InitializeCpiBuilder<'a, 'b> { instruction: Box>, @@ -304,17 +276,14 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { let instruction = Box::new(InitializeCpiBuilderInstruction { __program: program, stake: None, - rent: None, - staker: None, - withdrawer: None, - unix_timestamp: None, - epoch: None, - custodian: None, + rent_sysvar: None, + arg0: None, + arg1: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// The stake account to initialize + /// Uninitialized stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); @@ -322,33 +291,21 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { } /// Rent sysvar #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); - self - } - #[inline(always)] - pub fn staker(&mut self, staker: Pubkey) -> &mut Self { - self.instruction.staker = Some(staker); - self - } - #[inline(always)] - pub fn withdrawer(&mut self, withdrawer: Pubkey) -> &mut Self { - self.instruction.withdrawer = Some(withdrawer); - self - } - #[inline(always)] - pub fn unix_timestamp(&mut self, unix_timestamp: i64) -> &mut Self { - self.instruction.unix_timestamp = Some(unix_timestamp); + pub fn rent_sysvar( + &mut self, + rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.rent_sysvar = Some(rent_sysvar); self } #[inline(always)] - pub fn epoch(&mut self, epoch: u64) -> &mut Self { - self.instruction.epoch = Some(epoch); + pub fn arg0(&mut self, arg0: Authorized) -> &mut Self { + self.instruction.arg0 = Some(arg0); self } #[inline(always)] - pub fn custodian(&mut self, custodian: Pubkey) -> &mut Self { - self.instruction.custodian = Some(custodian); + pub fn arg1(&mut self, arg1: Lockup) -> &mut Self { + self.instruction.arg1 = Some(arg1); self } /// Add an additional account to the instruction. @@ -393,30 +350,18 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = InitializeInstructionArgs { - staker: self.instruction.staker.clone().expect("staker is not set"), - withdrawer: self - .instruction - .withdrawer - .clone() - .expect("withdrawer is not set"), - unix_timestamp: self - .instruction - .unix_timestamp - .clone() - .expect("unix_timestamp is not set"), - epoch: self.instruction.epoch.clone().expect("epoch is not set"), - custodian: self - .instruction - .custodian - .clone() - .expect("custodian is not set"), + arg0: self.instruction.arg0.clone().expect("arg0 is not set"), + arg1: self.instruction.arg1.clone().expect("arg1 is not set"), }; let instruction = InitializeCpi { __program: self.instruction.__program, stake: self.instruction.stake.expect("stake is not set"), - rent: self.instruction.rent.expect("rent is not set"), + rent_sysvar: self + .instruction + .rent_sysvar + .expect("rent_sysvar is not set"), __args: args, }; instruction.invoke_signed_with_remaining_accounts( @@ -430,12 +375,9 @@ impl<'a, 'b> InitializeCpiBuilder<'a, 'b> { struct InitializeCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - rent: Option<&'b solana_program::account_info::AccountInfo<'a>>, - staker: Option, - withdrawer: Option, - unix_timestamp: Option, - epoch: Option, - custodian: Option, + rent_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, + arg0: Option, + arg1: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/initialize_checked.rs b/clients/rust/src/generated/instructions/initialize_checked.rs index 61ff1a2..ac08dff 100644 --- a/clients/rust/src/generated/instructions/initialize_checked.rs +++ b/clients/rust/src/generated/instructions/initialize_checked.rs @@ -9,13 +9,13 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. pub struct InitializeChecked { - /// The stake account to initialize + /// Uninitialized stake account pub stake: solana_program::pubkey::Pubkey, /// Rent sysvar - pub rent: solana_program::pubkey::Pubkey, - /// stake's new stake authority + pub rent_sysvar: solana_program::pubkey::Pubkey, + /// The stake authority pub stake_authority: solana_program::pubkey::Pubkey, - /// stake's new withdraw authority + /// The withdraw authority pub withdraw_authority: solana_program::pubkey::Pubkey, } @@ -33,7 +33,8 @@ impl InitializeChecked { self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.rent, false, + self.rent_sysvar, + false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_authority, @@ -49,7 +50,7 @@ impl InitializeChecked { .unwrap(); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -58,14 +59,12 @@ impl InitializeChecked { #[derive(BorshDeserialize, BorshSerialize)] pub struct InitializeCheckedInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl InitializeCheckedInstructionData { pub fn new() -> Self { - Self { - discriminator: [219, 90, 58, 161, 139, 88, 246, 28], - } + Self { discriminator: 9 } } } @@ -80,13 +79,13 @@ impl Default for InitializeCheckedInstructionData { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[optional]` rent (default to `SysvarRent111111111111111111111111111111111`) +/// 1. `[optional]` rent_sysvar (default to `SysvarRent111111111111111111111111111111111`) /// 2. `[]` stake_authority /// 3. `[signer]` withdraw_authority #[derive(Clone, Debug, Default)] pub struct InitializeCheckedBuilder { stake: Option, - rent: Option, + rent_sysvar: Option, stake_authority: Option, withdraw_authority: Option, __remaining_accounts: Vec, @@ -96,7 +95,7 @@ impl InitializeCheckedBuilder { pub fn new() -> Self { Self::default() } - /// The stake account to initialize + /// Uninitialized stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); @@ -105,11 +104,11 @@ impl InitializeCheckedBuilder { /// `[optional account, default to 'SysvarRent111111111111111111111111111111111']` /// Rent sysvar #[inline(always)] - pub fn rent(&mut self, rent: solana_program::pubkey::Pubkey) -> &mut Self { - self.rent = Some(rent); + pub fn rent_sysvar(&mut self, rent_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + self.rent_sysvar = Some(rent_sysvar); self } - /// stake's new stake authority + /// The stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -118,7 +117,7 @@ impl InitializeCheckedBuilder { self.stake_authority = Some(stake_authority); self } - /// stake's new withdraw authority + /// The withdraw authority #[inline(always)] pub fn withdraw_authority( &mut self, @@ -149,7 +148,7 @@ impl InitializeCheckedBuilder { pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = InitializeChecked { stake: self.stake.expect("stake is not set"), - rent: self.rent.unwrap_or(solana_program::pubkey!( + rent_sysvar: self.rent_sysvar.unwrap_or(solana_program::pubkey!( "SysvarRent111111111111111111111111111111111" )), stake_authority: self.stake_authority.expect("stake_authority is not set"), @@ -164,13 +163,13 @@ impl InitializeCheckedBuilder { /// `initialize_checked` CPI accounts. pub struct InitializeCheckedCpiAccounts<'a, 'b> { - /// The stake account to initialize + /// Uninitialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Rent sysvar - pub rent: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's new stake authority + pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's new withdraw authority + /// The withdraw authority pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -178,13 +177,13 @@ pub struct InitializeCheckedCpiAccounts<'a, 'b> { pub struct InitializeCheckedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to initialize + /// Uninitialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Rent sysvar - pub rent: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's new stake authority + pub rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + /// The stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's new withdraw authority + /// The withdraw authority pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -196,7 +195,7 @@ impl<'a, 'b> InitializeCheckedCpi<'a, 'b> { Self { __program: program, stake: accounts.stake, - rent: accounts.rent, + rent_sysvar: accounts.rent_sysvar, stake_authority: accounts.stake_authority, withdraw_authority: accounts.withdraw_authority, } @@ -240,7 +239,7 @@ impl<'a, 'b> InitializeCheckedCpi<'a, 'b> { false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.rent.key, + *self.rent_sysvar.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -263,14 +262,14 @@ impl<'a, 'b> InitializeCheckedCpi<'a, 'b> { .unwrap(); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; let mut account_infos = Vec::with_capacity(5 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); - account_infos.push(self.rent.clone()); + account_infos.push(self.rent_sysvar.clone()); account_infos.push(self.stake_authority.clone()); account_infos.push(self.withdraw_authority.clone()); remaining_accounts @@ -290,7 +289,7 @@ impl<'a, 'b> InitializeCheckedCpi<'a, 'b> { /// ### Accounts: /// /// 0. `[writable]` stake -/// 1. `[]` rent +/// 1. `[]` rent_sysvar /// 2. `[]` stake_authority /// 3. `[signer]` withdraw_authority #[derive(Clone, Debug)] @@ -303,14 +302,14 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { let instruction = Box::new(InitializeCheckedCpiBuilderInstruction { __program: program, stake: None, - rent: None, + rent_sysvar: None, stake_authority: None, withdraw_authority: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// The stake account to initialize + /// Uninitialized stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); @@ -318,11 +317,14 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { } /// Rent sysvar #[inline(always)] - pub fn rent(&mut self, rent: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.rent = Some(rent); + pub fn rent_sysvar( + &mut self, + rent_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.rent_sysvar = Some(rent_sysvar); self } - /// stake's new stake authority + /// The stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -331,7 +333,7 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { self.instruction.stake_authority = Some(stake_authority); self } - /// stake's new withdraw authority + /// The withdraw authority #[inline(always)] pub fn withdraw_authority( &mut self, @@ -386,7 +388,10 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { stake: self.instruction.stake.expect("stake is not set"), - rent: self.instruction.rent.expect("rent is not set"), + rent_sysvar: self + .instruction + .rent_sysvar + .expect("rent_sysvar is not set"), stake_authority: self .instruction @@ -409,7 +414,7 @@ impl<'a, 'b> InitializeCheckedCpiBuilder<'a, 'b> { struct InitializeCheckedCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, - rent: Option<&'b solana_program::account_info::AccountInfo<'a>>, + rent_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, withdraw_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. diff --git a/clients/rust/src/generated/instructions/merge.rs b/clients/rust/src/generated/instructions/merge.rs index d82f3f8..97c89cb 100644 --- a/clients/rust/src/generated/instructions/merge.rs +++ b/clients/rust/src/generated/instructions/merge.rs @@ -9,15 +9,15 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. pub struct Merge { - /// The destination stake account to merge into - pub to: solana_program::pubkey::Pubkey, - /// The stake account to merge from. Must have exact same lockup and authority as to. This account will be drained. - pub from: solana_program::pubkey::Pubkey, + /// Destination stake account + pub destination_stake: solana_program::pubkey::Pubkey, + /// Source stake account + pub source_stake: solana_program::pubkey::Pubkey, /// Clock sysvar - pub clock: solana_program::pubkey::Pubkey, + pub clock_sysvar: solana_program::pubkey::Pubkey, /// Stake history sysvar pub stake_history: solana_program::pubkey::Pubkey, - /// Both from and to's stake authority + /// Stake authority pub stake_authority: solana_program::pubkey::Pubkey, } @@ -32,13 +32,16 @@ impl Merge { ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - self.to, false, + self.destination_stake, + false, )); accounts.push(solana_program::instruction::AccountMeta::new( - self.from, false, + self.source_stake, + false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.clock, false, + self.clock_sysvar, + false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_history, @@ -52,7 +55,7 @@ impl Merge { let data = MergeInstructionData::new().try_to_vec().unwrap(); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -61,14 +64,12 @@ impl Merge { #[derive(BorshDeserialize, BorshSerialize)] pub struct MergeInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl MergeInstructionData { pub fn new() -> Self { - Self { - discriminator: [148, 141, 236, 47, 174, 126, 69, 111], - } + Self { discriminator: 7 } } } @@ -82,16 +83,16 @@ impl Default for MergeInstructionData { /// /// ### Accounts: /// -/// 0. `[writable]` to -/// 1. `[writable]` from -/// 2. `[]` clock +/// 0. `[writable]` destination_stake +/// 1. `[writable]` source_stake +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) /// 3. `[]` stake_history /// 4. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct MergeBuilder { - to: Option, - from: Option, - clock: Option, + destination_stake: Option, + source_stake: Option, + clock_sysvar: Option, stake_history: Option, stake_authority: Option, __remaining_accounts: Vec, @@ -101,22 +102,26 @@ impl MergeBuilder { pub fn new() -> Self { Self::default() } - /// The destination stake account to merge into + /// Destination stake account #[inline(always)] - pub fn to(&mut self, to: solana_program::pubkey::Pubkey) -> &mut Self { - self.to = Some(to); + pub fn destination_stake( + &mut self, + destination_stake: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.destination_stake = Some(destination_stake); self } - /// The stake account to merge from. Must have exact same lockup and authority as to. This account will be drained. + /// Source stake account #[inline(always)] - pub fn from(&mut self, from: solana_program::pubkey::Pubkey) -> &mut Self { - self.from = Some(from); + pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { + self.source_stake = Some(source_stake); self } + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock = Some(clock); + pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + self.clock_sysvar = Some(clock_sysvar); self } /// Stake history sysvar @@ -125,7 +130,7 @@ impl MergeBuilder { self.stake_history = Some(stake_history); self } - /// Both from and to's stake authority + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -155,9 +160,13 @@ impl MergeBuilder { #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Merge { - to: self.to.expect("to is not set"), - from: self.from.expect("from is not set"), - clock: self.clock.expect("clock is not set"), + destination_stake: self + .destination_stake + .expect("destination_stake is not set"), + source_stake: self.source_stake.expect("source_stake is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), stake_history: self.stake_history.expect("stake_history is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; @@ -168,15 +177,15 @@ impl MergeBuilder { /// `merge` CPI accounts. pub struct MergeCpiAccounts<'a, 'b> { - /// The destination stake account to merge into - pub to: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to merge from. Must have exact same lockup and authority as to. This account will be drained. - pub from: &'b solana_program::account_info::AccountInfo<'a>, + /// Destination stake account + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Source stake account + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// Stake history sysvar pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, - /// Both from and to's stake authority + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -184,15 +193,15 @@ pub struct MergeCpiAccounts<'a, 'b> { pub struct MergeCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The destination stake account to merge into - pub to: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to merge from. Must have exact same lockup and authority as to. This account will be drained. - pub from: &'b solana_program::account_info::AccountInfo<'a>, + /// Destination stake account + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Source stake account + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// Stake history sysvar pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, - /// Both from and to's stake authority + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -203,9 +212,9 @@ impl<'a, 'b> MergeCpi<'a, 'b> { ) -> Self { Self { __program: program, - to: accounts.to, - from: accounts.from, - clock: accounts.clock, + destination_stake: accounts.destination_stake, + source_stake: accounts.source_stake, + clock_sysvar: accounts.clock_sysvar, stake_history: accounts.stake_history, stake_authority: accounts.stake_authority, } @@ -245,15 +254,15 @@ impl<'a, 'b> MergeCpi<'a, 'b> { ) -> solana_program::entrypoint::ProgramResult { let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - *self.to.key, + *self.destination_stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - *self.from.key, + *self.source_stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.clock.key, + *self.clock_sysvar.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -274,15 +283,15 @@ impl<'a, 'b> MergeCpi<'a, 'b> { let data = MergeInstructionData::new().try_to_vec().unwrap(); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); account_infos.push(self.__program.clone()); - account_infos.push(self.to.clone()); - account_infos.push(self.from.clone()); - account_infos.push(self.clock.clone()); + account_infos.push(self.destination_stake.clone()); + account_infos.push(self.source_stake.clone()); + account_infos.push(self.clock_sysvar.clone()); account_infos.push(self.stake_history.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts @@ -301,9 +310,9 @@ impl<'a, 'b> MergeCpi<'a, 'b> { /// /// ### Accounts: /// -/// 0. `[writable]` to -/// 1. `[writable]` from -/// 2. `[]` clock +/// 0. `[writable]` destination_stake +/// 1. `[writable]` source_stake +/// 2. `[]` clock_sysvar /// 3. `[]` stake_history /// 4. `[signer]` stake_authority #[derive(Clone, Debug)] @@ -315,31 +324,40 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(MergeCpiBuilderInstruction { __program: program, - to: None, - from: None, - clock: None, + destination_stake: None, + source_stake: None, + clock_sysvar: None, stake_history: None, stake_authority: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// The destination stake account to merge into + /// Destination stake account #[inline(always)] - pub fn to(&mut self, to: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.to = Some(to); + pub fn destination_stake( + &mut self, + destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.destination_stake = Some(destination_stake); self } - /// The stake account to merge from. Must have exact same lockup and authority as to. This account will be drained. + /// Source stake account #[inline(always)] - pub fn from(&mut self, from: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.from = Some(from); + pub fn source_stake( + &mut self, + source_stake: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.source_stake = Some(source_stake); self } /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock = Some(clock); + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); self } /// Stake history sysvar @@ -351,7 +369,7 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { self.instruction.stake_history = Some(stake_history); self } - /// Both from and to's stake authority + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -404,11 +422,20 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { let instruction = MergeCpi { __program: self.instruction.__program, - to: self.instruction.to.expect("to is not set"), + destination_stake: self + .instruction + .destination_stake + .expect("destination_stake is not set"), - from: self.instruction.from.expect("from is not set"), + source_stake: self + .instruction + .source_stake + .expect("source_stake is not set"), - clock: self.instruction.clock.expect("clock is not set"), + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), stake_history: self .instruction @@ -430,9 +457,9 @@ impl<'a, 'b> MergeCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct MergeCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, - to: Option<&'b solana_program::account_info::AccountInfo<'a>>, - from: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock: Option<&'b solana_program::account_info::AccountInfo<'a>>, + destination_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, + source_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_history: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. diff --git a/clients/rust/src/generated/instructions/mod.rs b/clients/rust/src/generated/instructions/mod.rs index 6aeaaf8..718e349 100644 --- a/clients/rust/src/generated/instructions/mod.rs +++ b/clients/rust/src/generated/instructions/mod.rs @@ -16,6 +16,8 @@ pub(crate) mod r#get_minimum_delegation; pub(crate) mod r#initialize; pub(crate) mod r#initialize_checked; pub(crate) mod r#merge; +pub(crate) mod r#move_lamports; +pub(crate) mod r#move_stake; pub(crate) mod r#set_lockup; pub(crate) mod r#set_lockup_checked; pub(crate) mod r#split; @@ -25,5 +27,6 @@ pub use self::{ r#authorize::*, r#authorize_checked::*, r#authorize_checked_with_seed::*, r#authorize_with_seed::*, r#deactivate::*, r#deactivate_delinquent::*, r#delegate_stake::*, r#get_minimum_delegation::*, r#initialize::*, r#initialize_checked::*, r#merge::*, - r#set_lockup::*, r#set_lockup_checked::*, r#split::*, r#withdraw::*, + r#move_lamports::*, r#move_stake::*, r#set_lockup::*, r#set_lockup_checked::*, r#split::*, + r#withdraw::*, }; diff --git a/clients/rust/src/generated/instructions/move_lamports.rs b/clients/rust/src/generated/instructions/move_lamports.rs new file mode 100644 index 0000000..f94f5d9 --- /dev/null +++ b/clients/rust/src/generated/instructions/move_lamports.rs @@ -0,0 +1,422 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +use borsh::{BorshDeserialize, BorshSerialize}; + +/// Accounts. +pub struct MoveLamports { + /// Active or inactive source stake account + pub source_stake: solana_program::pubkey::Pubkey, + /// Mergeable destination stake account + pub destination_stake: solana_program::pubkey::Pubkey, + /// Stake authority + pub stake_authority: solana_program::pubkey::Pubkey, +} + +impl MoveLamports { + pub fn instruction( + &self, + args: MoveLamportsInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: MoveLamportsInstructionArgs, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + self.source_stake, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.destination_stake, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.stake_authority, + true, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = MoveLamportsInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } + } +} + +#[derive(BorshDeserialize, BorshSerialize)] +pub struct MoveLamportsInstructionData { + discriminator: u8, +} + +impl MoveLamportsInstructionData { + pub fn new() -> Self { + Self { discriminator: 17 } + } +} + +impl Default for MoveLamportsInstructionData { + fn default() -> Self { + Self::new() + } +} + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct MoveLamportsInstructionArgs { + pub args: u64, +} + +/// Instruction builder for `MoveLamports`. +/// +/// ### Accounts: +/// +/// 0. `[writable]` source_stake +/// 1. `[writable]` destination_stake +/// 2. `[signer]` stake_authority +#[derive(Clone, Debug, Default)] +pub struct MoveLamportsBuilder { + source_stake: Option, + destination_stake: Option, + stake_authority: Option, + args: Option, + __remaining_accounts: Vec, +} + +impl MoveLamportsBuilder { + pub fn new() -> Self { + Self::default() + } + /// Active or inactive source stake account + #[inline(always)] + pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { + self.source_stake = Some(source_stake); + self + } + /// Mergeable destination stake account + #[inline(always)] + pub fn destination_stake( + &mut self, + destination_stake: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.destination_stake = Some(destination_stake); + self + } + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.stake_authority = Some(stake_authority); + self + } + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { + self.args = Some(args); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::instruction::AccountMeta], + ) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } + #[allow(clippy::clone_on_copy)] + pub fn instruction(&self) -> solana_program::instruction::Instruction { + let accounts = MoveLamports { + source_stake: self.source_stake.expect("source_stake is not set"), + destination_stake: self + .destination_stake + .expect("destination_stake is not set"), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; + let args = MoveLamportsInstructionArgs { + args: self.args.clone().expect("args is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} + +/// `move_lamports` CPI accounts. +pub struct MoveLamportsCpiAccounts<'a, 'b> { + /// Active or inactive source stake account + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Mergeable destination stake account + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, +} + +/// `move_lamports` CPI instruction. +pub struct MoveLamportsCpi<'a, 'b> { + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Active or inactive source stake account + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Mergeable destination stake account + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// The arguments for the instruction. + pub __args: MoveLamportsInstructionArgs, +} + +impl<'a, 'b> MoveLamportsCpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: MoveLamportsCpiAccounts<'a, 'b>, + args: MoveLamportsInstructionArgs, + ) -> Self { + Self { + __program: program, + source_stake: accounts.source_stake, + destination_stake: accounts.destination_stake, + stake_authority: accounts.stake_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed_with_remaining_accounts( + &self, + signers_seeds: &[&[&[u8]]], + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.source_stake.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.destination_stake.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.stake_authority.key, + true, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let mut data = MoveLamportsInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.source_stake.clone()); + account_infos.push(self.destination_stake.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } +} + +/// Instruction builder for `MoveLamports` via CPI. +/// +/// ### Accounts: +/// +/// 0. `[writable]` source_stake +/// 1. `[writable]` destination_stake +/// 2. `[signer]` stake_authority +#[derive(Clone, Debug)] +pub struct MoveLamportsCpiBuilder<'a, 'b> { + instruction: Box>, +} + +impl<'a, 'b> MoveLamportsCpiBuilder<'a, 'b> { + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(MoveLamportsCpiBuilderInstruction { + __program: program, + source_stake: None, + destination_stake: None, + stake_authority: None, + args: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Active or inactive source stake account + #[inline(always)] + pub fn source_stake( + &mut self, + source_stake: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.source_stake = Some(source_stake); + self + } + /// Mergeable destination stake account + #[inline(always)] + pub fn destination_stake( + &mut self, + destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.destination_stake = Some(destination_stake); + self + } + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self + } + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { + self.instruction.args = Some(args); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let args = MoveLamportsInstructionArgs { + args: self.instruction.args.clone().expect("args is not set"), + }; + let instruction = MoveLamportsCpi { + __program: self.instruction.__program, + + source_stake: self + .instruction + .source_stake + .expect("source_stake is not set"), + + destination_stake: self + .instruction + .destination_stake + .expect("destination_stake is not set"), + + stake_authority: self + .instruction + .stake_authority + .expect("stake_authority is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } +} + +#[derive(Clone, Debug)] +struct MoveLamportsCpiBuilderInstruction<'a, 'b> { + __program: &'b solana_program::account_info::AccountInfo<'a>, + source_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, + destination_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, + stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + args: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, +} diff --git a/clients/rust/src/generated/instructions/move_stake.rs b/clients/rust/src/generated/instructions/move_stake.rs new file mode 100644 index 0000000..708d470 --- /dev/null +++ b/clients/rust/src/generated/instructions/move_stake.rs @@ -0,0 +1,422 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +use borsh::{BorshDeserialize, BorshSerialize}; + +/// Accounts. +pub struct MoveStake { + /// Active source stake account + pub source_stake: solana_program::pubkey::Pubkey, + /// Active or inactive destination stake account + pub destination_stake: solana_program::pubkey::Pubkey, + /// Stake authority + pub stake_authority: solana_program::pubkey::Pubkey, +} + +impl MoveStake { + pub fn instruction( + &self, + args: MoveStakeInstructionArgs, + ) -> solana_program::instruction::Instruction { + self.instruction_with_remaining_accounts(args, &[]) + } + #[allow(clippy::vec_init_then_push)] + pub fn instruction_with_remaining_accounts( + &self, + args: MoveStakeInstructionArgs, + remaining_accounts: &[solana_program::instruction::AccountMeta], + ) -> solana_program::instruction::Instruction { + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + self.source_stake, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + self.destination_stake, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + self.stake_authority, + true, + )); + accounts.extend_from_slice(remaining_accounts); + let mut data = MoveStakeInstructionData::new().try_to_vec().unwrap(); + let mut args = args.try_to_vec().unwrap(); + data.append(&mut args); + + solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + } + } +} + +#[derive(BorshDeserialize, BorshSerialize)] +pub struct MoveStakeInstructionData { + discriminator: u8, +} + +impl MoveStakeInstructionData { + pub fn new() -> Self { + Self { discriminator: 16 } + } +} + +impl Default for MoveStakeInstructionData { + fn default() -> Self { + Self::new() + } +} + +#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] +pub struct MoveStakeInstructionArgs { + pub args: u64, +} + +/// Instruction builder for `MoveStake`. +/// +/// ### Accounts: +/// +/// 0. `[writable]` source_stake +/// 1. `[writable]` destination_stake +/// 2. `[signer]` stake_authority +#[derive(Clone, Debug, Default)] +pub struct MoveStakeBuilder { + source_stake: Option, + destination_stake: Option, + stake_authority: Option, + args: Option, + __remaining_accounts: Vec, +} + +impl MoveStakeBuilder { + pub fn new() -> Self { + Self::default() + } + /// Active source stake account + #[inline(always)] + pub fn source_stake(&mut self, source_stake: solana_program::pubkey::Pubkey) -> &mut Self { + self.source_stake = Some(source_stake); + self + } + /// Active or inactive destination stake account + #[inline(always)] + pub fn destination_stake( + &mut self, + destination_stake: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.destination_stake = Some(destination_stake); + self + } + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: solana_program::pubkey::Pubkey, + ) -> &mut Self { + self.stake_authority = Some(stake_authority); + self + } + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { + self.args = Some(args); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: solana_program::instruction::AccountMeta, + ) -> &mut Self { + self.__remaining_accounts.push(account); + self + } + /// Add additional accounts to the instruction. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[solana_program::instruction::AccountMeta], + ) -> &mut Self { + self.__remaining_accounts.extend_from_slice(accounts); + self + } + #[allow(clippy::clone_on_copy)] + pub fn instruction(&self) -> solana_program::instruction::Instruction { + let accounts = MoveStake { + source_stake: self.source_stake.expect("source_stake is not set"), + destination_stake: self + .destination_stake + .expect("destination_stake is not set"), + stake_authority: self.stake_authority.expect("stake_authority is not set"), + }; + let args = MoveStakeInstructionArgs { + args: self.args.clone().expect("args is not set"), + }; + + accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) + } +} + +/// `move_stake` CPI accounts. +pub struct MoveStakeCpiAccounts<'a, 'b> { + /// Active source stake account + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Active or inactive destination stake account + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, +} + +/// `move_stake` CPI instruction. +pub struct MoveStakeCpi<'a, 'b> { + /// The program to invoke. + pub __program: &'b solana_program::account_info::AccountInfo<'a>, + /// Active source stake account + pub source_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Active or inactive destination stake account + pub destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority + pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// The arguments for the instruction. + pub __args: MoveStakeInstructionArgs, +} + +impl<'a, 'b> MoveStakeCpi<'a, 'b> { + pub fn new( + program: &'b solana_program::account_info::AccountInfo<'a>, + accounts: MoveStakeCpiAccounts<'a, 'b>, + args: MoveStakeInstructionArgs, + ) -> Self { + Self { + __program: program, + source_stake: accounts.source_stake, + destination_stake: accounts.destination_stake, + stake_authority: accounts.stake_authority, + __args: args, + } + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], &[]) + } + #[inline(always)] + pub fn invoke_with_remaining_accounts( + &self, + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(&[], remaining_accounts) + } + #[inline(always)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed_with_remaining_accounts(signers_seeds, &[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed_with_remaining_accounts( + &self, + signers_seeds: &[&[&[u8]]], + remaining_accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> solana_program::entrypoint::ProgramResult { + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.source_stake.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new( + *self.destination_stake.key, + false, + )); + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *self.stake_authority.key, + true, + )); + remaining_accounts.iter().for_each(|remaining_account| { + accounts.push(solana_program::instruction::AccountMeta { + pubkey: *remaining_account.0.key, + is_signer: remaining_account.1, + is_writable: remaining_account.2, + }) + }); + let mut data = MoveStakeInstructionData::new().try_to_vec().unwrap(); + let mut args = self.__args.try_to_vec().unwrap(); + data.append(&mut args); + + let instruction = solana_program::instruction::Instruction { + program_id: crate::STAKE_ID, + accounts, + data, + }; + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); + account_infos.push(self.__program.clone()); + account_infos.push(self.source_stake.clone()); + account_infos.push(self.destination_stake.clone()); + account_infos.push(self.stake_authority.clone()); + remaining_accounts + .iter() + .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); + + if signers_seeds.is_empty() { + solana_program::program::invoke(&instruction, &account_infos) + } else { + solana_program::program::invoke_signed(&instruction, &account_infos, signers_seeds) + } + } +} + +/// Instruction builder for `MoveStake` via CPI. +/// +/// ### Accounts: +/// +/// 0. `[writable]` source_stake +/// 1. `[writable]` destination_stake +/// 2. `[signer]` stake_authority +#[derive(Clone, Debug)] +pub struct MoveStakeCpiBuilder<'a, 'b> { + instruction: Box>, +} + +impl<'a, 'b> MoveStakeCpiBuilder<'a, 'b> { + pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { + let instruction = Box::new(MoveStakeCpiBuilderInstruction { + __program: program, + source_stake: None, + destination_stake: None, + stake_authority: None, + args: None, + __remaining_accounts: Vec::new(), + }); + Self { instruction } + } + /// Active source stake account + #[inline(always)] + pub fn source_stake( + &mut self, + source_stake: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.source_stake = Some(source_stake); + self + } + /// Active or inactive destination stake account + #[inline(always)] + pub fn destination_stake( + &mut self, + destination_stake: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.destination_stake = Some(destination_stake); + self + } + /// Stake authority + #[inline(always)] + pub fn stake_authority( + &mut self, + stake_authority: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.stake_authority = Some(stake_authority); + self + } + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { + self.instruction.args = Some(args); + self + } + /// Add an additional account to the instruction. + #[inline(always)] + pub fn add_remaining_account( + &mut self, + account: &'b solana_program::account_info::AccountInfo<'a>, + is_writable: bool, + is_signer: bool, + ) -> &mut Self { + self.instruction + .__remaining_accounts + .push((account, is_writable, is_signer)); + self + } + /// Add additional accounts to the instruction. + /// + /// Each account is represented by a tuple of the `AccountInfo`, a `bool` indicating whether the account is writable or not, + /// and a `bool` indicating whether the account is a signer or not. + #[inline(always)] + pub fn add_remaining_accounts( + &mut self, + accounts: &[( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )], + ) -> &mut Self { + self.instruction + .__remaining_accounts + .extend_from_slice(accounts); + self + } + #[inline(always)] + pub fn invoke(&self) -> solana_program::entrypoint::ProgramResult { + self.invoke_signed(&[]) + } + #[allow(clippy::clone_on_copy)] + #[allow(clippy::vec_init_then_push)] + pub fn invoke_signed( + &self, + signers_seeds: &[&[&[u8]]], + ) -> solana_program::entrypoint::ProgramResult { + let args = MoveStakeInstructionArgs { + args: self.instruction.args.clone().expect("args is not set"), + }; + let instruction = MoveStakeCpi { + __program: self.instruction.__program, + + source_stake: self + .instruction + .source_stake + .expect("source_stake is not set"), + + destination_stake: self + .instruction + .destination_stake + .expect("destination_stake is not set"), + + stake_authority: self + .instruction + .stake_authority + .expect("stake_authority is not set"), + __args: args, + }; + instruction.invoke_signed_with_remaining_accounts( + signers_seeds, + &self.instruction.__remaining_accounts, + ) + } +} + +#[derive(Clone, Debug)] +struct MoveStakeCpiBuilderInstruction<'a, 'b> { + __program: &'b solana_program::account_info::AccountInfo<'a>, + source_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, + destination_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, + stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + args: Option, + /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. + __remaining_accounts: Vec<( + &'b solana_program::account_info::AccountInfo<'a>, + bool, + bool, + )>, +} diff --git a/clients/rust/src/generated/instructions/set_lockup.rs b/clients/rust/src/generated/instructions/set_lockup.rs index 5f9a3c6..f6d965f 100644 --- a/clients/rust/src/generated/instructions/set_lockup.rs +++ b/clients/rust/src/generated/instructions/set_lockup.rs @@ -12,9 +12,9 @@ use { /// Accounts. pub struct SetLockup { - /// The stake account to set the lockup of + /// Initialized stake account pub stake: solana_program::pubkey::Pubkey, - /// stake's withdraw authority or lockup authority if lockup is active + /// Lockup authority or withdraw authority pub authority: solana_program::pubkey::Pubkey, } @@ -45,7 +45,7 @@ impl SetLockup { data.append(&mut args); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -54,14 +54,12 @@ impl SetLockup { #[derive(BorshDeserialize, BorshSerialize)] pub struct SetLockupInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl SetLockupInstructionData { pub fn new() -> Self { - Self { - discriminator: [44, 170, 189, 40, 128, 123, 252, 201], - } + Self { discriminator: 6 } } } @@ -99,13 +97,13 @@ impl SetLockupBuilder { pub fn new() -> Self { Self::default() } - /// The stake account to set the lockup of + /// Initialized stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } - /// stake's withdraw authority or lockup authority if lockup is active + /// Lockup authority or withdraw authority #[inline(always)] pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); @@ -165,9 +163,9 @@ impl SetLockupBuilder { /// `set_lockup` CPI accounts. pub struct SetLockupCpiAccounts<'a, 'b> { - /// The stake account to set the lockup of + /// Initialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's withdraw authority or lockup authority if lockup is active + /// Lockup authority or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -175,9 +173,9 @@ pub struct SetLockupCpiAccounts<'a, 'b> { pub struct SetLockupCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to set the lockup of + /// Initialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's withdraw authority or lockup authority if lockup is active + /// Lockup authority or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: SetLockupInstructionArgs, @@ -250,7 +248,7 @@ impl<'a, 'b> SetLockupCpi<'a, 'b> { data.append(&mut args); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; @@ -294,13 +292,13 @@ impl<'a, 'b> SetLockupCpiBuilder<'a, 'b> { }); Self { instruction } } - /// The stake account to set the lockup of + /// Initialized stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// stake's withdraw authority or lockup authority if lockup is active + /// Lockup authority or withdraw authority #[inline(always)] pub fn authority( &mut self, diff --git a/clients/rust/src/generated/instructions/set_lockup_checked.rs b/clients/rust/src/generated/instructions/set_lockup_checked.rs index 14744ea..acc8c92 100644 --- a/clients/rust/src/generated/instructions/set_lockup_checked.rs +++ b/clients/rust/src/generated/instructions/set_lockup_checked.rs @@ -9,10 +9,12 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. pub struct SetLockupChecked { - /// The stake account to set the lockup of + /// Initialized stake account pub stake: solana_program::pubkey::Pubkey, - /// stake's withdraw authority or lockup authority if lockup is active. If setting a new lockup authority, the signing new lockup authority must follow. + /// Lockup authority or withdraw authority pub authority: solana_program::pubkey::Pubkey, + /// New lockup authority + pub new_authority: Option, } impl SetLockupChecked { @@ -28,7 +30,7 @@ impl SetLockupChecked { args: SetLockupCheckedInstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( self.stake, false, )); @@ -36,13 +38,24 @@ impl SetLockupChecked { self.authority, true, )); + if let Some(new_authority) = self.new_authority { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + new_authority, + true, + )); + } else { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + crate::STAKE_ID, + false, + )); + } accounts.extend_from_slice(remaining_accounts); let mut data = SetLockupCheckedInstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -51,14 +64,12 @@ impl SetLockupChecked { #[derive(BorshDeserialize, BorshSerialize)] pub struct SetLockupCheckedInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl SetLockupCheckedInstructionData { pub fn new() -> Self { - Self { - discriminator: [22, 158, 12, 183, 118, 94, 156, 255], - } + Self { discriminator: 12 } } } @@ -81,10 +92,12 @@ pub struct SetLockupCheckedInstructionArgs { /// /// 0. `[writable]` stake /// 1. `[signer]` authority +/// 2. `[signer, optional]` new_authority #[derive(Clone, Debug, Default)] pub struct SetLockupCheckedBuilder { stake: Option, authority: Option, + new_authority: Option, unix_timestamp: Option, epoch: Option, __remaining_accounts: Vec, @@ -94,18 +107,28 @@ impl SetLockupCheckedBuilder { pub fn new() -> Self { Self::default() } - /// The stake account to set the lockup of + /// Initialized stake account #[inline(always)] pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { self.stake = Some(stake); self } - /// stake's withdraw authority or lockup authority if lockup is active. If setting a new lockup authority, the signing new lockup authority must follow. + /// Lockup authority or withdraw authority #[inline(always)] pub fn authority(&mut self, authority: solana_program::pubkey::Pubkey) -> &mut Self { self.authority = Some(authority); self } + /// `[optional account]` + /// New lockup authority + #[inline(always)] + pub fn new_authority( + &mut self, + new_authority: Option, + ) -> &mut Self { + self.new_authority = new_authority; + self + } /// `[optional argument]` #[inline(always)] pub fn unix_timestamp(&mut self, unix_timestamp: i64) -> &mut Self { @@ -141,6 +164,7 @@ impl SetLockupCheckedBuilder { let accounts = SetLockupChecked { stake: self.stake.expect("stake is not set"), authority: self.authority.expect("authority is not set"), + new_authority: self.new_authority, }; let args = SetLockupCheckedInstructionArgs { unix_timestamp: self.unix_timestamp.clone(), @@ -153,20 +177,24 @@ impl SetLockupCheckedBuilder { /// `set_lockup_checked` CPI accounts. pub struct SetLockupCheckedCpiAccounts<'a, 'b> { - /// The stake account to set the lockup of + /// Initialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's withdraw authority or lockup authority if lockup is active. If setting a new lockup authority, the signing new lockup authority must follow. + /// Lockup authority or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// New lockup authority + pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } /// `set_lockup_checked` CPI instruction. pub struct SetLockupCheckedCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to set the lockup of + /// Initialized stake account pub stake: &'b solana_program::account_info::AccountInfo<'a>, - /// stake's withdraw authority or lockup authority if lockup is active. If setting a new lockup authority, the signing new lockup authority must follow. + /// Lockup authority or withdraw authority pub authority: &'b solana_program::account_info::AccountInfo<'a>, + /// New lockup authority + pub new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: SetLockupCheckedInstructionArgs, } @@ -181,6 +209,7 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { __program: program, stake: accounts.stake, authority: accounts.authority, + new_authority: accounts.new_authority, __args: args, } } @@ -217,7 +246,7 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { bool, )], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(2 + remaining_accounts.len()); + let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( *self.stake.key, false, @@ -226,6 +255,17 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { *self.authority.key, true, )); + if let Some(new_authority) = self.new_authority { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *new_authority.key, + true, + )); + } else { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + crate::STAKE_ID, + false, + )); + } remaining_accounts.iter().for_each(|remaining_account| { accounts.push(solana_program::instruction::AccountMeta { pubkey: *remaining_account.0.key, @@ -238,14 +278,17 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { data.append(&mut args); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; - let mut account_infos = Vec::with_capacity(3 + remaining_accounts.len()); + let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); account_infos.push(self.__program.clone()); account_infos.push(self.stake.clone()); account_infos.push(self.authority.clone()); + if let Some(new_authority) = self.new_authority { + account_infos.push(new_authority.clone()); + } remaining_accounts .iter() .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); @@ -264,6 +307,7 @@ impl<'a, 'b> SetLockupCheckedCpi<'a, 'b> { /// /// 0. `[writable]` stake /// 1. `[signer]` authority +/// 2. `[signer, optional]` new_authority #[derive(Clone, Debug)] pub struct SetLockupCheckedCpiBuilder<'a, 'b> { instruction: Box>, @@ -275,19 +319,20 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { __program: program, stake: None, authority: None, + new_authority: None, unix_timestamp: None, epoch: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// The stake account to set the lockup of + /// Initialized stake account #[inline(always)] pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { self.instruction.stake = Some(stake); self } - /// stake's withdraw authority or lockup authority if lockup is active. If setting a new lockup authority, the signing new lockup authority must follow. + /// Lockup authority or withdraw authority #[inline(always)] pub fn authority( &mut self, @@ -296,6 +341,16 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { self.instruction.authority = Some(authority); self } + /// `[optional account]` + /// New lockup authority + #[inline(always)] + pub fn new_authority( + &mut self, + new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.new_authority = new_authority; + self + } /// `[optional argument]` #[inline(always)] pub fn unix_timestamp(&mut self, unix_timestamp: i64) -> &mut Self { @@ -359,6 +414,8 @@ impl<'a, 'b> SetLockupCheckedCpiBuilder<'a, 'b> { stake: self.instruction.stake.expect("stake is not set"), authority: self.instruction.authority.expect("authority is not set"), + + new_authority: self.instruction.new_authority, __args: args, }; instruction.invoke_signed_with_remaining_accounts( @@ -373,6 +430,7 @@ struct SetLockupCheckedCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + new_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, unix_timestamp: Option, epoch: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. diff --git a/clients/rust/src/generated/instructions/split.rs b/clients/rust/src/generated/instructions/split.rs index f09a743..fa90079 100644 --- a/clients/rust/src/generated/instructions/split.rs +++ b/clients/rust/src/generated/instructions/split.rs @@ -9,11 +9,11 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. pub struct Split { - /// The stake account to split. Must be in the Initialized or Stake state - pub from: solana_program::pubkey::Pubkey, - /// The uninitialized stake account to split to. Must be rent-exempt starting from solana 1.17. - pub to: solana_program::pubkey::Pubkey, - /// from's stake authority + /// Stake account to be split + pub stake: solana_program::pubkey::Pubkey, + /// Uninitialized stake account + pub split_stake: solana_program::pubkey::Pubkey, + /// Stake authority pub stake_authority: solana_program::pubkey::Pubkey, } @@ -32,10 +32,11 @@ impl Split { ) -> solana_program::instruction::Instruction { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - self.from, false, + self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - self.to, false, + self.split_stake, + false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_authority, @@ -47,7 +48,7 @@ impl Split { data.append(&mut args); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -56,14 +57,12 @@ impl Split { #[derive(BorshDeserialize, BorshSerialize)] pub struct SplitInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl SplitInstructionData { pub fn new() -> Self { - Self { - discriminator: [124, 189, 27, 43, 216, 40, 147, 66], - } + Self { discriminator: 3 } } } @@ -76,22 +75,22 @@ impl Default for SplitInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SplitInstructionArgs { - pub lamports: u64, + pub args: u64, } /// Instruction builder for `Split`. /// /// ### Accounts: /// -/// 0. `[writable]` from -/// 1. `[writable]` to +/// 0. `[writable]` stake +/// 1. `[writable]` split_stake /// 2. `[signer]` stake_authority #[derive(Clone, Debug, Default)] pub struct SplitBuilder { - from: Option, - to: Option, + stake: Option, + split_stake: Option, stake_authority: Option, - lamports: Option, + args: Option, __remaining_accounts: Vec, } @@ -99,19 +98,19 @@ impl SplitBuilder { pub fn new() -> Self { Self::default() } - /// The stake account to split. Must be in the Initialized or Stake state + /// Stake account to be split #[inline(always)] - pub fn from(&mut self, from: solana_program::pubkey::Pubkey) -> &mut Self { - self.from = Some(from); + pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + self.stake = Some(stake); self } - /// The uninitialized stake account to split to. Must be rent-exempt starting from solana 1.17. + /// Uninitialized stake account #[inline(always)] - pub fn to(&mut self, to: solana_program::pubkey::Pubkey) -> &mut Self { - self.to = Some(to); + pub fn split_stake(&mut self, split_stake: solana_program::pubkey::Pubkey) -> &mut Self { + self.split_stake = Some(split_stake); self } - /// from's stake authority + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -121,8 +120,8 @@ impl SplitBuilder { self } #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { - self.lamports = Some(lamports); + pub fn args(&mut self, args: u64) -> &mut Self { + self.args = Some(args); self } /// Add an additional account to the instruction. @@ -146,12 +145,12 @@ impl SplitBuilder { #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Split { - from: self.from.expect("from is not set"), - to: self.to.expect("to is not set"), + stake: self.stake.expect("stake is not set"), + split_stake: self.split_stake.expect("split_stake is not set"), stake_authority: self.stake_authority.expect("stake_authority is not set"), }; let args = SplitInstructionArgs { - lamports: self.lamports.clone().expect("lamports is not set"), + args: self.args.clone().expect("args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -160,11 +159,11 @@ impl SplitBuilder { /// `split` CPI accounts. pub struct SplitCpiAccounts<'a, 'b> { - /// The stake account to split. Must be in the Initialized or Stake state - pub from: &'b solana_program::account_info::AccountInfo<'a>, - /// The uninitialized stake account to split to. Must be rent-exempt starting from solana 1.17. - pub to: &'b solana_program::account_info::AccountInfo<'a>, - /// from's stake authority + /// Stake account to be split + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Uninitialized stake account + pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, } @@ -172,11 +171,11 @@ pub struct SplitCpiAccounts<'a, 'b> { pub struct SplitCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to split. Must be in the Initialized or Stake state - pub from: &'b solana_program::account_info::AccountInfo<'a>, - /// The uninitialized stake account to split to. Must be rent-exempt starting from solana 1.17. - pub to: &'b solana_program::account_info::AccountInfo<'a>, - /// from's stake authority + /// Stake account to be split + pub stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Uninitialized stake account + pub split_stake: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake authority pub stake_authority: &'b solana_program::account_info::AccountInfo<'a>, /// The arguments for the instruction. pub __args: SplitInstructionArgs, @@ -190,8 +189,8 @@ impl<'a, 'b> SplitCpi<'a, 'b> { ) -> Self { Self { __program: program, - from: accounts.from, - to: accounts.to, + stake: accounts.stake, + split_stake: accounts.split_stake, stake_authority: accounts.stake_authority, __args: args, } @@ -231,11 +230,11 @@ impl<'a, 'b> SplitCpi<'a, 'b> { ) -> solana_program::entrypoint::ProgramResult { let mut accounts = Vec::with_capacity(3 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - *self.from.key, + *self.stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - *self.to.key, + *self.split_stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -254,14 +253,14 @@ impl<'a, 'b> SplitCpi<'a, 'b> { data.append(&mut args); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; let mut account_infos = Vec::with_capacity(4 + remaining_accounts.len()); account_infos.push(self.__program.clone()); - account_infos.push(self.from.clone()); - account_infos.push(self.to.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.split_stake.clone()); account_infos.push(self.stake_authority.clone()); remaining_accounts .iter() @@ -279,8 +278,8 @@ impl<'a, 'b> SplitCpi<'a, 'b> { /// /// ### Accounts: /// -/// 0. `[writable]` from -/// 1. `[writable]` to +/// 0. `[writable]` stake +/// 1. `[writable]` split_stake /// 2. `[signer]` stake_authority #[derive(Clone, Debug)] pub struct SplitCpiBuilder<'a, 'b> { @@ -291,27 +290,30 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(SplitCpiBuilderInstruction { __program: program, - from: None, - to: None, + stake: None, + split_stake: None, stake_authority: None, - lamports: None, + args: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// The stake account to split. Must be in the Initialized or Stake state + /// Stake account to be split #[inline(always)] - pub fn from(&mut self, from: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.from = Some(from); + pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.stake = Some(stake); self } - /// The uninitialized stake account to split to. Must be rent-exempt starting from solana 1.17. + /// Uninitialized stake account #[inline(always)] - pub fn to(&mut self, to: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.to = Some(to); + pub fn split_stake( + &mut self, + split_stake: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.split_stake = Some(split_stake); self } - /// from's stake authority + /// Stake authority #[inline(always)] pub fn stake_authority( &mut self, @@ -321,8 +323,8 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { self } #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { - self.instruction.lamports = Some(lamports); + pub fn args(&mut self, args: u64) -> &mut Self { + self.instruction.args = Some(args); self } /// Add an additional account to the instruction. @@ -367,18 +369,17 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = SplitInstructionArgs { - lamports: self - .instruction - .lamports - .clone() - .expect("lamports is not set"), + args: self.instruction.args.clone().expect("args is not set"), }; let instruction = SplitCpi { __program: self.instruction.__program, - from: self.instruction.from.expect("from is not set"), + stake: self.instruction.stake.expect("stake is not set"), - to: self.instruction.to.expect("to is not set"), + split_stake: self + .instruction + .split_stake + .expect("split_stake is not set"), stake_authority: self .instruction @@ -396,10 +397,10 @@ impl<'a, 'b> SplitCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct SplitCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, - from: Option<&'b solana_program::account_info::AccountInfo<'a>>, - to: Option<&'b solana_program::account_info::AccountInfo<'a>>, + stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, + split_stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - lamports: Option, + args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/instructions/withdraw.rs b/clients/rust/src/generated/instructions/withdraw.rs index 49afb92..6a87184 100644 --- a/clients/rust/src/generated/instructions/withdraw.rs +++ b/clients/rust/src/generated/instructions/withdraw.rs @@ -9,16 +9,18 @@ use borsh::{BorshDeserialize, BorshSerialize}; /// Accounts. pub struct Withdraw { - /// The stake account to withdraw from - pub from: solana_program::pubkey::Pubkey, + /// Stake account from which to withdraw + pub stake: solana_program::pubkey::Pubkey, /// Recipient account - pub to: solana_program::pubkey::Pubkey, + pub recipient: solana_program::pubkey::Pubkey, /// Clock sysvar - pub clock: solana_program::pubkey::Pubkey, + pub clock_sysvar: solana_program::pubkey::Pubkey, /// Stake history sysvar pub stake_history: solana_program::pubkey::Pubkey, - /// from's withdraw authority. If stake Lockup is active, the signing lockup authority must follow. + /// Withdraw authority pub withdraw_authority: solana_program::pubkey::Pubkey, + /// Lockup authority + pub lockup_authority: Option, } impl Withdraw { @@ -34,15 +36,17 @@ impl Withdraw { args: WithdrawInstructionArgs, remaining_accounts: &[solana_program::instruction::AccountMeta], ) -> solana_program::instruction::Instruction { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); + let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - self.from, false, + self.stake, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - self.to, false, + self.recipient, + false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - self.clock, false, + self.clock_sysvar, + false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( self.stake_history, @@ -52,13 +56,24 @@ impl Withdraw { self.withdraw_authority, true, )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + lockup_authority, + true, + )); + } else { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + crate::STAKE_ID, + false, + )); + } accounts.extend_from_slice(remaining_accounts); let mut data = WithdrawInstructionData::new().try_to_vec().unwrap(); let mut args = args.try_to_vec().unwrap(); data.append(&mut args); solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, } @@ -67,14 +82,12 @@ impl Withdraw { #[derive(BorshDeserialize, BorshSerialize)] pub struct WithdrawInstructionData { - discriminator: [u8; 8], + discriminator: u8, } impl WithdrawInstructionData { pub fn new() -> Self { - Self { - discriminator: [183, 18, 70, 156, 148, 109, 161, 34], - } + Self { discriminator: 4 } } } @@ -87,26 +100,28 @@ impl Default for WithdrawInstructionData { #[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Eq, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WithdrawInstructionArgs { - pub lamports: u64, + pub args: u64, } /// Instruction builder for `Withdraw`. /// /// ### Accounts: /// -/// 0. `[writable]` from -/// 1. `[writable]` to -/// 2. `[]` clock +/// 0. `[writable]` stake +/// 1. `[writable]` recipient +/// 2. `[optional]` clock_sysvar (default to `SysvarC1ock11111111111111111111111111111111`) /// 3. `[]` stake_history /// 4. `[signer]` withdraw_authority +/// 5. `[signer, optional]` lockup_authority #[derive(Clone, Debug, Default)] pub struct WithdrawBuilder { - from: Option, - to: Option, - clock: Option, + stake: Option, + recipient: Option, + clock_sysvar: Option, stake_history: Option, withdraw_authority: Option, - lamports: Option, + lockup_authority: Option, + args: Option, __remaining_accounts: Vec, } @@ -114,22 +129,23 @@ impl WithdrawBuilder { pub fn new() -> Self { Self::default() } - /// The stake account to withdraw from + /// Stake account from which to withdraw #[inline(always)] - pub fn from(&mut self, from: solana_program::pubkey::Pubkey) -> &mut Self { - self.from = Some(from); + pub fn stake(&mut self, stake: solana_program::pubkey::Pubkey) -> &mut Self { + self.stake = Some(stake); self } /// Recipient account #[inline(always)] - pub fn to(&mut self, to: solana_program::pubkey::Pubkey) -> &mut Self { - self.to = Some(to); + pub fn recipient(&mut self, recipient: solana_program::pubkey::Pubkey) -> &mut Self { + self.recipient = Some(recipient); self } + /// `[optional account, default to 'SysvarC1ock11111111111111111111111111111111']` /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: solana_program::pubkey::Pubkey) -> &mut Self { - self.clock = Some(clock); + pub fn clock_sysvar(&mut self, clock_sysvar: solana_program::pubkey::Pubkey) -> &mut Self { + self.clock_sysvar = Some(clock_sysvar); self } /// Stake history sysvar @@ -138,7 +154,7 @@ impl WithdrawBuilder { self.stake_history = Some(stake_history); self } - /// from's withdraw authority. If stake Lockup is active, the signing lockup authority must follow. + /// Withdraw authority #[inline(always)] pub fn withdraw_authority( &mut self, @@ -147,9 +163,19 @@ impl WithdrawBuilder { self.withdraw_authority = Some(withdraw_authority); self } + /// `[optional account]` + /// Lockup authority #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { - self.lamports = Some(lamports); + pub fn lockup_authority( + &mut self, + lockup_authority: Option, + ) -> &mut Self { + self.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { + self.args = Some(args); self } /// Add an additional account to the instruction. @@ -173,16 +199,19 @@ impl WithdrawBuilder { #[allow(clippy::clone_on_copy)] pub fn instruction(&self) -> solana_program::instruction::Instruction { let accounts = Withdraw { - from: self.from.expect("from is not set"), - to: self.to.expect("to is not set"), - clock: self.clock.expect("clock is not set"), + stake: self.stake.expect("stake is not set"), + recipient: self.recipient.expect("recipient is not set"), + clock_sysvar: self.clock_sysvar.unwrap_or(solana_program::pubkey!( + "SysvarC1ock11111111111111111111111111111111" + )), stake_history: self.stake_history.expect("stake_history is not set"), withdraw_authority: self .withdraw_authority .expect("withdraw_authority is not set"), + lockup_authority: self.lockup_authority, }; let args = WithdrawInstructionArgs { - lamports: self.lamports.clone().expect("lamports is not set"), + args: self.args.clone().expect("args is not set"), }; accounts.instruction_with_remaining_accounts(args, &self.__remaining_accounts) @@ -191,32 +220,36 @@ impl WithdrawBuilder { /// `withdraw` CPI accounts. pub struct WithdrawCpiAccounts<'a, 'b> { - /// The stake account to withdraw from - pub from: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account from which to withdraw + pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Recipient account - pub to: &'b solana_program::account_info::AccountInfo<'a>, + pub recipient: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// Stake history sysvar pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, - /// from's withdraw authority. If stake Lockup is active, the signing lockup authority must follow. + /// Withdraw authority pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, } /// `withdraw` CPI instruction. pub struct WithdrawCpi<'a, 'b> { /// The program to invoke. pub __program: &'b solana_program::account_info::AccountInfo<'a>, - /// The stake account to withdraw from - pub from: &'b solana_program::account_info::AccountInfo<'a>, + /// Stake account from which to withdraw + pub stake: &'b solana_program::account_info::AccountInfo<'a>, /// Recipient account - pub to: &'b solana_program::account_info::AccountInfo<'a>, + pub recipient: &'b solana_program::account_info::AccountInfo<'a>, /// Clock sysvar - pub clock: &'b solana_program::account_info::AccountInfo<'a>, + pub clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, /// Stake history sysvar pub stake_history: &'b solana_program::account_info::AccountInfo<'a>, - /// from's withdraw authority. If stake Lockup is active, the signing lockup authority must follow. + /// Withdraw authority pub withdraw_authority: &'b solana_program::account_info::AccountInfo<'a>, + /// Lockup authority + pub lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, /// The arguments for the instruction. pub __args: WithdrawInstructionArgs, } @@ -229,11 +262,12 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { ) -> Self { Self { __program: program, - from: accounts.from, - to: accounts.to, - clock: accounts.clock, + stake: accounts.stake, + recipient: accounts.recipient, + clock_sysvar: accounts.clock_sysvar, stake_history: accounts.stake_history, withdraw_authority: accounts.withdraw_authority, + lockup_authority: accounts.lockup_authority, __args: args, } } @@ -270,17 +304,17 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { bool, )], ) -> solana_program::entrypoint::ProgramResult { - let mut accounts = Vec::with_capacity(5 + remaining_accounts.len()); + let mut accounts = Vec::with_capacity(6 + remaining_accounts.len()); accounts.push(solana_program::instruction::AccountMeta::new( - *self.from.key, + *self.stake.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new( - *self.to.key, + *self.recipient.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( - *self.clock.key, + *self.clock_sysvar.key, false, )); accounts.push(solana_program::instruction::AccountMeta::new_readonly( @@ -291,6 +325,17 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { *self.withdraw_authority.key, true, )); + if let Some(lockup_authority) = self.lockup_authority { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + *lockup_authority.key, + true, + )); + } else { + accounts.push(solana_program::instruction::AccountMeta::new_readonly( + crate::STAKE_ID, + false, + )); + } remaining_accounts.iter().for_each(|remaining_account| { accounts.push(solana_program::instruction::AccountMeta { pubkey: *remaining_account.0.key, @@ -303,17 +348,20 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { data.append(&mut args); let instruction = solana_program::instruction::Instruction { - program_id: crate::STAKE_PROGRAM_ID, + program_id: crate::STAKE_ID, accounts, data, }; - let mut account_infos = Vec::with_capacity(6 + remaining_accounts.len()); + let mut account_infos = Vec::with_capacity(7 + remaining_accounts.len()); account_infos.push(self.__program.clone()); - account_infos.push(self.from.clone()); - account_infos.push(self.to.clone()); - account_infos.push(self.clock.clone()); + account_infos.push(self.stake.clone()); + account_infos.push(self.recipient.clone()); + account_infos.push(self.clock_sysvar.clone()); account_infos.push(self.stake_history.clone()); account_infos.push(self.withdraw_authority.clone()); + if let Some(lockup_authority) = self.lockup_authority { + account_infos.push(lockup_authority.clone()); + } remaining_accounts .iter() .for_each(|remaining_account| account_infos.push(remaining_account.0.clone())); @@ -330,11 +378,12 @@ impl<'a, 'b> WithdrawCpi<'a, 'b> { /// /// ### Accounts: /// -/// 0. `[writable]` from -/// 1. `[writable]` to -/// 2. `[]` clock +/// 0. `[writable]` stake +/// 1. `[writable]` recipient +/// 2. `[]` clock_sysvar /// 3. `[]` stake_history /// 4. `[signer]` withdraw_authority +/// 5. `[signer, optional]` lockup_authority #[derive(Clone, Debug)] pub struct WithdrawCpiBuilder<'a, 'b> { instruction: Box>, @@ -344,32 +393,39 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { pub fn new(program: &'b solana_program::account_info::AccountInfo<'a>) -> Self { let instruction = Box::new(WithdrawCpiBuilderInstruction { __program: program, - from: None, - to: None, - clock: None, + stake: None, + recipient: None, + clock_sysvar: None, stake_history: None, withdraw_authority: None, - lamports: None, + lockup_authority: None, + args: None, __remaining_accounts: Vec::new(), }); Self { instruction } } - /// The stake account to withdraw from + /// Stake account from which to withdraw #[inline(always)] - pub fn from(&mut self, from: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.from = Some(from); + pub fn stake(&mut self, stake: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { + self.instruction.stake = Some(stake); self } /// Recipient account #[inline(always)] - pub fn to(&mut self, to: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.to = Some(to); + pub fn recipient( + &mut self, + recipient: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.recipient = Some(recipient); self } /// Clock sysvar #[inline(always)] - pub fn clock(&mut self, clock: &'b solana_program::account_info::AccountInfo<'a>) -> &mut Self { - self.instruction.clock = Some(clock); + pub fn clock_sysvar( + &mut self, + clock_sysvar: &'b solana_program::account_info::AccountInfo<'a>, + ) -> &mut Self { + self.instruction.clock_sysvar = Some(clock_sysvar); self } /// Stake history sysvar @@ -381,7 +437,7 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { self.instruction.stake_history = Some(stake_history); self } - /// from's withdraw authority. If stake Lockup is active, the signing lockup authority must follow. + /// Withdraw authority #[inline(always)] pub fn withdraw_authority( &mut self, @@ -390,9 +446,19 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { self.instruction.withdraw_authority = Some(withdraw_authority); self } + /// `[optional account]` + /// Lockup authority #[inline(always)] - pub fn lamports(&mut self, lamports: u64) -> &mut Self { - self.instruction.lamports = Some(lamports); + pub fn lockup_authority( + &mut self, + lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + ) -> &mut Self { + self.instruction.lockup_authority = lockup_authority; + self + } + #[inline(always)] + pub fn args(&mut self, args: u64) -> &mut Self { + self.instruction.args = Some(args); self } /// Add an additional account to the instruction. @@ -437,20 +503,19 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { signers_seeds: &[&[&[u8]]], ) -> solana_program::entrypoint::ProgramResult { let args = WithdrawInstructionArgs { - lamports: self - .instruction - .lamports - .clone() - .expect("lamports is not set"), + args: self.instruction.args.clone().expect("args is not set"), }; let instruction = WithdrawCpi { __program: self.instruction.__program, - from: self.instruction.from.expect("from is not set"), + stake: self.instruction.stake.expect("stake is not set"), - to: self.instruction.to.expect("to is not set"), + recipient: self.instruction.recipient.expect("recipient is not set"), - clock: self.instruction.clock.expect("clock is not set"), + clock_sysvar: self + .instruction + .clock_sysvar + .expect("clock_sysvar is not set"), stake_history: self .instruction @@ -461,6 +526,8 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { .instruction .withdraw_authority .expect("withdraw_authority is not set"), + + lockup_authority: self.instruction.lockup_authority, __args: args, }; instruction.invoke_signed_with_remaining_accounts( @@ -473,12 +540,13 @@ impl<'a, 'b> WithdrawCpiBuilder<'a, 'b> { #[derive(Clone, Debug)] struct WithdrawCpiBuilderInstruction<'a, 'b> { __program: &'b solana_program::account_info::AccountInfo<'a>, - from: Option<&'b solana_program::account_info::AccountInfo<'a>>, - to: Option<&'b solana_program::account_info::AccountInfo<'a>>, - clock: Option<&'b solana_program::account_info::AccountInfo<'a>>, + stake: Option<&'b solana_program::account_info::AccountInfo<'a>>, + recipient: Option<&'b solana_program::account_info::AccountInfo<'a>>, + clock_sysvar: Option<&'b solana_program::account_info::AccountInfo<'a>>, stake_history: Option<&'b solana_program::account_info::AccountInfo<'a>>, withdraw_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, - lamports: Option, + lockup_authority: Option<&'b solana_program::account_info::AccountInfo<'a>>, + args: Option, /// Additional instruction accounts `(AccountInfo, is_writable, is_signer)`. __remaining_accounts: Vec<( &'b solana_program::account_info::AccountInfo<'a>, diff --git a/clients/rust/src/generated/programs.rs b/clients/rust/src/generated/programs.rs index 947d173..e3286ac 100644 --- a/clients/rust/src/generated/programs.rs +++ b/clients/rust/src/generated/programs.rs @@ -7,5 +7,5 @@ use solana_program::{pubkey, pubkey::Pubkey}; -/// `stake_program` program ID. -pub const STAKE_PROGRAM_ID: Pubkey = pubkey!("Stake11111111111111111111111111111111111111"); +/// `stake` program ID. +pub const STAKE_ID: Pubkey = pubkey!("Stake11111111111111111111111111111111111111"); diff --git a/clients/rust/src/generated/types/authorized.rs b/clients/rust/src/generated/types/authorized.rs new file mode 100644 index 0000000..52520b9 --- /dev/null +++ b/clients/rust/src/generated/types/authorized.rs @@ -0,0 +1,25 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +use { + borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, +}; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, Eq, PartialEq)] +pub struct Authorized { + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub staker: Pubkey, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub withdrawer: Pubkey, +} diff --git a/clients/rust/src/generated/types/delegation.rs b/clients/rust/src/generated/types/delegation.rs new file mode 100644 index 0000000..fc35bb8 --- /dev/null +++ b/clients/rust/src/generated/types/delegation.rs @@ -0,0 +1,24 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +use { + borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, +}; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, PartialEq)] +pub struct Delegation { + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub voter_pubkey: Pubkey, + pub stake: u64, + pub activation_epoch: u64, + pub deactivation_epoch: u64, + pub warmup_cooldown_rate: f64, +} diff --git a/clients/rust/src/generated/types/lockup.rs b/clients/rust/src/generated/types/lockup.rs new file mode 100644 index 0000000..2425461 --- /dev/null +++ b/clients/rust/src/generated/types/lockup.rs @@ -0,0 +1,22 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +use { + borsh::{BorshDeserialize, BorshSerialize}, + solana_program::pubkey::Pubkey, +}; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, Eq, PartialEq)] +pub struct Lockup { + pub unix_timestamp: i64, + pub epoch: u64, + #[cfg_attr( + feature = "serde", + serde(with = "serde_with::As::") + )] + pub custodian: Pubkey, +} diff --git a/clients/rust/src/generated/types/meta.rs b/clients/rust/src/generated/types/meta.rs new file mode 100644 index 0000000..3000cd3 --- /dev/null +++ b/clients/rust/src/generated/types/meta.rs @@ -0,0 +1,18 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +use { + crate::generated::types::{Authorized, Lockup}, + borsh::{BorshDeserialize, BorshSerialize}, +}; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, PartialEq)] +pub struct Meta { + pub rent_exempt_reserve: u64, + pub authorized: Authorized, + pub lockup: Lockup, +} diff --git a/clients/rust/src/generated/types/mod.rs b/clients/rust/src/generated/types/mod.rs index a433b5c..41560de 100644 --- a/clients/rust/src/generated/types/mod.rs +++ b/clients/rust/src/generated/types/mod.rs @@ -5,6 +5,17 @@ //! //! +pub(crate) mod r#authorized; +pub(crate) mod r#delegation; +pub(crate) mod r#lockup; +pub(crate) mod r#meta; +pub(crate) mod r#stake; pub(crate) mod r#stake_authorize; +pub(crate) mod r#stake_flags; +pub(crate) mod r#stake_state; +pub(crate) mod r#stake_state_v2; -pub use self::r#stake_authorize::*; +pub use self::{ + r#authorized::*, r#delegation::*, r#lockup::*, r#meta::*, r#stake::*, r#stake_authorize::*, + r#stake_flags::*, r#stake_state::*, r#stake_state_v2::*, +}; diff --git a/clients/rust/src/generated/types/stake.rs b/clients/rust/src/generated/types/stake.rs new file mode 100644 index 0000000..891d78e --- /dev/null +++ b/clients/rust/src/generated/types/stake.rs @@ -0,0 +1,17 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +use { + crate::generated::types::Delegation, + borsh::{BorshDeserialize, BorshSerialize}, +}; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, PartialEq)] +pub struct Stake { + pub delegation: Delegation, + pub credits_observed: u64, +} diff --git a/clients/rust/src/generated/types/stake_flags.rs b/clients/rust/src/generated/types/stake_flags.rs new file mode 100644 index 0000000..a2a5b95 --- /dev/null +++ b/clients/rust/src/generated/types/stake_flags.rs @@ -0,0 +1,13 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +use borsh::{BorshDeserialize, BorshSerialize}; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, PartialEq)] +pub struct StakeFlags { + pub bits: u8, +} diff --git a/clients/rust/src/generated/types/stake_state.rs b/clients/rust/src/generated/types/stake_state.rs new file mode 100644 index 0000000..79c4bbf --- /dev/null +++ b/clients/rust/src/generated/types/stake_state.rs @@ -0,0 +1,19 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +use { + crate::generated::types::{Meta, Stake}, + borsh::{BorshDeserialize, BorshSerialize}, +}; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, PartialEq)] +pub enum StakeState { + Uninitialized, + Initialized(Meta), + Stake(Meta, Stake), + RewardsPool, +} diff --git a/clients/rust/src/generated/types/stake_state_v2.rs b/clients/rust/src/generated/types/stake_state_v2.rs new file mode 100644 index 0000000..bd944fa --- /dev/null +++ b/clients/rust/src/generated/types/stake_state_v2.rs @@ -0,0 +1,19 @@ +//! This code was AUTOGENERATED using the codama library. +//! Please DO NOT EDIT THIS FILE, instead use visitors +//! to add features, then rerun codama to update it. +//! +//! +//! + +use { + crate::generated::types::{Meta, Stake, StakeFlags}, + borsh::{BorshDeserialize, BorshSerialize}, +}; + +#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, PartialEq)] +pub enum StakeStateV2 { + Uninitialized, + Initialized(Meta), + Stake(Meta, Stake, StakeFlags), + RewardsPool, +} diff --git a/clients/rust/src/hooked/mod.rs b/clients/rust/src/hooked/mod.rs new file mode 100644 index 0000000..37365c3 --- /dev/null +++ b/clients/rust/src/hooked/mod.rs @@ -0,0 +1,2 @@ +pub mod stake_state_account; +pub use stake_state_account::*; diff --git a/clients/rust/src/hooked/stake_state_account.rs b/clients/rust/src/hooked/stake_state_account.rs new file mode 100644 index 0000000..7c35688 --- /dev/null +++ b/clients/rust/src/hooked/stake_state_account.rs @@ -0,0 +1,159 @@ +use { + crate::generated::types::{ + Authorized, Delegation, Lockup, Meta, Stake, StakeFlags, StakeStateV2, + }, + borsh::{BorshDeserialize, BorshSerialize}, + std::io::{Error, ErrorKind}, +}; + +#[derive(Clone, Debug)] +pub struct StakeStateAccount { + state: StakeStateV2, +} + +impl StakeStateAccount { + #[inline(always)] + pub fn from_bytes(data: &[u8]) -> Result { + let mut data = data; + Self::deserialize(&mut data) + } + + pub const fn size_of() -> usize { + 200 + } + + pub fn stake(&self) -> Option { + match self.state { + StakeStateV2::Stake(_meta, stake, _stake_flags) => Some(stake), + StakeStateV2::Uninitialized + | StakeStateV2::Initialized(_) + | StakeStateV2::RewardsPool => None, + } + } + + pub fn stake_ref(&self) -> Option<&Stake> { + match &self.state { + StakeStateV2::Stake(_meta, stake, _stake_flags) => Some(stake), + StakeStateV2::Uninitialized + | StakeStateV2::Initialized(_) + | StakeStateV2::RewardsPool => None, + } + } + + pub fn stake_flags(&self) -> Option { + match self.state { + StakeStateV2::Stake(_meta, _stake, stake_flags) => Some(stake_flags), + StakeStateV2::Uninitialized + | StakeStateV2::Initialized(_) + | StakeStateV2::RewardsPool => None, + } + } + + pub fn stake_flags_ref(&self) -> Option<&StakeFlags> { + match &self.state { + StakeStateV2::Stake(_meta, _stake, stake_flags) => Some(stake_flags), + StakeStateV2::Uninitialized + | StakeStateV2::Initialized(_) + | StakeStateV2::RewardsPool => None, + } + } + + pub fn delegation(&self) -> Option { + match self.state { + StakeStateV2::Stake(_meta, stake, _stake_flags) => Some(stake.delegation), + StakeStateV2::Uninitialized + | StakeStateV2::Initialized(_) + | StakeStateV2::RewardsPool => None, + } + } + + pub fn delegation_ref(&self) -> Option<&Delegation> { + match &self.state { + StakeStateV2::Stake(_meta, stake, _stake_flags) => Some(&stake.delegation), + StakeStateV2::Uninitialized + | StakeStateV2::Initialized(_) + | StakeStateV2::RewardsPool => None, + } + } + + pub fn authorized(&self) -> Option { + match self.state { + StakeStateV2::Stake(meta, _stake, _stake_flags) => Some(meta.authorized), + StakeStateV2::Initialized(meta) => Some(meta.authorized), + StakeStateV2::Uninitialized | StakeStateV2::RewardsPool => None, + } + } + + pub fn lockup(&self) -> Option { + self.meta().map(|meta| meta.lockup) + } + + pub fn meta(&self) -> Option { + match self.state { + StakeStateV2::Stake(meta, _stake, _stake_flags) => Some(meta), + StakeStateV2::Initialized(meta) => Some(meta), + StakeStateV2::Uninitialized | StakeStateV2::RewardsPool => None, + } + } + + pub fn meta_ref(&self) -> Option<&Meta> { + match &self.state { + StakeStateV2::Stake(meta, _stake, _stake_flags) => Some(meta), + StakeStateV2::Initialized(meta) => Some(meta), + StakeStateV2::Uninitialized | StakeStateV2::RewardsPool => None, + } + } +} + +impl<'a> TryFrom<&solana_program::account_info::AccountInfo<'a>> for StakeStateAccount { + type Error = std::io::Error; + + fn try_from( + account_info: &solana_program::account_info::AccountInfo<'a>, + ) -> Result { + let mut data: &[u8] = &(*account_info.data).borrow(); + Self::deserialize(&mut data) + } +} + +impl BorshDeserialize for StakeStateAccount { + fn deserialize_reader(reader: &mut R) -> std::io::Result { + let enum_value: u32 = BorshDeserialize::deserialize_reader(reader)?; + let state = match enum_value { + 0 => StakeStateV2::Uninitialized, + 1 => { + let meta: Meta = BorshDeserialize::deserialize_reader(reader)?; + StakeStateV2::Initialized(meta) + } + 2 => { + let meta: Meta = BorshDeserialize::deserialize_reader(reader)?; + let stake: Stake = BorshDeserialize::deserialize_reader(reader)?; + let stake_flags: StakeFlags = BorshDeserialize::deserialize_reader(reader)?; + StakeStateV2::Stake(meta, stake, stake_flags) + } + 3 => StakeStateV2::RewardsPool, + _ => return Err(Error::new(ErrorKind::InvalidData, "Invalid enum value")), + }; + + Ok(StakeStateAccount { state }) + } +} + +impl BorshSerialize for StakeStateAccount { + fn serialize(&self, writer: &mut W) -> std::io::Result<()> { + match self.state { + StakeStateV2::Uninitialized => writer.write_all(&0u32.to_le_bytes()), + StakeStateV2::Initialized(ref meta) => { + writer.write_all(&1u32.to_le_bytes())?; + BorshSerialize::serialize(meta, writer) + } + StakeStateV2::Stake(ref meta, ref stake, ref stake_flags) => { + writer.write_all(&2u32.to_le_bytes())?; + BorshSerialize::serialize(meta, writer)?; + BorshSerialize::serialize(stake, writer)?; + BorshSerialize::serialize(stake_flags, writer) + } + StakeStateV2::RewardsPool => writer.write_all(&3u32.to_le_bytes()), + } + } +} diff --git a/clients/rust/src/lib.rs b/clients/rust/src/lib.rs index 72d44ec..5c13054 100644 --- a/clients/rust/src/lib.rs +++ b/clients/rust/src/lib.rs @@ -1,3 +1,7 @@ mod generated; +mod hooked; -pub use generated::{programs::STAKE_PROGRAM_ID as ID, *}; +pub use { + generated::{programs::STAKE_ID as ID, *}, + hooked::StakeStateAccount, +}; diff --git a/interface/Cargo.toml b/interface/Cargo.toml index 88c7a60..7953b8a 100644 --- a/interface/Cargo.toml +++ b/interface/Cargo.toml @@ -7,6 +7,9 @@ edition = "2021" readme = "README.md" license-file = "../LICENSE" +[package.metadata.solana] +program-id = "Stake11111111111111111111111111111111111111" + [dependencies] borsh = { version = "1.5.1", features = ["derive", "unstable__schema"], optional = true } borsh0-10 = { package = "borsh", version = "0.10.3", optional = true } diff --git a/interface/idl.json b/interface/idl.json new file mode 100644 index 0000000..f344501 --- /dev/null +++ b/interface/idl.json @@ -0,0 +1,1078 @@ +{ + "version": "0.1.0", + "name": "solana_stake_interface", + "instructions": [ + { + "name": "Initialize", + "accounts": [ + { + "name": "stake", + "isMut": true, + "isSigner": false, + "docs": [ + "Uninitialized stake account" + ] + }, + { + "name": "rentSysvar", + "isMut": false, + "isSigner": false, + "docs": [ + "Rent sysvar" + ] + } + ], + "args": [ + { + "name": "arg0", + "type": { + "defined": "Authorized" + } + }, + { + "name": "arg1", + "type": { + "defined": "Lockup" + } + } + ], + "discriminant": { + "type": "u8", + "value": 0 + } + }, + { + "name": "Authorize", + "accounts": [ + { + "name": "stake", + "isMut": true, + "isSigner": false, + "docs": [ + "Stake account to be updated" + ] + }, + { + "name": "clockSysvar", + "isMut": false, + "isSigner": false, + "docs": [ + "Clock sysvar" + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": true, + "docs": [ + "Stake or withdraw authority" + ] + }, + { + "name": "lockupAuthority", + "isMut": false, + "isSigner": true, + "isOptional": true, + "docs": [ + "Lockup authority" + ] + } + ], + "args": [ + { + "name": "arg0", + "type": "publicKey" + }, + { + "name": "arg1", + "type": { + "defined": "StakeAuthorize" + } + } + ], + "discriminant": { + "type": "u8", + "value": 1 + } + }, + { + "name": "DelegateStake", + "accounts": [ + { + "name": "stake", + "isMut": true, + "isSigner": false, + "docs": [ + "Initialized stake account to be delegated" + ] + }, + { + "name": "vote", + "isMut": false, + "isSigner": false, + "docs": [ + "Vote account to which this stake will be delegated" + ] + }, + { + "name": "clockSysvar", + "isMut": false, + "isSigner": false, + "docs": [ + "Clock sysvar" + ] + }, + { + "name": "stakeHistory", + "isMut": false, + "isSigner": false, + "docs": [ + "Stake history sysvar" + ] + }, + { + "name": "unused", + "isMut": false, + "isSigner": false, + "docs": [ + "Unused account, formerly the stake config" + ] + }, + { + "name": "stakeAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "Stake authority" + ] + } + ], + "args": [], + "discriminant": { + "type": "u8", + "value": 2 + } + }, + { + "name": "Split", + "accounts": [ + { + "name": "stake", + "isMut": true, + "isSigner": false, + "docs": [ + "Stake account to be split" + ] + }, + { + "name": "splitStake", + "isMut": true, + "isSigner": false, + "docs": [ + "Uninitialized stake account" + ] + }, + { + "name": "stakeAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "Stake authority" + ] + } + ], + "args": [ + { + "name": "args", + "type": "u64" + } + ], + "discriminant": { + "type": "u8", + "value": 3 + } + }, + { + "name": "Withdraw", + "accounts": [ + { + "name": "stake", + "isMut": true, + "isSigner": false, + "docs": [ + "Stake account from which to withdraw" + ] + }, + { + "name": "recipient", + "isMut": true, + "isSigner": false, + "docs": [ + "Recipient account" + ] + }, + { + "name": "clockSysvar", + "isMut": false, + "isSigner": false, + "docs": [ + "Clock sysvar" + ] + }, + { + "name": "stakeHistory", + "isMut": false, + "isSigner": false, + "docs": [ + "Stake history sysvar" + ] + }, + { + "name": "withdrawAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "Withdraw authority" + ] + }, + { + "name": "lockupAuthority", + "isMut": false, + "isSigner": true, + "isOptional": true, + "docs": [ + "Lockup authority" + ] + } + ], + "args": [ + { + "name": "args", + "type": "u64" + } + ], + "discriminant": { + "type": "u8", + "value": 4 + } + }, + { + "name": "Deactivate", + "accounts": [ + { + "name": "stake", + "isMut": true, + "isSigner": false, + "docs": [ + "Delegated stake account" + ] + }, + { + "name": "clockSysvar", + "isMut": false, + "isSigner": false, + "docs": [ + "Clock sysvar" + ] + }, + { + "name": "stakeAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "Stake authority" + ] + } + ], + "args": [], + "discriminant": { + "type": "u8", + "value": 5 + } + }, + { + "name": "SetLockup", + "accounts": [ + { + "name": "stake", + "isMut": true, + "isSigner": false, + "docs": [ + "Initialized stake account" + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": true, + "docs": [ + "Lockup authority or withdraw authority" + ] + } + ], + "args": [ + { + "name": "lockupArgs", + "type": { + "defined": "LockupArgs" + } + } + ], + "discriminant": { + "type": "u8", + "value": 6 + } + }, + { + "name": "Merge", + "accounts": [ + { + "name": "destinationStake", + "isMut": true, + "isSigner": false, + "docs": [ + "Destination stake account" + ] + }, + { + "name": "sourceStake", + "isMut": true, + "isSigner": false, + "docs": [ + "Source stake account" + ] + }, + { + "name": "clockSysvar", + "isMut": false, + "isSigner": false, + "docs": [ + "Clock sysvar" + ] + }, + { + "name": "stakeHistory", + "isMut": false, + "isSigner": false, + "docs": [ + "Stake history sysvar" + ] + }, + { + "name": "stakeAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "Stake authority" + ] + } + ], + "args": [], + "discriminant": { + "type": "u8", + "value": 7 + } + }, + { + "name": "AuthorizeWithSeed", + "accounts": [ + { + "name": "stake", + "isMut": true, + "isSigner": false, + "docs": [ + "Stake account to be updated" + ] + }, + { + "name": "base", + "isMut": false, + "isSigner": true, + "docs": [ + "Base key of stake or withdraw authority" + ] + }, + { + "name": "clockSysvar", + "isMut": false, + "isSigner": false, + "docs": [ + "Clock sysvar" + ] + }, + { + "name": "lockupAuthority", + "isMut": false, + "isSigner": true, + "isOptional": true, + "docs": [ + "Lockup authority" + ] + } + ], + "args": [ + { + "name": "authorizeWithSeedArgs", + "type": { + "defined": "AuthorizeWithSeedArgs" + } + } + ], + "discriminant": { + "type": "u8", + "value": 8 + } + }, + { + "name": "InitializeChecked", + "accounts": [ + { + "name": "stake", + "isMut": true, + "isSigner": false, + "docs": [ + "Uninitialized stake account" + ] + }, + { + "name": "rentSysvar", + "isMut": false, + "isSigner": false, + "docs": [ + "Rent sysvar" + ] + }, + { + "name": "stakeAuthority", + "isMut": false, + "isSigner": false, + "docs": [ + "The stake authority" + ] + }, + { + "name": "withdrawAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "The withdraw authority" + ] + } + ], + "args": [], + "discriminant": { + "type": "u8", + "value": 9 + } + }, + { + "name": "AuthorizeChecked", + "accounts": [ + { + "name": "stake", + "isMut": true, + "isSigner": false, + "docs": [ + "Stake account to be updated" + ] + }, + { + "name": "clockSysvar", + "isMut": false, + "isSigner": false, + "docs": [ + "Clock sysvar" + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": true, + "docs": [ + "The stake or withdraw authority" + ] + }, + { + "name": "newAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "The new stake or withdraw authority" + ] + }, + { + "name": "lockupAuthority", + "isMut": false, + "isSigner": true, + "isOptional": true, + "docs": [ + "Lockup authority" + ] + } + ], + "args": [ + { + "name": "stakeAuthorize", + "type": { + "defined": "StakeAuthorize" + } + } + ], + "discriminant": { + "type": "u8", + "value": 10 + } + }, + { + "name": "AuthorizeCheckedWithSeed", + "accounts": [ + { + "name": "stake", + "isMut": true, + "isSigner": false, + "docs": [ + "Stake account to be updated" + ] + }, + { + "name": "base", + "isMut": false, + "isSigner": true, + "docs": [ + "Base key of stake or withdraw authority" + ] + }, + { + "name": "clockSysvar", + "isMut": false, + "isSigner": false, + "docs": [ + "Clock sysvar" + ] + }, + { + "name": "newAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "The new stake or withdraw authority" + ] + }, + { + "name": "lockupAuthority", + "isMut": false, + "isSigner": true, + "isOptional": true, + "docs": [ + "Lockup authority" + ] + } + ], + "args": [ + { + "name": "authorizeCheckedWithSeedArgs", + "type": { + "defined": "AuthorizeCheckedWithSeedArgs" + } + } + ], + "discriminant": { + "type": "u8", + "value": 11 + } + }, + { + "name": "SetLockupChecked", + "accounts": [ + { + "name": "stake", + "isMut": true, + "isSigner": false, + "docs": [ + "Initialized stake account" + ] + }, + { + "name": "authority", + "isMut": false, + "isSigner": true, + "docs": [ + "Lockup authority or withdraw authority" + ] + }, + { + "name": "newAuthority", + "isMut": false, + "isSigner": true, + "isOptional": true, + "docs": [ + "New lockup authority" + ] + } + ], + "args": [ + { + "name": "lockupCheckedArgs", + "type": { + "defined": "LockupCheckedArgs" + } + } + ], + "discriminant": { + "type": "u8", + "value": 12 + } + }, + { + "name": "GetMinimumDelegation", + "accounts": [], + "args": [], + "discriminant": { + "type": "u8", + "value": 13 + } + }, + { + "name": "DeactivateDelinquent", + "accounts": [ + { + "name": "stake", + "isMut": true, + "isSigner": false, + "docs": [ + "Delegated stake account" + ] + }, + { + "name": "delinquentVote", + "isMut": false, + "isSigner": false, + "docs": [ + "Delinquent vote account" + ] + }, + { + "name": "referenceVote", + "isMut": false, + "isSigner": false, + "docs": [ + "Reference vote account" + ] + } + ], + "args": [], + "discriminant": { + "type": "u8", + "value": 14 + } + }, + { + "name": "Redelegate", + "accounts": [], + "args": [], + "discriminant": { + "type": "u8", + "value": 15 + } + }, + { + "name": "MoveStake", + "accounts": [ + { + "name": "sourceStake", + "isMut": true, + "isSigner": false, + "docs": [ + "Active source stake account" + ] + }, + { + "name": "destinationStake", + "isMut": true, + "isSigner": false, + "docs": [ + "Active or inactive destination stake account" + ] + }, + { + "name": "stakeAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "Stake authority" + ] + } + ], + "args": [ + { + "name": "args", + "type": "u64" + } + ], + "discriminant": { + "type": "u8", + "value": 16 + } + }, + { + "name": "MoveLamports", + "accounts": [ + { + "name": "sourceStake", + "isMut": true, + "isSigner": false, + "docs": [ + "Active or inactive source stake account" + ] + }, + { + "name": "destinationStake", + "isMut": true, + "isSigner": false, + "docs": [ + "Mergeable destination stake account" + ] + }, + { + "name": "stakeAuthority", + "isMut": false, + "isSigner": true, + "docs": [ + "Stake authority" + ] + } + ], + "args": [ + { + "name": "args", + "type": "u64" + } + ], + "discriminant": { + "type": "u8", + "value": 17 + } + } + ], + "types": [ + { + "name": "LockupArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "unixTimestamp", + "type": { + "option": { + "defined": "UnixTimestamp" + } + } + }, + { + "name": "epoch", + "type": { + "option": { + "defined": "Epoch" + } + } + }, + { + "name": "custodian", + "type": { + "option": "publicKey" + } + } + ] + } + }, + { + "name": "LockupCheckedArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "unixTimestamp", + "type": { + "option": { + "defined": "UnixTimestamp" + } + } + }, + { + "name": "epoch", + "type": { + "option": { + "defined": "Epoch" + } + } + } + ] + } + }, + { + "name": "AuthorizeWithSeedArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newAuthorizedPubkey", + "type": "publicKey" + }, + { + "name": "stakeAuthorize", + "type": { + "defined": "StakeAuthorize" + } + }, + { + "name": "authoritySeed", + "type": "string" + }, + { + "name": "authorityOwner", + "type": "publicKey" + } + ] + } + }, + { + "name": "AuthorizeCheckedWithSeedArgs", + "type": { + "kind": "struct", + "fields": [ + { + "name": "stakeAuthorize", + "type": { + "defined": "StakeAuthorize" + } + }, + { + "name": "authoritySeed", + "type": "string" + }, + { + "name": "authorityOwner", + "type": "publicKey" + } + ] + } + }, + { + "name": "StakeFlags", + "type": { + "kind": "struct", + "fields": [ + { + "name": "bits", + "type": "u8" + } + ] + } + }, + { + "name": "Lockup", + "type": { + "kind": "struct", + "fields": [ + { + "name": "unixTimestamp", + "type": { + "defined": "UnixTimestamp" + } + }, + { + "name": "epoch", + "type": { + "defined": "Epoch" + } + }, + { + "name": "custodian", + "type": "publicKey" + } + ] + } + }, + { + "name": "Authorized", + "type": { + "kind": "struct", + "fields": [ + { + "name": "staker", + "type": "publicKey" + }, + { + "name": "withdrawer", + "type": "publicKey" + } + ] + } + }, + { + "name": "Meta", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rentExemptReserve", + "type": "u64" + }, + { + "name": "authorized", + "type": { + "defined": "Authorized" + } + }, + { + "name": "lockup", + "type": { + "defined": "Lockup" + } + } + ] + } + }, + { + "name": "Delegation", + "type": { + "kind": "struct", + "fields": [ + { + "name": "voterPubkey", + "type": "publicKey" + }, + { + "name": "stake", + "type": "u64" + }, + { + "name": "activationEpoch", + "type": { + "defined": "Epoch" + } + }, + { + "name": "deactivationEpoch", + "type": { + "defined": "Epoch" + } + }, + { + "name": "warmupCooldownRate", + "type": { + "defined": "f64" + } + } + ] + } + }, + { + "name": "Stake", + "type": { + "kind": "struct", + "fields": [ + { + "name": "delegation", + "type": { + "defined": "Delegation" + } + }, + { + "name": "creditsObserved", + "type": "u64" + } + ] + } + }, + { + "name": "StakeState", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Uninitialized" + }, + { + "name": "Initialized", + "fields": [ + { + "defined": "Meta" + } + ] + }, + { + "name": "Stake", + "fields": [ + { + "defined": "Meta" + }, + { + "defined": "Stake" + } + ] + }, + { + "name": "RewardsPool" + } + ] + } + }, + { + "name": "StakeStateV2", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Uninitialized" + }, + { + "name": "Initialized", + "fields": [ + { + "defined": "Meta" + } + ] + }, + { + "name": "Stake", + "fields": [ + { + "defined": "Meta" + }, + { + "defined": "Stake" + }, + { + "defined": "StakeFlags" + } + ] + }, + { + "name": "RewardsPool" + } + ] + } + }, + { + "name": "StakeAuthorize", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Staker" + }, + { + "name": "Withdrawer" + } + ] + } + } + ], + "metadata": { + "origin": "shank", + "address": "Stake11111111111111111111111111111111111111", + "binaryVersion": "0.4.2", + "libVersion": "0.4.2" + } +} \ No newline at end of file diff --git a/interface/src/instruction.rs b/interface/src/instruction.rs index c6f2794..b74835b 100644 --- a/interface/src/instruction.rs +++ b/interface/src/instruction.rs @@ -158,7 +158,6 @@ pub enum StakeInstruction { /// 1. `[]` Rent sysvar /// 2. `[]` The stake authority /// 3. `[SIGNER]` The withdraw authority - /// InitializeChecked, /// Authorize a key to manage stake or withdrawal diff --git a/package.json b/package.json index 06ebf47..07a3f5e 100644 --- a/package.json +++ b/package.json @@ -6,10 +6,9 @@ "programs:clean": "zx ./scripts/program/clean.mjs", "programs:format": "zx ./scripts/program/format.mjs", "programs:lint": "zx ./scripts/program/lint.mjs", - "generate:idls": "zx ./scripts/generate-idls.mjs", "solana:check": "zx ./scripts/check-solana-version.mjs", "solana:link": "zx ./scripts/link-solana-version.mjs", - "generate": "pnpm generate:idls && pnpm generate:clients", + "generate": "pnpm generate:clients", "generate:clients": "zx ./scripts/generate-clients.mjs", "validator:start": "zx ./scripts/start-validator.mjs", "validator:restart": "pnpm validator:start --restart", @@ -24,12 +23,12 @@ "clients:rust:test": "zx ./scripts/client/test-rust.mjs" }, "devDependencies": { - "@codama/nodes-from-anchor": "^1.0.0", - "@codama/renderers-js": "^1.0.1", - "@codama/renderers-rust": "^1.0.3", + "@codama/nodes-from-anchor": "^1.0.1", + "@codama/renderers-js": "^1.1.0", + "@codama/renderers-rust": "^1.0.4", "@iarna/toml": "^2.2.5", "@metaplex-foundation/shank-js": "^0.1.7", - "codama": "^1.0.0", + "codama": "^1.1.0", "typescript": "^5.5.2", "zx": "^7.2.3" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 29dea5b..4e03e18 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,14 +9,14 @@ importers: .: devDependencies: '@codama/nodes-from-anchor': - specifier: ^1.0.0 - version: 1.0.0 - '@codama/renderers-js': specifier: ^1.0.1 - version: 1.0.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + version: 1.0.1 + '@codama/renderers-js': + specifier: ^1.1.0 + version: 1.1.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) '@codama/renderers-rust': - specifier: ^1.0.3 - version: 1.0.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + specifier: ^1.0.4 + version: 1.0.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) '@iarna/toml': specifier: ^2.2.5 version: 2.2.5 @@ -24,8 +24,8 @@ importers: specifier: ^0.1.7 version: 0.1.7 codama: - specifier: ^1.0.0 - version: 1.0.0 + specifier: ^1.1.0 + version: 1.1.0 typescript: specifier: ^5.5.2 version: 5.6.3 @@ -35,36 +35,36 @@ importers: packages: - '@codama/errors@1.0.0': - resolution: {integrity: sha512-XSdkNbCNJukhKO5TFJ5cFP7TfddxZwqHV7N/XyMbZ0meVPN1ymT94/d/9b8R+bvKuflj/SXImv527tGZWz6pGA==} + '@codama/errors@1.1.0': + resolution: {integrity: sha512-njLWTPYgz5uJP02617CX0BZCHGHrHnQvKroU0z4YcJZiaMQlw3VLzb+e2ZU2X+uVpp+3ITJZ9yexuoEhJBVQdQ==} hasBin: true - '@codama/node-types@1.0.0': - resolution: {integrity: sha512-UAc+0jprwHFOqtAPqqA//PkrnlUzuqs+N5E36bHhLV0m5qWMlqrfmPg/ffBwMYFJsLFWsRsisALrqPy7ARkUow==} + '@codama/node-types@1.1.0': + resolution: {integrity: sha512-+J6E0didCY0+8dr2vI6ag+FMaMr3SemvXJYKOhxKEJ6HXR/J+7cddpptXyrIhLa8R2Kw0yzIG9VjAlUGL7u8OQ==} - '@codama/nodes-from-anchor@1.0.0': - resolution: {integrity: sha512-urqFOV5K1oKBptgIFFLCPWrUsEeZsonml12ieP26ozX12aglGlN0tsxNsCvxJulRIjUxuONbH6xzv7uKt0xSYQ==} + '@codama/nodes-from-anchor@1.0.1': + resolution: {integrity: sha512-9sITAJyWxjbuBqeSmiA/AzN15+65KvycPJmc0ReWWsbqBCblr0A5jeA/zFbfILRFcu6MVyJXpQvl42FZ/vAL1g==} - '@codama/nodes@1.0.0': - resolution: {integrity: sha512-btcnjDaOpEFvVq3uVzlQK4G2OxxyK3P9HkXw423GZaqYQzeSr1pDdTKjyVyg+QO578CGqIMySVlJ2UAdHVMytw==} + '@codama/nodes@1.1.0': + resolution: {integrity: sha512-a6lX45CqfvdU5jKx63zWVEUbyAjEKqjye3EkboKNEJIM0RDmDwtTqNuQBR8HHx9nO7EBPypxYOXtGpmVXg0xYw==} - '@codama/renderers-core@1.0.0': - resolution: {integrity: sha512-WYvOylIzcR0WOc7GlUvGi5ym8IwmslwyV8zfj7FR646bMqaROirFJc+naGEbZ1lMykOyxcackTKL0eDB7954Qw==} + '@codama/renderers-core@1.0.1': + resolution: {integrity: sha512-EOOQx2s5t6huVJRXwwLC6adyqSuDPVKIWXiDhy5uyJBRlNk18/vb4OmVoXTIWb6mS64m/j0DuyrWJWzIUUJ84w==} - '@codama/renderers-js@1.0.1': - resolution: {integrity: sha512-RwTJM5L4ZuKZ9TUdr1K5PODr7Ji0lsqcqQGXQ71Hg+ZHQ+F4jj3RPvoWHxYm5tYMuqRajQxqL/W49kxqEtc96w==} + '@codama/renderers-js@1.1.0': + resolution: {integrity: sha512-LeFLDlKb726q6VARnuKCQ0qV2c0xS6s7U1jF7WrecMj3zrWy5hN1yGKKEZdItq95M0JOawbHbejjP9aiJ4R7Kw==} - '@codama/renderers-rust@1.0.3': - resolution: {integrity: sha512-S2n+bq92q5YZ01Z+8klNNbvgVErKsJzUYWN0Y0rPymx2vwkHfTkeQHEOuckb/kzHJm9QGXrzkDtSDBy5EDS1Wg==} + '@codama/renderers-rust@1.0.4': + resolution: {integrity: sha512-+THq6bCInn30dKEGGNrilnbaitA8A3pOjfsqwka/i3Aip5x5At6lk7VcQwoWzDvvcy/2FHaOVi3hmlc28d8maw==} - '@codama/validators@1.0.0': - resolution: {integrity: sha512-jSfU5IrcGTvcqsJSBSzD3Ochig+hKKg2NKsT/vUfQ4jAw2cQrVUP5f4dMXyX779JYfHLHCwZnBYvgEdgi9gBZQ==} + '@codama/validators@1.1.0': + resolution: {integrity: sha512-TVzTjN2m1bGauLnqJE12lZfZf1L2C9Hal7/i0sjNmtc3UbUL7pIH5Rp4bFSyfDuyhMD0JfxtJqr3YlK6yXoqkA==} - '@codama/visitors-core@1.0.0': - resolution: {integrity: sha512-tDIfURVPf7ZokCFLOpKL6Au0ORiza1sPT4zmRSEjCC7iZp0Vb5K5FrdtUL13Wb+6jNM191e5GUFOmULRoavWug==} + '@codama/visitors-core@1.1.0': + resolution: {integrity: sha512-NBJAgGmVdFIWHDsKSKjTYbIfSZRyRzgqPzmHFgRIRjy4Uw63zOwP5Yk1bctWrP6YRlGjrTunfVkOIA6QiVr6lg==} - '@codama/visitors@1.0.0': - resolution: {integrity: sha512-JncE6wRJLxt0imlj+loGH6dLPEMK7ozlv9YjWgCQgUYUI7is66OFwhWP5SFO0iEFlVjtOzZLXVQwoe9LSDz8Gg==} + '@codama/visitors@1.1.0': + resolution: {integrity: sha512-QpAShuxemS8oplHDXNqnUnYwhJq58RZjfZ/KMIpdm88OCBnQRO4YfM/zQLEvXjA+tpwJpe4WnL6opTLLnSYThw==} '@iarna/toml@2.2.5': resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} @@ -91,27 +91,27 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} - '@solana/codecs-core@2.0.0-rc.3': - resolution: {integrity: sha512-Z+KkHRHxxN/Ei4ujIxZeNiSuhioGSKnxNbswBvd/nNAv6Q9zi1DJMV2gIE1MKE/H6ZtrLCAiiHYBRtHpdAyndg==} + '@solana/codecs-core@2.0.0-rc.4': + resolution: {integrity: sha512-JIrTSps032mSE3wBxW3bXOqWfoy4CMy1CX/XeVCijyh5kLVxZTSDIdRTYdePdL1yzaOZF1Xysvt1DhOUgBdM+A==} engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/codecs-numbers@2.0.0-rc.3': - resolution: {integrity: sha512-ii05vAeZt5c5wbA8KLSLiV2WR5hHcnk1cp57UnjvIs2kX2oORXP0xKonK9AX0YxEc66ZnMBnE9e0wW28M4Bk/A==} + '@solana/codecs-numbers@2.0.0-rc.4': + resolution: {integrity: sha512-ZJR7TaUO65+3Hzo3YOOUCS0wlzh17IW+j0MZC2LCk1R0woaypRpHKj4iSMYeQOZkMxsd9QT3WNvjFrPC2qA6Sw==} engines: {node: '>=20.18.0'} peerDependencies: typescript: '>=5' - '@solana/codecs-strings@2.0.0-rc.3': - resolution: {integrity: sha512-eSYCPOEY1OARiP+i0ovrTyzRPlRVp8e8fmtGwSXKQoqvsdTJCWm80YVc6IeP8pIQD4KLO39Xae2WNq13e94CMg==} + '@solana/codecs-strings@2.0.0-rc.4': + resolution: {integrity: sha512-LGfK2RL0BKjYYUfzu2FG/gTgCsYOMz9FKVs2ntji6WneZygPxJTV5W98K3J8Rl0JewpCSCFQH3xjLSHBJUS0fA==} engines: {node: '>=20.18.0'} peerDependencies: fastestsmallesttextencoderdecoder: ^1.0.22 typescript: '>=5' - '@solana/errors@2.0.0-rc.3': - resolution: {integrity: sha512-bFEOfktu53RzZw9VVeFS+tHXmHEXD9KYtRu764Z4QxKe33RqwZgHiLh4MHvPska8BPN3VAw4azotF+KWVMGztw==} + '@solana/errors@2.0.0-rc.4': + resolution: {integrity: sha512-0PPaMyB81keEHG/1pnyEuiBVKctbXO641M2w3CIOrYT/wzjunfF0FTxsqq9wYJeYo0AyiefCKGgSPs6wiY2PpQ==} engines: {node: '>=20.18.0'} hasBin: true peerDependencies: @@ -157,8 +157,8 @@ packages: resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} - codama@1.0.0: - resolution: {integrity: sha512-ttJ9n2THpqTD8fP8reec+Y2j4ZTBuonDJk8SiKuS6enZBXd67JF3b+GFKM2S5a0xtxN5Evof5aBlY3JyC+jujQ==} + codama@1.1.0: + resolution: {integrity: sha512-dr0iTND6q9goY0CwNmX5tk53iJ/KhziN/js/x2g4Dvl5K6tUGy+iR20yeBYw8lq1rwUDIocOEgKVq/HcKOI9yA==} commander@12.1.0: resolution: {integrity: sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==} @@ -443,40 +443,40 @@ packages: snapshots: - '@codama/errors@1.0.0': + '@codama/errors@1.1.0': dependencies: - '@codama/node-types': 1.0.0 + '@codama/node-types': 1.1.0 chalk: 5.3.0 commander: 12.1.0 - '@codama/node-types@1.0.0': {} + '@codama/node-types@1.1.0': {} - '@codama/nodes-from-anchor@1.0.0': + '@codama/nodes-from-anchor@1.0.1': dependencies: - '@codama/errors': 1.0.0 - '@codama/nodes': 1.0.0 - '@codama/visitors': 1.0.0 + '@codama/errors': 1.1.0 + '@codama/nodes': 1.1.0 + '@codama/visitors': 1.1.0 '@noble/hashes': 1.5.0 - '@codama/nodes@1.0.0': + '@codama/nodes@1.1.0': dependencies: - '@codama/errors': 1.0.0 - '@codama/node-types': 1.0.0 + '@codama/errors': 1.1.0 + '@codama/node-types': 1.1.0 - '@codama/renderers-core@1.0.0': + '@codama/renderers-core@1.0.1': dependencies: - '@codama/errors': 1.0.0 - '@codama/nodes': 1.0.0 - '@codama/visitors-core': 1.0.0 + '@codama/errors': 1.1.0 + '@codama/nodes': 1.1.0 + '@codama/visitors-core': 1.1.0 - '@codama/renderers-js@1.0.1(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@codama/renderers-js@1.1.0(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@codama/errors': 1.0.0 - '@codama/nodes': 1.0.0 - '@codama/nodes-from-anchor': 1.0.0 - '@codama/renderers-core': 1.0.0 - '@codama/visitors-core': 1.0.0 - '@solana/codecs-strings': 2.0.0-rc.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@codama/errors': 1.1.0 + '@codama/nodes': 1.1.0 + '@codama/nodes-from-anchor': 1.0.1 + '@codama/renderers-core': 1.0.1 + '@codama/visitors-core': 1.1.0 + '@solana/codecs-strings': 2.0.0-rc.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) nunjucks: 3.2.4 prettier: 3.3.3 transitivePeerDependencies: @@ -484,36 +484,36 @@ snapshots: - fastestsmallesttextencoderdecoder - typescript - '@codama/renderers-rust@1.0.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@codama/renderers-rust@1.0.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@codama/errors': 1.0.0 - '@codama/nodes': 1.0.0 - '@codama/renderers-core': 1.0.0 - '@codama/visitors-core': 1.0.0 - '@solana/codecs-strings': 2.0.0-rc.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) + '@codama/errors': 1.1.0 + '@codama/nodes': 1.1.0 + '@codama/renderers-core': 1.0.1 + '@codama/visitors-core': 1.1.0 + '@solana/codecs-strings': 2.0.0-rc.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3) nunjucks: 3.2.4 transitivePeerDependencies: - chokidar - fastestsmallesttextencoderdecoder - typescript - '@codama/validators@1.0.0': + '@codama/validators@1.1.0': dependencies: - '@codama/errors': 1.0.0 - '@codama/nodes': 1.0.0 - '@codama/visitors-core': 1.0.0 + '@codama/errors': 1.1.0 + '@codama/nodes': 1.1.0 + '@codama/visitors-core': 1.1.0 - '@codama/visitors-core@1.0.0': + '@codama/visitors-core@1.1.0': dependencies: - '@codama/errors': 1.0.0 - '@codama/nodes': 1.0.0 + '@codama/errors': 1.1.0 + '@codama/nodes': 1.1.0 json-stable-stringify: 1.1.1 - '@codama/visitors@1.0.0': + '@codama/visitors@1.1.0': dependencies: - '@codama/errors': 1.0.0 - '@codama/nodes': 1.0.0 - '@codama/visitors-core': 1.0.0 + '@codama/errors': 1.1.0 + '@codama/nodes': 1.1.0 + '@codama/visitors-core': 1.1.0 '@iarna/toml@2.2.5': {} @@ -548,26 +548,26 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.17.1 - '@solana/codecs-core@2.0.0-rc.3(typescript@5.6.3)': + '@solana/codecs-core@2.0.0-rc.4(typescript@5.6.3)': dependencies: - '@solana/errors': 2.0.0-rc.3(typescript@5.6.3) + '@solana/errors': 2.0.0-rc.4(typescript@5.6.3) typescript: 5.6.3 - '@solana/codecs-numbers@2.0.0-rc.3(typescript@5.6.3)': + '@solana/codecs-numbers@2.0.0-rc.4(typescript@5.6.3)': dependencies: - '@solana/codecs-core': 2.0.0-rc.3(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.3(typescript@5.6.3) + '@solana/codecs-core': 2.0.0-rc.4(typescript@5.6.3) + '@solana/errors': 2.0.0-rc.4(typescript@5.6.3) typescript: 5.6.3 - '@solana/codecs-strings@2.0.0-rc.3(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': + '@solana/codecs-strings@2.0.0-rc.4(fastestsmallesttextencoderdecoder@1.0.22)(typescript@5.6.3)': dependencies: - '@solana/codecs-core': 2.0.0-rc.3(typescript@5.6.3) - '@solana/codecs-numbers': 2.0.0-rc.3(typescript@5.6.3) - '@solana/errors': 2.0.0-rc.3(typescript@5.6.3) + '@solana/codecs-core': 2.0.0-rc.4(typescript@5.6.3) + '@solana/codecs-numbers': 2.0.0-rc.4(typescript@5.6.3) + '@solana/errors': 2.0.0-rc.4(typescript@5.6.3) fastestsmallesttextencoderdecoder: 1.0.22 typescript: 5.6.3 - '@solana/errors@2.0.0-rc.3(typescript@5.6.3)': + '@solana/errors@2.0.0-rc.4(typescript@5.6.3)': dependencies: chalk: 5.3.0 commander: 12.1.0 @@ -612,12 +612,12 @@ snapshots: chalk@5.3.0: {} - codama@1.0.0: + codama@1.1.0: dependencies: - '@codama/errors': 1.0.0 - '@codama/nodes': 1.0.0 - '@codama/validators': 1.0.0 - '@codama/visitors': 1.0.0 + '@codama/errors': 1.1.0 + '@codama/nodes': 1.1.0 + '@codama/validators': 1.1.0 + '@codama/visitors': 1.1.0 commander@12.1.0: {} diff --git a/scripts/generate-clients.mjs b/scripts/generate-clients.mjs index 19ffbf5..a11011a 100644 --- a/scripts/generate-clients.mjs +++ b/scripts/generate-clients.mjs @@ -4,67 +4,179 @@ import * as c from 'codama'; import { rootNodeFromAnchor } from '@codama/nodes-from-anchor'; import { renderVisitor as renderJavaScriptVisitor } from '@codama/renderers-js'; import { renderVisitor as renderRustVisitor } from '@codama/renderers-rust'; -import { getAllProgramIdls, getToolchainArgument } from './utils.mjs'; +import { getToolchainArgument } from './utils.mjs'; -// Instanciate Codama. -const [idl, ...additionalIdls] = getAllProgramIdls().map((idl) => - rootNodeFromAnchor(require(idl)) -); -const codama = c.createFromRoot(idl, additionalIdls); +// Instanciate Codama from the IDL. +const idl = require(path.join(__dirname, '..', 'interface', 'idl.json')); +const codama = c.createFromRoot(rootNodeFromAnchor(idl)); -/* -// Update programs. +// Rename the program. codama.update( c.updateProgramsVisitor({ - solanaStakeProgram: { name: 'stake' }, + solanaStakeInterface: { name: 'stake' }, }) ); -// Update accounts. codama.update( - c.updateAccountsVisitor({ - counter: { - seeds: [ - c.constantPdaSeedNodeFromString('utf8', 'counter'), - c.variablePdaSeedNode( - 'authority', - c.publicKeyTypeNode(), - 'The authority of the counter account' - ), - ], - }, + c.updateInstructionsVisitor({ + // Deprecated instruction. + redelegate: { delete: true }, }) ); -// Update instructions. +// Add missing types from the IDL. codama.update( - c.updateInstructionsVisitor({ - create: { - byteDeltas: [c.instructionByteDeltaNode(c.accountLinkNode('counter'))], - accounts: { - counter: { defaultValue: c.pdaValueNode('counter') }, - payer: { defaultValue: c.accountValueNode('authority') }, + c.bottomUpTransformerVisitor([ + { + select: '[programNode]stake', + transform: (node) => { + c.assertIsNode(node, 'programNode'); + return { + ...node, + accounts: [ + ...node.accounts, + // stake account + c.accountNode({ + name: 'stakeStateAccount', + data: c.structTypeNode([ + c.structFieldTypeNode({ + name: 'state', + type: c.definedTypeLinkNode('stakeStateV2'), + }), + ]), + }), + ], + errors: [ + c.errorNode({ + code: 0, + name: 'NoCreditsToRedeem', + message: 'Not enough credits to redeem', + }), + c.errorNode({ + code: 1, + name: 'LockupInForce', + message: 'Lockup has not yet expired', + }), + c.errorNode({ + code: 2, + name: 'AlreadyDeactivated', + message: 'Stake already deactivated', + }), + c.errorNode({ + code: 3, + name: 'TooSoonToRedelegate', + message: 'One re-delegation permitted per epoch', + }), + c.errorNode({ + code: 4, + name: 'InsufficientStake', + message: 'Split amount is more than is staked', + }), + c.errorNode({ + code: 5, + name: 'MergeTransientStake', + message: 'Stake account with transient stake cannot be merged', + }), + c.errorNode({ + code: 6, + name: 'MergeMismatch', + message: + 'Stake account merge failed due to different authority, lockups or state', + }), + c.errorNode({ + code: 7, + name: 'CustodianMissing', + message: 'Custodian address not present', + }), + c.errorNode({ + code: 8, + name: 'CustodianSignatureMissing', + message: 'Custodian signature not present', + }), + c.errorNode({ + code: 9, + name: 'InsufficientReferenceVotes', + message: + 'Insufficient voting activity in the reference vote account', + }), + c.errorNode({ + code: 10, + name: 'VoteAddressMismatch', + message: + 'Stake account is not delegated to the provided vote account', + }), + c.errorNode({ + code: 11, + name: 'MinimumDelinquentEpochsForDeactivationNotMet', + message: + 'Stake account has not been delinquent for the minimum epochs required for deactivation', + }), + c.errorNode({ + code: 12, + name: 'InsufficientDelegation', + message: 'Delegation amount is less than the minimum', + }), + c.errorNode({ + code: 13, + name: 'RedelegateTransientOrInactiveStake', + message: + 'Stake account with transient or inactive stake cannot be redelegated', + }), + c.errorNode({ + code: 14, + name: 'RedelegateToSameVoteAccount', + message: + 'Stake redelegation to the same vote account is not permitted', + }), + c.errorNode({ + code: 15, + name: 'RedelegatedStakeMustFullyActivateBeforeDeactivationIsPermitted', + message: + 'Redelegated stake must be fully activated before deactivation', + }), + c.errorNode({ + code: 16, + name: 'EpochRewardsActive', + message: + 'Stake action is not permitted while the epoch rewards period is active', + }), + ], + }; }, }, - increment: { - accounts: { - counter: { defaultValue: c.pdaValueNode('counter') }, + { + // Epoch -> u64 + select: '[definedTypeLinkNode]epoch', + transform: () => { + return c.numberTypeNode('u64'); }, - arguments: { - amount: { defaultValue: c.noneValueNode() }, + }, + { + // UnixTimestamp -> i64 + select: '[definedTypeLinkNode]unixTimestamp', + transform: () => { + return c.numberTypeNode('i64'); }, }, - }) -); - -// Set account discriminators. -const key = (name) => ({ field: 'key', value: c.enumValueNode('Key', name) }); -codama.update( - c.setAccountDiscriminatorFromFieldVisitor({ - counter: key('counter'), - }) + { + // [definedType]f64 -> [numberType]f64 + select: '[definedTypeLinkNode]f64', + transform: () => { + return c.numberTypeNode('f64'); + }, + }, + { + // + select: '[definedTypeNode]stakeStateV2.[enumTypeNode]', + transform: (node) => { + return { + ...node, + size: c.numberTypeNode('u32'), + }; + }, + }, + ]) ); -*/ // Render JavaScript. const jsClient = path.join(__dirname, '..', 'clients', 'js'); @@ -74,6 +186,14 @@ codama.accept( }) ); +// Remove the stake account from the accounts since the Rust client +// provides its own implementation. +codama.update( + c.updateAccountsVisitor({ + stakeStateAccount: { delete: true }, + }) +); + // Render Rust. const rustClient = path.join(__dirname, '..', 'clients', 'rust'); codama.accept( @@ -82,5 +202,75 @@ codama.accept( crateFolder: rustClient, anchorTraits: false, toolchain: getToolchainArgument('format'), + traitOptions: { + overrides: { + authorized: [ + 'borsh::BorshSerialize', + 'borsh::BorshDeserialize', + 'Clone', + 'Copy', + 'Debug', + 'Eq', + 'PartialEq', + ], + delegation: [ + 'borsh::BorshSerialize', + 'borsh::BorshDeserialize', + 'Clone', + 'Copy', + 'Debug', + 'PartialEq', + ], + lockup: [ + 'borsh::BorshSerialize', + 'borsh::BorshDeserialize', + 'Clone', + 'Copy', + 'Debug', + 'Eq', + 'PartialEq', + ], + meta: [ + 'borsh::BorshSerialize', + 'borsh::BorshDeserialize', + 'Clone', + 'Copy', + 'Debug', + 'PartialEq', + ], + stake: [ + 'borsh::BorshSerialize', + 'borsh::BorshDeserialize', + 'Clone', + 'Copy', + 'Debug', + 'PartialEq', + ], + stakeFlags: [ + 'borsh::BorshSerialize', + 'borsh::BorshDeserialize', + 'Clone', + 'Copy', + 'Debug', + 'PartialEq', + ], + stakeState: [ + 'borsh::BorshSerialize', + 'borsh::BorshDeserialize', + 'Clone', + 'Copy', + 'Debug', + 'PartialEq', + ], + stakeStateV2: [ + 'borsh::BorshSerialize', + 'borsh::BorshDeserialize', + 'Clone', + 'Copy', + 'Debug', + 'PartialEq', + ], + }, + }, }) ); diff --git a/scripts/generate-idls.mjs b/scripts/generate-idls.mjs deleted file mode 100644 index faf2db8..0000000 --- a/scripts/generate-idls.mjs +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env zx -import 'zx/globals'; -import { generateIdl } from '@metaplex-foundation/shank-js'; -import { getCargo, getProgramFolders } from './utils.mjs'; - -const binaryInstallDir = path.join(__dirname, '..', '.cargo'); - -getProgramFolders().forEach((folder) => { - const cargo = getCargo(folder); - const isShank = Object.keys(cargo.dependencies).includes('shank'); - const programDir = path.join(__dirname, '..', folder); - - generateIdl({ - generator: isShank ? 'shank' : 'anchor', - programName: cargo.package.name.replace(/-/g, '_'), - programId: cargo.package.metadata.solana['program-id'], - idlDir: programDir, - idlName: 'idl', - programDir, - binaryInstallDir, - }); -});