From f1ef37e791b63d0aec03bdc3f4258da14dcadbd0 Mon Sep 17 00:00:00 2001 From: Faisal Usmani Date: Mon, 23 Mar 2026 12:58:34 -0400 Subject: [PATCH 01/12] feat: migrate SVM utils from contracts repo to SDK (ACP-56) Move production Solana/SVM TypeScript utilities from @across-protocol/contracts into the SDK under src/svm/. This includes web3-v1 utils, web3-v2 utils, auto-generated Codama clients, and IDL assets. - Add src/svm/ with web3-v1, web3-v2, assets, clients copied from contracts - Add ./svm subpath export in package.json for `@across-protocol/sdk/svm` - Update internal arch/svm imports to use local src/svm instead of contracts - Add IDL JSON copy to CJS/ESM build steps - Add sync-svm-clients.sh script for syncing generated clients from contracts - Add @solana/web3.js, borsh, buffer-layout and other Solana deps - Fix ES5 target compatibility (BigInt literals, iterator spread, borsh types) Co-Authored-By: Claude Opus 4.6 (1M context) --- package.json | 19 +- scripts/sync-svm-clients.sh | 28 + src/arch/svm/SpokeUtils.ts | 11 +- src/arch/svm/eventsClient.ts | 5 +- src/arch/svm/types.ts | 2 +- src/arch/svm/utils.ts | 2 +- src/clients/mocks/MockSvmCpiEventsClient.ts | 2 +- src/clients/mocks/MockSvmSpokePoolClient.ts | 2 +- src/svm/assets/idl/index.ts | 21 + src/svm/assets/idl/message_transmitter.json | 1675 +++++ .../assets/idl/message_transmitter_v2.json | 1863 ++++++ src/svm/assets/idl/multicall_handler.json | 31 + .../idl/sponsored_cctp_src_periphery.json | 1965 ++++++ src/svm/assets/idl/svm_spoke.json | 5496 ++++++++++++++++ src/svm/assets/idl/test.json | 243 + .../assets/idl/token_messenger_minter.json | 2049 ++++++ .../assets/idl/token_messenger_minter_v2.json | 4441 +++++++++++++ src/svm/assets/index.ts | 12 + src/svm/assets/message_transmitter.ts | 1681 +++++ src/svm/assets/message_transmitter_v2.ts | 1869 ++++++ src/svm/assets/multicall_handler.ts | 37 + .../assets/sponsored_cctp_src_periphery.ts | 1971 ++++++ src/svm/assets/svm_spoke.ts | 5502 +++++++++++++++++ src/svm/assets/test.ts | 249 + src/svm/assets/token_messenger_minter.ts | 2055 ++++++ src/svm/assets/token_messenger_minter_v2.ts | 4447 +++++++++++++ .../MessageTransmitter/accounts/index.ts | 11 + .../accounts/messageSent.ts | 137 + .../accounts/messageTransmitter.ts | 193 + .../MessageTransmitter/accounts/usedNonces.ts | 143 + .../MessageTransmitter/errors/index.ts | 9 + .../errors/messageTransmitter.ts | 184 + src/svm/clients/MessageTransmitter/index.ts | 13 + .../instructions/acceptOwnership.ts | 218 + .../instructions/disableAttester.ts | 271 + .../instructions/enableAttester.ts | 271 + .../instructions/getNoncePda.ts | 183 + .../MessageTransmitter/instructions/index.ts | 26 + .../instructions/initialize.ts | 326 + .../instructions/isNonceUsed.ts | 171 + .../MessageTransmitter/instructions/pause.ts | 214 + .../instructions/receiveMessage.ts | 319 + .../instructions/reclaimEventAccount.ts | 230 + .../instructions/replaceMessage.ts | 314 + .../instructions/sendMessage.ts | 291 + .../instructions/sendMessageWithCaller.ts | 301 + .../instructions/setMaxMessageBodySize.ts | 238 + .../instructions/setSignatureThreshold.ts | 241 + .../instructions/transferOwnership.ts | 231 + .../instructions/unpause.ts | 214 + .../instructions/updateAttesterManager.ts | 238 + .../instructions/updatePauser.ts | 231 + .../MessageTransmitter/programs/index.ts | 9 + .../programs/messageTransmitter.ts | 372 ++ .../MessageTransmitter/shared/index.ts | 164 + .../types/attesterDisabled.ts | 41 + .../types/attesterEnabled.ts | 38 + .../types/attesterManagerUpdated.ts | 50 + .../types/handleReceiveMessageParams.ts | 65 + .../clients/MessageTransmitter/types/index.ts | 21 + .../MessageTransmitter/types/mathError.ts | 36 + .../types/maxMessageBodySizeUpdated.ts | 42 + .../types/messageReceived.ts | 71 + .../types/ownershipTransferStarted.ts | 50 + .../types/ownershipTransferred.ts | 50 + .../clients/MessageTransmitter/types/pause.ts | 32 + .../MessageTransmitter/types/pauserChanged.ts | 38 + .../types/signatureThresholdUpdated.ts | 49 + .../MessageTransmitter/types/unpause.ts | 32 + .../MessageTransmitterV2/accounts/index.ts | 11 + .../accounts/messageSent.ts | 143 + .../accounts/messageTransmitter.ts | 189 + .../accounts/usedNonce.ts | 126 + .../MessageTransmitterV2/errors/index.ts | 9 + .../errors/messageTransmitterV2.ts | 199 + src/svm/clients/MessageTransmitterV2/index.ts | 13 + .../instructions/acceptOwnership.ts | 311 + .../instructions/disableAttester.ts | 393 ++ .../instructions/enableAttester.ts | 393 ++ .../instructions/index.ts | 23 + .../instructions/initialize.ts | 494 ++ .../instructions/isNonceUsed.ts | 157 + .../instructions/pause.ts | 307 + .../instructions/receiveMessage.ts | 486 ++ .../instructions/reclaimEventAccount.ts | 242 + .../instructions/sendMessage.ts | 302 + .../instructions/setMaxMessageBodySize.ts | 337 + .../instructions/setSignatureThreshold.ts | 343 + .../instructions/transferOwnership.ts | 330 + .../instructions/unpause.ts | 307 + .../instructions/updateAttesterManager.ts | 337 + .../instructions/updatePauser.ts | 330 + .../MessageTransmitterV2/programs/index.ts | 9 + .../programs/messageTransmitterV2.ts | 324 + .../MessageTransmitterV2/shared/index.ts | 164 + .../types/attesterDisabled.ts | 41 + .../types/attesterEnabled.ts | 38 + .../types/attesterManagerUpdated.ts | 50 + .../MessageTransmitterV2/types/index.ts | 19 + .../types/maxMessageBodySizeUpdated.ts | 42 + .../types/messageReceived.ts | 68 + .../types/ownershipTransferStarted.ts | 50 + .../types/ownershipTransferred.ts | 50 + .../MessageTransmitterV2/types/pause.ts | 32 + .../types/pauserChanged.ts | 38 + .../types/signatureThresholdUpdated.ts | 49 + .../MessageTransmitterV2/types/unpause.ts | 32 + src/svm/clients/MulticallHandler/index.ts | 10 + .../instructions/handleV3AcrossMessage.ts | 133 + .../MulticallHandler/instructions/index.ts | 9 + .../MulticallHandler/programs/index.ts | 9 + .../programs/multicallHandler.ts | 49 + .../clients/MulticallHandler/shared/index.ts | 164 + .../accounts/index.ts | 13 + .../accounts/messageSent.ts | 143 + .../accounts/minimumDeposit.ts | 147 + .../accounts/rentClaim.ts | 126 + .../accounts/state.ts | 139 + .../accounts/usedNonce.ts | 129 + .../SponsoredCctpSrcPeriphery/errors/index.ts | 9 + .../errors/sponsoredCctpSrcPeriphery.ts | 103 + .../SponsoredCctpSrcPeriphery/index.ts | 13 + .../instructions/depositForBurn.ts | 914 +++ .../instructions/getUsedNonceCloseInfo.ts | 275 + .../instructions/index.ts | 18 + .../instructions/initialize.ts | 369 ++ .../instructions/reclaimEventAccount.ts | 436 ++ .../instructions/reclaimUsedNonceAccount.ts | 371 ++ .../instructions/repayRentFundDebt.ts | 382 ++ .../instructions/setCurrentTime.ts | 254 + .../instructions/setMinimumDepositAmount.ts | 401 ++ .../instructions/setSigner.ts | 328 + .../instructions/withdrawRentFund.ts | 385 ++ .../programs/index.ts | 9 + .../programs/sponsoredCctpSrcPeriphery.ts | 268 + .../SponsoredCctpSrcPeriphery/shared/index.ts | 164 + .../types/accruedRentFundLiability.ts | 59 + .../types/createdEventAccount.ts | 41 + .../SponsoredCctpSrcPeriphery/types/index.ts | 20 + .../types/minimumDepositAmountSet.ts | 52 + .../types/reclaimedEventAccount.ts | 41 + .../types/reclaimedUsedNonceAccount.ts | 57 + .../types/repaidRentFundDebt.ts | 59 + .../types/signerSet.ts | 41 + .../types/sponsoredCCTPQuote.ts | 130 + .../types/sponsoredDepositForBurn.ts | 96 + .../types/usedNonceAccountParams.ts | 43 + .../types/usedNonceCloseInfo.ts | 54 + .../types/withdrawnRentFund.ts | 52 + .../clients/SvmSpoke/accounts/claimAccount.ts | 139 + .../executeRelayerRefundLeafParams.ts | 176 + .../accounts/executeSlowRelayLeafParams.ts | 176 + .../SvmSpoke/accounts/fillRelayParams.ts | 158 + .../SvmSpoke/accounts/fillStatusAccount.ts | 165 + src/svm/clients/SvmSpoke/accounts/index.ts | 17 + .../accounts/requestSlowFillParams.ts | 156 + .../clients/SvmSpoke/accounts/rootBundle.ts | 140 + src/svm/clients/SvmSpoke/accounts/state.ts | 181 + .../SvmSpoke/accounts/transferLiability.ts | 147 + src/svm/clients/SvmSpoke/errors/index.ts | 9 + src/svm/clients/SvmSpoke/errors/svmSpoke.ts | 112 + src/svm/clients/SvmSpoke/index.ts | 13 + .../instructions/bridgeTokensToHubPool.ts | 800 +++ .../instructions/claimRelayerRefund.ts | 498 ++ .../instructions/closeClaimAccount.ts | 307 + .../SvmSpoke/instructions/closeFillPda.ts | 194 + .../instructions/closeInstructionParams.ts | 270 + .../instructions/createTokenAccounts.ts | 252 + .../clients/SvmSpoke/instructions/deposit.ts | 614 ++ .../SvmSpoke/instructions/depositNow.ts | 608 ++ .../instructions/emergencyDeleteRootBundle.ts | 371 ++ .../instructions/executeRelayerRefundLeaf.ts | 536 ++ .../executeRelayerRefundLeafDeferred.ts | 539 ++ .../instructions/executeSlowRelayLeaf.ts | 634 ++ .../SvmSpoke/instructions/fillRelay.ts | 650 ++ .../instructions/getUnsafeDepositId.ts | 142 + .../instructions/handleReceiveMessage.ts | 382 ++ .../clients/SvmSpoke/instructions/index.ts | 35 + .../SvmSpoke/instructions/initialize.ts | 345 ++ .../instructions/initializeClaimAccount.ts | 345 ++ .../initializeInstructionParams.ts | 328 + .../SvmSpoke/instructions/pauseDeposits.ts | 320 + .../SvmSpoke/instructions/pauseFills.ts | 318 + .../SvmSpoke/instructions/relayRootBundle.ts | 405 ++ .../SvmSpoke/instructions/requestSlowFill.ts | 456 ++ .../instructions/setCrossDomainAdmin.ts | 327 + .../SvmSpoke/instructions/setCurrentTime.ts | 188 + .../instructions/transferOwnership.ts | 320 + .../SvmSpoke/instructions/unsafeDeposit.ts | 622 ++ .../writeInstructionParamsFragment.ts | 336 + src/svm/clients/SvmSpoke/programs/index.ts | 9 + src/svm/clients/SvmSpoke/programs/svmSpoke.ts | 588 ++ src/svm/clients/SvmSpoke/shared/index.ts | 164 + .../SvmSpoke/types/bridgedToHubPool.ts | 49 + .../SvmSpoke/types/claimedRelayerRefund.ts | 59 + .../types/emergencyDeletedRootBundle.ts | 40 + .../types/executedRelayerRefundRoot.ts | 89 + src/svm/clients/SvmSpoke/types/fillStatus.ts | 36 + src/svm/clients/SvmSpoke/types/fillType.ts | 36 + src/svm/clients/SvmSpoke/types/filledRelay.ts | 114 + .../clients/SvmSpoke/types/fundsDeposited.ts | 105 + src/svm/clients/SvmSpoke/types/index.ts | 27 + .../clients/SvmSpoke/types/pausedDeposits.ts | 37 + src/svm/clients/SvmSpoke/types/pausedFills.ts | 34 + src/svm/clients/SvmSpoke/types/relayData.ts | 98 + .../SvmSpoke/types/relayExecutionEventInfo.ts | 74 + .../SvmSpoke/types/relayedRootBundle.ts | 57 + .../SvmSpoke/types/relayerRefundLeaf.ts | 75 + .../SvmSpoke/types/requestedSlowFill.ts | 102 + .../clients/SvmSpoke/types/setXDomainAdmin.ts | 38 + src/svm/clients/SvmSpoke/types/slowFill.ts | 56 + .../clients/SvmSpoke/types/tokensBridged.ts | 66 + .../SvmSpoke/types/transferredOwnership.ts | 41 + .../TokenMessengerMinter/accounts/index.ts | 13 + .../accounts/localToken.ts | 169 + .../accounts/remoteTokenMessenger.ts | 164 + .../accounts/tokenMessenger.ts | 164 + .../accounts/tokenMinter.ts | 149 + .../accounts/tokenPair.ts | 147 + .../TokenMessengerMinter/errors/index.ts | 9 + .../errors/tokenMessengerMinter.ts | 111 + src/svm/clients/TokenMessengerMinter/index.ts | 13 + .../instructions/acceptOwnership.ts | 216 + .../instructions/addLocalToken.ts | 320 + .../instructions/addRemoteTokenMessenger.ts | 297 + .../instructions/burnTokenCustody.ts | 317 + .../instructions/depositForBurn.ts | 465 ++ .../instructions/depositForBurnWithCaller.ts | 475 ++ .../instructions/handleReceiveMessage.ts | 371 ++ .../instructions/index.ts | 27 + .../instructions/initialize.ts | 345 ++ .../instructions/linkTokenPair.ts | 297 + .../instructions/pause.ts | 212 + .../instructions/removeLocalToken.ts | 287 + .../removeRemoteTokenMessenger.ts | 254 + .../instructions/replaceDepositForBurn.ts | 392 ++ .../setMaxBurnAmountPerMessage.ts | 253 + .../instructions/setTokenController.ts | 247 + .../instructions/transferOwnership.ts | 229 + .../instructions/unlinkTokenPair.ts | 249 + .../instructions/unpause.ts | 212 + .../instructions/updatePauser.ts | 243 + .../TokenMessengerMinter/programs/index.ts | 9 + .../programs/tokenMessengerMinter.ts | 412 ++ .../TokenMessengerMinter/shared/index.ts | 164 + .../types/depositForBurn.ts | 78 + .../TokenMessengerMinter/types/index.ts | 25 + .../types/localTokenAdded.ts | 44 + .../types/localTokenRemoved.ts | 47 + .../types/mintAndWithdraw.ts | 56 + .../types/ownershipTransferStarted.ts | 50 + .../types/ownershipTransferred.ts | 50 + .../TokenMessengerMinter/types/pause.ts | 32 + .../types/pauserChanged.ts | 38 + .../types/remoteTokenMessengerAdded.ts | 52 + .../types/remoteTokenMessengerRemoved.ts | 52 + .../types/setBurnLimitPerMessage.ts | 55 + .../types/setTokenController.ts | 41 + .../types/tokenCustodyBurned.ts | 55 + .../types/tokenMinterError.ts | 48 + .../types/tokenPairLinked.ts | 52 + .../types/tokenPairUnlinked.ts | 55 + .../TokenMessengerMinter/types/unpause.ts | 32 + .../accounts/denylistedAccount.ts | 147 + .../TokenMessengerMinterV2/accounts/index.ts | 15 + .../accounts/localToken.ts | 169 + .../accounts/messageTransmitter.ts | 189 + .../accounts/remoteTokenMessenger.ts | 164 + .../accounts/tokenMessenger.ts | 176 + .../accounts/tokenMinter.ts | 149 + .../accounts/tokenPair.ts | 147 + .../TokenMessengerMinterV2/errors/index.ts | 9 + .../errors/tokenMessengerMinterV2.ts | 95 + .../clients/TokenMessengerMinterV2/index.ts | 13 + .../instructions/acceptOwnership.ts | 305 + .../instructions/addLocalToken.ts | 502 ++ .../instructions/addRemoteTokenMessenger.ts | 424 ++ .../instructions/burnTokenCustody.ts | 465 ++ .../instructions/denylistAccount.ts | 403 ++ .../instructions/depositForBurn.ts | 802 +++ .../instructions/depositForBurnWithHook.ts | 815 +++ .../handleReceiveFinalizedMessage.ts | 569 ++ .../handleReceiveUnfinalizedMessage.ts | 569 ++ .../instructions/index.ts | 33 + .../instructions/initialize.ts | 567 ++ .../instructions/linkTokenPair.ts | 425 ++ .../instructions/pause.ts | 301 + .../instructions/removeLocalToken.ts | 446 ++ .../removeRemoteTokenMessenger.ts | 362 ++ .../instructions/setFeeRecipient.ts | 324 + .../setMaxBurnAmountPerMessage.ts | 359 ++ .../instructions/setMinFee.ts | 328 + .../instructions/setMinFeeController.ts | 331 + .../instructions/setTokenController.ts | 350 ++ .../instructions/transferOwnership.ts | 324 + .../instructions/undenylistAccount.ts | 403 ++ .../instructions/unlinkTokenPair.ts | 357 ++ .../instructions/unpause.ts | 301 + .../instructions/updateDenylister.ts | 324 + .../instructions/updatePauser.ts | 346 ++ .../TokenMessengerMinterV2/programs/index.ts | 9 + .../programs/tokenMessengerMinterV2.ts | 532 ++ .../TokenMessengerMinterV2/shared/index.ts | 164 + .../types/denylisted.ts | 35 + .../types/denylisterChanged.ts | 50 + .../types/depositForBurn.ts | 91 + .../types/feeRecipientSet.ts | 38 + .../types/handleReceiveMessageParams.ts | 68 + .../TokenMessengerMinterV2/types/index.ts | 31 + .../types/localTokenAdded.ts | 44 + .../types/localTokenRemoved.ts | 47 + .../types/minFeeControllerSet.ts | 41 + .../TokenMessengerMinterV2/types/minFeeSet.ts | 34 + .../types/mintAndWithdraw.ts | 60 + .../types/ownershipTransferStarted.ts | 50 + .../types/ownershipTransferred.ts | 50 + .../TokenMessengerMinterV2/types/pause.ts | 32 + .../types/pauserChanged.ts | 38 + .../types/remoteTokenMessengerAdded.ts | 52 + .../types/remoteTokenMessengerRemoved.ts | 52 + .../types/setBurnLimitPerMessage.ts | 55 + .../types/setTokenController.ts | 41 + .../types/tokenCustodyBurned.ts | 55 + .../types/tokenPairLinked.ts | 52 + .../types/tokenPairUnlinked.ts | 55 + .../types/unDenylisted.ts | 35 + .../TokenMessengerMinterV2/types/unpause.ts | 32 + src/svm/clients/index.ts | 17 + src/svm/index.ts | 26 + src/svm/types.svm.ts | 138 + src/svm/web3-v1/buffer-layout.d.ts | 10 + src/svm/web3-v1/cctpHelpers.ts | 181 + src/svm/web3-v1/cctpV2Helpers.ts | 253 + src/svm/web3-v1/coders.ts | 268 + src/svm/web3-v1/constants.ts | 9 + src/svm/web3-v1/conversionUtils.ts | 107 + src/svm/web3-v1/helpers.ts | 303 + src/svm/web3-v1/index.ts | 11 + src/svm/web3-v1/instructionParamsUtils.ts | 198 + src/svm/web3-v1/programConnectors.ts | 82 + src/svm/web3-v1/relayHashUtils.ts | 224 + src/svm/web3-v1/solanaProgramUtils.ts | 277 + src/svm/web3-v1/transactionUtils.ts | 129 + src/svm/web3-v2/index.ts | 3 + src/svm/web3-v2/solanaProgramUtils.ts | 145 + src/svm/web3-v2/transactionUtils.ts | 143 + src/svm/web3-v2/types.ts | 16 + yarn.lock | 32 +- 348 files changed, 94583 insertions(+), 18 deletions(-) create mode 100755 scripts/sync-svm-clients.sh create mode 100644 src/svm/assets/idl/index.ts create mode 100644 src/svm/assets/idl/message_transmitter.json create mode 100644 src/svm/assets/idl/message_transmitter_v2.json create mode 100644 src/svm/assets/idl/multicall_handler.json create mode 100644 src/svm/assets/idl/sponsored_cctp_src_periphery.json create mode 100644 src/svm/assets/idl/svm_spoke.json create mode 100644 src/svm/assets/idl/test.json create mode 100644 src/svm/assets/idl/token_messenger_minter.json create mode 100644 src/svm/assets/idl/token_messenger_minter_v2.json create mode 100644 src/svm/assets/index.ts create mode 100644 src/svm/assets/message_transmitter.ts create mode 100644 src/svm/assets/message_transmitter_v2.ts create mode 100644 src/svm/assets/multicall_handler.ts create mode 100644 src/svm/assets/sponsored_cctp_src_periphery.ts create mode 100644 src/svm/assets/svm_spoke.ts create mode 100644 src/svm/assets/test.ts create mode 100644 src/svm/assets/token_messenger_minter.ts create mode 100644 src/svm/assets/token_messenger_minter_v2.ts create mode 100644 src/svm/clients/MessageTransmitter/accounts/index.ts create mode 100644 src/svm/clients/MessageTransmitter/accounts/messageSent.ts create mode 100644 src/svm/clients/MessageTransmitter/accounts/messageTransmitter.ts create mode 100644 src/svm/clients/MessageTransmitter/accounts/usedNonces.ts create mode 100644 src/svm/clients/MessageTransmitter/errors/index.ts create mode 100644 src/svm/clients/MessageTransmitter/errors/messageTransmitter.ts create mode 100644 src/svm/clients/MessageTransmitter/index.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/acceptOwnership.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/disableAttester.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/enableAttester.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/getNoncePda.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/index.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/initialize.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/isNonceUsed.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/pause.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/receiveMessage.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/reclaimEventAccount.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/replaceMessage.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/sendMessage.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/sendMessageWithCaller.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/setMaxMessageBodySize.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/setSignatureThreshold.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/transferOwnership.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/unpause.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/updateAttesterManager.ts create mode 100644 src/svm/clients/MessageTransmitter/instructions/updatePauser.ts create mode 100644 src/svm/clients/MessageTransmitter/programs/index.ts create mode 100644 src/svm/clients/MessageTransmitter/programs/messageTransmitter.ts create mode 100644 src/svm/clients/MessageTransmitter/shared/index.ts create mode 100644 src/svm/clients/MessageTransmitter/types/attesterDisabled.ts create mode 100644 src/svm/clients/MessageTransmitter/types/attesterEnabled.ts create mode 100644 src/svm/clients/MessageTransmitter/types/attesterManagerUpdated.ts create mode 100644 src/svm/clients/MessageTransmitter/types/handleReceiveMessageParams.ts create mode 100644 src/svm/clients/MessageTransmitter/types/index.ts create mode 100644 src/svm/clients/MessageTransmitter/types/mathError.ts create mode 100644 src/svm/clients/MessageTransmitter/types/maxMessageBodySizeUpdated.ts create mode 100644 src/svm/clients/MessageTransmitter/types/messageReceived.ts create mode 100644 src/svm/clients/MessageTransmitter/types/ownershipTransferStarted.ts create mode 100644 src/svm/clients/MessageTransmitter/types/ownershipTransferred.ts create mode 100644 src/svm/clients/MessageTransmitter/types/pause.ts create mode 100644 src/svm/clients/MessageTransmitter/types/pauserChanged.ts create mode 100644 src/svm/clients/MessageTransmitter/types/signatureThresholdUpdated.ts create mode 100644 src/svm/clients/MessageTransmitter/types/unpause.ts create mode 100644 src/svm/clients/MessageTransmitterV2/accounts/index.ts create mode 100644 src/svm/clients/MessageTransmitterV2/accounts/messageSent.ts create mode 100644 src/svm/clients/MessageTransmitterV2/accounts/messageTransmitter.ts create mode 100644 src/svm/clients/MessageTransmitterV2/accounts/usedNonce.ts create mode 100644 src/svm/clients/MessageTransmitterV2/errors/index.ts create mode 100644 src/svm/clients/MessageTransmitterV2/errors/messageTransmitterV2.ts create mode 100644 src/svm/clients/MessageTransmitterV2/index.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/acceptOwnership.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/disableAttester.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/enableAttester.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/index.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/initialize.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/isNonceUsed.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/pause.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/receiveMessage.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/reclaimEventAccount.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/sendMessage.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/setMaxMessageBodySize.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/setSignatureThreshold.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/transferOwnership.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/unpause.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/updateAttesterManager.ts create mode 100644 src/svm/clients/MessageTransmitterV2/instructions/updatePauser.ts create mode 100644 src/svm/clients/MessageTransmitterV2/programs/index.ts create mode 100644 src/svm/clients/MessageTransmitterV2/programs/messageTransmitterV2.ts create mode 100644 src/svm/clients/MessageTransmitterV2/shared/index.ts create mode 100644 src/svm/clients/MessageTransmitterV2/types/attesterDisabled.ts create mode 100644 src/svm/clients/MessageTransmitterV2/types/attesterEnabled.ts create mode 100644 src/svm/clients/MessageTransmitterV2/types/attesterManagerUpdated.ts create mode 100644 src/svm/clients/MessageTransmitterV2/types/index.ts create mode 100644 src/svm/clients/MessageTransmitterV2/types/maxMessageBodySizeUpdated.ts create mode 100644 src/svm/clients/MessageTransmitterV2/types/messageReceived.ts create mode 100644 src/svm/clients/MessageTransmitterV2/types/ownershipTransferStarted.ts create mode 100644 src/svm/clients/MessageTransmitterV2/types/ownershipTransferred.ts create mode 100644 src/svm/clients/MessageTransmitterV2/types/pause.ts create mode 100644 src/svm/clients/MessageTransmitterV2/types/pauserChanged.ts create mode 100644 src/svm/clients/MessageTransmitterV2/types/signatureThresholdUpdated.ts create mode 100644 src/svm/clients/MessageTransmitterV2/types/unpause.ts create mode 100644 src/svm/clients/MulticallHandler/index.ts create mode 100644 src/svm/clients/MulticallHandler/instructions/handleV3AcrossMessage.ts create mode 100644 src/svm/clients/MulticallHandler/instructions/index.ts create mode 100644 src/svm/clients/MulticallHandler/programs/index.ts create mode 100644 src/svm/clients/MulticallHandler/programs/multicallHandler.ts create mode 100644 src/svm/clients/MulticallHandler/shared/index.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/accounts/index.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/accounts/messageSent.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/accounts/minimumDeposit.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/accounts/rentClaim.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/accounts/state.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/accounts/usedNonce.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/errors/index.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/errors/sponsoredCctpSrcPeriphery.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/index.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/depositForBurn.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/getUsedNonceCloseInfo.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/index.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/initialize.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimEventAccount.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimUsedNonceAccount.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/repayRentFundDebt.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setCurrentTime.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setMinimumDepositAmount.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setSigner.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/withdrawRentFund.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/programs/index.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/programs/sponsoredCctpSrcPeriphery.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/shared/index.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/accruedRentFundLiability.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/createdEventAccount.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/index.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/minimumDepositAmountSet.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedEventAccount.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedUsedNonceAccount.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/repaidRentFundDebt.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/signerSet.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredCCTPQuote.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredDepositForBurn.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceAccountParams.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceCloseInfo.ts create mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/withdrawnRentFund.ts create mode 100644 src/svm/clients/SvmSpoke/accounts/claimAccount.ts create mode 100644 src/svm/clients/SvmSpoke/accounts/executeRelayerRefundLeafParams.ts create mode 100644 src/svm/clients/SvmSpoke/accounts/executeSlowRelayLeafParams.ts create mode 100644 src/svm/clients/SvmSpoke/accounts/fillRelayParams.ts create mode 100644 src/svm/clients/SvmSpoke/accounts/fillStatusAccount.ts create mode 100644 src/svm/clients/SvmSpoke/accounts/index.ts create mode 100644 src/svm/clients/SvmSpoke/accounts/requestSlowFillParams.ts create mode 100644 src/svm/clients/SvmSpoke/accounts/rootBundle.ts create mode 100644 src/svm/clients/SvmSpoke/accounts/state.ts create mode 100644 src/svm/clients/SvmSpoke/accounts/transferLiability.ts create mode 100644 src/svm/clients/SvmSpoke/errors/index.ts create mode 100644 src/svm/clients/SvmSpoke/errors/svmSpoke.ts create mode 100644 src/svm/clients/SvmSpoke/index.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/bridgeTokensToHubPool.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/claimRelayerRefund.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/closeClaimAccount.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/closeFillPda.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/closeInstructionParams.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/createTokenAccounts.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/deposit.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/depositNow.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/emergencyDeleteRootBundle.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeaf.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeafDeferred.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/executeSlowRelayLeaf.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/fillRelay.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/getUnsafeDepositId.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/handleReceiveMessage.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/index.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/initialize.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/initializeClaimAccount.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/initializeInstructionParams.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/pauseDeposits.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/pauseFills.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/relayRootBundle.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/requestSlowFill.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/setCrossDomainAdmin.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/setCurrentTime.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/transferOwnership.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/unsafeDeposit.ts create mode 100644 src/svm/clients/SvmSpoke/instructions/writeInstructionParamsFragment.ts create mode 100644 src/svm/clients/SvmSpoke/programs/index.ts create mode 100644 src/svm/clients/SvmSpoke/programs/svmSpoke.ts create mode 100644 src/svm/clients/SvmSpoke/shared/index.ts create mode 100644 src/svm/clients/SvmSpoke/types/bridgedToHubPool.ts create mode 100644 src/svm/clients/SvmSpoke/types/claimedRelayerRefund.ts create mode 100644 src/svm/clients/SvmSpoke/types/emergencyDeletedRootBundle.ts create mode 100644 src/svm/clients/SvmSpoke/types/executedRelayerRefundRoot.ts create mode 100644 src/svm/clients/SvmSpoke/types/fillStatus.ts create mode 100644 src/svm/clients/SvmSpoke/types/fillType.ts create mode 100644 src/svm/clients/SvmSpoke/types/filledRelay.ts create mode 100644 src/svm/clients/SvmSpoke/types/fundsDeposited.ts create mode 100644 src/svm/clients/SvmSpoke/types/index.ts create mode 100644 src/svm/clients/SvmSpoke/types/pausedDeposits.ts create mode 100644 src/svm/clients/SvmSpoke/types/pausedFills.ts create mode 100644 src/svm/clients/SvmSpoke/types/relayData.ts create mode 100644 src/svm/clients/SvmSpoke/types/relayExecutionEventInfo.ts create mode 100644 src/svm/clients/SvmSpoke/types/relayedRootBundle.ts create mode 100644 src/svm/clients/SvmSpoke/types/relayerRefundLeaf.ts create mode 100644 src/svm/clients/SvmSpoke/types/requestedSlowFill.ts create mode 100644 src/svm/clients/SvmSpoke/types/setXDomainAdmin.ts create mode 100644 src/svm/clients/SvmSpoke/types/slowFill.ts create mode 100644 src/svm/clients/SvmSpoke/types/tokensBridged.ts create mode 100644 src/svm/clients/SvmSpoke/types/transferredOwnership.ts create mode 100644 src/svm/clients/TokenMessengerMinter/accounts/index.ts create mode 100644 src/svm/clients/TokenMessengerMinter/accounts/localToken.ts create mode 100644 src/svm/clients/TokenMessengerMinter/accounts/remoteTokenMessenger.ts create mode 100644 src/svm/clients/TokenMessengerMinter/accounts/tokenMessenger.ts create mode 100644 src/svm/clients/TokenMessengerMinter/accounts/tokenMinter.ts create mode 100644 src/svm/clients/TokenMessengerMinter/accounts/tokenPair.ts create mode 100644 src/svm/clients/TokenMessengerMinter/errors/index.ts create mode 100644 src/svm/clients/TokenMessengerMinter/errors/tokenMessengerMinter.ts create mode 100644 src/svm/clients/TokenMessengerMinter/index.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/acceptOwnership.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/addLocalToken.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/addRemoteTokenMessenger.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/burnTokenCustody.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/depositForBurn.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/depositForBurnWithCaller.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/handleReceiveMessage.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/index.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/initialize.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/linkTokenPair.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/pause.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/removeLocalToken.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/removeRemoteTokenMessenger.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/replaceDepositForBurn.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/setMaxBurnAmountPerMessage.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/setTokenController.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/transferOwnership.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/unlinkTokenPair.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/unpause.ts create mode 100644 src/svm/clients/TokenMessengerMinter/instructions/updatePauser.ts create mode 100644 src/svm/clients/TokenMessengerMinter/programs/index.ts create mode 100644 src/svm/clients/TokenMessengerMinter/programs/tokenMessengerMinter.ts create mode 100644 src/svm/clients/TokenMessengerMinter/shared/index.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/depositForBurn.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/index.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/localTokenAdded.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/localTokenRemoved.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/mintAndWithdraw.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/ownershipTransferStarted.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/ownershipTransferred.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/pause.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/pauserChanged.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerAdded.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerRemoved.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/setBurnLimitPerMessage.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/setTokenController.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/tokenCustodyBurned.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/tokenMinterError.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/tokenPairLinked.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/tokenPairUnlinked.ts create mode 100644 src/svm/clients/TokenMessengerMinter/types/unpause.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/denylistedAccount.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/index.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/localToken.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/messageTransmitter.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/remoteTokenMessenger.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/tokenMessenger.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/tokenMinter.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/tokenPair.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/errors/index.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/errors/tokenMessengerMinterV2.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/index.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/acceptOwnership.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/addLocalToken.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/addRemoteTokenMessenger.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/burnTokenCustody.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/denylistAccount.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurn.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurnWithHook.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveFinalizedMessage.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveUnfinalizedMessage.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/index.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/initialize.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/linkTokenPair.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/pause.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/removeLocalToken.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/removeRemoteTokenMessenger.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/setFeeRecipient.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/setMaxBurnAmountPerMessage.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/setMinFee.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/setMinFeeController.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/setTokenController.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/transferOwnership.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/undenylistAccount.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/unlinkTokenPair.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/unpause.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/updateDenylister.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/updatePauser.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/programs/index.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/programs/tokenMessengerMinterV2.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/shared/index.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/denylisted.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/denylisterChanged.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/depositForBurn.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/feeRecipientSet.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/handleReceiveMessageParams.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/index.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/localTokenAdded.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/localTokenRemoved.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/minFeeControllerSet.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/minFeeSet.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/mintAndWithdraw.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferStarted.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferred.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/pause.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/pauserChanged.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerAdded.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerRemoved.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/setBurnLimitPerMessage.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/setTokenController.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/tokenCustodyBurned.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/tokenPairLinked.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/tokenPairUnlinked.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/unDenylisted.ts create mode 100644 src/svm/clients/TokenMessengerMinterV2/types/unpause.ts create mode 100644 src/svm/clients/index.ts create mode 100644 src/svm/index.ts create mode 100644 src/svm/types.svm.ts create mode 100644 src/svm/web3-v1/buffer-layout.d.ts create mode 100644 src/svm/web3-v1/cctpHelpers.ts create mode 100644 src/svm/web3-v1/cctpV2Helpers.ts create mode 100644 src/svm/web3-v1/coders.ts create mode 100644 src/svm/web3-v1/constants.ts create mode 100644 src/svm/web3-v1/conversionUtils.ts create mode 100644 src/svm/web3-v1/helpers.ts create mode 100644 src/svm/web3-v1/index.ts create mode 100644 src/svm/web3-v1/instructionParamsUtils.ts create mode 100644 src/svm/web3-v1/programConnectors.ts create mode 100644 src/svm/web3-v1/relayHashUtils.ts create mode 100644 src/svm/web3-v1/solanaProgramUtils.ts create mode 100644 src/svm/web3-v1/transactionUtils.ts create mode 100644 src/svm/web3-v2/index.ts create mode 100644 src/svm/web3-v2/solanaProgramUtils.ts create mode 100644 src/svm/web3-v2/transactionUtils.ts create mode 100644 src/svm/web3-v2/types.ts diff --git a/package.json b/package.json index 2b6539da7..6001cdc65 100644 --- a/package.json +++ b/package.json @@ -24,9 +24,11 @@ "start": "yarn typechain && nodemon -e ts,tsx,json,js,jsx --watch ./src --ignore ./dist --exec 'yarn dev'", "build": "yarn run clean && yarn typechain && yarn dev", "dev": "concurrently --kill-others-on-fail --names 'cjs,esm,types' --prefix-colors 'blue,magenta,green' 'yarn run build:cjs' 'yarn run build:esm' 'yarn run build:types'", - "build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}'", - "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir ./dist/esm && echo > ./dist/esm/package.json '{\"type\":\"module\",\"sideEffects\":false}'", + "build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}' && yarn export-svm-idl:cjs", + "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir ./dist/esm && echo > ./dist/esm/package.json '{\"type\":\"module\",\"sideEffects\":false}' && yarn export-svm-idl:esm", "build:types": "tsc --project tsconfig.build.json --module esnext --declarationDir ./dist/types --emitDeclarationOnly --declaration --declarationMap", + "export-svm-idl:cjs": "cp src/svm/assets/idl/*.json dist/cjs/src/svm/assets/idl/", + "export-svm-idl:esm": "cp src/svm/assets/idl/*.json dist/esm/src/svm/assets/idl/", "test": "hardhat test", "test:watch": "hardhat watch test", "test:run:arweave": "npx -y arlocal", @@ -40,6 +42,7 @@ "bump-version:minor": "yarn version --minor --no-git-tag-version --no-commit-hooks && git commit -m 'chore: bump version' ./package.json --no-verify", "bump-version:patch": "yarn version --patch --no-git-tag-version --no-commit-hooks && git commit -m 'chore: bump version' ./package.json --no-verify", "stage-artifacts": "node scripts/stage-typechain-artifacts.js", + "sync-svm-clients": "bash scripts/sync-svm-clients.sh", "typechain": "yarn stage-artifacts && typechain --target ethers-v5 --out-dir src/utils/abi/typechain 'src/utils/abi/contracts/*.json'", "yalc:watch": "nodemon --watch src --ext ts,tsx,json,js,jsx --ignore src/utils/abi/ --exec 'yalc publish --push --changed'" }, @@ -65,7 +68,6 @@ "@nomiclabs/hardhat-etherscan": "^3.1.7", "@openzeppelin/hardhat-upgrades": "^1.28.0", "@size-limit/preset-small-lib": "^7.0.8", - "@solana/web3.js": "^1.31.0", "@typechain/ethers-v5": "^11.1.1", "@typechain/hardhat": "^6.1.6", "@types/async": "^3.2.24", @@ -115,6 +117,7 @@ "@across-protocol/constants": "^3.1.100", "@across-protocol/contracts": "4.1.24", "@coral-xyz/anchor": "^0.30.1", + "@coral-xyz/borsh": "^0.30.1", "@eth-optimism/sdk": "^3.3.1", "@ethersproject/bignumber": "^5.7.0", "@nktkas/hyperliquid": "^0.25.9", @@ -124,8 +127,13 @@ "@solana-program/token-2022": "^0.6.1", "@solana-program/compute-budget": "^0.11.0", "@solana/kit": "^5.4.0", + "@solana/spl-token": "^0.4.14", "@solana/sysvars": "^5.4.0", + "@solana/web3.js": "^1.98.2", + "@solana-program/address-lookup-table": "^0.10.0", "arweave": "^1.14.4", + "borsh": "^2.0.0", + "buffer-layout": "^1.2.2", "async": "^3.2.5", "axios": "^0.27.2", "bs58": "^6.0.0", @@ -168,6 +176,11 @@ "import": "./dist/esm/typechain.js", "types": "./dist/types/typechain.d.ts" }, + "./svm": { + "require": "./dist/cjs/src/svm/index.js", + "import": "./dist/esm/src/svm/index.js", + "types": "./dist/types/src/svm/index.d.ts" + }, "./src/utils/abi/typechain": { "require": "./dist/cjs/src/utils/abi/typechain/index.js", "import": "./dist/esm/src/utils/abi/typechain/index.js", diff --git a/scripts/sync-svm-clients.sh b/scripts/sync-svm-clients.sh new file mode 100755 index 000000000..0848fc35e --- /dev/null +++ b/scripts/sync-svm-clients.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Syncs auto-generated Codama clients and IDL assets from the contracts repo. +# Run this after `yarn generate-svm-artifacts` in the contracts repo. +# See ACP-56 for context. + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SDK_ROOT="$(dirname "$SCRIPT_DIR")" +CONTRACTS_ROOT="${CONTRACTS_ROOT:-$(dirname "$SDK_ROOT")/contracts}" + +if [ ! -d "$CONTRACTS_ROOT/src/svm" ]; then + echo "Error: contracts repo not found at $CONTRACTS_ROOT" + echo "Set CONTRACTS_ROOT env var to the contracts repo path." + exit 1 +fi + +echo "Syncing SVM clients from $CONTRACTS_ROOT..." + +# Sync Codama-generated clients +rm -rf "$SDK_ROOT/src/svm/clients" +cp -r "$CONTRACTS_ROOT/src/svm/clients" "$SDK_ROOT/src/svm/clients" + +# Sync auto-generated assets (IDLs + Anchor types) +rm -rf "$SDK_ROOT/src/svm/assets" +cp -r "$CONTRACTS_ROOT/src/svm/assets" "$SDK_ROOT/src/svm/assets" + +echo "Done. Synced clients/ and assets/ to sdk/src/svm/" diff --git a/src/arch/svm/SpokeUtils.ts b/src/arch/svm/SpokeUtils.ts index 7c2ec6dd3..31bb4e23d 100644 --- a/src/arch/svm/SpokeUtils.ts +++ b/src/arch/svm/SpokeUtils.ts @@ -1,6 +1,5 @@ -import { MessageTransmitterClient, SvmSpokeClient, TokenMessengerMinterClient } from "@across-protocol/contracts"; -import { decodeFillStatusAccount, fetchState } from "@across-protocol/contracts/dist/src/svm/clients/SvmSpoke"; -import { decodeMessageHeader } from "@across-protocol/contracts/dist/src/svm/web3-v1"; +import { MessageTransmitterClient, SvmSpokeClient, TokenMessengerMinterClient } from "../../svm"; +import { decodeMessageHeader } from "../../svm/web3-v1/cctpHelpers"; import { SYSTEM_PROGRAM_ADDRESS } from "@solana-program/system"; import { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, @@ -210,7 +209,7 @@ async function _callGetTimestampForSlotWithRetry( * @returns fill deadline buffer */ export async function getFillDeadline(provider: SVMProvider, statePda: Address): Promise { - const state = await fetchState(provider, statePda); + const state = await SvmSpokeClient.fetchState(provider, statePda); return state.data.fillDeadlineBuffer; } @@ -341,7 +340,7 @@ export async function relayFillStatus( // If the PDA exists, return the stored fill status if (fillStatusAccount.exists) { - const decodedAccountData = decodeFillStatusAccount(fillStatusAccount); + const decodedAccountData = SvmSpokeClient.decodeFillStatusAccount(fillStatusAccount); return decodedAccountData.data.status; } // If the PDA doesn't exist and the deadline hasn't passed yet, the deposit must be unfilled, @@ -1068,7 +1067,7 @@ async function fetchBatchFillStatusFromPdaAccounts( const fillStatuses = pdaAccounts.flat().map((account, index) => { // If the PDA exists, we can fetch the status directly. if (account.exists) { - const decodedAccount = decodeFillStatusAccount(account); + const decodedAccount = SvmSpokeClient.decodeFillStatusAccount(account); return decodedAccount.data.status; } diff --git a/src/arch/svm/eventsClient.ts b/src/arch/svm/eventsClient.ts index 8d856918c..865651c3f 100644 --- a/src/arch/svm/eventsClient.ts +++ b/src/arch/svm/eventsClient.ts @@ -1,6 +1,7 @@ import { Idl } from "@coral-xyz/anchor"; -import { getDeployedAddress, SvmSpokeIdl } from "@across-protocol/contracts"; -import { getSolanaChainId } from "@across-protocol/contracts/dist/src/svm/web3-v1"; +import { getDeployedAddress } from "@across-protocol/contracts"; +import { SvmSpokeIdl } from "../../svm"; +import { getSolanaChainId } from "../../svm/web3-v1/helpers"; import { address, Address, diff --git a/src/arch/svm/types.ts b/src/arch/svm/types.ts index ea1e2c57c..5d1f95731 100644 --- a/src/arch/svm/types.ts +++ b/src/arch/svm/types.ts @@ -1,4 +1,4 @@ -import { SvmSpokeClient } from "@across-protocol/contracts"; +import { SvmSpokeClient } from "../../svm"; import { Address, Rpc, diff --git a/src/arch/svm/utils.ts b/src/arch/svm/utils.ts index 54eacebc2..f5821202a 100644 --- a/src/arch/svm/utils.ts +++ b/src/arch/svm/utils.ts @@ -1,4 +1,4 @@ -import { MessageTransmitterClient, SvmSpokeClient } from "@across-protocol/contracts"; +import { MessageTransmitterClient, SvmSpokeClient } from "../../svm"; import { SpokePool__factory } from "../../typechain"; import { BN, BorshEventCoder, Idl } from "@coral-xyz/anchor"; import { diff --git a/src/clients/mocks/MockSvmCpiEventsClient.ts b/src/clients/mocks/MockSvmCpiEventsClient.ts index 3208c7af2..fd5b6abb5 100644 --- a/src/clients/mocks/MockSvmCpiEventsClient.ts +++ b/src/clients/mocks/MockSvmCpiEventsClient.ts @@ -5,7 +5,7 @@ import { hexlify, arrayify, hexZeroPad } from "ethers/lib/utils"; import { random } from "lodash"; import { Address, UnixTimestamp, signature } from "@solana/kit"; import { Idl } from "@coral-xyz/anchor"; -import { SvmSpokeClient } from "@across-protocol/contracts"; +import { SvmSpokeClient } from "../../svm"; import { CHAIN_IDs } from "@across-protocol/constants"; import { MockSolanaRpcFactory } from "../../providers/mocks"; diff --git a/src/clients/mocks/MockSvmSpokePoolClient.ts b/src/clients/mocks/MockSvmSpokePoolClient.ts index 30fa64de0..c3eada6ed 100644 --- a/src/clients/mocks/MockSvmSpokePoolClient.ts +++ b/src/clients/mocks/MockSvmSpokePoolClient.ts @@ -1,5 +1,5 @@ import winston from "winston"; -import { SvmSpokeClient } from "@across-protocol/contracts"; +import { SvmSpokeClient } from "../../svm"; import { Address } from "@solana/kit"; import { DepositWithBlock, RelayerRefundExecution, SortableEvent, SlowFillLeaf, Log } from "../../interfaces"; import { diff --git a/src/svm/assets/idl/index.ts b/src/svm/assets/idl/index.ts new file mode 100644 index 000000000..9574894d8 --- /dev/null +++ b/src/svm/assets/idl/index.ts @@ -0,0 +1,21 @@ +// This file has been autogenerated. Do not edit manually. +// Generated by a script. + +const MessageTransmitterV2Idl = require("./message_transmitter_v2.json"); +const MessageTransmitterIdl = require("./message_transmitter.json"); +const MulticallHandlerIdl = require("./multicall_handler.json"); +const SponsoredCctpSrcPeripheryIdl = require("./sponsored_cctp_src_periphery.json"); +const SvmSpokeIdl = require("./svm_spoke.json"); +const TestIdl = require("./test.json"); +const TokenMessengerMinterV2Idl = require("./token_messenger_minter_v2.json"); +const TokenMessengerMinterIdl = require("./token_messenger_minter.json"); +export { + MessageTransmitterV2Idl, + MessageTransmitterIdl, + MulticallHandlerIdl, + SponsoredCctpSrcPeripheryIdl, + SvmSpokeIdl, + TestIdl, + TokenMessengerMinterV2Idl, + TokenMessengerMinterIdl +}; diff --git a/src/svm/assets/idl/message_transmitter.json b/src/svm/assets/idl/message_transmitter.json new file mode 100644 index 000000000..27504df15 --- /dev/null +++ b/src/svm/assets/idl/message_transmitter.json @@ -0,0 +1,1675 @@ +{ + "address": "CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd", + "metadata": { + "name": "message_transmitter", + "version": "0.1.0", + "spec": "0.1.0" + }, + "instructions": [ + { + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "upgrade_authority", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "message_transmitter_program_data" + }, + { + "name": "message_transmitter_program" + }, + { + "name": "system_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "InitializeParams" + } + } + } + ] + }, + { + "name": "transfer_ownership", + "discriminator": [ + 65, + 177, + 215, + 73, + 53, + 45, + 99, + 47 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "TransferOwnershipParams" + } + } + } + ] + }, + { + "name": "accept_ownership", + "discriminator": [ + 172, + 23, + 43, + 13, + 238, + 213, + 85, + 150 + ], + "accounts": [ + { + "name": "pending_owner", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "AcceptOwnershipParams" + } + } + } + ] + }, + { + "name": "update_pauser", + "discriminator": [ + 140, + 171, + 211, + 132, + 57, + 201, + 16, + 254 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UpdatePauserParams" + } + } + } + ] + }, + { + "name": "update_attester_manager", + "discriminator": [ + 175, + 245, + 178, + 104, + 85, + 179, + 71, + 16 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UpdateAttesterManagerParams" + } + } + } + ] + }, + { + "name": "pause", + "discriminator": [ + 211, + 22, + 221, + 251, + 74, + 121, + 193, + 47 + ], + "accounts": [ + { + "name": "pauser", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "PauseParams" + } + } + } + ] + }, + { + "name": "unpause", + "discriminator": [ + 169, + 144, + 4, + 38, + 10, + 141, + 188, + 255 + ], + "accounts": [ + { + "name": "pauser", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UnpauseParams" + } + } + } + ] + }, + { + "name": "set_max_message_body_size", + "discriminator": [ + 168, + 178, + 8, + 117, + 217, + 167, + 219, + 31 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetMaxMessageBodySizeParams" + } + } + } + ] + }, + { + "name": "enable_attester", + "discriminator": [ + 2, + 11, + 193, + 115, + 5, + 148, + 4, + 198 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "attester_manager", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "system_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "EnableAttesterParams" + } + } + } + ] + }, + { + "name": "disable_attester", + "discriminator": [ + 61, + 171, + 131, + 95, + 172, + 15, + 227, + 229 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "attester_manager", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "system_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "DisableAttesterParams" + } + } + } + ] + }, + { + "name": "set_signature_threshold", + "discriminator": [ + 163, + 19, + 154, + 168, + 82, + 209, + 214, + 219 + ], + "accounts": [ + { + "name": "attester_manager", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetSignatureThresholdParams" + } + } + } + ] + }, + { + "name": "send_message", + "discriminator": [ + 57, + 40, + 34, + 178, + 189, + 10, + 65, + 26 + ], + "accounts": [ + { + "name": "event_rent_payer", + "writable": true, + "signer": true + }, + { + "name": "sender_authority_pda", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "message_sent_event_data", + "writable": true, + "signer": true + }, + { + "name": "sender_program" + }, + { + "name": "system_program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SendMessageParams" + } + } + } + ], + "returns": "u64" + }, + { + "name": "send_message_with_caller", + "discriminator": [ + 212, + 47, + 34, + 52, + 91, + 32, + 176, + 204 + ], + "accounts": [ + { + "name": "event_rent_payer", + "writable": true, + "signer": true + }, + { + "name": "sender_authority_pda", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "message_sent_event_data", + "writable": true, + "signer": true + }, + { + "name": "sender_program" + }, + { + "name": "system_program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SendMessageWithCallerParams" + } + } + } + ], + "returns": "u64" + }, + { + "name": "replace_message", + "discriminator": [ + 189, + 189, + 210, + 163, + 149, + 205, + 69, + 229 + ], + "accounts": [ + { + "name": "event_rent_payer", + "writable": true, + "signer": true + }, + { + "name": "sender_authority_pda", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "message_sent_event_data", + "writable": true, + "signer": true + }, + { + "name": "sender_program" + }, + { + "name": "system_program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "ReplaceMessageParams" + } + } + } + ], + "returns": "u64" + }, + { + "name": "receive_message", + "discriminator": [ + 38, + 144, + 127, + 225, + 31, + 225, + 238, + 25 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "caller", + "signer": true + }, + { + "name": "authority_pda" + }, + { + "name": "message_transmitter" + }, + { + "name": "used_nonces", + "writable": true + }, + { + "name": "receiver" + }, + { + "name": "system_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "ReceiveMessageParams" + } + } + } + ] + }, + { + "name": "reclaim_event_account", + "discriminator": [ + 94, + 198, + 180, + 159, + 131, + 236, + 15, + 174 + ], + "accounts": [ + { + "name": "payee", + "docs": [ + "rent SOL receiver, should match original rent payer" + ], + "writable": true, + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "message_sent_event_data", + "writable": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "ReclaimEventAccountParams" + } + } + } + ] + }, + { + "name": "get_nonce_pda", + "discriminator": [ + 114, + 70, + 229, + 212, + 223, + 50, + 33, + 39 + ], + "accounts": [ + { + "name": "message_transmitter" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "GetNoncePDAParams" + } + } + } + ], + "returns": "pubkey" + }, + { + "name": "is_nonce_used", + "discriminator": [ + 144, + 72, + 107, + 148, + 35, + 218, + 31, + 187 + ], + "accounts": [ + { + "name": "used_nonces", + "docs": [ + "Account will be explicitly loaded to avoid error when it's not initialized" + ] + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "IsNonceUsedParams" + } + } + } + ], + "returns": "bool" + } + ], + "accounts": [ + { + "name": "MessageSent", + "discriminator": [ + 131, + 100, + 133, + 56, + 166, + 225, + 151, + 60 + ] + }, + { + "name": "MessageTransmitter", + "discriminator": [ + 71, + 40, + 180, + 142, + 19, + 203, + 35, + 252 + ] + }, + { + "name": "UsedNonces", + "discriminator": [ + 60, + 112, + 18, + 72, + 138, + 181, + 100, + 138 + ] + } + ], + "events": [ + { + "name": "OwnershipTransferStarted", + "discriminator": [ + 183, + 253, + 239, + 246, + 140, + 179, + 133, + 105 + ] + }, + { + "name": "OwnershipTransferred", + "discriminator": [ + 172, + 61, + 205, + 183, + 250, + 50, + 38, + 98 + ] + }, + { + "name": "PauserChanged", + "discriminator": [ + 142, + 157, + 158, + 87, + 127, + 8, + 119, + 55 + ] + }, + { + "name": "AttesterManagerUpdated", + "discriminator": [ + 5, + 97, + 191, + 108, + 44, + 189, + 69, + 88 + ] + }, + { + "name": "MessageReceived", + "discriminator": [ + 231, + 68, + 47, + 77, + 173, + 241, + 157, + 166 + ] + }, + { + "name": "SignatureThresholdUpdated", + "discriminator": [ + 156, + 99, + 103, + 200, + 15, + 38, + 122, + 189 + ] + }, + { + "name": "AttesterEnabled", + "discriminator": [ + 88, + 57, + 14, + 133, + 5, + 219, + 62, + 190 + ] + }, + { + "name": "AttesterDisabled", + "discriminator": [ + 186, + 136, + 186, + 14, + 229, + 2, + 121, + 211 + ] + }, + { + "name": "MaxMessageBodySizeUpdated", + "discriminator": [ + 134, + 206, + 151, + 111, + 137, + 11, + 160, + 225 + ] + }, + { + "name": "Pause", + "discriminator": [ + 194, + 251, + 232, + 196, + 118, + 95, + 111, + 219 + ] + }, + { + "name": "Unpause", + "discriminator": [ + 241, + 149, + 104, + 90, + 199, + 136, + 219, + 146 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "InvalidAuthority", + "msg": "Invalid authority" + }, + { + "code": 6001, + "name": "ProgramPaused", + "msg": "Instruction is not allowed at this time" + }, + { + "code": 6002, + "name": "InvalidMessageTransmitterState", + "msg": "Invalid message transmitter state" + }, + { + "code": 6003, + "name": "InvalidSignatureThreshold", + "msg": "Invalid signature threshold" + }, + { + "code": 6004, + "name": "SignatureThresholdAlreadySet", + "msg": "Signature threshold already set" + }, + { + "code": 6005, + "name": "InvalidOwner", + "msg": "Invalid owner" + }, + { + "code": 6006, + "name": "InvalidPauser", + "msg": "Invalid pauser" + }, + { + "code": 6007, + "name": "InvalidAttesterManager", + "msg": "Invalid attester manager" + }, + { + "code": 6008, + "name": "InvalidAttester", + "msg": "Invalid attester" + }, + { + "code": 6009, + "name": "AttesterAlreadyEnabled", + "msg": "Attester already enabled" + }, + { + "code": 6010, + "name": "TooFewEnabledAttesters", + "msg": "Too few enabled attesters" + }, + { + "code": 6011, + "name": "SignatureThresholdTooLow", + "msg": "Signature threshold is too low" + }, + { + "code": 6012, + "name": "AttesterAlreadyDisabled", + "msg": "Attester already disabled" + }, + { + "code": 6013, + "name": "MessageBodyLimitExceeded", + "msg": "Message body exceeds max size" + }, + { + "code": 6014, + "name": "InvalidDestinationCaller", + "msg": "Invalid destination caller" + }, + { + "code": 6015, + "name": "InvalidRecipient", + "msg": "Invalid message recipient" + }, + { + "code": 6016, + "name": "SenderNotPermitted", + "msg": "Sender is not permitted" + }, + { + "code": 6017, + "name": "InvalidSourceDomain", + "msg": "Invalid source domain" + }, + { + "code": 6018, + "name": "InvalidDestinationDomain", + "msg": "Invalid destination domain" + }, + { + "code": 6019, + "name": "InvalidMessageVersion", + "msg": "Invalid message version" + }, + { + "code": 6020, + "name": "InvalidUsedNoncesAccount", + "msg": "Invalid used nonces account" + }, + { + "code": 6021, + "name": "InvalidRecipientProgram", + "msg": "Invalid recipient program" + }, + { + "code": 6022, + "name": "InvalidNonce", + "msg": "Invalid nonce" + }, + { + "code": 6023, + "name": "NonceAlreadyUsed", + "msg": "Nonce already used" + }, + { + "code": 6024, + "name": "MessageTooShort", + "msg": "Message is too short" + }, + { + "code": 6025, + "name": "MalformedMessage", + "msg": "Malformed message" + }, + { + "code": 6026, + "name": "InvalidSignatureOrderOrDupe", + "msg": "Invalid signature order or dupe" + }, + { + "code": 6027, + "name": "InvalidAttesterSignature", + "msg": "Invalid attester signature" + }, + { + "code": 6028, + "name": "InvalidAttestationLength", + "msg": "Invalid attestation length" + }, + { + "code": 6029, + "name": "InvalidSignatureRecoveryId", + "msg": "Invalid signature recovery ID" + }, + { + "code": 6030, + "name": "InvalidSignatureSValue", + "msg": "Invalid signature S value" + }, + { + "code": 6031, + "name": "InvalidMessageHash", + "msg": "Invalid message hash" + } + ], + "types": [ + { + "name": "AcceptOwnershipParams", + "type": { + "kind": "struct" + } + }, + { + "name": "DisableAttesterParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "EnableAttesterParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "GetNoncePDAParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nonce", + "type": "u64" + }, + { + "name": "source_domain", + "type": "u32" + } + ] + } + }, + { + "name": "InitializeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "local_domain", + "type": "u32" + }, + { + "name": "attester", + "type": "pubkey" + }, + { + "name": "max_message_body_size", + "type": "u64" + }, + { + "name": "version", + "type": "u32" + } + ] + } + }, + { + "name": "IsNonceUsedParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nonce", + "type": "u64" + } + ] + } + }, + { + "name": "PauseParams", + "type": { + "kind": "struct" + } + }, + { + "name": "ReceiveMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "message", + "type": "bytes" + }, + { + "name": "attestation", + "type": "bytes" + } + ] + } + }, + { + "name": "HandleReceiveMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "sender", + "type": "pubkey" + }, + { + "name": "message_body", + "type": "bytes" + }, + { + "name": "authority_bump", + "type": "u8" + } + ] + } + }, + { + "name": "ReclaimEventAccountParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attestation", + "type": "bytes" + } + ] + } + }, + { + "name": "ReplaceMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "original_message", + "type": "bytes" + }, + { + "name": "original_attestation", + "type": "bytes" + }, + { + "name": "new_message_body", + "type": "bytes" + }, + { + "name": "new_destination_caller", + "type": "pubkey" + } + ] + } + }, + { + "name": "SendMessageWithCallerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "destination_domain", + "type": "u32" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "message_body", + "type": "bytes" + }, + { + "name": "destination_caller", + "type": "pubkey" + } + ] + } + }, + { + "name": "SendMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "destination_domain", + "type": "u32" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "message_body", + "type": "bytes" + } + ] + } + }, + { + "name": "SetMaxMessageBodySizeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_max_message_body_size", + "type": "u64" + } + ] + } + }, + { + "name": "SetSignatureThresholdParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_signature_threshold", + "type": "u32" + } + ] + } + }, + { + "name": "TransferOwnershipParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "UnpauseParams", + "type": { + "kind": "struct" + } + }, + { + "name": "UpdateAttesterManagerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_attester_manager", + "type": "pubkey" + } + ] + } + }, + { + "name": "UpdatePauserParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_pauser", + "type": "pubkey" + } + ] + } + }, + { + "name": "MathError", + "type": { + "kind": "enum", + "variants": [ + { + "name": "MathOverflow" + }, + { + "name": "MathUnderflow" + }, + { + "name": "ErrorInDivision" + } + ] + } + }, + { + "name": "MessageSent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rent_payer", + "type": "pubkey" + }, + { + "name": "message", + "type": "bytes" + } + ] + } + }, + { + "name": "MessageTransmitter", + "docs": [ + "Main state of the MessageTransmitter program" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "pending_owner", + "type": "pubkey" + }, + { + "name": "attester_manager", + "type": "pubkey" + }, + { + "name": "pauser", + "type": "pubkey" + }, + { + "name": "paused", + "type": "bool" + }, + { + "name": "local_domain", + "type": "u32" + }, + { + "name": "version", + "type": "u32" + }, + { + "name": "signature_threshold", + "type": "u32" + }, + { + "name": "enabled_attesters", + "type": { + "vec": "pubkey" + } + }, + { + "name": "max_message_body_size", + "type": "u64" + }, + { + "name": "next_available_nonce", + "type": "u64" + } + ] + } + }, + { + "name": "UsedNonces", + "docs": [ + "UsedNonces account holds an array of bits that indicate which nonces were already used", + "so they can't be resused to receive new messages. Array starts with the first_nonce and", + "holds flags for UsedNonces::MAX_NONCES. Nonces are recorded separately for each remote_domain." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "first_nonce", + "type": "u64" + }, + { + "name": "used_nonces", + "type": { + "array": [ + "u64", + 100 + ] + } + } + ] + } + }, + { + "name": "OwnershipTransferStarted", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previous_owner", + "type": "pubkey" + }, + { + "name": "new_owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "OwnershipTransferred", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previous_owner", + "type": "pubkey" + }, + { + "name": "new_owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "PauserChanged", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_address", + "type": "pubkey" + } + ] + } + }, + { + "name": "AttesterManagerUpdated", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previous_attester_manager", + "type": "pubkey" + }, + { + "name": "new_attester_manager", + "type": "pubkey" + } + ] + } + }, + { + "name": "MessageReceived", + "type": { + "kind": "struct", + "fields": [ + { + "name": "caller", + "type": "pubkey" + }, + { + "name": "source_domain", + "type": "u32" + }, + { + "name": "nonce", + "type": "u64" + }, + { + "name": "sender", + "type": "pubkey" + }, + { + "name": "message_body", + "type": "bytes" + } + ] + } + }, + { + "name": "SignatureThresholdUpdated", + "type": { + "kind": "struct", + "fields": [ + { + "name": "old_signature_threshold", + "type": "u32" + }, + { + "name": "new_signature_threshold", + "type": "u32" + } + ] + } + }, + { + "name": "AttesterEnabled", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "AttesterDisabled", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "MaxMessageBodySizeUpdated", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_max_message_body_size", + "type": "u64" + } + ] + } + }, + { + "name": "Pause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "Unpause", + "type": { + "kind": "struct", + "fields": [] + } + } + ] +} \ No newline at end of file diff --git a/src/svm/assets/idl/message_transmitter_v2.json b/src/svm/assets/idl/message_transmitter_v2.json new file mode 100644 index 000000000..722d98d77 --- /dev/null +++ b/src/svm/assets/idl/message_transmitter_v2.json @@ -0,0 +1,1863 @@ +{ + "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC", + "metadata": { + "name": "message_transmitter_v2", + "version": "0.2.0", + "spec": "0.1.0", + "description": "Message Transmitter for Cross-Chain Transfer Protocol V2", + "repository": "https://github.com/circlefin/solana-cctp-contracts" + }, + "instructions": [ + { + "name": "accept_ownership", + "discriminator": [ + 172, + 23, + 43, + 13, + 238, + 213, + 85, + 150 + ], + "accounts": [ + { + "name": "pending_owner", + "signer": true, + "relations": [ + "message_transmitter" + ] + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "AcceptOwnershipParams" + } + } + } + ] + }, + { + "name": "disable_attester", + "discriminator": [ + 61, + 171, + 131, + 95, + 172, + 15, + 227, + 229 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "attester_manager", + "signer": true, + "relations": [ + "message_transmitter" + ] + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "DisableAttesterParams" + } + } + } + ] + }, + { + "name": "enable_attester", + "discriminator": [ + 2, + 11, + 193, + 115, + 5, + 148, + 4, + 198 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "attester_manager", + "signer": true, + "relations": [ + "message_transmitter" + ] + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "EnableAttesterParams" + } + } + } + ] + }, + { + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "upgrade_authority", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 115, + 115, + 97, + 103, + 101, + 95, + 116, + 114, + 97, + 110, + 115, + 109, + 105, + 116, + 116, + 101, + 114 + ] + } + ] + } + }, + { + "name": "message_transmitter_program_data" + }, + { + "name": "message_transmitter_program", + "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "InitializeParams" + } + } + } + ] + }, + { + "name": "is_nonce_used", + "discriminator": [ + 144, + 72, + 107, + 148, + 35, + 218, + 31, + 187 + ], + "accounts": [ + { + "name": "used_nonce", + "docs": [ + "Account will be explicitly loaded to avoid error when it's not initialized" + ] + } + ], + "args": [], + "returns": "bool" + }, + { + "name": "pause", + "discriminator": [ + 211, + 22, + 221, + 251, + 74, + 121, + 193, + 47 + ], + "accounts": [ + { + "name": "pauser", + "signer": true, + "relations": [ + "message_transmitter" + ] + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "PauseParams" + } + } + } + ] + }, + { + "name": "receive_message", + "discriminator": [ + 38, + 144, + 127, + 225, + 31, + 225, + 238, + 25 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "caller", + "signer": true + }, + { + "name": "authority_pda", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 115, + 115, + 97, + 103, + 101, + 95, + 116, + 114, + 97, + 110, + 115, + 109, + 105, + 116, + 116, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "receiver" + } + ] + } + }, + { + "name": "message_transmitter" + }, + { + "name": "used_nonce", + "docs": [ + "Each nonce is stored in a separate PDA" + ], + "writable": true + }, + { + "name": "receiver" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "ReceiveMessageParams" + } + } + } + ] + }, + { + "name": "reclaim_event_account", + "discriminator": [ + 94, + 198, + 180, + 159, + 131, + 236, + 15, + 174 + ], + "accounts": [ + { + "name": "payee", + "docs": [ + "rent SOL receiver, should match original rent payer" + ], + "writable": true, + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "message_sent_event_data", + "writable": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "ReclaimEventAccountParams" + } + } + } + ] + }, + { + "name": "send_message", + "discriminator": [ + 57, + 40, + 34, + 178, + 189, + 10, + 65, + 26 + ], + "accounts": [ + { + "name": "event_rent_payer", + "writable": true, + "signer": true + }, + { + "name": "sender_authority_pda", + "signer": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "message_sent_event_data", + "writable": true, + "signer": true + }, + { + "name": "sender_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SendMessageParams" + } + } + } + ] + }, + { + "name": "set_max_message_body_size", + "discriminator": [ + 168, + 178, + 8, + 117, + 217, + 167, + 219, + 31 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "message_transmitter" + ] + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetMaxMessageBodySizeParams" + } + } + } + ] + }, + { + "name": "set_signature_threshold", + "discriminator": [ + 163, + 19, + 154, + 168, + 82, + 209, + 214, + 219 + ], + "accounts": [ + { + "name": "attester_manager", + "signer": true, + "relations": [ + "message_transmitter" + ] + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetSignatureThresholdParams" + } + } + } + ] + }, + { + "name": "transfer_ownership", + "discriminator": [ + 65, + 177, + 215, + 73, + 53, + 45, + 99, + 47 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "message_transmitter" + ] + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "TransferOwnershipParams" + } + } + } + ] + }, + { + "name": "unpause", + "discriminator": [ + 169, + 144, + 4, + 38, + 10, + 141, + 188, + 255 + ], + "accounts": [ + { + "name": "pauser", + "signer": true, + "relations": [ + "message_transmitter" + ] + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UnpauseParams" + } + } + } + ] + }, + { + "name": "update_attester_manager", + "discriminator": [ + 175, + 245, + 178, + 104, + 85, + 179, + 71, + 16 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "message_transmitter" + ] + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UpdateAttesterManagerParams" + } + } + } + ] + }, + { + "name": "update_pauser", + "discriminator": [ + 140, + 171, + 211, + 132, + 57, + 201, + 16, + 254 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "message_transmitter" + ] + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UpdatePauserParams" + } + } + } + ] + } + ], + "accounts": [ + { + "name": "MessageSent", + "discriminator": [ + 131, + 100, + 133, + 56, + 166, + 225, + 151, + 60 + ] + }, + { + "name": "MessageTransmitter", + "discriminator": [ + 71, + 40, + 180, + 142, + 19, + 203, + 35, + 252 + ] + }, + { + "name": "UsedNonce", + "discriminator": [ + 212, + 222, + 157, + 252, + 130, + 71, + 179, + 238 + ] + } + ], + "events": [ + { + "name": "AttesterDisabled", + "discriminator": [ + 186, + 136, + 186, + 14, + 229, + 2, + 121, + 211 + ] + }, + { + "name": "AttesterEnabled", + "discriminator": [ + 88, + 57, + 14, + 133, + 5, + 219, + 62, + 190 + ] + }, + { + "name": "AttesterManagerUpdated", + "discriminator": [ + 5, + 97, + 191, + 108, + 44, + 189, + 69, + 88 + ] + }, + { + "name": "MaxMessageBodySizeUpdated", + "discriminator": [ + 134, + 206, + 151, + 111, + 137, + 11, + 160, + 225 + ] + }, + { + "name": "MessageReceived", + "discriminator": [ + 231, + 68, + 47, + 77, + 173, + 241, + 157, + 166 + ] + }, + { + "name": "OwnershipTransferStarted", + "discriminator": [ + 183, + 253, + 239, + 246, + 140, + 179, + 133, + 105 + ] + }, + { + "name": "OwnershipTransferred", + "discriminator": [ + 172, + 61, + 205, + 183, + 250, + 50, + 38, + 98 + ] + }, + { + "name": "Pause", + "discriminator": [ + 194, + 251, + 232, + 196, + 118, + 95, + 111, + 219 + ] + }, + { + "name": "PauserChanged", + "discriminator": [ + 142, + 157, + 158, + 87, + 127, + 8, + 119, + 55 + ] + }, + { + "name": "SignatureThresholdUpdated", + "discriminator": [ + 156, + 99, + 103, + 200, + 15, + 38, + 122, + 189 + ] + }, + { + "name": "Unpause", + "discriminator": [ + 241, + 149, + 104, + 90, + 199, + 136, + 219, + 146 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "InvalidAuthority", + "msg": "Invalid authority" + }, + { + "code": 6001, + "name": "ProgramPaused", + "msg": "Instruction is not allowed at this time" + }, + { + "code": 6002, + "name": "InvalidMessageTransmitterState", + "msg": "Invalid message transmitter state" + }, + { + "code": 6003, + "name": "InvalidSignatureThreshold", + "msg": "Invalid signature threshold" + }, + { + "code": 6004, + "name": "SignatureThresholdAlreadySet", + "msg": "Signature threshold already set" + }, + { + "code": 6005, + "name": "InvalidOwner", + "msg": "Invalid owner" + }, + { + "code": 6006, + "name": "InvalidPauser", + "msg": "Invalid pauser" + }, + { + "code": 6007, + "name": "InvalidAttesterManager", + "msg": "Invalid attester manager" + }, + { + "code": 6008, + "name": "InvalidAttester", + "msg": "Invalid attester" + }, + { + "code": 6009, + "name": "AttesterAlreadyEnabled", + "msg": "Attester already enabled" + }, + { + "code": 6010, + "name": "TooFewEnabledAttesters", + "msg": "Too few enabled attesters" + }, + { + "code": 6011, + "name": "SignatureThresholdTooLow", + "msg": "Signature threshold is too low" + }, + { + "code": 6012, + "name": "AttesterAlreadyDisabled", + "msg": "Attester already disabled" + }, + { + "code": 6013, + "name": "MessageBodyLimitExceeded", + "msg": "Message body exceeds max size" + }, + { + "code": 6014, + "name": "InvalidDestinationCaller", + "msg": "Invalid destination caller" + }, + { + "code": 6015, + "name": "InvalidRecipient", + "msg": "Invalid message recipient" + }, + { + "code": 6016, + "name": "SenderNotPermitted", + "msg": "Sender is not permitted" + }, + { + "code": 6017, + "name": "InvalidSourceDomain", + "msg": "Invalid source domain" + }, + { + "code": 6018, + "name": "InvalidDestinationDomain", + "msg": "Invalid destination domain" + }, + { + "code": 6019, + "name": "InvalidMessageVersion", + "msg": "Invalid message version" + }, + { + "code": 6020, + "name": "InvalidUsedNoncesAccount", + "msg": "Invalid used nonces account" + }, + { + "code": 6021, + "name": "InvalidRecipientProgram", + "msg": "Invalid recipient program" + }, + { + "code": 6022, + "name": "InvalidNonce", + "msg": "Invalid nonce" + }, + { + "code": 6023, + "name": "NonceAlreadyUsed", + "msg": "Nonce already used" + }, + { + "code": 6024, + "name": "MessageTooShort", + "msg": "Message is too short" + }, + { + "code": 6025, + "name": "MalformedMessage", + "msg": "Malformed message" + }, + { + "code": 6026, + "name": "InvalidSignatureOrderOrDupe", + "msg": "Invalid signature order or dupe" + }, + { + "code": 6027, + "name": "InvalidAttesterSignature", + "msg": "Invalid attester signature" + }, + { + "code": 6028, + "name": "InvalidAttestationLength", + "msg": "Invalid attestation length" + }, + { + "code": 6029, + "name": "InvalidSignatureRecoveryId", + "msg": "Invalid signature recovery ID" + }, + { + "code": 6030, + "name": "InvalidSignatureSValue", + "msg": "Invalid signature S value" + }, + { + "code": 6031, + "name": "InvalidMessageHash", + "msg": "Invalid message hash" + }, + { + "code": 6032, + "name": "InvalidDestinationMessage", + "msg": "Invalid destination message" + }, + { + "code": 6033, + "name": "EventAccountWindowNotExpired", + "msg": "Event account window not expired" + }, + { + "code": 6034, + "name": "DestinationDomainIsLocalDomain", + "msg": "Destination domain is local domain" + } + ], + "types": [ + { + "name": "AcceptOwnershipParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "AttesterDisabled", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "AttesterEnabled", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "AttesterManagerUpdated", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previous_attester_manager", + "type": "pubkey" + }, + { + "name": "new_attester_manager", + "type": "pubkey" + } + ] + } + }, + { + "name": "DisableAttesterParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "EnableAttesterParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "InitializeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "local_domain", + "type": "u32" + }, + { + "name": "attester", + "type": "pubkey" + }, + { + "name": "max_message_body_size", + "type": "u64" + }, + { + "name": "version", + "type": "u32" + } + ] + } + }, + { + "name": "MaxMessageBodySizeUpdated", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_max_message_body_size", + "type": "u64" + } + ] + } + }, + { + "name": "MessageReceived", + "type": { + "kind": "struct", + "fields": [ + { + "name": "caller", + "type": "pubkey" + }, + { + "name": "source_domain", + "type": "u32" + }, + { + "name": "nonce", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "sender", + "type": "pubkey" + }, + { + "name": "finality_threshold_executed", + "type": "u32" + }, + { + "name": "message_body", + "type": "bytes" + } + ] + } + }, + { + "name": "MessageSent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rent_payer", + "type": "pubkey" + }, + { + "name": "created_at", + "type": "i64" + }, + { + "name": "message", + "type": "bytes" + } + ] + } + }, + { + "name": "MessageTransmitter", + "docs": [ + "Main state of the MessageTransmitter program" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "pending_owner", + "type": "pubkey" + }, + { + "name": "attester_manager", + "type": "pubkey" + }, + { + "name": "pauser", + "type": "pubkey" + }, + { + "name": "paused", + "type": "bool" + }, + { + "name": "local_domain", + "type": "u32" + }, + { + "name": "version", + "type": "u32" + }, + { + "name": "signature_threshold", + "type": "u32" + }, + { + "name": "enabled_attesters", + "type": { + "vec": "pubkey" + } + }, + { + "name": "max_message_body_size", + "type": "u64" + } + ] + } + }, + { + "name": "OwnershipTransferStarted", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previous_owner", + "type": "pubkey" + }, + { + "name": "new_owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "OwnershipTransferred", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previous_owner", + "type": "pubkey" + }, + { + "name": "new_owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "Pause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "PauseParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "PauserChanged", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_address", + "type": "pubkey" + } + ] + } + }, + { + "name": "ReceiveMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "message", + "type": "bytes" + }, + { + "name": "attestation", + "type": "bytes" + } + ] + } + }, + { + "name": "ReclaimEventAccountParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attestation", + "type": "bytes" + }, + { + "name": "destination_message", + "type": "bytes" + } + ] + } + }, + { + "name": "SendMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "destination_domain", + "type": "u32" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "destination_caller", + "type": "pubkey" + }, + { + "name": "min_finality_threshold", + "type": "u32" + }, + { + "name": "message_body", + "type": "bytes" + } + ] + } + }, + { + "name": "SetMaxMessageBodySizeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_max_message_body_size", + "type": "u64" + } + ] + } + }, + { + "name": "SetSignatureThresholdParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_signature_threshold", + "type": "u32" + } + ] + } + }, + { + "name": "SignatureThresholdUpdated", + "type": { + "kind": "struct", + "fields": [ + { + "name": "old_signature_threshold", + "type": "u32" + }, + { + "name": "new_signature_threshold", + "type": "u32" + } + ] + } + }, + { + "name": "TransferOwnershipParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "Unpause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "UnpauseParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "UpdateAttesterManagerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_attester_manager", + "type": "pubkey" + } + ] + } + }, + { + "name": "UpdatePauserParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_pauser", + "type": "pubkey" + } + ] + } + }, + { + "name": "UsedNonce", + "type": { + "kind": "struct", + "fields": [ + { + "name": "is_used", + "type": "bool" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/src/svm/assets/idl/multicall_handler.json b/src/svm/assets/idl/multicall_handler.json new file mode 100644 index 000000000..22813ecf4 --- /dev/null +++ b/src/svm/assets/idl/multicall_handler.json @@ -0,0 +1,31 @@ +{ + "address": "HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be", + "metadata": { + "name": "multicall_handler", + "version": "0.1.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "handle_v3_across_message", + "discriminator": [ + 131, + 141, + 52, + 71, + 16, + 59, + 196, + 92 + ], + "accounts": [], + "args": [ + { + "name": "message", + "type": "bytes" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/svm/assets/idl/sponsored_cctp_src_periphery.json b/src/svm/assets/idl/sponsored_cctp_src_periphery.json new file mode 100644 index 000000000..8de96f91a --- /dev/null +++ b/src/svm/assets/idl/sponsored_cctp_src_periphery.json @@ -0,0 +1,1965 @@ +{ + "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq", + "metadata": { + "name": "sponsored_cctp_src_periphery", + "version": "0.1.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "docs": [ + "# Across Sponsored CCTP Source Periphery", + "", + "Source chain periphery program for users to interact with to start a sponsored or a non-sponsored flow that allows", + "custom Across-supported flows on destination chain. Uses Circle's CCTPv2 as an underlying bridge" + ], + "instructions": [ + { + "name": "deposit_for_burn", + "docs": [ + "Verifies a sponsored CCTP quote, records its nonce, and burns the user's tokens via CCTPv2 with hook data.", + "", + "The user's depositor ATA is burned via `deposit_for_burn_with_hook` CPI on the CCTPv2. The rent cost for the", + "per-quote `used_nonce` PDA is refunded to the signer from the `rent_fund` and `rent_fund` also funds the", + "creation of CCTP `MessageSent` event account.", + "On success, this emits a `SponsoredDepositForBurn` event to be consumed by offchain infrastructure. This also", + "emits a `CreatedEventAccount` event containing the address of the created CCTP `MessageSent` event account that", + "can be reclaimed later using the `reclaim_event_account` instruction.", + "", + "Required Accounts:", + "- signer (Signer, Writable): The user authorizing the burn.", + "- state (Account): Program state PDA. Seed: [\"state\"].", + "- rent_fund (SystemAccount, Writable): PDA used to sponsor rent and event accounts. Seed: [\"rent_fund\"].", + "- minimum_deposit (Account): Minimum deposit state PDA. Seed: [\"minimum_deposit\", burn_token.key()].", + "- used_nonce (Account, Writable, Init): Per-quote nonce PDA. Seed: [\"used_nonce\", nonce].", + "- rent_claim (Optional Account, Writable, Init-If-Needed): Optional PDA to accrue rent_fund debt to the user.", + "Seed: [\"rent_claim\", signer.key()].", + "- depositor_token_account (InterfaceAccount, Writable): Signer ATA of the burn token.", + "- burn_token (InterfaceAccount, Mutable): Mint of the token to burn. Must match quote.burn_token.", + "- denylist_account (Unchecked): CCTP denylist PDA, validated within CCTP.", + "- token_messenger_minter_sender_authority (Unchecked): CCTP sender authority PDA.", + "- message_transmitter (Unchecked, Mutable): CCTP MessageTransmitter account.", + "- token_messenger (Unchecked): CCTP TokenMessenger account.", + "- remote_token_messenger (Unchecked): Remote TokenMessenger account for destination domain.", + "- token_minter (Unchecked): CCTP TokenMinter account.", + "- local_token (Unchecked, Mutable): Local token account (CCTP).", + "- cctp_event_authority (Unchecked): CCTP event authority account.", + "- message_sent_event_data (Signer, Mutable): Fresh account to store CCTP MessageSent event data.", + "- message_transmitter_program (Program): CCTPv2 MessageTransmitter program.", + "- token_messenger_minter_program (Program): CCTPv2 TokenMessengerMinter program.", + "- token_program (Interface): SPL token program.", + "- system_program (Program): System program.", + "", + "Parameters:", + "- quote: SponsoredCCTPQuote struct serialized by Anchor:", + "- source_domain: CCTP domain ID of the source chain.", + "- destination_domain: CCTP domain ID of the destination chain.", + "- mint_recipient: The recipient of the minted tokens on the destination chain.", + "- amount: The amount of tokens that the user pays on the source chain.", + "- burn_token: The token that will be burned on the source chain.", + "- destination_caller: The caller of the destination chain.", + "- max_fee: Maximum fee to pay on the destination domain, specified in units of burn_token.", + "- min_finality_threshold: Minimum finality threshold before allowed to attest.", + "- nonce: Nonce is used to prevent replay attacks.", + "- deadline: Timestamp of the quote after which it can no longer be used.", + "- max_bps_to_sponsor: The maximum basis points of the amount that can be sponsored.", + "- max_user_slippage_bps: Slippage tolerance for the fees on the destination. Used in swap flow, enforced on", + "destination.", + "- final_recipient: The final recipient of the sponsored deposit. This is needed as the mint_recipient will be", + "the handler contract address instead of the final recipient.", + "- final_token: The final token that final recipient will receive. This is needed as it can be different from", + "the burn_token in which case we perform a swap on the destination chain.", + "- execution_mode: Execution mode: DirectToCore (0), ArbitraryActionsToCore (1), or ArbitraryActionsToEVM (2).", + "- action_data: Encoded action data for arbitrary execution. Empty for DirectToCore mode.", + "- signature: 65-byte EVM signature authorizing the quote by the trusted signer.", + "", + "Notes:", + "- The upgrade authority must have set the valid EVM signer for this instruction to succeed.", + "- The operator of this program must have funded the `rent_fund` PDA with sufficient lamports to cover", + "rent for the `used_nonce` PDA and the CCTP `MessageSent` event account." + ], + "discriminator": [ + 215, + 60, + 61, + 46, + 114, + 55, + 128, + 176 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "rent_fund", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 102, + 117, + 110, + 100 + ] + } + ] + } + }, + { + "name": "minimum_deposit", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 105, + 110, + 105, + 109, + 117, + 109, + 95, + 100, + 101, + 112, + 111, + 115, + 105, + 116 + ] + }, + { + "kind": "account", + "path": "burn_token" + } + ] + } + }, + { + "name": "used_nonce", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 100, + 95, + 110, + 111, + 110, + 99, + 101 + ] + }, + { + "kind": "arg", + "path": "params.quote.nonce" + } + ] + } + }, + { + "name": "rent_claim", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 99, + 108, + 97, + 105, + 109 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "depositor_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "signer" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "burn_token" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "burn_token", + "writable": true + }, + { + "name": "denylist_account" + }, + { + "name": "token_messenger_minter_sender_authority" + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "token_messenger" + }, + { + "name": "remote_token_messenger" + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true + }, + { + "name": "cctp_event_authority" + }, + { + "name": "message_sent_event_data", + "writable": true, + "signer": true + }, + { + "name": "message_transmitter_program", + "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" + }, + { + "name": "token_messenger_minter_program", + "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "DepositForBurnParams" + } + } + } + ] + }, + { + "name": "get_used_nonce_close_info", + "docs": [ + "Returns whether a `used_nonce` PDA can be closed now and the timestamp after which it can be closed.", + "", + "This is a convenience \"view\" helper for off-chain systems to determine when rent can be reclaimed for a", + "specific quote nonce.", + "", + "Required Accounts:", + "- state (Account): Program state PDA. Seed: [\"state\"].", + "- used_nonce (Account): The `used_nonce` PDA. Seed: [\"used_nonce\", nonce].", + "", + "Parameters:", + "- _params.nonce: The 32-byte nonce identifying the PDA to check.", + "", + "Returns:", + "- UsedNonceCloseInfo { can_close_after, can_close_now }" + ], + "discriminator": [ + 19, + 183, + 42, + 151, + 118, + 234, + 57, + 92 + ], + "accounts": [ + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "used_nonce", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 100, + 95, + 110, + 111, + 110, + 99, + 101 + ] + }, + { + "kind": "arg", + "path": "_params.nonce" + } + ] + } + } + ], + "args": [ + { + "name": "_params", + "type": { + "defined": { + "name": "UsedNonceAccountParams" + } + } + } + ], + "returns": { + "defined": { + "name": "UsedNonceCloseInfo" + } + } + }, + { + "name": "initialize", + "docs": [ + "Initializes immutable program state and sets the trusted EVM quote signer.", + "", + "This can only be called once by the upgrade authority. It stores the local CCTP source domain and the", + "quote `signer` that must authorize sponsored deposits.", + "", + "Required Accounts:", + "- signer (Signer, Writable): Must be the program upgrade authority.", + "- state (Writable): Program state PDA. Seed: [\"state\"].", + "- program_data (Account): Program data account to verify the upgrade authority.", + "- this_program (Program): This program account, used to resolve `programdata_address`.", + "- system_program (Program): System program for account creation.", + "", + "Parameters:", + "- source_domain: CCTP domain for this chain (e.g., 5 for Solana).", + "- signer: EVM address (encoded as `Pubkey`) authorized to sign sponsored quotes." + ], + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "program_data" + }, + { + "name": "this_program", + "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "InitializeParams" + } + } + } + ] + }, + { + "name": "reclaim_event_account", + "docs": [ + "Reclaims the CCTP `MessageSent` event account, returning rent to the rent fund.", + "", + "Required Accounts:", + "- rent_fund (SystemAccount, Writable): PDA to receive reclaimed lamports. Seed: [\"rent_fund\"].", + "- message_transmitter (Unchecked, Mutable): CCTP MessageTransmitter account.", + "- message_sent_event_data (Account, Mutable): The `MessageSent` event account created during `deposit_for_burn`.", + "- message_transmitter_program (Program): CCTPv2 MessageTransmitter program.", + "", + "Parameters:", + "- params: Parameters struct required to construct reclaim_event_account instruction on the CCTPv2.", + "- attestation: Attestation obtained from the CCTP attestation service.", + "- nonce: bytes32 from the attested destination message.", + "- finality_threshold_executed: uint32 BE encoded from the attested destination message.", + "- fee_executed: uint256 BE encoded from the attested destination message body.", + "- expiration_block: uint256 BE encoded from the attested destination message body.", + "", + "Notes:", + "- This can only be called after the CCTP attestation service has processed the message and sufficient time has", + "passed since the `MessageSent` event was created. The operator can track the closable accounts from the", + "emitted `CreatedEventAccount` events and using the `EVENT_ACCOUNT_WINDOW_SECONDS` set in CCTP program." + ], + "discriminator": [ + 94, + 198, + 180, + 159, + 131, + 236, + 15, + 174 + ], + "accounts": [ + { + "name": "rent_fund", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 102, + 117, + 110, + 100 + ] + } + ] + } + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "message_sent_event_data", + "writable": true + }, + { + "name": "message_transmitter_program", + "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "ReclaimEventAccountParams" + } + } + } + ] + }, + { + "name": "reclaim_used_nonce_account", + "docs": [ + "Closes a `used_nonce` PDA once its quote deadline has passed, returning rent to the rent fund.", + "", + "Required Accounts:", + "- state (Account): Program state PDA. Seed: [\"state\"]. Used to fetch current time.", + "- rent_fund (SystemAccount, Writable): PDA receiving lamports upon close. Seed: [\"rent_fund\"].", + "- used_nonce (Account, Writable, Close=rent_fund): PDA to close. Seed: [\"used_nonce\", nonce].", + "", + "Parameters:", + "- params.nonce: The 32-byte nonce identifying the PDA to close.", + "", + "Notes:", + "- This can only be called after the quote's deadline has passed. The operator can track closable `used_nonce`", + "accounts from the emitted `SponsoredDepositForBurn` events (`quote_nonce` and `quote_deadline`) and using the", + "`get_used_nonce_close_info` helper." + ], + "discriminator": [ + 153, + 152, + 111, + 172, + 156, + 104, + 116, + 3 + ], + "accounts": [ + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "rent_fund", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 102, + 117, + 110, + 100 + ] + } + ] + } + }, + { + "name": "used_nonce", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 100, + 95, + 110, + 111, + 110, + 99, + 101 + ] + }, + { + "kind": "arg", + "path": "params.nonce" + } + ] + } + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UsedNonceAccountParams" + } + } + } + ] + }, + { + "name": "repay_rent_fund_debt", + "docs": [ + "Repays rent_fund liability for a user if rent_fund had insufficient balance at the time of deposit.", + "", + "Required Accounts:", + "- rent_fund (SystemAccount, Writable): PDA used to sponsor rent and event accounts. Seed: [\"rent_fund\"].", + "- recipient (Unchecked, Writable): The user account to repay rent fund debt to.", + "- rent_claim (Account, Writable, Close=recipient): PDA with accrued rent_fund debt to the user.", + "Seed: [\"rent_claim\", recipient.key()].", + "- system_program (Program): System program." + ], + "discriminator": [ + 111, + 95, + 222, + 174, + 241, + 41, + 61, + 78 + ], + "accounts": [ + { + "name": "rent_fund", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 102, + 117, + 110, + 100 + ] + } + ] + } + }, + { + "name": "recipient", + "writable": true + }, + { + "name": "rent_claim", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 99, + 108, + 97, + 105, + 109 + ] + }, + { + "kind": "account", + "path": "recipient" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "set_current_time", + "docs": [ + "Sets the current time in test mode. No-op on mainnet builds.", + "", + "Required Accounts:", + "- state (Writable): Program state PDA. Seed: [\"state\"].", + "- signer (Signer): Any signer. Only enabled when built with `--features test`.", + "", + "Parameters:", + "- new_time: New unix timestamp to set for tests." + ], + "discriminator": [ + 69, + 100, + 169, + 193, + 125, + 0, + 150, + 69 + ], + "accounts": [ + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "signer", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetCurrentTimeParams" + } + } + } + ] + }, + { + "name": "set_minimum_deposit_amount", + "docs": [ + "Updates the minimum deposit amount for a given burn token.", + "", + "Only callable by the upgrade authority. This must be set at least once for a supported burn token as otherwise", + "deposits would be blocked.", + "", + "Required Accounts:", + "- signer (Signer, Writable): Must be the program upgrade authority.", + "- minimum_deposit (Writable): Minimum deposit state PDA. Seed: [\"minimum_deposit\", burn_token.key()].", + "- burn_token: Supported burn token for which the minimum deposit amount is being set.", + "- program_data (Account): Program data account to verify the upgrade authority.", + "- this_program (Program): This program account, used to resolve `programdata_address`.", + "- system_program (Program): System program for transfers.", + "", + "Parameters:", + "- amount: New minimum deposit amount for a given burn token." + ], + "discriminator": [ + 176, + 4, + 74, + 229, + 206, + 148, + 151, + 138 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "minimum_deposit", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 105, + 110, + 105, + 109, + 117, + 109, + 95, + 100, + 101, + 112, + 111, + 115, + 105, + 116 + ] + }, + { + "kind": "account", + "path": "burn_token" + } + ] + } + }, + { + "name": "burn_token" + }, + { + "name": "program_data" + }, + { + "name": "this_program", + "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetMinimumDepositAmountParams" + } + } + } + ] + }, + { + "name": "set_signer", + "docs": [ + "Updates the trusted EVM quote signer.", + "", + "Only callable by the upgrade authority. Setting this to an invalid address (including `Pubkey::default()`) will", + "effectively disable deposits.", + "", + "Required Accounts:", + "- signer (Signer, Writable): Must be the program upgrade authority.", + "- state (Writable): Program state PDA. Seed: [\"state\"].", + "- program_data (Account): Program data account to verify the upgrade authority.", + "- this_program (Program): This program account, used to resolve `programdata_address`.", + "", + "Parameters:", + "- new_signer: New EVM signer address (encoded as `Pubkey`)." + ], + "discriminator": [ + 127, + 120, + 252, + 184, + 97, + 4, + 88, + 68 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "program_data" + }, + { + "name": "this_program", + "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetSignerParams" + } + } + } + ] + }, + { + "name": "withdraw_rent_fund", + "docs": [ + "Withdraws lamports from the rent fund PDA to an arbitrary recipient.", + "", + "The rent fund is used to sponsor temporary account creation (e.g., CCTP event accounts or per-quote nonce PDAs).", + "Only callable by the upgrade authority.", + "", + "Required Accounts:", + "- signer (Signer, Writable): Must be the program upgrade authority.", + "- rent_fund (SystemAccount, Writable): PDA holding lamports used for rent sponsorship. Seed: [\"rent_fund\"].", + "- recipient (UncheckedAccount, Writable): Destination account for the withdrawn lamports.", + "- program_data (Account): Program data account to verify the upgrade authority.", + "- this_program (Program): This program account, used to resolve `programdata_address`.", + "- system_program (Program): System program for transfers.", + "", + "Parameters:", + "- amount: Amount of lamports to transfer to the recipient." + ], + "discriminator": [ + 153, + 28, + 108, + 116, + 132, + 70, + 161, + 125 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "rent_fund", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 102, + 117, + 110, + 100 + ] + } + ] + } + }, + { + "name": "recipient", + "writable": true + }, + { + "name": "program_data" + }, + { + "name": "this_program", + "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "WithdrawRentFundParams" + } + } + } + ] + } + ], + "accounts": [ + { + "name": "MessageSent", + "discriminator": [ + 131, + 100, + 133, + 56, + 166, + 225, + 151, + 60 + ] + }, + { + "name": "MinimumDeposit", + "discriminator": [ + 218, + 139, + 120, + 202, + 3, + 12, + 233, + 65 + ] + }, + { + "name": "RentClaim", + "discriminator": [ + 13, + 5, + 183, + 82, + 60, + 122, + 72, + 11 + ] + }, + { + "name": "State", + "discriminator": [ + 216, + 146, + 107, + 94, + 104, + 75, + 182, + 177 + ] + }, + { + "name": "UsedNonce", + "discriminator": [ + 212, + 222, + 157, + 252, + 130, + 71, + 179, + 238 + ] + } + ], + "events": [ + { + "name": "AccruedRentFundLiability", + "discriminator": [ + 56, + 17, + 203, + 169, + 27, + 139, + 36, + 225 + ] + }, + { + "name": "CreatedEventAccount", + "discriminator": [ + 178, + 224, + 189, + 92, + 50, + 100, + 128, + 204 + ] + }, + { + "name": "MinimumDepositAmountSet", + "discriminator": [ + 134, + 237, + 176, + 205, + 21, + 44, + 95, + 177 + ] + }, + { + "name": "ReclaimedEventAccount", + "discriminator": [ + 210, + 180, + 74, + 27, + 92, + 74, + 46, + 216 + ] + }, + { + "name": "ReclaimedUsedNonceAccount", + "discriminator": [ + 6, + 199, + 109, + 7, + 58, + 150, + 119, + 103 + ] + }, + { + "name": "RepaidRentFundDebt", + "discriminator": [ + 134, + 86, + 59, + 173, + 10, + 250, + 191, + 190 + ] + }, + { + "name": "SignerSet", + "discriminator": [ + 137, + 203, + 187, + 74, + 141, + 187, + 226, + 95 + ] + }, + { + "name": "SponsoredDepositForBurn", + "discriminator": [ + 55, + 106, + 70, + 41, + 59, + 102, + 172, + 42 + ] + }, + { + "name": "WithdrawnRentFund", + "discriminator": [ + 110, + 180, + 127, + 254, + 32, + 122, + 209, + 22 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "NotUpgradeAuthority", + "msg": "Only the upgrade authority can call this instruction" + }, + { + "code": 6001, + "name": "InvalidProgramData", + "msg": "Invalid program data account" + }, + { + "code": 6002, + "name": "CannotSetCurrentTime", + "msg": "Cannot set time if not in test mode" + }, + { + "code": 6003, + "name": "InvalidBurnToken", + "msg": "Invalid burn_token key" + }, + { + "code": 6004, + "name": "AmountNotPositive", + "msg": "Amount must be greater than 0" + }, + { + "code": 6005, + "name": "QuoteDeadlineNotPassed", + "msg": "The quote deadline has not passed!" + }, + { + "code": 6006, + "name": "SignerUnchanged", + "msg": "New signer unchanged" + }, + { + "code": 6007, + "name": "DepositAmountBelowMinimum", + "msg": "Deposit amount below minimum" + }, + { + "code": 6008, + "name": "MissingRentClaimAccount", + "msg": "Missing rent claim account" + }, + { + "code": 6009, + "name": "RentClaimOverflow", + "msg": "Rent claim amount overflow" + }, + { + "code": 6010, + "name": "InvalidRecipientKey", + "msg": "Invalid recipient key" + } + ], + "types": [ + { + "name": "AccruedRentFundLiability", + "type": { + "kind": "struct", + "fields": [ + { + "name": "user", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "total_user_claim", + "type": "u64" + } + ] + } + }, + { + "name": "CreatedEventAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "message_sent_event_data", + "type": "pubkey" + } + ] + } + }, + { + "name": "DepositForBurnParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "quote", + "type": { + "defined": { + "name": "SponsoredCCTPQuote" + } + } + }, + { + "name": "signature", + "type": { + "array": [ + "u8", + 65 + ] + } + } + ] + } + }, + { + "name": "InitializeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "source_domain", + "type": "u32" + }, + { + "name": "signer", + "type": "pubkey" + } + ] + } + }, + { + "name": "MessageSent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rent_payer", + "type": "pubkey" + }, + { + "name": "created_at", + "type": "i64" + }, + { + "name": "message", + "type": "bytes" + } + ] + } + }, + { + "name": "MinimumDeposit", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "MinimumDepositAmountSet", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "burn_token", + "type": "pubkey" + } + ] + } + }, + { + "name": "ReclaimEventAccountParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attestation", + "type": "bytes" + }, + { + "name": "nonce", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "finality_threshold_executed", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "fee_executed", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "expiration_block", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "ReclaimedEventAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "message_sent_event_data", + "type": "pubkey" + } + ] + } + }, + { + "name": "ReclaimedUsedNonceAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nonce", + "type": "bytes" + }, + { + "name": "used_nonce", + "type": "pubkey" + } + ] + } + }, + { + "name": "RentClaim", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "RepaidRentFundDebt", + "type": { + "kind": "struct", + "fields": [ + { + "name": "user", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "remaining_user_claim", + "type": "u64" + } + ] + } + }, + { + "name": "SetCurrentTimeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_time", + "type": "u64" + } + ] + } + }, + { + "name": "SetMinimumDepositAmountParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "SetSignerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_signer", + "type": "pubkey" + } + ] + } + }, + { + "name": "SignerSet", + "type": { + "kind": "struct", + "fields": [ + { + "name": "old_signer", + "type": "pubkey" + }, + { + "name": "new_signer", + "type": "pubkey" + } + ] + } + }, + { + "name": "SponsoredCCTPQuote", + "type": { + "kind": "struct", + "fields": [ + { + "name": "source_domain", + "type": "u32" + }, + { + "name": "destination_domain", + "type": "u32" + }, + { + "name": "mint_recipient", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "burn_token", + "type": "pubkey" + }, + { + "name": "destination_caller", + "type": "pubkey" + }, + { + "name": "max_fee", + "type": "u64" + }, + { + "name": "min_finality_threshold", + "type": "u32" + }, + { + "name": "nonce", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "deadline", + "type": "u64" + }, + { + "name": "max_bps_to_sponsor", + "type": "u64" + }, + { + "name": "max_user_slippage_bps", + "type": "u64" + }, + { + "name": "final_recipient", + "type": "pubkey" + }, + { + "name": "final_token", + "type": "pubkey" + }, + { + "name": "destination_dex", + "type": "u32" + }, + { + "name": "account_creation_mode", + "type": "u8" + }, + { + "name": "execution_mode", + "type": "u8" + }, + { + "name": "action_data", + "type": "bytes" + } + ] + } + }, + { + "name": "SponsoredDepositForBurn", + "type": { + "kind": "struct", + "fields": [ + { + "name": "quote_nonce", + "type": "bytes" + }, + { + "name": "origin_sender", + "type": "pubkey" + }, + { + "name": "final_recipient", + "type": "pubkey" + }, + { + "name": "quote_deadline", + "type": "u64" + }, + { + "name": "max_bps_to_sponsor", + "type": "u64" + }, + { + "name": "max_user_slippage_bps", + "type": "u64" + }, + { + "name": "final_token", + "type": "pubkey" + }, + { + "name": "destination_dex", + "type": "u32" + }, + { + "name": "account_creation_mode", + "type": "u8" + }, + { + "name": "signature", + "type": "bytes" + } + ] + } + }, + { + "name": "State", + "type": { + "kind": "struct", + "fields": [ + { + "name": "source_domain", + "type": "u32" + }, + { + "name": "signer", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "UsedNonce", + "type": { + "kind": "struct", + "fields": [ + { + "name": "quote_deadline", + "type": "u64" + } + ] + } + }, + { + "name": "UsedNonceAccountParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nonce", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "UsedNonceCloseInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "can_close_after", + "type": "u64" + }, + { + "name": "can_close_now", + "type": "bool" + } + ] + } + }, + { + "name": "WithdrawRentFundParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "WithdrawnRentFund", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipient", + "type": "pubkey" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/src/svm/assets/idl/svm_spoke.json b/src/svm/assets/idl/svm_spoke.json new file mode 100644 index 000000000..7a667114e --- /dev/null +++ b/src/svm/assets/idl/svm_spoke.json @@ -0,0 +1,5496 @@ +{ + "address": "DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru", + "metadata": { + "name": "svm_spoke", + "version": "0.1.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "bridge_tokens_to_hub_pool", + "docs": [ + "Bridges tokens to the Hub Pool.", + "", + "This function initiates the process of sending tokens from the vault to the Hub Pool based on the outstanding", + "token liability this Spoke Pool has accrued. Enables the caller to choose a custom amount to work around CCTP", + "bridging limits. enforces that amount is less than or equal to liability. On execution decrements liability.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the bridge operation.", + "- payer (Signer): The account responsible for paying the transaction fees.", + "- mint (InterfaceAccount): The mint account for the token being bridged.", + "- state (Account): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- transfer_liability (Account): Account tracking the pending amount to be sent to the Hub Pool. Incremented on", + "relayRootBundle() and decremented on when this function is called. Seed: [\"transfer_liability\",mint].", + "- vault (InterfaceAccount): The ATA for the token being bridged. Authority must be the state.", + "- token_messenger_minter_sender_authority (UncheckedAccount): Authority for the token messenger minter.", + "- message_transmitter (UncheckedAccount): Account for the message transmitter.", + "- token_messenger (UncheckedAccount): Account for the token messenger.", + "- remote_token_messenger (UncheckedAccount): Account for the remote token messenger.", + "- token_minter (UncheckedAccount): Account for the token minter.", + "- local_token (UncheckedAccount): Account for the local token.", + "- cctp_event_authority (UncheckedAccount): Authority for CCTP events.", + "- message_sent_event_data (Signer): Account for message sent event data.", + "- message_transmitter_program (Program): Program for the message transmitter.", + "- token_messenger_minter_program (Program): Program for the token messenger minter.", + "- token_program (Interface): The token program.", + "- system_program (Program): The system program.", + "", + "### Parameters:", + "- amount: The amount of tokens to bridge to the Hub Pool." + ], + "discriminator": [ + 1, + 83, + 255, + 59, + 232, + 55, + 64, + 216 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "mint", + "writable": true + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "transfer_liability", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 114, + 97, + 110, + 115, + 102, + 101, + 114, + 95, + 108, + 105, + 97, + 98, + 105, + 108, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "mint" + } + ] + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "token_messenger_minter_sender_authority" + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "token_messenger" + }, + { + "name": "remote_token_messenger" + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true + }, + { + "name": "cctp_event_authority" + }, + { + "name": "message_sent_event_data", + "writable": true, + "signer": true + }, + { + "name": "message_transmitter_program", + "address": "CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd" + }, + { + "name": "token_messenger_minter_program", + "address": "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3" + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "claim_relayer_refund", + "docs": [ + "Claims a relayer refund for the caller.", + "", + "In the event a relayer refund was sent to a claim account, then this function enables the relayer to claim it by", + "transferring the claim amount from the vault to their token account. The claim account is closed after refund.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the claim.", + "- initializer (UncheckedAccount): Must be the same account that initialized the claim account.", + "- state (Account): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- vault (InterfaceAccount): The ATA for the refunded mint. Authority must be the state.", + "- mint (InterfaceAccount): The mint account for the token being refunded.", + "- refund_address: token account authority receiving the refund.", + "- token_account (InterfaceAccount): The receiving token account for the refund. When refund_address is different", + "from the signer, this must match its ATA.", + "- claim_account (Account): The claim account PDA. Seed: [\"claim_account\",mint,refund_address].", + "- token_program (Interface): The token program." + ], + "discriminator": [ + 205, + 34, + 34, + 224, + 204, + 103, + 81, + 176 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "initializer", + "writable": true + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "mint" + }, + { + "name": "refund_address" + }, + { + "name": "token_account", + "writable": true + }, + { + "name": "claim_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 108, + 97, + 105, + 109, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "account", + "path": "mint" + }, + { + "kind": "account", + "path": "refund_address" + } + ] + } + }, + { + "name": "token_program" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "close_claim_account", + "docs": [ + "Closes a claim account for a relayer refund.", + "", + "This function is used to close the claim account associated with a specific mint and refund address,", + "effectively marking the end of its lifecycle. It can only be called once the claim account is empty. It", + "transfers any remaining lamports to the signer and resets the account.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the closure. Must be the initializer of the claim account.", + "- mint: The mint associated with the claim account.", + "- refund_address: The refund address associated with the claim account.", + "- claim_account (Writable): The claim account PDA to be closed. Seed: [\"claim_account\",mint,refund_address]." + ], + "discriminator": [ + 241, + 146, + 203, + 216, + 58, + 222, + 91, + 118 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "mint" + }, + { + "name": "refund_address" + }, + { + "name": "claim_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 108, + 97, + 105, + 109, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "account", + "path": "mint" + }, + { + "kind": "account", + "path": "refund_address" + } + ] + } + } + ], + "args": [] + }, + { + "name": "close_fill_pda", + "docs": [ + "Closes the FillStatusAccount PDA to reclaim relayer rent.", + "", + "This function is used to close the FillStatusAccount associated with a specific relay hash, effectively marking", + "the end of its lifecycle. This can only be done once the fill deadline has passed. Relayers should do this for", + "all fills once they expire to reclaim their rent.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the closure. Must be the relayer in the fill_status PDA.", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- fill_status (Writable): The FillStatusAccount PDA to be closed." + ], + "discriminator": [ + 224, + 39, + 208, + 68, + 8, + 226, + 23, + 214 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "fill_status", + "writable": true + } + ], + "args": [] + }, + { + "name": "close_instruction_params", + "docs": [ + "Closes the instruction parameters account.", + "", + "This function is used to close the instruction parameters account, effectively marking the end of its lifecycle.", + "It transfers any remaining lamports to the signer and resets the account.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the closure.", + "- instruction_params (UncheckedAccount): The account to be closed. seed: [\"instruction_params\",signer]. Not", + "the signer being within the seed here implicitly protects this from only being called by the creator." + ], + "discriminator": [ + 224, + 44, + 254, + 10, + 216, + 8, + 172, + 96 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "instruction_params", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + } + ], + "args": [] + }, + { + "name": "create_token_accounts", + "docs": [ + "Creates token accounts in batch for a set of addresses.", + "", + "This helper function allows the caller to pass in a set of remaining accounts to create a batch of Associated", + "Token Accounts (ATAs) for addresses. It is particularly useful for relayers to call before filling a deposit.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the creation of token accounts.", + "- mint (InterfaceAccount): The mint account for the token.", + "- token_program (Interface): The token program.", + "- associated_token_program (Program): The associated token program.", + "- system_program (Program): The system program required for account creation." + ], + "discriminator": [ + 163, + 216, + 49, + 204, + 97, + 16, + 80, + 167 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "mint" + }, + { + "name": "token_program" + }, + { + "name": "associated_token_program", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "deposit", + "docs": [ + "Request to bridge input_token to a target chain and receive output_token.", + "", + "The fee paid to relayers and the system is captured in the spread between the input and output amounts,", + "denominated in the input token. A relayer on the destination chain will send `output_amount` of `output_token`", + "to the recipient and receive `input_token` on a repayment chain of their choice. The fee accounts for:", + "destination transaction costs, relayer's opportunity cost of capital while waiting for a refund during the", + "optimistic challenge window in the HubPool, and the system fee charged to the relayer.", + "", + "On the destination chain, a unique hash of the deposit data is used to identify this deposit. Modifying any", + "parameters will result in a different hash, creating a separate deposit. The hash is computed using all parameters", + "of this function along with the chain's `chainId()`. Relayers are refunded only for deposits with hashes that", + "exactly match those emitted by this contract.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the deposit.", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- depositor_token_account (Writable): The depositor's ATA for the input token.", + "- vault (Writable): Programs ATA for the associated input token. This is where the depositor's assets are sent.", + "Authority must be the state.", + "- mint (Account): The mint account for the input token.", + "- token_program (Interface): The token program.", + "- delegate (Account): The account used to delegate the input amount of the input token.", + "", + "### Parameters", + "- depositor: The account credited with the deposit. Can be different from the signer.", + "- recipient: The account receiving funds on the destination chain. Depending on the output chain can be an ETH", + "address or a contract address or any other address type encoded as a bytes32 field.", + "- input_token: The token pulled from the caller's account and locked into this program's vault on deposit.", + "- output_token: The token that the relayer will send to the recipient on the destination chain.", + "- input_amount: The amount of input tokens to pull from the caller's account and lock into the vault. This", + "amount will be sent to the relayer on their repayment chain of choice as a refund following an optimistic", + "challenge window in the HubPool, less a system fee.", + "- output_amount: The amount of output tokens that the relayer will send to the recipient on the destination.", + "This is big-endian encoded as a 32-byte array to match its underlying byte representation on EVM side.", + "- destination_chain_id: The destination chain identifier where the fill should be made.", + "- exclusive_relayer: The relayer that will be exclusively allowed to fill this deposit before the exclusivity", + "deadline timestamp. This must be a valid, non-zero address if the exclusivity deadline is greater than the", + "current block timestamp.", + "- quote_timestamp: The HubPool timestamp that is used to determine the system fee paid by the depositor. This", + "must be set to some time between [currentTime - depositQuoteTimeBuffer, currentTime].", + "- fill_deadline: The deadline for the relayer to fill the deposit. After this destination chain timestamp, the", + "fill will revert on the destination chain. Must be set before currentTime + fillDeadlineBuffer.", + "- exclusivity_parameter: Sets the exclusivity deadline timestamp for the exclusiveRelayer to fill the deposit.", + "1. If 0, no exclusivity period.", + "2. If less than MAX_EXCLUSIVITY_PERIOD_SECONDS, adds this value to the current block timestamp.", + "3. Otherwise, uses this value as the exclusivity deadline timestamp.", + "- message: The message to send to the recipient on the destination chain if the recipient is a contract.", + "If not empty, the recipient contract must implement handleV3AcrossMessage() or the fill will revert." + ], + "discriminator": [ + 242, + 35, + 198, + 137, + 82, + 225, + 242, + 182 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "delegate" + }, + { + "name": "depositor_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "arg", + "path": "depositor" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "mint" + }, + { + "name": "token_program" + }, + { + "name": "associated_token_program", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "input_token", + "type": "pubkey" + }, + { + "name": "output_token", + "type": "pubkey" + }, + { + "name": "input_amount", + "type": "u64" + }, + { + "name": "output_amount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "destination_chain_id", + "type": "u64" + }, + { + "name": "exclusive_relayer", + "type": "pubkey" + }, + { + "name": "quote_timestamp", + "type": "u32" + }, + { + "name": "fill_deadline", + "type": "u32" + }, + { + "name": "exclusivity_parameter", + "type": "u32" + }, + { + "name": "message", + "type": "bytes" + } + ] + }, + { + "name": "deposit_now", + "docs": [ + "Equivalent to deposit except quote_timestamp is set to the current time.", + "The deposit `fill_deadline` is calculated as the current time plus `fill_deadline_offset`." + ], + "discriminator": [ + 75, + 228, + 135, + 221, + 200, + 25, + 148, + 26 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "delegate" + }, + { + "name": "depositor_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "arg", + "path": "depositor" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "mint" + }, + { + "name": "token_program" + }, + { + "name": "associated_token_program", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "input_token", + "type": "pubkey" + }, + { + "name": "output_token", + "type": "pubkey" + }, + { + "name": "input_amount", + "type": "u64" + }, + { + "name": "output_amount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "destination_chain_id", + "type": "u64" + }, + { + "name": "exclusive_relayer", + "type": "pubkey" + }, + { + "name": "fill_deadline_offset", + "type": "u32" + }, + { + "name": "exclusivity_parameter", + "type": "u32" + }, + { + "name": "message", + "type": "bytes" + } + ] + }, + { + "name": "emergency_delete_root_bundle", + "docs": [ + "Deletes a root bundle in case of emergencies where bad bundle has reached the Spoke. Only callable by the owner.", + "", + "This function will close the PDA for the associated `root_bundle_id`.", + "Note: Using this function does not decrement `state.root_bundle_id`.", + "", + "### Required Accounts:", + "- signer (Signer): The account that must be the owner to authorize the deletion.", + "- closer (SystemAccount): The account that will receive the lamports from closing the root_bundle account.", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- root_bundle (Writable): The root bundle PDA to be closed. Seed: [\"root_bundle\",state.seed,root_bundle_id].", + "", + "### Parameters:", + "- root_bundle_id: Index of the root bundle that needs to be deleted." + ], + "discriminator": [ + 226, + 158, + 1, + 74, + 84, + 113, + 24, + 152 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "closer", + "writable": true + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "root_bundle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 111, + 111, + 116, + 95, + 98, + 117, + 110, + 100, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + }, + { + "kind": "arg", + "path": "root_bundle_id" + } + ] + } + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "root_bundle_id", + "type": "u32" + } + ] + }, + { + "name": "execute_relayer_refund_leaf", + "docs": [ + "Executes relayer refund leaf.", + "", + "Processes a relayer refund leaf, verifying its inclusion in a previous Merkle root and that it was not", + "previously executed. Function has two modes of operation: a) transfers all relayer refunds directly to", + "relayers ATA or b) credits relayers with claimable claim_account PDA that they can use later to claim their", + "refund. In the happy path, (a) should be used. (b) should only be used if there is a relayer within the bundle", + "who can't receive the transfer for some reason, such as failed token transfers due to blacklisting. Executing", + "relayer refunds requires the caller to create a LUT and load the execution params into it. This is needed to", + "fit the data in a single instruction. The exact structure and validation of the leaf is defined in the Accross", + "UMIP: https://github.com/UMAprotocol/UMIPs/blob/master/UMIPs/umip-179.md", + "", + "instruction_params Parameters:", + "- root_bundle_id: The ID of the root bundle containing the relayer refund root.", + "- relayer_refund_leaf: The relayer refund leaf to be executed. Contents must include:", + "- amount_to_return: The amount to be to be sent back to mainnet Ethereum from this Spoke pool.", + "- chain_id: The targeted chainId for the refund. Validated against state.chain_id.", + "- refund_amounts: The amounts to be returned to the relayer for each refund_address.", + "- leaf_id: The leaf ID of the relayer refund leaf.", + "- mint_public_key: The public key of the mint (refunded token) being refunded.", + "- refund_addresses: The addresses to be refunded.", + "- proof: The Merkle proof for the relayer refund leaf.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the execution. No permission requirements.", + "- instruction_params (Account): LUT containing the execution parameters. seed: [\"instruction_params\",signer]", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- root_bundle (Writable): The root bundle PDA containing the relayer refund root, created when the root bundle", + "was initially bridged. seed: [\"root_bundle\",state.seed,root_bundle_id].", + "- vault (Writable): The ATA for refunded mint. Authority must be the state.", + "- mint (Account): The mint account for the token being refunded.", + "- transfer_liability (Writable): Account to track pending refunds to be sent to the Ethereum hub pool. Only used", + "if the amount_to_return value is non-zero within the leaf. Seed: [\"transfer_liability\",mint]", + "- token_program: The token program.", + "- system_program: The system program required for account creation.", + "", + "execute_relayer_refund_leaf executes in mode where refunds are sent to ATA directly." + ], + "discriminator": [ + 27, + 136, + 159, + 240, + 127, + 68, + 123, + 164 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "instruction_params", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "root_bundle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 111, + 111, + 116, + 95, + 98, + 117, + 110, + 100, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + }, + { + "kind": "account", + "path": "instruction_params.root_bundle_id", + "account": "ExecuteRelayerRefundLeafParams" + } + ] + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "mint" + }, + { + "name": "transfer_liability", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 114, + 97, + 110, + 115, + 102, + 101, + 114, + 95, + 108, + 105, + 97, + 98, + 105, + 108, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "mint" + } + ] + } + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "execute_relayer_refund_leaf_deferred", + "docs": [ + "Similar to execute_relayer_refund_leaf, but executes in mode where refunds are allocated to claim_account PDAs." + ], + "discriminator": [ + 110, + 112, + 89, + 208, + 38, + 116, + 93, + 10 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "instruction_params", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "root_bundle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 111, + 111, + 116, + 95, + 98, + 117, + 110, + 100, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + }, + { + "kind": "account", + "path": "instruction_params.root_bundle_id", + "account": "ExecuteRelayerRefundLeafParams" + } + ] + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "mint" + }, + { + "name": "transfer_liability", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 114, + 97, + 110, + 115, + 102, + 101, + 114, + 95, + 108, + 105, + 97, + 98, + 105, + 108, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "mint" + } + ] + } + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "execute_slow_relay_leaf", + "docs": [ + "Executes a slow relay leaf stored as part of a root bundle relayed by the HubPool.", + "", + "Executing a slow fill leaf is equivalent to filling the relayData, so this function cannot be used to", + "double fill a recipient. The relayData that is filled is included in the slowFillLeaf and is hashed", + "like any other fill sent through fillRelay(). There is no relayer credited with filling this relay since funds", + "are sent directly out of this program's vault.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the execution. No permission requirements.", + "- instruction_params (Account): Optional account to load instruction parameters when they are not passed in the", + "instruction data due to message size constraints. Pass this program ID to represent None. When Some, this must", + "be derived from the signer's public key with seed [\"instruction_params\",signer].", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- root_bundle (Account): Root bundle PDA with slowRelayRoot. Seed: [\"root_bundle\",state.seed,root_bundle_id].", + "- fill_status (Writable): The fill status PDA, created when slow request was made. Updated to track slow fill.", + "Used to prevent double request and fill. Seed: [\"fills\",relay_hash].", + "- mint (Account): The mint account for the output token.", + "- recipient_token_account (Writable): The recipient's ATA for the output token.", + "- vault (Writable): The ATA for refunded mint. Authority must be the state.", + "- token_program (Interface): The token program.", + "- system_program (Program): The system program.", + "", + "### Parameters:", + "- _relay_hash: The hash identifying the deposit to be filled. Used to identify the deposit to be filled.", + "- slow_fill_leaf: Contains all data necessary to uniquely verify the slow fill. This struct contains:", + "- relayData: Struct containing all the data needed to identify the original deposit to be slow filled. Same", + "as the relay_data struct in fill_relay().", + "- chainId: Chain identifier where slow fill leaf should be executed. If this doesn't match this chain's", + "chainId, then this function will revert.", + "- updatedOutputAmount: Amount to be sent to recipient out of this contract's balance. Can be set differently", + "from relayData.outputAmount to charge a different fee because this deposit was \"slow\" filled. Usually,", + "this will be set higher to reimburse the recipient for waiting for the slow fill.", + "- _root_bundle_id: Unique ID of root bundle containing slow relay root that this leaf is contained in.", + "- proof: Inclusion proof for this leaf in slow relay root in root bundle.", + "Note: slow_fill_leaf, _root_bundle_id, and proof are optional parameters. If None for any of these is passed,", + "the caller must load them via the instruction_params account.", + "Note: When verifying the slow fill leaf, the relay data is hashed using AnchorSerialize::serialize that encodes", + "output token amounts to little-endian format while input token amount preserves its big-endian encoding as it", + "is passed as [u8; 32] array." + ], + "discriminator": [ + 26, + 207, + 3, + 168, + 193, + 252, + 59, + 127 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "instruction_params", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "root_bundle", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 111, + 111, + 116, + 95, + 98, + 117, + 110, + 100, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + }, + { + "kind": "arg", + "path": "_root_bundle_id.unwrap_or_else(| |\ninstruction_params" + } + ] + } + }, + { + "name": "fill_status", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 105, + 108, + 108, + 115 + ] + }, + { + "kind": "arg", + "path": "_relay_hash" + } + ] + } + }, + { + "name": "mint" + }, + { + "name": "recipient_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "arg", + "path": "slow_fill_leaf" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "token_program" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "_relay_hash", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "slow_fill_leaf", + "type": { + "option": { + "defined": { + "name": "SlowFill" + } + } + } + }, + { + "name": "_root_bundle_id", + "type": { + "option": "u32" + } + }, + { + "name": "proof", + "type": { + "option": { + "vec": { + "array": [ + "u8", + 32 + ] + } + } + } + } + ] + }, + { + "name": "fill_relay", + "docs": [ + "Fulfill request to bridge cross chain by sending specified output tokens to recipient.", + "", + "Relayer & system fee is captured in the spread between input and output amounts. This fee accounts for tx costs,", + "relayer's capital opportunity cost, and a system fee. The relay_data hash uniquely identifies the deposit to", + "fill, ensuring relayers are refunded only for deposits matching the original hash from the origin SpokePool.", + "This hash includes all parameters from deposit() and must match the destination_chain_id. Note the relayer", + "creates an ATA in calling this method to store the fill_status. This should be closed once the deposit has", + "expired to let the relayer re-claim their rent. Cannot fill more than once. Partial fills are not supported.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the fill (filler). No permission requirements.", + "- instruction_params (Account): Optional account to load instruction parameters when they are not passed in the", + "instruction data due to message size constraints. Pass this program ID to represent None. When Some, this must", + "be derived from the signer's public key with seed [\"instruction_params\",signer].", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- mint (Account): The mint of the output token, sent from the relayer to the recipient.", + "- relayer_token_account (Writable): The relayer's ATA for the input token.", + "- recipient_token_account (Writable): The recipient's ATA for the output token.", + "- fill_status (Writable): The fill status PDA, created on this function call to track the fill status to prevent", + "re-entrancy & double fills. Also used to track requested slow fills. Seed: [\"fills\",relay_hash].", + "- token_program (Interface): The token program.", + "- associated_token_program (Interface): The associated token program.", + "- system_program (Interface): The system program.", + "- delegate (Account): The account used to delegate the output amount of the output token.", + "", + "### Parameters:", + "- relay_hash: The hash identifying the deposit to be filled. Caller must pass this in. Computed as hash of", + "the flattened relay_data & destination_chain_id.", + "- relay_data: Struct containing all the data needed to identify the deposit to be filled. Should match", + "all the same-named parameters emitted in the origin chain FundsDeposited event.", + "- depositor: The account credited with the deposit.", + "- recipient: The account receiving funds on this chain.", + "- input_token: The token pulled from the caller's account to initiate the deposit. The equivalent of this", + "token on the repayment chain will be sent as a refund to the caller.", + "- output_token: The token that the caller will send to the recipient on this chain.", + "- input_amount: This amount, less a system fee, will be sent to the caller on their repayment chain.", + "This is big-endian encoded as a 32-byte array to match its underlying byte representation on EVM side", + "- output_amount: The amount of output tokens that the caller will send to the recipient.", + "- origin_chain_id: The origin chain identifier.", + "- exclusive_relayer: The relayer that will be exclusively allowed to fill this deposit before the", + "exclusivity deadline timestamp.", + "- fill_deadline: The deadline for the caller to fill the deposit. After this timestamp, the deposit will be", + "cancelled and the depositor will be refunded on the origin chain.", + "- exclusivity_deadline: The deadline for the exclusive relayer to fill the deposit. After this timestamp,", + "anyone can fill this deposit.", + "- message: The message to send to the recipient if the recipient is a contract that implements a", + "handle_across_message() public function.", + "- repayment_chain_id: Chain of SpokePool where relayer wants to be refunded after the challenge window has", + "passed. Will receive input_amount of the equivalent token to input_token on the repayment chain.", + "- repayment_address: The address of the recipient on the repayment chain that they want to be refunded to.", + "Note: relay_data, repayment_chain_id, and repayment_address are optional parameters. If None for any of these", + "is passed, the caller must load them via the instruction_params account." + ], + "discriminator": [ + 100, + 84, + 222, + 90, + 106, + 209, + 58, + 222 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "instruction_params", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "delegate" + }, + { + "name": "mint" + }, + { + "name": "relayer_token_account", + "writable": true + }, + { + "name": "recipient_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "arg", + "path": "relay_data" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "fill_status", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 105, + 108, + 108, + 115 + ] + }, + { + "kind": "arg", + "path": "relay_hash" + } + ] + } + }, + { + "name": "token_program" + }, + { + "name": "associated_token_program", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "relay_hash", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "relay_data", + "type": { + "option": { + "defined": { + "name": "RelayData" + } + } + } + }, + { + "name": "repayment_chain_id", + "type": { + "option": "u64" + } + }, + { + "name": "repayment_address", + "type": { + "option": "pubkey" + } + } + ] + }, + { + "name": "get_unsafe_deposit_id", + "docs": [ + "Computes the deposit ID for the depositor using the provided deposit_nonce. This acts like a \"view\" function for", + "off-chain actors to compute what the expected deposit ID is for a given depositor and deposit nonce will be.", + "", + "### Parameters:", + "- signer: The public key of the depositor sender.", + "- depositor: The public key of the depositor.", + "- deposit_nonce: The nonce used to derive the deposit ID." + ], + "discriminator": [ + 118, + 10, + 135, + 0, + 168, + 243, + 223, + 117 + ], + "accounts": [], + "args": [ + { + "name": "signer", + "type": "pubkey" + }, + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "deposit_nonce", + "type": "u64" + } + ], + "returns": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "handle_receive_message", + "docs": [ + "Handles cross-chain messages received from L1 Ethereum over CCTP.", + "", + "This function serves as the permissioned entry point for messages sent from the Ethereum mainnet to the Solana", + "SVM Spoke program over CCTP. It processes the incoming message by translating it into a corresponding Solana", + "instruction and then invokes the instruction within this program.", + "", + "### Required Accounts:", + "- authority_pda: A signer account that ensures this instruction can only be called by the Message Transmitter.", + "This acts to block that only the CCTP Message Transmitter can send messages to this program.", + "seed:[\"message_transmitter_authority\", program_id]", + "- state (Account): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet. Enforces that the", + "remote domain and sender are valid.", + "- self_authority: An unchecked account used for authenticating self-CPI invoked by the received message.", + "seed: [\"self_authority\"].", + "- program: The SVM Spoke program account.", + "", + "### Parameters:", + "- params: Contains information to process the received message, containing the following fields:", + "- remote_domain: The remote domain of the message sender.", + "- sender: The sender of the message.", + "- message_body: The body of the message.", + "- authority_bump: The authority bump for the message transmitter." + ], + "discriminator": [ + 133, + 102, + 1, + 180, + 145, + 11, + 138, + 180 + ], + "accounts": [ + { + "name": "authority_pda", + "signer": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 115, + 115, + 97, + 103, + 101, + 95, + 116, + 114, + 97, + 110, + 115, + 109, + 105, + 116, + 116, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "const", + "value": [ + 183, + 102, + 64, + 134, + 222, + 55, + 238, + 112, + 130, + 28, + 16, + 68, + 91, + 22, + 47, + 44, + 126, + 200, + 121, + 91, + 208, + 128, + 12, + 20, + 98, + 148, + 158, + 35, + 40, + 209, + 221, + 90 + ] + } + ], + "program": { + "kind": "const", + "value": [ + 166, + 95, + 201, + 137, + 219, + 95, + 93, + 66, + 117, + 159, + 58, + 84, + 96, + 88, + 239, + 205, + 205, + 192, + 191, + 60, + 24, + 152, + 7, + 45, + 142, + 180, + 93, + 209, + 216, + 5, + 8, + 206 + ] + } + } + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "self_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 108, + 102, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program", + "address": "DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "HandleReceiveMessageParams" + } + } + } + ] + }, + { + "name": "initialize", + "docs": [ + "Initializes the state for the SVM Spoke Pool. Only callable once.", + "", + "### Required Accounts:", + "- signer (Writable, Signer): The account that pays for the transaction and will own the state.", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- system_program: The system program required for account creation.", + "", + "### Parameters:", + "- seed: A unique seed used to derive the state account's address. Must be 0 on Mainnet.", + "- initial_number_of_deposits: The initial number of deposits. Used to offset in upgrades.", + "- chain_id: The chain ID for Solana, used to identify the Solana spoke in the rest of the Across protocol.", + "- remote_domain: The CCTP domain for Mainnet Ethereum.", + "- cross_domain_admin: The HubPool on Mainnet Ethereum.", + "- deposit_quote_time_buffer: Quote timestamps can't be set more than this amount into the past from deposit.", + "- fill_deadline_buffer: Fill deadlines can't be set more than this amount into the future from deposit." + ], + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "arg", + "path": "seed" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "seed", + "type": "u64" + }, + { + "name": "initial_number_of_deposits", + "type": "u32" + }, + { + "name": "chain_id", + "type": "u64" + }, + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "cross_domain_admin", + "type": "pubkey" + }, + { + "name": "deposit_quote_time_buffer", + "type": "u32" + }, + { + "name": "fill_deadline_buffer", + "type": "u32" + } + ] + }, + { + "name": "initialize_claim_account", + "docs": [ + "Initializes a claim account for a relayer refund.", + "", + "This function sets up a claim account for a relayer to claim their refund at a later time and should only be", + "used in the un-happy path where a bundle cant not be executed due to a recipient in the bundle having a blocked", + "or uninitialized claim ATA. The refund address becomes the \"owner\" of the claim_account.", + "", + "### Required Accounts:", + "- signer (Signer): The account that pays for the transaction and initializes the claim account.", + "- mint: The mint associated with the claim account.", + "- refund_address: The refund address associated with the claim account.", + "- claim_account (Writable): The newly created claim account PDA to store claim data for this associated mint.", + "Seed: [\"claim_account\",mint,refund_address].", + "- system_program: The system program required for account creation." + ], + "discriminator": [ + 22, + 247, + 214, + 191, + 90, + 74, + 87, + 216 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "mint" + }, + { + "name": "refund_address" + }, + { + "name": "claim_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 108, + 97, + 105, + 109, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "account", + "path": "mint" + }, + { + "kind": "account", + "path": "refund_address" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "initialize_instruction_params", + "docs": [ + "Initializes the instruction parameters account. Used by data worker when relaying bundles", + "", + "This function sets up an account to store raw data fragments for instructions (LUT).", + "", + "### Required Accounts:", + "- signer (Signer): The account that pays for the transaction and initializes the instruction parameters.", + "- instruction_params (UncheckedAccount): The account where raw data will be stored. Initialized with specified", + "size. seed: [\"instruction_params\",signer].", + "- system_program: The system program required for account creation.", + "", + "### Parameters:", + "- _total_size: The total size of the instruction parameters account." + ], + "discriminator": [ + 94, + 206, + 190, + 192, + 127, + 8, + 186, + 28 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "instruction_params", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "_total_size", + "type": "u32" + } + ] + }, + { + "name": "pause_deposits", + "docs": [ + "Pauses the Spoke Pool from accepting deposits. Only callable by the owner.", + "", + "### Required Accounts:", + "- signer (Signer): The account that must be the owner to authorize the pause.", + "- state (Writable): The Spoke state PDA. Seed: [\"state\",state.seed], where `seed` is 0 on mainnet.", + "", + "### Parameters:", + "- pause: `true` to pause the system, `false` to unpause it." + ], + "discriminator": [ + 206, + 186, + 203, + 153, + 253, + 61, + 206, + 122 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "pause", + "type": "bool" + } + ] + }, + { + "name": "pause_fills", + "docs": [ + "Pauses the Spoke Pool from processing fills. Only callable by the owner.", + "", + "### Required Accounts:", + "- signer (Signer): The account that must be the owner to authorize the pause.", + "- state (Writable): The Spoke state PDA. Seed: [\"state\",state.seed], where `seed` is 0 on mainnet.", + "", + "### Parameters:", + "- pause: `true` to pause the system, `false` to unpause it." + ], + "discriminator": [ + 92, + 114, + 214, + 49, + 13, + 243, + 73, + 35 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "pause", + "type": "bool" + } + ] + }, + { + "name": "relay_root_bundle", + "docs": [ + "Stores a new root bundle for later execution. Only callable by the owner.", + "", + "Once stored, these roots are used to execute relayer refunds, slow fills, and pool rebalancing actions.", + "This method initializes a root_bundle PDA to store the root bundle data. The caller", + "of this method is responsible for paying the rent for this PDA.", + "", + "### Required Accounts:", + "- signer (Signer): The account that must be the owner to authorize the addition of the new root bundle.", + "- payer (Signer): The account who pays rent to create root_bundle PDA.", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- root_bundle (Writable): The newly created bundle PDA to store root bundle data. Each root bundle has an", + "incrementing ID, stored in the state. Seed: [\"root_bundle\",state.seed,root_bundle_id].", + "- system_program (Program): The system program required for account creation.", + "", + "### Parameters:", + "- relayer_refund_root: Merkle root of the relayer refund tree.", + "- slow_relay_root: Merkle root of the slow relay tree." + ], + "discriminator": [ + 69, + 13, + 223, + 204, + 251, + 61, + 105, + 6 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "root_bundle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 111, + 111, + 116, + 95, + 98, + 117, + 110, + 100, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + }, + { + "kind": "account", + "path": "state.root_bundle_id", + "account": "State" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "relayer_refund_root", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "slow_relay_root", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "request_slow_fill", + "docs": [ + "Requests Across to send LP funds to this program to fulfill a slow fill.", + "", + "Slow fills are not possible unless the input and output tokens are \"equivalent\", i.e., they route to the same L1", + "token via PoolRebalanceRoutes. Slow fills are created by inserting slow fill objects into a Merkle tree that is", + "included in the next HubPool \"root bundle\". Once the optimistic challenge window has passed, the HubPool will", + "relay the slow root to this chain via relayRootBundle(). Once the slow root is relayed, the slow fill can be", + "executed by anyone who calls executeSlowRelayLeaf(). Cant request a slow fill if the fill deadline has", + "passed. Cant request a slow fill if the relay has already been filled or a slow fill has already been requested.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the slow fill request.", + "- instruction_params (Account): Optional account to load instruction parameters when they are not passed in the", + "instruction data due to message size constraints. Pass this program ID to represent None. When Some, this must", + "be derived from the signer's public key with seed [\"instruction_params\",signer].", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- fill_status (Writable): The fill status PDA, created on this function call. Updated to track slow fill status.", + "Used to prevent double request and fill. Seed: [\"fills\",relay_hash].", + "- system_program (Interface): The system program.", + "", + "### Parameters:", + "- _relay_hash: The hash identifying the deposit to be filled. Caller must pass this in. Computed as hash of", + "the flattened relay_data & destination_chain_id.", + "- relay_data: Struct containing all the data needed to identify the deposit that should be slow filled. If any", + "of the params are missing or different from the origin chain deposit, then Across will not include a slow", + "fill for the intended deposit. See fill_relay & RelayData struct for more details.", + "Note: relay_data is optional parameter. If None for it is passed, the caller must load it via the", + "instruction_params account." + ], + "discriminator": [ + 39, + 157, + 165, + 187, + 88, + 217, + 207, + 98 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "instruction_params", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "fill_status", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 105, + 108, + 108, + 115 + ] + }, + { + "kind": "arg", + "path": "_relay_hash" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "_relay_hash", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "relay_data", + "type": { + "option": { + "defined": { + "name": "RelayData" + } + } + } + } + ] + }, + { + "name": "set_cross_domain_admin", + "docs": [ + "Sets the cross-domain admin for the Spoke Pool. Only callable by owner. Used if Hubpool upgrades.", + "", + "### Required Accounts:", + "- signer (Signer): The account that must be the owner to authorize the admin change.", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "", + "### Parameters:", + "- cross_domain_admin: The public key of the new cross-domain admin." + ], + "discriminator": [ + 102, + 206, + 237, + 106, + 63, + 141, + 42, + 248 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "cross_domain_admin", + "type": "pubkey" + } + ] + }, + { + "name": "set_current_time", + "docs": [ + "Sets the current time for the SVM Spoke Pool when running in test mode. Disabled on Mainnet." + ], + "discriminator": [ + 69, + 100, + 169, + 193, + 125, + 0, + 150, + 69 + ], + "accounts": [ + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "signer", + "signer": true + } + ], + "args": [ + { + "name": "new_time", + "type": "u32" + } + ] + }, + { + "name": "transfer_ownership", + "docs": [ + "Transfers ownership of the Spoke Pool. Only callable by the current owner.", + "", + "### Required Accounts:", + "- signer (Signer): The account that must be the current owner to authorize the transfer.", + "- state (Writable): The Spoke state PDA. Seed: [\"state\",state.seed] where `seed` is 0 on mainnet.", + "", + "### Parameters:", + "- new_owner: The public key of the new owner." + ], + "discriminator": [ + 65, + 177, + 215, + 73, + 53, + 45, + 99, + 47 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "new_owner", + "type": "pubkey" + } + ] + }, + { + "name": "unsafe_deposit", + "docs": [ + "Equivalent to deposit, except that it doesn't use the global `number_of_deposits` counter as the deposit", + "nonce. Instead, it allows the caller to pass a `deposit_nonce`. This function is designed for anyone who", + "wants to pre-compute their resultant deposit ID, which can be useful for filling a deposit faster and", + "avoiding the risk of a deposit ID unexpectedly changing due to another deposit front-running this one and", + "incrementing the global deposit ID counter. This enables the caller to influence the deposit ID, making it", + "deterministic for the depositor. The computed `depositID` is the keccak256 hash of [signer, depositor, deposit_nonce]." + ], + "discriminator": [ + 196, + 187, + 166, + 179, + 3, + 146, + 150, + 246 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "State" + } + ] + } + }, + { + "name": "delegate" + }, + { + "name": "depositor_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "arg", + "path": "depositor" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "mint" + }, + { + "name": "token_program" + }, + { + "name": "associated_token_program", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "input_token", + "type": "pubkey" + }, + { + "name": "output_token", + "type": "pubkey" + }, + { + "name": "input_amount", + "type": "u64" + }, + { + "name": "output_amount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "destination_chain_id", + "type": "u64" + }, + { + "name": "exclusive_relayer", + "type": "pubkey" + }, + { + "name": "deposit_nonce", + "type": "u64" + }, + { + "name": "quote_timestamp", + "type": "u32" + }, + { + "name": "fill_deadline", + "type": "u32" + }, + { + "name": "exclusivity_parameter", + "type": "u32" + }, + { + "name": "message", + "type": "bytes" + } + ] + }, + { + "name": "write_instruction_params_fragment", + "docs": [ + "Writes a fragment of raw data into the instruction parameters account.", + "", + "This function allows writing a fragment of data into a specified offset within the instruction parameters", + "account. It ensures that the data does not overflow the account's allocated space.", + "", + "### Required Accounts:", + "- signer (Signer): Account that authorizes the write operation.", + "- instruction_params (UncheckedAccount): Account to write raw data to. seed: [\"instruction_params\",signer].", + "- system_program: The system program required for account operations.", + "", + "### Parameters:", + "- offset: The starting position within the account's data where the fragment will be written.", + "- fragment: The raw data fragment to be written into the account." + ], + "discriminator": [ + 238, + 182, + 109, + 113, + 124, + 255, + 72, + 18 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "instruction_params", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "offset", + "type": "u32" + }, + { + "name": "fragment", + "type": "bytes" + } + ] + } + ], + "accounts": [ + { + "name": "ClaimAccount", + "discriminator": [ + 113, + 109, + 47, + 96, + 242, + 219, + 61, + 165 + ] + }, + { + "name": "ExecuteRelayerRefundLeafParams", + "discriminator": [ + 192, + 59, + 93, + 9, + 171, + 77, + 28, + 250 + ] + }, + { + "name": "ExecuteSlowRelayLeafParams", + "discriminator": [ + 135, + 208, + 119, + 251, + 14, + 222, + 66, + 155 + ] + }, + { + "name": "FillRelayParams", + "discriminator": [ + 50, + 243, + 51, + 185, + 89, + 60, + 43, + 202 + ] + }, + { + "name": "FillStatusAccount", + "discriminator": [ + 105, + 89, + 88, + 35, + 24, + 147, + 178, + 137 + ] + }, + { + "name": "RequestSlowFillParams", + "discriminator": [ + 5, + 54, + 214, + 89, + 197, + 37, + 118, + 28 + ] + }, + { + "name": "RootBundle", + "discriminator": [ + 66, + 221, + 214, + 231, + 25, + 222, + 184, + 219 + ] + }, + { + "name": "State", + "discriminator": [ + 216, + 146, + 107, + 94, + 104, + 75, + 182, + 177 + ] + }, + { + "name": "TransferLiability", + "discriminator": [ + 157, + 137, + 86, + 109, + 206, + 241, + 183, + 79 + ] + } + ], + "events": [ + { + "name": "BridgedToHubPool", + "discriminator": [ + 181, + 111, + 52, + 218, + 105, + 53, + 240, + 205 + ] + }, + { + "name": "ClaimedRelayerRefund", + "discriminator": [ + 161, + 134, + 155, + 159, + 211, + 37, + 150, + 41 + ] + }, + { + "name": "EmergencyDeletedRootBundle", + "discriminator": [ + 45, + 150, + 89, + 248, + 134, + 142, + 200, + 114 + ] + }, + { + "name": "ExecutedRelayerRefundRoot", + "discriminator": [ + 198, + 167, + 248, + 175, + 34, + 3, + 4, + 240 + ] + }, + { + "name": "FilledRelay", + "discriminator": [ + 25, + 58, + 182, + 0, + 50, + 99, + 160, + 117 + ] + }, + { + "name": "FundsDeposited", + "discriminator": [ + 157, + 209, + 100, + 95, + 59, + 100, + 3, + 68 + ] + }, + { + "name": "PausedDeposits", + "discriminator": [ + 94, + 129, + 187, + 122, + 94, + 30, + 91, + 247 + ] + }, + { + "name": "PausedFills", + "discriminator": [ + 81, + 4, + 134, + 23, + 170, + 56, + 234, + 234 + ] + }, + { + "name": "RelayedRootBundle", + "discriminator": [ + 188, + 206, + 117, + 10, + 66, + 78, + 77, + 115 + ] + }, + { + "name": "RequestedSlowFill", + "discriminator": [ + 221, + 123, + 11, + 14, + 71, + 37, + 178, + 167 + ] + }, + { + "name": "SetXDomainAdmin", + "discriminator": [ + 164, + 13, + 119, + 18, + 103, + 226, + 98, + 66 + ] + }, + { + "name": "TokensBridged", + "discriminator": [ + 200, + 201, + 199, + 39, + 5, + 238, + 214, + 196 + ] + }, + { + "name": "TransferredOwnership", + "discriminator": [ + 235, + 235, + 154, + 16, + 153, + 94, + 21, + 117 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "InvalidQuoteTimestamp", + "msg": "Invalid quote timestamp!" + }, + { + "code": 6001, + "name": "InvalidFillDeadline", + "msg": "Invalid fill deadline!" + }, + { + "code": 6002, + "name": "NotExclusiveRelayer", + "msg": "Caller is not the exclusive relayer and exclusivity deadline has not passed!" + }, + { + "code": 6003, + "name": "NoSlowFillsInExclusivityWindow", + "msg": "The Deposit is still within the exclusivity window!" + }, + { + "code": 6004, + "name": "RelayFilled", + "msg": "The relay has already been filled!" + }, + { + "code": 6005, + "name": "InvalidSlowFillRequest", + "msg": "Slow fill requires status of Unfilled!" + }, + { + "code": 6006, + "name": "ExpiredFillDeadline", + "msg": "The fill deadline has passed!" + }, + { + "code": 6007, + "name": "InvalidMerkleProof", + "msg": "Invalid Merkle proof!" + }, + { + "code": 6008, + "name": "InvalidChainId", + "msg": "Invalid chain id!" + }, + { + "code": 6009, + "name": "InvalidMerkleLeaf", + "msg": "Invalid Merkle leaf!" + }, + { + "code": 6010, + "name": "ClaimedMerkleLeaf", + "msg": "Leaf already claimed!" + }, + { + "code": 6011, + "name": "DepositsArePaused", + "msg": "Deposits are currently paused!" + }, + { + "code": 6012, + "name": "FillsArePaused", + "msg": "Fills are currently paused!" + }, + { + "code": 6013, + "name": "InsufficientSpokePoolBalanceToExecuteLeaf", + "msg": "Insufficient spoke pool balance to execute leaf" + }, + { + "code": 6014, + "name": "InvalidExclusiveRelayer", + "msg": "Invalid exclusive relayer!" + }, + { + "code": 6015, + "name": "InvalidOutputToken", + "msg": "Invalid output token!" + } + ], + "types": [ + { + "name": "BridgedToHubPool", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "ClaimAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "initializer", + "type": "pubkey" + } + ] + } + }, + { + "name": "ClaimedRelayerRefund", + "type": { + "kind": "struct", + "fields": [ + { + "name": "l2_token_address", + "type": "pubkey" + }, + { + "name": "claim_amount", + "type": "u64" + }, + { + "name": "refund_address", + "type": "pubkey" + } + ] + } + }, + { + "name": "EmergencyDeletedRootBundle", + "type": { + "kind": "struct", + "fields": [ + { + "name": "root_bundle_id", + "type": "u32" + } + ] + } + }, + { + "name": "ExecuteRelayerRefundLeafParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "root_bundle_id", + "type": "u32" + }, + { + "name": "relayer_refund_leaf", + "type": { + "defined": { + "name": "RelayerRefundLeaf" + } + } + }, + { + "name": "proof", + "type": { + "vec": { + "array": [ + "u8", + 32 + ] + } + } + } + ] + } + }, + { + "name": "ExecuteSlowRelayLeafParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "slow_fill_leaf", + "type": { + "defined": { + "name": "SlowFill" + } + } + }, + { + "name": "root_bundle_id", + "type": "u32" + }, + { + "name": "proof", + "type": { + "vec": { + "array": [ + "u8", + 32 + ] + } + } + } + ] + } + }, + { + "name": "ExecutedRelayerRefundRoot", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_to_return", + "type": "u64" + }, + { + "name": "chain_id", + "type": "u64" + }, + { + "name": "refund_amounts", + "type": { + "vec": "u64" + } + }, + { + "name": "root_bundle_id", + "type": "u32" + }, + { + "name": "leaf_id", + "type": "u32" + }, + { + "name": "l2_token_address", + "type": "pubkey" + }, + { + "name": "refund_addresses", + "type": { + "vec": "pubkey" + } + }, + { + "name": "deferred_refunds", + "type": "bool" + }, + { + "name": "caller", + "type": "pubkey" + } + ] + } + }, + { + "name": "FillRelayParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "relay_data", + "type": { + "defined": { + "name": "RelayData" + } + } + }, + { + "name": "repayment_chain_id", + "type": "u64" + }, + { + "name": "repayment_address", + "type": "pubkey" + } + ] + } + }, + { + "name": "FillStatus", + "type": { + "kind": "enum", + "variants": [ + { + "name": "Unfilled" + }, + { + "name": "RequestedSlowFill" + }, + { + "name": "Filled" + } + ] + } + }, + { + "name": "FillStatusAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "status", + "type": { + "defined": { + "name": "FillStatus" + } + } + }, + { + "name": "relayer", + "type": "pubkey" + }, + { + "name": "fill_deadline", + "type": "u32" + } + ] + } + }, + { + "name": "FillType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "FastFill" + }, + { + "name": "ReplacedSlowFill" + }, + { + "name": "SlowFill" + } + ] + } + }, + { + "name": "FilledRelay", + "type": { + "kind": "struct", + "fields": [ + { + "name": "input_token", + "type": "pubkey" + }, + { + "name": "output_token", + "type": "pubkey" + }, + { + "name": "input_amount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "output_amount", + "type": "u64" + }, + { + "name": "repayment_chain_id", + "type": "u64" + }, + { + "name": "origin_chain_id", + "type": "u64" + }, + { + "name": "deposit_id", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "fill_deadline", + "type": "u32" + }, + { + "name": "exclusivity_deadline", + "type": "u32" + }, + { + "name": "exclusive_relayer", + "type": "pubkey" + }, + { + "name": "relayer", + "type": "pubkey" + }, + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "message_hash", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "relay_execution_info", + "type": { + "defined": { + "name": "RelayExecutionEventInfo" + } + } + } + ] + } + }, + { + "name": "FundsDeposited", + "type": { + "kind": "struct", + "fields": [ + { + "name": "input_token", + "type": "pubkey" + }, + { + "name": "output_token", + "type": "pubkey" + }, + { + "name": "input_amount", + "type": "u64" + }, + { + "name": "output_amount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "destination_chain_id", + "type": "u64" + }, + { + "name": "deposit_id", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "quote_timestamp", + "type": "u32" + }, + { + "name": "fill_deadline", + "type": "u32" + }, + { + "name": "exclusivity_deadline", + "type": "u32" + }, + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "exclusive_relayer", + "type": "pubkey" + }, + { + "name": "message", + "type": "bytes" + } + ] + } + }, + { + "name": "HandleReceiveMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "sender", + "type": "pubkey" + }, + { + "name": "message_body", + "type": "bytes" + }, + { + "name": "authority_bump", + "type": "u8" + } + ] + } + }, + { + "name": "PausedDeposits", + "type": { + "kind": "struct", + "fields": [ + { + "name": "is_paused", + "type": "bool" + } + ] + } + }, + { + "name": "PausedFills", + "type": { + "kind": "struct", + "fields": [ + { + "name": "is_paused", + "type": "bool" + } + ] + } + }, + { + "name": "RelayData", + "type": { + "kind": "struct", + "fields": [ + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "exclusive_relayer", + "type": "pubkey" + }, + { + "name": "input_token", + "type": "pubkey" + }, + { + "name": "output_token", + "type": "pubkey" + }, + { + "name": "input_amount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "output_amount", + "type": "u64" + }, + { + "name": "origin_chain_id", + "type": "u64" + }, + { + "name": "deposit_id", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "fill_deadline", + "type": "u32" + }, + { + "name": "exclusivity_deadline", + "type": "u32" + }, + { + "name": "message", + "type": "bytes" + } + ] + } + }, + { + "name": "RelayExecutionEventInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "updated_recipient", + "type": "pubkey" + }, + { + "name": "updated_message_hash", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "updated_output_amount", + "type": "u64" + }, + { + "name": "fill_type", + "type": { + "defined": { + "name": "FillType" + } + } + } + ] + } + }, + { + "name": "RelayedRootBundle", + "type": { + "kind": "struct", + "fields": [ + { + "name": "root_bundle_id", + "type": "u32" + }, + { + "name": "relayer_refund_root", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "slow_relay_root", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "RelayerRefundLeaf", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_to_return", + "type": "u64" + }, + { + "name": "chain_id", + "type": "u64" + }, + { + "name": "refund_amounts", + "type": { + "vec": "u64" + } + }, + { + "name": "leaf_id", + "type": "u32" + }, + { + "name": "mint_public_key", + "type": "pubkey" + }, + { + "name": "refund_addresses", + "type": { + "vec": "pubkey" + } + } + ] + } + }, + { + "name": "RequestSlowFillParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "relay_data", + "type": { + "defined": { + "name": "RelayData" + } + } + } + ] + } + }, + { + "name": "RequestedSlowFill", + "type": { + "kind": "struct", + "fields": [ + { + "name": "input_token", + "type": "pubkey" + }, + { + "name": "output_token", + "type": "pubkey" + }, + { + "name": "input_amount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "output_amount", + "type": "u64" + }, + { + "name": "origin_chain_id", + "type": "u64" + }, + { + "name": "deposit_id", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "fill_deadline", + "type": "u32" + }, + { + "name": "exclusivity_deadline", + "type": "u32" + }, + { + "name": "exclusive_relayer", + "type": "pubkey" + }, + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "message_hash", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "RootBundle", + "type": { + "kind": "struct", + "fields": [ + { + "name": "relayer_refund_root", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "slow_relay_root", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "claimed_bitmap", + "type": "bytes" + } + ] + } + }, + { + "name": "SetXDomainAdmin", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_admin", + "type": "pubkey" + } + ] + } + }, + { + "name": "SlowFill", + "type": { + "kind": "struct", + "fields": [ + { + "name": "relay_data", + "type": { + "defined": { + "name": "RelayData" + } + } + }, + { + "name": "chain_id", + "type": "u64" + }, + { + "name": "updated_output_amount", + "type": "u64" + } + ] + } + }, + { + "name": "State", + "type": { + "kind": "struct", + "fields": [ + { + "name": "paused_deposits", + "type": "bool" + }, + { + "name": "paused_fills", + "type": "bool" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "seed", + "type": "u64" + }, + { + "name": "number_of_deposits", + "type": "u32" + }, + { + "name": "chain_id", + "type": "u64" + }, + { + "name": "current_time", + "type": "u32" + }, + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "cross_domain_admin", + "type": "pubkey" + }, + { + "name": "root_bundle_id", + "type": "u32" + }, + { + "name": "deposit_quote_time_buffer", + "type": "u32" + }, + { + "name": "fill_deadline_buffer", + "type": "u32" + } + ] + } + }, + { + "name": "TokensBridged", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount_to_return", + "type": "u64" + }, + { + "name": "chain_id", + "type": "u64" + }, + { + "name": "leaf_id", + "type": "u32" + }, + { + "name": "l2_token_address", + "type": "pubkey" + }, + { + "name": "caller", + "type": "pubkey" + } + ] + } + }, + { + "name": "TransferLiability", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pending_to_hub_pool", + "type": "u64" + } + ] + } + }, + { + "name": "TransferredOwnership", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_owner", + "type": "pubkey" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/src/svm/assets/idl/test.json b/src/svm/assets/idl/test.json new file mode 100644 index 000000000..4d23674d9 --- /dev/null +++ b/src/svm/assets/idl/test.json @@ -0,0 +1,243 @@ +{ + "address": "8tsEfDSiE4WUMf97oyyyasLAvWwjeRZb2GByh4w7HckA", + "metadata": { + "name": "test", + "version": "0.1.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "bitmap_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + } + ] + } + }, + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "test_emit_large_log", + "discriminator": [ + 126, + 64, + 160, + 189, + 160, + 160, + 238, + 68 + ], + "accounts": [], + "args": [ + { + "name": "length", + "type": "u32" + } + ] + }, + { + "name": "test_is_claimed", + "discriminator": [ + 82, + 227, + 141, + 60, + 27, + 165, + 109, + 90 + ], + "accounts": [ + { + "name": "bitmap_account" + } + ], + "args": [ + { + "name": "index", + "type": "u32" + } + ], + "returns": "bool" + }, + { + "name": "test_set_claimed", + "discriminator": [ + 15, + 155, + 67, + 241, + 20, + 247, + 21, + 189 + ], + "accounts": [ + { + "name": "bitmap_account", + "writable": true + }, + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "index", + "type": "u32" + } + ] + }, + { + "name": "verify", + "discriminator": [ + 133, + 161, + 141, + 48, + 120, + 198, + 88, + 150 + ], + "accounts": [], + "args": [ + { + "name": "root", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "leaf", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "proof", + "type": { + "vec": { + "array": [ + "u8", + 32 + ] + } + } + } + ] + } + ], + "accounts": [ + { + "name": "BitmapAccount", + "discriminator": [ + 152, + 161, + 147, + 85, + 213, + 38, + 59, + 48 + ] + } + ], + "events": [ + { + "name": "TestEvent", + "discriminator": [ + 28, + 52, + 39, + 105, + 8, + 210, + 91, + 9 + ] + } + ], + "types": [ + { + "name": "BitmapAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "claimed_bitmap", + "type": "bytes" + } + ] + } + }, + { + "name": "TestEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "message", + "type": "string" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/src/svm/assets/idl/token_messenger_minter.json b/src/svm/assets/idl/token_messenger_minter.json new file mode 100644 index 000000000..ba9a2ad93 --- /dev/null +++ b/src/svm/assets/idl/token_messenger_minter.json @@ -0,0 +1,2049 @@ +{ + "address": "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3", + "metadata": { + "name": "token_messenger_minter", + "version": "0.1.0", + "spec": "0.1.0" + }, + "instructions": [ + { + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "upgrade_authority", + "signer": true + }, + { + "name": "authority_pda" + }, + { + "name": "token_messenger", + "writable": true + }, + { + "name": "token_minter", + "writable": true + }, + { + "name": "token_messenger_minter_program_data" + }, + { + "name": "token_messenger_minter_program" + }, + { + "name": "system_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "InitializeParams" + } + } + } + ] + }, + { + "name": "transfer_ownership", + "discriminator": [ + 65, + 177, + 215, + 73, + 53, + 45, + 99, + 47 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "token_messenger", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "TransferOwnershipParams" + } + } + } + ] + }, + { + "name": "accept_ownership", + "discriminator": [ + 172, + 23, + 43, + 13, + 238, + 213, + 85, + 150 + ], + "accounts": [ + { + "name": "pending_owner", + "signer": true + }, + { + "name": "token_messenger", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "AcceptOwnershipParams" + } + } + } + ] + }, + { + "name": "add_remote_token_messenger", + "discriminator": [ + 12, + 149, + 172, + 165, + 111, + 202, + 24, + 33 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "owner", + "signer": true + }, + { + "name": "token_messenger" + }, + { + "name": "remote_token_messenger", + "writable": true + }, + { + "name": "system_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "AddRemoteTokenMessengerParams" + } + } + } + ] + }, + { + "name": "remove_remote_token_messenger", + "discriminator": [ + 65, + 114, + 66, + 85, + 169, + 98, + 177, + 146 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "owner", + "signer": true + }, + { + "name": "token_messenger" + }, + { + "name": "remote_token_messenger", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "RemoveRemoteTokenMessengerParams" + } + } + } + ] + }, + { + "name": "deposit_for_burn", + "discriminator": [ + 215, + 60, + 61, + 46, + 114, + 55, + 128, + 176 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "event_rent_payer", + "writable": true, + "signer": true + }, + { + "name": "sender_authority_pda" + }, + { + "name": "burn_token_account", + "writable": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "token_messenger" + }, + { + "name": "remote_token_messenger" + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true + }, + { + "name": "burn_token_mint", + "writable": true + }, + { + "name": "message_sent_event_data", + "writable": true, + "signer": true + }, + { + "name": "message_transmitter_program" + }, + { + "name": "token_messenger_minter_program" + }, + { + "name": "token_program" + }, + { + "name": "system_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "DepositForBurnParams" + } + } + } + ], + "returns": "u64" + }, + { + "name": "deposit_for_burn_with_caller", + "discriminator": [ + 167, + 222, + 19, + 114, + 85, + 21, + 14, + 118 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "event_rent_payer", + "writable": true, + "signer": true + }, + { + "name": "sender_authority_pda" + }, + { + "name": "burn_token_account", + "writable": true + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "token_messenger" + }, + { + "name": "remote_token_messenger" + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true + }, + { + "name": "burn_token_mint", + "writable": true + }, + { + "name": "message_sent_event_data", + "writable": true, + "signer": true + }, + { + "name": "message_transmitter_program" + }, + { + "name": "token_messenger_minter_program" + }, + { + "name": "token_program" + }, + { + "name": "system_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "DepositForBurnWithCallerParams" + } + } + } + ], + "returns": "u64" + }, + { + "name": "replace_deposit_for_burn", + "discriminator": [ + 7, + 27, + 93, + 132, + 1, + 80, + 19, + 163 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "event_rent_payer", + "writable": true, + "signer": true + }, + { + "name": "sender_authority_pda" + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "token_messenger" + }, + { + "name": "message_sent_event_data", + "writable": true, + "signer": true + }, + { + "name": "message_transmitter_program" + }, + { + "name": "token_messenger_minter_program" + }, + { + "name": "system_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "ReplaceDepositForBurnParams" + } + } + } + ], + "returns": "u64" + }, + { + "name": "handle_receive_message", + "discriminator": [ + 133, + 102, + 1, + 180, + 145, + 11, + 138, + 180 + ], + "accounts": [ + { + "name": "authority_pda", + "signer": true + }, + { + "name": "token_messenger" + }, + { + "name": "remote_token_messenger" + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true + }, + { + "name": "token_pair" + }, + { + "name": "recipient_token_account", + "writable": true + }, + { + "name": "custody_token_account", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "HandleReceiveMessageParams" + } + } + } + ] + }, + { + "name": "set_token_controller", + "discriminator": [ + 88, + 6, + 98, + 10, + 79, + 59, + 15, + 24 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "token_messenger" + }, + { + "name": "token_minter", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetTokenControllerParams" + } + } + } + ] + }, + { + "name": "pause", + "discriminator": [ + 211, + 22, + 221, + 251, + 74, + 121, + 193, + 47 + ], + "accounts": [ + { + "name": "pauser", + "signer": true + }, + { + "name": "token_minter", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "PauseParams" + } + } + } + ] + }, + { + "name": "unpause", + "discriminator": [ + 169, + 144, + 4, + 38, + 10, + 141, + 188, + 255 + ], + "accounts": [ + { + "name": "pauser", + "signer": true + }, + { + "name": "token_minter", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UnpauseParams" + } + } + } + ] + }, + { + "name": "update_pauser", + "discriminator": [ + 140, + 171, + 211, + 132, + 57, + 201, + 16, + 254 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "token_messenger" + }, + { + "name": "token_minter", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UpdatePauserParams" + } + } + } + ] + }, + { + "name": "set_max_burn_amount_per_message", + "discriminator": [ + 30, + 128, + 145, + 240, + 70, + 237, + 109, + 207 + ], + "accounts": [ + { + "name": "token_controller", + "signer": true + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetMaxBurnAmountPerMessageParams" + } + } + } + ] + }, + { + "name": "add_local_token", + "discriminator": [ + 213, + 199, + 205, + 18, + 98, + 124, + 73, + 198 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "token_controller", + "signer": true + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true + }, + { + "name": "custody_token_account", + "writable": true + }, + { + "name": "local_token_mint" + }, + { + "name": "token_program" + }, + { + "name": "system_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "AddLocalTokenParams" + } + } + } + ] + }, + { + "name": "remove_local_token", + "discriminator": [ + 27, + 43, + 66, + 170, + 188, + 44, + 109, + 97 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "token_controller", + "signer": true + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true + }, + { + "name": "custody_token_account", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "RemoveLocalTokenParams" + } + } + } + ] + }, + { + "name": "link_token_pair", + "discriminator": [ + 68, + 162, + 24, + 104, + 125, + 46, + 130, + 12 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "token_controller", + "signer": true + }, + { + "name": "token_minter" + }, + { + "name": "token_pair", + "writable": true + }, + { + "name": "system_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "LinkTokenPairParams" + } + } + } + ] + }, + { + "name": "unlink_token_pair", + "discriminator": [ + 52, + 198, + 100, + 114, + 104, + 174, + 85, + 58 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "token_controller", + "signer": true + }, + { + "name": "token_minter" + }, + { + "name": "token_pair", + "writable": true + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UninkTokenPairParams" + } + } + } + ] + }, + { + "name": "burn_token_custody", + "discriminator": [ + 233, + 136, + 180, + 175, + 112, + 41, + 62, + 71 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "token_controller", + "signer": true + }, + { + "name": "token_minter" + }, + { + "name": "local_token" + }, + { + "name": "custody_token_account", + "writable": true + }, + { + "name": "custody_token_mint", + "writable": true + }, + { + "name": "token_program" + }, + { + "name": "event_authority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "BurnTokenCustodyParams" + } + } + } + ] + } + ], + "accounts": [ + { + "name": "TokenMessenger", + "discriminator": [ + 162, + 4, + 242, + 52, + 147, + 243, + 221, + 96 + ] + }, + { + "name": "RemoteTokenMessenger", + "discriminator": [ + 105, + 115, + 174, + 34, + 95, + 233, + 138, + 252 + ] + }, + { + "name": "TokenMinter", + "discriminator": [ + 122, + 133, + 84, + 63, + 57, + 159, + 171, + 206 + ] + }, + { + "name": "TokenPair", + "discriminator": [ + 17, + 214, + 45, + 176, + 229, + 149, + 197, + 71 + ] + }, + { + "name": "LocalToken", + "discriminator": [ + 159, + 131, + 58, + 170, + 193, + 84, + 128, + 182 + ] + } + ], + "events": [ + { + "name": "OwnershipTransferStarted", + "discriminator": [ + 183, + 253, + 239, + 246, + 140, + 179, + 133, + 105 + ] + }, + { + "name": "OwnershipTransferred", + "discriminator": [ + 172, + 61, + 205, + 183, + 250, + 50, + 38, + 98 + ] + }, + { + "name": "DepositForBurn", + "discriminator": [ + 144, + 252, + 145, + 146, + 6, + 74, + 167, + 235 + ] + }, + { + "name": "MintAndWithdraw", + "discriminator": [ + 75, + 67, + 229, + 70, + 162, + 126, + 0, + 71 + ] + }, + { + "name": "RemoteTokenMessengerAdded", + "discriminator": [ + 251, + 29, + 63, + 244, + 48, + 114, + 210, + 175 + ] + }, + { + "name": "RemoteTokenMessengerRemoved", + "discriminator": [ + 255, + 121, + 137, + 39, + 230, + 125, + 11, + 30 + ] + }, + { + "name": "SetTokenController", + "discriminator": [ + 193, + 44, + 243, + 83, + 230, + 72, + 120, + 216 + ] + }, + { + "name": "PauserChanged", + "discriminator": [ + 142, + 157, + 158, + 87, + 127, + 8, + 119, + 55 + ] + }, + { + "name": "SetBurnLimitPerMessage", + "discriminator": [ + 98, + 152, + 88, + 191, + 245, + 30, + 27, + 209 + ] + }, + { + "name": "LocalTokenAdded", + "discriminator": [ + 146, + 8, + 224, + 150, + 122, + 173, + 23, + 39 + ] + }, + { + "name": "LocalTokenRemoved", + "discriminator": [ + 181, + 204, + 1, + 95, + 2, + 50, + 66, + 210 + ] + }, + { + "name": "TokenPairLinked", + "discriminator": [ + 2, + 14, + 177, + 64, + 155, + 93, + 196, + 141 + ] + }, + { + "name": "TokenPairUnlinked", + "discriminator": [ + 78, + 232, + 230, + 208, + 180, + 212, + 246, + 72 + ] + }, + { + "name": "Pause", + "discriminator": [ + 194, + 251, + 232, + 196, + 118, + 95, + 111, + 219 + ] + }, + { + "name": "Unpause", + "discriminator": [ + 241, + 149, + 104, + 90, + 199, + 136, + 219, + 146 + ] + }, + { + "name": "TokenCustodyBurned", + "discriminator": [ + 219, + 143, + 107, + 226, + 67, + 75, + 178, + 46 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "InvalidAuthority", + "msg": "Invalid authority" + }, + { + "code": 6001, + "name": "InvalidTokenMessengerState", + "msg": "Invalid token messenger state" + }, + { + "code": 6002, + "name": "InvalidTokenMessenger", + "msg": "Invalid token messenger" + }, + { + "code": 6003, + "name": "InvalidOwner", + "msg": "Invalid owner" + }, + { + "code": 6004, + "name": "MalformedMessage", + "msg": "Malformed message" + }, + { + "code": 6005, + "name": "InvalidMessageBodyVersion", + "msg": "Invalid message body version" + }, + { + "code": 6006, + "name": "InvalidAmount", + "msg": "Invalid amount" + }, + { + "code": 6007, + "name": "InvalidDestinationDomain", + "msg": "Invalid destination domain" + }, + { + "code": 6008, + "name": "InvalidDestinationCaller", + "msg": "Invalid destination caller" + }, + { + "code": 6009, + "name": "InvalidMintRecipient", + "msg": "Invalid mint recipient" + }, + { + "code": 6010, + "name": "InvalidSender", + "msg": "Invalid sender" + }, + { + "code": 6011, + "name": "InvalidTokenPair", + "msg": "Invalid token pair" + }, + { + "code": 6012, + "name": "InvalidTokenMint", + "msg": "Invalid token mint" + } + ], + "types": [ + { + "name": "AcceptOwnershipParams", + "type": { + "kind": "struct" + } + }, + { + "name": "AddRemoteTokenMessengerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "token_messenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "DepositForBurnWithCallerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "destination_domain", + "type": "u32" + }, + { + "name": "mint_recipient", + "type": "pubkey" + }, + { + "name": "destination_caller", + "type": "pubkey" + } + ] + } + }, + { + "name": "DepositForBurnParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "destination_domain", + "type": "u32" + }, + { + "name": "mint_recipient", + "type": "pubkey" + } + ] + } + }, + { + "name": "HandleReceiveMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "sender", + "type": "pubkey" + }, + { + "name": "message_body", + "type": "bytes" + }, + { + "name": "authority_bump", + "type": "u8" + } + ] + } + }, + { + "name": "InitializeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "token_controller", + "type": "pubkey" + }, + { + "name": "local_message_transmitter", + "type": "pubkey" + }, + { + "name": "message_body_version", + "type": "u32" + } + ] + } + }, + { + "name": "RemoveRemoteTokenMessengerParams", + "type": { + "kind": "struct" + } + }, + { + "name": "ReplaceDepositForBurnParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "original_message", + "type": "bytes" + }, + { + "name": "original_attestation", + "type": "bytes" + }, + { + "name": "new_destination_caller", + "type": "pubkey" + }, + { + "name": "new_mint_recipient", + "type": "pubkey" + } + ] + } + }, + { + "name": "TransferOwnershipParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "AddLocalTokenParams", + "type": { + "kind": "struct" + } + }, + { + "name": "BurnTokenCustodyParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "LinkTokenPairParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "local_token", + "type": "pubkey" + }, + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "remote_token", + "type": "pubkey" + } + ] + } + }, + { + "name": "PauseParams", + "type": { + "kind": "struct" + } + }, + { + "name": "RemoveLocalTokenParams", + "type": { + "kind": "struct" + } + }, + { + "name": "SetMaxBurnAmountPerMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "burn_limit_per_message", + "type": "u64" + } + ] + } + }, + { + "name": "SetTokenControllerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "token_controller", + "type": "pubkey" + } + ] + } + }, + { + "name": "UninkTokenPairParams", + "type": { + "kind": "struct" + } + }, + { + "name": "UnpauseParams", + "type": { + "kind": "struct" + } + }, + { + "name": "UpdatePauserParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_pauser", + "type": "pubkey" + } + ] + } + }, + { + "name": "TokenMinterError", + "type": { + "kind": "enum", + "variants": [ + { + "name": "InvalidAuthority" + }, + { + "name": "InvalidTokenMinterState" + }, + { + "name": "ProgramPaused" + }, + { + "name": "InvalidTokenPairState" + }, + { + "name": "InvalidLocalTokenState" + }, + { + "name": "InvalidPauser" + }, + { + "name": "InvalidTokenController" + }, + { + "name": "BurnAmountExceeded" + }, + { + "name": "InvalidAmount" + } + ] + } + }, + { + "name": "TokenMessenger", + "type": { + "kind": "struct", + "fields": [ + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "pending_owner", + "type": "pubkey" + }, + { + "name": "local_message_transmitter", + "type": "pubkey" + }, + { + "name": "message_body_version", + "type": "u32" + }, + { + "name": "authority_bump", + "type": "u8" + } + ] + } + }, + { + "name": "RemoteTokenMessenger", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "token_messenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "TokenMinter", + "type": { + "kind": "struct", + "fields": [ + { + "name": "token_controller", + "type": "pubkey" + }, + { + "name": "pauser", + "type": "pubkey" + }, + { + "name": "paused", + "type": "bool" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "TokenPair", + "type": { + "kind": "struct", + "fields": [ + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "remote_token", + "type": "pubkey" + }, + { + "name": "local_token", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "LocalToken", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "burn_limit_per_message", + "type": "u64" + }, + { + "name": "messages_sent", + "type": "u64" + }, + { + "name": "messages_received", + "type": "u64" + }, + { + "name": "amount_sent", + "type": "u128" + }, + { + "name": "amount_received", + "type": "u128" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "custody_bump", + "type": "u8" + } + ] + } + }, + { + "name": "OwnershipTransferStarted", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previous_owner", + "type": "pubkey" + }, + { + "name": "new_owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "OwnershipTransferred", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previous_owner", + "type": "pubkey" + }, + { + "name": "new_owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "DepositForBurn", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nonce", + "type": "u64" + }, + { + "name": "burn_token", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "mint_recipient", + "type": "pubkey" + }, + { + "name": "destination_domain", + "type": "u32" + }, + { + "name": "destination_token_messenger", + "type": "pubkey" + }, + { + "name": "destination_caller", + "type": "pubkey" + } + ] + } + }, + { + "name": "MintAndWithdraw", + "type": { + "kind": "struct", + "fields": [ + { + "name": "mint_recipient", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "mint_token", + "type": "pubkey" + } + ] + } + }, + { + "name": "RemoteTokenMessengerAdded", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "token_messenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "RemoteTokenMessengerRemoved", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "token_messenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "SetTokenController", + "type": { + "kind": "struct", + "fields": [ + { + "name": "token_controller", + "type": "pubkey" + } + ] + } + }, + { + "name": "PauserChanged", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_address", + "type": "pubkey" + } + ] + } + }, + { + "name": "SetBurnLimitPerMessage", + "type": { + "kind": "struct", + "fields": [ + { + "name": "token", + "type": "pubkey" + }, + { + "name": "burn_limit_per_message", + "type": "u64" + } + ] + } + }, + { + "name": "LocalTokenAdded", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "LocalTokenRemoved", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "TokenPairLinked", + "type": { + "kind": "struct", + "fields": [ + { + "name": "local_token", + "type": "pubkey" + }, + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "remote_token", + "type": "pubkey" + } + ] + } + }, + { + "name": "TokenPairUnlinked", + "type": { + "kind": "struct", + "fields": [ + { + "name": "local_token", + "type": "pubkey" + }, + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "remote_token", + "type": "pubkey" + } + ] + } + }, + { + "name": "Pause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "Unpause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "TokenCustodyBurned", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody_token_account", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/src/svm/assets/idl/token_messenger_minter_v2.json b/src/svm/assets/idl/token_messenger_minter_v2.json new file mode 100644 index 000000000..670896b85 --- /dev/null +++ b/src/svm/assets/idl/token_messenger_minter_v2.json @@ -0,0 +1,4441 @@ +{ + "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe", + "metadata": { + "name": "token_messenger_minter_v2", + "version": "0.2.0", + "spec": "0.1.0", + "description": "Token Messenger and Minter for Cross-Chain Transfer Protocol V2", + "repository": "https://github.com/circlefin/solana-cctp-contracts" + }, + "instructions": [ + { + "name": "accept_ownership", + "discriminator": [ + 172, + 23, + 43, + 13, + 238, + 213, + 85, + 150 + ], + "accounts": [ + { + "name": "pending_owner", + "signer": true, + "relations": [ + "token_messenger" + ] + }, + { + "name": "token_messenger", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "AcceptOwnershipParams" + } + } + } + ] + }, + { + "name": "add_local_token", + "discriminator": [ + 213, + 199, + 205, + 18, + 98, + 124, + 73, + 198 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "token_controller", + "signer": true, + "relations": [ + "token_minter" + ] + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "local_token_mint" + } + ] + } + }, + { + "name": "custody_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "local_token_mint" + } + ] + } + }, + { + "name": "local_token_mint" + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "AddLocalTokenParams" + } + } + } + ] + }, + { + "name": "add_remote_token_messenger", + "discriminator": [ + 12, + 149, + 172, + 165, + 111, + 202, + 24, + 33 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "owner", + "signer": true, + "relations": [ + "token_messenger" + ] + }, + { + "name": "token_messenger" + }, + { + "name": "remote_token_messenger", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 109, + 111, + 116, + 101, + 95, + 116, + 111, + 107, + 101, + 110, + 95, + 109, + 101, + 115, + 115, + 101, + 110, + 103, + 101, + 114 + ] + }, + { + "kind": "arg", + "path": "params.domain" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "AddRemoteTokenMessengerParams" + } + } + } + ] + }, + { + "name": "burn_token_custody", + "discriminator": [ + 233, + 136, + 180, + 175, + 112, + 41, + 62, + 71 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "token_controller", + "signer": true, + "relations": [ + "token_minter" + ] + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "LocalToken" + } + ] + } + }, + { + "name": "custody_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "LocalToken" + } + ] + } + }, + { + "name": "custody_token_mint", + "writable": true + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "BurnTokenCustodyParams" + } + } + } + ] + }, + { + "name": "denylist_account", + "discriminator": [ + 101, + 116, + 197, + 112, + 81, + 249, + 75, + 194 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "denylister", + "signer": true, + "relations": [ + "token_messenger" + ] + }, + { + "name": "token_messenger" + }, + { + "name": "denylist_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 100, + 101, + 110, + 121, + 108, + 105, + 115, + 116, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "arg", + "path": "params.account" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "DenylistParams" + } + } + } + ] + }, + { + "name": "deposit_for_burn", + "discriminator": [ + 215, + 60, + 61, + 46, + 114, + 55, + 128, + 176 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "burn_token_account" + ] + }, + { + "name": "event_rent_payer", + "writable": true, + "signer": true + }, + { + "name": "sender_authority_pda", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 110, + 100, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "burn_token_account", + "writable": true + }, + { + "name": "denylist_account", + "docs": [ + "Account is denylisted if the account exists at the expected PDA." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 100, + 101, + 110, + 121, + 108, + 105, + 115, + 116, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "account", + "path": "owner" + } + ] + } + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "token_messenger" + }, + { + "name": "remote_token_messenger" + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "burn_token_mint" + } + ] + } + }, + { + "name": "burn_token_mint", + "writable": true + }, + { + "name": "message_sent_event_data", + "writable": true, + "signer": true + }, + { + "name": "message_transmitter_program", + "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" + }, + { + "name": "token_messenger_minter_program", + "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "DepositForBurnParams" + } + } + } + ] + }, + { + "name": "deposit_for_burn_with_hook", + "discriminator": [ + 111, + 245, + 62, + 131, + 204, + 108, + 223, + 155 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "burn_token_account" + ] + }, + { + "name": "event_rent_payer", + "writable": true, + "signer": true + }, + { + "name": "sender_authority_pda", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 110, + 100, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "burn_token_account", + "writable": true + }, + { + "name": "denylist_account", + "docs": [ + "Account is denylisted if the account exists at the expected PDA." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 100, + 101, + 110, + 121, + 108, + 105, + 115, + 116, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "account", + "path": "owner" + } + ] + } + }, + { + "name": "message_transmitter", + "writable": true + }, + { + "name": "token_messenger" + }, + { + "name": "remote_token_messenger" + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "burn_token_mint" + } + ] + } + }, + { + "name": "burn_token_mint", + "writable": true + }, + { + "name": "message_sent_event_data", + "writable": true, + "signer": true + }, + { + "name": "message_transmitter_program", + "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" + }, + { + "name": "token_messenger_minter_program", + "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "DepositForBurnWithHookParams" + } + } + } + ] + }, + { + "name": "handle_receive_finalized_message", + "discriminator": [ + 186, + 252, + 239, + 70, + 86, + 180, + 110, + 95 + ], + "accounts": [ + { + "name": "authority_pda", + "signer": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 115, + 115, + 97, + 103, + 101, + 95, + 116, + 114, + 97, + 110, + 115, + 109, + 105, + 116, + 116, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "const", + "value": [ + 166, + 95, + 200, + 29, + 15, + 239, + 168, + 134, + 12, + 179, + 184, + 63, + 8, + 155, + 2, + 36, + 190, + 138, + 102, + 135, + 183, + 174, + 73, + 245, + 148, + 192, + 185, + 180, + 215, + 233, + 56, + 147 + ] + } + ], + "program": { + "kind": "const", + "value": [ + 166, + 95, + 200, + 28, + 225, + 158, + 220, + 210, + 210, + 195, + 64, + 176, + 47, + 166, + 27, + 225, + 213, + 186, + 221, + 225, + 89, + 40, + 51, + 221, + 249, + 32, + 9, + 216, + 207, + 104, + 84, + 85 + ] + } + } + }, + { + "name": "token_messenger" + }, + { + "name": "remote_token_messenger" + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "LocalToken" + } + ] + } + }, + { + "name": "token_pair" + }, + { + "name": "fee_recipient_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "token_messenger.fee_recipient", + "account": "TokenMessenger" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "LocalToken" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "recipient_token_account", + "writable": true + }, + { + "name": "custody_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "LocalToken" + } + ] + } + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "HandleReceiveMessageParams" + } + } + } + ] + }, + { + "name": "handle_receive_unfinalized_message", + "discriminator": [ + 200, + 169, + 175, + 20, + 200, + 58, + 182, + 61 + ], + "accounts": [ + { + "name": "authority_pda", + "signer": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 115, + 115, + 97, + 103, + 101, + 95, + 116, + 114, + 97, + 110, + 115, + 109, + 105, + 116, + 116, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "const", + "value": [ + 166, + 95, + 200, + 29, + 15, + 239, + 168, + 134, + 12, + 179, + 184, + 63, + 8, + 155, + 2, + 36, + 190, + 138, + 102, + 135, + 183, + 174, + 73, + 245, + 148, + 192, + 185, + 180, + 215, + 233, + 56, + 147 + ] + } + ], + "program": { + "kind": "const", + "value": [ + 166, + 95, + 200, + 28, + 225, + 158, + 220, + 210, + 210, + 195, + 64, + 176, + 47, + 166, + 27, + 225, + 213, + 186, + 221, + 225, + 89, + 40, + 51, + 221, + 249, + 32, + 9, + 216, + 207, + 104, + 84, + 85 + ] + } + } + }, + { + "name": "token_messenger" + }, + { + "name": "remote_token_messenger" + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "LocalToken" + } + ] + } + }, + { + "name": "token_pair" + }, + { + "name": "fee_recipient_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "token_messenger.fee_recipient", + "account": "TokenMessenger" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "LocalToken" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "recipient_token_account", + "writable": true + }, + { + "name": "custody_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "LocalToken" + } + ] + } + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "HandleReceiveMessageParams" + } + } + } + ] + }, + { + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "upgrade_authority", + "signer": true + }, + { + "name": "authority_pda", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 110, + 100, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "token_messenger", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 111, + 107, + 101, + 110, + 95, + 109, + 101, + 115, + 115, + 101, + 110, + 103, + 101, + 114 + ] + } + ] + } + }, + { + "name": "token_minter", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 111, + 107, + 101, + 110, + 95, + 109, + 105, + 110, + 116, + 101, + 114 + ] + } + ] + } + }, + { + "name": "token_messenger_minter_program_data" + }, + { + "name": "token_messenger_minter_program", + "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "InitializeParams" + } + } + } + ] + }, + { + "name": "link_token_pair", + "discriminator": [ + 68, + 162, + 24, + 104, + 125, + 46, + 130, + 12 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "token_controller", + "signer": true, + "relations": [ + "token_minter" + ] + }, + { + "name": "token_minter" + }, + { + "name": "token_pair", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 111, + 107, + 101, + 110, + 95, + 112, + 97, + 105, + 114 + ] + }, + { + "kind": "arg", + "path": "params.remote_domain" + }, + { + "kind": "arg", + "path": "params.remote_token" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "LinkTokenPairParams" + } + } + } + ] + }, + { + "name": "pause", + "discriminator": [ + 211, + 22, + 221, + 251, + 74, + 121, + 193, + 47 + ], + "accounts": [ + { + "name": "pauser", + "signer": true, + "relations": [ + "token_minter" + ] + }, + { + "name": "token_minter", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "PauseParams" + } + } + } + ] + }, + { + "name": "remove_local_token", + "discriminator": [ + 27, + 43, + 66, + 170, + 188, + 44, + 109, + 97 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "token_controller", + "signer": true, + "relations": [ + "token_minter" + ] + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "LocalToken" + } + ] + } + }, + { + "name": "custody_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "LocalToken" + } + ] + } + }, + { + "name": "custody_token_mint", + "writable": true + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "RemoveLocalTokenParams" + } + } + } + ] + }, + { + "name": "remove_remote_token_messenger", + "discriminator": [ + 65, + 114, + 66, + 85, + 169, + 98, + 177, + 146 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "owner", + "signer": true, + "relations": [ + "token_messenger" + ] + }, + { + "name": "token_messenger" + }, + { + "name": "remote_token_messenger", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 109, + 111, + 116, + 101, + 95, + 116, + 111, + 107, + 101, + 110, + 95, + 109, + 101, + 115, + 115, + 101, + 110, + 103, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "remote_token_messenger.domain", + "account": "RemoteTokenMessenger" + } + ] + } + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "RemoveRemoteTokenMessengerParams" + } + } + } + ] + }, + { + "name": "set_fee_recipient", + "discriminator": [ + 227, + 18, + 215, + 42, + 237, + 246, + 151, + 66 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "token_messenger" + ] + }, + { + "name": "token_messenger", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetFeeRecipientParams" + } + } + } + ] + }, + { + "name": "set_max_burn_amount_per_message", + "discriminator": [ + 30, + 128, + 145, + 240, + 70, + 237, + 109, + 207 + ], + "accounts": [ + { + "name": "token_controller", + "signer": true, + "relations": [ + "token_minter" + ] + }, + { + "name": "token_minter" + }, + { + "name": "local_token", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "LocalToken" + } + ] + } + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetMaxBurnAmountPerMessageParams" + } + } + } + ] + }, + { + "name": "set_min_fee", + "discriminator": [ + 114, + 198, + 35, + 3, + 41, + 196, + 194, + 246 + ], + "accounts": [ + { + "name": "min_fee_controller", + "signer": true, + "relations": [ + "token_messenger" + ] + }, + { + "name": "token_messenger", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetMinFeeParams" + } + } + } + ] + }, + { + "name": "set_min_fee_controller", + "discriminator": [ + 195, + 142, + 74, + 84, + 234, + 94, + 180, + 113 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "token_messenger" + ] + }, + { + "name": "token_messenger", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetMinFeeControllerParams" + } + } + } + ] + }, + { + "name": "set_token_controller", + "discriminator": [ + 88, + 6, + 98, + 10, + 79, + 59, + 15, + 24 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "token_messenger" + ] + }, + { + "name": "token_messenger" + }, + { + "name": "token_minter", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "SetTokenControllerParams" + } + } + } + ] + }, + { + "name": "transfer_ownership", + "discriminator": [ + 65, + 177, + 215, + 73, + 53, + 45, + 99, + 47 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "token_messenger" + ] + }, + { + "name": "token_messenger", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "TransferOwnershipParams" + } + } + } + ] + }, + { + "name": "undenylist_account", + "discriminator": [ + 57, + 36, + 43, + 168, + 62, + 172, + 33, + 39 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "denylister", + "signer": true, + "relations": [ + "token_messenger" + ] + }, + { + "name": "token_messenger" + }, + { + "name": "denylist_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 100, + 101, + 110, + 121, + 108, + 105, + 115, + 116, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "arg", + "path": "params.account" + } + ] + } + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UndenylistParams" + } + } + } + ] + }, + { + "name": "unlink_token_pair", + "discriminator": [ + 52, + 198, + 100, + 114, + 104, + 174, + 85, + 58 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "token_controller", + "signer": true, + "relations": [ + "token_minter" + ] + }, + { + "name": "token_minter" + }, + { + "name": "token_pair", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 111, + 107, + 101, + 110, + 95, + 112, + 97, + 105, + 114 + ] + }, + { + "kind": "account", + "path": "token_pair.remote_domain", + "account": "TokenPair" + }, + { + "kind": "account", + "path": "token_pair.remote_token", + "account": "TokenPair" + } + ] + } + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UninkTokenPairParams" + } + } + } + ] + }, + { + "name": "unpause", + "discriminator": [ + 169, + 144, + 4, + 38, + 10, + 141, + 188, + 255 + ], + "accounts": [ + { + "name": "pauser", + "signer": true, + "relations": [ + "token_minter" + ] + }, + { + "name": "token_minter", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UnpauseParams" + } + } + } + ] + }, + { + "name": "update_denylister", + "discriminator": [ + 193, + 66, + 198, + 201, + 84, + 57, + 14, + 222 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "token_messenger" + ] + }, + { + "name": "token_messenger", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UpdateDenylisterParams" + } + } + } + ] + }, + { + "name": "update_pauser", + "discriminator": [ + 140, + 171, + 211, + 132, + 57, + 201, + 16, + 254 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "token_messenger" + ] + }, + { + "name": "token_messenger" + }, + { + "name": "token_minter", + "writable": true + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "UpdatePauserParams" + } + } + } + ] + } + ], + "accounts": [ + { + "name": "DenylistedAccount", + "discriminator": [ + 186, + 58, + 212, + 239, + 102, + 131, + 157, + 146 + ] + }, + { + "name": "LocalToken", + "discriminator": [ + 159, + 131, + 58, + 170, + 193, + 84, + 128, + 182 + ] + }, + { + "name": "MessageTransmitter", + "discriminator": [ + 71, + 40, + 180, + 142, + 19, + 203, + 35, + 252 + ] + }, + { + "name": "RemoteTokenMessenger", + "discriminator": [ + 105, + 115, + 174, + 34, + 95, + 233, + 138, + 252 + ] + }, + { + "name": "TokenMessenger", + "discriminator": [ + 162, + 4, + 242, + 52, + 147, + 243, + 221, + 96 + ] + }, + { + "name": "TokenMinter", + "discriminator": [ + 122, + 133, + 84, + 63, + 57, + 159, + 171, + 206 + ] + }, + { + "name": "TokenPair", + "discriminator": [ + 17, + 214, + 45, + 176, + 229, + 149, + 197, + 71 + ] + } + ], + "events": [ + { + "name": "Denylisted", + "discriminator": [ + 20, + 145, + 173, + 200, + 182, + 17, + 234, + 154 + ] + }, + { + "name": "DenylisterChanged", + "discriminator": [ + 249, + 170, + 81, + 180, + 185, + 175, + 138, + 72 + ] + }, + { + "name": "DepositForBurn", + "discriminator": [ + 144, + 252, + 145, + 146, + 6, + 74, + 167, + 235 + ] + }, + { + "name": "FeeRecipientSet", + "discriminator": [ + 99, + 140, + 80, + 35, + 245, + 176, + 179, + 110 + ] + }, + { + "name": "LocalTokenAdded", + "discriminator": [ + 146, + 8, + 224, + 150, + 122, + 173, + 23, + 39 + ] + }, + { + "name": "LocalTokenRemoved", + "discriminator": [ + 181, + 204, + 1, + 95, + 2, + 50, + 66, + 210 + ] + }, + { + "name": "MinFeeControllerSet", + "discriminator": [ + 239, + 12, + 122, + 105, + 231, + 114, + 13, + 196 + ] + }, + { + "name": "MinFeeSet", + "discriminator": [ + 60, + 127, + 101, + 230, + 216, + 129, + 188, + 98 + ] + }, + { + "name": "MintAndWithdraw", + "discriminator": [ + 75, + 67, + 229, + 70, + 162, + 126, + 0, + 71 + ] + }, + { + "name": "OwnershipTransferStarted", + "discriminator": [ + 183, + 253, + 239, + 246, + 140, + 179, + 133, + 105 + ] + }, + { + "name": "OwnershipTransferred", + "discriminator": [ + 172, + 61, + 205, + 183, + 250, + 50, + 38, + 98 + ] + }, + { + "name": "Pause", + "discriminator": [ + 194, + 251, + 232, + 196, + 118, + 95, + 111, + 219 + ] + }, + { + "name": "PauserChanged", + "discriminator": [ + 142, + 157, + 158, + 87, + 127, + 8, + 119, + 55 + ] + }, + { + "name": "RemoteTokenMessengerAdded", + "discriminator": [ + 251, + 29, + 63, + 244, + 48, + 114, + 210, + 175 + ] + }, + { + "name": "RemoteTokenMessengerRemoved", + "discriminator": [ + 255, + 121, + 137, + 39, + 230, + 125, + 11, + 30 + ] + }, + { + "name": "SetBurnLimitPerMessage", + "discriminator": [ + 98, + 152, + 88, + 191, + 245, + 30, + 27, + 209 + ] + }, + { + "name": "SetTokenController", + "discriminator": [ + 193, + 44, + 243, + 83, + 230, + 72, + 120, + 216 + ] + }, + { + "name": "TokenCustodyBurned", + "discriminator": [ + 219, + 143, + 107, + 226, + 67, + 75, + 178, + 46 + ] + }, + { + "name": "TokenPairLinked", + "discriminator": [ + 2, + 14, + 177, + 64, + 155, + 93, + 196, + 141 + ] + }, + { + "name": "TokenPairUnlinked", + "discriminator": [ + 78, + 232, + 230, + 208, + 180, + 212, + 246, + 72 + ] + }, + { + "name": "UnDenylisted", + "discriminator": [ + 150, + 39, + 227, + 20, + 162, + 180, + 5, + 242 + ] + }, + { + "name": "Unpause", + "discriminator": [ + 241, + 149, + 104, + 90, + 199, + 136, + 219, + 146 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "InvalidAuthority", + "msg": "Invalid authority" + }, + { + "code": 6001, + "name": "InvalidTokenMinterState", + "msg": "Invalid token minter state" + }, + { + "code": 6002, + "name": "ProgramPaused", + "msg": "Instruction is not allowed at this time" + }, + { + "code": 6003, + "name": "InvalidTokenPairState", + "msg": "Invalid token pair state" + }, + { + "code": 6004, + "name": "InvalidLocalTokenState", + "msg": "Invalid local token state" + }, + { + "code": 6005, + "name": "InvalidPauser", + "msg": "Invalid pauser" + }, + { + "code": 6006, + "name": "InvalidTokenController", + "msg": "Invalid token controller" + }, + { + "code": 6007, + "name": "BurnAmountExceeded", + "msg": "Burn amount exceeded" + }, + { + "code": 6008, + "name": "InvalidAmount", + "msg": "Invalid amount" + } + ], + "types": [ + { + "name": "AcceptOwnershipParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "AddLocalTokenParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "AddRemoteTokenMessengerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "token_messenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "BurnTokenCustodyParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "DenylistParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "account", + "type": "pubkey" + } + ] + } + }, + { + "name": "Denylisted", + "type": { + "kind": "struct", + "fields": [ + { + "name": "account", + "type": "pubkey" + } + ] + } + }, + { + "name": "DenylistedAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "account", + "type": "pubkey" + } + ] + } + }, + { + "name": "DenylisterChanged", + "type": { + "kind": "struct", + "fields": [ + { + "name": "old_denylister", + "type": "pubkey" + }, + { + "name": "new_denylister", + "type": "pubkey" + } + ] + } + }, + { + "name": "DepositForBurn", + "type": { + "kind": "struct", + "fields": [ + { + "name": "burn_token", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "mint_recipient", + "type": "pubkey" + }, + { + "name": "destination_domain", + "type": "u32" + }, + { + "name": "destination_token_messenger", + "type": "pubkey" + }, + { + "name": "destination_caller", + "type": "pubkey" + }, + { + "name": "max_fee", + "type": "u64" + }, + { + "name": "min_finality_threshold", + "type": "u32" + }, + { + "name": "hook_data", + "type": "bytes" + } + ] + } + }, + { + "name": "DepositForBurnParams", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "destination_domain", + "type": "u32" + }, + { + "name": "mint_recipient", + "type": "pubkey" + }, + { + "name": "destination_caller", + "type": "pubkey" + }, + { + "name": "max_fee", + "type": "u64" + }, + { + "name": "min_finality_threshold", + "type": "u32" + } + ] + } + }, + { + "name": "DepositForBurnWithHookParams", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "destination_domain", + "type": "u32" + }, + { + "name": "mint_recipient", + "type": "pubkey" + }, + { + "name": "destination_caller", + "type": "pubkey" + }, + { + "name": "max_fee", + "type": "u64" + }, + { + "name": "min_finality_threshold", + "type": "u32" + }, + { + "name": "hook_data", + "type": "bytes" + } + ] + } + }, + { + "name": "FeeRecipientSet", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_fee_recipient", + "type": "pubkey" + } + ] + } + }, + { + "name": "HandleReceiveMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "sender", + "type": "pubkey" + }, + { + "name": "finality_threshold_executed", + "type": "u32" + }, + { + "name": "message_body", + "type": "bytes" + }, + { + "name": "authority_bump", + "type": "u8" + } + ] + } + }, + { + "name": "InitializeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "token_controller", + "type": "pubkey" + }, + { + "name": "denylister", + "type": "pubkey" + }, + { + "name": "fee_recipient", + "type": "pubkey" + }, + { + "name": "min_fee_controller", + "type": "pubkey" + }, + { + "name": "min_fee", + "type": "u32" + }, + { + "name": "message_body_version", + "type": "u32" + } + ] + } + }, + { + "name": "LinkTokenPairParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "local_token", + "type": "pubkey" + }, + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "remote_token", + "type": "pubkey" + } + ] + } + }, + { + "name": "LocalToken", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "burn_limit_per_message", + "type": "u64" + }, + { + "name": "messages_sent", + "type": "u64" + }, + { + "name": "messages_received", + "type": "u64" + }, + { + "name": "amount_sent", + "type": "u128" + }, + { + "name": "amount_received", + "type": "u128" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "custody_bump", + "type": "u8" + } + ] + } + }, + { + "name": "LocalTokenAdded", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "LocalTokenRemoved", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "MessageTransmitter", + "docs": [ + "Main state of the MessageTransmitter program" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "pending_owner", + "type": "pubkey" + }, + { + "name": "attester_manager", + "type": "pubkey" + }, + { + "name": "pauser", + "type": "pubkey" + }, + { + "name": "paused", + "type": "bool" + }, + { + "name": "local_domain", + "type": "u32" + }, + { + "name": "version", + "type": "u32" + }, + { + "name": "signature_threshold", + "type": "u32" + }, + { + "name": "enabled_attesters", + "type": { + "vec": "pubkey" + } + }, + { + "name": "max_message_body_size", + "type": "u64" + } + ] + } + }, + { + "name": "MinFeeControllerSet", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_min_fee_controller", + "type": "pubkey" + } + ] + } + }, + { + "name": "MinFeeSet", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_min_fee", + "type": "u32" + } + ] + } + }, + { + "name": "MintAndWithdraw", + "type": { + "kind": "struct", + "fields": [ + { + "name": "mint_recipient", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "mint_token", + "type": "pubkey" + }, + { + "name": "fee_collected", + "type": "u64" + } + ] + } + }, + { + "name": "OwnershipTransferStarted", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previous_owner", + "type": "pubkey" + }, + { + "name": "new_owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "OwnershipTransferred", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previous_owner", + "type": "pubkey" + }, + { + "name": "new_owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "Pause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "PauseParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "PauserChanged", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_address", + "type": "pubkey" + } + ] + } + }, + { + "name": "RemoteTokenMessenger", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "token_messenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "RemoteTokenMessengerAdded", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "token_messenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "RemoteTokenMessengerRemoved", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "token_messenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "RemoveLocalTokenParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "RemoveRemoteTokenMessengerParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "SetBurnLimitPerMessage", + "type": { + "kind": "struct", + "fields": [ + { + "name": "token", + "type": "pubkey" + }, + { + "name": "burn_limit_per_message", + "type": "u64" + } + ] + } + }, + { + "name": "SetFeeRecipientParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_fee_recipient", + "type": "pubkey" + } + ] + } + }, + { + "name": "SetMaxBurnAmountPerMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "burn_limit_per_message", + "type": "u64" + } + ] + } + }, + { + "name": "SetMinFeeControllerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_min_fee_controller", + "type": "pubkey" + } + ] + } + }, + { + "name": "SetMinFeeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_min_fee", + "type": "u32" + } + ] + } + }, + { + "name": "SetTokenController", + "type": { + "kind": "struct", + "fields": [ + { + "name": "token_controller", + "type": "pubkey" + } + ] + } + }, + { + "name": "SetTokenControllerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "token_controller", + "type": "pubkey" + } + ] + } + }, + { + "name": "TokenCustodyBurned", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody_token_account", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "TokenMessenger", + "type": { + "kind": "struct", + "fields": [ + { + "name": "denylister", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "pending_owner", + "type": "pubkey" + }, + { + "name": "message_body_version", + "type": "u32" + }, + { + "name": "authority_bump", + "type": "u8" + }, + { + "name": "fee_recipient", + "type": "pubkey" + }, + { + "name": "min_fee_controller", + "type": "pubkey" + }, + { + "name": "min_fee", + "type": "u32" + } + ] + } + }, + { + "name": "TokenMinter", + "type": { + "kind": "struct", + "fields": [ + { + "name": "token_controller", + "type": "pubkey" + }, + { + "name": "pauser", + "type": "pubkey" + }, + { + "name": "paused", + "type": "bool" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "TokenPair", + "type": { + "kind": "struct", + "fields": [ + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "remote_token", + "type": "pubkey" + }, + { + "name": "local_token", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "TokenPairLinked", + "type": { + "kind": "struct", + "fields": [ + { + "name": "local_token", + "type": "pubkey" + }, + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "remote_token", + "type": "pubkey" + } + ] + } + }, + { + "name": "TokenPairUnlinked", + "type": { + "kind": "struct", + "fields": [ + { + "name": "local_token", + "type": "pubkey" + }, + { + "name": "remote_domain", + "type": "u32" + }, + { + "name": "remote_token", + "type": "pubkey" + } + ] + } + }, + { + "name": "TransferOwnershipParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_owner", + "type": "pubkey" + } + ] + } + }, + { + "name": "UnDenylisted", + "type": { + "kind": "struct", + "fields": [ + { + "name": "account", + "type": "pubkey" + } + ] + } + }, + { + "name": "UndenylistParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "account", + "type": "pubkey" + } + ] + } + }, + { + "name": "UninkTokenPairParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "Unpause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "UnpauseParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "UpdateDenylisterParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_denylister", + "type": "pubkey" + } + ] + } + }, + { + "name": "UpdatePauserParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "new_pauser", + "type": "pubkey" + } + ] + } + } + ] +} \ No newline at end of file diff --git a/src/svm/assets/index.ts b/src/svm/assets/index.ts new file mode 100644 index 000000000..a9f2785d3 --- /dev/null +++ b/src/svm/assets/index.ts @@ -0,0 +1,12 @@ +// This file has been autogenerated. Do not edit manually. +// Generated by a script. + +export * from "./idl"; +export {MessageTransmitterV2 as MessageTransmitterV2Anchor} from "./message_transmitter_v2"; +export {MessageTransmitter as MessageTransmitterAnchor} from "./message_transmitter"; +export {MulticallHandler as MulticallHandlerAnchor} from "./multicall_handler"; +export {SponsoredCctpSrcPeriphery as SponsoredCctpSrcPeripheryAnchor} from "./sponsored_cctp_src_periphery"; +export {SvmSpoke as SvmSpokeAnchor} from "./svm_spoke"; +export {Test as TestAnchor} from "./test"; +export {TokenMessengerMinterV2 as TokenMessengerMinterV2Anchor} from "./token_messenger_minter_v2"; +export {TokenMessengerMinter as TokenMessengerMinterAnchor} from "./token_messenger_minter"; diff --git a/src/svm/assets/message_transmitter.ts b/src/svm/assets/message_transmitter.ts new file mode 100644 index 000000000..7f54e1107 --- /dev/null +++ b/src/svm/assets/message_transmitter.ts @@ -0,0 +1,1681 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/message_transmitter.json`. + */ +export type MessageTransmitter = { + "address": "CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd", + "metadata": { + "name": "messageTransmitter", + "version": "0.1.0", + "spec": "0.1.0" + }, + "instructions": [ + { + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "upgradeAuthority", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "messageTransmitterProgramData" + }, + { + "name": "messageTransmitterProgram" + }, + { + "name": "systemProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "initializeParams" + } + } + } + ] + }, + { + "name": "transferOwnership", + "discriminator": [ + 65, + 177, + 215, + 73, + 53, + 45, + 99, + 47 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "transferOwnershipParams" + } + } + } + ] + }, + { + "name": "acceptOwnership", + "discriminator": [ + 172, + 23, + 43, + 13, + 238, + 213, + 85, + 150 + ], + "accounts": [ + { + "name": "pendingOwner", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "acceptOwnershipParams" + } + } + } + ] + }, + { + "name": "updatePauser", + "discriminator": [ + 140, + 171, + 211, + 132, + 57, + 201, + 16, + 254 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "updatePauserParams" + } + } + } + ] + }, + { + "name": "updateAttesterManager", + "discriminator": [ + 175, + 245, + 178, + 104, + 85, + 179, + 71, + 16 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "updateAttesterManagerParams" + } + } + } + ] + }, + { + "name": "pause", + "discriminator": [ + 211, + 22, + 221, + 251, + 74, + 121, + 193, + 47 + ], + "accounts": [ + { + "name": "pauser", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "pauseParams" + } + } + } + ] + }, + { + "name": "unpause", + "discriminator": [ + 169, + 144, + 4, + 38, + 10, + 141, + 188, + 255 + ], + "accounts": [ + { + "name": "pauser", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "unpauseParams" + } + } + } + ] + }, + { + "name": "setMaxMessageBodySize", + "discriminator": [ + 168, + 178, + 8, + 117, + 217, + 167, + 219, + 31 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setMaxMessageBodySizeParams" + } + } + } + ] + }, + { + "name": "enableAttester", + "discriminator": [ + 2, + 11, + 193, + 115, + 5, + 148, + 4, + 198 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "attesterManager", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "systemProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "enableAttesterParams" + } + } + } + ] + }, + { + "name": "disableAttester", + "discriminator": [ + 61, + 171, + 131, + 95, + 172, + 15, + 227, + 229 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "attesterManager", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "systemProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "disableAttesterParams" + } + } + } + ] + }, + { + "name": "setSignatureThreshold", + "discriminator": [ + 163, + 19, + 154, + 168, + 82, + 209, + 214, + 219 + ], + "accounts": [ + { + "name": "attesterManager", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setSignatureThresholdParams" + } + } + } + ] + }, + { + "name": "sendMessage", + "discriminator": [ + 57, + 40, + 34, + 178, + 189, + 10, + 65, + 26 + ], + "accounts": [ + { + "name": "eventRentPayer", + "writable": true, + "signer": true + }, + { + "name": "senderAuthorityPda", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "messageSentEventData", + "writable": true, + "signer": true + }, + { + "name": "senderProgram" + }, + { + "name": "systemProgram" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "sendMessageParams" + } + } + } + ], + "returns": "u64" + }, + { + "name": "sendMessageWithCaller", + "discriminator": [ + 212, + 47, + 34, + 52, + 91, + 32, + 176, + 204 + ], + "accounts": [ + { + "name": "eventRentPayer", + "writable": true, + "signer": true + }, + { + "name": "senderAuthorityPda", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "messageSentEventData", + "writable": true, + "signer": true + }, + { + "name": "senderProgram" + }, + { + "name": "systemProgram" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "sendMessageWithCallerParams" + } + } + } + ], + "returns": "u64" + }, + { + "name": "replaceMessage", + "discriminator": [ + 189, + 189, + 210, + 163, + 149, + 205, + 69, + 229 + ], + "accounts": [ + { + "name": "eventRentPayer", + "writable": true, + "signer": true + }, + { + "name": "senderAuthorityPda", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "messageSentEventData", + "writable": true, + "signer": true + }, + { + "name": "senderProgram" + }, + { + "name": "systemProgram" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "replaceMessageParams" + } + } + } + ], + "returns": "u64" + }, + { + "name": "receiveMessage", + "discriminator": [ + 38, + 144, + 127, + 225, + 31, + 225, + 238, + 25 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "caller", + "signer": true + }, + { + "name": "authorityPda" + }, + { + "name": "messageTransmitter" + }, + { + "name": "usedNonces", + "writable": true + }, + { + "name": "receiver" + }, + { + "name": "systemProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "receiveMessageParams" + } + } + } + ] + }, + { + "name": "reclaimEventAccount", + "discriminator": [ + 94, + 198, + 180, + 159, + 131, + 236, + 15, + 174 + ], + "accounts": [ + { + "name": "payee", + "docs": [ + "rent SOL receiver, should match original rent payer" + ], + "writable": true, + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "messageSentEventData", + "writable": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "reclaimEventAccountParams" + } + } + } + ] + }, + { + "name": "getNoncePda", + "discriminator": [ + 114, + 70, + 229, + 212, + 223, + 50, + 33, + 39 + ], + "accounts": [ + { + "name": "messageTransmitter" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "getNoncePdaParams" + } + } + } + ], + "returns": "pubkey" + }, + { + "name": "isNonceUsed", + "discriminator": [ + 144, + 72, + 107, + 148, + 35, + 218, + 31, + 187 + ], + "accounts": [ + { + "name": "usedNonces", + "docs": [ + "Account will be explicitly loaded to avoid error when it's not initialized" + ] + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "isNonceUsedParams" + } + } + } + ], + "returns": "bool" + } + ], + "accounts": [ + { + "name": "messageSent", + "discriminator": [ + 131, + 100, + 133, + 56, + 166, + 225, + 151, + 60 + ] + }, + { + "name": "messageTransmitter", + "discriminator": [ + 71, + 40, + 180, + 142, + 19, + 203, + 35, + 252 + ] + }, + { + "name": "usedNonces", + "discriminator": [ + 60, + 112, + 18, + 72, + 138, + 181, + 100, + 138 + ] + } + ], + "events": [ + { + "name": "ownershipTransferStarted", + "discriminator": [ + 183, + 253, + 239, + 246, + 140, + 179, + 133, + 105 + ] + }, + { + "name": "ownershipTransferred", + "discriminator": [ + 172, + 61, + 205, + 183, + 250, + 50, + 38, + 98 + ] + }, + { + "name": "pauserChanged", + "discriminator": [ + 142, + 157, + 158, + 87, + 127, + 8, + 119, + 55 + ] + }, + { + "name": "attesterManagerUpdated", + "discriminator": [ + 5, + 97, + 191, + 108, + 44, + 189, + 69, + 88 + ] + }, + { + "name": "messageReceived", + "discriminator": [ + 231, + 68, + 47, + 77, + 173, + 241, + 157, + 166 + ] + }, + { + "name": "signatureThresholdUpdated", + "discriminator": [ + 156, + 99, + 103, + 200, + 15, + 38, + 122, + 189 + ] + }, + { + "name": "attesterEnabled", + "discriminator": [ + 88, + 57, + 14, + 133, + 5, + 219, + 62, + 190 + ] + }, + { + "name": "attesterDisabled", + "discriminator": [ + 186, + 136, + 186, + 14, + 229, + 2, + 121, + 211 + ] + }, + { + "name": "maxMessageBodySizeUpdated", + "discriminator": [ + 134, + 206, + 151, + 111, + 137, + 11, + 160, + 225 + ] + }, + { + "name": "pause", + "discriminator": [ + 194, + 251, + 232, + 196, + 118, + 95, + 111, + 219 + ] + }, + { + "name": "unpause", + "discriminator": [ + 241, + 149, + 104, + 90, + 199, + 136, + 219, + 146 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "invalidAuthority", + "msg": "Invalid authority" + }, + { + "code": 6001, + "name": "programPaused", + "msg": "Instruction is not allowed at this time" + }, + { + "code": 6002, + "name": "invalidMessageTransmitterState", + "msg": "Invalid message transmitter state" + }, + { + "code": 6003, + "name": "invalidSignatureThreshold", + "msg": "Invalid signature threshold" + }, + { + "code": 6004, + "name": "signatureThresholdAlreadySet", + "msg": "Signature threshold already set" + }, + { + "code": 6005, + "name": "invalidOwner", + "msg": "Invalid owner" + }, + { + "code": 6006, + "name": "invalidPauser", + "msg": "Invalid pauser" + }, + { + "code": 6007, + "name": "invalidAttesterManager", + "msg": "Invalid attester manager" + }, + { + "code": 6008, + "name": "invalidAttester", + "msg": "Invalid attester" + }, + { + "code": 6009, + "name": "attesterAlreadyEnabled", + "msg": "Attester already enabled" + }, + { + "code": 6010, + "name": "tooFewEnabledAttesters", + "msg": "Too few enabled attesters" + }, + { + "code": 6011, + "name": "signatureThresholdTooLow", + "msg": "Signature threshold is too low" + }, + { + "code": 6012, + "name": "attesterAlreadyDisabled", + "msg": "Attester already disabled" + }, + { + "code": 6013, + "name": "messageBodyLimitExceeded", + "msg": "Message body exceeds max size" + }, + { + "code": 6014, + "name": "invalidDestinationCaller", + "msg": "Invalid destination caller" + }, + { + "code": 6015, + "name": "invalidRecipient", + "msg": "Invalid message recipient" + }, + { + "code": 6016, + "name": "senderNotPermitted", + "msg": "Sender is not permitted" + }, + { + "code": 6017, + "name": "invalidSourceDomain", + "msg": "Invalid source domain" + }, + { + "code": 6018, + "name": "invalidDestinationDomain", + "msg": "Invalid destination domain" + }, + { + "code": 6019, + "name": "invalidMessageVersion", + "msg": "Invalid message version" + }, + { + "code": 6020, + "name": "invalidUsedNoncesAccount", + "msg": "Invalid used nonces account" + }, + { + "code": 6021, + "name": "invalidRecipientProgram", + "msg": "Invalid recipient program" + }, + { + "code": 6022, + "name": "invalidNonce", + "msg": "Invalid nonce" + }, + { + "code": 6023, + "name": "nonceAlreadyUsed", + "msg": "Nonce already used" + }, + { + "code": 6024, + "name": "messageTooShort", + "msg": "Message is too short" + }, + { + "code": 6025, + "name": "malformedMessage", + "msg": "Malformed message" + }, + { + "code": 6026, + "name": "invalidSignatureOrderOrDupe", + "msg": "Invalid signature order or dupe" + }, + { + "code": 6027, + "name": "invalidAttesterSignature", + "msg": "Invalid attester signature" + }, + { + "code": 6028, + "name": "invalidAttestationLength", + "msg": "Invalid attestation length" + }, + { + "code": 6029, + "name": "invalidSignatureRecoveryId", + "msg": "Invalid signature recovery ID" + }, + { + "code": 6030, + "name": "invalidSignatureSValue", + "msg": "Invalid signature S value" + }, + { + "code": 6031, + "name": "invalidMessageHash", + "msg": "Invalid message hash" + } + ], + "types": [ + { + "name": "acceptOwnershipParams", + "type": { + "kind": "struct" + } + }, + { + "name": "disableAttesterParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "enableAttesterParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newAttester", + "type": "pubkey" + } + ] + } + }, + { + "name": "getNoncePdaParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nonce", + "type": "u64" + }, + { + "name": "sourceDomain", + "type": "u32" + } + ] + } + }, + { + "name": "initializeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "localDomain", + "type": "u32" + }, + { + "name": "attester", + "type": "pubkey" + }, + { + "name": "maxMessageBodySize", + "type": "u64" + }, + { + "name": "version", + "type": "u32" + } + ] + } + }, + { + "name": "isNonceUsedParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nonce", + "type": "u64" + } + ] + } + }, + { + "name": "pauseParams", + "type": { + "kind": "struct" + } + }, + { + "name": "receiveMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "message", + "type": "bytes" + }, + { + "name": "attestation", + "type": "bytes" + } + ] + } + }, + { + "name": "handleReceiveMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "sender", + "type": "pubkey" + }, + { + "name": "messageBody", + "type": "bytes" + }, + { + "name": "authorityBump", + "type": "u8" + } + ] + } + }, + { + "name": "reclaimEventAccountParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attestation", + "type": "bytes" + } + ] + } + }, + { + "name": "replaceMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "originalMessage", + "type": "bytes" + }, + { + "name": "originalAttestation", + "type": "bytes" + }, + { + "name": "newMessageBody", + "type": "bytes" + }, + { + "name": "newDestinationCaller", + "type": "pubkey" + } + ] + } + }, + { + "name": "sendMessageWithCallerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "destinationDomain", + "type": "u32" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "messageBody", + "type": "bytes" + }, + { + "name": "destinationCaller", + "type": "pubkey" + } + ] + } + }, + { + "name": "sendMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "destinationDomain", + "type": "u32" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "messageBody", + "type": "bytes" + } + ] + } + }, + { + "name": "setMaxMessageBodySizeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newMaxMessageBodySize", + "type": "u64" + } + ] + } + }, + { + "name": "setSignatureThresholdParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newSignatureThreshold", + "type": "u32" + } + ] + } + }, + { + "name": "transferOwnershipParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newOwner", + "type": "pubkey" + } + ] + } + }, + { + "name": "unpauseParams", + "type": { + "kind": "struct" + } + }, + { + "name": "updateAttesterManagerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newAttesterManager", + "type": "pubkey" + } + ] + } + }, + { + "name": "updatePauserParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newPauser", + "type": "pubkey" + } + ] + } + }, + { + "name": "mathError", + "type": { + "kind": "enum", + "variants": [ + { + "name": "mathOverflow" + }, + { + "name": "mathUnderflow" + }, + { + "name": "errorInDivision" + } + ] + } + }, + { + "name": "messageSent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rentPayer", + "type": "pubkey" + }, + { + "name": "message", + "type": "bytes" + } + ] + } + }, + { + "name": "messageTransmitter", + "docs": [ + "Main state of the MessageTransmitter program" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "pendingOwner", + "type": "pubkey" + }, + { + "name": "attesterManager", + "type": "pubkey" + }, + { + "name": "pauser", + "type": "pubkey" + }, + { + "name": "paused", + "type": "bool" + }, + { + "name": "localDomain", + "type": "u32" + }, + { + "name": "version", + "type": "u32" + }, + { + "name": "signatureThreshold", + "type": "u32" + }, + { + "name": "enabledAttesters", + "type": { + "vec": "pubkey" + } + }, + { + "name": "maxMessageBodySize", + "type": "u64" + }, + { + "name": "nextAvailableNonce", + "type": "u64" + } + ] + } + }, + { + "name": "usedNonces", + "docs": [ + "UsedNonces account holds an array of bits that indicate which nonces were already used", + "so they can't be resused to receive new messages. Array starts with the first_nonce and", + "holds flags for UsedNonces::MAX_NONCES. Nonces are recorded separately for each remote_domain." + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "firstNonce", + "type": "u64" + }, + { + "name": "usedNonces", + "type": { + "array": [ + "u64", + 100 + ] + } + } + ] + } + }, + { + "name": "ownershipTransferStarted", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previousOwner", + "type": "pubkey" + }, + { + "name": "newOwner", + "type": "pubkey" + } + ] + } + }, + { + "name": "ownershipTransferred", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previousOwner", + "type": "pubkey" + }, + { + "name": "newOwner", + "type": "pubkey" + } + ] + } + }, + { + "name": "pauserChanged", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newAddress", + "type": "pubkey" + } + ] + } + }, + { + "name": "attesterManagerUpdated", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previousAttesterManager", + "type": "pubkey" + }, + { + "name": "newAttesterManager", + "type": "pubkey" + } + ] + } + }, + { + "name": "messageReceived", + "type": { + "kind": "struct", + "fields": [ + { + "name": "caller", + "type": "pubkey" + }, + { + "name": "sourceDomain", + "type": "u32" + }, + { + "name": "nonce", + "type": "u64" + }, + { + "name": "sender", + "type": "pubkey" + }, + { + "name": "messageBody", + "type": "bytes" + } + ] + } + }, + { + "name": "signatureThresholdUpdated", + "type": { + "kind": "struct", + "fields": [ + { + "name": "oldSignatureThreshold", + "type": "u32" + }, + { + "name": "newSignatureThreshold", + "type": "u32" + } + ] + } + }, + { + "name": "attesterEnabled", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "attesterDisabled", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "maxMessageBodySizeUpdated", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newMaxMessageBodySize", + "type": "u64" + } + ] + } + }, + { + "name": "pause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "unpause", + "type": { + "kind": "struct", + "fields": [] + } + } + ] +}; diff --git a/src/svm/assets/message_transmitter_v2.ts b/src/svm/assets/message_transmitter_v2.ts new file mode 100644 index 000000000..79168e7f3 --- /dev/null +++ b/src/svm/assets/message_transmitter_v2.ts @@ -0,0 +1,1869 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/message_transmitter_v2.json`. + */ +export type MessageTransmitterV2 = { + "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC", + "metadata": { + "name": "messageTransmitterV2", + "version": "0.2.0", + "spec": "0.1.0", + "description": "Message Transmitter for Cross-Chain Transfer Protocol V2", + "repository": "https://github.com/circlefin/solana-cctp-contracts" + }, + "instructions": [ + { + "name": "acceptOwnership", + "discriminator": [ + 172, + 23, + 43, + 13, + 238, + 213, + 85, + 150 + ], + "accounts": [ + { + "name": "pendingOwner", + "signer": true, + "relations": [ + "messageTransmitter" + ] + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "acceptOwnershipParams" + } + } + } + ] + }, + { + "name": "disableAttester", + "discriminator": [ + 61, + 171, + 131, + 95, + 172, + 15, + 227, + 229 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "attesterManager", + "signer": true, + "relations": [ + "messageTransmitter" + ] + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "disableAttesterParams" + } + } + } + ] + }, + { + "name": "enableAttester", + "discriminator": [ + 2, + 11, + 193, + 115, + 5, + 148, + 4, + 198 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "attesterManager", + "signer": true, + "relations": [ + "messageTransmitter" + ] + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "enableAttesterParams" + } + } + } + ] + }, + { + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "upgradeAuthority", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 115, + 115, + 97, + 103, + 101, + 95, + 116, + 114, + 97, + 110, + 115, + 109, + 105, + 116, + 116, + 101, + 114 + ] + } + ] + } + }, + { + "name": "messageTransmitterProgramData" + }, + { + "name": "messageTransmitterProgram", + "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "initializeParams" + } + } + } + ] + }, + { + "name": "isNonceUsed", + "discriminator": [ + 144, + 72, + 107, + 148, + 35, + 218, + 31, + 187 + ], + "accounts": [ + { + "name": "usedNonce", + "docs": [ + "Account will be explicitly loaded to avoid error when it's not initialized" + ] + } + ], + "args": [], + "returns": "bool" + }, + { + "name": "pause", + "discriminator": [ + 211, + 22, + 221, + 251, + 74, + 121, + 193, + 47 + ], + "accounts": [ + { + "name": "pauser", + "signer": true, + "relations": [ + "messageTransmitter" + ] + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "pauseParams" + } + } + } + ] + }, + { + "name": "receiveMessage", + "discriminator": [ + 38, + 144, + 127, + 225, + 31, + 225, + 238, + 25 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "caller", + "signer": true + }, + { + "name": "authorityPda", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 115, + 115, + 97, + 103, + 101, + 95, + 116, + 114, + 97, + 110, + 115, + 109, + 105, + 116, + 116, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "receiver" + } + ] + } + }, + { + "name": "messageTransmitter" + }, + { + "name": "usedNonce", + "docs": [ + "Each nonce is stored in a separate PDA" + ], + "writable": true + }, + { + "name": "receiver" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "receiveMessageParams" + } + } + } + ] + }, + { + "name": "reclaimEventAccount", + "discriminator": [ + 94, + 198, + 180, + 159, + 131, + 236, + 15, + 174 + ], + "accounts": [ + { + "name": "payee", + "docs": [ + "rent SOL receiver, should match original rent payer" + ], + "writable": true, + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "messageSentEventData", + "writable": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "reclaimEventAccountParams" + } + } + } + ] + }, + { + "name": "sendMessage", + "discriminator": [ + 57, + 40, + 34, + 178, + 189, + 10, + 65, + 26 + ], + "accounts": [ + { + "name": "eventRentPayer", + "writable": true, + "signer": true + }, + { + "name": "senderAuthorityPda", + "signer": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "messageSentEventData", + "writable": true, + "signer": true + }, + { + "name": "senderProgram" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "sendMessageParams" + } + } + } + ] + }, + { + "name": "setMaxMessageBodySize", + "discriminator": [ + 168, + 178, + 8, + 117, + 217, + 167, + 219, + 31 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "messageTransmitter" + ] + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setMaxMessageBodySizeParams" + } + } + } + ] + }, + { + "name": "setSignatureThreshold", + "discriminator": [ + 163, + 19, + 154, + 168, + 82, + 209, + 214, + 219 + ], + "accounts": [ + { + "name": "attesterManager", + "signer": true, + "relations": [ + "messageTransmitter" + ] + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setSignatureThresholdParams" + } + } + } + ] + }, + { + "name": "transferOwnership", + "discriminator": [ + 65, + 177, + 215, + 73, + 53, + 45, + 99, + 47 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "messageTransmitter" + ] + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "transferOwnershipParams" + } + } + } + ] + }, + { + "name": "unpause", + "discriminator": [ + 169, + 144, + 4, + 38, + 10, + 141, + 188, + 255 + ], + "accounts": [ + { + "name": "pauser", + "signer": true, + "relations": [ + "messageTransmitter" + ] + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "unpauseParams" + } + } + } + ] + }, + { + "name": "updateAttesterManager", + "discriminator": [ + 175, + 245, + 178, + 104, + 85, + 179, + 71, + 16 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "messageTransmitter" + ] + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "updateAttesterManagerParams" + } + } + } + ] + }, + { + "name": "updatePauser", + "discriminator": [ + 140, + 171, + 211, + 132, + 57, + 201, + 16, + 254 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "messageTransmitter" + ] + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "updatePauserParams" + } + } + } + ] + } + ], + "accounts": [ + { + "name": "messageSent", + "discriminator": [ + 131, + 100, + 133, + 56, + 166, + 225, + 151, + 60 + ] + }, + { + "name": "messageTransmitter", + "discriminator": [ + 71, + 40, + 180, + 142, + 19, + 203, + 35, + 252 + ] + }, + { + "name": "usedNonce", + "discriminator": [ + 212, + 222, + 157, + 252, + 130, + 71, + 179, + 238 + ] + } + ], + "events": [ + { + "name": "attesterDisabled", + "discriminator": [ + 186, + 136, + 186, + 14, + 229, + 2, + 121, + 211 + ] + }, + { + "name": "attesterEnabled", + "discriminator": [ + 88, + 57, + 14, + 133, + 5, + 219, + 62, + 190 + ] + }, + { + "name": "attesterManagerUpdated", + "discriminator": [ + 5, + 97, + 191, + 108, + 44, + 189, + 69, + 88 + ] + }, + { + "name": "maxMessageBodySizeUpdated", + "discriminator": [ + 134, + 206, + 151, + 111, + 137, + 11, + 160, + 225 + ] + }, + { + "name": "messageReceived", + "discriminator": [ + 231, + 68, + 47, + 77, + 173, + 241, + 157, + 166 + ] + }, + { + "name": "ownershipTransferStarted", + "discriminator": [ + 183, + 253, + 239, + 246, + 140, + 179, + 133, + 105 + ] + }, + { + "name": "ownershipTransferred", + "discriminator": [ + 172, + 61, + 205, + 183, + 250, + 50, + 38, + 98 + ] + }, + { + "name": "pause", + "discriminator": [ + 194, + 251, + 232, + 196, + 118, + 95, + 111, + 219 + ] + }, + { + "name": "pauserChanged", + "discriminator": [ + 142, + 157, + 158, + 87, + 127, + 8, + 119, + 55 + ] + }, + { + "name": "signatureThresholdUpdated", + "discriminator": [ + 156, + 99, + 103, + 200, + 15, + 38, + 122, + 189 + ] + }, + { + "name": "unpause", + "discriminator": [ + 241, + 149, + 104, + 90, + 199, + 136, + 219, + 146 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "invalidAuthority", + "msg": "Invalid authority" + }, + { + "code": 6001, + "name": "programPaused", + "msg": "Instruction is not allowed at this time" + }, + { + "code": 6002, + "name": "invalidMessageTransmitterState", + "msg": "Invalid message transmitter state" + }, + { + "code": 6003, + "name": "invalidSignatureThreshold", + "msg": "Invalid signature threshold" + }, + { + "code": 6004, + "name": "signatureThresholdAlreadySet", + "msg": "Signature threshold already set" + }, + { + "code": 6005, + "name": "invalidOwner", + "msg": "Invalid owner" + }, + { + "code": 6006, + "name": "invalidPauser", + "msg": "Invalid pauser" + }, + { + "code": 6007, + "name": "invalidAttesterManager", + "msg": "Invalid attester manager" + }, + { + "code": 6008, + "name": "invalidAttester", + "msg": "Invalid attester" + }, + { + "code": 6009, + "name": "attesterAlreadyEnabled", + "msg": "Attester already enabled" + }, + { + "code": 6010, + "name": "tooFewEnabledAttesters", + "msg": "Too few enabled attesters" + }, + { + "code": 6011, + "name": "signatureThresholdTooLow", + "msg": "Signature threshold is too low" + }, + { + "code": 6012, + "name": "attesterAlreadyDisabled", + "msg": "Attester already disabled" + }, + { + "code": 6013, + "name": "messageBodyLimitExceeded", + "msg": "Message body exceeds max size" + }, + { + "code": 6014, + "name": "invalidDestinationCaller", + "msg": "Invalid destination caller" + }, + { + "code": 6015, + "name": "invalidRecipient", + "msg": "Invalid message recipient" + }, + { + "code": 6016, + "name": "senderNotPermitted", + "msg": "Sender is not permitted" + }, + { + "code": 6017, + "name": "invalidSourceDomain", + "msg": "Invalid source domain" + }, + { + "code": 6018, + "name": "invalidDestinationDomain", + "msg": "Invalid destination domain" + }, + { + "code": 6019, + "name": "invalidMessageVersion", + "msg": "Invalid message version" + }, + { + "code": 6020, + "name": "invalidUsedNoncesAccount", + "msg": "Invalid used nonces account" + }, + { + "code": 6021, + "name": "invalidRecipientProgram", + "msg": "Invalid recipient program" + }, + { + "code": 6022, + "name": "invalidNonce", + "msg": "Invalid nonce" + }, + { + "code": 6023, + "name": "nonceAlreadyUsed", + "msg": "Nonce already used" + }, + { + "code": 6024, + "name": "messageTooShort", + "msg": "Message is too short" + }, + { + "code": 6025, + "name": "malformedMessage", + "msg": "Malformed message" + }, + { + "code": 6026, + "name": "invalidSignatureOrderOrDupe", + "msg": "Invalid signature order or dupe" + }, + { + "code": 6027, + "name": "invalidAttesterSignature", + "msg": "Invalid attester signature" + }, + { + "code": 6028, + "name": "invalidAttestationLength", + "msg": "Invalid attestation length" + }, + { + "code": 6029, + "name": "invalidSignatureRecoveryId", + "msg": "Invalid signature recovery ID" + }, + { + "code": 6030, + "name": "invalidSignatureSValue", + "msg": "Invalid signature S value" + }, + { + "code": 6031, + "name": "invalidMessageHash", + "msg": "Invalid message hash" + }, + { + "code": 6032, + "name": "invalidDestinationMessage", + "msg": "Invalid destination message" + }, + { + "code": 6033, + "name": "eventAccountWindowNotExpired", + "msg": "Event account window not expired" + }, + { + "code": 6034, + "name": "destinationDomainIsLocalDomain", + "msg": "Destination domain is local domain" + } + ], + "types": [ + { + "name": "acceptOwnershipParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "attesterDisabled", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "attesterEnabled", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "attesterManagerUpdated", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previousAttesterManager", + "type": "pubkey" + }, + { + "name": "newAttesterManager", + "type": "pubkey" + } + ] + } + }, + { + "name": "disableAttesterParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attester", + "type": "pubkey" + } + ] + } + }, + { + "name": "enableAttesterParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newAttester", + "type": "pubkey" + } + ] + } + }, + { + "name": "initializeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "localDomain", + "type": "u32" + }, + { + "name": "attester", + "type": "pubkey" + }, + { + "name": "maxMessageBodySize", + "type": "u64" + }, + { + "name": "version", + "type": "u32" + } + ] + } + }, + { + "name": "maxMessageBodySizeUpdated", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newMaxMessageBodySize", + "type": "u64" + } + ] + } + }, + { + "name": "messageReceived", + "type": { + "kind": "struct", + "fields": [ + { + "name": "caller", + "type": "pubkey" + }, + { + "name": "sourceDomain", + "type": "u32" + }, + { + "name": "nonce", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "sender", + "type": "pubkey" + }, + { + "name": "finalityThresholdExecuted", + "type": "u32" + }, + { + "name": "messageBody", + "type": "bytes" + } + ] + } + }, + { + "name": "messageSent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rentPayer", + "type": "pubkey" + }, + { + "name": "createdAt", + "type": "i64" + }, + { + "name": "message", + "type": "bytes" + } + ] + } + }, + { + "name": "messageTransmitter", + "docs": [ + "Main state of the MessageTransmitter program" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "pendingOwner", + "type": "pubkey" + }, + { + "name": "attesterManager", + "type": "pubkey" + }, + { + "name": "pauser", + "type": "pubkey" + }, + { + "name": "paused", + "type": "bool" + }, + { + "name": "localDomain", + "type": "u32" + }, + { + "name": "version", + "type": "u32" + }, + { + "name": "signatureThreshold", + "type": "u32" + }, + { + "name": "enabledAttesters", + "type": { + "vec": "pubkey" + } + }, + { + "name": "maxMessageBodySize", + "type": "u64" + } + ] + } + }, + { + "name": "ownershipTransferStarted", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previousOwner", + "type": "pubkey" + }, + { + "name": "newOwner", + "type": "pubkey" + } + ] + } + }, + { + "name": "ownershipTransferred", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previousOwner", + "type": "pubkey" + }, + { + "name": "newOwner", + "type": "pubkey" + } + ] + } + }, + { + "name": "pause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "pauseParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "pauserChanged", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newAddress", + "type": "pubkey" + } + ] + } + }, + { + "name": "receiveMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "message", + "type": "bytes" + }, + { + "name": "attestation", + "type": "bytes" + } + ] + } + }, + { + "name": "reclaimEventAccountParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attestation", + "type": "bytes" + }, + { + "name": "destinationMessage", + "type": "bytes" + } + ] + } + }, + { + "name": "sendMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "destinationDomain", + "type": "u32" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "destinationCaller", + "type": "pubkey" + }, + { + "name": "minFinalityThreshold", + "type": "u32" + }, + { + "name": "messageBody", + "type": "bytes" + } + ] + } + }, + { + "name": "setMaxMessageBodySizeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newMaxMessageBodySize", + "type": "u64" + } + ] + } + }, + { + "name": "setSignatureThresholdParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newSignatureThreshold", + "type": "u32" + } + ] + } + }, + { + "name": "signatureThresholdUpdated", + "type": { + "kind": "struct", + "fields": [ + { + "name": "oldSignatureThreshold", + "type": "u32" + }, + { + "name": "newSignatureThreshold", + "type": "u32" + } + ] + } + }, + { + "name": "transferOwnershipParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newOwner", + "type": "pubkey" + } + ] + } + }, + { + "name": "unpause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "unpauseParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "updateAttesterManagerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newAttesterManager", + "type": "pubkey" + } + ] + } + }, + { + "name": "updatePauserParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newPauser", + "type": "pubkey" + } + ] + } + }, + { + "name": "usedNonce", + "type": { + "kind": "struct", + "fields": [ + { + "name": "isUsed", + "type": "bool" + } + ] + } + } + ] +}; diff --git a/src/svm/assets/multicall_handler.ts b/src/svm/assets/multicall_handler.ts new file mode 100644 index 000000000..81be4b1df --- /dev/null +++ b/src/svm/assets/multicall_handler.ts @@ -0,0 +1,37 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/multicall_handler.json`. + */ +export type MulticallHandler = { + "address": "HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be", + "metadata": { + "name": "multicallHandler", + "version": "0.1.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "handleV3AcrossMessage", + "discriminator": [ + 131, + 141, + 52, + 71, + 16, + 59, + 196, + 92 + ], + "accounts": [], + "args": [ + { + "name": "message", + "type": "bytes" + } + ] + } + ] +}; diff --git a/src/svm/assets/sponsored_cctp_src_periphery.ts b/src/svm/assets/sponsored_cctp_src_periphery.ts new file mode 100644 index 000000000..cded111ed --- /dev/null +++ b/src/svm/assets/sponsored_cctp_src_periphery.ts @@ -0,0 +1,1971 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/sponsored_cctp_src_periphery.json`. + */ +export type SponsoredCctpSrcPeriphery = { + "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq", + "metadata": { + "name": "sponsoredCctpSrcPeriphery", + "version": "0.1.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "docs": [ + "# Across Sponsored CCTP Source Periphery", + "", + "Source chain periphery program for users to interact with to start a sponsored or a non-sponsored flow that allows", + "custom Across-supported flows on destination chain. Uses Circle's CCTPv2 as an underlying bridge" + ], + "instructions": [ + { + "name": "depositForBurn", + "docs": [ + "Verifies a sponsored CCTP quote, records its nonce, and burns the user's tokens via CCTPv2 with hook data.", + "", + "The user's depositor ATA is burned via `deposit_for_burn_with_hook` CPI on the CCTPv2. The rent cost for the", + "per-quote `used_nonce` PDA is refunded to the signer from the `rent_fund` and `rent_fund` also funds the", + "creation of CCTP `MessageSent` event account.", + "On success, this emits a `SponsoredDepositForBurn` event to be consumed by offchain infrastructure. This also", + "emits a `CreatedEventAccount` event containing the address of the created CCTP `MessageSent` event account that", + "can be reclaimed later using the `reclaim_event_account` instruction.", + "", + "Required Accounts:", + "- signer (Signer, Writable): The user authorizing the burn.", + "- state (Account): Program state PDA. Seed: [\"state\"].", + "- rent_fund (SystemAccount, Writable): PDA used to sponsor rent and event accounts. Seed: [\"rent_fund\"].", + "- minimum_deposit (Account): Minimum deposit state PDA. Seed: [\"minimum_deposit\", burn_token.key()].", + "- used_nonce (Account, Writable, Init): Per-quote nonce PDA. Seed: [\"used_nonce\", nonce].", + "- rent_claim (Optional Account, Writable, Init-If-Needed): Optional PDA to accrue rent_fund debt to the user.", + "Seed: [\"rent_claim\", signer.key()].", + "- depositor_token_account (InterfaceAccount, Writable): Signer ATA of the burn token.", + "- burn_token (InterfaceAccount, Mutable): Mint of the token to burn. Must match quote.burn_token.", + "- denylist_account (Unchecked): CCTP denylist PDA, validated within CCTP.", + "- token_messenger_minter_sender_authority (Unchecked): CCTP sender authority PDA.", + "- message_transmitter (Unchecked, Mutable): CCTP MessageTransmitter account.", + "- token_messenger (Unchecked): CCTP TokenMessenger account.", + "- remote_token_messenger (Unchecked): Remote TokenMessenger account for destination domain.", + "- token_minter (Unchecked): CCTP TokenMinter account.", + "- local_token (Unchecked, Mutable): Local token account (CCTP).", + "- cctp_event_authority (Unchecked): CCTP event authority account.", + "- message_sent_event_data (Signer, Mutable): Fresh account to store CCTP MessageSent event data.", + "- message_transmitter_program (Program): CCTPv2 MessageTransmitter program.", + "- token_messenger_minter_program (Program): CCTPv2 TokenMessengerMinter program.", + "- token_program (Interface): SPL token program.", + "- system_program (Program): System program.", + "", + "Parameters:", + "- quote: SponsoredCCTPQuote struct serialized by Anchor:", + "- source_domain: CCTP domain ID of the source chain.", + "- destination_domain: CCTP domain ID of the destination chain.", + "- mint_recipient: The recipient of the minted tokens on the destination chain.", + "- amount: The amount of tokens that the user pays on the source chain.", + "- burn_token: The token that will be burned on the source chain.", + "- destination_caller: The caller of the destination chain.", + "- max_fee: Maximum fee to pay on the destination domain, specified in units of burn_token.", + "- min_finality_threshold: Minimum finality threshold before allowed to attest.", + "- nonce: Nonce is used to prevent replay attacks.", + "- deadline: Timestamp of the quote after which it can no longer be used.", + "- max_bps_to_sponsor: The maximum basis points of the amount that can be sponsored.", + "- max_user_slippage_bps: Slippage tolerance for the fees on the destination. Used in swap flow, enforced on", + "destination.", + "- final_recipient: The final recipient of the sponsored deposit. This is needed as the mint_recipient will be", + "the handler contract address instead of the final recipient.", + "- final_token: The final token that final recipient will receive. This is needed as it can be different from", + "the burn_token in which case we perform a swap on the destination chain.", + "- execution_mode: Execution mode: DirectToCore (0), ArbitraryActionsToCore (1), or ArbitraryActionsToEVM (2).", + "- action_data: Encoded action data for arbitrary execution. Empty for DirectToCore mode.", + "- signature: 65-byte EVM signature authorizing the quote by the trusted signer.", + "", + "Notes:", + "- The upgrade authority must have set the valid EVM signer for this instruction to succeed.", + "- The operator of this program must have funded the `rent_fund` PDA with sufficient lamports to cover", + "rent for the `used_nonce` PDA and the CCTP `MessageSent` event account." + ], + "discriminator": [ + 215, + 60, + 61, + 46, + 114, + 55, + 128, + 176 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "rentFund", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 102, + 117, + 110, + 100 + ] + } + ] + } + }, + { + "name": "minimumDeposit", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 105, + 110, + 105, + 109, + 117, + 109, + 95, + 100, + 101, + 112, + 111, + 115, + 105, + 116 + ] + }, + { + "kind": "account", + "path": "burnToken" + } + ] + } + }, + { + "name": "usedNonce", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 100, + 95, + 110, + 111, + 110, + 99, + 101 + ] + }, + { + "kind": "arg", + "path": "params.quote.nonce" + } + ] + } + }, + { + "name": "rentClaim", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 99, + 108, + 97, + 105, + 109 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "depositorTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "signer" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "burnToken" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "burnToken", + "writable": true + }, + { + "name": "denylistAccount" + }, + { + "name": "tokenMessengerMinterSenderAuthority" + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "tokenMessenger" + }, + { + "name": "remoteTokenMessenger" + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true + }, + { + "name": "cctpEventAuthority" + }, + { + "name": "messageSentEventData", + "writable": true, + "signer": true + }, + { + "name": "messageTransmitterProgram", + "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" + }, + { + "name": "tokenMessengerMinterProgram", + "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" + }, + { + "name": "tokenProgram" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "depositForBurnParams" + } + } + } + ] + }, + { + "name": "getUsedNonceCloseInfo", + "docs": [ + "Returns whether a `used_nonce` PDA can be closed now and the timestamp after which it can be closed.", + "", + "This is a convenience \"view\" helper for off-chain systems to determine when rent can be reclaimed for a", + "specific quote nonce.", + "", + "Required Accounts:", + "- state (Account): Program state PDA. Seed: [\"state\"].", + "- used_nonce (Account): The `used_nonce` PDA. Seed: [\"used_nonce\", nonce].", + "", + "Parameters:", + "- _params.nonce: The 32-byte nonce identifying the PDA to check.", + "", + "Returns:", + "- UsedNonceCloseInfo { can_close_after, can_close_now }" + ], + "discriminator": [ + 19, + 183, + 42, + 151, + 118, + 234, + 57, + 92 + ], + "accounts": [ + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "usedNonce", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 100, + 95, + 110, + 111, + 110, + 99, + 101 + ] + }, + { + "kind": "arg", + "path": "_params.nonce" + } + ] + } + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "usedNonceAccountParams" + } + } + } + ], + "returns": { + "defined": { + "name": "usedNonceCloseInfo" + } + } + }, + { + "name": "initialize", + "docs": [ + "Initializes immutable program state and sets the trusted EVM quote signer.", + "", + "This can only be called once by the upgrade authority. It stores the local CCTP source domain and the", + "quote `signer` that must authorize sponsored deposits.", + "", + "Required Accounts:", + "- signer (Signer, Writable): Must be the program upgrade authority.", + "- state (Writable): Program state PDA. Seed: [\"state\"].", + "- program_data (Account): Program data account to verify the upgrade authority.", + "- this_program (Program): This program account, used to resolve `programdata_address`.", + "- system_program (Program): System program for account creation.", + "", + "Parameters:", + "- source_domain: CCTP domain for this chain (e.g., 5 for Solana).", + "- signer: EVM address (encoded as `Pubkey`) authorized to sign sponsored quotes." + ], + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "programData" + }, + { + "name": "thisProgram", + "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "initializeParams" + } + } + } + ] + }, + { + "name": "reclaimEventAccount", + "docs": [ + "Reclaims the CCTP `MessageSent` event account, returning rent to the rent fund.", + "", + "Required Accounts:", + "- rent_fund (SystemAccount, Writable): PDA to receive reclaimed lamports. Seed: [\"rent_fund\"].", + "- message_transmitter (Unchecked, Mutable): CCTP MessageTransmitter account.", + "- message_sent_event_data (Account, Mutable): The `MessageSent` event account created during `deposit_for_burn`.", + "- message_transmitter_program (Program): CCTPv2 MessageTransmitter program.", + "", + "Parameters:", + "- params: Parameters struct required to construct reclaim_event_account instruction on the CCTPv2.", + "- attestation: Attestation obtained from the CCTP attestation service.", + "- nonce: bytes32 from the attested destination message.", + "- finality_threshold_executed: uint32 BE encoded from the attested destination message.", + "- fee_executed: uint256 BE encoded from the attested destination message body.", + "- expiration_block: uint256 BE encoded from the attested destination message body.", + "", + "Notes:", + "- This can only be called after the CCTP attestation service has processed the message and sufficient time has", + "passed since the `MessageSent` event was created. The operator can track the closable accounts from the", + "emitted `CreatedEventAccount` events and using the `EVENT_ACCOUNT_WINDOW_SECONDS` set in CCTP program." + ], + "discriminator": [ + 94, + 198, + 180, + 159, + 131, + 236, + 15, + 174 + ], + "accounts": [ + { + "name": "rentFund", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 102, + 117, + 110, + 100 + ] + } + ] + } + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "messageSentEventData", + "writable": true + }, + { + "name": "messageTransmitterProgram", + "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "reclaimEventAccountParams" + } + } + } + ] + }, + { + "name": "reclaimUsedNonceAccount", + "docs": [ + "Closes a `used_nonce` PDA once its quote deadline has passed, returning rent to the rent fund.", + "", + "Required Accounts:", + "- state (Account): Program state PDA. Seed: [\"state\"]. Used to fetch current time.", + "- rent_fund (SystemAccount, Writable): PDA receiving lamports upon close. Seed: [\"rent_fund\"].", + "- used_nonce (Account, Writable, Close=rent_fund): PDA to close. Seed: [\"used_nonce\", nonce].", + "", + "Parameters:", + "- params.nonce: The 32-byte nonce identifying the PDA to close.", + "", + "Notes:", + "- This can only be called after the quote's deadline has passed. The operator can track closable `used_nonce`", + "accounts from the emitted `SponsoredDepositForBurn` events (`quote_nonce` and `quote_deadline`) and using the", + "`get_used_nonce_close_info` helper." + ], + "discriminator": [ + 153, + 152, + 111, + 172, + 156, + 104, + 116, + 3 + ], + "accounts": [ + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "rentFund", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 102, + 117, + 110, + 100 + ] + } + ] + } + }, + { + "name": "usedNonce", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 117, + 115, + 101, + 100, + 95, + 110, + 111, + 110, + 99, + 101 + ] + }, + { + "kind": "arg", + "path": "params.nonce" + } + ] + } + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "usedNonceAccountParams" + } + } + } + ] + }, + { + "name": "repayRentFundDebt", + "docs": [ + "Repays rent_fund liability for a user if rent_fund had insufficient balance at the time of deposit.", + "", + "Required Accounts:", + "- rent_fund (SystemAccount, Writable): PDA used to sponsor rent and event accounts. Seed: [\"rent_fund\"].", + "- recipient (Unchecked, Writable): The user account to repay rent fund debt to.", + "- rent_claim (Account, Writable, Close=recipient): PDA with accrued rent_fund debt to the user.", + "Seed: [\"rent_claim\", recipient.key()].", + "- system_program (Program): System program." + ], + "discriminator": [ + 111, + 95, + 222, + 174, + 241, + 41, + 61, + 78 + ], + "accounts": [ + { + "name": "rentFund", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 102, + 117, + 110, + 100 + ] + } + ] + } + }, + { + "name": "recipient", + "writable": true + }, + { + "name": "rentClaim", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 99, + 108, + 97, + 105, + 109 + ] + }, + { + "kind": "account", + "path": "recipient" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "setCurrentTime", + "docs": [ + "Sets the current time in test mode. No-op on mainnet builds.", + "", + "Required Accounts:", + "- state (Writable): Program state PDA. Seed: [\"state\"].", + "- signer (Signer): Any signer. Only enabled when built with `--features test`.", + "", + "Parameters:", + "- new_time: New unix timestamp to set for tests." + ], + "discriminator": [ + 69, + 100, + 169, + 193, + 125, + 0, + 150, + 69 + ], + "accounts": [ + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "signer", + "signer": true + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setCurrentTimeParams" + } + } + } + ] + }, + { + "name": "setMinimumDepositAmount", + "docs": [ + "Updates the minimum deposit amount for a given burn token.", + "", + "Only callable by the upgrade authority. This must be set at least once for a supported burn token as otherwise", + "deposits would be blocked.", + "", + "Required Accounts:", + "- signer (Signer, Writable): Must be the program upgrade authority.", + "- minimum_deposit (Writable): Minimum deposit state PDA. Seed: [\"minimum_deposit\", burn_token.key()].", + "- burn_token: Supported burn token for which the minimum deposit amount is being set.", + "- program_data (Account): Program data account to verify the upgrade authority.", + "- this_program (Program): This program account, used to resolve `programdata_address`.", + "- system_program (Program): System program for transfers.", + "", + "Parameters:", + "- amount: New minimum deposit amount for a given burn token." + ], + "discriminator": [ + 176, + 4, + 74, + 229, + 206, + 148, + 151, + 138 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "minimumDeposit", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 105, + 110, + 105, + 109, + 117, + 109, + 95, + 100, + 101, + 112, + 111, + 115, + 105, + 116 + ] + }, + { + "kind": "account", + "path": "burnToken" + } + ] + } + }, + { + "name": "burnToken" + }, + { + "name": "programData" + }, + { + "name": "thisProgram", + "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setMinimumDepositAmountParams" + } + } + } + ] + }, + { + "name": "setSigner", + "docs": [ + "Updates the trusted EVM quote signer.", + "", + "Only callable by the upgrade authority. Setting this to an invalid address (including `Pubkey::default()`) will", + "effectively disable deposits.", + "", + "Required Accounts:", + "- signer (Signer, Writable): Must be the program upgrade authority.", + "- state (Writable): Program state PDA. Seed: [\"state\"].", + "- program_data (Account): Program data account to verify the upgrade authority.", + "- this_program (Program): This program account, used to resolve `programdata_address`.", + "", + "Parameters:", + "- new_signer: New EVM signer address (encoded as `Pubkey`)." + ], + "discriminator": [ + 127, + 120, + 252, + 184, + 97, + 4, + 88, + 68 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + } + ] + } + }, + { + "name": "programData" + }, + { + "name": "thisProgram", + "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setSignerParams" + } + } + } + ] + }, + { + "name": "withdrawRentFund", + "docs": [ + "Withdraws lamports from the rent fund PDA to an arbitrary recipient.", + "", + "The rent fund is used to sponsor temporary account creation (e.g., CCTP event accounts or per-quote nonce PDAs).", + "Only callable by the upgrade authority.", + "", + "Required Accounts:", + "- signer (Signer, Writable): Must be the program upgrade authority.", + "- rent_fund (SystemAccount, Writable): PDA holding lamports used for rent sponsorship. Seed: [\"rent_fund\"].", + "- recipient (UncheckedAccount, Writable): Destination account for the withdrawn lamports.", + "- program_data (Account): Program data account to verify the upgrade authority.", + "- this_program (Program): This program account, used to resolve `programdata_address`.", + "- system_program (Program): System program for transfers.", + "", + "Parameters:", + "- amount: Amount of lamports to transfer to the recipient." + ], + "discriminator": [ + 153, + 28, + 108, + 116, + 132, + 70, + 161, + 125 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "rentFund", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 110, + 116, + 95, + 102, + 117, + 110, + 100 + ] + } + ] + } + }, + { + "name": "recipient", + "writable": true + }, + { + "name": "programData" + }, + { + "name": "thisProgram", + "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "withdrawRentFundParams" + } + } + } + ] + } + ], + "accounts": [ + { + "name": "messageSent", + "discriminator": [ + 131, + 100, + 133, + 56, + 166, + 225, + 151, + 60 + ] + }, + { + "name": "minimumDeposit", + "discriminator": [ + 218, + 139, + 120, + 202, + 3, + 12, + 233, + 65 + ] + }, + { + "name": "rentClaim", + "discriminator": [ + 13, + 5, + 183, + 82, + 60, + 122, + 72, + 11 + ] + }, + { + "name": "state", + "discriminator": [ + 216, + 146, + 107, + 94, + 104, + 75, + 182, + 177 + ] + }, + { + "name": "usedNonce", + "discriminator": [ + 212, + 222, + 157, + 252, + 130, + 71, + 179, + 238 + ] + } + ], + "events": [ + { + "name": "accruedRentFundLiability", + "discriminator": [ + 56, + 17, + 203, + 169, + 27, + 139, + 36, + 225 + ] + }, + { + "name": "createdEventAccount", + "discriminator": [ + 178, + 224, + 189, + 92, + 50, + 100, + 128, + 204 + ] + }, + { + "name": "minimumDepositAmountSet", + "discriminator": [ + 134, + 237, + 176, + 205, + 21, + 44, + 95, + 177 + ] + }, + { + "name": "reclaimedEventAccount", + "discriminator": [ + 210, + 180, + 74, + 27, + 92, + 74, + 46, + 216 + ] + }, + { + "name": "reclaimedUsedNonceAccount", + "discriminator": [ + 6, + 199, + 109, + 7, + 58, + 150, + 119, + 103 + ] + }, + { + "name": "repaidRentFundDebt", + "discriminator": [ + 134, + 86, + 59, + 173, + 10, + 250, + 191, + 190 + ] + }, + { + "name": "signerSet", + "discriminator": [ + 137, + 203, + 187, + 74, + 141, + 187, + 226, + 95 + ] + }, + { + "name": "sponsoredDepositForBurn", + "discriminator": [ + 55, + 106, + 70, + 41, + 59, + 102, + 172, + 42 + ] + }, + { + "name": "withdrawnRentFund", + "discriminator": [ + 110, + 180, + 127, + 254, + 32, + 122, + 209, + 22 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "notUpgradeAuthority", + "msg": "Only the upgrade authority can call this instruction" + }, + { + "code": 6001, + "name": "invalidProgramData", + "msg": "Invalid program data account" + }, + { + "code": 6002, + "name": "cannotSetCurrentTime", + "msg": "Cannot set time if not in test mode" + }, + { + "code": 6003, + "name": "invalidBurnToken", + "msg": "Invalid burn_token key" + }, + { + "code": 6004, + "name": "amountNotPositive", + "msg": "Amount must be greater than 0" + }, + { + "code": 6005, + "name": "quoteDeadlineNotPassed", + "msg": "The quote deadline has not passed!" + }, + { + "code": 6006, + "name": "signerUnchanged", + "msg": "New signer unchanged" + }, + { + "code": 6007, + "name": "depositAmountBelowMinimum", + "msg": "Deposit amount below minimum" + }, + { + "code": 6008, + "name": "missingRentClaimAccount", + "msg": "Missing rent claim account" + }, + { + "code": 6009, + "name": "rentClaimOverflow", + "msg": "Rent claim amount overflow" + }, + { + "code": 6010, + "name": "invalidRecipientKey", + "msg": "Invalid recipient key" + } + ], + "types": [ + { + "name": "accruedRentFundLiability", + "type": { + "kind": "struct", + "fields": [ + { + "name": "user", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "totalUserClaim", + "type": "u64" + } + ] + } + }, + { + "name": "createdEventAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "messageSentEventData", + "type": "pubkey" + } + ] + } + }, + { + "name": "depositForBurnParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "quote", + "type": { + "defined": { + "name": "sponsoredCctpQuote" + } + } + }, + { + "name": "signature", + "type": { + "array": [ + "u8", + 65 + ] + } + } + ] + } + }, + { + "name": "initializeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "sourceDomain", + "type": "u32" + }, + { + "name": "signer", + "type": "pubkey" + } + ] + } + }, + { + "name": "messageSent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rentPayer", + "type": "pubkey" + }, + { + "name": "createdAt", + "type": "i64" + }, + { + "name": "message", + "type": "bytes" + } + ] + } + }, + { + "name": "minimumDeposit", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "minimumDepositAmountSet", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "burnToken", + "type": "pubkey" + } + ] + } + }, + { + "name": "reclaimEventAccountParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "attestation", + "type": "bytes" + }, + { + "name": "nonce", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "finalityThresholdExecuted", + "type": { + "array": [ + "u8", + 4 + ] + } + }, + { + "name": "feeExecuted", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "expirationBlock", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "reclaimedEventAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "messageSentEventData", + "type": "pubkey" + } + ] + } + }, + { + "name": "reclaimedUsedNonceAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nonce", + "type": "bytes" + }, + { + "name": "usedNonce", + "type": "pubkey" + } + ] + } + }, + { + "name": "rentClaim", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "repaidRentFundDebt", + "type": { + "kind": "struct", + "fields": [ + { + "name": "user", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "remainingUserClaim", + "type": "u64" + } + ] + } + }, + { + "name": "setCurrentTimeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newTime", + "type": "u64" + } + ] + } + }, + { + "name": "setMinimumDepositAmountParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "setSignerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newSigner", + "type": "pubkey" + } + ] + } + }, + { + "name": "signerSet", + "type": { + "kind": "struct", + "fields": [ + { + "name": "oldSigner", + "type": "pubkey" + }, + { + "name": "newSigner", + "type": "pubkey" + } + ] + } + }, + { + "name": "sponsoredCctpQuote", + "type": { + "kind": "struct", + "fields": [ + { + "name": "sourceDomain", + "type": "u32" + }, + { + "name": "destinationDomain", + "type": "u32" + }, + { + "name": "mintRecipient", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "burnToken", + "type": "pubkey" + }, + { + "name": "destinationCaller", + "type": "pubkey" + }, + { + "name": "maxFee", + "type": "u64" + }, + { + "name": "minFinalityThreshold", + "type": "u32" + }, + { + "name": "nonce", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "deadline", + "type": "u64" + }, + { + "name": "maxBpsToSponsor", + "type": "u64" + }, + { + "name": "maxUserSlippageBps", + "type": "u64" + }, + { + "name": "finalRecipient", + "type": "pubkey" + }, + { + "name": "finalToken", + "type": "pubkey" + }, + { + "name": "destinationDex", + "type": "u32" + }, + { + "name": "accountCreationMode", + "type": "u8" + }, + { + "name": "executionMode", + "type": "u8" + }, + { + "name": "actionData", + "type": "bytes" + } + ] + } + }, + { + "name": "sponsoredDepositForBurn", + "type": { + "kind": "struct", + "fields": [ + { + "name": "quoteNonce", + "type": "bytes" + }, + { + "name": "originSender", + "type": "pubkey" + }, + { + "name": "finalRecipient", + "type": "pubkey" + }, + { + "name": "quoteDeadline", + "type": "u64" + }, + { + "name": "maxBpsToSponsor", + "type": "u64" + }, + { + "name": "maxUserSlippageBps", + "type": "u64" + }, + { + "name": "finalToken", + "type": "pubkey" + }, + { + "name": "destinationDex", + "type": "u32" + }, + { + "name": "accountCreationMode", + "type": "u8" + }, + { + "name": "signature", + "type": "bytes" + } + ] + } + }, + { + "name": "state", + "type": { + "kind": "struct", + "fields": [ + { + "name": "sourceDomain", + "type": "u32" + }, + { + "name": "signer", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "usedNonce", + "type": { + "kind": "struct", + "fields": [ + { + "name": "quoteDeadline", + "type": "u64" + } + ] + } + }, + { + "name": "usedNonceAccountParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nonce", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "usedNonceCloseInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "canCloseAfter", + "type": "u64" + }, + { + "name": "canCloseNow", + "type": "bool" + } + ] + } + }, + { + "name": "withdrawRentFundParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "withdrawnRentFund", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "recipient", + "type": "pubkey" + } + ] + } + } + ] +}; diff --git a/src/svm/assets/svm_spoke.ts b/src/svm/assets/svm_spoke.ts new file mode 100644 index 000000000..a22419014 --- /dev/null +++ b/src/svm/assets/svm_spoke.ts @@ -0,0 +1,5502 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/svm_spoke.json`. + */ +export type SvmSpoke = { + "address": "DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru", + "metadata": { + "name": "svmSpoke", + "version": "0.1.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "bridgeTokensToHubPool", + "docs": [ + "Bridges tokens to the Hub Pool.", + "", + "This function initiates the process of sending tokens from the vault to the Hub Pool based on the outstanding", + "token liability this Spoke Pool has accrued. Enables the caller to choose a custom amount to work around CCTP", + "bridging limits. enforces that amount is less than or equal to liability. On execution decrements liability.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the bridge operation.", + "- payer (Signer): The account responsible for paying the transaction fees.", + "- mint (InterfaceAccount): The mint account for the token being bridged.", + "- state (Account): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- transfer_liability (Account): Account tracking the pending amount to be sent to the Hub Pool. Incremented on", + "relayRootBundle() and decremented on when this function is called. Seed: [\"transfer_liability\",mint].", + "- vault (InterfaceAccount): The ATA for the token being bridged. Authority must be the state.", + "- token_messenger_minter_sender_authority (UncheckedAccount): Authority for the token messenger minter.", + "- message_transmitter (UncheckedAccount): Account for the message transmitter.", + "- token_messenger (UncheckedAccount): Account for the token messenger.", + "- remote_token_messenger (UncheckedAccount): Account for the remote token messenger.", + "- token_minter (UncheckedAccount): Account for the token minter.", + "- local_token (UncheckedAccount): Account for the local token.", + "- cctp_event_authority (UncheckedAccount): Authority for CCTP events.", + "- message_sent_event_data (Signer): Account for message sent event data.", + "- message_transmitter_program (Program): Program for the message transmitter.", + "- token_messenger_minter_program (Program): Program for the token messenger minter.", + "- token_program (Interface): The token program.", + "- system_program (Program): The system program.", + "", + "### Parameters:", + "- amount: The amount of tokens to bridge to the Hub Pool." + ], + "discriminator": [ + 1, + 83, + 255, + 59, + 232, + 55, + 64, + 216 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "mint", + "writable": true + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "transferLiability", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 114, + 97, + 110, + 115, + 102, + 101, + 114, + 95, + 108, + 105, + 97, + 98, + 105, + 108, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "mint" + } + ] + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "tokenMessengerMinterSenderAuthority" + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "tokenMessenger" + }, + { + "name": "remoteTokenMessenger" + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true + }, + { + "name": "cctpEventAuthority" + }, + { + "name": "messageSentEventData", + "writable": true, + "signer": true + }, + { + "name": "messageTransmitterProgram", + "address": "CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd" + }, + { + "name": "tokenMessengerMinterProgram", + "address": "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3" + }, + { + "name": "tokenProgram" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "claimRelayerRefund", + "docs": [ + "Claims a relayer refund for the caller.", + "", + "In the event a relayer refund was sent to a claim account, then this function enables the relayer to claim it by", + "transferring the claim amount from the vault to their token account. The claim account is closed after refund.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the claim.", + "- initializer (UncheckedAccount): Must be the same account that initialized the claim account.", + "- state (Account): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- vault (InterfaceAccount): The ATA for the refunded mint. Authority must be the state.", + "- mint (InterfaceAccount): The mint account for the token being refunded.", + "- refund_address: token account authority receiving the refund.", + "- token_account (InterfaceAccount): The receiving token account for the refund. When refund_address is different", + "from the signer, this must match its ATA.", + "- claim_account (Account): The claim account PDA. Seed: [\"claim_account\",mint,refund_address].", + "- token_program (Interface): The token program." + ], + "discriminator": [ + 205, + 34, + 34, + 224, + 204, + 103, + 81, + 176 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "initializer", + "writable": true + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "mint" + }, + { + "name": "refundAddress" + }, + { + "name": "tokenAccount", + "writable": true + }, + { + "name": "claimAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 108, + 97, + 105, + 109, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "account", + "path": "mint" + }, + { + "kind": "account", + "path": "refundAddress" + } + ] + } + }, + { + "name": "tokenProgram" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "closeClaimAccount", + "docs": [ + "Closes a claim account for a relayer refund.", + "", + "This function is used to close the claim account associated with a specific mint and refund address,", + "effectively marking the end of its lifecycle. It can only be called once the claim account is empty. It", + "transfers any remaining lamports to the signer and resets the account.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the closure. Must be the initializer of the claim account.", + "- mint: The mint associated with the claim account.", + "- refund_address: The refund address associated with the claim account.", + "- claim_account (Writable): The claim account PDA to be closed. Seed: [\"claim_account\",mint,refund_address]." + ], + "discriminator": [ + 241, + 146, + 203, + 216, + 58, + 222, + 91, + 118 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "mint" + }, + { + "name": "refundAddress" + }, + { + "name": "claimAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 108, + 97, + 105, + 109, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "account", + "path": "mint" + }, + { + "kind": "account", + "path": "refundAddress" + } + ] + } + } + ], + "args": [] + }, + { + "name": "closeFillPda", + "docs": [ + "Closes the FillStatusAccount PDA to reclaim relayer rent.", + "", + "This function is used to close the FillStatusAccount associated with a specific relay hash, effectively marking", + "the end of its lifecycle. This can only be done once the fill deadline has passed. Relayers should do this for", + "all fills once they expire to reclaim their rent.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the closure. Must be the relayer in the fill_status PDA.", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- fill_status (Writable): The FillStatusAccount PDA to be closed." + ], + "discriminator": [ + 224, + 39, + 208, + 68, + 8, + 226, + 23, + 214 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "fillStatus", + "writable": true + } + ], + "args": [] + }, + { + "name": "closeInstructionParams", + "docs": [ + "Closes the instruction parameters account.", + "", + "This function is used to close the instruction parameters account, effectively marking the end of its lifecycle.", + "It transfers any remaining lamports to the signer and resets the account.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the closure.", + "- instruction_params (UncheckedAccount): The account to be closed. seed: [\"instruction_params\",signer]. Not", + "the signer being within the seed here implicitly protects this from only being called by the creator." + ], + "discriminator": [ + 224, + 44, + 254, + 10, + 216, + 8, + 172, + 96 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "instructionParams", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + } + ], + "args": [] + }, + { + "name": "createTokenAccounts", + "docs": [ + "Creates token accounts in batch for a set of addresses.", + "", + "This helper function allows the caller to pass in a set of remaining accounts to create a batch of Associated", + "Token Accounts (ATAs) for addresses. It is particularly useful for relayers to call before filling a deposit.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the creation of token accounts.", + "- mint (InterfaceAccount): The mint account for the token.", + "- token_program (Interface): The token program.", + "- associated_token_program (Program): The associated token program.", + "- system_program (Program): The system program required for account creation." + ], + "discriminator": [ + 163, + 216, + 49, + 204, + 97, + 16, + 80, + 167 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "mint" + }, + { + "name": "tokenProgram" + }, + { + "name": "associatedTokenProgram", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "deposit", + "docs": [ + "Request to bridge input_token to a target chain and receive output_token.", + "", + "The fee paid to relayers and the system is captured in the spread between the input and output amounts,", + "denominated in the input token. A relayer on the destination chain will send `output_amount` of `output_token`", + "to the recipient and receive `input_token` on a repayment chain of their choice. The fee accounts for:", + "destination transaction costs, relayer's opportunity cost of capital while waiting for a refund during the", + "optimistic challenge window in the HubPool, and the system fee charged to the relayer.", + "", + "On the destination chain, a unique hash of the deposit data is used to identify this deposit. Modifying any", + "parameters will result in a different hash, creating a separate deposit. The hash is computed using all parameters", + "of this function along with the chain's `chainId()`. Relayers are refunded only for deposits with hashes that", + "exactly match those emitted by this contract.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the deposit.", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- depositor_token_account (Writable): The depositor's ATA for the input token.", + "- vault (Writable): Programs ATA for the associated input token. This is where the depositor's assets are sent.", + "Authority must be the state.", + "- mint (Account): The mint account for the input token.", + "- token_program (Interface): The token program.", + "- delegate (Account): The account used to delegate the input amount of the input token.", + "", + "### Parameters", + "- depositor: The account credited with the deposit. Can be different from the signer.", + "- recipient: The account receiving funds on the destination chain. Depending on the output chain can be an ETH", + "address or a contract address or any other address type encoded as a bytes32 field.", + "- input_token: The token pulled from the caller's account and locked into this program's vault on deposit.", + "- output_token: The token that the relayer will send to the recipient on the destination chain.", + "- input_amount: The amount of input tokens to pull from the caller's account and lock into the vault. This", + "amount will be sent to the relayer on their repayment chain of choice as a refund following an optimistic", + "challenge window in the HubPool, less a system fee.", + "- output_amount: The amount of output tokens that the relayer will send to the recipient on the destination.", + "This is big-endian encoded as a 32-byte array to match its underlying byte representation on EVM side.", + "- destination_chain_id: The destination chain identifier where the fill should be made.", + "- exclusive_relayer: The relayer that will be exclusively allowed to fill this deposit before the exclusivity", + "deadline timestamp. This must be a valid, non-zero address if the exclusivity deadline is greater than the", + "current block timestamp.", + "- quote_timestamp: The HubPool timestamp that is used to determine the system fee paid by the depositor. This", + "must be set to some time between [currentTime - depositQuoteTimeBuffer, currentTime].", + "- fill_deadline: The deadline for the relayer to fill the deposit. After this destination chain timestamp, the", + "fill will revert on the destination chain. Must be set before currentTime + fillDeadlineBuffer.", + "- exclusivity_parameter: Sets the exclusivity deadline timestamp for the exclusiveRelayer to fill the deposit.", + "1. If 0, no exclusivity period.", + "2. If less than MAX_EXCLUSIVITY_PERIOD_SECONDS, adds this value to the current block timestamp.", + "3. Otherwise, uses this value as the exclusivity deadline timestamp.", + "- message: The message to send to the recipient on the destination chain if the recipient is a contract.", + "If not empty, the recipient contract must implement handleV3AcrossMessage() or the fill will revert." + ], + "discriminator": [ + 242, + 35, + 198, + 137, + 82, + 225, + 242, + 182 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "delegate" + }, + { + "name": "depositorTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "arg", + "path": "depositor" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "mint" + }, + { + "name": "tokenProgram" + }, + { + "name": "associatedTokenProgram", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "inputToken", + "type": "pubkey" + }, + { + "name": "outputToken", + "type": "pubkey" + }, + { + "name": "inputAmount", + "type": "u64" + }, + { + "name": "outputAmount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "destinationChainId", + "type": "u64" + }, + { + "name": "exclusiveRelayer", + "type": "pubkey" + }, + { + "name": "quoteTimestamp", + "type": "u32" + }, + { + "name": "fillDeadline", + "type": "u32" + }, + { + "name": "exclusivityParameter", + "type": "u32" + }, + { + "name": "message", + "type": "bytes" + } + ] + }, + { + "name": "depositNow", + "docs": [ + "Equivalent to deposit except quote_timestamp is set to the current time.", + "The deposit `fill_deadline` is calculated as the current time plus `fill_deadline_offset`." + ], + "discriminator": [ + 75, + 228, + 135, + 221, + 200, + 25, + 148, + 26 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "delegate" + }, + { + "name": "depositorTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "arg", + "path": "depositor" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "mint" + }, + { + "name": "tokenProgram" + }, + { + "name": "associatedTokenProgram", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "inputToken", + "type": "pubkey" + }, + { + "name": "outputToken", + "type": "pubkey" + }, + { + "name": "inputAmount", + "type": "u64" + }, + { + "name": "outputAmount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "destinationChainId", + "type": "u64" + }, + { + "name": "exclusiveRelayer", + "type": "pubkey" + }, + { + "name": "fillDeadlineOffset", + "type": "u32" + }, + { + "name": "exclusivityParameter", + "type": "u32" + }, + { + "name": "message", + "type": "bytes" + } + ] + }, + { + "name": "emergencyDeleteRootBundle", + "docs": [ + "Deletes a root bundle in case of emergencies where bad bundle has reached the Spoke. Only callable by the owner.", + "", + "This function will close the PDA for the associated `root_bundle_id`.", + "Note: Using this function does not decrement `state.root_bundle_id`.", + "", + "### Required Accounts:", + "- signer (Signer): The account that must be the owner to authorize the deletion.", + "- closer (SystemAccount): The account that will receive the lamports from closing the root_bundle account.", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- root_bundle (Writable): The root bundle PDA to be closed. Seed: [\"root_bundle\",state.seed,root_bundle_id].", + "", + "### Parameters:", + "- root_bundle_id: Index of the root bundle that needs to be deleted." + ], + "discriminator": [ + 226, + 158, + 1, + 74, + 84, + 113, + 24, + 152 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "closer", + "writable": true + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "rootBundle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 111, + 111, + 116, + 95, + 98, + 117, + 110, + 100, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + }, + { + "kind": "arg", + "path": "rootBundleId" + } + ] + } + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "rootBundleId", + "type": "u32" + } + ] + }, + { + "name": "executeRelayerRefundLeaf", + "docs": [ + "Executes relayer refund leaf.", + "", + "Processes a relayer refund leaf, verifying its inclusion in a previous Merkle root and that it was not", + "previously executed. Function has two modes of operation: a) transfers all relayer refunds directly to", + "relayers ATA or b) credits relayers with claimable claim_account PDA that they can use later to claim their", + "refund. In the happy path, (a) should be used. (b) should only be used if there is a relayer within the bundle", + "who can't receive the transfer for some reason, such as failed token transfers due to blacklisting. Executing", + "relayer refunds requires the caller to create a LUT and load the execution params into it. This is needed to", + "fit the data in a single instruction. The exact structure and validation of the leaf is defined in the Accross", + "UMIP: https://github.com/UMAprotocol/UMIPs/blob/master/UMIPs/umip-179.md", + "", + "instruction_params Parameters:", + "- root_bundle_id: The ID of the root bundle containing the relayer refund root.", + "- relayer_refund_leaf: The relayer refund leaf to be executed. Contents must include:", + "- amount_to_return: The amount to be to be sent back to mainnet Ethereum from this Spoke pool.", + "- chain_id: The targeted chainId for the refund. Validated against state.chain_id.", + "- refund_amounts: The amounts to be returned to the relayer for each refund_address.", + "- leaf_id: The leaf ID of the relayer refund leaf.", + "- mint_public_key: The public key of the mint (refunded token) being refunded.", + "- refund_addresses: The addresses to be refunded.", + "- proof: The Merkle proof for the relayer refund leaf.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the execution. No permission requirements.", + "- instruction_params (Account): LUT containing the execution parameters. seed: [\"instruction_params\",signer]", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- root_bundle (Writable): The root bundle PDA containing the relayer refund root, created when the root bundle", + "was initially bridged. seed: [\"root_bundle\",state.seed,root_bundle_id].", + "- vault (Writable): The ATA for refunded mint. Authority must be the state.", + "- mint (Account): The mint account for the token being refunded.", + "- transfer_liability (Writable): Account to track pending refunds to be sent to the Ethereum hub pool. Only used", + "if the amount_to_return value is non-zero within the leaf. Seed: [\"transfer_liability\",mint]", + "- token_program: The token program.", + "- system_program: The system program required for account creation.", + "", + "execute_relayer_refund_leaf executes in mode where refunds are sent to ATA directly." + ], + "discriminator": [ + 27, + 136, + 159, + 240, + 127, + 68, + 123, + 164 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "instructionParams", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "rootBundle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 111, + 111, + 116, + 95, + 98, + 117, + 110, + 100, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + }, + { + "kind": "account", + "path": "instruction_params.root_bundle_id", + "account": "executeRelayerRefundLeafParams" + } + ] + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "mint" + }, + { + "name": "transferLiability", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 114, + 97, + 110, + 115, + 102, + 101, + 114, + 95, + 108, + 105, + 97, + 98, + 105, + 108, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "mint" + } + ] + } + }, + { + "name": "tokenProgram" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "executeRelayerRefundLeafDeferred", + "docs": [ + "Similar to execute_relayer_refund_leaf, but executes in mode where refunds are allocated to claim_account PDAs." + ], + "discriminator": [ + 110, + 112, + 89, + 208, + 38, + 116, + 93, + 10 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "instructionParams", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "rootBundle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 111, + 111, + 116, + 95, + 98, + 117, + 110, + 100, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + }, + { + "kind": "account", + "path": "instruction_params.root_bundle_id", + "account": "executeRelayerRefundLeafParams" + } + ] + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "mint" + }, + { + "name": "transferLiability", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 114, + 97, + 110, + 115, + 102, + 101, + 114, + 95, + 108, + 105, + 97, + 98, + 105, + 108, + 105, + 116, + 121 + ] + }, + { + "kind": "account", + "path": "mint" + } + ] + } + }, + { + "name": "tokenProgram" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "executeSlowRelayLeaf", + "docs": [ + "Executes a slow relay leaf stored as part of a root bundle relayed by the HubPool.", + "", + "Executing a slow fill leaf is equivalent to filling the relayData, so this function cannot be used to", + "double fill a recipient. The relayData that is filled is included in the slowFillLeaf and is hashed", + "like any other fill sent through fillRelay(). There is no relayer credited with filling this relay since funds", + "are sent directly out of this program's vault.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the execution. No permission requirements.", + "- instruction_params (Account): Optional account to load instruction parameters when they are not passed in the", + "instruction data due to message size constraints. Pass this program ID to represent None. When Some, this must", + "be derived from the signer's public key with seed [\"instruction_params\",signer].", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- root_bundle (Account): Root bundle PDA with slowRelayRoot. Seed: [\"root_bundle\",state.seed,root_bundle_id].", + "- fill_status (Writable): The fill status PDA, created when slow request was made. Updated to track slow fill.", + "Used to prevent double request and fill. Seed: [\"fills\",relay_hash].", + "- mint (Account): The mint account for the output token.", + "- recipient_token_account (Writable): The recipient's ATA for the output token.", + "- vault (Writable): The ATA for refunded mint. Authority must be the state.", + "- token_program (Interface): The token program.", + "- system_program (Program): The system program.", + "", + "### Parameters:", + "- _relay_hash: The hash identifying the deposit to be filled. Used to identify the deposit to be filled.", + "- slow_fill_leaf: Contains all data necessary to uniquely verify the slow fill. This struct contains:", + "- relayData: Struct containing all the data needed to identify the original deposit to be slow filled. Same", + "as the relay_data struct in fill_relay().", + "- chainId: Chain identifier where slow fill leaf should be executed. If this doesn't match this chain's", + "chainId, then this function will revert.", + "- updatedOutputAmount: Amount to be sent to recipient out of this contract's balance. Can be set differently", + "from relayData.outputAmount to charge a different fee because this deposit was \"slow\" filled. Usually,", + "this will be set higher to reimburse the recipient for waiting for the slow fill.", + "- _root_bundle_id: Unique ID of root bundle containing slow relay root that this leaf is contained in.", + "- proof: Inclusion proof for this leaf in slow relay root in root bundle.", + "Note: slow_fill_leaf, _root_bundle_id, and proof are optional parameters. If None for any of these is passed,", + "the caller must load them via the instruction_params account.", + "Note: When verifying the slow fill leaf, the relay data is hashed using AnchorSerialize::serialize that encodes", + "output token amounts to little-endian format while input token amount preserves its big-endian encoding as it", + "is passed as [u8; 32] array." + ], + "discriminator": [ + 26, + 207, + 3, + 168, + 193, + 252, + 59, + 127 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "instructionParams", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "rootBundle", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 111, + 111, + 116, + 95, + 98, + 117, + 110, + 100, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + }, + { + "kind": "arg", + "path": "_root_bundle_id.unwrap_or_else(| |\ninstruction_params" + } + ] + } + }, + { + "name": "fillStatus", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 105, + 108, + 108, + 115 + ] + }, + { + "kind": "arg", + "path": "relayHash" + } + ] + } + }, + { + "name": "mint" + }, + { + "name": "recipientTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "arg", + "path": "slowFillLeaf" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "tokenProgram" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "relayHash", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "slowFillLeaf", + "type": { + "option": { + "defined": { + "name": "slowFill" + } + } + } + }, + { + "name": "rootBundleId", + "type": { + "option": "u32" + } + }, + { + "name": "proof", + "type": { + "option": { + "vec": { + "array": [ + "u8", + 32 + ] + } + } + } + } + ] + }, + { + "name": "fillRelay", + "docs": [ + "Fulfill request to bridge cross chain by sending specified output tokens to recipient.", + "", + "Relayer & system fee is captured in the spread between input and output amounts. This fee accounts for tx costs,", + "relayer's capital opportunity cost, and a system fee. The relay_data hash uniquely identifies the deposit to", + "fill, ensuring relayers are refunded only for deposits matching the original hash from the origin SpokePool.", + "This hash includes all parameters from deposit() and must match the destination_chain_id. Note the relayer", + "creates an ATA in calling this method to store the fill_status. This should be closed once the deposit has", + "expired to let the relayer re-claim their rent. Cannot fill more than once. Partial fills are not supported.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the fill (filler). No permission requirements.", + "- instruction_params (Account): Optional account to load instruction parameters when they are not passed in the", + "instruction data due to message size constraints. Pass this program ID to represent None. When Some, this must", + "be derived from the signer's public key with seed [\"instruction_params\",signer].", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- mint (Account): The mint of the output token, sent from the relayer to the recipient.", + "- relayer_token_account (Writable): The relayer's ATA for the input token.", + "- recipient_token_account (Writable): The recipient's ATA for the output token.", + "- fill_status (Writable): The fill status PDA, created on this function call to track the fill status to prevent", + "re-entrancy & double fills. Also used to track requested slow fills. Seed: [\"fills\",relay_hash].", + "- token_program (Interface): The token program.", + "- associated_token_program (Interface): The associated token program.", + "- system_program (Interface): The system program.", + "- delegate (Account): The account used to delegate the output amount of the output token.", + "", + "### Parameters:", + "- relay_hash: The hash identifying the deposit to be filled. Caller must pass this in. Computed as hash of", + "the flattened relay_data & destination_chain_id.", + "- relay_data: Struct containing all the data needed to identify the deposit to be filled. Should match", + "all the same-named parameters emitted in the origin chain FundsDeposited event.", + "- depositor: The account credited with the deposit.", + "- recipient: The account receiving funds on this chain.", + "- input_token: The token pulled from the caller's account to initiate the deposit. The equivalent of this", + "token on the repayment chain will be sent as a refund to the caller.", + "- output_token: The token that the caller will send to the recipient on this chain.", + "- input_amount: This amount, less a system fee, will be sent to the caller on their repayment chain.", + "This is big-endian encoded as a 32-byte array to match its underlying byte representation on EVM side", + "- output_amount: The amount of output tokens that the caller will send to the recipient.", + "- origin_chain_id: The origin chain identifier.", + "- exclusive_relayer: The relayer that will be exclusively allowed to fill this deposit before the", + "exclusivity deadline timestamp.", + "- fill_deadline: The deadline for the caller to fill the deposit. After this timestamp, the deposit will be", + "cancelled and the depositor will be refunded on the origin chain.", + "- exclusivity_deadline: The deadline for the exclusive relayer to fill the deposit. After this timestamp,", + "anyone can fill this deposit.", + "- message: The message to send to the recipient if the recipient is a contract that implements a", + "handle_across_message() public function.", + "- repayment_chain_id: Chain of SpokePool where relayer wants to be refunded after the challenge window has", + "passed. Will receive input_amount of the equivalent token to input_token on the repayment chain.", + "- repayment_address: The address of the recipient on the repayment chain that they want to be refunded to.", + "Note: relay_data, repayment_chain_id, and repayment_address are optional parameters. If None for any of these", + "is passed, the caller must load them via the instruction_params account." + ], + "discriminator": [ + 100, + 84, + 222, + 90, + 106, + 209, + 58, + 222 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "instructionParams", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "delegate" + }, + { + "name": "mint" + }, + { + "name": "relayerTokenAccount", + "writable": true + }, + { + "name": "recipientTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "arg", + "path": "relayData" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "fillStatus", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 105, + 108, + 108, + 115 + ] + }, + { + "kind": "arg", + "path": "relayHash" + } + ] + } + }, + { + "name": "tokenProgram" + }, + { + "name": "associatedTokenProgram", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "relayHash", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "relayData", + "type": { + "option": { + "defined": { + "name": "relayData" + } + } + } + }, + { + "name": "repaymentChainId", + "type": { + "option": "u64" + } + }, + { + "name": "repaymentAddress", + "type": { + "option": "pubkey" + } + } + ] + }, + { + "name": "getUnsafeDepositId", + "docs": [ + "Computes the deposit ID for the depositor using the provided deposit_nonce. This acts like a \"view\" function for", + "off-chain actors to compute what the expected deposit ID is for a given depositor and deposit nonce will be.", + "", + "### Parameters:", + "- signer: The public key of the depositor sender.", + "- depositor: The public key of the depositor.", + "- deposit_nonce: The nonce used to derive the deposit ID." + ], + "discriminator": [ + 118, + 10, + 135, + 0, + 168, + 243, + 223, + 117 + ], + "accounts": [], + "args": [ + { + "name": "signer", + "type": "pubkey" + }, + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "depositNonce", + "type": "u64" + } + ], + "returns": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "handleReceiveMessage", + "docs": [ + "Handles cross-chain messages received from L1 Ethereum over CCTP.", + "", + "This function serves as the permissioned entry point for messages sent from the Ethereum mainnet to the Solana", + "SVM Spoke program over CCTP. It processes the incoming message by translating it into a corresponding Solana", + "instruction and then invokes the instruction within this program.", + "", + "### Required Accounts:", + "- authority_pda: A signer account that ensures this instruction can only be called by the Message Transmitter.", + "This acts to block that only the CCTP Message Transmitter can send messages to this program.", + "seed:[\"message_transmitter_authority\", program_id]", + "- state (Account): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet. Enforces that the", + "remote domain and sender are valid.", + "- self_authority: An unchecked account used for authenticating self-CPI invoked by the received message.", + "seed: [\"self_authority\"].", + "- program: The SVM Spoke program account.", + "", + "### Parameters:", + "- params: Contains information to process the received message, containing the following fields:", + "- remote_domain: The remote domain of the message sender.", + "- sender: The sender of the message.", + "- message_body: The body of the message.", + "- authority_bump: The authority bump for the message transmitter." + ], + "discriminator": [ + 133, + 102, + 1, + 180, + 145, + 11, + 138, + 180 + ], + "accounts": [ + { + "name": "authorityPda", + "signer": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 115, + 115, + 97, + 103, + 101, + 95, + 116, + 114, + 97, + 110, + 115, + 109, + 105, + 116, + 116, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "const", + "value": [ + 183, + 102, + 64, + 134, + 222, + 55, + 238, + 112, + 130, + 28, + 16, + 68, + 91, + 22, + 47, + 44, + 126, + 200, + 121, + 91, + 208, + 128, + 12, + 20, + 98, + 148, + 158, + 35, + 40, + 209, + 221, + 90 + ] + } + ], + "program": { + "kind": "const", + "value": [ + 166, + 95, + 201, + 137, + 219, + 95, + 93, + 66, + 117, + 159, + 58, + 84, + 96, + 88, + 239, + 205, + 205, + 192, + 191, + 60, + 24, + 152, + 7, + 45, + 142, + 180, + 93, + 209, + 216, + 5, + 8, + 206 + ] + } + } + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "selfAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 108, + 102, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program", + "address": "DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "handleReceiveMessageParams" + } + } + } + ] + }, + { + "name": "initialize", + "docs": [ + "Initializes the state for the SVM Spoke Pool. Only callable once.", + "", + "### Required Accounts:", + "- signer (Writable, Signer): The account that pays for the transaction and will own the state.", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- system_program: The system program required for account creation.", + "", + "### Parameters:", + "- seed: A unique seed used to derive the state account's address. Must be 0 on Mainnet.", + "- initial_number_of_deposits: The initial number of deposits. Used to offset in upgrades.", + "- chain_id: The chain ID for Solana, used to identify the Solana spoke in the rest of the Across protocol.", + "- remote_domain: The CCTP domain for Mainnet Ethereum.", + "- cross_domain_admin: The HubPool on Mainnet Ethereum.", + "- deposit_quote_time_buffer: Quote timestamps can't be set more than this amount into the past from deposit.", + "- fill_deadline_buffer: Fill deadlines can't be set more than this amount into the future from deposit." + ], + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "arg", + "path": "seed" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "seed", + "type": "u64" + }, + { + "name": "initialNumberOfDeposits", + "type": "u32" + }, + { + "name": "chainId", + "type": "u64" + }, + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "crossDomainAdmin", + "type": "pubkey" + }, + { + "name": "depositQuoteTimeBuffer", + "type": "u32" + }, + { + "name": "fillDeadlineBuffer", + "type": "u32" + } + ] + }, + { + "name": "initializeClaimAccount", + "docs": [ + "Initializes a claim account for a relayer refund.", + "", + "This function sets up a claim account for a relayer to claim their refund at a later time and should only be", + "used in the un-happy path where a bundle cant not be executed due to a recipient in the bundle having a blocked", + "or uninitialized claim ATA. The refund address becomes the \"owner\" of the claim_account.", + "", + "### Required Accounts:", + "- signer (Signer): The account that pays for the transaction and initializes the claim account.", + "- mint: The mint associated with the claim account.", + "- refund_address: The refund address associated with the claim account.", + "- claim_account (Writable): The newly created claim account PDA to store claim data for this associated mint.", + "Seed: [\"claim_account\",mint,refund_address].", + "- system_program: The system program required for account creation." + ], + "discriminator": [ + 22, + 247, + 214, + 191, + 90, + 74, + 87, + 216 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "mint" + }, + { + "name": "refundAddress" + }, + { + "name": "claimAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 108, + 97, + 105, + 109, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "account", + "path": "mint" + }, + { + "kind": "account", + "path": "refundAddress" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "initializeInstructionParams", + "docs": [ + "Initializes the instruction parameters account. Used by data worker when relaying bundles", + "", + "This function sets up an account to store raw data fragments for instructions (LUT).", + "", + "### Required Accounts:", + "- signer (Signer): The account that pays for the transaction and initializes the instruction parameters.", + "- instruction_params (UncheckedAccount): The account where raw data will be stored. Initialized with specified", + "size. seed: [\"instruction_params\",signer].", + "- system_program: The system program required for account creation.", + "", + "### Parameters:", + "- _total_size: The total size of the instruction parameters account." + ], + "discriminator": [ + 94, + 206, + 190, + 192, + 127, + 8, + 186, + 28 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "instructionParams", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "totalSize", + "type": "u32" + } + ] + }, + { + "name": "pauseDeposits", + "docs": [ + "Pauses the Spoke Pool from accepting deposits. Only callable by the owner.", + "", + "### Required Accounts:", + "- signer (Signer): The account that must be the owner to authorize the pause.", + "- state (Writable): The Spoke state PDA. Seed: [\"state\",state.seed], where `seed` is 0 on mainnet.", + "", + "### Parameters:", + "- pause: `true` to pause the system, `false` to unpause it." + ], + "discriminator": [ + 206, + 186, + 203, + 153, + 253, + 61, + 206, + 122 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "pause", + "type": "bool" + } + ] + }, + { + "name": "pauseFills", + "docs": [ + "Pauses the Spoke Pool from processing fills. Only callable by the owner.", + "", + "### Required Accounts:", + "- signer (Signer): The account that must be the owner to authorize the pause.", + "- state (Writable): The Spoke state PDA. Seed: [\"state\",state.seed], where `seed` is 0 on mainnet.", + "", + "### Parameters:", + "- pause: `true` to pause the system, `false` to unpause it." + ], + "discriminator": [ + 92, + 114, + 214, + 49, + 13, + 243, + 73, + 35 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "pause", + "type": "bool" + } + ] + }, + { + "name": "relayRootBundle", + "docs": [ + "Stores a new root bundle for later execution. Only callable by the owner.", + "", + "Once stored, these roots are used to execute relayer refunds, slow fills, and pool rebalancing actions.", + "This method initializes a root_bundle PDA to store the root bundle data. The caller", + "of this method is responsible for paying the rent for this PDA.", + "", + "### Required Accounts:", + "- signer (Signer): The account that must be the owner to authorize the addition of the new root bundle.", + "- payer (Signer): The account who pays rent to create root_bundle PDA.", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- root_bundle (Writable): The newly created bundle PDA to store root bundle data. Each root bundle has an", + "incrementing ID, stored in the state. Seed: [\"root_bundle\",state.seed,root_bundle_id].", + "- system_program (Program): The system program required for account creation.", + "", + "### Parameters:", + "- relayer_refund_root: Merkle root of the relayer refund tree.", + "- slow_relay_root: Merkle root of the slow relay tree." + ], + "discriminator": [ + 69, + 13, + 223, + 204, + 251, + 61, + 105, + 6 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "rootBundle", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 111, + 111, + 116, + 95, + 98, + 117, + 110, + 100, + 108, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + }, + { + "kind": "account", + "path": "state.root_bundle_id", + "account": "state" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "relayerRefundRoot", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "slowRelayRoot", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + }, + { + "name": "requestSlowFill", + "docs": [ + "Requests Across to send LP funds to this program to fulfill a slow fill.", + "", + "Slow fills are not possible unless the input and output tokens are \"equivalent\", i.e., they route to the same L1", + "token via PoolRebalanceRoutes. Slow fills are created by inserting slow fill objects into a Merkle tree that is", + "included in the next HubPool \"root bundle\". Once the optimistic challenge window has passed, the HubPool will", + "relay the slow root to this chain via relayRootBundle(). Once the slow root is relayed, the slow fill can be", + "executed by anyone who calls executeSlowRelayLeaf(). Cant request a slow fill if the fill deadline has", + "passed. Cant request a slow fill if the relay has already been filled or a slow fill has already been requested.", + "", + "### Required Accounts:", + "- signer (Signer): The account that authorizes the slow fill request.", + "- instruction_params (Account): Optional account to load instruction parameters when they are not passed in the", + "instruction data due to message size constraints. Pass this program ID to represent None. When Some, this must", + "be derived from the signer's public key with seed [\"instruction_params\",signer].", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "- fill_status (Writable): The fill status PDA, created on this function call. Updated to track slow fill status.", + "Used to prevent double request and fill. Seed: [\"fills\",relay_hash].", + "- system_program (Interface): The system program.", + "", + "### Parameters:", + "- _relay_hash: The hash identifying the deposit to be filled. Caller must pass this in. Computed as hash of", + "the flattened relay_data & destination_chain_id.", + "- relay_data: Struct containing all the data needed to identify the deposit that should be slow filled. If any", + "of the params are missing or different from the origin chain deposit, then Across will not include a slow", + "fill for the intended deposit. See fill_relay & RelayData struct for more details.", + "Note: relay_data is optional parameter. If None for it is passed, the caller must load it via the", + "instruction_params account." + ], + "discriminator": [ + 39, + 157, + 165, + 187, + 88, + 217, + 207, + 98 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "instructionParams", + "writable": true, + "optional": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "state", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "fillStatus", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 102, + 105, + 108, + 108, + 115 + ] + }, + { + "kind": "arg", + "path": "relayHash" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "relayHash", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "relayData", + "type": { + "option": { + "defined": { + "name": "relayData" + } + } + } + } + ] + }, + { + "name": "setCrossDomainAdmin", + "docs": [ + "Sets the cross-domain admin for the Spoke Pool. Only callable by owner. Used if Hubpool upgrades.", + "", + "### Required Accounts:", + "- signer (Signer): The account that must be the owner to authorize the admin change.", + "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", + "", + "### Parameters:", + "- cross_domain_admin: The public key of the new cross-domain admin." + ], + "discriminator": [ + 102, + 206, + 237, + 106, + 63, + 141, + 42, + 248 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "crossDomainAdmin", + "type": "pubkey" + } + ] + }, + { + "name": "setCurrentTime", + "docs": [ + "Sets the current time for the SVM Spoke Pool when running in test mode. Disabled on Mainnet." + ], + "discriminator": [ + 69, + 100, + 169, + 193, + 125, + 0, + 150, + 69 + ], + "accounts": [ + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "signer", + "signer": true + } + ], + "args": [ + { + "name": "newTime", + "type": "u32" + } + ] + }, + { + "name": "transferOwnership", + "docs": [ + "Transfers ownership of the Spoke Pool. Only callable by the current owner.", + "", + "### Required Accounts:", + "- signer (Signer): The account that must be the current owner to authorize the transfer.", + "- state (Writable): The Spoke state PDA. Seed: [\"state\",state.seed] where `seed` is 0 on mainnet.", + "", + "### Parameters:", + "- new_owner: The public key of the new owner." + ], + "discriminator": [ + 65, + 177, + 215, + 73, + 53, + 45, + 99, + 47 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "newOwner", + "type": "pubkey" + } + ] + }, + { + "name": "unsafeDeposit", + "docs": [ + "Equivalent to deposit, except that it doesn't use the global `number_of_deposits` counter as the deposit", + "nonce. Instead, it allows the caller to pass a `deposit_nonce`. This function is designed for anyone who", + "wants to pre-compute their resultant deposit ID, which can be useful for filling a deposit faster and", + "avoiding the risk of a deposit ID unexpectedly changing due to another deposit front-running this one and", + "incrementing the global deposit ID counter. This enables the caller to influence the deposit ID, making it", + "deterministic for the depositor. The computed `depositID` is the keccak256 hash of [signer, depositor, deposit_nonce]." + ], + "discriminator": [ + 196, + 187, + 166, + 179, + 3, + 146, + 150, + 246 + ], + "accounts": [ + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "state", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 116, + 97, + 116, + 101 + ] + }, + { + "kind": "account", + "path": "state.seed", + "account": "state" + } + ] + } + }, + { + "name": "delegate" + }, + { + "name": "depositorTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "arg", + "path": "depositor" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "state" + }, + { + "kind": "account", + "path": "tokenProgram" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "mint" + }, + { + "name": "tokenProgram" + }, + { + "name": "associatedTokenProgram", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "inputToken", + "type": "pubkey" + }, + { + "name": "outputToken", + "type": "pubkey" + }, + { + "name": "inputAmount", + "type": "u64" + }, + { + "name": "outputAmount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "destinationChainId", + "type": "u64" + }, + { + "name": "exclusiveRelayer", + "type": "pubkey" + }, + { + "name": "depositNonce", + "type": "u64" + }, + { + "name": "quoteTimestamp", + "type": "u32" + }, + { + "name": "fillDeadline", + "type": "u32" + }, + { + "name": "exclusivityParameter", + "type": "u32" + }, + { + "name": "message", + "type": "bytes" + } + ] + }, + { + "name": "writeInstructionParamsFragment", + "docs": [ + "Writes a fragment of raw data into the instruction parameters account.", + "", + "This function allows writing a fragment of data into a specified offset within the instruction parameters", + "account. It ensures that the data does not overflow the account's allocated space.", + "", + "### Required Accounts:", + "- signer (Signer): Account that authorizes the write operation.", + "- instruction_params (UncheckedAccount): Account to write raw data to. seed: [\"instruction_params\",signer].", + "- system_program: The system program required for account operations.", + "", + "### Parameters:", + "- offset: The starting position within the account's data where the fragment will be written.", + "- fragment: The raw data fragment to be written into the account." + ], + "discriminator": [ + 238, + 182, + 109, + 113, + 124, + 255, + 72, + 18 + ], + "accounts": [ + { + "name": "signer", + "signer": true + }, + { + "name": "instructionParams", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 105, + 110, + 115, + 116, + 114, + 117, + 99, + 116, + 105, + 111, + 110, + 95, + 112, + 97, + 114, + 97, + 109, + 115 + ] + }, + { + "kind": "account", + "path": "signer" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "offset", + "type": "u32" + }, + { + "name": "fragment", + "type": "bytes" + } + ] + } + ], + "accounts": [ + { + "name": "claimAccount", + "discriminator": [ + 113, + 109, + 47, + 96, + 242, + 219, + 61, + 165 + ] + }, + { + "name": "executeRelayerRefundLeafParams", + "discriminator": [ + 192, + 59, + 93, + 9, + 171, + 77, + 28, + 250 + ] + }, + { + "name": "executeSlowRelayLeafParams", + "discriminator": [ + 135, + 208, + 119, + 251, + 14, + 222, + 66, + 155 + ] + }, + { + "name": "fillRelayParams", + "discriminator": [ + 50, + 243, + 51, + 185, + 89, + 60, + 43, + 202 + ] + }, + { + "name": "fillStatusAccount", + "discriminator": [ + 105, + 89, + 88, + 35, + 24, + 147, + 178, + 137 + ] + }, + { + "name": "requestSlowFillParams", + "discriminator": [ + 5, + 54, + 214, + 89, + 197, + 37, + 118, + 28 + ] + }, + { + "name": "rootBundle", + "discriminator": [ + 66, + 221, + 214, + 231, + 25, + 222, + 184, + 219 + ] + }, + { + "name": "state", + "discriminator": [ + 216, + 146, + 107, + 94, + 104, + 75, + 182, + 177 + ] + }, + { + "name": "transferLiability", + "discriminator": [ + 157, + 137, + 86, + 109, + 206, + 241, + 183, + 79 + ] + } + ], + "events": [ + { + "name": "bridgedToHubPool", + "discriminator": [ + 181, + 111, + 52, + 218, + 105, + 53, + 240, + 205 + ] + }, + { + "name": "claimedRelayerRefund", + "discriminator": [ + 161, + 134, + 155, + 159, + 211, + 37, + 150, + 41 + ] + }, + { + "name": "emergencyDeletedRootBundle", + "discriminator": [ + 45, + 150, + 89, + 248, + 134, + 142, + 200, + 114 + ] + }, + { + "name": "executedRelayerRefundRoot", + "discriminator": [ + 198, + 167, + 248, + 175, + 34, + 3, + 4, + 240 + ] + }, + { + "name": "filledRelay", + "discriminator": [ + 25, + 58, + 182, + 0, + 50, + 99, + 160, + 117 + ] + }, + { + "name": "fundsDeposited", + "discriminator": [ + 157, + 209, + 100, + 95, + 59, + 100, + 3, + 68 + ] + }, + { + "name": "pausedDeposits", + "discriminator": [ + 94, + 129, + 187, + 122, + 94, + 30, + 91, + 247 + ] + }, + { + "name": "pausedFills", + "discriminator": [ + 81, + 4, + 134, + 23, + 170, + 56, + 234, + 234 + ] + }, + { + "name": "relayedRootBundle", + "discriminator": [ + 188, + 206, + 117, + 10, + 66, + 78, + 77, + 115 + ] + }, + { + "name": "requestedSlowFill", + "discriminator": [ + 221, + 123, + 11, + 14, + 71, + 37, + 178, + 167 + ] + }, + { + "name": "setXDomainAdmin", + "discriminator": [ + 164, + 13, + 119, + 18, + 103, + 226, + 98, + 66 + ] + }, + { + "name": "tokensBridged", + "discriminator": [ + 200, + 201, + 199, + 39, + 5, + 238, + 214, + 196 + ] + }, + { + "name": "transferredOwnership", + "discriminator": [ + 235, + 235, + 154, + 16, + 153, + 94, + 21, + 117 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "invalidQuoteTimestamp", + "msg": "Invalid quote timestamp!" + }, + { + "code": 6001, + "name": "invalidFillDeadline", + "msg": "Invalid fill deadline!" + }, + { + "code": 6002, + "name": "notExclusiveRelayer", + "msg": "Caller is not the exclusive relayer and exclusivity deadline has not passed!" + }, + { + "code": 6003, + "name": "noSlowFillsInExclusivityWindow", + "msg": "The Deposit is still within the exclusivity window!" + }, + { + "code": 6004, + "name": "relayFilled", + "msg": "The relay has already been filled!" + }, + { + "code": 6005, + "name": "invalidSlowFillRequest", + "msg": "Slow fill requires status of Unfilled!" + }, + { + "code": 6006, + "name": "expiredFillDeadline", + "msg": "The fill deadline has passed!" + }, + { + "code": 6007, + "name": "invalidMerkleProof", + "msg": "Invalid Merkle proof!" + }, + { + "code": 6008, + "name": "invalidChainId", + "msg": "Invalid chain id!" + }, + { + "code": 6009, + "name": "invalidMerkleLeaf", + "msg": "Invalid Merkle leaf!" + }, + { + "code": 6010, + "name": "claimedMerkleLeaf", + "msg": "Leaf already claimed!" + }, + { + "code": 6011, + "name": "depositsArePaused", + "msg": "Deposits are currently paused!" + }, + { + "code": 6012, + "name": "fillsArePaused", + "msg": "Fills are currently paused!" + }, + { + "code": 6013, + "name": "insufficientSpokePoolBalanceToExecuteLeaf", + "msg": "Insufficient spoke pool balance to execute leaf" + }, + { + "code": 6014, + "name": "invalidExclusiveRelayer", + "msg": "Invalid exclusive relayer!" + }, + { + "code": 6015, + "name": "invalidOutputToken", + "msg": "Invalid output token!" + } + ], + "types": [ + { + "name": "bridgedToHubPool", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "claimAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "initializer", + "type": "pubkey" + } + ] + } + }, + { + "name": "claimedRelayerRefund", + "type": { + "kind": "struct", + "fields": [ + { + "name": "l2TokenAddress", + "type": "pubkey" + }, + { + "name": "claimAmount", + "type": "u64" + }, + { + "name": "refundAddress", + "type": "pubkey" + } + ] + } + }, + { + "name": "emergencyDeletedRootBundle", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rootBundleId", + "type": "u32" + } + ] + } + }, + { + "name": "executeRelayerRefundLeafParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rootBundleId", + "type": "u32" + }, + { + "name": "relayerRefundLeaf", + "type": { + "defined": { + "name": "relayerRefundLeaf" + } + } + }, + { + "name": "proof", + "type": { + "vec": { + "array": [ + "u8", + 32 + ] + } + } + } + ] + } + }, + { + "name": "executeSlowRelayLeafParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "slowFillLeaf", + "type": { + "defined": { + "name": "slowFill" + } + } + }, + { + "name": "rootBundleId", + "type": "u32" + }, + { + "name": "proof", + "type": { + "vec": { + "array": [ + "u8", + 32 + ] + } + } + } + ] + } + }, + { + "name": "executedRelayerRefundRoot", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amountToReturn", + "type": "u64" + }, + { + "name": "chainId", + "type": "u64" + }, + { + "name": "refundAmounts", + "type": { + "vec": "u64" + } + }, + { + "name": "rootBundleId", + "type": "u32" + }, + { + "name": "leafId", + "type": "u32" + }, + { + "name": "l2TokenAddress", + "type": "pubkey" + }, + { + "name": "refundAddresses", + "type": { + "vec": "pubkey" + } + }, + { + "name": "deferredRefunds", + "type": "bool" + }, + { + "name": "caller", + "type": "pubkey" + } + ] + } + }, + { + "name": "fillRelayParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "relayData", + "type": { + "defined": { + "name": "relayData" + } + } + }, + { + "name": "repaymentChainId", + "type": "u64" + }, + { + "name": "repaymentAddress", + "type": "pubkey" + } + ] + } + }, + { + "name": "fillStatus", + "type": { + "kind": "enum", + "variants": [ + { + "name": "unfilled" + }, + { + "name": "requestedSlowFill" + }, + { + "name": "filled" + } + ] + } + }, + { + "name": "fillStatusAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "status", + "type": { + "defined": { + "name": "fillStatus" + } + } + }, + { + "name": "relayer", + "type": "pubkey" + }, + { + "name": "fillDeadline", + "type": "u32" + } + ] + } + }, + { + "name": "fillType", + "type": { + "kind": "enum", + "variants": [ + { + "name": "fastFill" + }, + { + "name": "replacedSlowFill" + }, + { + "name": "slowFill" + } + ] + } + }, + { + "name": "filledRelay", + "type": { + "kind": "struct", + "fields": [ + { + "name": "inputToken", + "type": "pubkey" + }, + { + "name": "outputToken", + "type": "pubkey" + }, + { + "name": "inputAmount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "outputAmount", + "type": "u64" + }, + { + "name": "repaymentChainId", + "type": "u64" + }, + { + "name": "originChainId", + "type": "u64" + }, + { + "name": "depositId", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "fillDeadline", + "type": "u32" + }, + { + "name": "exclusivityDeadline", + "type": "u32" + }, + { + "name": "exclusiveRelayer", + "type": "pubkey" + }, + { + "name": "relayer", + "type": "pubkey" + }, + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "messageHash", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "relayExecutionInfo", + "type": { + "defined": { + "name": "relayExecutionEventInfo" + } + } + } + ] + } + }, + { + "name": "fundsDeposited", + "type": { + "kind": "struct", + "fields": [ + { + "name": "inputToken", + "type": "pubkey" + }, + { + "name": "outputToken", + "type": "pubkey" + }, + { + "name": "inputAmount", + "type": "u64" + }, + { + "name": "outputAmount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "destinationChainId", + "type": "u64" + }, + { + "name": "depositId", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "quoteTimestamp", + "type": "u32" + }, + { + "name": "fillDeadline", + "type": "u32" + }, + { + "name": "exclusivityDeadline", + "type": "u32" + }, + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "exclusiveRelayer", + "type": "pubkey" + }, + { + "name": "message", + "type": "bytes" + } + ] + } + }, + { + "name": "handleReceiveMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "sender", + "type": "pubkey" + }, + { + "name": "messageBody", + "type": "bytes" + }, + { + "name": "authorityBump", + "type": "u8" + } + ] + } + }, + { + "name": "pausedDeposits", + "type": { + "kind": "struct", + "fields": [ + { + "name": "isPaused", + "type": "bool" + } + ] + } + }, + { + "name": "pausedFills", + "type": { + "kind": "struct", + "fields": [ + { + "name": "isPaused", + "type": "bool" + } + ] + } + }, + { + "name": "relayData", + "type": { + "kind": "struct", + "fields": [ + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "exclusiveRelayer", + "type": "pubkey" + }, + { + "name": "inputToken", + "type": "pubkey" + }, + { + "name": "outputToken", + "type": "pubkey" + }, + { + "name": "inputAmount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "outputAmount", + "type": "u64" + }, + { + "name": "originChainId", + "type": "u64" + }, + { + "name": "depositId", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "fillDeadline", + "type": "u32" + }, + { + "name": "exclusivityDeadline", + "type": "u32" + }, + { + "name": "message", + "type": "bytes" + } + ] + } + }, + { + "name": "relayExecutionEventInfo", + "type": { + "kind": "struct", + "fields": [ + { + "name": "updatedRecipient", + "type": "pubkey" + }, + { + "name": "updatedMessageHash", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "updatedOutputAmount", + "type": "u64" + }, + { + "name": "fillType", + "type": { + "defined": { + "name": "fillType" + } + } + } + ] + } + }, + { + "name": "relayedRootBundle", + "type": { + "kind": "struct", + "fields": [ + { + "name": "rootBundleId", + "type": "u32" + }, + { + "name": "relayerRefundRoot", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "slowRelayRoot", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "relayerRefundLeaf", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amountToReturn", + "type": "u64" + }, + { + "name": "chainId", + "type": "u64" + }, + { + "name": "refundAmounts", + "type": { + "vec": "u64" + } + }, + { + "name": "leafId", + "type": "u32" + }, + { + "name": "mintPublicKey", + "type": "pubkey" + }, + { + "name": "refundAddresses", + "type": { + "vec": "pubkey" + } + } + ] + } + }, + { + "name": "requestSlowFillParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "relayData", + "type": { + "defined": { + "name": "relayData" + } + } + } + ] + } + }, + { + "name": "requestedSlowFill", + "type": { + "kind": "struct", + "fields": [ + { + "name": "inputToken", + "type": "pubkey" + }, + { + "name": "outputToken", + "type": "pubkey" + }, + { + "name": "inputAmount", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "outputAmount", + "type": "u64" + }, + { + "name": "originChainId", + "type": "u64" + }, + { + "name": "depositId", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "fillDeadline", + "type": "u32" + }, + { + "name": "exclusivityDeadline", + "type": "u32" + }, + { + "name": "exclusiveRelayer", + "type": "pubkey" + }, + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "recipient", + "type": "pubkey" + }, + { + "name": "messageHash", + "type": { + "array": [ + "u8", + 32 + ] + } + } + ] + } + }, + { + "name": "rootBundle", + "type": { + "kind": "struct", + "fields": [ + { + "name": "relayerRefundRoot", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "slowRelayRoot", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "claimedBitmap", + "type": "bytes" + } + ] + } + }, + { + "name": "setXDomainAdmin", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newAdmin", + "type": "pubkey" + } + ] + } + }, + { + "name": "slowFill", + "type": { + "kind": "struct", + "fields": [ + { + "name": "relayData", + "type": { + "defined": { + "name": "relayData" + } + } + }, + { + "name": "chainId", + "type": "u64" + }, + { + "name": "updatedOutputAmount", + "type": "u64" + } + ] + } + }, + { + "name": "state", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pausedDeposits", + "type": "bool" + }, + { + "name": "pausedFills", + "type": "bool" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "seed", + "type": "u64" + }, + { + "name": "numberOfDeposits", + "type": "u32" + }, + { + "name": "chainId", + "type": "u64" + }, + { + "name": "currentTime", + "type": "u32" + }, + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "crossDomainAdmin", + "type": "pubkey" + }, + { + "name": "rootBundleId", + "type": "u32" + }, + { + "name": "depositQuoteTimeBuffer", + "type": "u32" + }, + { + "name": "fillDeadlineBuffer", + "type": "u32" + } + ] + } + }, + { + "name": "tokensBridged", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amountToReturn", + "type": "u64" + }, + { + "name": "chainId", + "type": "u64" + }, + { + "name": "leafId", + "type": "u32" + }, + { + "name": "l2TokenAddress", + "type": "pubkey" + }, + { + "name": "caller", + "type": "pubkey" + } + ] + } + }, + { + "name": "transferLiability", + "type": { + "kind": "struct", + "fields": [ + { + "name": "pendingToHubPool", + "type": "u64" + } + ] + } + }, + { + "name": "transferredOwnership", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newOwner", + "type": "pubkey" + } + ] + } + } + ] +}; diff --git a/src/svm/assets/test.ts b/src/svm/assets/test.ts new file mode 100644 index 000000000..b18b39b2b --- /dev/null +++ b/src/svm/assets/test.ts @@ -0,0 +1,249 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/test.json`. + */ +export type Test = { + "address": "8tsEfDSiE4WUMf97oyyyasLAvWwjeRZb2GByh4w7HckA", + "metadata": { + "name": "test", + "version": "0.1.0", + "spec": "0.1.0", + "description": "Created with Anchor" + }, + "instructions": [ + { + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "bitmapAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 105, + 116, + 109, + 97, + 112, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + } + ] + } + }, + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [] + }, + { + "name": "testEmitLargeLog", + "discriminator": [ + 126, + 64, + 160, + 189, + 160, + 160, + 238, + 68 + ], + "accounts": [], + "args": [ + { + "name": "length", + "type": "u32" + } + ] + }, + { + "name": "testIsClaimed", + "discriminator": [ + 82, + 227, + 141, + 60, + 27, + 165, + 109, + 90 + ], + "accounts": [ + { + "name": "bitmapAccount" + } + ], + "args": [ + { + "name": "index", + "type": "u32" + } + ], + "returns": "bool" + }, + { + "name": "testSetClaimed", + "discriminator": [ + 15, + 155, + 67, + 241, + 20, + 247, + 21, + 189 + ], + "accounts": [ + { + "name": "bitmapAccount", + "writable": true + }, + { + "name": "signer", + "writable": true, + "signer": true + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + } + ], + "args": [ + { + "name": "index", + "type": "u32" + } + ] + }, + { + "name": "verify", + "discriminator": [ + 133, + 161, + 141, + 48, + 120, + 198, + 88, + 150 + ], + "accounts": [], + "args": [ + { + "name": "root", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "leaf", + "type": { + "array": [ + "u8", + 32 + ] + } + }, + { + "name": "proof", + "type": { + "vec": { + "array": [ + "u8", + 32 + ] + } + } + } + ] + } + ], + "accounts": [ + { + "name": "bitmapAccount", + "discriminator": [ + 152, + 161, + 147, + 85, + 213, + 38, + 59, + 48 + ] + } + ], + "events": [ + { + "name": "testEvent", + "discriminator": [ + 28, + 52, + 39, + 105, + 8, + 210, + 91, + 9 + ] + } + ], + "types": [ + { + "name": "bitmapAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "claimedBitmap", + "type": "bytes" + } + ] + } + }, + { + "name": "testEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "message", + "type": "string" + } + ] + } + } + ] +}; diff --git a/src/svm/assets/token_messenger_minter.ts b/src/svm/assets/token_messenger_minter.ts new file mode 100644 index 000000000..7ecacc2b5 --- /dev/null +++ b/src/svm/assets/token_messenger_minter.ts @@ -0,0 +1,2055 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/token_messenger_minter.json`. + */ +export type TokenMessengerMinter = { + "address": "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3", + "metadata": { + "name": "tokenMessengerMinter", + "version": "0.1.0", + "spec": "0.1.0" + }, + "instructions": [ + { + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "upgradeAuthority", + "signer": true + }, + { + "name": "authorityPda" + }, + { + "name": "tokenMessenger", + "writable": true + }, + { + "name": "tokenMinter", + "writable": true + }, + { + "name": "tokenMessengerMinterProgramData" + }, + { + "name": "tokenMessengerMinterProgram" + }, + { + "name": "systemProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "initializeParams" + } + } + } + ] + }, + { + "name": "transferOwnership", + "discriminator": [ + 65, + 177, + 215, + 73, + 53, + 45, + 99, + 47 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "tokenMessenger", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "transferOwnershipParams" + } + } + } + ] + }, + { + "name": "acceptOwnership", + "discriminator": [ + 172, + 23, + 43, + 13, + 238, + 213, + 85, + 150 + ], + "accounts": [ + { + "name": "pendingOwner", + "signer": true + }, + { + "name": "tokenMessenger", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "acceptOwnershipParams" + } + } + } + ] + }, + { + "name": "addRemoteTokenMessenger", + "discriminator": [ + 12, + 149, + 172, + 165, + 111, + 202, + 24, + 33 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "owner", + "signer": true + }, + { + "name": "tokenMessenger" + }, + { + "name": "remoteTokenMessenger", + "writable": true + }, + { + "name": "systemProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "addRemoteTokenMessengerParams" + } + } + } + ] + }, + { + "name": "removeRemoteTokenMessenger", + "discriminator": [ + 65, + 114, + 66, + 85, + 169, + 98, + 177, + 146 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "owner", + "signer": true + }, + { + "name": "tokenMessenger" + }, + { + "name": "remoteTokenMessenger", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "removeRemoteTokenMessengerParams" + } + } + } + ] + }, + { + "name": "depositForBurn", + "discriminator": [ + 215, + 60, + 61, + 46, + 114, + 55, + 128, + 176 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "eventRentPayer", + "writable": true, + "signer": true + }, + { + "name": "senderAuthorityPda" + }, + { + "name": "burnTokenAccount", + "writable": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "tokenMessenger" + }, + { + "name": "remoteTokenMessenger" + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true + }, + { + "name": "burnTokenMint", + "writable": true + }, + { + "name": "messageSentEventData", + "writable": true, + "signer": true + }, + { + "name": "messageTransmitterProgram" + }, + { + "name": "tokenMessengerMinterProgram" + }, + { + "name": "tokenProgram" + }, + { + "name": "systemProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "depositForBurnParams" + } + } + } + ], + "returns": "u64" + }, + { + "name": "depositForBurnWithCaller", + "discriminator": [ + 167, + 222, + 19, + 114, + 85, + 21, + 14, + 118 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "eventRentPayer", + "writable": true, + "signer": true + }, + { + "name": "senderAuthorityPda" + }, + { + "name": "burnTokenAccount", + "writable": true + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "tokenMessenger" + }, + { + "name": "remoteTokenMessenger" + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true + }, + { + "name": "burnTokenMint", + "writable": true + }, + { + "name": "messageSentEventData", + "writable": true, + "signer": true + }, + { + "name": "messageTransmitterProgram" + }, + { + "name": "tokenMessengerMinterProgram" + }, + { + "name": "tokenProgram" + }, + { + "name": "systemProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "depositForBurnWithCallerParams" + } + } + } + ], + "returns": "u64" + }, + { + "name": "replaceDepositForBurn", + "discriminator": [ + 7, + 27, + 93, + 132, + 1, + 80, + 19, + 163 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "eventRentPayer", + "writable": true, + "signer": true + }, + { + "name": "senderAuthorityPda" + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "tokenMessenger" + }, + { + "name": "messageSentEventData", + "writable": true, + "signer": true + }, + { + "name": "messageTransmitterProgram" + }, + { + "name": "tokenMessengerMinterProgram" + }, + { + "name": "systemProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "replaceDepositForBurnParams" + } + } + } + ], + "returns": "u64" + }, + { + "name": "handleReceiveMessage", + "discriminator": [ + 133, + 102, + 1, + 180, + 145, + 11, + 138, + 180 + ], + "accounts": [ + { + "name": "authorityPda", + "signer": true + }, + { + "name": "tokenMessenger" + }, + { + "name": "remoteTokenMessenger" + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true + }, + { + "name": "tokenPair" + }, + { + "name": "recipientTokenAccount", + "writable": true + }, + { + "name": "custodyTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "handleReceiveMessageParams" + } + } + } + ] + }, + { + "name": "setTokenController", + "discriminator": [ + 88, + 6, + 98, + 10, + 79, + 59, + 15, + 24 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "tokenMessenger" + }, + { + "name": "tokenMinter", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setTokenControllerParams" + } + } + } + ] + }, + { + "name": "pause", + "discriminator": [ + 211, + 22, + 221, + 251, + 74, + 121, + 193, + 47 + ], + "accounts": [ + { + "name": "pauser", + "signer": true + }, + { + "name": "tokenMinter", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "pauseParams" + } + } + } + ] + }, + { + "name": "unpause", + "discriminator": [ + 169, + 144, + 4, + 38, + 10, + 141, + 188, + 255 + ], + "accounts": [ + { + "name": "pauser", + "signer": true + }, + { + "name": "tokenMinter", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "unpauseParams" + } + } + } + ] + }, + { + "name": "updatePauser", + "discriminator": [ + 140, + 171, + 211, + 132, + 57, + 201, + 16, + 254 + ], + "accounts": [ + { + "name": "owner", + "signer": true + }, + { + "name": "tokenMessenger" + }, + { + "name": "tokenMinter", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "updatePauserParams" + } + } + } + ] + }, + { + "name": "setMaxBurnAmountPerMessage", + "discriminator": [ + 30, + 128, + 145, + 240, + 70, + 237, + 109, + 207 + ], + "accounts": [ + { + "name": "tokenController", + "signer": true + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setMaxBurnAmountPerMessageParams" + } + } + } + ] + }, + { + "name": "addLocalToken", + "discriminator": [ + 213, + 199, + 205, + 18, + 98, + 124, + 73, + 198 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "tokenController", + "signer": true + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true + }, + { + "name": "custodyTokenAccount", + "writable": true + }, + { + "name": "localTokenMint" + }, + { + "name": "tokenProgram" + }, + { + "name": "systemProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "addLocalTokenParams" + } + } + } + ] + }, + { + "name": "removeLocalToken", + "discriminator": [ + 27, + 43, + 66, + 170, + 188, + 44, + 109, + 97 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "tokenController", + "signer": true + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true + }, + { + "name": "custodyTokenAccount", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "removeLocalTokenParams" + } + } + } + ] + }, + { + "name": "linkTokenPair", + "discriminator": [ + 68, + 162, + 24, + 104, + 125, + 46, + 130, + 12 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "tokenController", + "signer": true + }, + { + "name": "tokenMinter" + }, + { + "name": "tokenPair", + "writable": true + }, + { + "name": "systemProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "linkTokenPairParams" + } + } + } + ] + }, + { + "name": "unlinkTokenPair", + "discriminator": [ + 52, + 198, + 100, + 114, + 104, + 174, + 85, + 58 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "tokenController", + "signer": true + }, + { + "name": "tokenMinter" + }, + { + "name": "tokenPair", + "writable": true + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "uninkTokenPairParams" + } + } + } + ] + }, + { + "name": "burnTokenCustody", + "discriminator": [ + 233, + 136, + 180, + 175, + 112, + 41, + 62, + 71 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "tokenController", + "signer": true + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken" + }, + { + "name": "custodyTokenAccount", + "writable": true + }, + { + "name": "custodyTokenMint", + "writable": true + }, + { + "name": "tokenProgram" + }, + { + "name": "eventAuthority" + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "burnTokenCustodyParams" + } + } + } + ] + } + ], + "accounts": [ + { + "name": "tokenMessenger", + "discriminator": [ + 162, + 4, + 242, + 52, + 147, + 243, + 221, + 96 + ] + }, + { + "name": "remoteTokenMessenger", + "discriminator": [ + 105, + 115, + 174, + 34, + 95, + 233, + 138, + 252 + ] + }, + { + "name": "tokenMinter", + "discriminator": [ + 122, + 133, + 84, + 63, + 57, + 159, + 171, + 206 + ] + }, + { + "name": "tokenPair", + "discriminator": [ + 17, + 214, + 45, + 176, + 229, + 149, + 197, + 71 + ] + }, + { + "name": "localToken", + "discriminator": [ + 159, + 131, + 58, + 170, + 193, + 84, + 128, + 182 + ] + } + ], + "events": [ + { + "name": "ownershipTransferStarted", + "discriminator": [ + 183, + 253, + 239, + 246, + 140, + 179, + 133, + 105 + ] + }, + { + "name": "ownershipTransferred", + "discriminator": [ + 172, + 61, + 205, + 183, + 250, + 50, + 38, + 98 + ] + }, + { + "name": "depositForBurn", + "discriminator": [ + 144, + 252, + 145, + 146, + 6, + 74, + 167, + 235 + ] + }, + { + "name": "mintAndWithdraw", + "discriminator": [ + 75, + 67, + 229, + 70, + 162, + 126, + 0, + 71 + ] + }, + { + "name": "remoteTokenMessengerAdded", + "discriminator": [ + 251, + 29, + 63, + 244, + 48, + 114, + 210, + 175 + ] + }, + { + "name": "remoteTokenMessengerRemoved", + "discriminator": [ + 255, + 121, + 137, + 39, + 230, + 125, + 11, + 30 + ] + }, + { + "name": "setTokenController", + "discriminator": [ + 193, + 44, + 243, + 83, + 230, + 72, + 120, + 216 + ] + }, + { + "name": "pauserChanged", + "discriminator": [ + 142, + 157, + 158, + 87, + 127, + 8, + 119, + 55 + ] + }, + { + "name": "setBurnLimitPerMessage", + "discriminator": [ + 98, + 152, + 88, + 191, + 245, + 30, + 27, + 209 + ] + }, + { + "name": "localTokenAdded", + "discriminator": [ + 146, + 8, + 224, + 150, + 122, + 173, + 23, + 39 + ] + }, + { + "name": "localTokenRemoved", + "discriminator": [ + 181, + 204, + 1, + 95, + 2, + 50, + 66, + 210 + ] + }, + { + "name": "tokenPairLinked", + "discriminator": [ + 2, + 14, + 177, + 64, + 155, + 93, + 196, + 141 + ] + }, + { + "name": "tokenPairUnlinked", + "discriminator": [ + 78, + 232, + 230, + 208, + 180, + 212, + 246, + 72 + ] + }, + { + "name": "pause", + "discriminator": [ + 194, + 251, + 232, + 196, + 118, + 95, + 111, + 219 + ] + }, + { + "name": "unpause", + "discriminator": [ + 241, + 149, + 104, + 90, + 199, + 136, + 219, + 146 + ] + }, + { + "name": "tokenCustodyBurned", + "discriminator": [ + 219, + 143, + 107, + 226, + 67, + 75, + 178, + 46 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "invalidAuthority", + "msg": "Invalid authority" + }, + { + "code": 6001, + "name": "invalidTokenMessengerState", + "msg": "Invalid token messenger state" + }, + { + "code": 6002, + "name": "invalidTokenMessenger", + "msg": "Invalid token messenger" + }, + { + "code": 6003, + "name": "invalidOwner", + "msg": "Invalid owner" + }, + { + "code": 6004, + "name": "malformedMessage", + "msg": "Malformed message" + }, + { + "code": 6005, + "name": "invalidMessageBodyVersion", + "msg": "Invalid message body version" + }, + { + "code": 6006, + "name": "invalidAmount", + "msg": "Invalid amount" + }, + { + "code": 6007, + "name": "invalidDestinationDomain", + "msg": "Invalid destination domain" + }, + { + "code": 6008, + "name": "invalidDestinationCaller", + "msg": "Invalid destination caller" + }, + { + "code": 6009, + "name": "invalidMintRecipient", + "msg": "Invalid mint recipient" + }, + { + "code": 6010, + "name": "invalidSender", + "msg": "Invalid sender" + }, + { + "code": 6011, + "name": "invalidTokenPair", + "msg": "Invalid token pair" + }, + { + "code": 6012, + "name": "invalidTokenMint", + "msg": "Invalid token mint" + } + ], + "types": [ + { + "name": "acceptOwnershipParams", + "type": { + "kind": "struct" + } + }, + { + "name": "addRemoteTokenMessengerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "tokenMessenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "depositForBurnWithCallerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "destinationDomain", + "type": "u32" + }, + { + "name": "mintRecipient", + "type": "pubkey" + }, + { + "name": "destinationCaller", + "type": "pubkey" + } + ] + } + }, + { + "name": "depositForBurnParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "destinationDomain", + "type": "u32" + }, + { + "name": "mintRecipient", + "type": "pubkey" + } + ] + } + }, + { + "name": "handleReceiveMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "sender", + "type": "pubkey" + }, + { + "name": "messageBody", + "type": "bytes" + }, + { + "name": "authorityBump", + "type": "u8" + } + ] + } + }, + { + "name": "initializeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "tokenController", + "type": "pubkey" + }, + { + "name": "localMessageTransmitter", + "type": "pubkey" + }, + { + "name": "messageBodyVersion", + "type": "u32" + } + ] + } + }, + { + "name": "removeRemoteTokenMessengerParams", + "type": { + "kind": "struct" + } + }, + { + "name": "replaceDepositForBurnParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "originalMessage", + "type": "bytes" + }, + { + "name": "originalAttestation", + "type": "bytes" + }, + { + "name": "newDestinationCaller", + "type": "pubkey" + }, + { + "name": "newMintRecipient", + "type": "pubkey" + } + ] + } + }, + { + "name": "transferOwnershipParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newOwner", + "type": "pubkey" + } + ] + } + }, + { + "name": "addLocalTokenParams", + "type": { + "kind": "struct" + } + }, + { + "name": "burnTokenCustodyParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "linkTokenPairParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "localToken", + "type": "pubkey" + }, + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "remoteToken", + "type": "pubkey" + } + ] + } + }, + { + "name": "pauseParams", + "type": { + "kind": "struct" + } + }, + { + "name": "removeLocalTokenParams", + "type": { + "kind": "struct" + } + }, + { + "name": "setMaxBurnAmountPerMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "burnLimitPerMessage", + "type": "u64" + } + ] + } + }, + { + "name": "setTokenControllerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "tokenController", + "type": "pubkey" + } + ] + } + }, + { + "name": "uninkTokenPairParams", + "type": { + "kind": "struct" + } + }, + { + "name": "unpauseParams", + "type": { + "kind": "struct" + } + }, + { + "name": "updatePauserParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newPauser", + "type": "pubkey" + } + ] + } + }, + { + "name": "tokenMinterError", + "type": { + "kind": "enum", + "variants": [ + { + "name": "invalidAuthority" + }, + { + "name": "invalidTokenMinterState" + }, + { + "name": "programPaused" + }, + { + "name": "invalidTokenPairState" + }, + { + "name": "invalidLocalTokenState" + }, + { + "name": "invalidPauser" + }, + { + "name": "invalidTokenController" + }, + { + "name": "burnAmountExceeded" + }, + { + "name": "invalidAmount" + } + ] + } + }, + { + "name": "tokenMessenger", + "type": { + "kind": "struct", + "fields": [ + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "pendingOwner", + "type": "pubkey" + }, + { + "name": "localMessageTransmitter", + "type": "pubkey" + }, + { + "name": "messageBodyVersion", + "type": "u32" + }, + { + "name": "authorityBump", + "type": "u8" + } + ] + } + }, + { + "name": "remoteTokenMessenger", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "tokenMessenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "tokenMinter", + "type": { + "kind": "struct", + "fields": [ + { + "name": "tokenController", + "type": "pubkey" + }, + { + "name": "pauser", + "type": "pubkey" + }, + { + "name": "paused", + "type": "bool" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "tokenPair", + "type": { + "kind": "struct", + "fields": [ + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "remoteToken", + "type": "pubkey" + }, + { + "name": "localToken", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "localToken", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "burnLimitPerMessage", + "type": "u64" + }, + { + "name": "messagesSent", + "type": "u64" + }, + { + "name": "messagesReceived", + "type": "u64" + }, + { + "name": "amountSent", + "type": "u128" + }, + { + "name": "amountReceived", + "type": "u128" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "custodyBump", + "type": "u8" + } + ] + } + }, + { + "name": "ownershipTransferStarted", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previousOwner", + "type": "pubkey" + }, + { + "name": "newOwner", + "type": "pubkey" + } + ] + } + }, + { + "name": "ownershipTransferred", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previousOwner", + "type": "pubkey" + }, + { + "name": "newOwner", + "type": "pubkey" + } + ] + } + }, + { + "name": "depositForBurn", + "type": { + "kind": "struct", + "fields": [ + { + "name": "nonce", + "type": "u64" + }, + { + "name": "burnToken", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "mintRecipient", + "type": "pubkey" + }, + { + "name": "destinationDomain", + "type": "u32" + }, + { + "name": "destinationTokenMessenger", + "type": "pubkey" + }, + { + "name": "destinationCaller", + "type": "pubkey" + } + ] + } + }, + { + "name": "mintAndWithdraw", + "type": { + "kind": "struct", + "fields": [ + { + "name": "mintRecipient", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "mintToken", + "type": "pubkey" + } + ] + } + }, + { + "name": "remoteTokenMessengerAdded", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "tokenMessenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "remoteTokenMessengerRemoved", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "tokenMessenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "setTokenController", + "type": { + "kind": "struct", + "fields": [ + { + "name": "tokenController", + "type": "pubkey" + } + ] + } + }, + { + "name": "pauserChanged", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newAddress", + "type": "pubkey" + } + ] + } + }, + { + "name": "setBurnLimitPerMessage", + "type": { + "kind": "struct", + "fields": [ + { + "name": "token", + "type": "pubkey" + }, + { + "name": "burnLimitPerMessage", + "type": "u64" + } + ] + } + }, + { + "name": "localTokenAdded", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "localTokenRemoved", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "tokenPairLinked", + "type": { + "kind": "struct", + "fields": [ + { + "name": "localToken", + "type": "pubkey" + }, + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "remoteToken", + "type": "pubkey" + } + ] + } + }, + { + "name": "tokenPairUnlinked", + "type": { + "kind": "struct", + "fields": [ + { + "name": "localToken", + "type": "pubkey" + }, + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "remoteToken", + "type": "pubkey" + } + ] + } + }, + { + "name": "pause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "unpause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "tokenCustodyBurned", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custodyTokenAccount", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + } + ] + } + } + ] +}; diff --git a/src/svm/assets/token_messenger_minter_v2.ts b/src/svm/assets/token_messenger_minter_v2.ts new file mode 100644 index 000000000..c447392f9 --- /dev/null +++ b/src/svm/assets/token_messenger_minter_v2.ts @@ -0,0 +1,4447 @@ +/** + * Program IDL in camelCase format in order to be used in JS/TS. + * + * Note that this is only a type helper and is not the actual IDL. The original + * IDL can be found at `target/idl/token_messenger_minter_v2.json`. + */ +export type TokenMessengerMinterV2 = { + "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe", + "metadata": { + "name": "tokenMessengerMinterV2", + "version": "0.2.0", + "spec": "0.1.0", + "description": "Token Messenger and Minter for Cross-Chain Transfer Protocol V2", + "repository": "https://github.com/circlefin/solana-cctp-contracts" + }, + "instructions": [ + { + "name": "acceptOwnership", + "discriminator": [ + 172, + 23, + 43, + 13, + 238, + 213, + 85, + 150 + ], + "accounts": [ + { + "name": "pendingOwner", + "signer": true, + "relations": [ + "tokenMessenger" + ] + }, + { + "name": "tokenMessenger", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "acceptOwnershipParams" + } + } + } + ] + }, + { + "name": "addLocalToken", + "discriminator": [ + 213, + 199, + 205, + 18, + 98, + 124, + 73, + 198 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "tokenController", + "signer": true, + "relations": [ + "tokenMinter" + ] + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "localTokenMint" + } + ] + } + }, + { + "name": "custodyTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "localTokenMint" + } + ] + } + }, + { + "name": "localTokenMint" + }, + { + "name": "tokenProgram", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "addLocalTokenParams" + } + } + } + ] + }, + { + "name": "addRemoteTokenMessenger", + "discriminator": [ + 12, + 149, + 172, + 165, + 111, + 202, + 24, + 33 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "owner", + "signer": true, + "relations": [ + "tokenMessenger" + ] + }, + { + "name": "tokenMessenger" + }, + { + "name": "remoteTokenMessenger", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 109, + 111, + 116, + 101, + 95, + 116, + 111, + 107, + 101, + 110, + 95, + 109, + 101, + 115, + 115, + 101, + 110, + 103, + 101, + 114 + ] + }, + { + "kind": "arg", + "path": "params.domain" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "addRemoteTokenMessengerParams" + } + } + } + ] + }, + { + "name": "burnTokenCustody", + "discriminator": [ + 233, + 136, + 180, + 175, + 112, + 41, + 62, + 71 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "tokenController", + "signer": true, + "relations": [ + "tokenMinter" + ] + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "localToken" + } + ] + } + }, + { + "name": "custodyTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "localToken" + } + ] + } + }, + { + "name": "custodyTokenMint", + "writable": true + }, + { + "name": "tokenProgram", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "burnTokenCustodyParams" + } + } + } + ] + }, + { + "name": "denylistAccount", + "discriminator": [ + 101, + 116, + 197, + 112, + 81, + 249, + 75, + 194 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "denylister", + "signer": true, + "relations": [ + "tokenMessenger" + ] + }, + { + "name": "tokenMessenger" + }, + { + "name": "denylistAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 100, + 101, + 110, + 121, + 108, + 105, + 115, + 116, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "arg", + "path": "params.account" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "denylistParams" + } + } + } + ] + }, + { + "name": "depositForBurn", + "discriminator": [ + 215, + 60, + 61, + 46, + 114, + 55, + 128, + 176 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "burnTokenAccount" + ] + }, + { + "name": "eventRentPayer", + "writable": true, + "signer": true + }, + { + "name": "senderAuthorityPda", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 110, + 100, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "burnTokenAccount", + "writable": true + }, + { + "name": "denylistAccount", + "docs": [ + "Account is denylisted if the account exists at the expected PDA." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 100, + 101, + 110, + 121, + 108, + 105, + 115, + 116, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "account", + "path": "owner" + } + ] + } + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "tokenMessenger" + }, + { + "name": "remoteTokenMessenger" + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "burnTokenMint" + } + ] + } + }, + { + "name": "burnTokenMint", + "writable": true + }, + { + "name": "messageSentEventData", + "writable": true, + "signer": true + }, + { + "name": "messageTransmitterProgram", + "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" + }, + { + "name": "tokenMessengerMinterProgram", + "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" + }, + { + "name": "tokenProgram", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "depositForBurnParams" + } + } + } + ] + }, + { + "name": "depositForBurnWithHook", + "discriminator": [ + 111, + 245, + 62, + 131, + 204, + 108, + 223, + 155 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "burnTokenAccount" + ] + }, + { + "name": "eventRentPayer", + "writable": true, + "signer": true + }, + { + "name": "senderAuthorityPda", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 110, + 100, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "burnTokenAccount", + "writable": true + }, + { + "name": "denylistAccount", + "docs": [ + "Account is denylisted if the account exists at the expected PDA." + ], + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 100, + 101, + 110, + 121, + 108, + 105, + 115, + 116, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "account", + "path": "owner" + } + ] + } + }, + { + "name": "messageTransmitter", + "writable": true + }, + { + "name": "tokenMessenger" + }, + { + "name": "remoteTokenMessenger" + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "burnTokenMint" + } + ] + } + }, + { + "name": "burnTokenMint", + "writable": true + }, + { + "name": "messageSentEventData", + "writable": true, + "signer": true + }, + { + "name": "messageTransmitterProgram", + "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" + }, + { + "name": "tokenMessengerMinterProgram", + "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" + }, + { + "name": "tokenProgram", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "depositForBurnWithHookParams" + } + } + } + ] + }, + { + "name": "handleReceiveFinalizedMessage", + "discriminator": [ + 186, + 252, + 239, + 70, + 86, + 180, + 110, + 95 + ], + "accounts": [ + { + "name": "authorityPda", + "signer": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 115, + 115, + 97, + 103, + 101, + 95, + 116, + 114, + 97, + 110, + 115, + 109, + 105, + 116, + 116, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "const", + "value": [ + 166, + 95, + 200, + 29, + 15, + 239, + 168, + 134, + 12, + 179, + 184, + 63, + 8, + 155, + 2, + 36, + 190, + 138, + 102, + 135, + 183, + 174, + 73, + 245, + 148, + 192, + 185, + 180, + 215, + 233, + 56, + 147 + ] + } + ], + "program": { + "kind": "const", + "value": [ + 166, + 95, + 200, + 28, + 225, + 158, + 220, + 210, + 210, + 195, + 64, + 176, + 47, + 166, + 27, + 225, + 213, + 186, + 221, + 225, + 89, + 40, + 51, + 221, + 249, + 32, + 9, + 216, + 207, + 104, + 84, + 85 + ] + } + } + }, + { + "name": "tokenMessenger" + }, + { + "name": "remoteTokenMessenger" + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "localToken" + } + ] + } + }, + { + "name": "tokenPair" + }, + { + "name": "feeRecipientTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "token_messenger.fee_recipient", + "account": "tokenMessenger" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "localToken" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "recipientTokenAccount", + "writable": true + }, + { + "name": "custodyTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "localToken" + } + ] + } + }, + { + "name": "tokenProgram", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "handleReceiveMessageParams" + } + } + } + ] + }, + { + "name": "handleReceiveUnfinalizedMessage", + "discriminator": [ + 200, + 169, + 175, + 20, + 200, + 58, + 182, + 61 + ], + "accounts": [ + { + "name": "authorityPda", + "signer": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 115, + 115, + 97, + 103, + 101, + 95, + 116, + 114, + 97, + 110, + 115, + 109, + 105, + 116, + 116, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + }, + { + "kind": "const", + "value": [ + 166, + 95, + 200, + 29, + 15, + 239, + 168, + 134, + 12, + 179, + 184, + 63, + 8, + 155, + 2, + 36, + 190, + 138, + 102, + 135, + 183, + 174, + 73, + 245, + 148, + 192, + 185, + 180, + 215, + 233, + 56, + 147 + ] + } + ], + "program": { + "kind": "const", + "value": [ + 166, + 95, + 200, + 28, + 225, + 158, + 220, + 210, + 210, + 195, + 64, + 176, + 47, + 166, + 27, + 225, + 213, + 186, + 221, + 225, + 89, + 40, + 51, + 221, + 249, + 32, + 9, + 216, + 207, + 104, + 84, + 85 + ] + } + } + }, + { + "name": "tokenMessenger" + }, + { + "name": "remoteTokenMessenger" + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "localToken" + } + ] + } + }, + { + "name": "tokenPair" + }, + { + "name": "feeRecipientTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "token_messenger.fee_recipient", + "account": "tokenMessenger" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "localToken" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "recipientTokenAccount", + "writable": true + }, + { + "name": "custodyTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "localToken" + } + ] + } + }, + { + "name": "tokenProgram", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "handleReceiveMessageParams" + } + } + } + ] + }, + { + "name": "initialize", + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "upgradeAuthority", + "signer": true + }, + { + "name": "authorityPda", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 115, + 101, + 110, + 100, + 101, + 114, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "tokenMessenger", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 111, + 107, + 101, + 110, + 95, + 109, + 101, + 115, + 115, + 101, + 110, + 103, + 101, + 114 + ] + } + ] + } + }, + { + "name": "tokenMinter", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 111, + 107, + 101, + 110, + 95, + 109, + 105, + 110, + 116, + 101, + 114 + ] + } + ] + } + }, + { + "name": "tokenMessengerMinterProgramData" + }, + { + "name": "tokenMessengerMinterProgram", + "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "initializeParams" + } + } + } + ] + }, + { + "name": "linkTokenPair", + "discriminator": [ + 68, + 162, + 24, + 104, + 125, + 46, + 130, + 12 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "tokenController", + "signer": true, + "relations": [ + "tokenMinter" + ] + }, + { + "name": "tokenMinter" + }, + { + "name": "tokenPair", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 111, + 107, + 101, + 110, + 95, + 112, + 97, + 105, + 114 + ] + }, + { + "kind": "arg", + "path": "params.remote_domain" + }, + { + "kind": "arg", + "path": "params.remote_token" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "linkTokenPairParams" + } + } + } + ] + }, + { + "name": "pause", + "discriminator": [ + 211, + 22, + 221, + 251, + 74, + 121, + 193, + 47 + ], + "accounts": [ + { + "name": "pauser", + "signer": true, + "relations": [ + "tokenMinter" + ] + }, + { + "name": "tokenMinter", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "pauseParams" + } + } + } + ] + }, + { + "name": "removeLocalToken", + "discriminator": [ + 27, + 43, + 66, + 170, + 188, + 44, + 109, + 97 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "tokenController", + "signer": true, + "relations": [ + "tokenMinter" + ] + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "localToken" + } + ] + } + }, + { + "name": "custodyTokenAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 117, + 115, + 116, + 111, + 100, + 121 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "localToken" + } + ] + } + }, + { + "name": "custodyTokenMint", + "writable": true + }, + { + "name": "tokenProgram", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "removeLocalTokenParams" + } + } + } + ] + }, + { + "name": "removeRemoteTokenMessenger", + "discriminator": [ + 65, + 114, + 66, + 85, + 169, + 98, + 177, + 146 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "owner", + "signer": true, + "relations": [ + "tokenMessenger" + ] + }, + { + "name": "tokenMessenger" + }, + { + "name": "remoteTokenMessenger", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 114, + 101, + 109, + 111, + 116, + 101, + 95, + 116, + 111, + 107, + 101, + 110, + 95, + 109, + 101, + 115, + 115, + 101, + 110, + 103, + 101, + 114 + ] + }, + { + "kind": "account", + "path": "remote_token_messenger.domain", + "account": "remoteTokenMessenger" + } + ] + } + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "removeRemoteTokenMessengerParams" + } + } + } + ] + }, + { + "name": "setFeeRecipient", + "discriminator": [ + 227, + 18, + 215, + 42, + 237, + 246, + 151, + 66 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "tokenMessenger" + ] + }, + { + "name": "tokenMessenger", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setFeeRecipientParams" + } + } + } + ] + }, + { + "name": "setMaxBurnAmountPerMessage", + "discriminator": [ + 30, + 128, + 145, + 240, + 70, + 237, + 109, + 207 + ], + "accounts": [ + { + "name": "tokenController", + "signer": true, + "relations": [ + "tokenMinter" + ] + }, + { + "name": "tokenMinter" + }, + { + "name": "localToken", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 108, + 111, + 99, + 97, + 108, + 95, + 116, + 111, + 107, + 101, + 110 + ] + }, + { + "kind": "account", + "path": "local_token.mint", + "account": "localToken" + } + ] + } + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setMaxBurnAmountPerMessageParams" + } + } + } + ] + }, + { + "name": "setMinFee", + "discriminator": [ + 114, + 198, + 35, + 3, + 41, + 196, + 194, + 246 + ], + "accounts": [ + { + "name": "minFeeController", + "signer": true, + "relations": [ + "tokenMessenger" + ] + }, + { + "name": "tokenMessenger", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setMinFeeParams" + } + } + } + ] + }, + { + "name": "setMinFeeController", + "discriminator": [ + 195, + 142, + 74, + 84, + 234, + 94, + 180, + 113 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "tokenMessenger" + ] + }, + { + "name": "tokenMessenger", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setMinFeeControllerParams" + } + } + } + ] + }, + { + "name": "setTokenController", + "discriminator": [ + 88, + 6, + 98, + 10, + 79, + 59, + 15, + 24 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "tokenMessenger" + ] + }, + { + "name": "tokenMessenger" + }, + { + "name": "tokenMinter", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "setTokenControllerParams" + } + } + } + ] + }, + { + "name": "transferOwnership", + "discriminator": [ + 65, + 177, + 215, + 73, + 53, + 45, + 99, + 47 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "tokenMessenger" + ] + }, + { + "name": "tokenMessenger", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "transferOwnershipParams" + } + } + } + ] + }, + { + "name": "undenylistAccount", + "discriminator": [ + 57, + 36, + 43, + 168, + 62, + 172, + 33, + 39 + ], + "accounts": [ + { + "name": "payer", + "writable": true, + "signer": true + }, + { + "name": "denylister", + "signer": true, + "relations": [ + "tokenMessenger" + ] + }, + { + "name": "tokenMessenger" + }, + { + "name": "denylistAccount", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 100, + 101, + 110, + 121, + 108, + 105, + 115, + 116, + 95, + 97, + 99, + 99, + 111, + 117, + 110, + 116 + ] + }, + { + "kind": "arg", + "path": "params.account" + } + ] + } + }, + { + "name": "systemProgram", + "address": "11111111111111111111111111111111" + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "undenylistParams" + } + } + } + ] + }, + { + "name": "unlinkTokenPair", + "discriminator": [ + 52, + 198, + 100, + 114, + 104, + 174, + 85, + 58 + ], + "accounts": [ + { + "name": "payee", + "writable": true, + "signer": true + }, + { + "name": "tokenController", + "signer": true, + "relations": [ + "tokenMinter" + ] + }, + { + "name": "tokenMinter" + }, + { + "name": "tokenPair", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 116, + 111, + 107, + 101, + 110, + 95, + 112, + 97, + 105, + 114 + ] + }, + { + "kind": "account", + "path": "token_pair.remote_domain", + "account": "tokenPair" + }, + { + "kind": "account", + "path": "token_pair.remote_token", + "account": "tokenPair" + } + ] + } + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "uninkTokenPairParams" + } + } + } + ] + }, + { + "name": "unpause", + "discriminator": [ + 169, + 144, + 4, + 38, + 10, + 141, + 188, + 255 + ], + "accounts": [ + { + "name": "pauser", + "signer": true, + "relations": [ + "tokenMinter" + ] + }, + { + "name": "tokenMinter", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "unpauseParams" + } + } + } + ] + }, + { + "name": "updateDenylister", + "discriminator": [ + 193, + 66, + 198, + 201, + 84, + 57, + 14, + 222 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "tokenMessenger" + ] + }, + { + "name": "tokenMessenger", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "updateDenylisterParams" + } + } + } + ] + }, + { + "name": "updatePauser", + "discriminator": [ + 140, + 171, + 211, + 132, + 57, + 201, + 16, + 254 + ], + "accounts": [ + { + "name": "owner", + "signer": true, + "relations": [ + "tokenMessenger" + ] + }, + { + "name": "tokenMessenger" + }, + { + "name": "tokenMinter", + "writable": true + }, + { + "name": "eventAuthority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "params", + "type": { + "defined": { + "name": "updatePauserParams" + } + } + } + ] + } + ], + "accounts": [ + { + "name": "denylistedAccount", + "discriminator": [ + 186, + 58, + 212, + 239, + 102, + 131, + 157, + 146 + ] + }, + { + "name": "localToken", + "discriminator": [ + 159, + 131, + 58, + 170, + 193, + 84, + 128, + 182 + ] + }, + { + "name": "messageTransmitter", + "discriminator": [ + 71, + 40, + 180, + 142, + 19, + 203, + 35, + 252 + ] + }, + { + "name": "remoteTokenMessenger", + "discriminator": [ + 105, + 115, + 174, + 34, + 95, + 233, + 138, + 252 + ] + }, + { + "name": "tokenMessenger", + "discriminator": [ + 162, + 4, + 242, + 52, + 147, + 243, + 221, + 96 + ] + }, + { + "name": "tokenMinter", + "discriminator": [ + 122, + 133, + 84, + 63, + 57, + 159, + 171, + 206 + ] + }, + { + "name": "tokenPair", + "discriminator": [ + 17, + 214, + 45, + 176, + 229, + 149, + 197, + 71 + ] + } + ], + "events": [ + { + "name": "denylisted", + "discriminator": [ + 20, + 145, + 173, + 200, + 182, + 17, + 234, + 154 + ] + }, + { + "name": "denylisterChanged", + "discriminator": [ + 249, + 170, + 81, + 180, + 185, + 175, + 138, + 72 + ] + }, + { + "name": "depositForBurn", + "discriminator": [ + 144, + 252, + 145, + 146, + 6, + 74, + 167, + 235 + ] + }, + { + "name": "feeRecipientSet", + "discriminator": [ + 99, + 140, + 80, + 35, + 245, + 176, + 179, + 110 + ] + }, + { + "name": "localTokenAdded", + "discriminator": [ + 146, + 8, + 224, + 150, + 122, + 173, + 23, + 39 + ] + }, + { + "name": "localTokenRemoved", + "discriminator": [ + 181, + 204, + 1, + 95, + 2, + 50, + 66, + 210 + ] + }, + { + "name": "minFeeControllerSet", + "discriminator": [ + 239, + 12, + 122, + 105, + 231, + 114, + 13, + 196 + ] + }, + { + "name": "minFeeSet", + "discriminator": [ + 60, + 127, + 101, + 230, + 216, + 129, + 188, + 98 + ] + }, + { + "name": "mintAndWithdraw", + "discriminator": [ + 75, + 67, + 229, + 70, + 162, + 126, + 0, + 71 + ] + }, + { + "name": "ownershipTransferStarted", + "discriminator": [ + 183, + 253, + 239, + 246, + 140, + 179, + 133, + 105 + ] + }, + { + "name": "ownershipTransferred", + "discriminator": [ + 172, + 61, + 205, + 183, + 250, + 50, + 38, + 98 + ] + }, + { + "name": "pause", + "discriminator": [ + 194, + 251, + 232, + 196, + 118, + 95, + 111, + 219 + ] + }, + { + "name": "pauserChanged", + "discriminator": [ + 142, + 157, + 158, + 87, + 127, + 8, + 119, + 55 + ] + }, + { + "name": "remoteTokenMessengerAdded", + "discriminator": [ + 251, + 29, + 63, + 244, + 48, + 114, + 210, + 175 + ] + }, + { + "name": "remoteTokenMessengerRemoved", + "discriminator": [ + 255, + 121, + 137, + 39, + 230, + 125, + 11, + 30 + ] + }, + { + "name": "setBurnLimitPerMessage", + "discriminator": [ + 98, + 152, + 88, + 191, + 245, + 30, + 27, + 209 + ] + }, + { + "name": "setTokenController", + "discriminator": [ + 193, + 44, + 243, + 83, + 230, + 72, + 120, + 216 + ] + }, + { + "name": "tokenCustodyBurned", + "discriminator": [ + 219, + 143, + 107, + 226, + 67, + 75, + 178, + 46 + ] + }, + { + "name": "tokenPairLinked", + "discriminator": [ + 2, + 14, + 177, + 64, + 155, + 93, + 196, + 141 + ] + }, + { + "name": "tokenPairUnlinked", + "discriminator": [ + 78, + 232, + 230, + 208, + 180, + 212, + 246, + 72 + ] + }, + { + "name": "unDenylisted", + "discriminator": [ + 150, + 39, + 227, + 20, + 162, + 180, + 5, + 242 + ] + }, + { + "name": "unpause", + "discriminator": [ + 241, + 149, + 104, + 90, + 199, + 136, + 219, + 146 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "invalidAuthority", + "msg": "Invalid authority" + }, + { + "code": 6001, + "name": "invalidTokenMinterState", + "msg": "Invalid token minter state" + }, + { + "code": 6002, + "name": "programPaused", + "msg": "Instruction is not allowed at this time" + }, + { + "code": 6003, + "name": "invalidTokenPairState", + "msg": "Invalid token pair state" + }, + { + "code": 6004, + "name": "invalidLocalTokenState", + "msg": "Invalid local token state" + }, + { + "code": 6005, + "name": "invalidPauser", + "msg": "Invalid pauser" + }, + { + "code": 6006, + "name": "invalidTokenController", + "msg": "Invalid token controller" + }, + { + "code": 6007, + "name": "burnAmountExceeded", + "msg": "Burn amount exceeded" + }, + { + "code": 6008, + "name": "invalidAmount", + "msg": "Invalid amount" + } + ], + "types": [ + { + "name": "acceptOwnershipParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "addLocalTokenParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "addRemoteTokenMessengerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "tokenMessenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "burnTokenCustodyParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "denylistParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "account", + "type": "pubkey" + } + ] + } + }, + { + "name": "denylisted", + "type": { + "kind": "struct", + "fields": [ + { + "name": "account", + "type": "pubkey" + } + ] + } + }, + { + "name": "denylistedAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "account", + "type": "pubkey" + } + ] + } + }, + { + "name": "denylisterChanged", + "type": { + "kind": "struct", + "fields": [ + { + "name": "oldDenylister", + "type": "pubkey" + }, + { + "name": "newDenylister", + "type": "pubkey" + } + ] + } + }, + { + "name": "depositForBurn", + "type": { + "kind": "struct", + "fields": [ + { + "name": "burnToken", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "depositor", + "type": "pubkey" + }, + { + "name": "mintRecipient", + "type": "pubkey" + }, + { + "name": "destinationDomain", + "type": "u32" + }, + { + "name": "destinationTokenMessenger", + "type": "pubkey" + }, + { + "name": "destinationCaller", + "type": "pubkey" + }, + { + "name": "maxFee", + "type": "u64" + }, + { + "name": "minFinalityThreshold", + "type": "u32" + }, + { + "name": "hookData", + "type": "bytes" + } + ] + } + }, + { + "name": "depositForBurnParams", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "destinationDomain", + "type": "u32" + }, + { + "name": "mintRecipient", + "type": "pubkey" + }, + { + "name": "destinationCaller", + "type": "pubkey" + }, + { + "name": "maxFee", + "type": "u64" + }, + { + "name": "minFinalityThreshold", + "type": "u32" + } + ] + } + }, + { + "name": "depositForBurnWithHookParams", + "repr": { + "kind": "c" + }, + "type": { + "kind": "struct", + "fields": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "destinationDomain", + "type": "u32" + }, + { + "name": "mintRecipient", + "type": "pubkey" + }, + { + "name": "destinationCaller", + "type": "pubkey" + }, + { + "name": "maxFee", + "type": "u64" + }, + { + "name": "minFinalityThreshold", + "type": "u32" + }, + { + "name": "hookData", + "type": "bytes" + } + ] + } + }, + { + "name": "feeRecipientSet", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newFeeRecipient", + "type": "pubkey" + } + ] + } + }, + { + "name": "handleReceiveMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "sender", + "type": "pubkey" + }, + { + "name": "finalityThresholdExecuted", + "type": "u32" + }, + { + "name": "messageBody", + "type": "bytes" + }, + { + "name": "authorityBump", + "type": "u8" + } + ] + } + }, + { + "name": "initializeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "tokenController", + "type": "pubkey" + }, + { + "name": "denylister", + "type": "pubkey" + }, + { + "name": "feeRecipient", + "type": "pubkey" + }, + { + "name": "minFeeController", + "type": "pubkey" + }, + { + "name": "minFee", + "type": "u32" + }, + { + "name": "messageBodyVersion", + "type": "u32" + } + ] + } + }, + { + "name": "linkTokenPairParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "localToken", + "type": "pubkey" + }, + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "remoteToken", + "type": "pubkey" + } + ] + } + }, + { + "name": "localToken", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "burnLimitPerMessage", + "type": "u64" + }, + { + "name": "messagesSent", + "type": "u64" + }, + { + "name": "messagesReceived", + "type": "u64" + }, + { + "name": "amountSent", + "type": "u128" + }, + { + "name": "amountReceived", + "type": "u128" + }, + { + "name": "bump", + "type": "u8" + }, + { + "name": "custodyBump", + "type": "u8" + } + ] + } + }, + { + "name": "localTokenAdded", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "localTokenRemoved", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custody", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + } + ] + } + }, + { + "name": "messageTransmitter", + "docs": [ + "Main state of the MessageTransmitter program" + ], + "type": { + "kind": "struct", + "fields": [ + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "pendingOwner", + "type": "pubkey" + }, + { + "name": "attesterManager", + "type": "pubkey" + }, + { + "name": "pauser", + "type": "pubkey" + }, + { + "name": "paused", + "type": "bool" + }, + { + "name": "localDomain", + "type": "u32" + }, + { + "name": "version", + "type": "u32" + }, + { + "name": "signatureThreshold", + "type": "u32" + }, + { + "name": "enabledAttesters", + "type": { + "vec": "pubkey" + } + }, + { + "name": "maxMessageBodySize", + "type": "u64" + } + ] + } + }, + { + "name": "minFeeControllerSet", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newMinFeeController", + "type": "pubkey" + } + ] + } + }, + { + "name": "minFeeSet", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newMinFee", + "type": "u32" + } + ] + } + }, + { + "name": "mintAndWithdraw", + "type": { + "kind": "struct", + "fields": [ + { + "name": "mintRecipient", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + }, + { + "name": "mintToken", + "type": "pubkey" + }, + { + "name": "feeCollected", + "type": "u64" + } + ] + } + }, + { + "name": "ownershipTransferStarted", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previousOwner", + "type": "pubkey" + }, + { + "name": "newOwner", + "type": "pubkey" + } + ] + } + }, + { + "name": "ownershipTransferred", + "type": { + "kind": "struct", + "fields": [ + { + "name": "previousOwner", + "type": "pubkey" + }, + { + "name": "newOwner", + "type": "pubkey" + } + ] + } + }, + { + "name": "pause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "pauseParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "pauserChanged", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newAddress", + "type": "pubkey" + } + ] + } + }, + { + "name": "remoteTokenMessenger", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "tokenMessenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "remoteTokenMessengerAdded", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "tokenMessenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "remoteTokenMessengerRemoved", + "type": { + "kind": "struct", + "fields": [ + { + "name": "domain", + "type": "u32" + }, + { + "name": "tokenMessenger", + "type": "pubkey" + } + ] + } + }, + { + "name": "removeLocalTokenParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "removeRemoteTokenMessengerParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "setBurnLimitPerMessage", + "type": { + "kind": "struct", + "fields": [ + { + "name": "token", + "type": "pubkey" + }, + { + "name": "burnLimitPerMessage", + "type": "u64" + } + ] + } + }, + { + "name": "setFeeRecipientParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newFeeRecipient", + "type": "pubkey" + } + ] + } + }, + { + "name": "setMaxBurnAmountPerMessageParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "burnLimitPerMessage", + "type": "u64" + } + ] + } + }, + { + "name": "setMinFeeControllerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newMinFeeController", + "type": "pubkey" + } + ] + } + }, + { + "name": "setMinFeeParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newMinFee", + "type": "u32" + } + ] + } + }, + { + "name": "setTokenController", + "type": { + "kind": "struct", + "fields": [ + { + "name": "tokenController", + "type": "pubkey" + } + ] + } + }, + { + "name": "setTokenControllerParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "tokenController", + "type": "pubkey" + } + ] + } + }, + { + "name": "tokenCustodyBurned", + "type": { + "kind": "struct", + "fields": [ + { + "name": "custodyTokenAccount", + "type": "pubkey" + }, + { + "name": "amount", + "type": "u64" + } + ] + } + }, + { + "name": "tokenMessenger", + "type": { + "kind": "struct", + "fields": [ + { + "name": "denylister", + "type": "pubkey" + }, + { + "name": "owner", + "type": "pubkey" + }, + { + "name": "pendingOwner", + "type": "pubkey" + }, + { + "name": "messageBodyVersion", + "type": "u32" + }, + { + "name": "authorityBump", + "type": "u8" + }, + { + "name": "feeRecipient", + "type": "pubkey" + }, + { + "name": "minFeeController", + "type": "pubkey" + }, + { + "name": "minFee", + "type": "u32" + } + ] + } + }, + { + "name": "tokenMinter", + "type": { + "kind": "struct", + "fields": [ + { + "name": "tokenController", + "type": "pubkey" + }, + { + "name": "pauser", + "type": "pubkey" + }, + { + "name": "paused", + "type": "bool" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "tokenPair", + "type": { + "kind": "struct", + "fields": [ + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "remoteToken", + "type": "pubkey" + }, + { + "name": "localToken", + "type": "pubkey" + }, + { + "name": "bump", + "type": "u8" + } + ] + } + }, + { + "name": "tokenPairLinked", + "type": { + "kind": "struct", + "fields": [ + { + "name": "localToken", + "type": "pubkey" + }, + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "remoteToken", + "type": "pubkey" + } + ] + } + }, + { + "name": "tokenPairUnlinked", + "type": { + "kind": "struct", + "fields": [ + { + "name": "localToken", + "type": "pubkey" + }, + { + "name": "remoteDomain", + "type": "u32" + }, + { + "name": "remoteToken", + "type": "pubkey" + } + ] + } + }, + { + "name": "transferOwnershipParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newOwner", + "type": "pubkey" + } + ] + } + }, + { + "name": "unDenylisted", + "type": { + "kind": "struct", + "fields": [ + { + "name": "account", + "type": "pubkey" + } + ] + } + }, + { + "name": "undenylistParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "account", + "type": "pubkey" + } + ] + } + }, + { + "name": "uninkTokenPairParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "unpause", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "unpauseParams", + "type": { + "kind": "struct", + "fields": [] + } + }, + { + "name": "updateDenylisterParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newDenylister", + "type": "pubkey" + } + ] + } + }, + { + "name": "updatePauserParams", + "type": { + "kind": "struct", + "fields": [ + { + "name": "newPauser", + "type": "pubkey" + } + ] + } + } + ] +}; diff --git a/src/svm/clients/MessageTransmitter/accounts/index.ts b/src/svm/clients/MessageTransmitter/accounts/index.ts new file mode 100644 index 000000000..2b409df43 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/accounts/index.ts @@ -0,0 +1,11 @@ +/** + * 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 './messageSent'; +export * from './messageTransmitter'; +export * from './usedNonces'; diff --git a/src/svm/clients/MessageTransmitter/accounts/messageSent.ts b/src/svm/clients/MessageTransmitter/accounts/messageSent.ts new file mode 100644 index 000000000..0accd2aa4 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/accounts/messageSent.ts @@ -0,0 +1,137 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const MESSAGE_SENT_DISCRIMINATOR = new Uint8Array([ + 131, 100, 133, 56, 166, 225, 151, 60, +]); + +export function getMessageSentDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + MESSAGE_SENT_DISCRIMINATOR + ); +} + +export type MessageSent = { + discriminator: ReadonlyUint8Array; + rentPayer: Address; + message: ReadonlyUint8Array; +}; + +export type MessageSentArgs = { + rentPayer: Address; + message: ReadonlyUint8Array; +}; + +export function getMessageSentEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['rentPayer', getAddressEncoder()], + ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ ...value, discriminator: MESSAGE_SENT_DISCRIMINATOR }) + ); +} + +export function getMessageSentDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['rentPayer', getAddressDecoder()], + ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getMessageSentCodec(): Codec { + return combineCodec(getMessageSentEncoder(), getMessageSentDecoder()); +} + +export function decodeMessageSent( + encodedAccount: EncodedAccount +): Account; +export function decodeMessageSent( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeMessageSent( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getMessageSentDecoder() + ); +} + +export async function fetchMessageSent( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeMessageSent(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeMessageSent( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeMessageSent(maybeAccount); +} + +export async function fetchAllMessageSent( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeMessageSent(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeMessageSent( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeMessageSent(maybeAccount)); +} diff --git a/src/svm/clients/MessageTransmitter/accounts/messageTransmitter.ts b/src/svm/clients/MessageTransmitter/accounts/messageTransmitter.ts new file mode 100644 index 000000000..fc36cae2e --- /dev/null +++ b/src/svm/clients/MessageTransmitter/accounts/messageTransmitter.ts @@ -0,0 +1,193 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBooleanDecoder, + getBooleanEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const MESSAGE_TRANSMITTER_DISCRIMINATOR = new Uint8Array([ + 71, 40, 180, 142, 19, 203, 35, 252, +]); + +export function getMessageTransmitterDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + MESSAGE_TRANSMITTER_DISCRIMINATOR + ); +} + +export type MessageTransmitter = { + discriminator: ReadonlyUint8Array; + owner: Address; + pendingOwner: Address; + attesterManager: Address; + pauser: Address; + paused: boolean; + localDomain: number; + version: number; + signatureThreshold: number; + enabledAttesters: Array
; + maxMessageBodySize: bigint; + nextAvailableNonce: bigint; +}; + +export type MessageTransmitterArgs = { + owner: Address; + pendingOwner: Address; + attesterManager: Address; + pauser: Address; + paused: boolean; + localDomain: number; + version: number; + signatureThreshold: number; + enabledAttesters: Array
; + maxMessageBodySize: number | bigint; + nextAvailableNonce: number | bigint; +}; + +export function getMessageTransmitterEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['owner', getAddressEncoder()], + ['pendingOwner', getAddressEncoder()], + ['attesterManager', getAddressEncoder()], + ['pauser', getAddressEncoder()], + ['paused', getBooleanEncoder()], + ['localDomain', getU32Encoder()], + ['version', getU32Encoder()], + ['signatureThreshold', getU32Encoder()], + ['enabledAttesters', getArrayEncoder(getAddressEncoder())], + ['maxMessageBodySize', getU64Encoder()], + ['nextAvailableNonce', getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: MESSAGE_TRANSMITTER_DISCRIMINATOR }) + ); +} + +export function getMessageTransmitterDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['owner', getAddressDecoder()], + ['pendingOwner', getAddressDecoder()], + ['attesterManager', getAddressDecoder()], + ['pauser', getAddressDecoder()], + ['paused', getBooleanDecoder()], + ['localDomain', getU32Decoder()], + ['version', getU32Decoder()], + ['signatureThreshold', getU32Decoder()], + ['enabledAttesters', getArrayDecoder(getAddressDecoder())], + ['maxMessageBodySize', getU64Decoder()], + ['nextAvailableNonce', getU64Decoder()], + ]); +} + +export function getMessageTransmitterCodec(): Codec< + MessageTransmitterArgs, + MessageTransmitter +> { + return combineCodec( + getMessageTransmitterEncoder(), + getMessageTransmitterDecoder() + ); +} + +export function decodeMessageTransmitter( + encodedAccount: EncodedAccount +): Account; +export function decodeMessageTransmitter( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeMessageTransmitter( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getMessageTransmitterDecoder() + ); +} + +export async function fetchMessageTransmitter( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeMessageTransmitter(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeMessageTransmitter< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeMessageTransmitter(maybeAccount); +} + +export async function fetchAllMessageTransmitter( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeMessageTransmitter( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeMessageTransmitter( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeMessageTransmitter(maybeAccount) + ); +} diff --git a/src/svm/clients/MessageTransmitter/accounts/usedNonces.ts b/src/svm/clients/MessageTransmitter/accounts/usedNonces.ts new file mode 100644 index 000000000..e872a957b --- /dev/null +++ b/src/svm/clients/MessageTransmitter/accounts/usedNonces.ts @@ -0,0 +1,143 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const USED_NONCES_DISCRIMINATOR = new Uint8Array([ + 60, 112, 18, 72, 138, 181, 100, 138, +]); + +export function getUsedNoncesDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(USED_NONCES_DISCRIMINATOR); +} + +export type UsedNonces = { + discriminator: ReadonlyUint8Array; + remoteDomain: number; + firstNonce: bigint; + usedNonces: Array; +}; + +export type UsedNoncesArgs = { + remoteDomain: number; + firstNonce: number | bigint; + usedNonces: Array; +}; + +export function getUsedNoncesEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['remoteDomain', getU32Encoder()], + ['firstNonce', getU64Encoder()], + ['usedNonces', getArrayEncoder(getU64Encoder(), { size: 100 })], + ]), + (value) => ({ ...value, discriminator: USED_NONCES_DISCRIMINATOR }) + ); +} + +export function getUsedNoncesDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['remoteDomain', getU32Decoder()], + ['firstNonce', getU64Decoder()], + ['usedNonces', getArrayDecoder(getU64Decoder(), { size: 100 })], + ]); +} + +export function getUsedNoncesCodec(): Codec { + return combineCodec(getUsedNoncesEncoder(), getUsedNoncesDecoder()); +} + +export function decodeUsedNonces( + encodedAccount: EncodedAccount +): Account; +export function decodeUsedNonces( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeUsedNonces( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getUsedNoncesDecoder() + ); +} + +export async function fetchUsedNonces( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeUsedNonces(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeUsedNonces( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeUsedNonces(maybeAccount); +} + +export async function fetchAllUsedNonces( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeUsedNonces(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeUsedNonces( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeUsedNonces(maybeAccount)); +} + +export function getUsedNoncesSize(): number { + return 820; +} diff --git a/src/svm/clients/MessageTransmitter/errors/index.ts b/src/svm/clients/MessageTransmitter/errors/index.ts new file mode 100644 index 000000000..35d6ae3df --- /dev/null +++ b/src/svm/clients/MessageTransmitter/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 './messageTransmitter'; diff --git a/src/svm/clients/MessageTransmitter/errors/messageTransmitter.ts b/src/svm/clients/MessageTransmitter/errors/messageTransmitter.ts new file mode 100644 index 000000000..eab5c97ed --- /dev/null +++ b/src/svm/clients/MessageTransmitter/errors/messageTransmitter.ts @@ -0,0 +1,184 @@ +/** + * 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/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; + +/** InvalidAuthority: Invalid authority */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_AUTHORITY = 0x1770; // 6000 +/** ProgramPaused: Instruction is not allowed at this time */ +export const MESSAGE_TRANSMITTER_ERROR__PROGRAM_PAUSED = 0x1771; // 6001 +/** InvalidMessageTransmitterState: Invalid message transmitter state */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_TRANSMITTER_STATE = 0x1772; // 6002 +/** InvalidSignatureThreshold: Invalid signature threshold */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_THRESHOLD = 0x1773; // 6003 +/** SignatureThresholdAlreadySet: Signature threshold already set */ +export const MESSAGE_TRANSMITTER_ERROR__SIGNATURE_THRESHOLD_ALREADY_SET = 0x1774; // 6004 +/** InvalidOwner: Invalid owner */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_OWNER = 0x1775; // 6005 +/** InvalidPauser: Invalid pauser */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_PAUSER = 0x1776; // 6006 +/** InvalidAttesterManager: Invalid attester manager */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER_MANAGER = 0x1777; // 6007 +/** InvalidAttester: Invalid attester */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER = 0x1778; // 6008 +/** AttesterAlreadyEnabled: Attester already enabled */ +export const MESSAGE_TRANSMITTER_ERROR__ATTESTER_ALREADY_ENABLED = 0x1779; // 6009 +/** TooFewEnabledAttesters: Too few enabled attesters */ +export const MESSAGE_TRANSMITTER_ERROR__TOO_FEW_ENABLED_ATTESTERS = 0x177a; // 6010 +/** SignatureThresholdTooLow: Signature threshold is too low */ +export const MESSAGE_TRANSMITTER_ERROR__SIGNATURE_THRESHOLD_TOO_LOW = 0x177b; // 6011 +/** AttesterAlreadyDisabled: Attester already disabled */ +export const MESSAGE_TRANSMITTER_ERROR__ATTESTER_ALREADY_DISABLED = 0x177c; // 6012 +/** MessageBodyLimitExceeded: Message body exceeds max size */ +export const MESSAGE_TRANSMITTER_ERROR__MESSAGE_BODY_LIMIT_EXCEEDED = 0x177d; // 6013 +/** InvalidDestinationCaller: Invalid destination caller */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_DESTINATION_CALLER = 0x177e; // 6014 +/** InvalidRecipient: Invalid message recipient */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_RECIPIENT = 0x177f; // 6015 +/** SenderNotPermitted: Sender is not permitted */ +export const MESSAGE_TRANSMITTER_ERROR__SENDER_NOT_PERMITTED = 0x1780; // 6016 +/** InvalidSourceDomain: Invalid source domain */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_SOURCE_DOMAIN = 0x1781; // 6017 +/** InvalidDestinationDomain: Invalid destination domain */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_DESTINATION_DOMAIN = 0x1782; // 6018 +/** InvalidMessageVersion: Invalid message version */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_VERSION = 0x1783; // 6019 +/** InvalidUsedNoncesAccount: Invalid used nonces account */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_USED_NONCES_ACCOUNT = 0x1784; // 6020 +/** InvalidRecipientProgram: Invalid recipient program */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_RECIPIENT_PROGRAM = 0x1785; // 6021 +/** InvalidNonce: Invalid nonce */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_NONCE = 0x1786; // 6022 +/** NonceAlreadyUsed: Nonce already used */ +export const MESSAGE_TRANSMITTER_ERROR__NONCE_ALREADY_USED = 0x1787; // 6023 +/** MessageTooShort: Message is too short */ +export const MESSAGE_TRANSMITTER_ERROR__MESSAGE_TOO_SHORT = 0x1788; // 6024 +/** MalformedMessage: Malformed message */ +export const MESSAGE_TRANSMITTER_ERROR__MALFORMED_MESSAGE = 0x1789; // 6025 +/** InvalidSignatureOrderOrDupe: Invalid signature order or dupe */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_ORDER_OR_DUPE = 0x178a; // 6026 +/** InvalidAttesterSignature: Invalid attester signature */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER_SIGNATURE = 0x178b; // 6027 +/** InvalidAttestationLength: Invalid attestation length */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTATION_LENGTH = 0x178c; // 6028 +/** InvalidSignatureRecoveryId: Invalid signature recovery ID */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_RECOVERY_ID = 0x178d; // 6029 +/** InvalidSignatureSValue: Invalid signature S value */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_S_VALUE = 0x178e; // 6030 +/** InvalidMessageHash: Invalid message hash */ +export const MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_HASH = 0x178f; // 6031 + +export type MessageTransmitterError = + | typeof MESSAGE_TRANSMITTER_ERROR__ATTESTER_ALREADY_DISABLED + | typeof MESSAGE_TRANSMITTER_ERROR__ATTESTER_ALREADY_ENABLED + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTATION_LENGTH + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER_MANAGER + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER_SIGNATURE + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_AUTHORITY + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_DESTINATION_CALLER + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_DESTINATION_DOMAIN + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_HASH + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_TRANSMITTER_STATE + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_VERSION + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_NONCE + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_OWNER + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_PAUSER + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_RECIPIENT + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_RECIPIENT_PROGRAM + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_ORDER_OR_DUPE + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_RECOVERY_ID + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_S_VALUE + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_THRESHOLD + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_SOURCE_DOMAIN + | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_USED_NONCES_ACCOUNT + | typeof MESSAGE_TRANSMITTER_ERROR__MALFORMED_MESSAGE + | typeof MESSAGE_TRANSMITTER_ERROR__MESSAGE_BODY_LIMIT_EXCEEDED + | typeof MESSAGE_TRANSMITTER_ERROR__MESSAGE_TOO_SHORT + | typeof MESSAGE_TRANSMITTER_ERROR__NONCE_ALREADY_USED + | typeof MESSAGE_TRANSMITTER_ERROR__PROGRAM_PAUSED + | typeof MESSAGE_TRANSMITTER_ERROR__SENDER_NOT_PERMITTED + | typeof MESSAGE_TRANSMITTER_ERROR__SIGNATURE_THRESHOLD_ALREADY_SET + | typeof MESSAGE_TRANSMITTER_ERROR__SIGNATURE_THRESHOLD_TOO_LOW + | typeof MESSAGE_TRANSMITTER_ERROR__TOO_FEW_ENABLED_ATTESTERS; + +let messageTransmitterErrorMessages: + | Record + | undefined; +if (process.env.NODE_ENV !== 'production') { + messageTransmitterErrorMessages = { + [MESSAGE_TRANSMITTER_ERROR__ATTESTER_ALREADY_DISABLED]: `Attester already disabled`, + [MESSAGE_TRANSMITTER_ERROR__ATTESTER_ALREADY_ENABLED]: `Attester already enabled`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTATION_LENGTH]: `Invalid attestation length`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER]: `Invalid attester`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER_MANAGER]: `Invalid attester manager`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER_SIGNATURE]: `Invalid attester signature`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_AUTHORITY]: `Invalid authority`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_DESTINATION_CALLER]: `Invalid destination caller`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_DESTINATION_DOMAIN]: `Invalid destination domain`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_HASH]: `Invalid message hash`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_TRANSMITTER_STATE]: `Invalid message transmitter state`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_VERSION]: `Invalid message version`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_NONCE]: `Invalid nonce`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_OWNER]: `Invalid owner`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_PAUSER]: `Invalid pauser`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_RECIPIENT]: `Invalid message recipient`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_RECIPIENT_PROGRAM]: `Invalid recipient program`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_ORDER_OR_DUPE]: `Invalid signature order or dupe`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_RECOVERY_ID]: `Invalid signature recovery ID`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_S_VALUE]: `Invalid signature S value`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_THRESHOLD]: `Invalid signature threshold`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_SOURCE_DOMAIN]: `Invalid source domain`, + [MESSAGE_TRANSMITTER_ERROR__INVALID_USED_NONCES_ACCOUNT]: `Invalid used nonces account`, + [MESSAGE_TRANSMITTER_ERROR__MALFORMED_MESSAGE]: `Malformed message`, + [MESSAGE_TRANSMITTER_ERROR__MESSAGE_BODY_LIMIT_EXCEEDED]: `Message body exceeds max size`, + [MESSAGE_TRANSMITTER_ERROR__MESSAGE_TOO_SHORT]: `Message is too short`, + [MESSAGE_TRANSMITTER_ERROR__NONCE_ALREADY_USED]: `Nonce already used`, + [MESSAGE_TRANSMITTER_ERROR__PROGRAM_PAUSED]: `Instruction is not allowed at this time`, + [MESSAGE_TRANSMITTER_ERROR__SENDER_NOT_PERMITTED]: `Sender is not permitted`, + [MESSAGE_TRANSMITTER_ERROR__SIGNATURE_THRESHOLD_ALREADY_SET]: `Signature threshold already set`, + [MESSAGE_TRANSMITTER_ERROR__SIGNATURE_THRESHOLD_TOO_LOW]: `Signature threshold is too low`, + [MESSAGE_TRANSMITTER_ERROR__TOO_FEW_ENABLED_ATTESTERS]: `Too few enabled attesters`, + }; +} + +export function getMessageTransmitterErrorMessage( + code: MessageTransmitterError +): string { + if (process.env.NODE_ENV !== 'production') { + return ( + messageTransmitterErrorMessages as Record + )[code]; + } + + return 'Error message not available in production bundles.'; +} + +export function isMessageTransmitterError< + TProgramErrorCode extends MessageTransmitterError, +>( + error: unknown, + transactionMessage: { + instructions: Record; + }, + code?: TProgramErrorCode +): error is SolanaError & + Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { + return isProgramError( + error, + transactionMessage, + MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + code + ); +} diff --git a/src/svm/clients/MessageTransmitter/index.ts b/src/svm/clients/MessageTransmitter/index.ts new file mode 100644 index 000000000..02964a6ae --- /dev/null +++ b/src/svm/clients/MessageTransmitter/index.ts @@ -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. + * + * @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/src/svm/clients/MessageTransmitter/instructions/acceptOwnership.ts b/src/svm/clients/MessageTransmitter/instructions/acceptOwnership.ts new file mode 100644 index 000000000..ed851fa91 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/acceptOwnership.ts @@ -0,0 +1,218 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const ACCEPT_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ + 172, 23, 43, 13, 238, 213, 85, 150, +]); + +export function getAcceptOwnershipDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + ACCEPT_OWNERSHIP_DISCRIMINATOR + ); +} + +export type AcceptOwnershipInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountPendingOwner extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPendingOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountPendingOwner, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type AcceptOwnershipInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type AcceptOwnershipInstructionDataArgs = {}; + +export function getAcceptOwnershipInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: ACCEPT_OWNERSHIP_DISCRIMINATOR }) + ); +} + +export function getAcceptOwnershipInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getAcceptOwnershipInstructionDataCodec(): Codec< + AcceptOwnershipInstructionDataArgs, + AcceptOwnershipInstructionData +> { + return combineCodec( + getAcceptOwnershipInstructionDataEncoder(), + getAcceptOwnershipInstructionDataDecoder() + ); +} + +export type AcceptOwnershipInput< + TAccountPendingOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pendingOwner: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; +}; + +export function getAcceptOwnershipInstruction< + TAccountPendingOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: AcceptOwnershipInput< + TAccountPendingOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): AcceptOwnershipInstruction< + TProgramAddress, + TAccountPendingOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pendingOwner: { value: input.pendingOwner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pendingOwner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getAcceptOwnershipInstructionDataEncoder().encode({}), + } as AcceptOwnershipInstruction< + TProgramAddress, + TAccountPendingOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedAcceptOwnershipInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + pendingOwner: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: AcceptOwnershipInstructionData; +}; + +export function parseAcceptOwnershipInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedAcceptOwnershipInstruction { + if (instruction.accounts.length < 4) { + // 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: { + pendingOwner: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getAcceptOwnershipInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/disableAttester.ts b/src/svm/clients/MessageTransmitter/instructions/disableAttester.ts new file mode 100644 index 000000000..0c14036af --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/disableAttester.ts @@ -0,0 +1,271 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const DISABLE_ATTESTER_DISCRIMINATOR = new Uint8Array([ + 61, 171, 131, 95, 172, 15, 227, 229, +]); + +export function getDisableAttesterDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DISABLE_ATTESTER_DISCRIMINATOR + ); +} + +export type DisableAttesterInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountAttesterManager extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountAttesterManager extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAttesterManager, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type DisableAttesterInstructionData = { + discriminator: ReadonlyUint8Array; + attester: Address; +}; + +export type DisableAttesterInstructionDataArgs = { attester: Address }; + +export function getDisableAttesterInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['attester', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: DISABLE_ATTESTER_DISCRIMINATOR }) + ); +} + +export function getDisableAttesterInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['attester', getAddressDecoder()], + ]); +} + +export function getDisableAttesterInstructionDataCodec(): Codec< + DisableAttesterInstructionDataArgs, + DisableAttesterInstructionData +> { + return combineCodec( + getDisableAttesterInstructionDataEncoder(), + getDisableAttesterInstructionDataDecoder() + ); +} + +export type DisableAttesterInput< + TAccountPayer extends string = string, + TAccountAttesterManager extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + attesterManager: TransactionSigner; + messageTransmitter: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + attester: DisableAttesterInstructionDataArgs['attester']; +}; + +export function getDisableAttesterInstruction< + TAccountPayer extends string, + TAccountAttesterManager extends string, + TAccountMessageTransmitter extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: DisableAttesterInput< + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): DisableAttesterInstruction< + TProgramAddress, + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + attesterManager: { + value: input.attesterManager ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.attesterManager), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDisableAttesterInstructionDataEncoder().encode( + args as DisableAttesterInstructionDataArgs + ), + } as DisableAttesterInstruction< + TProgramAddress, + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedDisableAttesterInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + attesterManager: TAccountMetas[1]; + messageTransmitter: TAccountMetas[2]; + systemProgram: TAccountMetas[3]; + eventAuthority: TAccountMetas[4]; + program: TAccountMetas[5]; + }; + data: DisableAttesterInstructionData; +}; + +export function parseDisableAttesterInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedDisableAttesterInstruction { + if (instruction.accounts.length < 6) { + // 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: { + payer: getNextAccount(), + attesterManager: getNextAccount(), + messageTransmitter: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getDisableAttesterInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/enableAttester.ts b/src/svm/clients/MessageTransmitter/instructions/enableAttester.ts new file mode 100644 index 000000000..68f9761dd --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/enableAttester.ts @@ -0,0 +1,271 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const ENABLE_ATTESTER_DISCRIMINATOR = new Uint8Array([ + 2, 11, 193, 115, 5, 148, 4, 198, +]); + +export function getEnableAttesterDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + ENABLE_ATTESTER_DISCRIMINATOR + ); +} + +export type EnableAttesterInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountAttesterManager extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountAttesterManager extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAttesterManager, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type EnableAttesterInstructionData = { + discriminator: ReadonlyUint8Array; + newAttester: Address; +}; + +export type EnableAttesterInstructionDataArgs = { newAttester: Address }; + +export function getEnableAttesterInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newAttester', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: ENABLE_ATTESTER_DISCRIMINATOR }) + ); +} + +export function getEnableAttesterInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newAttester', getAddressDecoder()], + ]); +} + +export function getEnableAttesterInstructionDataCodec(): Codec< + EnableAttesterInstructionDataArgs, + EnableAttesterInstructionData +> { + return combineCodec( + getEnableAttesterInstructionDataEncoder(), + getEnableAttesterInstructionDataDecoder() + ); +} + +export type EnableAttesterInput< + TAccountPayer extends string = string, + TAccountAttesterManager extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + attesterManager: TransactionSigner; + messageTransmitter: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + newAttester: EnableAttesterInstructionDataArgs['newAttester']; +}; + +export function getEnableAttesterInstruction< + TAccountPayer extends string, + TAccountAttesterManager extends string, + TAccountMessageTransmitter extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: EnableAttesterInput< + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): EnableAttesterInstruction< + TProgramAddress, + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + attesterManager: { + value: input.attesterManager ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.attesterManager), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getEnableAttesterInstructionDataEncoder().encode( + args as EnableAttesterInstructionDataArgs + ), + } as EnableAttesterInstruction< + TProgramAddress, + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedEnableAttesterInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + attesterManager: TAccountMetas[1]; + messageTransmitter: TAccountMetas[2]; + systemProgram: TAccountMetas[3]; + eventAuthority: TAccountMetas[4]; + program: TAccountMetas[5]; + }; + data: EnableAttesterInstructionData; +}; + +export function parseEnableAttesterInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedEnableAttesterInstruction { + if (instruction.accounts.length < 6) { + // 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: { + payer: getNextAccount(), + attesterManager: getNextAccount(), + messageTransmitter: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getEnableAttesterInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/getNoncePda.ts b/src/svm/clients/MessageTransmitter/instructions/getNoncePda.ts new file mode 100644 index 000000000..ea99487e8 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/getNoncePda.ts @@ -0,0 +1,183 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const GET_NONCE_PDA_DISCRIMINATOR = new Uint8Array([ + 114, 70, 229, 212, 223, 50, 33, 39, +]); + +export function getGetNoncePdaDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + GET_NONCE_PDA_DISCRIMINATOR + ); +} + +export type GetNoncePdaInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMessageTransmitter extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountMessageTransmitter extends string + ? ReadonlyAccount + : TAccountMessageTransmitter, + ...TRemainingAccounts, + ] + >; + +export type GetNoncePdaInstructionData = { + discriminator: ReadonlyUint8Array; + nonce: bigint; + sourceDomain: number; +}; + +export type GetNoncePdaInstructionDataArgs = { + nonce: number | bigint; + sourceDomain: number; +}; + +export function getGetNoncePdaInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['nonce', getU64Encoder()], + ['sourceDomain', getU32Encoder()], + ]), + (value) => ({ ...value, discriminator: GET_NONCE_PDA_DISCRIMINATOR }) + ); +} + +export function getGetNoncePdaInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['nonce', getU64Decoder()], + ['sourceDomain', getU32Decoder()], + ]); +} + +export function getGetNoncePdaInstructionDataCodec(): Codec< + GetNoncePdaInstructionDataArgs, + GetNoncePdaInstructionData +> { + return combineCodec( + getGetNoncePdaInstructionDataEncoder(), + getGetNoncePdaInstructionDataDecoder() + ); +} + +export type GetNoncePdaInput< + TAccountMessageTransmitter extends string = string, +> = { + messageTransmitter: Address; + nonce: GetNoncePdaInstructionDataArgs['nonce']; + sourceDomain: GetNoncePdaInstructionDataArgs['sourceDomain']; +}; + +export function getGetNoncePdaInstruction< + TAccountMessageTransmitter extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: GetNoncePdaInput, + config?: { programAddress?: TProgramAddress } +): GetNoncePdaInstruction { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + messageTransmitter: { + value: input.messageTransmitter ?? 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.messageTransmitter)], + programAddress, + data: getGetNoncePdaInstructionDataEncoder().encode( + args as GetNoncePdaInstructionDataArgs + ), + } as GetNoncePdaInstruction; + + return instruction; +} + +export type ParsedGetNoncePdaInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + messageTransmitter: TAccountMetas[0]; + }; + data: GetNoncePdaInstructionData; +}; + +export function parseGetNoncePdaInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedGetNoncePdaInstruction { + if (instruction.accounts.length < 1) { + // 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: { + messageTransmitter: getNextAccount(), + }, + data: getGetNoncePdaInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/index.ts b/src/svm/clients/MessageTransmitter/instructions/index.ts new file mode 100644 index 000000000..d285a7021 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/index.ts @@ -0,0 +1,26 @@ +/** + * 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 './acceptOwnership'; +export * from './disableAttester'; +export * from './enableAttester'; +export * from './getNoncePda'; +export * from './initialize'; +export * from './isNonceUsed'; +export * from './pause'; +export * from './receiveMessage'; +export * from './reclaimEventAccount'; +export * from './replaceMessage'; +export * from './sendMessage'; +export * from './sendMessageWithCaller'; +export * from './setMaxMessageBodySize'; +export * from './setSignatureThreshold'; +export * from './transferOwnership'; +export * from './unpause'; +export * from './updateAttesterManager'; +export * from './updatePauser'; diff --git a/src/svm/clients/MessageTransmitter/instructions/initialize.ts b/src/svm/clients/MessageTransmitter/instructions/initialize.ts new file mode 100644 index 000000000..d333f9169 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/initialize.ts @@ -0,0 +1,326 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const INITIALIZE_DISCRIMINATOR = new Uint8Array([ + 175, 175, 109, 31, 13, 152, 155, 237, +]); + +export function getInitializeDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_DISCRIMINATOR); +} + +export type InitializeInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountUpgradeAuthority extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountMessageTransmitterProgramData extends string | AccountMeta = + string, + TAccountMessageTransmitterProgram extends string | AccountMeta = + string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountUpgradeAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountUpgradeAuthority, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountMessageTransmitterProgramData extends string + ? ReadonlyAccount + : TAccountMessageTransmitterProgramData, + TAccountMessageTransmitterProgram extends string + ? ReadonlyAccount + : TAccountMessageTransmitterProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type InitializeInstructionData = { + discriminator: ReadonlyUint8Array; + localDomain: number; + attester: Address; + maxMessageBodySize: bigint; + version: number; +}; + +export type InitializeInstructionDataArgs = { + localDomain: number; + attester: Address; + maxMessageBodySize: number | bigint; + version: number; +}; + +export function getInitializeInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['localDomain', getU32Encoder()], + ['attester', getAddressEncoder()], + ['maxMessageBodySize', getU64Encoder()], + ['version', getU32Encoder()], + ]), + (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) + ); +} + +export function getInitializeInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['localDomain', getU32Decoder()], + ['attester', getAddressDecoder()], + ['maxMessageBodySize', getU64Decoder()], + ['version', getU32Decoder()], + ]); +} + +export function getInitializeInstructionDataCodec(): Codec< + InitializeInstructionDataArgs, + InitializeInstructionData +> { + return combineCodec( + getInitializeInstructionDataEncoder(), + getInitializeInstructionDataDecoder() + ); +} + +export type InitializeInput< + TAccountPayer extends string = string, + TAccountUpgradeAuthority extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountMessageTransmitterProgramData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + upgradeAuthority: TransactionSigner; + messageTransmitter: Address; + messageTransmitterProgramData: Address; + messageTransmitterProgram: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + localDomain: InitializeInstructionDataArgs['localDomain']; + attester: InitializeInstructionDataArgs['attester']; + maxMessageBodySize: InitializeInstructionDataArgs['maxMessageBodySize']; + version: InitializeInstructionDataArgs['version']; +}; + +export function getInitializeInstruction< + TAccountPayer extends string, + TAccountUpgradeAuthority extends string, + TAccountMessageTransmitter extends string, + TAccountMessageTransmitterProgramData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: InitializeInput< + TAccountPayer, + TAccountUpgradeAuthority, + TAccountMessageTransmitter, + TAccountMessageTransmitterProgramData, + TAccountMessageTransmitterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): InitializeInstruction< + TProgramAddress, + TAccountPayer, + TAccountUpgradeAuthority, + TAccountMessageTransmitter, + TAccountMessageTransmitterProgramData, + TAccountMessageTransmitterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + upgradeAuthority: { + value: input.upgradeAuthority ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + messageTransmitterProgramData: { + value: input.messageTransmitterProgramData ?? null, + isWritable: false, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.upgradeAuthority), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.messageTransmitterProgramData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getInitializeInstructionDataEncoder().encode( + args as InitializeInstructionDataArgs + ), + } as InitializeInstruction< + TProgramAddress, + TAccountPayer, + TAccountUpgradeAuthority, + TAccountMessageTransmitter, + TAccountMessageTransmitterProgramData, + TAccountMessageTransmitterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedInitializeInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + upgradeAuthority: TAccountMetas[1]; + messageTransmitter: TAccountMetas[2]; + messageTransmitterProgramData: TAccountMetas[3]; + messageTransmitterProgram: TAccountMetas[4]; + systemProgram: TAccountMetas[5]; + eventAuthority: TAccountMetas[6]; + program: TAccountMetas[7]; + }; + data: InitializeInstructionData; +}; + +export function parseInitializeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedInitializeInstruction { + if (instruction.accounts.length < 8) { + // 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: { + payer: getNextAccount(), + upgradeAuthority: getNextAccount(), + messageTransmitter: getNextAccount(), + messageTransmitterProgramData: getNextAccount(), + messageTransmitterProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getInitializeInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/isNonceUsed.ts b/src/svm/clients/MessageTransmitter/instructions/isNonceUsed.ts new file mode 100644 index 000000000..ef3466f72 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/isNonceUsed.ts @@ -0,0 +1,171 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const IS_NONCE_USED_DISCRIMINATOR = new Uint8Array([ + 144, 72, 107, 148, 35, 218, 31, 187, +]); + +export function getIsNonceUsedDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + IS_NONCE_USED_DISCRIMINATOR + ); +} + +export type IsNonceUsedInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountUsedNonces extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountUsedNonces extends string + ? ReadonlyAccount + : TAccountUsedNonces, + ...TRemainingAccounts, + ] + >; + +export type IsNonceUsedInstructionData = { + discriminator: ReadonlyUint8Array; + nonce: bigint; +}; + +export type IsNonceUsedInstructionDataArgs = { nonce: number | bigint }; + +export function getIsNonceUsedInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['nonce', getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: IS_NONCE_USED_DISCRIMINATOR }) + ); +} + +export function getIsNonceUsedInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['nonce', getU64Decoder()], + ]); +} + +export function getIsNonceUsedInstructionDataCodec(): Codec< + IsNonceUsedInstructionDataArgs, + IsNonceUsedInstructionData +> { + return combineCodec( + getIsNonceUsedInstructionDataEncoder(), + getIsNonceUsedInstructionDataDecoder() + ); +} + +export type IsNonceUsedInput = { + /** Account will be explicitly loaded to avoid error when it's not initialized */ + usedNonces: Address; + nonce: IsNonceUsedInstructionDataArgs['nonce']; +}; + +export function getIsNonceUsedInstruction< + TAccountUsedNonces extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: IsNonceUsedInput, + config?: { programAddress?: TProgramAddress } +): IsNonceUsedInstruction { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + usedNonces: { value: input.usedNonces ?? 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.usedNonces)], + programAddress, + data: getIsNonceUsedInstructionDataEncoder().encode( + args as IsNonceUsedInstructionDataArgs + ), + } as IsNonceUsedInstruction; + + return instruction; +} + +export type ParsedIsNonceUsedInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + /** Account will be explicitly loaded to avoid error when it's not initialized */ + usedNonces: TAccountMetas[0]; + }; + data: IsNonceUsedInstructionData; +}; + +export function parseIsNonceUsedInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedIsNonceUsedInstruction { + if (instruction.accounts.length < 1) { + // 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: { + usedNonces: getNextAccount(), + }, + data: getIsNonceUsedInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/pause.ts b/src/svm/clients/MessageTransmitter/instructions/pause.ts new file mode 100644 index 000000000..d0caab341 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/pause.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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const PAUSE_DISCRIMINATOR = new Uint8Array([ + 211, 22, 221, 251, 74, 121, 193, 47, +]); + +export function getPauseDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(PAUSE_DISCRIMINATOR); +} + +export type PauseInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountPauser extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPauser extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountPauser, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type PauseInstructionData = { discriminator: ReadonlyUint8Array }; + +export type PauseInstructionDataArgs = {}; + +export function getPauseInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: PAUSE_DISCRIMINATOR }) + ); +} + +export function getPauseInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getPauseInstructionDataCodec(): Codec< + PauseInstructionDataArgs, + PauseInstructionData +> { + return combineCodec( + getPauseInstructionDataEncoder(), + getPauseInstructionDataDecoder() + ); +} + +export type PauseInput< + TAccountPauser extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pauser: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; +}; + +export function getPauseInstruction< + TAccountPauser extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: PauseInput< + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): PauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pauser: { value: input.pauser ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pauser), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getPauseInstructionDataEncoder().encode({}), + } as PauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedPauseInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + pauser: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: PauseInstructionData; +}; + +export function parsePauseInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedPauseInstruction { + if (instruction.accounts.length < 4) { + // 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: { + pauser: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getPauseInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/receiveMessage.ts b/src/svm/clients/MessageTransmitter/instructions/receiveMessage.ts new file mode 100644 index 000000000..612dad4de --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/receiveMessage.ts @@ -0,0 +1,319 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const RECEIVE_MESSAGE_DISCRIMINATOR = new Uint8Array([ + 38, 144, 127, 225, 31, 225, 238, 25, +]); + +export function getReceiveMessageDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + RECEIVE_MESSAGE_DISCRIMINATOR + ); +} + +export type ReceiveMessageInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountCaller extends string | AccountMeta = string, + TAccountAuthorityPda extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountUsedNonces extends string | AccountMeta = string, + TAccountReceiver extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountCaller extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountCaller, + TAccountAuthorityPda extends string + ? ReadonlyAccount + : TAccountAuthorityPda, + TAccountMessageTransmitter extends string + ? ReadonlyAccount + : TAccountMessageTransmitter, + TAccountUsedNonces extends string + ? WritableAccount + : TAccountUsedNonces, + TAccountReceiver extends string + ? ReadonlyAccount + : TAccountReceiver, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type ReceiveMessageInstructionData = { + discriminator: ReadonlyUint8Array; + message: ReadonlyUint8Array; + attestation: ReadonlyUint8Array; +}; + +export type ReceiveMessageInstructionDataArgs = { + message: ReadonlyUint8Array; + attestation: ReadonlyUint8Array; +}; + +export function getReceiveMessageInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ['attestation', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ ...value, discriminator: RECEIVE_MESSAGE_DISCRIMINATOR }) + ); +} + +export function getReceiveMessageInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ['attestation', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getReceiveMessageInstructionDataCodec(): Codec< + ReceiveMessageInstructionDataArgs, + ReceiveMessageInstructionData +> { + return combineCodec( + getReceiveMessageInstructionDataEncoder(), + getReceiveMessageInstructionDataDecoder() + ); +} + +export type ReceiveMessageInput< + TAccountPayer extends string = string, + TAccountCaller extends string = string, + TAccountAuthorityPda extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountUsedNonces extends string = string, + TAccountReceiver extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + caller: TransactionSigner; + authorityPda: Address; + messageTransmitter: Address; + usedNonces: Address; + receiver: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + message: ReceiveMessageInstructionDataArgs['message']; + attestation: ReceiveMessageInstructionDataArgs['attestation']; +}; + +export function getReceiveMessageInstruction< + TAccountPayer extends string, + TAccountCaller extends string, + TAccountAuthorityPda extends string, + TAccountMessageTransmitter extends string, + TAccountUsedNonces extends string, + TAccountReceiver extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: ReceiveMessageInput< + TAccountPayer, + TAccountCaller, + TAccountAuthorityPda, + TAccountMessageTransmitter, + TAccountUsedNonces, + TAccountReceiver, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): ReceiveMessageInstruction< + TProgramAddress, + TAccountPayer, + TAccountCaller, + TAccountAuthorityPda, + TAccountMessageTransmitter, + TAccountUsedNonces, + TAccountReceiver, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + caller: { value: input.caller ?? null, isWritable: false }, + authorityPda: { value: input.authorityPda ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: false, + }, + usedNonces: { value: input.usedNonces ?? null, isWritable: true }, + receiver: { value: input.receiver ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.caller), + getAccountMeta(accounts.authorityPda), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.usedNonces), + getAccountMeta(accounts.receiver), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getReceiveMessageInstructionDataEncoder().encode( + args as ReceiveMessageInstructionDataArgs + ), + } as ReceiveMessageInstruction< + TProgramAddress, + TAccountPayer, + TAccountCaller, + TAccountAuthorityPda, + TAccountMessageTransmitter, + TAccountUsedNonces, + TAccountReceiver, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedReceiveMessageInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + caller: TAccountMetas[1]; + authorityPda: TAccountMetas[2]; + messageTransmitter: TAccountMetas[3]; + usedNonces: TAccountMetas[4]; + receiver: TAccountMetas[5]; + systemProgram: TAccountMetas[6]; + eventAuthority: TAccountMetas[7]; + program: TAccountMetas[8]; + }; + data: ReceiveMessageInstructionData; +}; + +export function parseReceiveMessageInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedReceiveMessageInstruction { + if (instruction.accounts.length < 9) { + // 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: { + payer: getNextAccount(), + caller: getNextAccount(), + authorityPda: getNextAccount(), + messageTransmitter: getNextAccount(), + usedNonces: getNextAccount(), + receiver: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getReceiveMessageInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/reclaimEventAccount.ts b/src/svm/clients/MessageTransmitter/instructions/reclaimEventAccount.ts new file mode 100644 index 000000000..56c25c910 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/reclaimEventAccount.ts @@ -0,0 +1,230 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR = new Uint8Array([ + 94, 198, 180, 159, 131, 236, 15, 174, +]); + +export function getReclaimEventAccountDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR + ); +} + +export type ReclaimEventAccountInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountPayee extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayee extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayee, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountMessageSentEventData extends string + ? WritableAccount + : TAccountMessageSentEventData, + ...TRemainingAccounts, + ] + >; + +export type ReclaimEventAccountInstructionData = { + discriminator: ReadonlyUint8Array; + attestation: ReadonlyUint8Array; +}; + +export type ReclaimEventAccountInstructionDataArgs = { + attestation: ReadonlyUint8Array; +}; + +export function getReclaimEventAccountInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['attestation', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ + ...value, + discriminator: RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR, + }) + ); +} + +export function getReclaimEventAccountInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['attestation', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getReclaimEventAccountInstructionDataCodec(): Codec< + ReclaimEventAccountInstructionDataArgs, + ReclaimEventAccountInstructionData +> { + return combineCodec( + getReclaimEventAccountInstructionDataEncoder(), + getReclaimEventAccountInstructionDataDecoder() + ); +} + +export type ReclaimEventAccountInput< + TAccountPayee extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountMessageSentEventData extends string = string, +> = { + /** rent SOL receiver, should match original rent payer */ + payee: TransactionSigner; + messageTransmitter: Address; + messageSentEventData: Address; + attestation: ReclaimEventAccountInstructionDataArgs['attestation']; +}; + +export function getReclaimEventAccountInstruction< + TAccountPayee extends string, + TAccountMessageTransmitter extends string, + TAccountMessageSentEventData extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: ReclaimEventAccountInput< + TAccountPayee, + TAccountMessageTransmitter, + TAccountMessageSentEventData + >, + config?: { programAddress?: TProgramAddress } +): ReclaimEventAccountInstruction< + TProgramAddress, + TAccountPayee, + TAccountMessageTransmitter, + TAccountMessageSentEventData +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.messageSentEventData), + ], + programAddress, + data: getReclaimEventAccountInstructionDataEncoder().encode( + args as ReclaimEventAccountInstructionDataArgs + ), + } as ReclaimEventAccountInstruction< + TProgramAddress, + TAccountPayee, + TAccountMessageTransmitter, + TAccountMessageSentEventData + >; + + return instruction; +} + +export type ParsedReclaimEventAccountInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + /** rent SOL receiver, should match original rent payer */ + payee: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + messageSentEventData: TAccountMetas[2]; + }; + data: ReclaimEventAccountInstructionData; +}; + +export function parseReclaimEventAccountInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedReclaimEventAccountInstruction { + 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: { + payee: getNextAccount(), + messageTransmitter: getNextAccount(), + messageSentEventData: getNextAccount(), + }, + data: getReclaimEventAccountInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/replaceMessage.ts b/src/svm/clients/MessageTransmitter/instructions/replaceMessage.ts new file mode 100644 index 000000000..f0162de72 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/replaceMessage.ts @@ -0,0 +1,314 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const REPLACE_MESSAGE_DISCRIMINATOR = new Uint8Array([ + 189, 189, 210, 163, 149, 205, 69, 229, +]); + +export function getReplaceMessageDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REPLACE_MESSAGE_DISCRIMINATOR + ); +} + +export type ReplaceMessageInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountEventRentPayer extends string | AccountMeta = string, + TAccountSenderAuthorityPda extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TAccountSenderProgram extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountEventRentPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountEventRentPayer, + TAccountSenderAuthorityPda extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSenderAuthorityPda, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountMessageSentEventData extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountMessageSentEventData, + TAccountSenderProgram extends string + ? ReadonlyAccount + : TAccountSenderProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type ReplaceMessageInstructionData = { + discriminator: ReadonlyUint8Array; + originalMessage: ReadonlyUint8Array; + originalAttestation: ReadonlyUint8Array; + newMessageBody: ReadonlyUint8Array; + newDestinationCaller: Address; +}; + +export type ReplaceMessageInstructionDataArgs = { + originalMessage: ReadonlyUint8Array; + originalAttestation: ReadonlyUint8Array; + newMessageBody: ReadonlyUint8Array; + newDestinationCaller: Address; +}; + +export function getReplaceMessageInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + [ + 'originalMessage', + addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), + ], + [ + 'originalAttestation', + addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), + ], + [ + 'newMessageBody', + addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), + ], + ['newDestinationCaller', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: REPLACE_MESSAGE_DISCRIMINATOR }) + ); +} + +export function getReplaceMessageInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + [ + 'originalMessage', + addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()), + ], + [ + 'originalAttestation', + addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()), + ], + [ + 'newMessageBody', + addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()), + ], + ['newDestinationCaller', getAddressDecoder()], + ]); +} + +export function getReplaceMessageInstructionDataCodec(): Codec< + ReplaceMessageInstructionDataArgs, + ReplaceMessageInstructionData +> { + return combineCodec( + getReplaceMessageInstructionDataEncoder(), + getReplaceMessageInstructionDataDecoder() + ); +} + +export type ReplaceMessageInput< + TAccountEventRentPayer extends string = string, + TAccountSenderAuthorityPda extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountSenderProgram extends string = string, + TAccountSystemProgram extends string = string, +> = { + eventRentPayer: TransactionSigner; + senderAuthorityPda: TransactionSigner; + messageTransmitter: Address; + messageSentEventData: TransactionSigner; + senderProgram: Address; + systemProgram?: Address; + originalMessage: ReplaceMessageInstructionDataArgs['originalMessage']; + originalAttestation: ReplaceMessageInstructionDataArgs['originalAttestation']; + newMessageBody: ReplaceMessageInstructionDataArgs['newMessageBody']; + newDestinationCaller: ReplaceMessageInstructionDataArgs['newDestinationCaller']; +}; + +export function getReplaceMessageInstruction< + TAccountEventRentPayer extends string, + TAccountSenderAuthorityPda extends string, + TAccountMessageTransmitter extends string, + TAccountMessageSentEventData extends string, + TAccountSenderProgram extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: ReplaceMessageInput< + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountSenderProgram, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): ReplaceMessageInstruction< + TProgramAddress, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountSenderProgram, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, + senderAuthorityPda: { + value: input.senderAuthorityPda ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + senderProgram: { value: input.senderProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.eventRentPayer), + getAccountMeta(accounts.senderAuthorityPda), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.senderProgram), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getReplaceMessageInstructionDataEncoder().encode( + args as ReplaceMessageInstructionDataArgs + ), + } as ReplaceMessageInstruction< + TProgramAddress, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountSenderProgram, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedReplaceMessageInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + eventRentPayer: TAccountMetas[0]; + senderAuthorityPda: TAccountMetas[1]; + messageTransmitter: TAccountMetas[2]; + messageSentEventData: TAccountMetas[3]; + senderProgram: TAccountMetas[4]; + systemProgram: TAccountMetas[5]; + }; + data: ReplaceMessageInstructionData; +}; + +export function parseReplaceMessageInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedReplaceMessageInstruction { + if (instruction.accounts.length < 6) { + // 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: { + eventRentPayer: getNextAccount(), + senderAuthorityPda: getNextAccount(), + messageTransmitter: getNextAccount(), + messageSentEventData: getNextAccount(), + senderProgram: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getReplaceMessageInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/sendMessage.ts b/src/svm/clients/MessageTransmitter/instructions/sendMessage.ts new file mode 100644 index 000000000..d17392904 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/sendMessage.ts @@ -0,0 +1,291 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SEND_MESSAGE_DISCRIMINATOR = new Uint8Array([ + 57, 40, 34, 178, 189, 10, 65, 26, +]); + +export function getSendMessageDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SEND_MESSAGE_DISCRIMINATOR + ); +} + +export type SendMessageInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountEventRentPayer extends string | AccountMeta = string, + TAccountSenderAuthorityPda extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TAccountSenderProgram extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountEventRentPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountEventRentPayer, + TAccountSenderAuthorityPda extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSenderAuthorityPda, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountMessageSentEventData extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountMessageSentEventData, + TAccountSenderProgram extends string + ? ReadonlyAccount + : TAccountSenderProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type SendMessageInstructionData = { + discriminator: ReadonlyUint8Array; + destinationDomain: number; + recipient: Address; + messageBody: ReadonlyUint8Array; +}; + +export type SendMessageInstructionDataArgs = { + destinationDomain: number; + recipient: Address; + messageBody: ReadonlyUint8Array; +}; + +export function getSendMessageInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['destinationDomain', getU32Encoder()], + ['recipient', getAddressEncoder()], + ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ ...value, discriminator: SEND_MESSAGE_DISCRIMINATOR }) + ); +} + +export function getSendMessageInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['destinationDomain', getU32Decoder()], + ['recipient', getAddressDecoder()], + ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getSendMessageInstructionDataCodec(): Codec< + SendMessageInstructionDataArgs, + SendMessageInstructionData +> { + return combineCodec( + getSendMessageInstructionDataEncoder(), + getSendMessageInstructionDataDecoder() + ); +} + +export type SendMessageInput< + TAccountEventRentPayer extends string = string, + TAccountSenderAuthorityPda extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountSenderProgram extends string = string, + TAccountSystemProgram extends string = string, +> = { + eventRentPayer: TransactionSigner; + senderAuthorityPda: TransactionSigner; + messageTransmitter: Address; + messageSentEventData: TransactionSigner; + senderProgram: Address; + systemProgram?: Address; + destinationDomain: SendMessageInstructionDataArgs['destinationDomain']; + recipient: SendMessageInstructionDataArgs['recipient']; + messageBody: SendMessageInstructionDataArgs['messageBody']; +}; + +export function getSendMessageInstruction< + TAccountEventRentPayer extends string, + TAccountSenderAuthorityPda extends string, + TAccountMessageTransmitter extends string, + TAccountMessageSentEventData extends string, + TAccountSenderProgram extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: SendMessageInput< + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountSenderProgram, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): SendMessageInstruction< + TProgramAddress, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountSenderProgram, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, + senderAuthorityPda: { + value: input.senderAuthorityPda ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + senderProgram: { value: input.senderProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.eventRentPayer), + getAccountMeta(accounts.senderAuthorityPda), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.senderProgram), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getSendMessageInstructionDataEncoder().encode( + args as SendMessageInstructionDataArgs + ), + } as SendMessageInstruction< + TProgramAddress, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountSenderProgram, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedSendMessageInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + eventRentPayer: TAccountMetas[0]; + senderAuthorityPda: TAccountMetas[1]; + messageTransmitter: TAccountMetas[2]; + messageSentEventData: TAccountMetas[3]; + senderProgram: TAccountMetas[4]; + systemProgram: TAccountMetas[5]; + }; + data: SendMessageInstructionData; +}; + +export function parseSendMessageInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSendMessageInstruction { + if (instruction.accounts.length < 6) { + // 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: { + eventRentPayer: getNextAccount(), + senderAuthorityPda: getNextAccount(), + messageTransmitter: getNextAccount(), + messageSentEventData: getNextAccount(), + senderProgram: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getSendMessageInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/sendMessageWithCaller.ts b/src/svm/clients/MessageTransmitter/instructions/sendMessageWithCaller.ts new file mode 100644 index 000000000..07513e929 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/sendMessageWithCaller.ts @@ -0,0 +1,301 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SEND_MESSAGE_WITH_CALLER_DISCRIMINATOR = new Uint8Array([ + 212, 47, 34, 52, 91, 32, 176, 204, +]); + +export function getSendMessageWithCallerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SEND_MESSAGE_WITH_CALLER_DISCRIMINATOR + ); +} + +export type SendMessageWithCallerInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountEventRentPayer extends string | AccountMeta = string, + TAccountSenderAuthorityPda extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TAccountSenderProgram extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountEventRentPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountEventRentPayer, + TAccountSenderAuthorityPda extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSenderAuthorityPda, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountMessageSentEventData extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountMessageSentEventData, + TAccountSenderProgram extends string + ? ReadonlyAccount + : TAccountSenderProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type SendMessageWithCallerInstructionData = { + discriminator: ReadonlyUint8Array; + destinationDomain: number; + recipient: Address; + messageBody: ReadonlyUint8Array; + destinationCaller: Address; +}; + +export type SendMessageWithCallerInstructionDataArgs = { + destinationDomain: number; + recipient: Address; + messageBody: ReadonlyUint8Array; + destinationCaller: Address; +}; + +export function getSendMessageWithCallerInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['destinationDomain', getU32Encoder()], + ['recipient', getAddressEncoder()], + ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ['destinationCaller', getAddressEncoder()], + ]), + (value) => ({ + ...value, + discriminator: SEND_MESSAGE_WITH_CALLER_DISCRIMINATOR, + }) + ); +} + +export function getSendMessageWithCallerInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['destinationDomain', getU32Decoder()], + ['recipient', getAddressDecoder()], + ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ['destinationCaller', getAddressDecoder()], + ]); +} + +export function getSendMessageWithCallerInstructionDataCodec(): Codec< + SendMessageWithCallerInstructionDataArgs, + SendMessageWithCallerInstructionData +> { + return combineCodec( + getSendMessageWithCallerInstructionDataEncoder(), + getSendMessageWithCallerInstructionDataDecoder() + ); +} + +export type SendMessageWithCallerInput< + TAccountEventRentPayer extends string = string, + TAccountSenderAuthorityPda extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountSenderProgram extends string = string, + TAccountSystemProgram extends string = string, +> = { + eventRentPayer: TransactionSigner; + senderAuthorityPda: TransactionSigner; + messageTransmitter: Address; + messageSentEventData: TransactionSigner; + senderProgram: Address; + systemProgram?: Address; + destinationDomain: SendMessageWithCallerInstructionDataArgs['destinationDomain']; + recipient: SendMessageWithCallerInstructionDataArgs['recipient']; + messageBody: SendMessageWithCallerInstructionDataArgs['messageBody']; + destinationCaller: SendMessageWithCallerInstructionDataArgs['destinationCaller']; +}; + +export function getSendMessageWithCallerInstruction< + TAccountEventRentPayer extends string, + TAccountSenderAuthorityPda extends string, + TAccountMessageTransmitter extends string, + TAccountMessageSentEventData extends string, + TAccountSenderProgram extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: SendMessageWithCallerInput< + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountSenderProgram, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): SendMessageWithCallerInstruction< + TProgramAddress, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountSenderProgram, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, + senderAuthorityPda: { + value: input.senderAuthorityPda ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + senderProgram: { value: input.senderProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.eventRentPayer), + getAccountMeta(accounts.senderAuthorityPda), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.senderProgram), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getSendMessageWithCallerInstructionDataEncoder().encode( + args as SendMessageWithCallerInstructionDataArgs + ), + } as SendMessageWithCallerInstruction< + TProgramAddress, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountSenderProgram, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedSendMessageWithCallerInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + eventRentPayer: TAccountMetas[0]; + senderAuthorityPda: TAccountMetas[1]; + messageTransmitter: TAccountMetas[2]; + messageSentEventData: TAccountMetas[3]; + senderProgram: TAccountMetas[4]; + systemProgram: TAccountMetas[5]; + }; + data: SendMessageWithCallerInstructionData; +}; + +export function parseSendMessageWithCallerInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSendMessageWithCallerInstruction { + if (instruction.accounts.length < 6) { + // 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: { + eventRentPayer: getNextAccount(), + senderAuthorityPda: getNextAccount(), + messageTransmitter: getNextAccount(), + messageSentEventData: getNextAccount(), + senderProgram: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getSendMessageWithCallerInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/setMaxMessageBodySize.ts b/src/svm/clients/MessageTransmitter/instructions/setMaxMessageBodySize.ts new file mode 100644 index 000000000..522c023b7 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/setMaxMessageBodySize.ts @@ -0,0 +1,238 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_MAX_MESSAGE_BODY_SIZE_DISCRIMINATOR = new Uint8Array([ + 168, 178, 8, 117, 217, 167, 219, 31, +]); + +export function getSetMaxMessageBodySizeDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_MAX_MESSAGE_BODY_SIZE_DISCRIMINATOR + ); +} + +export type SetMaxMessageBodySizeInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type SetMaxMessageBodySizeInstructionData = { + discriminator: ReadonlyUint8Array; + newMaxMessageBodySize: bigint; +}; + +export type SetMaxMessageBodySizeInstructionDataArgs = { + newMaxMessageBodySize: number | bigint; +}; + +export function getSetMaxMessageBodySizeInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newMaxMessageBodySize', getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: SET_MAX_MESSAGE_BODY_SIZE_DISCRIMINATOR, + }) + ); +} + +export function getSetMaxMessageBodySizeInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newMaxMessageBodySize', getU64Decoder()], + ]); +} + +export function getSetMaxMessageBodySizeInstructionDataCodec(): Codec< + SetMaxMessageBodySizeInstructionDataArgs, + SetMaxMessageBodySizeInstructionData +> { + return combineCodec( + getSetMaxMessageBodySizeInstructionDataEncoder(), + getSetMaxMessageBodySizeInstructionDataDecoder() + ); +} + +export type SetMaxMessageBodySizeInput< + TAccountOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; + newMaxMessageBodySize: SetMaxMessageBodySizeInstructionDataArgs['newMaxMessageBodySize']; +}; + +export function getSetMaxMessageBodySizeInstruction< + TAccountOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: SetMaxMessageBodySizeInput< + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): SetMaxMessageBodySizeInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetMaxMessageBodySizeInstructionDataEncoder().encode( + args as SetMaxMessageBodySizeInstructionDataArgs + ), + } as SetMaxMessageBodySizeInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedSetMaxMessageBodySizeInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: SetMaxMessageBodySizeInstructionData; +}; + +export function parseSetMaxMessageBodySizeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetMaxMessageBodySizeInstruction { + if (instruction.accounts.length < 4) { + // 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: { + owner: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getSetMaxMessageBodySizeInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/setSignatureThreshold.ts b/src/svm/clients/MessageTransmitter/instructions/setSignatureThreshold.ts new file mode 100644 index 000000000..889ac78cb --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/setSignatureThreshold.ts @@ -0,0 +1,241 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_SIGNATURE_THRESHOLD_DISCRIMINATOR = new Uint8Array([ + 163, 19, 154, 168, 82, 209, 214, 219, +]); + +export function getSetSignatureThresholdDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_SIGNATURE_THRESHOLD_DISCRIMINATOR + ); +} + +export type SetSignatureThresholdInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountAttesterManager extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountAttesterManager extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAttesterManager, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type SetSignatureThresholdInstructionData = { + discriminator: ReadonlyUint8Array; + newSignatureThreshold: number; +}; + +export type SetSignatureThresholdInstructionDataArgs = { + newSignatureThreshold: number; +}; + +export function getSetSignatureThresholdInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newSignatureThreshold', getU32Encoder()], + ]), + (value) => ({ + ...value, + discriminator: SET_SIGNATURE_THRESHOLD_DISCRIMINATOR, + }) + ); +} + +export function getSetSignatureThresholdInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newSignatureThreshold', getU32Decoder()], + ]); +} + +export function getSetSignatureThresholdInstructionDataCodec(): Codec< + SetSignatureThresholdInstructionDataArgs, + SetSignatureThresholdInstructionData +> { + return combineCodec( + getSetSignatureThresholdInstructionDataEncoder(), + getSetSignatureThresholdInstructionDataDecoder() + ); +} + +export type SetSignatureThresholdInput< + TAccountAttesterManager extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + attesterManager: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; + newSignatureThreshold: SetSignatureThresholdInstructionDataArgs['newSignatureThreshold']; +}; + +export function getSetSignatureThresholdInstruction< + TAccountAttesterManager extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: SetSignatureThresholdInput< + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): SetSignatureThresholdInstruction< + TProgramAddress, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + attesterManager: { + value: input.attesterManager ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.attesterManager), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetSignatureThresholdInstructionDataEncoder().encode( + args as SetSignatureThresholdInstructionDataArgs + ), + } as SetSignatureThresholdInstruction< + TProgramAddress, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedSetSignatureThresholdInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + attesterManager: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: SetSignatureThresholdInstructionData; +}; + +export function parseSetSignatureThresholdInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetSignatureThresholdInstruction { + if (instruction.accounts.length < 4) { + // 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: { + attesterManager: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getSetSignatureThresholdInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/transferOwnership.ts b/src/svm/clients/MessageTransmitter/instructions/transferOwnership.ts new file mode 100644 index 000000000..009a2aaab --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/transferOwnership.ts @@ -0,0 +1,231 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const TRANSFER_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ + 65, 177, 215, 73, 53, 45, 99, 47, +]); + +export function getTransferOwnershipDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + TRANSFER_OWNERSHIP_DISCRIMINATOR + ); +} + +export type TransferOwnershipInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type TransferOwnershipInstructionData = { + discriminator: ReadonlyUint8Array; + newOwner: Address; +}; + +export type TransferOwnershipInstructionDataArgs = { newOwner: Address }; + +export function getTransferOwnershipInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newOwner', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: TRANSFER_OWNERSHIP_DISCRIMINATOR }) + ); +} + +export function getTransferOwnershipInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newOwner', getAddressDecoder()], + ]); +} + +export function getTransferOwnershipInstructionDataCodec(): Codec< + TransferOwnershipInstructionDataArgs, + TransferOwnershipInstructionData +> { + return combineCodec( + getTransferOwnershipInstructionDataEncoder(), + getTransferOwnershipInstructionDataDecoder() + ); +} + +export type TransferOwnershipInput< + TAccountOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; + newOwner: TransferOwnershipInstructionDataArgs['newOwner']; +}; + +export function getTransferOwnershipInstruction< + TAccountOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: TransferOwnershipInput< + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getTransferOwnershipInstructionDataEncoder().encode( + args as TransferOwnershipInstructionDataArgs + ), + } as TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedTransferOwnershipInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: TransferOwnershipInstructionData; +}; + +export function parseTransferOwnershipInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedTransferOwnershipInstruction { + if (instruction.accounts.length < 4) { + // 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: { + owner: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getTransferOwnershipInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/unpause.ts b/src/svm/clients/MessageTransmitter/instructions/unpause.ts new file mode 100644 index 000000000..f2bfff89f --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/unpause.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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UNPAUSE_DISCRIMINATOR = new Uint8Array([ + 169, 144, 4, 38, 10, 141, 188, 255, +]); + +export function getUnpauseDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(UNPAUSE_DISCRIMINATOR); +} + +export type UnpauseInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountPauser extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPauser extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountPauser, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UnpauseInstructionData = { discriminator: ReadonlyUint8Array }; + +export type UnpauseInstructionDataArgs = {}; + +export function getUnpauseInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: UNPAUSE_DISCRIMINATOR }) + ); +} + +export function getUnpauseInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getUnpauseInstructionDataCodec(): Codec< + UnpauseInstructionDataArgs, + UnpauseInstructionData +> { + return combineCodec( + getUnpauseInstructionDataEncoder(), + getUnpauseInstructionDataDecoder() + ); +} + +export type UnpauseInput< + TAccountPauser extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pauser: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; +}; + +export function getUnpauseInstruction< + TAccountPauser extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: UnpauseInput< + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UnpauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pauser: { value: input.pauser ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pauser), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUnpauseInstructionDataEncoder().encode({}), + } as UnpauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUnpauseInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + pauser: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: UnpauseInstructionData; +}; + +export function parseUnpauseInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUnpauseInstruction { + if (instruction.accounts.length < 4) { + // 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: { + pauser: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUnpauseInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/updateAttesterManager.ts b/src/svm/clients/MessageTransmitter/instructions/updateAttesterManager.ts new file mode 100644 index 000000000..63c53f0ca --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/updateAttesterManager.ts @@ -0,0 +1,238 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UPDATE_ATTESTER_MANAGER_DISCRIMINATOR = new Uint8Array([ + 175, 245, 178, 104, 85, 179, 71, 16, +]); + +export function getUpdateAttesterManagerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_ATTESTER_MANAGER_DISCRIMINATOR + ); +} + +export type UpdateAttesterManagerInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UpdateAttesterManagerInstructionData = { + discriminator: ReadonlyUint8Array; + newAttesterManager: Address; +}; + +export type UpdateAttesterManagerInstructionDataArgs = { + newAttesterManager: Address; +}; + +export function getUpdateAttesterManagerInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newAttesterManager', getAddressEncoder()], + ]), + (value) => ({ + ...value, + discriminator: UPDATE_ATTESTER_MANAGER_DISCRIMINATOR, + }) + ); +} + +export function getUpdateAttesterManagerInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newAttesterManager', getAddressDecoder()], + ]); +} + +export function getUpdateAttesterManagerInstructionDataCodec(): Codec< + UpdateAttesterManagerInstructionDataArgs, + UpdateAttesterManagerInstructionData +> { + return combineCodec( + getUpdateAttesterManagerInstructionDataEncoder(), + getUpdateAttesterManagerInstructionDataDecoder() + ); +} + +export type UpdateAttesterManagerInput< + TAccountOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; + newAttesterManager: UpdateAttesterManagerInstructionDataArgs['newAttesterManager']; +}; + +export function getUpdateAttesterManagerInstruction< + TAccountOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: UpdateAttesterManagerInput< + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UpdateAttesterManagerInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUpdateAttesterManagerInstructionDataEncoder().encode( + args as UpdateAttesterManagerInstructionDataArgs + ), + } as UpdateAttesterManagerInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUpdateAttesterManagerInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: UpdateAttesterManagerInstructionData; +}; + +export function parseUpdateAttesterManagerInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUpdateAttesterManagerInstruction { + if (instruction.accounts.length < 4) { + // 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: { + owner: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUpdateAttesterManagerInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/MessageTransmitter/instructions/updatePauser.ts b/src/svm/clients/MessageTransmitter/instructions/updatePauser.ts new file mode 100644 index 000000000..7736174e7 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/instructions/updatePauser.ts @@ -0,0 +1,231 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UPDATE_PAUSER_DISCRIMINATOR = new Uint8Array([ + 140, 171, 211, 132, 57, 201, 16, 254, +]); + +export function getUpdatePauserDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_PAUSER_DISCRIMINATOR + ); +} + +export type UpdatePauserInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UpdatePauserInstructionData = { + discriminator: ReadonlyUint8Array; + newPauser: Address; +}; + +export type UpdatePauserInstructionDataArgs = { newPauser: Address }; + +export function getUpdatePauserInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newPauser', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: UPDATE_PAUSER_DISCRIMINATOR }) + ); +} + +export function getUpdatePauserInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newPauser', getAddressDecoder()], + ]); +} + +export function getUpdatePauserInstructionDataCodec(): Codec< + UpdatePauserInstructionDataArgs, + UpdatePauserInstructionData +> { + return combineCodec( + getUpdatePauserInstructionDataEncoder(), + getUpdatePauserInstructionDataDecoder() + ); +} + +export type UpdatePauserInput< + TAccountOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; + newPauser: UpdatePauserInstructionDataArgs['newPauser']; +}; + +export function getUpdatePauserInstruction< + TAccountOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, +>( + input: UpdatePauserInput< + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UpdatePauserInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUpdatePauserInstructionDataEncoder().encode( + args as UpdatePauserInstructionDataArgs + ), + } as UpdatePauserInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUpdatePauserInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: UpdatePauserInstructionData; +}; + +export function parseUpdatePauserInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUpdatePauserInstruction { + if (instruction.accounts.length < 4) { + // 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: { + owner: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUpdatePauserInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitter/programs/index.ts b/src/svm/clients/MessageTransmitter/programs/index.ts new file mode 100644 index 000000000..35d6ae3df --- /dev/null +++ b/src/svm/clients/MessageTransmitter/programs/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 './messageTransmitter'; diff --git a/src/svm/clients/MessageTransmitter/programs/messageTransmitter.ts b/src/svm/clients/MessageTransmitter/programs/messageTransmitter.ts new file mode 100644 index 000000000..12dc139e7 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/programs/messageTransmitter.ts @@ -0,0 +1,372 @@ +/** + * 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/kit'; +import { + type ParsedAcceptOwnershipInstruction, + type ParsedDisableAttesterInstruction, + type ParsedEnableAttesterInstruction, + type ParsedGetNoncePdaInstruction, + type ParsedInitializeInstruction, + type ParsedIsNonceUsedInstruction, + type ParsedPauseInstruction, + type ParsedReceiveMessageInstruction, + type ParsedReclaimEventAccountInstruction, + type ParsedReplaceMessageInstruction, + type ParsedSendMessageInstruction, + type ParsedSendMessageWithCallerInstruction, + type ParsedSetMaxMessageBodySizeInstruction, + type ParsedSetSignatureThresholdInstruction, + type ParsedTransferOwnershipInstruction, + type ParsedUnpauseInstruction, + type ParsedUpdateAttesterManagerInstruction, + type ParsedUpdatePauserInstruction, +} from '../instructions'; + +export const MESSAGE_TRANSMITTER_PROGRAM_ADDRESS = + 'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd' as Address<'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd'>; + +export enum MessageTransmitterAccount { + MessageSent, + MessageTransmitter, + UsedNonces, +} + +export function identifyMessageTransmitterAccount( + account: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): MessageTransmitterAccount { + const data = 'data' in account ? account.data : account; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([131, 100, 133, 56, 166, 225, 151, 60]) + ), + 0 + ) + ) { + return MessageTransmitterAccount.MessageSent; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([71, 40, 180, 142, 19, 203, 35, 252]) + ), + 0 + ) + ) { + return MessageTransmitterAccount.MessageTransmitter; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([60, 112, 18, 72, 138, 181, 100, 138]) + ), + 0 + ) + ) { + return MessageTransmitterAccount.UsedNonces; + } + throw new Error( + 'The provided account could not be identified as a messageTransmitter account.' + ); +} + +export enum MessageTransmitterInstruction { + Initialize, + TransferOwnership, + AcceptOwnership, + UpdatePauser, + UpdateAttesterManager, + Pause, + Unpause, + SetMaxMessageBodySize, + EnableAttester, + DisableAttester, + SetSignatureThreshold, + SendMessage, + SendMessageWithCaller, + ReplaceMessage, + ReceiveMessage, + ReclaimEventAccount, + GetNoncePda, + IsNonceUsed, +} + +export function identifyMessageTransmitterInstruction( + instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): MessageTransmitterInstruction { + 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 MessageTransmitterInstruction.Initialize; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.TransferOwnership; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([172, 23, 43, 13, 238, 213, 85, 150]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.AcceptOwnership; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([140, 171, 211, 132, 57, 201, 16, 254]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.UpdatePauser; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([175, 245, 178, 104, 85, 179, 71, 16]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.UpdateAttesterManager; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([211, 22, 221, 251, 74, 121, 193, 47]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.Pause; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([169, 144, 4, 38, 10, 141, 188, 255]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.Unpause; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([168, 178, 8, 117, 217, 167, 219, 31]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.SetMaxMessageBodySize; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([2, 11, 193, 115, 5, 148, 4, 198]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.EnableAttester; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([61, 171, 131, 95, 172, 15, 227, 229]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.DisableAttester; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([163, 19, 154, 168, 82, 209, 214, 219]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.SetSignatureThreshold; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([57, 40, 34, 178, 189, 10, 65, 26]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.SendMessage; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([212, 47, 34, 52, 91, 32, 176, 204]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.SendMessageWithCaller; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([189, 189, 210, 163, 149, 205, 69, 229]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.ReplaceMessage; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([38, 144, 127, 225, 31, 225, 238, 25]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.ReceiveMessage; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([94, 198, 180, 159, 131, 236, 15, 174]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.ReclaimEventAccount; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([114, 70, 229, 212, 223, 50, 33, 39]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.GetNoncePda; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([144, 72, 107, 148, 35, 218, 31, 187]) + ), + 0 + ) + ) { + return MessageTransmitterInstruction.IsNonceUsed; + } + throw new Error( + 'The provided instruction could not be identified as a messageTransmitter instruction.' + ); +} + +export type ParsedMessageTransmitterInstruction< + TProgram extends string = 'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd', +> = + | ({ + instructionType: MessageTransmitterInstruction.Initialize; + } & ParsedInitializeInstruction) + | ({ + instructionType: MessageTransmitterInstruction.TransferOwnership; + } & ParsedTransferOwnershipInstruction) + | ({ + instructionType: MessageTransmitterInstruction.AcceptOwnership; + } & ParsedAcceptOwnershipInstruction) + | ({ + instructionType: MessageTransmitterInstruction.UpdatePauser; + } & ParsedUpdatePauserInstruction) + | ({ + instructionType: MessageTransmitterInstruction.UpdateAttesterManager; + } & ParsedUpdateAttesterManagerInstruction) + | ({ + instructionType: MessageTransmitterInstruction.Pause; + } & ParsedPauseInstruction) + | ({ + instructionType: MessageTransmitterInstruction.Unpause; + } & ParsedUnpauseInstruction) + | ({ + instructionType: MessageTransmitterInstruction.SetMaxMessageBodySize; + } & ParsedSetMaxMessageBodySizeInstruction) + | ({ + instructionType: MessageTransmitterInstruction.EnableAttester; + } & ParsedEnableAttesterInstruction) + | ({ + instructionType: MessageTransmitterInstruction.DisableAttester; + } & ParsedDisableAttesterInstruction) + | ({ + instructionType: MessageTransmitterInstruction.SetSignatureThreshold; + } & ParsedSetSignatureThresholdInstruction) + | ({ + instructionType: MessageTransmitterInstruction.SendMessage; + } & ParsedSendMessageInstruction) + | ({ + instructionType: MessageTransmitterInstruction.SendMessageWithCaller; + } & ParsedSendMessageWithCallerInstruction) + | ({ + instructionType: MessageTransmitterInstruction.ReplaceMessage; + } & ParsedReplaceMessageInstruction) + | ({ + instructionType: MessageTransmitterInstruction.ReceiveMessage; + } & ParsedReceiveMessageInstruction) + | ({ + instructionType: MessageTransmitterInstruction.ReclaimEventAccount; + } & ParsedReclaimEventAccountInstruction) + | ({ + instructionType: MessageTransmitterInstruction.GetNoncePda; + } & ParsedGetNoncePdaInstruction) + | ({ + instructionType: MessageTransmitterInstruction.IsNonceUsed; + } & ParsedIsNonceUsedInstruction); diff --git a/src/svm/clients/MessageTransmitter/shared/index.ts b/src/svm/clients/MessageTransmitter/shared/index.ts new file mode 100644 index 000000000..7ebc26514 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/shared/index.ts @@ -0,0 +1,164 @@ +/** + * 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 { + AccountRole, + isProgramDerivedAddress, + isTransactionSigner as kitIsTransactionSigner, + type AccountMeta, + type AccountSignerMeta, + type Address, + type ProgramDerivedAddress, + type TransactionSigner, + upgradeRoleToSigner, +} from '@solana/kit'; + +/** + * Asserts that the given value is not null or undefined. + * @internal + */ +export function expectSome(value: T | null | undefined): T { + if (value == null) { + throw new Error('Expected a value but received null or undefined.'); + } + return value; +} + +/** + * Asserts that the given value is a PublicKey. + * @internal + */ +export function expectAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): Address { + if (!value) { + throw new Error('Expected a Address.'); + } + if (typeof value === 'object' && 'address' in value) { + return value.address; + } + if (Array.isArray(value)) { + return value[0]; + } + return value as Address; +} + +/** + * Asserts that the given value is a PDA. + * @internal + */ +export function expectProgramDerivedAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): ProgramDerivedAddress { + if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { + throw new Error('Expected a ProgramDerivedAddress.'); + } + return value; +} + +/** + * Asserts that the given value is a TransactionSigner. + * @internal + */ +export function expectTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): TransactionSigner { + if (!value || !isTransactionSigner(value)) { + throw new Error('Expected a TransactionSigner.'); + } + return value; +} + +/** + * Defines an instruction account to resolve. + * @internal + */ +export type ResolvedAccount< + T extends string = string, + U extends + | Address + | ProgramDerivedAddress + | TransactionSigner + | null = + | Address + | ProgramDerivedAddress + | TransactionSigner + | null, +> = { + isWritable: boolean; + value: U; +}; + +/** + * Defines an instruction that stores additional bytes on-chain. + * @internal + */ +export type InstructionWithByteDelta = { + byteDelta: number; +}; + +/** + * Get account metas and signers from resolved accounts. + * @internal + */ +export function getAccountMetaFactory( + programAddress: Address, + optionalAccountStrategy: 'omitted' | 'programId' +) { + return ( + account: ResolvedAccount + ): AccountMeta | AccountSignerMeta | undefined => { + if (!account.value) { + if (optionalAccountStrategy === 'omitted') return; + return Object.freeze({ + address: programAddress, + role: AccountRole.READONLY, + }); + } + + const writableRole = account.isWritable + ? AccountRole.WRITABLE + : AccountRole.READONLY; + return Object.freeze({ + address: expectAddress(account.value), + role: isTransactionSigner(account.value) + ? upgradeRoleToSigner(writableRole) + : writableRole, + ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), + }); + }; +} + +export function isTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner +): value is TransactionSigner { + return ( + !!value && + typeof value === 'object' && + 'address' in value && + kitIsTransactionSigner(value) + ); +} diff --git a/src/svm/clients/MessageTransmitter/types/attesterDisabled.ts b/src/svm/clients/MessageTransmitter/types/attesterDisabled.ts new file mode 100644 index 000000000..b643a7a51 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/attesterDisabled.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/kit'; + +export type AttesterDisabled = { attester: Address }; + +export type AttesterDisabledArgs = AttesterDisabled; + +export function getAttesterDisabledEncoder(): Encoder { + return getStructEncoder([['attester', getAddressEncoder()]]); +} + +export function getAttesterDisabledDecoder(): Decoder { + return getStructDecoder([['attester', getAddressDecoder()]]); +} + +export function getAttesterDisabledCodec(): Codec< + AttesterDisabledArgs, + AttesterDisabled +> { + return combineCodec( + getAttesterDisabledEncoder(), + getAttesterDisabledDecoder() + ); +} diff --git a/src/svm/clients/MessageTransmitter/types/attesterEnabled.ts b/src/svm/clients/MessageTransmitter/types/attesterEnabled.ts new file mode 100644 index 000000000..ad2132a58 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/attesterEnabled.ts @@ -0,0 +1,38 @@ +/** + * 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/kit'; + +export type AttesterEnabled = { attester: Address }; + +export type AttesterEnabledArgs = AttesterEnabled; + +export function getAttesterEnabledEncoder(): Encoder { + return getStructEncoder([['attester', getAddressEncoder()]]); +} + +export function getAttesterEnabledDecoder(): Decoder { + return getStructDecoder([['attester', getAddressDecoder()]]); +} + +export function getAttesterEnabledCodec(): Codec< + AttesterEnabledArgs, + AttesterEnabled +> { + return combineCodec(getAttesterEnabledEncoder(), getAttesterEnabledDecoder()); +} diff --git a/src/svm/clients/MessageTransmitter/types/attesterManagerUpdated.ts b/src/svm/clients/MessageTransmitter/types/attesterManagerUpdated.ts new file mode 100644 index 000000000..f75c9f3ec --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/attesterManagerUpdated.ts @@ -0,0 +1,50 @@ +/** + * 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/kit'; + +export type AttesterManagerUpdated = { + previousAttesterManager: Address; + newAttesterManager: Address; +}; + +export type AttesterManagerUpdatedArgs = AttesterManagerUpdated; + +export function getAttesterManagerUpdatedEncoder(): Encoder { + return getStructEncoder([ + ['previousAttesterManager', getAddressEncoder()], + ['newAttesterManager', getAddressEncoder()], + ]); +} + +export function getAttesterManagerUpdatedDecoder(): Decoder { + return getStructDecoder([ + ['previousAttesterManager', getAddressDecoder()], + ['newAttesterManager', getAddressDecoder()], + ]); +} + +export function getAttesterManagerUpdatedCodec(): Codec< + AttesterManagerUpdatedArgs, + AttesterManagerUpdated +> { + return combineCodec( + getAttesterManagerUpdatedEncoder(), + getAttesterManagerUpdatedDecoder() + ); +} diff --git a/src/svm/clients/MessageTransmitter/types/handleReceiveMessageParams.ts b/src/svm/clients/MessageTransmitter/types/handleReceiveMessageParams.ts new file mode 100644 index 000000000..f0d1dde9b --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/handleReceiveMessageParams.ts @@ -0,0 +1,65 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU8Decoder, + getU8Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export type HandleReceiveMessageParams = { + remoteDomain: number; + sender: Address; + messageBody: ReadonlyUint8Array; + authorityBump: number; +}; + +export type HandleReceiveMessageParamsArgs = HandleReceiveMessageParams; + +export function getHandleReceiveMessageParamsEncoder(): Encoder { + return getStructEncoder([ + ['remoteDomain', getU32Encoder()], + ['sender', getAddressEncoder()], + ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ['authorityBump', getU8Encoder()], + ]); +} + +export function getHandleReceiveMessageParamsDecoder(): Decoder { + return getStructDecoder([ + ['remoteDomain', getU32Decoder()], + ['sender', getAddressDecoder()], + ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ['authorityBump', getU8Decoder()], + ]); +} + +export function getHandleReceiveMessageParamsCodec(): Codec< + HandleReceiveMessageParamsArgs, + HandleReceiveMessageParams +> { + return combineCodec( + getHandleReceiveMessageParamsEncoder(), + getHandleReceiveMessageParamsDecoder() + ); +} diff --git a/src/svm/clients/MessageTransmitter/types/index.ts b/src/svm/clients/MessageTransmitter/types/index.ts new file mode 100644 index 000000000..131ee2226 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/index.ts @@ -0,0 +1,21 @@ +/** + * 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 './attesterDisabled'; +export * from './attesterEnabled'; +export * from './attesterManagerUpdated'; +export * from './handleReceiveMessageParams'; +export * from './mathError'; +export * from './maxMessageBodySizeUpdated'; +export * from './messageReceived'; +export * from './ownershipTransferred'; +export * from './ownershipTransferStarted'; +export * from './pause'; +export * from './pauserChanged'; +export * from './signatureThresholdUpdated'; +export * from './unpause'; diff --git a/src/svm/clients/MessageTransmitter/types/mathError.ts b/src/svm/clients/MessageTransmitter/types/mathError.ts new file mode 100644 index 000000000..725835c2a --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/mathError.ts @@ -0,0 +1,36 @@ +/** + * 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, + getEnumDecoder, + getEnumEncoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export enum MathError { + MathOverflow, + MathUnderflow, + ErrorInDivision, +} + +export type MathErrorArgs = MathError; + +export function getMathErrorEncoder(): Encoder { + return getEnumEncoder(MathError); +} + +export function getMathErrorDecoder(): Decoder { + return getEnumDecoder(MathError); +} + +export function getMathErrorCodec(): Codec { + return combineCodec(getMathErrorEncoder(), getMathErrorDecoder()); +} diff --git a/src/svm/clients/MessageTransmitter/types/maxMessageBodySizeUpdated.ts b/src/svm/clients/MessageTransmitter/types/maxMessageBodySizeUpdated.ts new file mode 100644 index 000000000..8a0231c61 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/maxMessageBodySizeUpdated.ts @@ -0,0 +1,42 @@ +/** + * 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/kit'; + +export type MaxMessageBodySizeUpdated = { newMaxMessageBodySize: bigint }; + +export type MaxMessageBodySizeUpdatedArgs = { + newMaxMessageBodySize: number | bigint; +}; + +export function getMaxMessageBodySizeUpdatedEncoder(): Encoder { + return getStructEncoder([['newMaxMessageBodySize', getU64Encoder()]]); +} + +export function getMaxMessageBodySizeUpdatedDecoder(): Decoder { + return getStructDecoder([['newMaxMessageBodySize', getU64Decoder()]]); +} + +export function getMaxMessageBodySizeUpdatedCodec(): Codec< + MaxMessageBodySizeUpdatedArgs, + MaxMessageBodySizeUpdated +> { + return combineCodec( + getMaxMessageBodySizeUpdatedEncoder(), + getMaxMessageBodySizeUpdatedDecoder() + ); +} diff --git a/src/svm/clients/MessageTransmitter/types/messageReceived.ts b/src/svm/clients/MessageTransmitter/types/messageReceived.ts new file mode 100644 index 000000000..3340a3c79 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/messageReceived.ts @@ -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. + * + * @see https://github.com/codama-idl/codama + */ + +import { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export type MessageReceived = { + caller: Address; + sourceDomain: number; + nonce: bigint; + sender: Address; + messageBody: ReadonlyUint8Array; +}; + +export type MessageReceivedArgs = { + caller: Address; + sourceDomain: number; + nonce: number | bigint; + sender: Address; + messageBody: ReadonlyUint8Array; +}; + +export function getMessageReceivedEncoder(): Encoder { + return getStructEncoder([ + ['caller', getAddressEncoder()], + ['sourceDomain', getU32Encoder()], + ['nonce', getU64Encoder()], + ['sender', getAddressEncoder()], + ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]); +} + +export function getMessageReceivedDecoder(): Decoder { + return getStructDecoder([ + ['caller', getAddressDecoder()], + ['sourceDomain', getU32Decoder()], + ['nonce', getU64Decoder()], + ['sender', getAddressDecoder()], + ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getMessageReceivedCodec(): Codec< + MessageReceivedArgs, + MessageReceived +> { + return combineCodec(getMessageReceivedEncoder(), getMessageReceivedDecoder()); +} diff --git a/src/svm/clients/MessageTransmitter/types/ownershipTransferStarted.ts b/src/svm/clients/MessageTransmitter/types/ownershipTransferStarted.ts new file mode 100644 index 000000000..e170a569a --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/ownershipTransferStarted.ts @@ -0,0 +1,50 @@ +/** + * 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/kit'; + +export type OwnershipTransferStarted = { + previousOwner: Address; + newOwner: Address; +}; + +export type OwnershipTransferStartedArgs = OwnershipTransferStarted; + +export function getOwnershipTransferStartedEncoder(): Encoder { + return getStructEncoder([ + ['previousOwner', getAddressEncoder()], + ['newOwner', getAddressEncoder()], + ]); +} + +export function getOwnershipTransferStartedDecoder(): Decoder { + return getStructDecoder([ + ['previousOwner', getAddressDecoder()], + ['newOwner', getAddressDecoder()], + ]); +} + +export function getOwnershipTransferStartedCodec(): Codec< + OwnershipTransferStartedArgs, + OwnershipTransferStarted +> { + return combineCodec( + getOwnershipTransferStartedEncoder(), + getOwnershipTransferStartedDecoder() + ); +} diff --git a/src/svm/clients/MessageTransmitter/types/ownershipTransferred.ts b/src/svm/clients/MessageTransmitter/types/ownershipTransferred.ts new file mode 100644 index 000000000..40f21c661 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/ownershipTransferred.ts @@ -0,0 +1,50 @@ +/** + * 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/kit'; + +export type OwnershipTransferred = { + previousOwner: Address; + newOwner: Address; +}; + +export type OwnershipTransferredArgs = OwnershipTransferred; + +export function getOwnershipTransferredEncoder(): Encoder { + return getStructEncoder([ + ['previousOwner', getAddressEncoder()], + ['newOwner', getAddressEncoder()], + ]); +} + +export function getOwnershipTransferredDecoder(): Decoder { + return getStructDecoder([ + ['previousOwner', getAddressDecoder()], + ['newOwner', getAddressDecoder()], + ]); +} + +export function getOwnershipTransferredCodec(): Codec< + OwnershipTransferredArgs, + OwnershipTransferred +> { + return combineCodec( + getOwnershipTransferredEncoder(), + getOwnershipTransferredDecoder() + ); +} diff --git a/src/svm/clients/MessageTransmitter/types/pause.ts b/src/svm/clients/MessageTransmitter/types/pause.ts new file mode 100644 index 000000000..f1f423325 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/pause.ts @@ -0,0 +1,32 @@ +/** + * 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, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type Pause = {}; + +export type PauseArgs = Pause; + +export function getPauseEncoder(): Encoder { + return getStructEncoder([]); +} + +export function getPauseDecoder(): Decoder { + return getStructDecoder([]); +} + +export function getPauseCodec(): Codec { + return combineCodec(getPauseEncoder(), getPauseDecoder()); +} diff --git a/src/svm/clients/MessageTransmitter/types/pauserChanged.ts b/src/svm/clients/MessageTransmitter/types/pauserChanged.ts new file mode 100644 index 000000000..57d7433da --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/pauserChanged.ts @@ -0,0 +1,38 @@ +/** + * 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/kit'; + +export type PauserChanged = { newAddress: Address }; + +export type PauserChangedArgs = PauserChanged; + +export function getPauserChangedEncoder(): Encoder { + return getStructEncoder([['newAddress', getAddressEncoder()]]); +} + +export function getPauserChangedDecoder(): Decoder { + return getStructDecoder([['newAddress', getAddressDecoder()]]); +} + +export function getPauserChangedCodec(): Codec< + PauserChangedArgs, + PauserChanged +> { + return combineCodec(getPauserChangedEncoder(), getPauserChangedDecoder()); +} diff --git a/src/svm/clients/MessageTransmitter/types/signatureThresholdUpdated.ts b/src/svm/clients/MessageTransmitter/types/signatureThresholdUpdated.ts new file mode 100644 index 000000000..e8a729867 --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/signatureThresholdUpdated.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, + getU32Decoder, + getU32Encoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type SignatureThresholdUpdated = { + oldSignatureThreshold: number; + newSignatureThreshold: number; +}; + +export type SignatureThresholdUpdatedArgs = SignatureThresholdUpdated; + +export function getSignatureThresholdUpdatedEncoder(): Encoder { + return getStructEncoder([ + ['oldSignatureThreshold', getU32Encoder()], + ['newSignatureThreshold', getU32Encoder()], + ]); +} + +export function getSignatureThresholdUpdatedDecoder(): Decoder { + return getStructDecoder([ + ['oldSignatureThreshold', getU32Decoder()], + ['newSignatureThreshold', getU32Decoder()], + ]); +} + +export function getSignatureThresholdUpdatedCodec(): Codec< + SignatureThresholdUpdatedArgs, + SignatureThresholdUpdated +> { + return combineCodec( + getSignatureThresholdUpdatedEncoder(), + getSignatureThresholdUpdatedDecoder() + ); +} diff --git a/src/svm/clients/MessageTransmitter/types/unpause.ts b/src/svm/clients/MessageTransmitter/types/unpause.ts new file mode 100644 index 000000000..4fdc009ef --- /dev/null +++ b/src/svm/clients/MessageTransmitter/types/unpause.ts @@ -0,0 +1,32 @@ +/** + * 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, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type Unpause = {}; + +export type UnpauseArgs = Unpause; + +export function getUnpauseEncoder(): Encoder { + return getStructEncoder([]); +} + +export function getUnpauseDecoder(): Decoder { + return getStructDecoder([]); +} + +export function getUnpauseCodec(): Codec { + return combineCodec(getUnpauseEncoder(), getUnpauseDecoder()); +} diff --git a/src/svm/clients/MessageTransmitterV2/accounts/index.ts b/src/svm/clients/MessageTransmitterV2/accounts/index.ts new file mode 100644 index 000000000..4475a820f --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/accounts/index.ts @@ -0,0 +1,11 @@ +/** + * 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 './messageSent'; +export * from './messageTransmitter'; +export * from './usedNonce'; diff --git a/src/svm/clients/MessageTransmitterV2/accounts/messageSent.ts b/src/svm/clients/MessageTransmitterV2/accounts/messageSent.ts new file mode 100644 index 000000000..e401030f7 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/accounts/messageSent.ts @@ -0,0 +1,143 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getI64Decoder, + getI64Encoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const MESSAGE_SENT_DISCRIMINATOR = new Uint8Array([ + 131, 100, 133, 56, 166, 225, 151, 60, +]); + +export function getMessageSentDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + MESSAGE_SENT_DISCRIMINATOR + ); +} + +export type MessageSent = { + discriminator: ReadonlyUint8Array; + rentPayer: Address; + createdAt: bigint; + message: ReadonlyUint8Array; +}; + +export type MessageSentArgs = { + rentPayer: Address; + createdAt: number | bigint; + message: ReadonlyUint8Array; +}; + +export function getMessageSentEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['rentPayer', getAddressEncoder()], + ['createdAt', getI64Encoder()], + ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ ...value, discriminator: MESSAGE_SENT_DISCRIMINATOR }) + ); +} + +export function getMessageSentDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['rentPayer', getAddressDecoder()], + ['createdAt', getI64Decoder()], + ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getMessageSentCodec(): Codec { + return combineCodec(getMessageSentEncoder(), getMessageSentDecoder()); +} + +export function decodeMessageSent( + encodedAccount: EncodedAccount +): Account; +export function decodeMessageSent( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeMessageSent( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getMessageSentDecoder() + ); +} + +export async function fetchMessageSent( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeMessageSent(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeMessageSent( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeMessageSent(maybeAccount); +} + +export async function fetchAllMessageSent( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeMessageSent(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeMessageSent( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeMessageSent(maybeAccount)); +} diff --git a/src/svm/clients/MessageTransmitterV2/accounts/messageTransmitter.ts b/src/svm/clients/MessageTransmitterV2/accounts/messageTransmitter.ts new file mode 100644 index 000000000..7f6c300df --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/accounts/messageTransmitter.ts @@ -0,0 +1,189 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBooleanDecoder, + getBooleanEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const MESSAGE_TRANSMITTER_DISCRIMINATOR = new Uint8Array([ + 71, 40, 180, 142, 19, 203, 35, 252, +]); + +export function getMessageTransmitterDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + MESSAGE_TRANSMITTER_DISCRIMINATOR + ); +} + +export type MessageTransmitter = { + discriminator: ReadonlyUint8Array; + owner: Address; + pendingOwner: Address; + attesterManager: Address; + pauser: Address; + paused: boolean; + localDomain: number; + version: number; + signatureThreshold: number; + enabledAttesters: Array
; + maxMessageBodySize: bigint; +}; + +export type MessageTransmitterArgs = { + owner: Address; + pendingOwner: Address; + attesterManager: Address; + pauser: Address; + paused: boolean; + localDomain: number; + version: number; + signatureThreshold: number; + enabledAttesters: Array
; + maxMessageBodySize: number | bigint; +}; + +export function getMessageTransmitterEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['owner', getAddressEncoder()], + ['pendingOwner', getAddressEncoder()], + ['attesterManager', getAddressEncoder()], + ['pauser', getAddressEncoder()], + ['paused', getBooleanEncoder()], + ['localDomain', getU32Encoder()], + ['version', getU32Encoder()], + ['signatureThreshold', getU32Encoder()], + ['enabledAttesters', getArrayEncoder(getAddressEncoder())], + ['maxMessageBodySize', getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: MESSAGE_TRANSMITTER_DISCRIMINATOR }) + ); +} + +export function getMessageTransmitterDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['owner', getAddressDecoder()], + ['pendingOwner', getAddressDecoder()], + ['attesterManager', getAddressDecoder()], + ['pauser', getAddressDecoder()], + ['paused', getBooleanDecoder()], + ['localDomain', getU32Decoder()], + ['version', getU32Decoder()], + ['signatureThreshold', getU32Decoder()], + ['enabledAttesters', getArrayDecoder(getAddressDecoder())], + ['maxMessageBodySize', getU64Decoder()], + ]); +} + +export function getMessageTransmitterCodec(): Codec< + MessageTransmitterArgs, + MessageTransmitter +> { + return combineCodec( + getMessageTransmitterEncoder(), + getMessageTransmitterDecoder() + ); +} + +export function decodeMessageTransmitter( + encodedAccount: EncodedAccount +): Account; +export function decodeMessageTransmitter( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeMessageTransmitter( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getMessageTransmitterDecoder() + ); +} + +export async function fetchMessageTransmitter( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeMessageTransmitter(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeMessageTransmitter< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeMessageTransmitter(maybeAccount); +} + +export async function fetchAllMessageTransmitter( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeMessageTransmitter( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeMessageTransmitter( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeMessageTransmitter(maybeAccount) + ); +} diff --git a/src/svm/clients/MessageTransmitterV2/accounts/usedNonce.ts b/src/svm/clients/MessageTransmitterV2/accounts/usedNonce.ts new file mode 100644 index 000000000..a39c6cbbd --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/accounts/usedNonce.ts @@ -0,0 +1,126 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBooleanDecoder, + getBooleanEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const USED_NONCE_DISCRIMINATOR = new Uint8Array([ + 212, 222, 157, 252, 130, 71, 179, 238, +]); + +export function getUsedNonceDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(USED_NONCE_DISCRIMINATOR); +} + +export type UsedNonce = { discriminator: ReadonlyUint8Array; isUsed: boolean }; + +export type UsedNonceArgs = { isUsed: boolean }; + +export function getUsedNonceEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['isUsed', getBooleanEncoder()], + ]), + (value) => ({ ...value, discriminator: USED_NONCE_DISCRIMINATOR }) + ); +} + +export function getUsedNonceDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['isUsed', getBooleanDecoder()], + ]); +} + +export function getUsedNonceCodec(): Codec { + return combineCodec(getUsedNonceEncoder(), getUsedNonceDecoder()); +} + +export function decodeUsedNonce( + encodedAccount: EncodedAccount +): Account; +export function decodeUsedNonce( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeUsedNonce( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getUsedNonceDecoder() + ); +} + +export async function fetchUsedNonce( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeUsedNonce(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeUsedNonce( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeUsedNonce(maybeAccount); +} + +export async function fetchAllUsedNonce( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeUsedNonce(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeUsedNonce( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeUsedNonce(maybeAccount)); +} + +export function getUsedNonceSize(): number { + return 9; +} diff --git a/src/svm/clients/MessageTransmitterV2/errors/index.ts b/src/svm/clients/MessageTransmitterV2/errors/index.ts new file mode 100644 index 000000000..eecc709dc --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/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 './messageTransmitterV2'; diff --git a/src/svm/clients/MessageTransmitterV2/errors/messageTransmitterV2.ts b/src/svm/clients/MessageTransmitterV2/errors/messageTransmitterV2.ts new file mode 100644 index 000000000..1e8e1a679 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/errors/messageTransmitterV2.ts @@ -0,0 +1,199 @@ +/** + * 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/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; + +/** InvalidAuthority: Invalid authority */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_AUTHORITY = 0x1770; // 6000 +/** ProgramPaused: Instruction is not allowed at this time */ +export const MESSAGE_TRANSMITTER_V2_ERROR__PROGRAM_PAUSED = 0x1771; // 6001 +/** InvalidMessageTransmitterState: Invalid message transmitter state */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_TRANSMITTER_STATE = 0x1772; // 6002 +/** InvalidSignatureThreshold: Invalid signature threshold */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_THRESHOLD = 0x1773; // 6003 +/** SignatureThresholdAlreadySet: Signature threshold already set */ +export const MESSAGE_TRANSMITTER_V2_ERROR__SIGNATURE_THRESHOLD_ALREADY_SET = 0x1774; // 6004 +/** InvalidOwner: Invalid owner */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_OWNER = 0x1775; // 6005 +/** InvalidPauser: Invalid pauser */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_PAUSER = 0x1776; // 6006 +/** InvalidAttesterManager: Invalid attester manager */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER_MANAGER = 0x1777; // 6007 +/** InvalidAttester: Invalid attester */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER = 0x1778; // 6008 +/** AttesterAlreadyEnabled: Attester already enabled */ +export const MESSAGE_TRANSMITTER_V2_ERROR__ATTESTER_ALREADY_ENABLED = 0x1779; // 6009 +/** TooFewEnabledAttesters: Too few enabled attesters */ +export const MESSAGE_TRANSMITTER_V2_ERROR__TOO_FEW_ENABLED_ATTESTERS = 0x177a; // 6010 +/** SignatureThresholdTooLow: Signature threshold is too low */ +export const MESSAGE_TRANSMITTER_V2_ERROR__SIGNATURE_THRESHOLD_TOO_LOW = 0x177b; // 6011 +/** AttesterAlreadyDisabled: Attester already disabled */ +export const MESSAGE_TRANSMITTER_V2_ERROR__ATTESTER_ALREADY_DISABLED = 0x177c; // 6012 +/** MessageBodyLimitExceeded: Message body exceeds max size */ +export const MESSAGE_TRANSMITTER_V2_ERROR__MESSAGE_BODY_LIMIT_EXCEEDED = 0x177d; // 6013 +/** InvalidDestinationCaller: Invalid destination caller */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_CALLER = 0x177e; // 6014 +/** InvalidRecipient: Invalid message recipient */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_RECIPIENT = 0x177f; // 6015 +/** SenderNotPermitted: Sender is not permitted */ +export const MESSAGE_TRANSMITTER_V2_ERROR__SENDER_NOT_PERMITTED = 0x1780; // 6016 +/** InvalidSourceDomain: Invalid source domain */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SOURCE_DOMAIN = 0x1781; // 6017 +/** InvalidDestinationDomain: Invalid destination domain */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_DOMAIN = 0x1782; // 6018 +/** InvalidMessageVersion: Invalid message version */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_VERSION = 0x1783; // 6019 +/** InvalidUsedNoncesAccount: Invalid used nonces account */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_USED_NONCES_ACCOUNT = 0x1784; // 6020 +/** InvalidRecipientProgram: Invalid recipient program */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_RECIPIENT_PROGRAM = 0x1785; // 6021 +/** InvalidNonce: Invalid nonce */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_NONCE = 0x1786; // 6022 +/** NonceAlreadyUsed: Nonce already used */ +export const MESSAGE_TRANSMITTER_V2_ERROR__NONCE_ALREADY_USED = 0x1787; // 6023 +/** MessageTooShort: Message is too short */ +export const MESSAGE_TRANSMITTER_V2_ERROR__MESSAGE_TOO_SHORT = 0x1788; // 6024 +/** MalformedMessage: Malformed message */ +export const MESSAGE_TRANSMITTER_V2_ERROR__MALFORMED_MESSAGE = 0x1789; // 6025 +/** InvalidSignatureOrderOrDupe: Invalid signature order or dupe */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_ORDER_OR_DUPE = 0x178a; // 6026 +/** InvalidAttesterSignature: Invalid attester signature */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER_SIGNATURE = 0x178b; // 6027 +/** InvalidAttestationLength: Invalid attestation length */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTATION_LENGTH = 0x178c; // 6028 +/** InvalidSignatureRecoveryId: Invalid signature recovery ID */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_RECOVERY_ID = 0x178d; // 6029 +/** InvalidSignatureSValue: Invalid signature S value */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_S_VALUE = 0x178e; // 6030 +/** InvalidMessageHash: Invalid message hash */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_HASH = 0x178f; // 6031 +/** InvalidDestinationMessage: Invalid destination message */ +export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_MESSAGE = 0x1790; // 6032 +/** EventAccountWindowNotExpired: Event account window not expired */ +export const MESSAGE_TRANSMITTER_V2_ERROR__EVENT_ACCOUNT_WINDOW_NOT_EXPIRED = 0x1791; // 6033 +/** DestinationDomainIsLocalDomain: Destination domain is local domain */ +export const MESSAGE_TRANSMITTER_V2_ERROR__DESTINATION_DOMAIN_IS_LOCAL_DOMAIN = 0x1792; // 6034 + +export type MessageTransmitterV2Error = + | typeof MESSAGE_TRANSMITTER_V2_ERROR__ATTESTER_ALREADY_DISABLED + | typeof MESSAGE_TRANSMITTER_V2_ERROR__ATTESTER_ALREADY_ENABLED + | typeof MESSAGE_TRANSMITTER_V2_ERROR__DESTINATION_DOMAIN_IS_LOCAL_DOMAIN + | typeof MESSAGE_TRANSMITTER_V2_ERROR__EVENT_ACCOUNT_WINDOW_NOT_EXPIRED + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTATION_LENGTH + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER_MANAGER + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER_SIGNATURE + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_AUTHORITY + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_CALLER + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_DOMAIN + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_MESSAGE + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_HASH + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_TRANSMITTER_STATE + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_VERSION + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_NONCE + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_OWNER + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_PAUSER + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_RECIPIENT + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_RECIPIENT_PROGRAM + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_ORDER_OR_DUPE + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_RECOVERY_ID + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_S_VALUE + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_THRESHOLD + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SOURCE_DOMAIN + | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_USED_NONCES_ACCOUNT + | typeof MESSAGE_TRANSMITTER_V2_ERROR__MALFORMED_MESSAGE + | typeof MESSAGE_TRANSMITTER_V2_ERROR__MESSAGE_BODY_LIMIT_EXCEEDED + | typeof MESSAGE_TRANSMITTER_V2_ERROR__MESSAGE_TOO_SHORT + | typeof MESSAGE_TRANSMITTER_V2_ERROR__NONCE_ALREADY_USED + | typeof MESSAGE_TRANSMITTER_V2_ERROR__PROGRAM_PAUSED + | typeof MESSAGE_TRANSMITTER_V2_ERROR__SENDER_NOT_PERMITTED + | typeof MESSAGE_TRANSMITTER_V2_ERROR__SIGNATURE_THRESHOLD_ALREADY_SET + | typeof MESSAGE_TRANSMITTER_V2_ERROR__SIGNATURE_THRESHOLD_TOO_LOW + | typeof MESSAGE_TRANSMITTER_V2_ERROR__TOO_FEW_ENABLED_ATTESTERS; + +let messageTransmitterV2ErrorMessages: + | Record + | undefined; +if (process.env.NODE_ENV !== 'production') { + messageTransmitterV2ErrorMessages = { + [MESSAGE_TRANSMITTER_V2_ERROR__ATTESTER_ALREADY_DISABLED]: `Attester already disabled`, + [MESSAGE_TRANSMITTER_V2_ERROR__ATTESTER_ALREADY_ENABLED]: `Attester already enabled`, + [MESSAGE_TRANSMITTER_V2_ERROR__DESTINATION_DOMAIN_IS_LOCAL_DOMAIN]: `Destination domain is local domain`, + [MESSAGE_TRANSMITTER_V2_ERROR__EVENT_ACCOUNT_WINDOW_NOT_EXPIRED]: `Event account window not expired`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTATION_LENGTH]: `Invalid attestation length`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER]: `Invalid attester`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER_MANAGER]: `Invalid attester manager`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER_SIGNATURE]: `Invalid attester signature`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_AUTHORITY]: `Invalid authority`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_CALLER]: `Invalid destination caller`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_DOMAIN]: `Invalid destination domain`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_MESSAGE]: `Invalid destination message`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_HASH]: `Invalid message hash`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_TRANSMITTER_STATE]: `Invalid message transmitter state`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_VERSION]: `Invalid message version`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_NONCE]: `Invalid nonce`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_OWNER]: `Invalid owner`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_PAUSER]: `Invalid pauser`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_RECIPIENT]: `Invalid message recipient`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_RECIPIENT_PROGRAM]: `Invalid recipient program`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_ORDER_OR_DUPE]: `Invalid signature order or dupe`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_RECOVERY_ID]: `Invalid signature recovery ID`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_S_VALUE]: `Invalid signature S value`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_THRESHOLD]: `Invalid signature threshold`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SOURCE_DOMAIN]: `Invalid source domain`, + [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_USED_NONCES_ACCOUNT]: `Invalid used nonces account`, + [MESSAGE_TRANSMITTER_V2_ERROR__MALFORMED_MESSAGE]: `Malformed message`, + [MESSAGE_TRANSMITTER_V2_ERROR__MESSAGE_BODY_LIMIT_EXCEEDED]: `Message body exceeds max size`, + [MESSAGE_TRANSMITTER_V2_ERROR__MESSAGE_TOO_SHORT]: `Message is too short`, + [MESSAGE_TRANSMITTER_V2_ERROR__NONCE_ALREADY_USED]: `Nonce already used`, + [MESSAGE_TRANSMITTER_V2_ERROR__PROGRAM_PAUSED]: `Instruction is not allowed at this time`, + [MESSAGE_TRANSMITTER_V2_ERROR__SENDER_NOT_PERMITTED]: `Sender is not permitted`, + [MESSAGE_TRANSMITTER_V2_ERROR__SIGNATURE_THRESHOLD_ALREADY_SET]: `Signature threshold already set`, + [MESSAGE_TRANSMITTER_V2_ERROR__SIGNATURE_THRESHOLD_TOO_LOW]: `Signature threshold is too low`, + [MESSAGE_TRANSMITTER_V2_ERROR__TOO_FEW_ENABLED_ATTESTERS]: `Too few enabled attesters`, + }; +} + +export function getMessageTransmitterV2ErrorMessage( + code: MessageTransmitterV2Error +): string { + if (process.env.NODE_ENV !== 'production') { + return ( + messageTransmitterV2ErrorMessages as Record< + MessageTransmitterV2Error, + string + > + )[code]; + } + + return 'Error message not available in production bundles.'; +} + +export function isMessageTransmitterV2Error< + TProgramErrorCode extends MessageTransmitterV2Error, +>( + error: unknown, + transactionMessage: { + instructions: Record; + }, + code?: TProgramErrorCode +): error is SolanaError & + Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { + return isProgramError( + error, + transactionMessage, + MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + code + ); +} diff --git a/src/svm/clients/MessageTransmitterV2/index.ts b/src/svm/clients/MessageTransmitterV2/index.ts new file mode 100644 index 000000000..02964a6ae --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/index.ts @@ -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. + * + * @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/src/svm/clients/MessageTransmitterV2/instructions/acceptOwnership.ts b/src/svm/clients/MessageTransmitterV2/instructions/acceptOwnership.ts new file mode 100644 index 000000000..aa7ab864c --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/acceptOwnership.ts @@ -0,0 +1,311 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const ACCEPT_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ + 172, 23, 43, 13, 238, 213, 85, 150, +]); + +export function getAcceptOwnershipDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + ACCEPT_OWNERSHIP_DISCRIMINATOR + ); +} + +export type AcceptOwnershipInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountPendingOwner extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPendingOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountPendingOwner, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type AcceptOwnershipInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type AcceptOwnershipInstructionDataArgs = {}; + +export function getAcceptOwnershipInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: ACCEPT_OWNERSHIP_DISCRIMINATOR }) + ); +} + +export function getAcceptOwnershipInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getAcceptOwnershipInstructionDataCodec(): Codec< + AcceptOwnershipInstructionDataArgs, + AcceptOwnershipInstructionData +> { + return combineCodec( + getAcceptOwnershipInstructionDataEncoder(), + getAcceptOwnershipInstructionDataDecoder() + ); +} + +export type AcceptOwnershipAsyncInput< + TAccountPendingOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pendingOwner: TransactionSigner; + messageTransmitter: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getAcceptOwnershipInstructionAsync< + TAccountPendingOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: AcceptOwnershipAsyncInput< + TAccountPendingOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + AcceptOwnershipInstruction< + TProgramAddress, + TAccountPendingOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pendingOwner: { value: input.pendingOwner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pendingOwner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getAcceptOwnershipInstructionDataEncoder().encode({}), + } as AcceptOwnershipInstruction< + TProgramAddress, + TAccountPendingOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type AcceptOwnershipInput< + TAccountPendingOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pendingOwner: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; +}; + +export function getAcceptOwnershipInstruction< + TAccountPendingOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: AcceptOwnershipInput< + TAccountPendingOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): AcceptOwnershipInstruction< + TProgramAddress, + TAccountPendingOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pendingOwner: { value: input.pendingOwner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pendingOwner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getAcceptOwnershipInstructionDataEncoder().encode({}), + } as AcceptOwnershipInstruction< + TProgramAddress, + TAccountPendingOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedAcceptOwnershipInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + pendingOwner: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: AcceptOwnershipInstructionData; +}; + +export function parseAcceptOwnershipInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedAcceptOwnershipInstruction { + if (instruction.accounts.length < 4) { + // 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: { + pendingOwner: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getAcceptOwnershipInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/disableAttester.ts b/src/svm/clients/MessageTransmitterV2/instructions/disableAttester.ts new file mode 100644 index 000000000..07eb78250 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/disableAttester.ts @@ -0,0 +1,393 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const DISABLE_ATTESTER_DISCRIMINATOR = new Uint8Array([ + 61, 171, 131, 95, 172, 15, 227, 229, +]); + +export function getDisableAttesterDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DISABLE_ATTESTER_DISCRIMINATOR + ); +} + +export type DisableAttesterInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountAttesterManager extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountAttesterManager extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAttesterManager, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type DisableAttesterInstructionData = { + discriminator: ReadonlyUint8Array; + attester: Address; +}; + +export type DisableAttesterInstructionDataArgs = { attester: Address }; + +export function getDisableAttesterInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['attester', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: DISABLE_ATTESTER_DISCRIMINATOR }) + ); +} + +export function getDisableAttesterInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['attester', getAddressDecoder()], + ]); +} + +export function getDisableAttesterInstructionDataCodec(): Codec< + DisableAttesterInstructionDataArgs, + DisableAttesterInstructionData +> { + return combineCodec( + getDisableAttesterInstructionDataEncoder(), + getDisableAttesterInstructionDataDecoder() + ); +} + +export type DisableAttesterAsyncInput< + TAccountPayer extends string = string, + TAccountAttesterManager extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + attesterManager: TransactionSigner; + messageTransmitter: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + attester: DisableAttesterInstructionDataArgs['attester']; +}; + +export async function getDisableAttesterInstructionAsync< + TAccountPayer extends string, + TAccountAttesterManager extends string, + TAccountMessageTransmitter extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: DisableAttesterAsyncInput< + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + DisableAttesterInstruction< + TProgramAddress, + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + attesterManager: { + value: input.attesterManager ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.attesterManager), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDisableAttesterInstructionDataEncoder().encode( + args as DisableAttesterInstructionDataArgs + ), + } as DisableAttesterInstruction< + TProgramAddress, + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type DisableAttesterInput< + TAccountPayer extends string = string, + TAccountAttesterManager extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + attesterManager: TransactionSigner; + messageTransmitter: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + attester: DisableAttesterInstructionDataArgs['attester']; +}; + +export function getDisableAttesterInstruction< + TAccountPayer extends string, + TAccountAttesterManager extends string, + TAccountMessageTransmitter extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: DisableAttesterInput< + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): DisableAttesterInstruction< + TProgramAddress, + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + attesterManager: { + value: input.attesterManager ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.attesterManager), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDisableAttesterInstructionDataEncoder().encode( + args as DisableAttesterInstructionDataArgs + ), + } as DisableAttesterInstruction< + TProgramAddress, + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedDisableAttesterInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + attesterManager: TAccountMetas[1]; + messageTransmitter: TAccountMetas[2]; + systemProgram: TAccountMetas[3]; + eventAuthority: TAccountMetas[4]; + program: TAccountMetas[5]; + }; + data: DisableAttesterInstructionData; +}; + +export function parseDisableAttesterInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedDisableAttesterInstruction { + if (instruction.accounts.length < 6) { + // 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: { + payer: getNextAccount(), + attesterManager: getNextAccount(), + messageTransmitter: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getDisableAttesterInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/enableAttester.ts b/src/svm/clients/MessageTransmitterV2/instructions/enableAttester.ts new file mode 100644 index 000000000..9f8ee2d60 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/enableAttester.ts @@ -0,0 +1,393 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const ENABLE_ATTESTER_DISCRIMINATOR = new Uint8Array([ + 2, 11, 193, 115, 5, 148, 4, 198, +]); + +export function getEnableAttesterDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + ENABLE_ATTESTER_DISCRIMINATOR + ); +} + +export type EnableAttesterInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountAttesterManager extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountAttesterManager extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAttesterManager, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type EnableAttesterInstructionData = { + discriminator: ReadonlyUint8Array; + newAttester: Address; +}; + +export type EnableAttesterInstructionDataArgs = { newAttester: Address }; + +export function getEnableAttesterInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newAttester', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: ENABLE_ATTESTER_DISCRIMINATOR }) + ); +} + +export function getEnableAttesterInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newAttester', getAddressDecoder()], + ]); +} + +export function getEnableAttesterInstructionDataCodec(): Codec< + EnableAttesterInstructionDataArgs, + EnableAttesterInstructionData +> { + return combineCodec( + getEnableAttesterInstructionDataEncoder(), + getEnableAttesterInstructionDataDecoder() + ); +} + +export type EnableAttesterAsyncInput< + TAccountPayer extends string = string, + TAccountAttesterManager extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + attesterManager: TransactionSigner; + messageTransmitter: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + newAttester: EnableAttesterInstructionDataArgs['newAttester']; +}; + +export async function getEnableAttesterInstructionAsync< + TAccountPayer extends string, + TAccountAttesterManager extends string, + TAccountMessageTransmitter extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: EnableAttesterAsyncInput< + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + EnableAttesterInstruction< + TProgramAddress, + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + attesterManager: { + value: input.attesterManager ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.attesterManager), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getEnableAttesterInstructionDataEncoder().encode( + args as EnableAttesterInstructionDataArgs + ), + } as EnableAttesterInstruction< + TProgramAddress, + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type EnableAttesterInput< + TAccountPayer extends string = string, + TAccountAttesterManager extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + attesterManager: TransactionSigner; + messageTransmitter: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + newAttester: EnableAttesterInstructionDataArgs['newAttester']; +}; + +export function getEnableAttesterInstruction< + TAccountPayer extends string, + TAccountAttesterManager extends string, + TAccountMessageTransmitter extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: EnableAttesterInput< + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): EnableAttesterInstruction< + TProgramAddress, + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + attesterManager: { + value: input.attesterManager ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.attesterManager), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getEnableAttesterInstructionDataEncoder().encode( + args as EnableAttesterInstructionDataArgs + ), + } as EnableAttesterInstruction< + TProgramAddress, + TAccountPayer, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedEnableAttesterInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + attesterManager: TAccountMetas[1]; + messageTransmitter: TAccountMetas[2]; + systemProgram: TAccountMetas[3]; + eventAuthority: TAccountMetas[4]; + program: TAccountMetas[5]; + }; + data: EnableAttesterInstructionData; +}; + +export function parseEnableAttesterInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedEnableAttesterInstruction { + if (instruction.accounts.length < 6) { + // 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: { + payer: getNextAccount(), + attesterManager: getNextAccount(), + messageTransmitter: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getEnableAttesterInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/index.ts b/src/svm/clients/MessageTransmitterV2/instructions/index.ts new file mode 100644 index 000000000..9aa64f714 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/index.ts @@ -0,0 +1,23 @@ +/** + * 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 './acceptOwnership'; +export * from './disableAttester'; +export * from './enableAttester'; +export * from './initialize'; +export * from './isNonceUsed'; +export * from './pause'; +export * from './receiveMessage'; +export * from './reclaimEventAccount'; +export * from './sendMessage'; +export * from './setMaxMessageBodySize'; +export * from './setSignatureThreshold'; +export * from './transferOwnership'; +export * from './unpause'; +export * from './updateAttesterManager'; +export * from './updatePauser'; diff --git a/src/svm/clients/MessageTransmitterV2/instructions/initialize.ts b/src/svm/clients/MessageTransmitterV2/instructions/initialize.ts new file mode 100644 index 000000000..95ab689b1 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/initialize.ts @@ -0,0 +1,494 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const INITIALIZE_DISCRIMINATOR = new Uint8Array([ + 175, 175, 109, 31, 13, 152, 155, 237, +]); + +export function getInitializeDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_DISCRIMINATOR); +} + +export type InitializeInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountUpgradeAuthority extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountMessageTransmitterProgramData extends string | AccountMeta = + string, + TAccountMessageTransmitterProgram extends string | AccountMeta = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountUpgradeAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountUpgradeAuthority, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountMessageTransmitterProgramData extends string + ? ReadonlyAccount + : TAccountMessageTransmitterProgramData, + TAccountMessageTransmitterProgram extends string + ? ReadonlyAccount + : TAccountMessageTransmitterProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type InitializeInstructionData = { + discriminator: ReadonlyUint8Array; + localDomain: number; + attester: Address; + maxMessageBodySize: bigint; + version: number; +}; + +export type InitializeInstructionDataArgs = { + localDomain: number; + attester: Address; + maxMessageBodySize: number | bigint; + version: number; +}; + +export function getInitializeInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['localDomain', getU32Encoder()], + ['attester', getAddressEncoder()], + ['maxMessageBodySize', getU64Encoder()], + ['version', getU32Encoder()], + ]), + (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) + ); +} + +export function getInitializeInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['localDomain', getU32Decoder()], + ['attester', getAddressDecoder()], + ['maxMessageBodySize', getU64Decoder()], + ['version', getU32Decoder()], + ]); +} + +export function getInitializeInstructionDataCodec(): Codec< + InitializeInstructionDataArgs, + InitializeInstructionData +> { + return combineCodec( + getInitializeInstructionDataEncoder(), + getInitializeInstructionDataDecoder() + ); +} + +export type InitializeAsyncInput< + TAccountPayer extends string = string, + TAccountUpgradeAuthority extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountMessageTransmitterProgramData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + upgradeAuthority: TransactionSigner; + messageTransmitter?: Address; + messageTransmitterProgramData: Address; + messageTransmitterProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + localDomain: InitializeInstructionDataArgs['localDomain']; + attester: InitializeInstructionDataArgs['attester']; + maxMessageBodySize: InitializeInstructionDataArgs['maxMessageBodySize']; + version: InitializeInstructionDataArgs['version']; +}; + +export async function getInitializeInstructionAsync< + TAccountPayer extends string, + TAccountUpgradeAuthority extends string, + TAccountMessageTransmitter extends string, + TAccountMessageTransmitterProgramData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: InitializeAsyncInput< + TAccountPayer, + TAccountUpgradeAuthority, + TAccountMessageTransmitter, + TAccountMessageTransmitterProgramData, + TAccountMessageTransmitterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + InitializeInstruction< + TProgramAddress, + TAccountPayer, + TAccountUpgradeAuthority, + TAccountMessageTransmitter, + TAccountMessageTransmitterProgramData, + TAccountMessageTransmitterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + upgradeAuthority: { + value: input.upgradeAuthority ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + messageTransmitterProgramData: { + value: input.messageTransmitterProgramData ?? null, + isWritable: false, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.messageTransmitter.value) { + accounts.messageTransmitter.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 109, 101, 115, 115, 97, 103, 101, 95, 116, 114, 97, 110, 115, 109, + 105, 116, 116, 101, 114, + ]) + ), + ], + }); + } + if (!accounts.messageTransmitterProgram.value) { + accounts.messageTransmitterProgram.value = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.upgradeAuthority), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.messageTransmitterProgramData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getInitializeInstructionDataEncoder().encode( + args as InitializeInstructionDataArgs + ), + } as InitializeInstruction< + TProgramAddress, + TAccountPayer, + TAccountUpgradeAuthority, + TAccountMessageTransmitter, + TAccountMessageTransmitterProgramData, + TAccountMessageTransmitterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type InitializeInput< + TAccountPayer extends string = string, + TAccountUpgradeAuthority extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountMessageTransmitterProgramData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + upgradeAuthority: TransactionSigner; + messageTransmitter: Address; + messageTransmitterProgramData: Address; + messageTransmitterProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + localDomain: InitializeInstructionDataArgs['localDomain']; + attester: InitializeInstructionDataArgs['attester']; + maxMessageBodySize: InitializeInstructionDataArgs['maxMessageBodySize']; + version: InitializeInstructionDataArgs['version']; +}; + +export function getInitializeInstruction< + TAccountPayer extends string, + TAccountUpgradeAuthority extends string, + TAccountMessageTransmitter extends string, + TAccountMessageTransmitterProgramData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: InitializeInput< + TAccountPayer, + TAccountUpgradeAuthority, + TAccountMessageTransmitter, + TAccountMessageTransmitterProgramData, + TAccountMessageTransmitterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): InitializeInstruction< + TProgramAddress, + TAccountPayer, + TAccountUpgradeAuthority, + TAccountMessageTransmitter, + TAccountMessageTransmitterProgramData, + TAccountMessageTransmitterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + upgradeAuthority: { + value: input.upgradeAuthority ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + messageTransmitterProgramData: { + value: input.messageTransmitterProgramData ?? null, + isWritable: false, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.messageTransmitterProgram.value) { + accounts.messageTransmitterProgram.value = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.upgradeAuthority), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.messageTransmitterProgramData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getInitializeInstructionDataEncoder().encode( + args as InitializeInstructionDataArgs + ), + } as InitializeInstruction< + TProgramAddress, + TAccountPayer, + TAccountUpgradeAuthority, + TAccountMessageTransmitter, + TAccountMessageTransmitterProgramData, + TAccountMessageTransmitterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedInitializeInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + upgradeAuthority: TAccountMetas[1]; + messageTransmitter: TAccountMetas[2]; + messageTransmitterProgramData: TAccountMetas[3]; + messageTransmitterProgram: TAccountMetas[4]; + systemProgram: TAccountMetas[5]; + eventAuthority: TAccountMetas[6]; + program: TAccountMetas[7]; + }; + data: InitializeInstructionData; +}; + +export function parseInitializeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedInitializeInstruction { + if (instruction.accounts.length < 8) { + // 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: { + payer: getNextAccount(), + upgradeAuthority: getNextAccount(), + messageTransmitter: getNextAccount(), + messageTransmitterProgramData: getNextAccount(), + messageTransmitterProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getInitializeInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/isNonceUsed.ts b/src/svm/clients/MessageTransmitterV2/instructions/isNonceUsed.ts new file mode 100644 index 000000000..3d4f6ac42 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/isNonceUsed.ts @@ -0,0 +1,157 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const IS_NONCE_USED_DISCRIMINATOR = new Uint8Array([ + 144, 72, 107, 148, 35, 218, 31, 187, +]); + +export function getIsNonceUsedDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + IS_NONCE_USED_DISCRIMINATOR + ); +} + +export type IsNonceUsedInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountUsedNonce extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountUsedNonce extends string + ? ReadonlyAccount + : TAccountUsedNonce, + ...TRemainingAccounts, + ] + >; + +export type IsNonceUsedInstructionData = { discriminator: ReadonlyUint8Array }; + +export type IsNonceUsedInstructionDataArgs = {}; + +export function getIsNonceUsedInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: IS_NONCE_USED_DISCRIMINATOR }) + ); +} + +export function getIsNonceUsedInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getIsNonceUsedInstructionDataCodec(): Codec< + IsNonceUsedInstructionDataArgs, + IsNonceUsedInstructionData +> { + return combineCodec( + getIsNonceUsedInstructionDataEncoder(), + getIsNonceUsedInstructionDataDecoder() + ); +} + +export type IsNonceUsedInput = { + /** Account will be explicitly loaded to avoid error when it's not initialized */ + usedNonce: Address; +}; + +export function getIsNonceUsedInstruction< + TAccountUsedNonce extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: IsNonceUsedInput, + config?: { programAddress?: TProgramAddress } +): IsNonceUsedInstruction { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + usedNonce: { value: input.usedNonce ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [getAccountMeta(accounts.usedNonce)], + programAddress, + data: getIsNonceUsedInstructionDataEncoder().encode({}), + } as IsNonceUsedInstruction; + + return instruction; +} + +export type ParsedIsNonceUsedInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + /** Account will be explicitly loaded to avoid error when it's not initialized */ + usedNonce: TAccountMetas[0]; + }; + data: IsNonceUsedInstructionData; +}; + +export function parseIsNonceUsedInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedIsNonceUsedInstruction { + if (instruction.accounts.length < 1) { + // 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: { + usedNonce: getNextAccount(), + }, + data: getIsNonceUsedInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/pause.ts b/src/svm/clients/MessageTransmitterV2/instructions/pause.ts new file mode 100644 index 000000000..2a43d3d20 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/pause.ts @@ -0,0 +1,307 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const PAUSE_DISCRIMINATOR = new Uint8Array([ + 211, 22, 221, 251, 74, 121, 193, 47, +]); + +export function getPauseDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(PAUSE_DISCRIMINATOR); +} + +export type PauseInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountPauser extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPauser extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountPauser, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type PauseInstructionData = { discriminator: ReadonlyUint8Array }; + +export type PauseInstructionDataArgs = {}; + +export function getPauseInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: PAUSE_DISCRIMINATOR }) + ); +} + +export function getPauseInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getPauseInstructionDataCodec(): Codec< + PauseInstructionDataArgs, + PauseInstructionData +> { + return combineCodec( + getPauseInstructionDataEncoder(), + getPauseInstructionDataDecoder() + ); +} + +export type PauseAsyncInput< + TAccountPauser extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pauser: TransactionSigner; + messageTransmitter: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getPauseInstructionAsync< + TAccountPauser extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: PauseAsyncInput< + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + PauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pauser: { value: input.pauser ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pauser), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getPauseInstructionDataEncoder().encode({}), + } as PauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type PauseInput< + TAccountPauser extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pauser: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; +}; + +export function getPauseInstruction< + TAccountPauser extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: PauseInput< + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): PauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pauser: { value: input.pauser ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pauser), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getPauseInstructionDataEncoder().encode({}), + } as PauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedPauseInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + pauser: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: PauseInstructionData; +}; + +export function parsePauseInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedPauseInstruction { + if (instruction.accounts.length < 4) { + // 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: { + pauser: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getPauseInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/receiveMessage.ts b/src/svm/clients/MessageTransmitterV2/instructions/receiveMessage.ts new file mode 100644 index 000000000..b471b4cf0 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/receiveMessage.ts @@ -0,0 +1,486 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const RECEIVE_MESSAGE_DISCRIMINATOR = new Uint8Array([ + 38, 144, 127, 225, 31, 225, 238, 25, +]); + +export function getReceiveMessageDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + RECEIVE_MESSAGE_DISCRIMINATOR + ); +} + +export type ReceiveMessageInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountCaller extends string | AccountMeta = string, + TAccountAuthorityPda extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountUsedNonce extends string | AccountMeta = string, + TAccountReceiver extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountCaller extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountCaller, + TAccountAuthorityPda extends string + ? ReadonlyAccount + : TAccountAuthorityPda, + TAccountMessageTransmitter extends string + ? ReadonlyAccount + : TAccountMessageTransmitter, + TAccountUsedNonce extends string + ? WritableAccount + : TAccountUsedNonce, + TAccountReceiver extends string + ? ReadonlyAccount + : TAccountReceiver, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type ReceiveMessageInstructionData = { + discriminator: ReadonlyUint8Array; + message: ReadonlyUint8Array; + attestation: ReadonlyUint8Array; +}; + +export type ReceiveMessageInstructionDataArgs = { + message: ReadonlyUint8Array; + attestation: ReadonlyUint8Array; +}; + +export function getReceiveMessageInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ['attestation', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ ...value, discriminator: RECEIVE_MESSAGE_DISCRIMINATOR }) + ); +} + +export function getReceiveMessageInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ['attestation', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getReceiveMessageInstructionDataCodec(): Codec< + ReceiveMessageInstructionDataArgs, + ReceiveMessageInstructionData +> { + return combineCodec( + getReceiveMessageInstructionDataEncoder(), + getReceiveMessageInstructionDataDecoder() + ); +} + +export type ReceiveMessageAsyncInput< + TAccountPayer extends string = string, + TAccountCaller extends string = string, + TAccountAuthorityPda extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountUsedNonce extends string = string, + TAccountReceiver extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + caller: TransactionSigner; + authorityPda?: Address; + messageTransmitter: Address; + /** Each nonce is stored in a separate PDA */ + usedNonce: Address; + receiver: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + message: ReceiveMessageInstructionDataArgs['message']; + attestation: ReceiveMessageInstructionDataArgs['attestation']; +}; + +export async function getReceiveMessageInstructionAsync< + TAccountPayer extends string, + TAccountCaller extends string, + TAccountAuthorityPda extends string, + TAccountMessageTransmitter extends string, + TAccountUsedNonce extends string, + TAccountReceiver extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: ReceiveMessageAsyncInput< + TAccountPayer, + TAccountCaller, + TAccountAuthorityPda, + TAccountMessageTransmitter, + TAccountUsedNonce, + TAccountReceiver, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + ReceiveMessageInstruction< + TProgramAddress, + TAccountPayer, + TAccountCaller, + TAccountAuthorityPda, + TAccountMessageTransmitter, + TAccountUsedNonce, + TAccountReceiver, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + caller: { value: input.caller ?? null, isWritable: false }, + authorityPda: { value: input.authorityPda ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: false, + }, + usedNonce: { value: input.usedNonce ?? null, isWritable: true }, + receiver: { value: input.receiver ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.authorityPda.value) { + accounts.authorityPda.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 109, 101, 115, 115, 97, 103, 101, 95, 116, 114, 97, 110, 115, 109, + 105, 116, 116, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, 116, + 121, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.receiver.value)), + ], + }); + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.caller), + getAccountMeta(accounts.authorityPda), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.usedNonce), + getAccountMeta(accounts.receiver), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getReceiveMessageInstructionDataEncoder().encode( + args as ReceiveMessageInstructionDataArgs + ), + } as ReceiveMessageInstruction< + TProgramAddress, + TAccountPayer, + TAccountCaller, + TAccountAuthorityPda, + TAccountMessageTransmitter, + TAccountUsedNonce, + TAccountReceiver, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ReceiveMessageInput< + TAccountPayer extends string = string, + TAccountCaller extends string = string, + TAccountAuthorityPda extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountUsedNonce extends string = string, + TAccountReceiver extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + caller: TransactionSigner; + authorityPda: Address; + messageTransmitter: Address; + /** Each nonce is stored in a separate PDA */ + usedNonce: Address; + receiver: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + message: ReceiveMessageInstructionDataArgs['message']; + attestation: ReceiveMessageInstructionDataArgs['attestation']; +}; + +export function getReceiveMessageInstruction< + TAccountPayer extends string, + TAccountCaller extends string, + TAccountAuthorityPda extends string, + TAccountMessageTransmitter extends string, + TAccountUsedNonce extends string, + TAccountReceiver extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: ReceiveMessageInput< + TAccountPayer, + TAccountCaller, + TAccountAuthorityPda, + TAccountMessageTransmitter, + TAccountUsedNonce, + TAccountReceiver, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): ReceiveMessageInstruction< + TProgramAddress, + TAccountPayer, + TAccountCaller, + TAccountAuthorityPda, + TAccountMessageTransmitter, + TAccountUsedNonce, + TAccountReceiver, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + caller: { value: input.caller ?? null, isWritable: false }, + authorityPda: { value: input.authorityPda ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: false, + }, + usedNonce: { value: input.usedNonce ?? null, isWritable: true }, + receiver: { value: input.receiver ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.caller), + getAccountMeta(accounts.authorityPda), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.usedNonce), + getAccountMeta(accounts.receiver), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getReceiveMessageInstructionDataEncoder().encode( + args as ReceiveMessageInstructionDataArgs + ), + } as ReceiveMessageInstruction< + TProgramAddress, + TAccountPayer, + TAccountCaller, + TAccountAuthorityPda, + TAccountMessageTransmitter, + TAccountUsedNonce, + TAccountReceiver, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedReceiveMessageInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + caller: TAccountMetas[1]; + authorityPda: TAccountMetas[2]; + messageTransmitter: TAccountMetas[3]; + /** Each nonce is stored in a separate PDA */ + usedNonce: TAccountMetas[4]; + receiver: TAccountMetas[5]; + systemProgram: TAccountMetas[6]; + eventAuthority: TAccountMetas[7]; + program: TAccountMetas[8]; + }; + data: ReceiveMessageInstructionData; +}; + +export function parseReceiveMessageInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedReceiveMessageInstruction { + if (instruction.accounts.length < 9) { + // 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: { + payer: getNextAccount(), + caller: getNextAccount(), + authorityPda: getNextAccount(), + messageTransmitter: getNextAccount(), + usedNonce: getNextAccount(), + receiver: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getReceiveMessageInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/reclaimEventAccount.ts b/src/svm/clients/MessageTransmitterV2/instructions/reclaimEventAccount.ts new file mode 100644 index 000000000..72ecffb6b --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/reclaimEventAccount.ts @@ -0,0 +1,242 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR = new Uint8Array([ + 94, 198, 180, 159, 131, 236, 15, 174, +]); + +export function getReclaimEventAccountDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR + ); +} + +export type ReclaimEventAccountInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountPayee extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayee extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayee, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountMessageSentEventData extends string + ? WritableAccount + : TAccountMessageSentEventData, + ...TRemainingAccounts, + ] + >; + +export type ReclaimEventAccountInstructionData = { + discriminator: ReadonlyUint8Array; + attestation: ReadonlyUint8Array; + destinationMessage: ReadonlyUint8Array; +}; + +export type ReclaimEventAccountInstructionDataArgs = { + attestation: ReadonlyUint8Array; + destinationMessage: ReadonlyUint8Array; +}; + +export function getReclaimEventAccountInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['attestation', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + [ + 'destinationMessage', + addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), + ], + ]), + (value) => ({ + ...value, + discriminator: RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR, + }) + ); +} + +export function getReclaimEventAccountInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['attestation', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + [ + 'destinationMessage', + addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()), + ], + ]); +} + +export function getReclaimEventAccountInstructionDataCodec(): Codec< + ReclaimEventAccountInstructionDataArgs, + ReclaimEventAccountInstructionData +> { + return combineCodec( + getReclaimEventAccountInstructionDataEncoder(), + getReclaimEventAccountInstructionDataDecoder() + ); +} + +export type ReclaimEventAccountInput< + TAccountPayee extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountMessageSentEventData extends string = string, +> = { + /** rent SOL receiver, should match original rent payer */ + payee: TransactionSigner; + messageTransmitter: Address; + messageSentEventData: Address; + attestation: ReclaimEventAccountInstructionDataArgs['attestation']; + destinationMessage: ReclaimEventAccountInstructionDataArgs['destinationMessage']; +}; + +export function getReclaimEventAccountInstruction< + TAccountPayee extends string, + TAccountMessageTransmitter extends string, + TAccountMessageSentEventData extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: ReclaimEventAccountInput< + TAccountPayee, + TAccountMessageTransmitter, + TAccountMessageSentEventData + >, + config?: { programAddress?: TProgramAddress } +): ReclaimEventAccountInstruction< + TProgramAddress, + TAccountPayee, + TAccountMessageTransmitter, + TAccountMessageSentEventData +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.messageSentEventData), + ], + programAddress, + data: getReclaimEventAccountInstructionDataEncoder().encode( + args as ReclaimEventAccountInstructionDataArgs + ), + } as ReclaimEventAccountInstruction< + TProgramAddress, + TAccountPayee, + TAccountMessageTransmitter, + TAccountMessageSentEventData + >; + + return instruction; +} + +export type ParsedReclaimEventAccountInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + /** rent SOL receiver, should match original rent payer */ + payee: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + messageSentEventData: TAccountMetas[2]; + }; + data: ReclaimEventAccountInstructionData; +}; + +export function parseReclaimEventAccountInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedReclaimEventAccountInstruction { + 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: { + payee: getNextAccount(), + messageTransmitter: getNextAccount(), + messageSentEventData: getNextAccount(), + }, + data: getReclaimEventAccountInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/sendMessage.ts b/src/svm/clients/MessageTransmitterV2/instructions/sendMessage.ts new file mode 100644 index 000000000..c33eb00f1 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/sendMessage.ts @@ -0,0 +1,302 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SEND_MESSAGE_DISCRIMINATOR = new Uint8Array([ + 57, 40, 34, 178, 189, 10, 65, 26, +]); + +export function getSendMessageDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SEND_MESSAGE_DISCRIMINATOR + ); +} + +export type SendMessageInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountEventRentPayer extends string | AccountMeta = string, + TAccountSenderAuthorityPda extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TAccountSenderProgram extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountEventRentPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountEventRentPayer, + TAccountSenderAuthorityPda extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSenderAuthorityPda, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountMessageSentEventData extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountMessageSentEventData, + TAccountSenderProgram extends string + ? ReadonlyAccount + : TAccountSenderProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type SendMessageInstructionData = { + discriminator: ReadonlyUint8Array; + destinationDomain: number; + recipient: Address; + destinationCaller: Address; + minFinalityThreshold: number; + messageBody: ReadonlyUint8Array; +}; + +export type SendMessageInstructionDataArgs = { + destinationDomain: number; + recipient: Address; + destinationCaller: Address; + minFinalityThreshold: number; + messageBody: ReadonlyUint8Array; +}; + +export function getSendMessageInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['destinationDomain', getU32Encoder()], + ['recipient', getAddressEncoder()], + ['destinationCaller', getAddressEncoder()], + ['minFinalityThreshold', getU32Encoder()], + ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ ...value, discriminator: SEND_MESSAGE_DISCRIMINATOR }) + ); +} + +export function getSendMessageInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['destinationDomain', getU32Decoder()], + ['recipient', getAddressDecoder()], + ['destinationCaller', getAddressDecoder()], + ['minFinalityThreshold', getU32Decoder()], + ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getSendMessageInstructionDataCodec(): Codec< + SendMessageInstructionDataArgs, + SendMessageInstructionData +> { + return combineCodec( + getSendMessageInstructionDataEncoder(), + getSendMessageInstructionDataDecoder() + ); +} + +export type SendMessageInput< + TAccountEventRentPayer extends string = string, + TAccountSenderAuthorityPda extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountSenderProgram extends string = string, + TAccountSystemProgram extends string = string, +> = { + eventRentPayer: TransactionSigner; + senderAuthorityPda: TransactionSigner; + messageTransmitter: Address; + messageSentEventData: TransactionSigner; + senderProgram: Address; + systemProgram?: Address; + destinationDomain: SendMessageInstructionDataArgs['destinationDomain']; + recipient: SendMessageInstructionDataArgs['recipient']; + destinationCaller: SendMessageInstructionDataArgs['destinationCaller']; + minFinalityThreshold: SendMessageInstructionDataArgs['minFinalityThreshold']; + messageBody: SendMessageInstructionDataArgs['messageBody']; +}; + +export function getSendMessageInstruction< + TAccountEventRentPayer extends string, + TAccountSenderAuthorityPda extends string, + TAccountMessageTransmitter extends string, + TAccountMessageSentEventData extends string, + TAccountSenderProgram extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: SendMessageInput< + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountSenderProgram, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): SendMessageInstruction< + TProgramAddress, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountSenderProgram, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, + senderAuthorityPda: { + value: input.senderAuthorityPda ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + senderProgram: { value: input.senderProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.eventRentPayer), + getAccountMeta(accounts.senderAuthorityPda), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.senderProgram), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getSendMessageInstructionDataEncoder().encode( + args as SendMessageInstructionDataArgs + ), + } as SendMessageInstruction< + TProgramAddress, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountSenderProgram, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedSendMessageInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + eventRentPayer: TAccountMetas[0]; + senderAuthorityPda: TAccountMetas[1]; + messageTransmitter: TAccountMetas[2]; + messageSentEventData: TAccountMetas[3]; + senderProgram: TAccountMetas[4]; + systemProgram: TAccountMetas[5]; + }; + data: SendMessageInstructionData; +}; + +export function parseSendMessageInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSendMessageInstruction { + if (instruction.accounts.length < 6) { + // 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: { + eventRentPayer: getNextAccount(), + senderAuthorityPda: getNextAccount(), + messageTransmitter: getNextAccount(), + messageSentEventData: getNextAccount(), + senderProgram: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getSendMessageInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/setMaxMessageBodySize.ts b/src/svm/clients/MessageTransmitterV2/instructions/setMaxMessageBodySize.ts new file mode 100644 index 000000000..f65656b00 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/setMaxMessageBodySize.ts @@ -0,0 +1,337 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_MAX_MESSAGE_BODY_SIZE_DISCRIMINATOR = new Uint8Array([ + 168, 178, 8, 117, 217, 167, 219, 31, +]); + +export function getSetMaxMessageBodySizeDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_MAX_MESSAGE_BODY_SIZE_DISCRIMINATOR + ); +} + +export type SetMaxMessageBodySizeInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type SetMaxMessageBodySizeInstructionData = { + discriminator: ReadonlyUint8Array; + newMaxMessageBodySize: bigint; +}; + +export type SetMaxMessageBodySizeInstructionDataArgs = { + newMaxMessageBodySize: number | bigint; +}; + +export function getSetMaxMessageBodySizeInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newMaxMessageBodySize', getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: SET_MAX_MESSAGE_BODY_SIZE_DISCRIMINATOR, + }) + ); +} + +export function getSetMaxMessageBodySizeInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newMaxMessageBodySize', getU64Decoder()], + ]); +} + +export function getSetMaxMessageBodySizeInstructionDataCodec(): Codec< + SetMaxMessageBodySizeInstructionDataArgs, + SetMaxMessageBodySizeInstructionData +> { + return combineCodec( + getSetMaxMessageBodySizeInstructionDataEncoder(), + getSetMaxMessageBodySizeInstructionDataDecoder() + ); +} + +export type SetMaxMessageBodySizeAsyncInput< + TAccountOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + messageTransmitter: Address; + eventAuthority?: Address; + program: Address; + newMaxMessageBodySize: SetMaxMessageBodySizeInstructionDataArgs['newMaxMessageBodySize']; +}; + +export async function getSetMaxMessageBodySizeInstructionAsync< + TAccountOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: SetMaxMessageBodySizeAsyncInput< + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + SetMaxMessageBodySizeInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetMaxMessageBodySizeInstructionDataEncoder().encode( + args as SetMaxMessageBodySizeInstructionDataArgs + ), + } as SetMaxMessageBodySizeInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type SetMaxMessageBodySizeInput< + TAccountOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; + newMaxMessageBodySize: SetMaxMessageBodySizeInstructionDataArgs['newMaxMessageBodySize']; +}; + +export function getSetMaxMessageBodySizeInstruction< + TAccountOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: SetMaxMessageBodySizeInput< + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): SetMaxMessageBodySizeInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetMaxMessageBodySizeInstructionDataEncoder().encode( + args as SetMaxMessageBodySizeInstructionDataArgs + ), + } as SetMaxMessageBodySizeInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedSetMaxMessageBodySizeInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: SetMaxMessageBodySizeInstructionData; +}; + +export function parseSetMaxMessageBodySizeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetMaxMessageBodySizeInstruction { + if (instruction.accounts.length < 4) { + // 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: { + owner: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getSetMaxMessageBodySizeInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/setSignatureThreshold.ts b/src/svm/clients/MessageTransmitterV2/instructions/setSignatureThreshold.ts new file mode 100644 index 000000000..3bee2ee85 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/setSignatureThreshold.ts @@ -0,0 +1,343 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_SIGNATURE_THRESHOLD_DISCRIMINATOR = new Uint8Array([ + 163, 19, 154, 168, 82, 209, 214, 219, +]); + +export function getSetSignatureThresholdDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_SIGNATURE_THRESHOLD_DISCRIMINATOR + ); +} + +export type SetSignatureThresholdInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountAttesterManager extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountAttesterManager extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAttesterManager, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type SetSignatureThresholdInstructionData = { + discriminator: ReadonlyUint8Array; + newSignatureThreshold: number; +}; + +export type SetSignatureThresholdInstructionDataArgs = { + newSignatureThreshold: number; +}; + +export function getSetSignatureThresholdInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newSignatureThreshold', getU32Encoder()], + ]), + (value) => ({ + ...value, + discriminator: SET_SIGNATURE_THRESHOLD_DISCRIMINATOR, + }) + ); +} + +export function getSetSignatureThresholdInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newSignatureThreshold', getU32Decoder()], + ]); +} + +export function getSetSignatureThresholdInstructionDataCodec(): Codec< + SetSignatureThresholdInstructionDataArgs, + SetSignatureThresholdInstructionData +> { + return combineCodec( + getSetSignatureThresholdInstructionDataEncoder(), + getSetSignatureThresholdInstructionDataDecoder() + ); +} + +export type SetSignatureThresholdAsyncInput< + TAccountAttesterManager extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + attesterManager: TransactionSigner; + messageTransmitter: Address; + eventAuthority?: Address; + program: Address; + newSignatureThreshold: SetSignatureThresholdInstructionDataArgs['newSignatureThreshold']; +}; + +export async function getSetSignatureThresholdInstructionAsync< + TAccountAttesterManager extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: SetSignatureThresholdAsyncInput< + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + SetSignatureThresholdInstruction< + TProgramAddress, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + attesterManager: { + value: input.attesterManager ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.attesterManager), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetSignatureThresholdInstructionDataEncoder().encode( + args as SetSignatureThresholdInstructionDataArgs + ), + } as SetSignatureThresholdInstruction< + TProgramAddress, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type SetSignatureThresholdInput< + TAccountAttesterManager extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + attesterManager: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; + newSignatureThreshold: SetSignatureThresholdInstructionDataArgs['newSignatureThreshold']; +}; + +export function getSetSignatureThresholdInstruction< + TAccountAttesterManager extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: SetSignatureThresholdInput< + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): SetSignatureThresholdInstruction< + TProgramAddress, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + attesterManager: { + value: input.attesterManager ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.attesterManager), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetSignatureThresholdInstructionDataEncoder().encode( + args as SetSignatureThresholdInstructionDataArgs + ), + } as SetSignatureThresholdInstruction< + TProgramAddress, + TAccountAttesterManager, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedSetSignatureThresholdInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + attesterManager: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: SetSignatureThresholdInstructionData; +}; + +export function parseSetSignatureThresholdInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetSignatureThresholdInstruction { + if (instruction.accounts.length < 4) { + // 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: { + attesterManager: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getSetSignatureThresholdInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/transferOwnership.ts b/src/svm/clients/MessageTransmitterV2/instructions/transferOwnership.ts new file mode 100644 index 000000000..7fd509aa4 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/transferOwnership.ts @@ -0,0 +1,330 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const TRANSFER_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ + 65, 177, 215, 73, 53, 45, 99, 47, +]); + +export function getTransferOwnershipDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + TRANSFER_OWNERSHIP_DISCRIMINATOR + ); +} + +export type TransferOwnershipInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type TransferOwnershipInstructionData = { + discriminator: ReadonlyUint8Array; + newOwner: Address; +}; + +export type TransferOwnershipInstructionDataArgs = { newOwner: Address }; + +export function getTransferOwnershipInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newOwner', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: TRANSFER_OWNERSHIP_DISCRIMINATOR }) + ); +} + +export function getTransferOwnershipInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newOwner', getAddressDecoder()], + ]); +} + +export function getTransferOwnershipInstructionDataCodec(): Codec< + TransferOwnershipInstructionDataArgs, + TransferOwnershipInstructionData +> { + return combineCodec( + getTransferOwnershipInstructionDataEncoder(), + getTransferOwnershipInstructionDataDecoder() + ); +} + +export type TransferOwnershipAsyncInput< + TAccountOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + messageTransmitter: Address; + eventAuthority?: Address; + program: Address; + newOwner: TransferOwnershipInstructionDataArgs['newOwner']; +}; + +export async function getTransferOwnershipInstructionAsync< + TAccountOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: TransferOwnershipAsyncInput< + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getTransferOwnershipInstructionDataEncoder().encode( + args as TransferOwnershipInstructionDataArgs + ), + } as TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type TransferOwnershipInput< + TAccountOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; + newOwner: TransferOwnershipInstructionDataArgs['newOwner']; +}; + +export function getTransferOwnershipInstruction< + TAccountOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: TransferOwnershipInput< + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getTransferOwnershipInstructionDataEncoder().encode( + args as TransferOwnershipInstructionDataArgs + ), + } as TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedTransferOwnershipInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: TransferOwnershipInstructionData; +}; + +export function parseTransferOwnershipInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedTransferOwnershipInstruction { + if (instruction.accounts.length < 4) { + // 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: { + owner: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getTransferOwnershipInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/unpause.ts b/src/svm/clients/MessageTransmitterV2/instructions/unpause.ts new file mode 100644 index 000000000..82e09eb08 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/unpause.ts @@ -0,0 +1,307 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UNPAUSE_DISCRIMINATOR = new Uint8Array([ + 169, 144, 4, 38, 10, 141, 188, 255, +]); + +export function getUnpauseDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(UNPAUSE_DISCRIMINATOR); +} + +export type UnpauseInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountPauser extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPauser extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountPauser, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UnpauseInstructionData = { discriminator: ReadonlyUint8Array }; + +export type UnpauseInstructionDataArgs = {}; + +export function getUnpauseInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: UNPAUSE_DISCRIMINATOR }) + ); +} + +export function getUnpauseInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getUnpauseInstructionDataCodec(): Codec< + UnpauseInstructionDataArgs, + UnpauseInstructionData +> { + return combineCodec( + getUnpauseInstructionDataEncoder(), + getUnpauseInstructionDataDecoder() + ); +} + +export type UnpauseAsyncInput< + TAccountPauser extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pauser: TransactionSigner; + messageTransmitter: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getUnpauseInstructionAsync< + TAccountPauser extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: UnpauseAsyncInput< + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + UnpauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pauser: { value: input.pauser ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pauser), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUnpauseInstructionDataEncoder().encode({}), + } as UnpauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type UnpauseInput< + TAccountPauser extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pauser: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; +}; + +export function getUnpauseInstruction< + TAccountPauser extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: UnpauseInput< + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UnpauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pauser: { value: input.pauser ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pauser), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUnpauseInstructionDataEncoder().encode({}), + } as UnpauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUnpauseInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + pauser: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: UnpauseInstructionData; +}; + +export function parseUnpauseInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUnpauseInstruction { + if (instruction.accounts.length < 4) { + // 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: { + pauser: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUnpauseInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/updateAttesterManager.ts b/src/svm/clients/MessageTransmitterV2/instructions/updateAttesterManager.ts new file mode 100644 index 000000000..740fe3c72 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/updateAttesterManager.ts @@ -0,0 +1,337 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UPDATE_ATTESTER_MANAGER_DISCRIMINATOR = new Uint8Array([ + 175, 245, 178, 104, 85, 179, 71, 16, +]); + +export function getUpdateAttesterManagerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_ATTESTER_MANAGER_DISCRIMINATOR + ); +} + +export type UpdateAttesterManagerInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UpdateAttesterManagerInstructionData = { + discriminator: ReadonlyUint8Array; + newAttesterManager: Address; +}; + +export type UpdateAttesterManagerInstructionDataArgs = { + newAttesterManager: Address; +}; + +export function getUpdateAttesterManagerInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newAttesterManager', getAddressEncoder()], + ]), + (value) => ({ + ...value, + discriminator: UPDATE_ATTESTER_MANAGER_DISCRIMINATOR, + }) + ); +} + +export function getUpdateAttesterManagerInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newAttesterManager', getAddressDecoder()], + ]); +} + +export function getUpdateAttesterManagerInstructionDataCodec(): Codec< + UpdateAttesterManagerInstructionDataArgs, + UpdateAttesterManagerInstructionData +> { + return combineCodec( + getUpdateAttesterManagerInstructionDataEncoder(), + getUpdateAttesterManagerInstructionDataDecoder() + ); +} + +export type UpdateAttesterManagerAsyncInput< + TAccountOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + messageTransmitter: Address; + eventAuthority?: Address; + program: Address; + newAttesterManager: UpdateAttesterManagerInstructionDataArgs['newAttesterManager']; +}; + +export async function getUpdateAttesterManagerInstructionAsync< + TAccountOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: UpdateAttesterManagerAsyncInput< + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + UpdateAttesterManagerInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUpdateAttesterManagerInstructionDataEncoder().encode( + args as UpdateAttesterManagerInstructionDataArgs + ), + } as UpdateAttesterManagerInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type UpdateAttesterManagerInput< + TAccountOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; + newAttesterManager: UpdateAttesterManagerInstructionDataArgs['newAttesterManager']; +}; + +export function getUpdateAttesterManagerInstruction< + TAccountOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: UpdateAttesterManagerInput< + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UpdateAttesterManagerInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUpdateAttesterManagerInstructionDataEncoder().encode( + args as UpdateAttesterManagerInstructionDataArgs + ), + } as UpdateAttesterManagerInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUpdateAttesterManagerInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: UpdateAttesterManagerInstructionData; +}; + +export function parseUpdateAttesterManagerInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUpdateAttesterManagerInstruction { + if (instruction.accounts.length < 4) { + // 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: { + owner: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUpdateAttesterManagerInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/updatePauser.ts b/src/svm/clients/MessageTransmitterV2/instructions/updatePauser.ts new file mode 100644 index 000000000..dd37d75e7 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/instructions/updatePauser.ts @@ -0,0 +1,330 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UPDATE_PAUSER_DISCRIMINATOR = new Uint8Array([ + 140, 171, 211, 132, 57, 201, 16, 254, +]); + +export function getUpdatePauserDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_PAUSER_DISCRIMINATOR + ); +} + +export type UpdatePauserInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UpdatePauserInstructionData = { + discriminator: ReadonlyUint8Array; + newPauser: Address; +}; + +export type UpdatePauserInstructionDataArgs = { newPauser: Address }; + +export function getUpdatePauserInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newPauser', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: UPDATE_PAUSER_DISCRIMINATOR }) + ); +} + +export function getUpdatePauserInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newPauser', getAddressDecoder()], + ]); +} + +export function getUpdatePauserInstructionDataCodec(): Codec< + UpdatePauserInstructionDataArgs, + UpdatePauserInstructionData +> { + return combineCodec( + getUpdatePauserInstructionDataEncoder(), + getUpdatePauserInstructionDataDecoder() + ); +} + +export type UpdatePauserAsyncInput< + TAccountOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + messageTransmitter: Address; + eventAuthority?: Address; + program: Address; + newPauser: UpdatePauserInstructionDataArgs['newPauser']; +}; + +export async function getUpdatePauserInstructionAsync< + TAccountOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: UpdatePauserAsyncInput< + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + UpdatePauserInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUpdatePauserInstructionDataEncoder().encode( + args as UpdatePauserInstructionDataArgs + ), + } as UpdatePauserInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type UpdatePauserInput< + TAccountOwner extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + messageTransmitter: Address; + eventAuthority: Address; + program: Address; + newPauser: UpdatePauserInstructionDataArgs['newPauser']; +}; + +export function getUpdatePauserInstruction< + TAccountOwner extends string, + TAccountMessageTransmitter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, +>( + input: UpdatePauserInput< + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UpdatePauserInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUpdatePauserInstructionDataEncoder().encode( + args as UpdatePauserInstructionDataArgs + ), + } as UpdatePauserInstruction< + TProgramAddress, + TAccountOwner, + TAccountMessageTransmitter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUpdatePauserInstruction< + TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: UpdatePauserInstructionData; +}; + +export function parseUpdatePauserInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUpdatePauserInstruction { + if (instruction.accounts.length < 4) { + // 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: { + owner: getNextAccount(), + messageTransmitter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUpdatePauserInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/MessageTransmitterV2/programs/index.ts b/src/svm/clients/MessageTransmitterV2/programs/index.ts new file mode 100644 index 000000000..eecc709dc --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/programs/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 './messageTransmitterV2'; diff --git a/src/svm/clients/MessageTransmitterV2/programs/messageTransmitterV2.ts b/src/svm/clients/MessageTransmitterV2/programs/messageTransmitterV2.ts new file mode 100644 index 000000000..23ce64aed --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/programs/messageTransmitterV2.ts @@ -0,0 +1,324 @@ +/** + * 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/kit'; +import { + type ParsedAcceptOwnershipInstruction, + type ParsedDisableAttesterInstruction, + type ParsedEnableAttesterInstruction, + type ParsedInitializeInstruction, + type ParsedIsNonceUsedInstruction, + type ParsedPauseInstruction, + type ParsedReceiveMessageInstruction, + type ParsedReclaimEventAccountInstruction, + type ParsedSendMessageInstruction, + type ParsedSetMaxMessageBodySizeInstruction, + type ParsedSetSignatureThresholdInstruction, + type ParsedTransferOwnershipInstruction, + type ParsedUnpauseInstruction, + type ParsedUpdateAttesterManagerInstruction, + type ParsedUpdatePauserInstruction, +} from '../instructions'; + +export const MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; + +export enum MessageTransmitterV2Account { + MessageSent, + MessageTransmitter, + UsedNonce, +} + +export function identifyMessageTransmitterV2Account( + account: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): MessageTransmitterV2Account { + const data = 'data' in account ? account.data : account; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([131, 100, 133, 56, 166, 225, 151, 60]) + ), + 0 + ) + ) { + return MessageTransmitterV2Account.MessageSent; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([71, 40, 180, 142, 19, 203, 35, 252]) + ), + 0 + ) + ) { + return MessageTransmitterV2Account.MessageTransmitter; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([212, 222, 157, 252, 130, 71, 179, 238]) + ), + 0 + ) + ) { + return MessageTransmitterV2Account.UsedNonce; + } + throw new Error( + 'The provided account could not be identified as a messageTransmitterV2 account.' + ); +} + +export enum MessageTransmitterV2Instruction { + AcceptOwnership, + DisableAttester, + EnableAttester, + Initialize, + IsNonceUsed, + Pause, + ReceiveMessage, + ReclaimEventAccount, + SendMessage, + SetMaxMessageBodySize, + SetSignatureThreshold, + TransferOwnership, + Unpause, + UpdateAttesterManager, + UpdatePauser, +} + +export function identifyMessageTransmitterV2Instruction( + instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): MessageTransmitterV2Instruction { + const data = 'data' in instruction ? instruction.data : instruction; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([172, 23, 43, 13, 238, 213, 85, 150]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.AcceptOwnership; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([61, 171, 131, 95, 172, 15, 227, 229]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.DisableAttester; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([2, 11, 193, 115, 5, 148, 4, 198]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.EnableAttester; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.Initialize; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([144, 72, 107, 148, 35, 218, 31, 187]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.IsNonceUsed; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([211, 22, 221, 251, 74, 121, 193, 47]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.Pause; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([38, 144, 127, 225, 31, 225, 238, 25]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.ReceiveMessage; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([94, 198, 180, 159, 131, 236, 15, 174]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.ReclaimEventAccount; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([57, 40, 34, 178, 189, 10, 65, 26]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.SendMessage; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([168, 178, 8, 117, 217, 167, 219, 31]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.SetMaxMessageBodySize; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([163, 19, 154, 168, 82, 209, 214, 219]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.SetSignatureThreshold; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.TransferOwnership; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([169, 144, 4, 38, 10, 141, 188, 255]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.Unpause; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([175, 245, 178, 104, 85, 179, 71, 16]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.UpdateAttesterManager; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([140, 171, 211, 132, 57, 201, 16, 254]) + ), + 0 + ) + ) { + return MessageTransmitterV2Instruction.UpdatePauser; + } + throw new Error( + 'The provided instruction could not be identified as a messageTransmitterV2 instruction.' + ); +} + +export type ParsedMessageTransmitterV2Instruction< + TProgram extends string = 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC', +> = + | ({ + instructionType: MessageTransmitterV2Instruction.AcceptOwnership; + } & ParsedAcceptOwnershipInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.DisableAttester; + } & ParsedDisableAttesterInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.EnableAttester; + } & ParsedEnableAttesterInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.Initialize; + } & ParsedInitializeInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.IsNonceUsed; + } & ParsedIsNonceUsedInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.Pause; + } & ParsedPauseInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.ReceiveMessage; + } & ParsedReceiveMessageInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.ReclaimEventAccount; + } & ParsedReclaimEventAccountInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.SendMessage; + } & ParsedSendMessageInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.SetMaxMessageBodySize; + } & ParsedSetMaxMessageBodySizeInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.SetSignatureThreshold; + } & ParsedSetSignatureThresholdInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.TransferOwnership; + } & ParsedTransferOwnershipInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.Unpause; + } & ParsedUnpauseInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.UpdateAttesterManager; + } & ParsedUpdateAttesterManagerInstruction) + | ({ + instructionType: MessageTransmitterV2Instruction.UpdatePauser; + } & ParsedUpdatePauserInstruction); diff --git a/src/svm/clients/MessageTransmitterV2/shared/index.ts b/src/svm/clients/MessageTransmitterV2/shared/index.ts new file mode 100644 index 000000000..7ebc26514 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/shared/index.ts @@ -0,0 +1,164 @@ +/** + * 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 { + AccountRole, + isProgramDerivedAddress, + isTransactionSigner as kitIsTransactionSigner, + type AccountMeta, + type AccountSignerMeta, + type Address, + type ProgramDerivedAddress, + type TransactionSigner, + upgradeRoleToSigner, +} from '@solana/kit'; + +/** + * Asserts that the given value is not null or undefined. + * @internal + */ +export function expectSome(value: T | null | undefined): T { + if (value == null) { + throw new Error('Expected a value but received null or undefined.'); + } + return value; +} + +/** + * Asserts that the given value is a PublicKey. + * @internal + */ +export function expectAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): Address { + if (!value) { + throw new Error('Expected a Address.'); + } + if (typeof value === 'object' && 'address' in value) { + return value.address; + } + if (Array.isArray(value)) { + return value[0]; + } + return value as Address; +} + +/** + * Asserts that the given value is a PDA. + * @internal + */ +export function expectProgramDerivedAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): ProgramDerivedAddress { + if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { + throw new Error('Expected a ProgramDerivedAddress.'); + } + return value; +} + +/** + * Asserts that the given value is a TransactionSigner. + * @internal + */ +export function expectTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): TransactionSigner { + if (!value || !isTransactionSigner(value)) { + throw new Error('Expected a TransactionSigner.'); + } + return value; +} + +/** + * Defines an instruction account to resolve. + * @internal + */ +export type ResolvedAccount< + T extends string = string, + U extends + | Address + | ProgramDerivedAddress + | TransactionSigner + | null = + | Address + | ProgramDerivedAddress + | TransactionSigner + | null, +> = { + isWritable: boolean; + value: U; +}; + +/** + * Defines an instruction that stores additional bytes on-chain. + * @internal + */ +export type InstructionWithByteDelta = { + byteDelta: number; +}; + +/** + * Get account metas and signers from resolved accounts. + * @internal + */ +export function getAccountMetaFactory( + programAddress: Address, + optionalAccountStrategy: 'omitted' | 'programId' +) { + return ( + account: ResolvedAccount + ): AccountMeta | AccountSignerMeta | undefined => { + if (!account.value) { + if (optionalAccountStrategy === 'omitted') return; + return Object.freeze({ + address: programAddress, + role: AccountRole.READONLY, + }); + } + + const writableRole = account.isWritable + ? AccountRole.WRITABLE + : AccountRole.READONLY; + return Object.freeze({ + address: expectAddress(account.value), + role: isTransactionSigner(account.value) + ? upgradeRoleToSigner(writableRole) + : writableRole, + ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), + }); + }; +} + +export function isTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner +): value is TransactionSigner { + return ( + !!value && + typeof value === 'object' && + 'address' in value && + kitIsTransactionSigner(value) + ); +} diff --git a/src/svm/clients/MessageTransmitterV2/types/attesterDisabled.ts b/src/svm/clients/MessageTransmitterV2/types/attesterDisabled.ts new file mode 100644 index 000000000..b643a7a51 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/types/attesterDisabled.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/kit'; + +export type AttesterDisabled = { attester: Address }; + +export type AttesterDisabledArgs = AttesterDisabled; + +export function getAttesterDisabledEncoder(): Encoder { + return getStructEncoder([['attester', getAddressEncoder()]]); +} + +export function getAttesterDisabledDecoder(): Decoder { + return getStructDecoder([['attester', getAddressDecoder()]]); +} + +export function getAttesterDisabledCodec(): Codec< + AttesterDisabledArgs, + AttesterDisabled +> { + return combineCodec( + getAttesterDisabledEncoder(), + getAttesterDisabledDecoder() + ); +} diff --git a/src/svm/clients/MessageTransmitterV2/types/attesterEnabled.ts b/src/svm/clients/MessageTransmitterV2/types/attesterEnabled.ts new file mode 100644 index 000000000..ad2132a58 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/types/attesterEnabled.ts @@ -0,0 +1,38 @@ +/** + * 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/kit'; + +export type AttesterEnabled = { attester: Address }; + +export type AttesterEnabledArgs = AttesterEnabled; + +export function getAttesterEnabledEncoder(): Encoder { + return getStructEncoder([['attester', getAddressEncoder()]]); +} + +export function getAttesterEnabledDecoder(): Decoder { + return getStructDecoder([['attester', getAddressDecoder()]]); +} + +export function getAttesterEnabledCodec(): Codec< + AttesterEnabledArgs, + AttesterEnabled +> { + return combineCodec(getAttesterEnabledEncoder(), getAttesterEnabledDecoder()); +} diff --git a/src/svm/clients/MessageTransmitterV2/types/attesterManagerUpdated.ts b/src/svm/clients/MessageTransmitterV2/types/attesterManagerUpdated.ts new file mode 100644 index 000000000..f75c9f3ec --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/types/attesterManagerUpdated.ts @@ -0,0 +1,50 @@ +/** + * 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/kit'; + +export type AttesterManagerUpdated = { + previousAttesterManager: Address; + newAttesterManager: Address; +}; + +export type AttesterManagerUpdatedArgs = AttesterManagerUpdated; + +export function getAttesterManagerUpdatedEncoder(): Encoder { + return getStructEncoder([ + ['previousAttesterManager', getAddressEncoder()], + ['newAttesterManager', getAddressEncoder()], + ]); +} + +export function getAttesterManagerUpdatedDecoder(): Decoder { + return getStructDecoder([ + ['previousAttesterManager', getAddressDecoder()], + ['newAttesterManager', getAddressDecoder()], + ]); +} + +export function getAttesterManagerUpdatedCodec(): Codec< + AttesterManagerUpdatedArgs, + AttesterManagerUpdated +> { + return combineCodec( + getAttesterManagerUpdatedEncoder(), + getAttesterManagerUpdatedDecoder() + ); +} diff --git a/src/svm/clients/MessageTransmitterV2/types/index.ts b/src/svm/clients/MessageTransmitterV2/types/index.ts new file mode 100644 index 000000000..df8590dc1 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/types/index.ts @@ -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. + * + * @see https://github.com/codama-idl/codama + */ + +export * from './attesterDisabled'; +export * from './attesterEnabled'; +export * from './attesterManagerUpdated'; +export * from './maxMessageBodySizeUpdated'; +export * from './messageReceived'; +export * from './ownershipTransferred'; +export * from './ownershipTransferStarted'; +export * from './pause'; +export * from './pauserChanged'; +export * from './signatureThresholdUpdated'; +export * from './unpause'; diff --git a/src/svm/clients/MessageTransmitterV2/types/maxMessageBodySizeUpdated.ts b/src/svm/clients/MessageTransmitterV2/types/maxMessageBodySizeUpdated.ts new file mode 100644 index 000000000..8a0231c61 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/types/maxMessageBodySizeUpdated.ts @@ -0,0 +1,42 @@ +/** + * 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/kit'; + +export type MaxMessageBodySizeUpdated = { newMaxMessageBodySize: bigint }; + +export type MaxMessageBodySizeUpdatedArgs = { + newMaxMessageBodySize: number | bigint; +}; + +export function getMaxMessageBodySizeUpdatedEncoder(): Encoder { + return getStructEncoder([['newMaxMessageBodySize', getU64Encoder()]]); +} + +export function getMaxMessageBodySizeUpdatedDecoder(): Decoder { + return getStructDecoder([['newMaxMessageBodySize', getU64Decoder()]]); +} + +export function getMaxMessageBodySizeUpdatedCodec(): Codec< + MaxMessageBodySizeUpdatedArgs, + MaxMessageBodySizeUpdated +> { + return combineCodec( + getMaxMessageBodySizeUpdatedEncoder(), + getMaxMessageBodySizeUpdatedDecoder() + ); +} diff --git a/src/svm/clients/MessageTransmitterV2/types/messageReceived.ts b/src/svm/clients/MessageTransmitterV2/types/messageReceived.ts new file mode 100644 index 000000000..f79286e6d --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/types/messageReceived.ts @@ -0,0 +1,68 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export type MessageReceived = { + caller: Address; + sourceDomain: number; + nonce: ReadonlyUint8Array; + sender: Address; + finalityThresholdExecuted: number; + messageBody: ReadonlyUint8Array; +}; + +export type MessageReceivedArgs = MessageReceived; + +export function getMessageReceivedEncoder(): Encoder { + return getStructEncoder([ + ['caller', getAddressEncoder()], + ['sourceDomain', getU32Encoder()], + ['nonce', fixEncoderSize(getBytesEncoder(), 32)], + ['sender', getAddressEncoder()], + ['finalityThresholdExecuted', getU32Encoder()], + ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]); +} + +export function getMessageReceivedDecoder(): Decoder { + return getStructDecoder([ + ['caller', getAddressDecoder()], + ['sourceDomain', getU32Decoder()], + ['nonce', fixDecoderSize(getBytesDecoder(), 32)], + ['sender', getAddressDecoder()], + ['finalityThresholdExecuted', getU32Decoder()], + ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getMessageReceivedCodec(): Codec< + MessageReceivedArgs, + MessageReceived +> { + return combineCodec(getMessageReceivedEncoder(), getMessageReceivedDecoder()); +} diff --git a/src/svm/clients/MessageTransmitterV2/types/ownershipTransferStarted.ts b/src/svm/clients/MessageTransmitterV2/types/ownershipTransferStarted.ts new file mode 100644 index 000000000..e170a569a --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/types/ownershipTransferStarted.ts @@ -0,0 +1,50 @@ +/** + * 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/kit'; + +export type OwnershipTransferStarted = { + previousOwner: Address; + newOwner: Address; +}; + +export type OwnershipTransferStartedArgs = OwnershipTransferStarted; + +export function getOwnershipTransferStartedEncoder(): Encoder { + return getStructEncoder([ + ['previousOwner', getAddressEncoder()], + ['newOwner', getAddressEncoder()], + ]); +} + +export function getOwnershipTransferStartedDecoder(): Decoder { + return getStructDecoder([ + ['previousOwner', getAddressDecoder()], + ['newOwner', getAddressDecoder()], + ]); +} + +export function getOwnershipTransferStartedCodec(): Codec< + OwnershipTransferStartedArgs, + OwnershipTransferStarted +> { + return combineCodec( + getOwnershipTransferStartedEncoder(), + getOwnershipTransferStartedDecoder() + ); +} diff --git a/src/svm/clients/MessageTransmitterV2/types/ownershipTransferred.ts b/src/svm/clients/MessageTransmitterV2/types/ownershipTransferred.ts new file mode 100644 index 000000000..40f21c661 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/types/ownershipTransferred.ts @@ -0,0 +1,50 @@ +/** + * 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/kit'; + +export type OwnershipTransferred = { + previousOwner: Address; + newOwner: Address; +}; + +export type OwnershipTransferredArgs = OwnershipTransferred; + +export function getOwnershipTransferredEncoder(): Encoder { + return getStructEncoder([ + ['previousOwner', getAddressEncoder()], + ['newOwner', getAddressEncoder()], + ]); +} + +export function getOwnershipTransferredDecoder(): Decoder { + return getStructDecoder([ + ['previousOwner', getAddressDecoder()], + ['newOwner', getAddressDecoder()], + ]); +} + +export function getOwnershipTransferredCodec(): Codec< + OwnershipTransferredArgs, + OwnershipTransferred +> { + return combineCodec( + getOwnershipTransferredEncoder(), + getOwnershipTransferredDecoder() + ); +} diff --git a/src/svm/clients/MessageTransmitterV2/types/pause.ts b/src/svm/clients/MessageTransmitterV2/types/pause.ts new file mode 100644 index 000000000..f1f423325 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/types/pause.ts @@ -0,0 +1,32 @@ +/** + * 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, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type Pause = {}; + +export type PauseArgs = Pause; + +export function getPauseEncoder(): Encoder { + return getStructEncoder([]); +} + +export function getPauseDecoder(): Decoder { + return getStructDecoder([]); +} + +export function getPauseCodec(): Codec { + return combineCodec(getPauseEncoder(), getPauseDecoder()); +} diff --git a/src/svm/clients/MessageTransmitterV2/types/pauserChanged.ts b/src/svm/clients/MessageTransmitterV2/types/pauserChanged.ts new file mode 100644 index 000000000..57d7433da --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/types/pauserChanged.ts @@ -0,0 +1,38 @@ +/** + * 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/kit'; + +export type PauserChanged = { newAddress: Address }; + +export type PauserChangedArgs = PauserChanged; + +export function getPauserChangedEncoder(): Encoder { + return getStructEncoder([['newAddress', getAddressEncoder()]]); +} + +export function getPauserChangedDecoder(): Decoder { + return getStructDecoder([['newAddress', getAddressDecoder()]]); +} + +export function getPauserChangedCodec(): Codec< + PauserChangedArgs, + PauserChanged +> { + return combineCodec(getPauserChangedEncoder(), getPauserChangedDecoder()); +} diff --git a/src/svm/clients/MessageTransmitterV2/types/signatureThresholdUpdated.ts b/src/svm/clients/MessageTransmitterV2/types/signatureThresholdUpdated.ts new file mode 100644 index 000000000..e8a729867 --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/types/signatureThresholdUpdated.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, + getU32Decoder, + getU32Encoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type SignatureThresholdUpdated = { + oldSignatureThreshold: number; + newSignatureThreshold: number; +}; + +export type SignatureThresholdUpdatedArgs = SignatureThresholdUpdated; + +export function getSignatureThresholdUpdatedEncoder(): Encoder { + return getStructEncoder([ + ['oldSignatureThreshold', getU32Encoder()], + ['newSignatureThreshold', getU32Encoder()], + ]); +} + +export function getSignatureThresholdUpdatedDecoder(): Decoder { + return getStructDecoder([ + ['oldSignatureThreshold', getU32Decoder()], + ['newSignatureThreshold', getU32Decoder()], + ]); +} + +export function getSignatureThresholdUpdatedCodec(): Codec< + SignatureThresholdUpdatedArgs, + SignatureThresholdUpdated +> { + return combineCodec( + getSignatureThresholdUpdatedEncoder(), + getSignatureThresholdUpdatedDecoder() + ); +} diff --git a/src/svm/clients/MessageTransmitterV2/types/unpause.ts b/src/svm/clients/MessageTransmitterV2/types/unpause.ts new file mode 100644 index 000000000..4fdc009ef --- /dev/null +++ b/src/svm/clients/MessageTransmitterV2/types/unpause.ts @@ -0,0 +1,32 @@ +/** + * 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, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type Unpause = {}; + +export type UnpauseArgs = Unpause; + +export function getUnpauseEncoder(): Encoder { + return getStructEncoder([]); +} + +export function getUnpauseDecoder(): Decoder { + return getStructDecoder([]); +} + +export function getUnpauseCodec(): Codec { + return combineCodec(getUnpauseEncoder(), getUnpauseDecoder()); +} diff --git a/src/svm/clients/MulticallHandler/index.ts b/src/svm/clients/MulticallHandler/index.ts new file mode 100644 index 000000000..d69c576af --- /dev/null +++ b/src/svm/clients/MulticallHandler/index.ts @@ -0,0 +1,10 @@ +/** + * 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 './instructions'; +export * from './programs'; diff --git a/src/svm/clients/MulticallHandler/instructions/handleV3AcrossMessage.ts b/src/svm/clients/MulticallHandler/instructions/handleV3AcrossMessage.ts new file mode 100644 index 000000000..20d6b2591 --- /dev/null +++ b/src/svm/clients/MulticallHandler/instructions/handleV3AcrossMessage.ts @@ -0,0 +1,133 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { MULTICALL_HANDLER_PROGRAM_ADDRESS } from '../programs'; + +export const HANDLE_V3_ACROSS_MESSAGE_DISCRIMINATOR = new Uint8Array([ + 131, 141, 52, 71, 16, 59, 196, 92, +]); + +export function getHandleV3AcrossMessageDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + HANDLE_V3_ACROSS_MESSAGE_DISCRIMINATOR + ); +} + +export type HandleV3AcrossMessageInstruction< + TProgram extends string = typeof MULTICALL_HANDLER_PROGRAM_ADDRESS, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts; + +export type HandleV3AcrossMessageInstructionData = { + discriminator: ReadonlyUint8Array; + message: ReadonlyUint8Array; +}; + +export type HandleV3AcrossMessageInstructionDataArgs = { + message: ReadonlyUint8Array; +}; + +export function getHandleV3AcrossMessageInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ + ...value, + discriminator: HANDLE_V3_ACROSS_MESSAGE_DISCRIMINATOR, + }) + ); +} + +export function getHandleV3AcrossMessageInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getHandleV3AcrossMessageInstructionDataCodec(): Codec< + HandleV3AcrossMessageInstructionDataArgs, + HandleV3AcrossMessageInstructionData +> { + return combineCodec( + getHandleV3AcrossMessageInstructionDataEncoder(), + getHandleV3AcrossMessageInstructionDataDecoder() + ); +} + +export type HandleV3AcrossMessageInput = { + message: HandleV3AcrossMessageInstructionDataArgs['message']; +}; + +export function getHandleV3AcrossMessageInstruction< + TProgramAddress extends Address = typeof MULTICALL_HANDLER_PROGRAM_ADDRESS, +>( + input: HandleV3AcrossMessageInput, + config?: { programAddress?: TProgramAddress } +): HandleV3AcrossMessageInstruction { + // Program address. + const programAddress = + config?.programAddress ?? MULTICALL_HANDLER_PROGRAM_ADDRESS; + + // Original args. + const args = { ...input }; + + const instruction = { + programAddress, + data: getHandleV3AcrossMessageInstructionDataEncoder().encode( + args as HandleV3AcrossMessageInstructionDataArgs + ), + } as HandleV3AcrossMessageInstruction; + + return instruction; +} + +export type ParsedHandleV3AcrossMessageInstruction< + TProgram extends string = typeof MULTICALL_HANDLER_PROGRAM_ADDRESS, +> = { + programAddress: Address; + data: HandleV3AcrossMessageInstructionData; +}; + +export function parseHandleV3AcrossMessageInstruction( + instruction: Instruction & InstructionWithData +): ParsedHandleV3AcrossMessageInstruction { + return { + programAddress: instruction.programAddress, + data: getHandleV3AcrossMessageInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/MulticallHandler/instructions/index.ts b/src/svm/clients/MulticallHandler/instructions/index.ts new file mode 100644 index 000000000..1dfed40c0 --- /dev/null +++ b/src/svm/clients/MulticallHandler/instructions/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 './handleV3AcrossMessage'; diff --git a/src/svm/clients/MulticallHandler/programs/index.ts b/src/svm/clients/MulticallHandler/programs/index.ts new file mode 100644 index 000000000..e8d227f30 --- /dev/null +++ b/src/svm/clients/MulticallHandler/programs/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 './multicallHandler'; diff --git a/src/svm/clients/MulticallHandler/programs/multicallHandler.ts b/src/svm/clients/MulticallHandler/programs/multicallHandler.ts new file mode 100644 index 000000000..d0f0fc93f --- /dev/null +++ b/src/svm/clients/MulticallHandler/programs/multicallHandler.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 { + containsBytes, + fixEncoderSize, + getBytesEncoder, + type Address, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { type ParsedHandleV3AcrossMessageInstruction } from '../instructions'; + +export const MULTICALL_HANDLER_PROGRAM_ADDRESS = + 'HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be' as Address<'HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be'>; + +export enum MulticallHandlerInstruction { + HandleV3AcrossMessage, +} + +export function identifyMulticallHandlerInstruction( + instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): MulticallHandlerInstruction { + const data = 'data' in instruction ? instruction.data : instruction; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([131, 141, 52, 71, 16, 59, 196, 92]) + ), + 0 + ) + ) { + return MulticallHandlerInstruction.HandleV3AcrossMessage; + } + throw new Error( + 'The provided instruction could not be identified as a multicallHandler instruction.' + ); +} + +export type ParsedMulticallHandlerInstruction< + TProgram extends string = 'HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be', +> = { + instructionType: MulticallHandlerInstruction.HandleV3AcrossMessage; +} & ParsedHandleV3AcrossMessageInstruction; diff --git a/src/svm/clients/MulticallHandler/shared/index.ts b/src/svm/clients/MulticallHandler/shared/index.ts new file mode 100644 index 000000000..7ebc26514 --- /dev/null +++ b/src/svm/clients/MulticallHandler/shared/index.ts @@ -0,0 +1,164 @@ +/** + * 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 { + AccountRole, + isProgramDerivedAddress, + isTransactionSigner as kitIsTransactionSigner, + type AccountMeta, + type AccountSignerMeta, + type Address, + type ProgramDerivedAddress, + type TransactionSigner, + upgradeRoleToSigner, +} from '@solana/kit'; + +/** + * Asserts that the given value is not null or undefined. + * @internal + */ +export function expectSome(value: T | null | undefined): T { + if (value == null) { + throw new Error('Expected a value but received null or undefined.'); + } + return value; +} + +/** + * Asserts that the given value is a PublicKey. + * @internal + */ +export function expectAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): Address { + if (!value) { + throw new Error('Expected a Address.'); + } + if (typeof value === 'object' && 'address' in value) { + return value.address; + } + if (Array.isArray(value)) { + return value[0]; + } + return value as Address; +} + +/** + * Asserts that the given value is a PDA. + * @internal + */ +export function expectProgramDerivedAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): ProgramDerivedAddress { + if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { + throw new Error('Expected a ProgramDerivedAddress.'); + } + return value; +} + +/** + * Asserts that the given value is a TransactionSigner. + * @internal + */ +export function expectTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): TransactionSigner { + if (!value || !isTransactionSigner(value)) { + throw new Error('Expected a TransactionSigner.'); + } + return value; +} + +/** + * Defines an instruction account to resolve. + * @internal + */ +export type ResolvedAccount< + T extends string = string, + U extends + | Address + | ProgramDerivedAddress + | TransactionSigner + | null = + | Address + | ProgramDerivedAddress + | TransactionSigner + | null, +> = { + isWritable: boolean; + value: U; +}; + +/** + * Defines an instruction that stores additional bytes on-chain. + * @internal + */ +export type InstructionWithByteDelta = { + byteDelta: number; +}; + +/** + * Get account metas and signers from resolved accounts. + * @internal + */ +export function getAccountMetaFactory( + programAddress: Address, + optionalAccountStrategy: 'omitted' | 'programId' +) { + return ( + account: ResolvedAccount + ): AccountMeta | AccountSignerMeta | undefined => { + if (!account.value) { + if (optionalAccountStrategy === 'omitted') return; + return Object.freeze({ + address: programAddress, + role: AccountRole.READONLY, + }); + } + + const writableRole = account.isWritable + ? AccountRole.WRITABLE + : AccountRole.READONLY; + return Object.freeze({ + address: expectAddress(account.value), + role: isTransactionSigner(account.value) + ? upgradeRoleToSigner(writableRole) + : writableRole, + ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), + }); + }; +} + +export function isTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner +): value is TransactionSigner { + return ( + !!value && + typeof value === 'object' && + 'address' in value && + kitIsTransactionSigner(value) + ); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/index.ts new file mode 100644 index 000000000..669123917 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/index.ts @@ -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. + * + * @see https://github.com/codama-idl/codama + */ + +export * from './messageSent'; +export * from './minimumDeposit'; +export * from './rentClaim'; +export * from './state'; +export * from './usedNonce'; diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/messageSent.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/messageSent.ts new file mode 100644 index 000000000..e401030f7 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/messageSent.ts @@ -0,0 +1,143 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getI64Decoder, + getI64Encoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const MESSAGE_SENT_DISCRIMINATOR = new Uint8Array([ + 131, 100, 133, 56, 166, 225, 151, 60, +]); + +export function getMessageSentDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + MESSAGE_SENT_DISCRIMINATOR + ); +} + +export type MessageSent = { + discriminator: ReadonlyUint8Array; + rentPayer: Address; + createdAt: bigint; + message: ReadonlyUint8Array; +}; + +export type MessageSentArgs = { + rentPayer: Address; + createdAt: number | bigint; + message: ReadonlyUint8Array; +}; + +export function getMessageSentEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['rentPayer', getAddressEncoder()], + ['createdAt', getI64Encoder()], + ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ ...value, discriminator: MESSAGE_SENT_DISCRIMINATOR }) + ); +} + +export function getMessageSentDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['rentPayer', getAddressDecoder()], + ['createdAt', getI64Decoder()], + ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getMessageSentCodec(): Codec { + return combineCodec(getMessageSentEncoder(), getMessageSentDecoder()); +} + +export function decodeMessageSent( + encodedAccount: EncodedAccount +): Account; +export function decodeMessageSent( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeMessageSent( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getMessageSentDecoder() + ); +} + +export async function fetchMessageSent( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeMessageSent(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeMessageSent( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeMessageSent(maybeAccount); +} + +export async function fetchAllMessageSent( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeMessageSent(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeMessageSent( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeMessageSent(maybeAccount)); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/minimumDeposit.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/minimumDeposit.ts new file mode 100644 index 000000000..69afbefb0 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/minimumDeposit.ts @@ -0,0 +1,147 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const MINIMUM_DEPOSIT_DISCRIMINATOR = new Uint8Array([ + 218, 139, 120, 202, 3, 12, 233, 65, +]); + +export function getMinimumDepositDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + MINIMUM_DEPOSIT_DISCRIMINATOR + ); +} + +export type MinimumDeposit = { + discriminator: ReadonlyUint8Array; + amount: bigint; + bump: number; +}; + +export type MinimumDepositArgs = { amount: number | bigint; bump: number }; + +export function getMinimumDepositEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['amount', getU64Encoder()], + ['bump', getU8Encoder()], + ]), + (value) => ({ ...value, discriminator: MINIMUM_DEPOSIT_DISCRIMINATOR }) + ); +} + +export function getMinimumDepositDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['amount', getU64Decoder()], + ['bump', getU8Decoder()], + ]); +} + +export function getMinimumDepositCodec(): Codec< + MinimumDepositArgs, + MinimumDeposit +> { + return combineCodec(getMinimumDepositEncoder(), getMinimumDepositDecoder()); +} + +export function decodeMinimumDeposit( + encodedAccount: EncodedAccount +): Account; +export function decodeMinimumDeposit( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeMinimumDeposit( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getMinimumDepositDecoder() + ); +} + +export async function fetchMinimumDeposit( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeMinimumDeposit(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeMinimumDeposit< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeMinimumDeposit(maybeAccount); +} + +export async function fetchAllMinimumDeposit( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeMinimumDeposit( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeMinimumDeposit( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeMinimumDeposit(maybeAccount) + ); +} + +export function getMinimumDepositSize(): number { + return 17; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/rentClaim.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/rentClaim.ts new file mode 100644 index 000000000..6631dac9b --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/rentClaim.ts @@ -0,0 +1,126 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const RENT_CLAIM_DISCRIMINATOR = new Uint8Array([ + 13, 5, 183, 82, 60, 122, 72, 11, +]); + +export function getRentClaimDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(RENT_CLAIM_DISCRIMINATOR); +} + +export type RentClaim = { discriminator: ReadonlyUint8Array; amount: bigint }; + +export type RentClaimArgs = { amount: number | bigint }; + +export function getRentClaimEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['amount', getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: RENT_CLAIM_DISCRIMINATOR }) + ); +} + +export function getRentClaimDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['amount', getU64Decoder()], + ]); +} + +export function getRentClaimCodec(): Codec { + return combineCodec(getRentClaimEncoder(), getRentClaimDecoder()); +} + +export function decodeRentClaim( + encodedAccount: EncodedAccount +): Account; +export function decodeRentClaim( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeRentClaim( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getRentClaimDecoder() + ); +} + +export async function fetchRentClaim( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeRentClaim(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeRentClaim( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeRentClaim(maybeAccount); +} + +export async function fetchAllRentClaim( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeRentClaim(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeRentClaim( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeRentClaim(maybeAccount)); +} + +export function getRentClaimSize(): number { + return 16; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/state.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/state.ts new file mode 100644 index 000000000..6d6399bb2 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/state.ts @@ -0,0 +1,139 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const STATE_DISCRIMINATOR = new Uint8Array([ + 216, 146, 107, 94, 104, 75, 182, 177, +]); + +export function getStateDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(STATE_DISCRIMINATOR); +} + +export type State = { + discriminator: ReadonlyUint8Array; + sourceDomain: number; + signer: Address; + bump: number; +}; + +export type StateArgs = { sourceDomain: number; signer: Address; bump: number }; + +export function getStateEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['sourceDomain', getU32Encoder()], + ['signer', getAddressEncoder()], + ['bump', getU8Encoder()], + ]), + (value) => ({ ...value, discriminator: STATE_DISCRIMINATOR }) + ); +} + +export function getStateDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['sourceDomain', getU32Decoder()], + ['signer', getAddressDecoder()], + ['bump', getU8Decoder()], + ]); +} + +export function getStateCodec(): Codec { + return combineCodec(getStateEncoder(), getStateDecoder()); +} + +export function decodeState( + encodedAccount: EncodedAccount +): Account; +export function decodeState( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeState( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getStateDecoder() + ); +} + +export async function fetchState( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeState(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeState( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeState(maybeAccount); +} + +export async function fetchAllState( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeState(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeState( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeState(maybeAccount)); +} + +export function getStateSize(): number { + return 45; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/usedNonce.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/usedNonce.ts new file mode 100644 index 000000000..32d04d0b0 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/usedNonce.ts @@ -0,0 +1,129 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const USED_NONCE_DISCRIMINATOR = new Uint8Array([ + 212, 222, 157, 252, 130, 71, 179, 238, +]); + +export function getUsedNonceDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(USED_NONCE_DISCRIMINATOR); +} + +export type UsedNonce = { + discriminator: ReadonlyUint8Array; + quoteDeadline: bigint; +}; + +export type UsedNonceArgs = { quoteDeadline: number | bigint }; + +export function getUsedNonceEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['quoteDeadline', getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: USED_NONCE_DISCRIMINATOR }) + ); +} + +export function getUsedNonceDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['quoteDeadline', getU64Decoder()], + ]); +} + +export function getUsedNonceCodec(): Codec { + return combineCodec(getUsedNonceEncoder(), getUsedNonceDecoder()); +} + +export function decodeUsedNonce( + encodedAccount: EncodedAccount +): Account; +export function decodeUsedNonce( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeUsedNonce( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getUsedNonceDecoder() + ); +} + +export async function fetchUsedNonce( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeUsedNonce(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeUsedNonce( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeUsedNonce(maybeAccount); +} + +export async function fetchAllUsedNonce( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeUsedNonce(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeUsedNonce( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeUsedNonce(maybeAccount)); +} + +export function getUsedNonceSize(): number { + return 16; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/errors/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/errors/index.ts new file mode 100644 index 000000000..b022681a8 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/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 './sponsoredCctpSrcPeriphery'; diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/errors/sponsoredCctpSrcPeriphery.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/errors/sponsoredCctpSrcPeriphery.ts new file mode 100644 index 000000000..818a08a00 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/errors/sponsoredCctpSrcPeriphery.ts @@ -0,0 +1,103 @@ +/** + * 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/kit'; +import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; + +/** NotUpgradeAuthority: Only the upgrade authority can call this instruction */ +export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__NOT_UPGRADE_AUTHORITY = 0x1770; // 6000 +/** InvalidProgramData: Invalid program data account */ +export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_PROGRAM_DATA = 0x1771; // 6001 +/** CannotSetCurrentTime: Cannot set time if not in test mode */ +export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__CANNOT_SET_CURRENT_TIME = 0x1772; // 6002 +/** InvalidBurnToken: Invalid burn_token key */ +export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_BURN_TOKEN = 0x1773; // 6003 +/** AmountNotPositive: Amount must be greater than 0 */ +export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__AMOUNT_NOT_POSITIVE = 0x1774; // 6004 +/** QuoteDeadlineNotPassed: The quote deadline has not passed! */ +export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__QUOTE_DEADLINE_NOT_PASSED = 0x1775; // 6005 +/** SignerUnchanged: New signer unchanged */ +export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__SIGNER_UNCHANGED = 0x1776; // 6006 +/** DepositAmountBelowMinimum: Deposit amount below minimum */ +export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__DEPOSIT_AMOUNT_BELOW_MINIMUM = 0x1777; // 6007 +/** MissingRentClaimAccount: Missing rent claim account */ +export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__MISSING_RENT_CLAIM_ACCOUNT = 0x1778; // 6008 +/** RentClaimOverflow: Rent claim amount overflow */ +export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__RENT_CLAIM_OVERFLOW = 0x1779; // 6009 +/** InvalidRecipientKey: Invalid recipient key */ +export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_RECIPIENT_KEY = 0x177a; // 6010 + +export type SponsoredCctpSrcPeripheryError = + | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__AMOUNT_NOT_POSITIVE + | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__CANNOT_SET_CURRENT_TIME + | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__DEPOSIT_AMOUNT_BELOW_MINIMUM + | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_BURN_TOKEN + | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_PROGRAM_DATA + | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_RECIPIENT_KEY + | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__MISSING_RENT_CLAIM_ACCOUNT + | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__NOT_UPGRADE_AUTHORITY + | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__QUOTE_DEADLINE_NOT_PASSED + | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__RENT_CLAIM_OVERFLOW + | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__SIGNER_UNCHANGED; + +let sponsoredCctpSrcPeripheryErrorMessages: + | Record + | undefined; +if (process.env.NODE_ENV !== 'production') { + sponsoredCctpSrcPeripheryErrorMessages = { + [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__AMOUNT_NOT_POSITIVE]: `Amount must be greater than 0`, + [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__CANNOT_SET_CURRENT_TIME]: `Cannot set time if not in test mode`, + [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__DEPOSIT_AMOUNT_BELOW_MINIMUM]: `Deposit amount below minimum`, + [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_BURN_TOKEN]: `Invalid burn_token key`, + [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_PROGRAM_DATA]: `Invalid program data account`, + [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_RECIPIENT_KEY]: `Invalid recipient key`, + [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__MISSING_RENT_CLAIM_ACCOUNT]: `Missing rent claim account`, + [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__NOT_UPGRADE_AUTHORITY]: `Only the upgrade authority can call this instruction`, + [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__QUOTE_DEADLINE_NOT_PASSED]: `The quote deadline has not passed!`, + [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__RENT_CLAIM_OVERFLOW]: `Rent claim amount overflow`, + [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__SIGNER_UNCHANGED]: `New signer unchanged`, + }; +} + +export function getSponsoredCctpSrcPeripheryErrorMessage( + code: SponsoredCctpSrcPeripheryError +): string { + if (process.env.NODE_ENV !== 'production') { + return ( + sponsoredCctpSrcPeripheryErrorMessages as Record< + SponsoredCctpSrcPeripheryError, + string + > + )[code]; + } + + return 'Error message not available in production bundles.'; +} + +export function isSponsoredCctpSrcPeripheryError< + TProgramErrorCode extends SponsoredCctpSrcPeripheryError, +>( + error: unknown, + transactionMessage: { + instructions: Record; + }, + code?: TProgramErrorCode +): error is SolanaError & + Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { + return isProgramError( + error, + transactionMessage, + SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + code + ); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/index.ts new file mode 100644 index 000000000..02964a6ae --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/index.ts @@ -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. + * + * @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/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/depositForBurn.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/depositForBurn.ts new file mode 100644 index 000000000..f4ed8234e --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/depositForBurn.ts @@ -0,0 +1,914 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; +import { + getSponsoredCCTPQuoteDecoder, + getSponsoredCCTPQuoteEncoder, + type SponsoredCCTPQuote, + type SponsoredCCTPQuoteArgs, +} from '../types'; + +export const DEPOSIT_FOR_BURN_DISCRIMINATOR = new Uint8Array([ + 215, 60, 61, 46, 114, 55, 128, 176, +]); + +export function getDepositForBurnDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DEPOSIT_FOR_BURN_DISCRIMINATOR + ); +} + +export type DepositForBurnInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountRentFund extends string | AccountMeta = string, + TAccountMinimumDeposit extends string | AccountMeta = string, + TAccountUsedNonce extends string | AccountMeta = string, + TAccountRentClaim extends string | AccountMeta = string, + TAccountDepositorTokenAccount extends string | AccountMeta = string, + TAccountBurnToken extends string | AccountMeta = string, + TAccountDenylistAccount extends string | AccountMeta = string, + TAccountTokenMessengerMinterSenderAuthority extends + | string + | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountRemoteTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountCctpEventAuthority extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TAccountMessageTransmitterProgram extends string | AccountMeta = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC', + TAccountTokenMessengerMinterProgram extends string | AccountMeta = + 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe', + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountState extends string + ? ReadonlyAccount + : TAccountState, + TAccountRentFund extends string + ? WritableAccount + : TAccountRentFund, + TAccountMinimumDeposit extends string + ? ReadonlyAccount + : TAccountMinimumDeposit, + TAccountUsedNonce extends string + ? WritableAccount + : TAccountUsedNonce, + TAccountRentClaim extends string + ? WritableAccount + : TAccountRentClaim, + TAccountDepositorTokenAccount extends string + ? WritableAccount + : TAccountDepositorTokenAccount, + TAccountBurnToken extends string + ? WritableAccount + : TAccountBurnToken, + TAccountDenylistAccount extends string + ? ReadonlyAccount + : TAccountDenylistAccount, + TAccountTokenMessengerMinterSenderAuthority extends string + ? ReadonlyAccount + : TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountRemoteTokenMessenger extends string + ? ReadonlyAccount + : TAccountRemoteTokenMessenger, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountCctpEventAuthority extends string + ? ReadonlyAccount + : TAccountCctpEventAuthority, + TAccountMessageSentEventData extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountMessageSentEventData, + TAccountMessageTransmitterProgram extends string + ? ReadonlyAccount + : TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram extends string + ? ReadonlyAccount + : TAccountTokenMessengerMinterProgram, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type DepositForBurnInstructionData = { + discriminator: ReadonlyUint8Array; + quote: SponsoredCCTPQuote; + signature: ReadonlyUint8Array; +}; + +export type DepositForBurnInstructionDataArgs = { + quote: SponsoredCCTPQuoteArgs; + signature: ReadonlyUint8Array; +}; + +export function getDepositForBurnInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['quote', getSponsoredCCTPQuoteEncoder()], + ['signature', fixEncoderSize(getBytesEncoder(), 65)], + ]), + (value) => ({ ...value, discriminator: DEPOSIT_FOR_BURN_DISCRIMINATOR }) + ); +} + +export function getDepositForBurnInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['quote', getSponsoredCCTPQuoteDecoder()], + ['signature', fixDecoderSize(getBytesDecoder(), 65)], + ]); +} + +export function getDepositForBurnInstructionDataCodec(): Codec< + DepositForBurnInstructionDataArgs, + DepositForBurnInstructionData +> { + return combineCodec( + getDepositForBurnInstructionDataEncoder(), + getDepositForBurnInstructionDataDecoder() + ); +} + +export type DepositForBurnAsyncInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountRentFund extends string = string, + TAccountMinimumDeposit extends string = string, + TAccountUsedNonce extends string = string, + TAccountRentClaim extends string = string, + TAccountDepositorTokenAccount extends string = string, + TAccountBurnToken extends string = string, + TAccountDenylistAccount extends string = string, + TAccountTokenMessengerMinterSenderAuthority extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountCctpEventAuthority extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state?: Address; + rentFund?: Address; + minimumDeposit?: Address; + usedNonce: Address; + rentClaim?: Address; + depositorTokenAccount?: Address; + burnToken: Address; + denylistAccount: Address; + tokenMessengerMinterSenderAuthority: Address; + messageTransmitter: Address; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken: Address; + cctpEventAuthority: Address; + messageSentEventData: TransactionSigner; + messageTransmitterProgram?: Address; + tokenMessengerMinterProgram?: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + quote: DepositForBurnInstructionDataArgs['quote']; + signature: DepositForBurnInstructionDataArgs['signature']; +}; + +export async function getDepositForBurnInstructionAsync< + TAccountSigner extends string, + TAccountState extends string, + TAccountRentFund extends string, + TAccountMinimumDeposit extends string, + TAccountUsedNonce extends string, + TAccountRentClaim extends string, + TAccountDepositorTokenAccount extends string, + TAccountBurnToken extends string, + TAccountDenylistAccount extends string, + TAccountTokenMessengerMinterSenderAuthority extends string, + TAccountMessageTransmitter extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountCctpEventAuthority extends string, + TAccountMessageSentEventData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: DepositForBurnAsyncInput< + TAccountSigner, + TAccountState, + TAccountRentFund, + TAccountMinimumDeposit, + TAccountUsedNonce, + TAccountRentClaim, + TAccountDepositorTokenAccount, + TAccountBurnToken, + TAccountDenylistAccount, + TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCctpEventAuthority, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + DepositForBurnInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountRentFund, + TAccountMinimumDeposit, + TAccountUsedNonce, + TAccountRentClaim, + TAccountDepositorTokenAccount, + TAccountBurnToken, + TAccountDenylistAccount, + TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCctpEventAuthority, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: false }, + rentFund: { value: input.rentFund ?? null, isWritable: true }, + minimumDeposit: { value: input.minimumDeposit ?? null, isWritable: false }, + usedNonce: { value: input.usedNonce ?? null, isWritable: true }, + rentClaim: { value: input.rentClaim ?? null, isWritable: true }, + depositorTokenAccount: { + value: input.depositorTokenAccount ?? null, + isWritable: true, + }, + burnToken: { value: input.burnToken ?? null, isWritable: true }, + denylistAccount: { + value: input.denylistAccount ?? null, + isWritable: false, + }, + tokenMessengerMinterSenderAuthority: { + value: input.tokenMessengerMinterSenderAuthority ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + cctpEventAuthority: { + value: input.cctpEventAuthority ?? null, + isWritable: false, + }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.state.value) { + accounts.state.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), + ], + }); + } + if (!accounts.rentFund.value) { + accounts.rentFund.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([114, 101, 110, 116, 95, 102, 117, 110, 100]) + ), + ], + }); + } + if (!accounts.minimumDeposit.value) { + accounts.minimumDeposit.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 109, 105, 110, 105, 109, 117, 109, 95, 100, 101, 112, 111, 115, 105, + 116, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.burnToken.value)), + ], + }); + } + if (!accounts.rentClaim.value) { + accounts.rentClaim.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([114, 101, 110, 116, 95, 99, 108, 97, 105, 109]) + ), + getAddressEncoder().encode(expectAddress(accounts.signer.value)), + ], + }); + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.depositorTokenAccount.value) { + accounts.depositorTokenAccount.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getAddressEncoder().encode(expectAddress(accounts.signer.value)), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.burnToken.value)), + ], + }); + } + if (!accounts.messageTransmitterProgram.value) { + accounts.messageTransmitterProgram.value = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; + } + if (!accounts.tokenMessengerMinterProgram.value) { + accounts.tokenMessengerMinterProgram.value = + 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.rentFund), + getAccountMeta(accounts.minimumDeposit), + getAccountMeta(accounts.usedNonce), + getAccountMeta(accounts.rentClaim), + getAccountMeta(accounts.depositorTokenAccount), + getAccountMeta(accounts.burnToken), + getAccountMeta(accounts.denylistAccount), + getAccountMeta(accounts.tokenMessengerMinterSenderAuthority), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.cctpEventAuthority), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDepositForBurnInstructionDataEncoder().encode( + args as DepositForBurnInstructionDataArgs + ), + } as DepositForBurnInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountRentFund, + TAccountMinimumDeposit, + TAccountUsedNonce, + TAccountRentClaim, + TAccountDepositorTokenAccount, + TAccountBurnToken, + TAccountDenylistAccount, + TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCctpEventAuthority, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type DepositForBurnInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountRentFund extends string = string, + TAccountMinimumDeposit extends string = string, + TAccountUsedNonce extends string = string, + TAccountRentClaim extends string = string, + TAccountDepositorTokenAccount extends string = string, + TAccountBurnToken extends string = string, + TAccountDenylistAccount extends string = string, + TAccountTokenMessengerMinterSenderAuthority extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountCctpEventAuthority extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + rentFund: Address; + minimumDeposit: Address; + usedNonce: Address; + rentClaim?: Address; + depositorTokenAccount: Address; + burnToken: Address; + denylistAccount: Address; + tokenMessengerMinterSenderAuthority: Address; + messageTransmitter: Address; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken: Address; + cctpEventAuthority: Address; + messageSentEventData: TransactionSigner; + messageTransmitterProgram?: Address; + tokenMessengerMinterProgram?: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + quote: DepositForBurnInstructionDataArgs['quote']; + signature: DepositForBurnInstructionDataArgs['signature']; +}; + +export function getDepositForBurnInstruction< + TAccountSigner extends string, + TAccountState extends string, + TAccountRentFund extends string, + TAccountMinimumDeposit extends string, + TAccountUsedNonce extends string, + TAccountRentClaim extends string, + TAccountDepositorTokenAccount extends string, + TAccountBurnToken extends string, + TAccountDenylistAccount extends string, + TAccountTokenMessengerMinterSenderAuthority extends string, + TAccountMessageTransmitter extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountCctpEventAuthority extends string, + TAccountMessageSentEventData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: DepositForBurnInput< + TAccountSigner, + TAccountState, + TAccountRentFund, + TAccountMinimumDeposit, + TAccountUsedNonce, + TAccountRentClaim, + TAccountDepositorTokenAccount, + TAccountBurnToken, + TAccountDenylistAccount, + TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCctpEventAuthority, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): DepositForBurnInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountRentFund, + TAccountMinimumDeposit, + TAccountUsedNonce, + TAccountRentClaim, + TAccountDepositorTokenAccount, + TAccountBurnToken, + TAccountDenylistAccount, + TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCctpEventAuthority, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: false }, + rentFund: { value: input.rentFund ?? null, isWritable: true }, + minimumDeposit: { value: input.minimumDeposit ?? null, isWritable: false }, + usedNonce: { value: input.usedNonce ?? null, isWritable: true }, + rentClaim: { value: input.rentClaim ?? null, isWritable: true }, + depositorTokenAccount: { + value: input.depositorTokenAccount ?? null, + isWritable: true, + }, + burnToken: { value: input.burnToken ?? null, isWritable: true }, + denylistAccount: { + value: input.denylistAccount ?? null, + isWritable: false, + }, + tokenMessengerMinterSenderAuthority: { + value: input.tokenMessengerMinterSenderAuthority ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + cctpEventAuthority: { + value: input.cctpEventAuthority ?? null, + isWritable: false, + }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.messageTransmitterProgram.value) { + accounts.messageTransmitterProgram.value = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; + } + if (!accounts.tokenMessengerMinterProgram.value) { + accounts.tokenMessengerMinterProgram.value = + 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.rentFund), + getAccountMeta(accounts.minimumDeposit), + getAccountMeta(accounts.usedNonce), + getAccountMeta(accounts.rentClaim), + getAccountMeta(accounts.depositorTokenAccount), + getAccountMeta(accounts.burnToken), + getAccountMeta(accounts.denylistAccount), + getAccountMeta(accounts.tokenMessengerMinterSenderAuthority), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.cctpEventAuthority), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDepositForBurnInstructionDataEncoder().encode( + args as DepositForBurnInstructionDataArgs + ), + } as DepositForBurnInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountRentFund, + TAccountMinimumDeposit, + TAccountUsedNonce, + TAccountRentClaim, + TAccountDepositorTokenAccount, + TAccountBurnToken, + TAccountDenylistAccount, + TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCctpEventAuthority, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedDepositForBurnInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + state: TAccountMetas[1]; + rentFund: TAccountMetas[2]; + minimumDeposit: TAccountMetas[3]; + usedNonce: TAccountMetas[4]; + rentClaim?: TAccountMetas[5] | undefined; + depositorTokenAccount: TAccountMetas[6]; + burnToken: TAccountMetas[7]; + denylistAccount: TAccountMetas[8]; + tokenMessengerMinterSenderAuthority: TAccountMetas[9]; + messageTransmitter: TAccountMetas[10]; + tokenMessenger: TAccountMetas[11]; + remoteTokenMessenger: TAccountMetas[12]; + tokenMinter: TAccountMetas[13]; + localToken: TAccountMetas[14]; + cctpEventAuthority: TAccountMetas[15]; + messageSentEventData: TAccountMetas[16]; + messageTransmitterProgram: TAccountMetas[17]; + tokenMessengerMinterProgram: TAccountMetas[18]; + tokenProgram: TAccountMetas[19]; + systemProgram: TAccountMetas[20]; + eventAuthority: TAccountMetas[21]; + program: TAccountMetas[22]; + }; + data: DepositForBurnInstructionData; +}; + +export function parseDepositForBurnInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedDepositForBurnInstruction { + if (instruction.accounts.length < 23) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = instruction.accounts![accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + signer: getNextAccount(), + state: getNextAccount(), + rentFund: getNextAccount(), + minimumDeposit: getNextAccount(), + usedNonce: getNextAccount(), + rentClaim: getNextOptionalAccount(), + depositorTokenAccount: getNextAccount(), + burnToken: getNextAccount(), + denylistAccount: getNextAccount(), + tokenMessengerMinterSenderAuthority: getNextAccount(), + messageTransmitter: getNextAccount(), + tokenMessenger: getNextAccount(), + remoteTokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + cctpEventAuthority: getNextAccount(), + messageSentEventData: getNextAccount(), + messageTransmitterProgram: getNextAccount(), + tokenMessengerMinterProgram: getNextAccount(), + tokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getDepositForBurnInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/getUsedNonceCloseInfo.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/getUsedNonceCloseInfo.ts new file mode 100644 index 000000000..96fec482f --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/getUsedNonceCloseInfo.ts @@ -0,0 +1,275 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +import { + getUsedNonceAccountParamsDecoder, + getUsedNonceAccountParamsEncoder, + type UsedNonceAccountParams, + type UsedNonceAccountParamsArgs, +} from '../types'; + +export const GET_USED_NONCE_CLOSE_INFO_DISCRIMINATOR = new Uint8Array([ + 19, 183, 42, 151, 118, 234, 57, 92, +]); + +export function getGetUsedNonceCloseInfoDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + GET_USED_NONCE_CLOSE_INFO_DISCRIMINATOR + ); +} + +export type GetUsedNonceCloseInfoInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountState extends string | AccountMeta = string, + TAccountUsedNonce extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountState extends string + ? ReadonlyAccount + : TAccountState, + TAccountUsedNonce extends string + ? ReadonlyAccount + : TAccountUsedNonce, + ...TRemainingAccounts, + ] + >; + +export type GetUsedNonceCloseInfoInstructionData = { + discriminator: ReadonlyUint8Array; + params: UsedNonceAccountParams; +}; + +export type GetUsedNonceCloseInfoInstructionDataArgs = { + params: UsedNonceAccountParamsArgs; +}; + +export function getGetUsedNonceCloseInfoInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['params', getUsedNonceAccountParamsEncoder()], + ]), + (value) => ({ + ...value, + discriminator: GET_USED_NONCE_CLOSE_INFO_DISCRIMINATOR, + }) + ); +} + +export function getGetUsedNonceCloseInfoInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['params', getUsedNonceAccountParamsDecoder()], + ]); +} + +export function getGetUsedNonceCloseInfoInstructionDataCodec(): Codec< + GetUsedNonceCloseInfoInstructionDataArgs, + GetUsedNonceCloseInfoInstructionData +> { + return combineCodec( + getGetUsedNonceCloseInfoInstructionDataEncoder(), + getGetUsedNonceCloseInfoInstructionDataDecoder() + ); +} + +export type GetUsedNonceCloseInfoAsyncInput< + TAccountState extends string = string, + TAccountUsedNonce extends string = string, +> = { + state?: Address; + usedNonce: Address; + params: GetUsedNonceCloseInfoInstructionDataArgs['params']; +}; + +export async function getGetUsedNonceCloseInfoInstructionAsync< + TAccountState extends string, + TAccountUsedNonce extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: GetUsedNonceCloseInfoAsyncInput, + config?: { programAddress?: TProgramAddress } +): Promise< + GetUsedNonceCloseInfoInstruction< + TProgramAddress, + TAccountState, + TAccountUsedNonce + > +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + state: { value: input.state ?? null, isWritable: false }, + usedNonce: { value: input.usedNonce ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.state.value) { + accounts.state.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.state), + getAccountMeta(accounts.usedNonce), + ], + programAddress, + data: getGetUsedNonceCloseInfoInstructionDataEncoder().encode( + args as GetUsedNonceCloseInfoInstructionDataArgs + ), + } as GetUsedNonceCloseInfoInstruction< + TProgramAddress, + TAccountState, + TAccountUsedNonce + >; + + return instruction; +} + +export type GetUsedNonceCloseInfoInput< + TAccountState extends string = string, + TAccountUsedNonce extends string = string, +> = { + state: Address; + usedNonce: Address; + params: GetUsedNonceCloseInfoInstructionDataArgs['params']; +}; + +export function getGetUsedNonceCloseInfoInstruction< + TAccountState extends string, + TAccountUsedNonce extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: GetUsedNonceCloseInfoInput, + config?: { programAddress?: TProgramAddress } +): GetUsedNonceCloseInfoInstruction< + TProgramAddress, + TAccountState, + TAccountUsedNonce +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + state: { value: input.state ?? null, isWritable: false }, + usedNonce: { value: input.usedNonce ?? 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.state), + getAccountMeta(accounts.usedNonce), + ], + programAddress, + data: getGetUsedNonceCloseInfoInstructionDataEncoder().encode( + args as GetUsedNonceCloseInfoInstructionDataArgs + ), + } as GetUsedNonceCloseInfoInstruction< + TProgramAddress, + TAccountState, + TAccountUsedNonce + >; + + return instruction; +} + +export type ParsedGetUsedNonceCloseInfoInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + state: TAccountMetas[0]; + usedNonce: TAccountMetas[1]; + }; + data: GetUsedNonceCloseInfoInstructionData; +}; + +export function parseGetUsedNonceCloseInfoInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedGetUsedNonceCloseInfoInstruction { + if (instruction.accounts.length < 2) { + // 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: { + state: getNextAccount(), + usedNonce: getNextAccount(), + }, + data: getGetUsedNonceCloseInfoInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/index.ts new file mode 100644 index 000000000..706f7eee5 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/index.ts @@ -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. + * + * @see https://github.com/codama-idl/codama + */ + +export * from './depositForBurn'; +export * from './getUsedNonceCloseInfo'; +export * from './initialize'; +export * from './reclaimEventAccount'; +export * from './reclaimUsedNonceAccount'; +export * from './repayRentFundDebt'; +export * from './setCurrentTime'; +export * from './setMinimumDepositAmount'; +export * from './setSigner'; +export * from './withdrawRentFund'; diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/initialize.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/initialize.ts new file mode 100644 index 000000000..d40b3b2b1 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/initialize.ts @@ -0,0 +1,369 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const INITIALIZE_DISCRIMINATOR = new Uint8Array([ + 175, 175, 109, 31, 13, 152, 155, 237, +]); + +export function getInitializeDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_DISCRIMINATOR); +} + +export type InitializeInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountProgramData extends string | AccountMeta = string, + TAccountThisProgram extends string | AccountMeta = + 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountState extends string + ? WritableAccount + : TAccountState, + TAccountProgramData extends string + ? ReadonlyAccount + : TAccountProgramData, + TAccountThisProgram extends string + ? ReadonlyAccount + : TAccountThisProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type InitializeInstructionData = { + discriminator: ReadonlyUint8Array; + sourceDomain: number; + signer: Address; +}; + +export type InitializeInstructionDataArgs = { + sourceDomain: number; + signer: Address; +}; + +export function getInitializeInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['sourceDomain', getU32Encoder()], + ['signer', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) + ); +} + +export function getInitializeInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['sourceDomain', getU32Decoder()], + ['signer', getAddressDecoder()], + ]); +} + +export function getInitializeInstructionDataCodec(): Codec< + InitializeInstructionDataArgs, + InitializeInstructionData +> { + return combineCodec( + getInitializeInstructionDataEncoder(), + getInitializeInstructionDataDecoder() + ); +} + +export type InitializeAsyncInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountProgramData extends string = string, + TAccountThisProgram extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + state?: Address; + programData: Address; + thisProgram?: Address; + systemProgram?: Address; + sourceDomain: InitializeInstructionDataArgs['sourceDomain']; + signerArg: InitializeInstructionDataArgs['signer']; +}; + +export async function getInitializeInstructionAsync< + TAccountSigner extends string, + TAccountState extends string, + TAccountProgramData extends string, + TAccountThisProgram extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: InitializeAsyncInput< + TAccountSigner, + TAccountState, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + InitializeInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + programData: { value: input.programData ?? null, isWritable: false }, + thisProgram: { value: input.thisProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input, signer: input.signerArg }; + + // Resolve default values. + if (!accounts.state.value) { + accounts.state.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), + ], + }); + } + if (!accounts.thisProgram.value) { + accounts.thisProgram.value = + 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.programData), + getAccountMeta(accounts.thisProgram), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitializeInstructionDataEncoder().encode( + args as InitializeInstructionDataArgs + ), + } as InitializeInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + >; + + return instruction; +} + +export type InitializeInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountProgramData extends string = string, + TAccountThisProgram extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + programData: Address; + thisProgram?: Address; + systemProgram?: Address; + sourceDomain: InitializeInstructionDataArgs['sourceDomain']; + signerArg: InitializeInstructionDataArgs['signer']; +}; + +export function getInitializeInstruction< + TAccountSigner extends string, + TAccountState extends string, + TAccountProgramData extends string, + TAccountThisProgram extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: InitializeInput< + TAccountSigner, + TAccountState, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): InitializeInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + programData: { value: input.programData ?? null, isWritable: false }, + thisProgram: { value: input.thisProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input, signer: input.signerArg }; + + // Resolve default values. + if (!accounts.thisProgram.value) { + accounts.thisProgram.value = + 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.programData), + getAccountMeta(accounts.thisProgram), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitializeInstructionDataEncoder().encode( + args as InitializeInstructionDataArgs + ), + } as InitializeInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedInitializeInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + state: TAccountMetas[1]; + programData: TAccountMetas[2]; + thisProgram: TAccountMetas[3]; + systemProgram: TAccountMetas[4]; + }; + data: InitializeInstructionData; +}; + +export function parseInitializeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedInitializeInstruction { + if (instruction.accounts.length < 5) { + // 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: { + signer: getNextAccount(), + state: getNextAccount(), + programData: getNextAccount(), + thisProgram: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitializeInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimEventAccount.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimEventAccount.ts new file mode 100644 index 000000000..fb92b282b --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimEventAccount.ts @@ -0,0 +1,436 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type WritableAccount, +} from '@solana/kit'; +import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR = new Uint8Array([ + 94, 198, 180, 159, 131, 236, 15, 174, +]); + +export function getReclaimEventAccountDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR + ); +} + +export type ReclaimEventAccountInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountRentFund extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TAccountMessageTransmitterProgram extends string | AccountMeta = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountRentFund extends string + ? WritableAccount + : TAccountRentFund, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountMessageSentEventData extends string + ? WritableAccount + : TAccountMessageSentEventData, + TAccountMessageTransmitterProgram extends string + ? ReadonlyAccount + : TAccountMessageTransmitterProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type ReclaimEventAccountInstructionData = { + discriminator: ReadonlyUint8Array; + attestation: ReadonlyUint8Array; + nonce: ReadonlyUint8Array; + finalityThresholdExecuted: ReadonlyUint8Array; + feeExecuted: ReadonlyUint8Array; + expirationBlock: ReadonlyUint8Array; +}; + +export type ReclaimEventAccountInstructionDataArgs = { + attestation: ReadonlyUint8Array; + nonce: ReadonlyUint8Array; + finalityThresholdExecuted: ReadonlyUint8Array; + feeExecuted: ReadonlyUint8Array; + expirationBlock: ReadonlyUint8Array; +}; + +export function getReclaimEventAccountInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['attestation', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ['nonce', fixEncoderSize(getBytesEncoder(), 32)], + ['finalityThresholdExecuted', fixEncoderSize(getBytesEncoder(), 4)], + ['feeExecuted', fixEncoderSize(getBytesEncoder(), 32)], + ['expirationBlock', fixEncoderSize(getBytesEncoder(), 32)], + ]), + (value) => ({ + ...value, + discriminator: RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR, + }) + ); +} + +export function getReclaimEventAccountInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['attestation', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ['nonce', fixDecoderSize(getBytesDecoder(), 32)], + ['finalityThresholdExecuted', fixDecoderSize(getBytesDecoder(), 4)], + ['feeExecuted', fixDecoderSize(getBytesDecoder(), 32)], + ['expirationBlock', fixDecoderSize(getBytesDecoder(), 32)], + ]); +} + +export function getReclaimEventAccountInstructionDataCodec(): Codec< + ReclaimEventAccountInstructionDataArgs, + ReclaimEventAccountInstructionData +> { + return combineCodec( + getReclaimEventAccountInstructionDataEncoder(), + getReclaimEventAccountInstructionDataDecoder() + ); +} + +export type ReclaimEventAccountAsyncInput< + TAccountRentFund extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + rentFund?: Address; + messageTransmitter: Address; + messageSentEventData: Address; + messageTransmitterProgram?: Address; + eventAuthority?: Address; + program: Address; + attestation: ReclaimEventAccountInstructionDataArgs['attestation']; + nonce: ReclaimEventAccountInstructionDataArgs['nonce']; + finalityThresholdExecuted: ReclaimEventAccountInstructionDataArgs['finalityThresholdExecuted']; + feeExecuted: ReclaimEventAccountInstructionDataArgs['feeExecuted']; + expirationBlock: ReclaimEventAccountInstructionDataArgs['expirationBlock']; +}; + +export async function getReclaimEventAccountInstructionAsync< + TAccountRentFund extends string, + TAccountMessageTransmitter extends string, + TAccountMessageSentEventData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: ReclaimEventAccountAsyncInput< + TAccountRentFund, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + ReclaimEventAccountInstruction< + TProgramAddress, + TAccountRentFund, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + rentFund: { value: input.rentFund ?? null, isWritable: true }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.rentFund.value) { + accounts.rentFund.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([114, 101, 110, 116, 95, 102, 117, 110, 100]) + ), + ], + }); + } + if (!accounts.messageTransmitterProgram.value) { + accounts.messageTransmitterProgram.value = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.rentFund), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getReclaimEventAccountInstructionDataEncoder().encode( + args as ReclaimEventAccountInstructionDataArgs + ), + } as ReclaimEventAccountInstruction< + TProgramAddress, + TAccountRentFund, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ReclaimEventAccountInput< + TAccountRentFund extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + rentFund: Address; + messageTransmitter: Address; + messageSentEventData: Address; + messageTransmitterProgram?: Address; + eventAuthority: Address; + program: Address; + attestation: ReclaimEventAccountInstructionDataArgs['attestation']; + nonce: ReclaimEventAccountInstructionDataArgs['nonce']; + finalityThresholdExecuted: ReclaimEventAccountInstructionDataArgs['finalityThresholdExecuted']; + feeExecuted: ReclaimEventAccountInstructionDataArgs['feeExecuted']; + expirationBlock: ReclaimEventAccountInstructionDataArgs['expirationBlock']; +}; + +export function getReclaimEventAccountInstruction< + TAccountRentFund extends string, + TAccountMessageTransmitter extends string, + TAccountMessageSentEventData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: ReclaimEventAccountInput< + TAccountRentFund, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): ReclaimEventAccountInstruction< + TProgramAddress, + TAccountRentFund, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + rentFund: { value: input.rentFund ?? null, isWritable: true }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.messageTransmitterProgram.value) { + accounts.messageTransmitterProgram.value = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.rentFund), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getReclaimEventAccountInstructionDataEncoder().encode( + args as ReclaimEventAccountInstructionDataArgs + ), + } as ReclaimEventAccountInstruction< + TProgramAddress, + TAccountRentFund, + TAccountMessageTransmitter, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedReclaimEventAccountInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + rentFund: TAccountMetas[0]; + messageTransmitter: TAccountMetas[1]; + messageSentEventData: TAccountMetas[2]; + messageTransmitterProgram: TAccountMetas[3]; + eventAuthority: TAccountMetas[4]; + program: TAccountMetas[5]; + }; + data: ReclaimEventAccountInstructionData; +}; + +export function parseReclaimEventAccountInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedReclaimEventAccountInstruction { + if (instruction.accounts.length < 6) { + // 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: { + rentFund: getNextAccount(), + messageTransmitter: getNextAccount(), + messageSentEventData: getNextAccount(), + messageTransmitterProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getReclaimEventAccountInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimUsedNonceAccount.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimUsedNonceAccount.ts new file mode 100644 index 000000000..ba6101715 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimUsedNonceAccount.ts @@ -0,0 +1,371 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type WritableAccount, +} from '@solana/kit'; +import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +import { + getUsedNonceAccountParamsDecoder, + getUsedNonceAccountParamsEncoder, + type UsedNonceAccountParams, + type UsedNonceAccountParamsArgs, +} from '../types'; + +export const RECLAIM_USED_NONCE_ACCOUNT_DISCRIMINATOR = new Uint8Array([ + 153, 152, 111, 172, 156, 104, 116, 3, +]); + +export function getReclaimUsedNonceAccountDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + RECLAIM_USED_NONCE_ACCOUNT_DISCRIMINATOR + ); +} + +export type ReclaimUsedNonceAccountInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountState extends string | AccountMeta = string, + TAccountRentFund extends string | AccountMeta = string, + TAccountUsedNonce extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountState extends string + ? ReadonlyAccount + : TAccountState, + TAccountRentFund extends string + ? WritableAccount + : TAccountRentFund, + TAccountUsedNonce extends string + ? WritableAccount + : TAccountUsedNonce, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type ReclaimUsedNonceAccountInstructionData = { + discriminator: ReadonlyUint8Array; + params: UsedNonceAccountParams; +}; + +export type ReclaimUsedNonceAccountInstructionDataArgs = { + params: UsedNonceAccountParamsArgs; +}; + +export function getReclaimUsedNonceAccountInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['params', getUsedNonceAccountParamsEncoder()], + ]), + (value) => ({ + ...value, + discriminator: RECLAIM_USED_NONCE_ACCOUNT_DISCRIMINATOR, + }) + ); +} + +export function getReclaimUsedNonceAccountInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['params', getUsedNonceAccountParamsDecoder()], + ]); +} + +export function getReclaimUsedNonceAccountInstructionDataCodec(): Codec< + ReclaimUsedNonceAccountInstructionDataArgs, + ReclaimUsedNonceAccountInstructionData +> { + return combineCodec( + getReclaimUsedNonceAccountInstructionDataEncoder(), + getReclaimUsedNonceAccountInstructionDataDecoder() + ); +} + +export type ReclaimUsedNonceAccountAsyncInput< + TAccountState extends string = string, + TAccountRentFund extends string = string, + TAccountUsedNonce extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + state?: Address; + rentFund?: Address; + usedNonce: Address; + eventAuthority?: Address; + program: Address; + params: ReclaimUsedNonceAccountInstructionDataArgs['params']; +}; + +export async function getReclaimUsedNonceAccountInstructionAsync< + TAccountState extends string, + TAccountRentFund extends string, + TAccountUsedNonce extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: ReclaimUsedNonceAccountAsyncInput< + TAccountState, + TAccountRentFund, + TAccountUsedNonce, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + ReclaimUsedNonceAccountInstruction< + TProgramAddress, + TAccountState, + TAccountRentFund, + TAccountUsedNonce, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + state: { value: input.state ?? null, isWritable: false }, + rentFund: { value: input.rentFund ?? null, isWritable: true }, + usedNonce: { value: input.usedNonce ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.state.value) { + accounts.state.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), + ], + }); + } + if (!accounts.rentFund.value) { + accounts.rentFund.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([114, 101, 110, 116, 95, 102, 117, 110, 100]) + ), + ], + }); + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.state), + getAccountMeta(accounts.rentFund), + getAccountMeta(accounts.usedNonce), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getReclaimUsedNonceAccountInstructionDataEncoder().encode( + args as ReclaimUsedNonceAccountInstructionDataArgs + ), + } as ReclaimUsedNonceAccountInstruction< + TProgramAddress, + TAccountState, + TAccountRentFund, + TAccountUsedNonce, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ReclaimUsedNonceAccountInput< + TAccountState extends string = string, + TAccountRentFund extends string = string, + TAccountUsedNonce extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + state: Address; + rentFund: Address; + usedNonce: Address; + eventAuthority: Address; + program: Address; + params: ReclaimUsedNonceAccountInstructionDataArgs['params']; +}; + +export function getReclaimUsedNonceAccountInstruction< + TAccountState extends string, + TAccountRentFund extends string, + TAccountUsedNonce extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: ReclaimUsedNonceAccountInput< + TAccountState, + TAccountRentFund, + TAccountUsedNonce, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): ReclaimUsedNonceAccountInstruction< + TProgramAddress, + TAccountState, + TAccountRentFund, + TAccountUsedNonce, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + state: { value: input.state ?? null, isWritable: false }, + rentFund: { value: input.rentFund ?? null, isWritable: true }, + usedNonce: { value: input.usedNonce ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.state), + getAccountMeta(accounts.rentFund), + getAccountMeta(accounts.usedNonce), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getReclaimUsedNonceAccountInstructionDataEncoder().encode( + args as ReclaimUsedNonceAccountInstructionDataArgs + ), + } as ReclaimUsedNonceAccountInstruction< + TProgramAddress, + TAccountState, + TAccountRentFund, + TAccountUsedNonce, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedReclaimUsedNonceAccountInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + state: TAccountMetas[0]; + rentFund: TAccountMetas[1]; + usedNonce: TAccountMetas[2]; + eventAuthority: TAccountMetas[3]; + program: TAccountMetas[4]; + }; + data: ReclaimUsedNonceAccountInstructionData; +}; + +export function parseReclaimUsedNonceAccountInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedReclaimUsedNonceAccountInstruction { + if (instruction.accounts.length < 5) { + // 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: { + state: getNextAccount(), + rentFund: getNextAccount(), + usedNonce: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getReclaimUsedNonceAccountInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/repayRentFundDebt.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/repayRentFundDebt.ts new file mode 100644 index 000000000..efb2eeeb4 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/repayRentFundDebt.ts @@ -0,0 +1,382 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type WritableAccount, +} from '@solana/kit'; +import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const REPAY_RENT_FUND_DEBT_DISCRIMINATOR = new Uint8Array([ + 111, 95, 222, 174, 241, 41, 61, 78, +]); + +export function getRepayRentFundDebtDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REPAY_RENT_FUND_DEBT_DISCRIMINATOR + ); +} + +export type RepayRentFundDebtInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountRentFund extends string | AccountMeta = string, + TAccountRecipient extends string | AccountMeta = string, + TAccountRentClaim extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountRentFund extends string + ? WritableAccount + : TAccountRentFund, + TAccountRecipient extends string + ? WritableAccount + : TAccountRecipient, + TAccountRentClaim extends string + ? WritableAccount + : TAccountRentClaim, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type RepayRentFundDebtInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type RepayRentFundDebtInstructionDataArgs = {}; + +export function getRepayRentFundDebtInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: REPAY_RENT_FUND_DEBT_DISCRIMINATOR }) + ); +} + +export function getRepayRentFundDebtInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getRepayRentFundDebtInstructionDataCodec(): Codec< + RepayRentFundDebtInstructionDataArgs, + RepayRentFundDebtInstructionData +> { + return combineCodec( + getRepayRentFundDebtInstructionDataEncoder(), + getRepayRentFundDebtInstructionDataDecoder() + ); +} + +export type RepayRentFundDebtAsyncInput< + TAccountRentFund extends string = string, + TAccountRecipient extends string = string, + TAccountRentClaim extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + rentFund?: Address; + recipient: Address; + rentClaim?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getRepayRentFundDebtInstructionAsync< + TAccountRentFund extends string, + TAccountRecipient extends string, + TAccountRentClaim extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: RepayRentFundDebtAsyncInput< + TAccountRentFund, + TAccountRecipient, + TAccountRentClaim, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + RepayRentFundDebtInstruction< + TProgramAddress, + TAccountRentFund, + TAccountRecipient, + TAccountRentClaim, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + rentFund: { value: input.rentFund ?? null, isWritable: true }, + recipient: { value: input.recipient ?? null, isWritable: true }, + rentClaim: { value: input.rentClaim ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.rentFund.value) { + accounts.rentFund.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([114, 101, 110, 116, 95, 102, 117, 110, 100]) + ), + ], + }); + } + if (!accounts.rentClaim.value) { + accounts.rentClaim.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([114, 101, 110, 116, 95, 99, 108, 97, 105, 109]) + ), + getAddressEncoder().encode(expectAddress(accounts.recipient.value)), + ], + }); + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.rentFund), + getAccountMeta(accounts.recipient), + getAccountMeta(accounts.rentClaim), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getRepayRentFundDebtInstructionDataEncoder().encode({}), + } as RepayRentFundDebtInstruction< + TProgramAddress, + TAccountRentFund, + TAccountRecipient, + TAccountRentClaim, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type RepayRentFundDebtInput< + TAccountRentFund extends string = string, + TAccountRecipient extends string = string, + TAccountRentClaim extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + rentFund: Address; + recipient: Address; + rentClaim: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; +}; + +export function getRepayRentFundDebtInstruction< + TAccountRentFund extends string, + TAccountRecipient extends string, + TAccountRentClaim extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: RepayRentFundDebtInput< + TAccountRentFund, + TAccountRecipient, + TAccountRentClaim, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): RepayRentFundDebtInstruction< + TProgramAddress, + TAccountRentFund, + TAccountRecipient, + TAccountRentClaim, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + rentFund: { value: input.rentFund ?? null, isWritable: true }, + recipient: { value: input.recipient ?? null, isWritable: true }, + rentClaim: { value: input.rentClaim ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.rentFund), + getAccountMeta(accounts.recipient), + getAccountMeta(accounts.rentClaim), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getRepayRentFundDebtInstructionDataEncoder().encode({}), + } as RepayRentFundDebtInstruction< + TProgramAddress, + TAccountRentFund, + TAccountRecipient, + TAccountRentClaim, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedRepayRentFundDebtInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + rentFund: TAccountMetas[0]; + recipient: TAccountMetas[1]; + rentClaim: TAccountMetas[2]; + systemProgram: TAccountMetas[3]; + eventAuthority: TAccountMetas[4]; + program: TAccountMetas[5]; + }; + data: RepayRentFundDebtInstructionData; +}; + +export function parseRepayRentFundDebtInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedRepayRentFundDebtInstruction { + if (instruction.accounts.length < 6) { + // 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: { + rentFund: getNextAccount(), + recipient: getNextAccount(), + rentClaim: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getRepayRentFundDebtInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setCurrentTime.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setCurrentTime.ts new file mode 100644 index 000000000..9619a1840 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setCurrentTime.ts @@ -0,0 +1,254 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_CURRENT_TIME_DISCRIMINATOR = new Uint8Array([ + 69, 100, 169, 193, 125, 0, 150, 69, +]); + +export function getSetCurrentTimeDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_CURRENT_TIME_DISCRIMINATOR + ); +} + +export type SetCurrentTimeInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountState extends string | AccountMeta = string, + TAccountSigner extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountState extends string + ? WritableAccount + : TAccountState, + TAccountSigner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSigner, + ...TRemainingAccounts, + ] + >; + +export type SetCurrentTimeInstructionData = { + discriminator: ReadonlyUint8Array; + newTime: bigint; +}; + +export type SetCurrentTimeInstructionDataArgs = { newTime: number | bigint }; + +export function getSetCurrentTimeInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newTime', getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: SET_CURRENT_TIME_DISCRIMINATOR }) + ); +} + +export function getSetCurrentTimeInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newTime', getU64Decoder()], + ]); +} + +export function getSetCurrentTimeInstructionDataCodec(): Codec< + SetCurrentTimeInstructionDataArgs, + SetCurrentTimeInstructionData +> { + return combineCodec( + getSetCurrentTimeInstructionDataEncoder(), + getSetCurrentTimeInstructionDataDecoder() + ); +} + +export type SetCurrentTimeAsyncInput< + TAccountState extends string = string, + TAccountSigner extends string = string, +> = { + state?: Address; + signer: TransactionSigner; + newTime: SetCurrentTimeInstructionDataArgs['newTime']; +}; + +export async function getSetCurrentTimeInstructionAsync< + TAccountState extends string, + TAccountSigner extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: SetCurrentTimeAsyncInput, + config?: { programAddress?: TProgramAddress } +): Promise< + SetCurrentTimeInstruction +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + state: { value: input.state ?? null, isWritable: true }, + signer: { value: input.signer ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.state.value) { + accounts.state.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [getAccountMeta(accounts.state), getAccountMeta(accounts.signer)], + programAddress, + data: getSetCurrentTimeInstructionDataEncoder().encode( + args as SetCurrentTimeInstructionDataArgs + ), + } as SetCurrentTimeInstruction< + TProgramAddress, + TAccountState, + TAccountSigner + >; + + return instruction; +} + +export type SetCurrentTimeInput< + TAccountState extends string = string, + TAccountSigner extends string = string, +> = { + state: Address; + signer: TransactionSigner; + newTime: SetCurrentTimeInstructionDataArgs['newTime']; +}; + +export function getSetCurrentTimeInstruction< + TAccountState extends string, + TAccountSigner extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: SetCurrentTimeInput, + config?: { programAddress?: TProgramAddress } +): SetCurrentTimeInstruction { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + state: { value: input.state ?? null, isWritable: true }, + signer: { value: input.signer ?? 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.state), getAccountMeta(accounts.signer)], + programAddress, + data: getSetCurrentTimeInstructionDataEncoder().encode( + args as SetCurrentTimeInstructionDataArgs + ), + } as SetCurrentTimeInstruction< + TProgramAddress, + TAccountState, + TAccountSigner + >; + + return instruction; +} + +export type ParsedSetCurrentTimeInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + state: TAccountMetas[0]; + signer: TAccountMetas[1]; + }; + data: SetCurrentTimeInstructionData; +}; + +export function parseSetCurrentTimeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetCurrentTimeInstruction { + if (instruction.accounts.length < 2) { + // 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: { + state: getNextAccount(), + signer: getNextAccount(), + }, + data: getSetCurrentTimeInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setMinimumDepositAmount.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setMinimumDepositAmount.ts new file mode 100644 index 000000000..12db886ec --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setMinimumDepositAmount.ts @@ -0,0 +1,401 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const SET_MINIMUM_DEPOSIT_AMOUNT_DISCRIMINATOR = new Uint8Array([ + 176, 4, 74, 229, 206, 148, 151, 138, +]); + +export function getSetMinimumDepositAmountDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_MINIMUM_DEPOSIT_AMOUNT_DISCRIMINATOR + ); +} + +export type SetMinimumDepositAmountInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountMinimumDeposit extends string | AccountMeta = string, + TAccountBurnToken extends string | AccountMeta = string, + TAccountProgramData extends string | AccountMeta = string, + TAccountThisProgram extends string | AccountMeta = + 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountMinimumDeposit extends string + ? WritableAccount + : TAccountMinimumDeposit, + TAccountBurnToken extends string + ? ReadonlyAccount + : TAccountBurnToken, + TAccountProgramData extends string + ? ReadonlyAccount + : TAccountProgramData, + TAccountThisProgram extends string + ? ReadonlyAccount + : TAccountThisProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type SetMinimumDepositAmountInstructionData = { + discriminator: ReadonlyUint8Array; + amount: bigint; +}; + +export type SetMinimumDepositAmountInstructionDataArgs = { + amount: number | bigint; +}; + +export function getSetMinimumDepositAmountInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['amount', getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: SET_MINIMUM_DEPOSIT_AMOUNT_DISCRIMINATOR, + }) + ); +} + +export function getSetMinimumDepositAmountInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['amount', getU64Decoder()], + ]); +} + +export function getSetMinimumDepositAmountInstructionDataCodec(): Codec< + SetMinimumDepositAmountInstructionDataArgs, + SetMinimumDepositAmountInstructionData +> { + return combineCodec( + getSetMinimumDepositAmountInstructionDataEncoder(), + getSetMinimumDepositAmountInstructionDataDecoder() + ); +} + +export type SetMinimumDepositAmountAsyncInput< + TAccountSigner extends string = string, + TAccountMinimumDeposit extends string = string, + TAccountBurnToken extends string = string, + TAccountProgramData extends string = string, + TAccountThisProgram extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + minimumDeposit?: Address; + burnToken: Address; + programData: Address; + thisProgram?: Address; + systemProgram?: Address; + amount: SetMinimumDepositAmountInstructionDataArgs['amount']; +}; + +export async function getSetMinimumDepositAmountInstructionAsync< + TAccountSigner extends string, + TAccountMinimumDeposit extends string, + TAccountBurnToken extends string, + TAccountProgramData extends string, + TAccountThisProgram extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: SetMinimumDepositAmountAsyncInput< + TAccountSigner, + TAccountMinimumDeposit, + TAccountBurnToken, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + SetMinimumDepositAmountInstruction< + TProgramAddress, + TAccountSigner, + TAccountMinimumDeposit, + TAccountBurnToken, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + minimumDeposit: { value: input.minimumDeposit ?? null, isWritable: true }, + burnToken: { value: input.burnToken ?? null, isWritable: false }, + programData: { value: input.programData ?? null, isWritable: false }, + thisProgram: { value: input.thisProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.minimumDeposit.value) { + accounts.minimumDeposit.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 109, 105, 110, 105, 109, 117, 109, 95, 100, 101, 112, 111, 115, 105, + 116, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.burnToken.value)), + ], + }); + } + if (!accounts.thisProgram.value) { + accounts.thisProgram.value = + 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.minimumDeposit), + getAccountMeta(accounts.burnToken), + getAccountMeta(accounts.programData), + getAccountMeta(accounts.thisProgram), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getSetMinimumDepositAmountInstructionDataEncoder().encode( + args as SetMinimumDepositAmountInstructionDataArgs + ), + } as SetMinimumDepositAmountInstruction< + TProgramAddress, + TAccountSigner, + TAccountMinimumDeposit, + TAccountBurnToken, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + >; + + return instruction; +} + +export type SetMinimumDepositAmountInput< + TAccountSigner extends string = string, + TAccountMinimumDeposit extends string = string, + TAccountBurnToken extends string = string, + TAccountProgramData extends string = string, + TAccountThisProgram extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + minimumDeposit: Address; + burnToken: Address; + programData: Address; + thisProgram?: Address; + systemProgram?: Address; + amount: SetMinimumDepositAmountInstructionDataArgs['amount']; +}; + +export function getSetMinimumDepositAmountInstruction< + TAccountSigner extends string, + TAccountMinimumDeposit extends string, + TAccountBurnToken extends string, + TAccountProgramData extends string, + TAccountThisProgram extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: SetMinimumDepositAmountInput< + TAccountSigner, + TAccountMinimumDeposit, + TAccountBurnToken, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): SetMinimumDepositAmountInstruction< + TProgramAddress, + TAccountSigner, + TAccountMinimumDeposit, + TAccountBurnToken, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + minimumDeposit: { value: input.minimumDeposit ?? null, isWritable: true }, + burnToken: { value: input.burnToken ?? null, isWritable: false }, + programData: { value: input.programData ?? null, isWritable: false }, + thisProgram: { value: input.thisProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.thisProgram.value) { + accounts.thisProgram.value = + 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.minimumDeposit), + getAccountMeta(accounts.burnToken), + getAccountMeta(accounts.programData), + getAccountMeta(accounts.thisProgram), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getSetMinimumDepositAmountInstructionDataEncoder().encode( + args as SetMinimumDepositAmountInstructionDataArgs + ), + } as SetMinimumDepositAmountInstruction< + TProgramAddress, + TAccountSigner, + TAccountMinimumDeposit, + TAccountBurnToken, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedSetMinimumDepositAmountInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + minimumDeposit: TAccountMetas[1]; + burnToken: TAccountMetas[2]; + programData: TAccountMetas[3]; + thisProgram: TAccountMetas[4]; + systemProgram: TAccountMetas[5]; + }; + data: SetMinimumDepositAmountInstructionData; +}; + +export function parseSetMinimumDepositAmountInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetMinimumDepositAmountInstruction { + if (instruction.accounts.length < 6) { + // 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: { + signer: getNextAccount(), + minimumDeposit: getNextAccount(), + burnToken: getNextAccount(), + programData: getNextAccount(), + thisProgram: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getSetMinimumDepositAmountInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setSigner.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setSigner.ts new file mode 100644 index 000000000..185ebfe5f --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setSigner.ts @@ -0,0 +1,328 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_SIGNER_DISCRIMINATOR = new Uint8Array([ + 127, 120, 252, 184, 97, 4, 88, 68, +]); + +export function getSetSignerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(SET_SIGNER_DISCRIMINATOR); +} + +export type SetSignerInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountProgramData extends string | AccountMeta = string, + TAccountThisProgram extends string | AccountMeta = + 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountState extends string + ? WritableAccount + : TAccountState, + TAccountProgramData extends string + ? ReadonlyAccount + : TAccountProgramData, + TAccountThisProgram extends string + ? ReadonlyAccount + : TAccountThisProgram, + ...TRemainingAccounts, + ] + >; + +export type SetSignerInstructionData = { + discriminator: ReadonlyUint8Array; + newSigner: Address; +}; + +export type SetSignerInstructionDataArgs = { newSigner: Address }; + +export function getSetSignerInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newSigner', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: SET_SIGNER_DISCRIMINATOR }) + ); +} + +export function getSetSignerInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newSigner', getAddressDecoder()], + ]); +} + +export function getSetSignerInstructionDataCodec(): Codec< + SetSignerInstructionDataArgs, + SetSignerInstructionData +> { + return combineCodec( + getSetSignerInstructionDataEncoder(), + getSetSignerInstructionDataDecoder() + ); +} + +export type SetSignerAsyncInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountProgramData extends string = string, + TAccountThisProgram extends string = string, +> = { + signer: TransactionSigner; + state?: Address; + programData: Address; + thisProgram?: Address; + newSigner: SetSignerInstructionDataArgs['newSigner']; +}; + +export async function getSetSignerInstructionAsync< + TAccountSigner extends string, + TAccountState extends string, + TAccountProgramData extends string, + TAccountThisProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: SetSignerAsyncInput< + TAccountSigner, + TAccountState, + TAccountProgramData, + TAccountThisProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + SetSignerInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountProgramData, + TAccountThisProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + programData: { value: input.programData ?? null, isWritable: false }, + thisProgram: { value: input.thisProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.state.value) { + accounts.state.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), + ], + }); + } + if (!accounts.thisProgram.value) { + accounts.thisProgram.value = + 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.programData), + getAccountMeta(accounts.thisProgram), + ], + programAddress, + data: getSetSignerInstructionDataEncoder().encode( + args as SetSignerInstructionDataArgs + ), + } as SetSignerInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountProgramData, + TAccountThisProgram + >; + + return instruction; +} + +export type SetSignerInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountProgramData extends string = string, + TAccountThisProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + programData: Address; + thisProgram?: Address; + newSigner: SetSignerInstructionDataArgs['newSigner']; +}; + +export function getSetSignerInstruction< + TAccountSigner extends string, + TAccountState extends string, + TAccountProgramData extends string, + TAccountThisProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: SetSignerInput< + TAccountSigner, + TAccountState, + TAccountProgramData, + TAccountThisProgram + >, + config?: { programAddress?: TProgramAddress } +): SetSignerInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountProgramData, + TAccountThisProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + programData: { value: input.programData ?? null, isWritable: false }, + thisProgram: { value: input.thisProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.thisProgram.value) { + accounts.thisProgram.value = + 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.programData), + getAccountMeta(accounts.thisProgram), + ], + programAddress, + data: getSetSignerInstructionDataEncoder().encode( + args as SetSignerInstructionDataArgs + ), + } as SetSignerInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountProgramData, + TAccountThisProgram + >; + + return instruction; +} + +export type ParsedSetSignerInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + state: TAccountMetas[1]; + programData: TAccountMetas[2]; + thisProgram: TAccountMetas[3]; + }; + data: SetSignerInstructionData; +}; + +export function parseSetSignerInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetSignerInstruction { + if (instruction.accounts.length < 4) { + // 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: { + signer: getNextAccount(), + state: getNextAccount(), + programData: getNextAccount(), + thisProgram: getNextAccount(), + }, + data: getSetSignerInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/withdrawRentFund.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/withdrawRentFund.ts new file mode 100644 index 000000000..1e07191ec --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/withdrawRentFund.ts @@ -0,0 +1,385 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const WITHDRAW_RENT_FUND_DISCRIMINATOR = new Uint8Array([ + 153, 28, 108, 116, 132, 70, 161, 125, +]); + +export function getWithdrawRentFundDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + WITHDRAW_RENT_FUND_DISCRIMINATOR + ); +} + +export type WithdrawRentFundInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountRentFund extends string | AccountMeta = string, + TAccountRecipient extends string | AccountMeta = string, + TAccountProgramData extends string | AccountMeta = string, + TAccountThisProgram extends string | AccountMeta = + 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountRentFund extends string + ? WritableAccount + : TAccountRentFund, + TAccountRecipient extends string + ? WritableAccount + : TAccountRecipient, + TAccountProgramData extends string + ? ReadonlyAccount + : TAccountProgramData, + TAccountThisProgram extends string + ? ReadonlyAccount + : TAccountThisProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type WithdrawRentFundInstructionData = { + discriminator: ReadonlyUint8Array; + amount: bigint; +}; + +export type WithdrawRentFundInstructionDataArgs = { amount: number | bigint }; + +export function getWithdrawRentFundInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['amount', getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: WITHDRAW_RENT_FUND_DISCRIMINATOR }) + ); +} + +export function getWithdrawRentFundInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['amount', getU64Decoder()], + ]); +} + +export function getWithdrawRentFundInstructionDataCodec(): Codec< + WithdrawRentFundInstructionDataArgs, + WithdrawRentFundInstructionData +> { + return combineCodec( + getWithdrawRentFundInstructionDataEncoder(), + getWithdrawRentFundInstructionDataDecoder() + ); +} + +export type WithdrawRentFundAsyncInput< + TAccountSigner extends string = string, + TAccountRentFund extends string = string, + TAccountRecipient extends string = string, + TAccountProgramData extends string = string, + TAccountThisProgram extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + rentFund?: Address; + recipient: Address; + programData: Address; + thisProgram?: Address; + systemProgram?: Address; + amount: WithdrawRentFundInstructionDataArgs['amount']; +}; + +export async function getWithdrawRentFundInstructionAsync< + TAccountSigner extends string, + TAccountRentFund extends string, + TAccountRecipient extends string, + TAccountProgramData extends string, + TAccountThisProgram extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: WithdrawRentFundAsyncInput< + TAccountSigner, + TAccountRentFund, + TAccountRecipient, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + WithdrawRentFundInstruction< + TProgramAddress, + TAccountSigner, + TAccountRentFund, + TAccountRecipient, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + rentFund: { value: input.rentFund ?? null, isWritable: true }, + recipient: { value: input.recipient ?? null, isWritable: true }, + programData: { value: input.programData ?? null, isWritable: false }, + thisProgram: { value: input.thisProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.rentFund.value) { + accounts.rentFund.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([114, 101, 110, 116, 95, 102, 117, 110, 100]) + ), + ], + }); + } + if (!accounts.thisProgram.value) { + accounts.thisProgram.value = + 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.rentFund), + getAccountMeta(accounts.recipient), + getAccountMeta(accounts.programData), + getAccountMeta(accounts.thisProgram), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getWithdrawRentFundInstructionDataEncoder().encode( + args as WithdrawRentFundInstructionDataArgs + ), + } as WithdrawRentFundInstruction< + TProgramAddress, + TAccountSigner, + TAccountRentFund, + TAccountRecipient, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + >; + + return instruction; +} + +export type WithdrawRentFundInput< + TAccountSigner extends string = string, + TAccountRentFund extends string = string, + TAccountRecipient extends string = string, + TAccountProgramData extends string = string, + TAccountThisProgram extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + rentFund: Address; + recipient: Address; + programData: Address; + thisProgram?: Address; + systemProgram?: Address; + amount: WithdrawRentFundInstructionDataArgs['amount']; +}; + +export function getWithdrawRentFundInstruction< + TAccountSigner extends string, + TAccountRentFund extends string, + TAccountRecipient extends string, + TAccountProgramData extends string, + TAccountThisProgram extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = + typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, +>( + input: WithdrawRentFundInput< + TAccountSigner, + TAccountRentFund, + TAccountRecipient, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): WithdrawRentFundInstruction< + TProgramAddress, + TAccountSigner, + TAccountRentFund, + TAccountRecipient, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + rentFund: { value: input.rentFund ?? null, isWritable: true }, + recipient: { value: input.recipient ?? null, isWritable: true }, + programData: { value: input.programData ?? null, isWritable: false }, + thisProgram: { value: input.thisProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.thisProgram.value) { + accounts.thisProgram.value = + 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.rentFund), + getAccountMeta(accounts.recipient), + getAccountMeta(accounts.programData), + getAccountMeta(accounts.thisProgram), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getWithdrawRentFundInstructionDataEncoder().encode( + args as WithdrawRentFundInstructionDataArgs + ), + } as WithdrawRentFundInstruction< + TProgramAddress, + TAccountSigner, + TAccountRentFund, + TAccountRecipient, + TAccountProgramData, + TAccountThisProgram, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedWithdrawRentFundInstruction< + TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + rentFund: TAccountMetas[1]; + recipient: TAccountMetas[2]; + programData: TAccountMetas[3]; + thisProgram: TAccountMetas[4]; + systemProgram: TAccountMetas[5]; + }; + data: WithdrawRentFundInstructionData; +}; + +export function parseWithdrawRentFundInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedWithdrawRentFundInstruction { + if (instruction.accounts.length < 6) { + // 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: { + signer: getNextAccount(), + rentFund: getNextAccount(), + recipient: getNextAccount(), + programData: getNextAccount(), + thisProgram: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getWithdrawRentFundInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/programs/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/programs/index.ts new file mode 100644 index 000000000..b022681a8 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/programs/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 './sponsoredCctpSrcPeriphery'; diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/programs/sponsoredCctpSrcPeriphery.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/programs/sponsoredCctpSrcPeriphery.ts new file mode 100644 index 000000000..31734df44 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/programs/sponsoredCctpSrcPeriphery.ts @@ -0,0 +1,268 @@ +/** + * 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/kit'; +import { + type ParsedDepositForBurnInstruction, + type ParsedGetUsedNonceCloseInfoInstruction, + type ParsedInitializeInstruction, + type ParsedReclaimEventAccountInstruction, + type ParsedReclaimUsedNonceAccountInstruction, + type ParsedRepayRentFundDebtInstruction, + type ParsedSetCurrentTimeInstruction, + type ParsedSetMinimumDepositAmountInstruction, + type ParsedSetSignerInstruction, + type ParsedWithdrawRentFundInstruction, +} from '../instructions'; + +export const SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS = + 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; + +export enum SponsoredCctpSrcPeripheryAccount { + MessageSent, + MinimumDeposit, + RentClaim, + State, + UsedNonce, +} + +export function identifySponsoredCctpSrcPeripheryAccount( + account: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): SponsoredCctpSrcPeripheryAccount { + const data = 'data' in account ? account.data : account; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([131, 100, 133, 56, 166, 225, 151, 60]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryAccount.MessageSent; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([218, 139, 120, 202, 3, 12, 233, 65]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryAccount.MinimumDeposit; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([13, 5, 183, 82, 60, 122, 72, 11]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryAccount.RentClaim; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([216, 146, 107, 94, 104, 75, 182, 177]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryAccount.State; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([212, 222, 157, 252, 130, 71, 179, 238]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryAccount.UsedNonce; + } + throw new Error( + 'The provided account could not be identified as a sponsoredCctpSrcPeriphery account.' + ); +} + +export enum SponsoredCctpSrcPeripheryInstruction { + DepositForBurn, + GetUsedNonceCloseInfo, + Initialize, + ReclaimEventAccount, + ReclaimUsedNonceAccount, + RepayRentFundDebt, + SetCurrentTime, + SetMinimumDepositAmount, + SetSigner, + WithdrawRentFund, +} + +export function identifySponsoredCctpSrcPeripheryInstruction( + instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): SponsoredCctpSrcPeripheryInstruction { + const data = 'data' in instruction ? instruction.data : instruction; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([215, 60, 61, 46, 114, 55, 128, 176]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryInstruction.DepositForBurn; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([19, 183, 42, 151, 118, 234, 57, 92]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryInstruction.GetUsedNonceCloseInfo; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryInstruction.Initialize; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([94, 198, 180, 159, 131, 236, 15, 174]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryInstruction.ReclaimEventAccount; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([153, 152, 111, 172, 156, 104, 116, 3]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryInstruction.ReclaimUsedNonceAccount; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([111, 95, 222, 174, 241, 41, 61, 78]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryInstruction.RepayRentFundDebt; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([69, 100, 169, 193, 125, 0, 150, 69]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryInstruction.SetCurrentTime; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([176, 4, 74, 229, 206, 148, 151, 138]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryInstruction.SetMinimumDepositAmount; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([127, 120, 252, 184, 97, 4, 88, 68]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryInstruction.SetSigner; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([153, 28, 108, 116, 132, 70, 161, 125]) + ), + 0 + ) + ) { + return SponsoredCctpSrcPeripheryInstruction.WithdrawRentFund; + } + throw new Error( + 'The provided instruction could not be identified as a sponsoredCctpSrcPeriphery instruction.' + ); +} + +export type ParsedSponsoredCctpSrcPeripheryInstruction< + TProgram extends string = 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq', +> = + | ({ + instructionType: SponsoredCctpSrcPeripheryInstruction.DepositForBurn; + } & ParsedDepositForBurnInstruction) + | ({ + instructionType: SponsoredCctpSrcPeripheryInstruction.GetUsedNonceCloseInfo; + } & ParsedGetUsedNonceCloseInfoInstruction) + | ({ + instructionType: SponsoredCctpSrcPeripheryInstruction.Initialize; + } & ParsedInitializeInstruction) + | ({ + instructionType: SponsoredCctpSrcPeripheryInstruction.ReclaimEventAccount; + } & ParsedReclaimEventAccountInstruction) + | ({ + instructionType: SponsoredCctpSrcPeripheryInstruction.ReclaimUsedNonceAccount; + } & ParsedReclaimUsedNonceAccountInstruction) + | ({ + instructionType: SponsoredCctpSrcPeripheryInstruction.RepayRentFundDebt; + } & ParsedRepayRentFundDebtInstruction) + | ({ + instructionType: SponsoredCctpSrcPeripheryInstruction.SetCurrentTime; + } & ParsedSetCurrentTimeInstruction) + | ({ + instructionType: SponsoredCctpSrcPeripheryInstruction.SetMinimumDepositAmount; + } & ParsedSetMinimumDepositAmountInstruction) + | ({ + instructionType: SponsoredCctpSrcPeripheryInstruction.SetSigner; + } & ParsedSetSignerInstruction) + | ({ + instructionType: SponsoredCctpSrcPeripheryInstruction.WithdrawRentFund; + } & ParsedWithdrawRentFundInstruction); diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/shared/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/shared/index.ts new file mode 100644 index 000000000..7ebc26514 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/shared/index.ts @@ -0,0 +1,164 @@ +/** + * 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 { + AccountRole, + isProgramDerivedAddress, + isTransactionSigner as kitIsTransactionSigner, + type AccountMeta, + type AccountSignerMeta, + type Address, + type ProgramDerivedAddress, + type TransactionSigner, + upgradeRoleToSigner, +} from '@solana/kit'; + +/** + * Asserts that the given value is not null or undefined. + * @internal + */ +export function expectSome(value: T | null | undefined): T { + if (value == null) { + throw new Error('Expected a value but received null or undefined.'); + } + return value; +} + +/** + * Asserts that the given value is a PublicKey. + * @internal + */ +export function expectAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): Address { + if (!value) { + throw new Error('Expected a Address.'); + } + if (typeof value === 'object' && 'address' in value) { + return value.address; + } + if (Array.isArray(value)) { + return value[0]; + } + return value as Address; +} + +/** + * Asserts that the given value is a PDA. + * @internal + */ +export function expectProgramDerivedAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): ProgramDerivedAddress { + if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { + throw new Error('Expected a ProgramDerivedAddress.'); + } + return value; +} + +/** + * Asserts that the given value is a TransactionSigner. + * @internal + */ +export function expectTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): TransactionSigner { + if (!value || !isTransactionSigner(value)) { + throw new Error('Expected a TransactionSigner.'); + } + return value; +} + +/** + * Defines an instruction account to resolve. + * @internal + */ +export type ResolvedAccount< + T extends string = string, + U extends + | Address + | ProgramDerivedAddress + | TransactionSigner + | null = + | Address + | ProgramDerivedAddress + | TransactionSigner + | null, +> = { + isWritable: boolean; + value: U; +}; + +/** + * Defines an instruction that stores additional bytes on-chain. + * @internal + */ +export type InstructionWithByteDelta = { + byteDelta: number; +}; + +/** + * Get account metas and signers from resolved accounts. + * @internal + */ +export function getAccountMetaFactory( + programAddress: Address, + optionalAccountStrategy: 'omitted' | 'programId' +) { + return ( + account: ResolvedAccount + ): AccountMeta | AccountSignerMeta | undefined => { + if (!account.value) { + if (optionalAccountStrategy === 'omitted') return; + return Object.freeze({ + address: programAddress, + role: AccountRole.READONLY, + }); + } + + const writableRole = account.isWritable + ? AccountRole.WRITABLE + : AccountRole.READONLY; + return Object.freeze({ + address: expectAddress(account.value), + role: isTransactionSigner(account.value) + ? upgradeRoleToSigner(writableRole) + : writableRole, + ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), + }); + }; +} + +export function isTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner +): value is TransactionSigner { + return ( + !!value && + typeof value === 'object' && + 'address' in value && + kitIsTransactionSigner(value) + ); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/accruedRentFundLiability.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/accruedRentFundLiability.ts new file mode 100644 index 000000000..ee41776c4 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/types/accruedRentFundLiability.ts @@ -0,0 +1,59 @@ +/** + * 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, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type AccruedRentFundLiability = { + user: Address; + amount: bigint; + totalUserClaim: bigint; +}; + +export type AccruedRentFundLiabilityArgs = { + user: Address; + amount: number | bigint; + totalUserClaim: number | bigint; +}; + +export function getAccruedRentFundLiabilityEncoder(): Encoder { + return getStructEncoder([ + ['user', getAddressEncoder()], + ['amount', getU64Encoder()], + ['totalUserClaim', getU64Encoder()], + ]); +} + +export function getAccruedRentFundLiabilityDecoder(): Decoder { + return getStructDecoder([ + ['user', getAddressDecoder()], + ['amount', getU64Decoder()], + ['totalUserClaim', getU64Decoder()], + ]); +} + +export function getAccruedRentFundLiabilityCodec(): Codec< + AccruedRentFundLiabilityArgs, + AccruedRentFundLiability +> { + return combineCodec( + getAccruedRentFundLiabilityEncoder(), + getAccruedRentFundLiabilityDecoder() + ); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/createdEventAccount.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/createdEventAccount.ts new file mode 100644 index 000000000..bcc7959b4 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/types/createdEventAccount.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/kit'; + +export type CreatedEventAccount = { messageSentEventData: Address }; + +export type CreatedEventAccountArgs = CreatedEventAccount; + +export function getCreatedEventAccountEncoder(): Encoder { + return getStructEncoder([['messageSentEventData', getAddressEncoder()]]); +} + +export function getCreatedEventAccountDecoder(): Decoder { + return getStructDecoder([['messageSentEventData', getAddressDecoder()]]); +} + +export function getCreatedEventAccountCodec(): Codec< + CreatedEventAccountArgs, + CreatedEventAccount +> { + return combineCodec( + getCreatedEventAccountEncoder(), + getCreatedEventAccountDecoder() + ); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/index.ts new file mode 100644 index 000000000..e130d5b74 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/types/index.ts @@ -0,0 +1,20 @@ +/** + * 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 './accruedRentFundLiability'; +export * from './createdEventAccount'; +export * from './minimumDepositAmountSet'; +export * from './reclaimedEventAccount'; +export * from './reclaimedUsedNonceAccount'; +export * from './repaidRentFundDebt'; +export * from './signerSet'; +export * from './sponsoredCCTPQuote'; +export * from './sponsoredDepositForBurn'; +export * from './usedNonceAccountParams'; +export * from './usedNonceCloseInfo'; +export * from './withdrawnRentFund'; diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/minimumDepositAmountSet.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/minimumDepositAmountSet.ts new file mode 100644 index 000000000..d19d6d04c --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/types/minimumDepositAmountSet.ts @@ -0,0 +1,52 @@ +/** + * 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, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type MinimumDepositAmountSet = { amount: bigint; burnToken: Address }; + +export type MinimumDepositAmountSetArgs = { + amount: number | bigint; + burnToken: Address; +}; + +export function getMinimumDepositAmountSetEncoder(): Encoder { + return getStructEncoder([ + ['amount', getU64Encoder()], + ['burnToken', getAddressEncoder()], + ]); +} + +export function getMinimumDepositAmountSetDecoder(): Decoder { + return getStructDecoder([ + ['amount', getU64Decoder()], + ['burnToken', getAddressDecoder()], + ]); +} + +export function getMinimumDepositAmountSetCodec(): Codec< + MinimumDepositAmountSetArgs, + MinimumDepositAmountSet +> { + return combineCodec( + getMinimumDepositAmountSetEncoder(), + getMinimumDepositAmountSetDecoder() + ); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedEventAccount.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedEventAccount.ts new file mode 100644 index 000000000..1acb1b219 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedEventAccount.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/kit'; + +export type ReclaimedEventAccount = { messageSentEventData: Address }; + +export type ReclaimedEventAccountArgs = ReclaimedEventAccount; + +export function getReclaimedEventAccountEncoder(): Encoder { + return getStructEncoder([['messageSentEventData', getAddressEncoder()]]); +} + +export function getReclaimedEventAccountDecoder(): Decoder { + return getStructDecoder([['messageSentEventData', getAddressDecoder()]]); +} + +export function getReclaimedEventAccountCodec(): Codec< + ReclaimedEventAccountArgs, + ReclaimedEventAccount +> { + return combineCodec( + getReclaimedEventAccountEncoder(), + getReclaimedEventAccountDecoder() + ); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedUsedNonceAccount.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedUsedNonceAccount.ts new file mode 100644 index 000000000..160ef570e --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedUsedNonceAccount.ts @@ -0,0 +1,57 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export type ReclaimedUsedNonceAccount = { + nonce: ReadonlyUint8Array; + usedNonce: Address; +}; + +export type ReclaimedUsedNonceAccountArgs = ReclaimedUsedNonceAccount; + +export function getReclaimedUsedNonceAccountEncoder(): Encoder { + return getStructEncoder([ + ['nonce', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ['usedNonce', getAddressEncoder()], + ]); +} + +export function getReclaimedUsedNonceAccountDecoder(): Decoder { + return getStructDecoder([ + ['nonce', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ['usedNonce', getAddressDecoder()], + ]); +} + +export function getReclaimedUsedNonceAccountCodec(): Codec< + ReclaimedUsedNonceAccountArgs, + ReclaimedUsedNonceAccount +> { + return combineCodec( + getReclaimedUsedNonceAccountEncoder(), + getReclaimedUsedNonceAccountDecoder() + ); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/repaidRentFundDebt.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/repaidRentFundDebt.ts new file mode 100644 index 000000000..1b4c6ae60 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/types/repaidRentFundDebt.ts @@ -0,0 +1,59 @@ +/** + * 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, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type RepaidRentFundDebt = { + user: Address; + amount: bigint; + remainingUserClaim: bigint; +}; + +export type RepaidRentFundDebtArgs = { + user: Address; + amount: number | bigint; + remainingUserClaim: number | bigint; +}; + +export function getRepaidRentFundDebtEncoder(): Encoder { + return getStructEncoder([ + ['user', getAddressEncoder()], + ['amount', getU64Encoder()], + ['remainingUserClaim', getU64Encoder()], + ]); +} + +export function getRepaidRentFundDebtDecoder(): Decoder { + return getStructDecoder([ + ['user', getAddressDecoder()], + ['amount', getU64Decoder()], + ['remainingUserClaim', getU64Decoder()], + ]); +} + +export function getRepaidRentFundDebtCodec(): Codec< + RepaidRentFundDebtArgs, + RepaidRentFundDebt +> { + return combineCodec( + getRepaidRentFundDebtEncoder(), + getRepaidRentFundDebtDecoder() + ); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/signerSet.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/signerSet.ts new file mode 100644 index 000000000..125210729 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/types/signerSet.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/kit'; + +export type SignerSet = { oldSigner: Address; newSigner: Address }; + +export type SignerSetArgs = SignerSet; + +export function getSignerSetEncoder(): Encoder { + return getStructEncoder([ + ['oldSigner', getAddressEncoder()], + ['newSigner', getAddressEncoder()], + ]); +} + +export function getSignerSetDecoder(): Decoder { + return getStructDecoder([ + ['oldSigner', getAddressDecoder()], + ['newSigner', getAddressDecoder()], + ]); +} + +export function getSignerSetCodec(): Codec { + return combineCodec(getSignerSetEncoder(), getSignerSetDecoder()); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredCCTPQuote.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredCCTPQuote.ts new file mode 100644 index 000000000..4dc544223 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredCCTPQuote.ts @@ -0,0 +1,130 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + getU8Decoder, + getU8Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export type SponsoredCCTPQuote = { + sourceDomain: number; + destinationDomain: number; + mintRecipient: Address; + amount: bigint; + burnToken: Address; + destinationCaller: Address; + maxFee: bigint; + minFinalityThreshold: number; + nonce: ReadonlyUint8Array; + deadline: bigint; + maxBpsToSponsor: bigint; + maxUserSlippageBps: bigint; + finalRecipient: Address; + finalToken: Address; + destinationDex: number; + accountCreationMode: number; + executionMode: number; + actionData: ReadonlyUint8Array; +}; + +export type SponsoredCCTPQuoteArgs = { + sourceDomain: number; + destinationDomain: number; + mintRecipient: Address; + amount: number | bigint; + burnToken: Address; + destinationCaller: Address; + maxFee: number | bigint; + minFinalityThreshold: number; + nonce: ReadonlyUint8Array; + deadline: number | bigint; + maxBpsToSponsor: number | bigint; + maxUserSlippageBps: number | bigint; + finalRecipient: Address; + finalToken: Address; + destinationDex: number; + accountCreationMode: number; + executionMode: number; + actionData: ReadonlyUint8Array; +}; + +export function getSponsoredCCTPQuoteEncoder(): Encoder { + return getStructEncoder([ + ['sourceDomain', getU32Encoder()], + ['destinationDomain', getU32Encoder()], + ['mintRecipient', getAddressEncoder()], + ['amount', getU64Encoder()], + ['burnToken', getAddressEncoder()], + ['destinationCaller', getAddressEncoder()], + ['maxFee', getU64Encoder()], + ['minFinalityThreshold', getU32Encoder()], + ['nonce', fixEncoderSize(getBytesEncoder(), 32)], + ['deadline', getU64Encoder()], + ['maxBpsToSponsor', getU64Encoder()], + ['maxUserSlippageBps', getU64Encoder()], + ['finalRecipient', getAddressEncoder()], + ['finalToken', getAddressEncoder()], + ['destinationDex', getU32Encoder()], + ['accountCreationMode', getU8Encoder()], + ['executionMode', getU8Encoder()], + ['actionData', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]); +} + +export function getSponsoredCCTPQuoteDecoder(): Decoder { + return getStructDecoder([ + ['sourceDomain', getU32Decoder()], + ['destinationDomain', getU32Decoder()], + ['mintRecipient', getAddressDecoder()], + ['amount', getU64Decoder()], + ['burnToken', getAddressDecoder()], + ['destinationCaller', getAddressDecoder()], + ['maxFee', getU64Decoder()], + ['minFinalityThreshold', getU32Decoder()], + ['nonce', fixDecoderSize(getBytesDecoder(), 32)], + ['deadline', getU64Decoder()], + ['maxBpsToSponsor', getU64Decoder()], + ['maxUserSlippageBps', getU64Decoder()], + ['finalRecipient', getAddressDecoder()], + ['finalToken', getAddressDecoder()], + ['destinationDex', getU32Decoder()], + ['accountCreationMode', getU8Decoder()], + ['executionMode', getU8Decoder()], + ['actionData', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getSponsoredCCTPQuoteCodec(): Codec< + SponsoredCCTPQuoteArgs, + SponsoredCCTPQuote +> { + return combineCodec( + getSponsoredCCTPQuoteEncoder(), + getSponsoredCCTPQuoteDecoder() + ); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredDepositForBurn.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredDepositForBurn.ts new file mode 100644 index 000000000..0317ee5ea --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredDepositForBurn.ts @@ -0,0 +1,96 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + getU8Decoder, + getU8Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export type SponsoredDepositForBurn = { + quoteNonce: ReadonlyUint8Array; + originSender: Address; + finalRecipient: Address; + quoteDeadline: bigint; + maxBpsToSponsor: bigint; + maxUserSlippageBps: bigint; + finalToken: Address; + destinationDex: number; + accountCreationMode: number; + signature: ReadonlyUint8Array; +}; + +export type SponsoredDepositForBurnArgs = { + quoteNonce: ReadonlyUint8Array; + originSender: Address; + finalRecipient: Address; + quoteDeadline: number | bigint; + maxBpsToSponsor: number | bigint; + maxUserSlippageBps: number | bigint; + finalToken: Address; + destinationDex: number; + accountCreationMode: number; + signature: ReadonlyUint8Array; +}; + +export function getSponsoredDepositForBurnEncoder(): Encoder { + return getStructEncoder([ + ['quoteNonce', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ['originSender', getAddressEncoder()], + ['finalRecipient', getAddressEncoder()], + ['quoteDeadline', getU64Encoder()], + ['maxBpsToSponsor', getU64Encoder()], + ['maxUserSlippageBps', getU64Encoder()], + ['finalToken', getAddressEncoder()], + ['destinationDex', getU32Encoder()], + ['accountCreationMode', getU8Encoder()], + ['signature', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]); +} + +export function getSponsoredDepositForBurnDecoder(): Decoder { + return getStructDecoder([ + ['quoteNonce', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ['originSender', getAddressDecoder()], + ['finalRecipient', getAddressDecoder()], + ['quoteDeadline', getU64Decoder()], + ['maxBpsToSponsor', getU64Decoder()], + ['maxUserSlippageBps', getU64Decoder()], + ['finalToken', getAddressDecoder()], + ['destinationDex', getU32Decoder()], + ['accountCreationMode', getU8Decoder()], + ['signature', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getSponsoredDepositForBurnCodec(): Codec< + SponsoredDepositForBurnArgs, + SponsoredDepositForBurn +> { + return combineCodec( + getSponsoredDepositForBurnEncoder(), + getSponsoredDepositForBurnDecoder() + ); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceAccountParams.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceAccountParams.ts new file mode 100644 index 000000000..b16705b55 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceAccountParams.ts @@ -0,0 +1,43 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export type UsedNonceAccountParams = { nonce: ReadonlyUint8Array }; + +export type UsedNonceAccountParamsArgs = UsedNonceAccountParams; + +export function getUsedNonceAccountParamsEncoder(): Encoder { + return getStructEncoder([['nonce', fixEncoderSize(getBytesEncoder(), 32)]]); +} + +export function getUsedNonceAccountParamsDecoder(): Decoder { + return getStructDecoder([['nonce', fixDecoderSize(getBytesDecoder(), 32)]]); +} + +export function getUsedNonceAccountParamsCodec(): Codec< + UsedNonceAccountParamsArgs, + UsedNonceAccountParams +> { + return combineCodec( + getUsedNonceAccountParamsEncoder(), + getUsedNonceAccountParamsDecoder() + ); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceCloseInfo.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceCloseInfo.ts new file mode 100644 index 000000000..ebc545fdf --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceCloseInfo.ts @@ -0,0 +1,54 @@ +/** + * 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, + getBooleanDecoder, + getBooleanEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type UsedNonceCloseInfo = { + canCloseAfter: bigint; + canCloseNow: boolean; +}; + +export type UsedNonceCloseInfoArgs = { + canCloseAfter: number | bigint; + canCloseNow: boolean; +}; + +export function getUsedNonceCloseInfoEncoder(): Encoder { + return getStructEncoder([ + ['canCloseAfter', getU64Encoder()], + ['canCloseNow', getBooleanEncoder()], + ]); +} + +export function getUsedNonceCloseInfoDecoder(): Decoder { + return getStructDecoder([ + ['canCloseAfter', getU64Decoder()], + ['canCloseNow', getBooleanDecoder()], + ]); +} + +export function getUsedNonceCloseInfoCodec(): Codec< + UsedNonceCloseInfoArgs, + UsedNonceCloseInfo +> { + return combineCodec( + getUsedNonceCloseInfoEncoder(), + getUsedNonceCloseInfoDecoder() + ); +} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/withdrawnRentFund.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/withdrawnRentFund.ts new file mode 100644 index 000000000..a1837ff44 --- /dev/null +++ b/src/svm/clients/SponsoredCctpSrcPeriphery/types/withdrawnRentFund.ts @@ -0,0 +1,52 @@ +/** + * 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, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type WithdrawnRentFund = { amount: bigint; recipient: Address }; + +export type WithdrawnRentFundArgs = { + amount: number | bigint; + recipient: Address; +}; + +export function getWithdrawnRentFundEncoder(): Encoder { + return getStructEncoder([ + ['amount', getU64Encoder()], + ['recipient', getAddressEncoder()], + ]); +} + +export function getWithdrawnRentFundDecoder(): Decoder { + return getStructDecoder([ + ['amount', getU64Decoder()], + ['recipient', getAddressDecoder()], + ]); +} + +export function getWithdrawnRentFundCodec(): Codec< + WithdrawnRentFundArgs, + WithdrawnRentFund +> { + return combineCodec( + getWithdrawnRentFundEncoder(), + getWithdrawnRentFundDecoder() + ); +} diff --git a/src/svm/clients/SvmSpoke/accounts/claimAccount.ts b/src/svm/clients/SvmSpoke/accounts/claimAccount.ts new file mode 100644 index 000000000..b0d78662b --- /dev/null +++ b/src/svm/clients/SvmSpoke/accounts/claimAccount.ts @@ -0,0 +1,139 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const CLAIM_ACCOUNT_DISCRIMINATOR = new Uint8Array([ + 113, 109, 47, 96, 242, 219, 61, 165, +]); + +export function getClaimAccountDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + CLAIM_ACCOUNT_DISCRIMINATOR + ); +} + +export type ClaimAccount = { + discriminator: ReadonlyUint8Array; + amount: bigint; + initializer: Address; +}; + +export type ClaimAccountArgs = { + amount: number | bigint; + initializer: Address; +}; + +export function getClaimAccountEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['amount', getU64Encoder()], + ['initializer', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: CLAIM_ACCOUNT_DISCRIMINATOR }) + ); +} + +export function getClaimAccountDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['amount', getU64Decoder()], + ['initializer', getAddressDecoder()], + ]); +} + +export function getClaimAccountCodec(): Codec { + return combineCodec(getClaimAccountEncoder(), getClaimAccountDecoder()); +} + +export function decodeClaimAccount( + encodedAccount: EncodedAccount +): Account; +export function decodeClaimAccount( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeClaimAccount( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getClaimAccountDecoder() + ); +} + +export async function fetchClaimAccount( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeClaimAccount(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeClaimAccount( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeClaimAccount(maybeAccount); +} + +export async function fetchAllClaimAccount( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeClaimAccount(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeClaimAccount( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeClaimAccount(maybeAccount)); +} + +export function getClaimAccountSize(): number { + return 48; +} diff --git a/src/svm/clients/SvmSpoke/accounts/executeRelayerRefundLeafParams.ts b/src/svm/clients/SvmSpoke/accounts/executeRelayerRefundLeafParams.ts new file mode 100644 index 000000000..98693aa19 --- /dev/null +++ b/src/svm/clients/SvmSpoke/accounts/executeRelayerRefundLeafParams.ts @@ -0,0 +1,176 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { + getRelayerRefundLeafDecoder, + getRelayerRefundLeafEncoder, + type RelayerRefundLeaf, + type RelayerRefundLeafArgs, +} from '../types'; + +export const EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR = new Uint8Array([ + 192, 59, 93, 9, 171, 77, 28, 250, +]); + +export function getExecuteRelayerRefundLeafParamsDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR + ); +} + +export type ExecuteRelayerRefundLeafParams = { + discriminator: ReadonlyUint8Array; + rootBundleId: number; + relayerRefundLeaf: RelayerRefundLeaf; + proof: Array; +}; + +export type ExecuteRelayerRefundLeafParamsArgs = { + rootBundleId: number; + relayerRefundLeaf: RelayerRefundLeafArgs; + proof: Array; +}; + +export function getExecuteRelayerRefundLeafParamsEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['rootBundleId', getU32Encoder()], + ['relayerRefundLeaf', getRelayerRefundLeafEncoder()], + ['proof', getArrayEncoder(fixEncoderSize(getBytesEncoder(), 32))], + ]), + (value) => ({ + ...value, + discriminator: EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR, + }) + ); +} + +export function getExecuteRelayerRefundLeafParamsDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['rootBundleId', getU32Decoder()], + ['relayerRefundLeaf', getRelayerRefundLeafDecoder()], + ['proof', getArrayDecoder(fixDecoderSize(getBytesDecoder(), 32))], + ]); +} + +export function getExecuteRelayerRefundLeafParamsCodec(): Codec< + ExecuteRelayerRefundLeafParamsArgs, + ExecuteRelayerRefundLeafParams +> { + return combineCodec( + getExecuteRelayerRefundLeafParamsEncoder(), + getExecuteRelayerRefundLeafParamsDecoder() + ); +} + +export function decodeExecuteRelayerRefundLeafParams< + TAddress extends string = string, +>( + encodedAccount: EncodedAccount +): Account; +export function decodeExecuteRelayerRefundLeafParams< + TAddress extends string = string, +>( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeExecuteRelayerRefundLeafParams< + TAddress extends string = string, +>( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getExecuteRelayerRefundLeafParamsDecoder() + ); +} + +export async function fetchExecuteRelayerRefundLeafParams< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeExecuteRelayerRefundLeafParams( + rpc, + address, + config + ); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeExecuteRelayerRefundLeafParams< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeExecuteRelayerRefundLeafParams(maybeAccount); +} + +export async function fetchAllExecuteRelayerRefundLeafParams( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeExecuteRelayerRefundLeafParams( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeExecuteRelayerRefundLeafParams( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeExecuteRelayerRefundLeafParams(maybeAccount) + ); +} diff --git a/src/svm/clients/SvmSpoke/accounts/executeSlowRelayLeafParams.ts b/src/svm/clients/SvmSpoke/accounts/executeSlowRelayLeafParams.ts new file mode 100644 index 000000000..e1d990ac0 --- /dev/null +++ b/src/svm/clients/SvmSpoke/accounts/executeSlowRelayLeafParams.ts @@ -0,0 +1,176 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { + getSlowFillDecoder, + getSlowFillEncoder, + type SlowFill, + type SlowFillArgs, +} from '../types'; + +export const EXECUTE_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR = new Uint8Array([ + 135, 208, 119, 251, 14, 222, 66, 155, +]); + +export function getExecuteSlowRelayLeafParamsDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + EXECUTE_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR + ); +} + +export type ExecuteSlowRelayLeafParams = { + discriminator: ReadonlyUint8Array; + slowFillLeaf: SlowFill; + rootBundleId: number; + proof: Array; +}; + +export type ExecuteSlowRelayLeafParamsArgs = { + slowFillLeaf: SlowFillArgs; + rootBundleId: number; + proof: Array; +}; + +export function getExecuteSlowRelayLeafParamsEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['slowFillLeaf', getSlowFillEncoder()], + ['rootBundleId', getU32Encoder()], + ['proof', getArrayEncoder(fixEncoderSize(getBytesEncoder(), 32))], + ]), + (value) => ({ + ...value, + discriminator: EXECUTE_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR, + }) + ); +} + +export function getExecuteSlowRelayLeafParamsDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['slowFillLeaf', getSlowFillDecoder()], + ['rootBundleId', getU32Decoder()], + ['proof', getArrayDecoder(fixDecoderSize(getBytesDecoder(), 32))], + ]); +} + +export function getExecuteSlowRelayLeafParamsCodec(): Codec< + ExecuteSlowRelayLeafParamsArgs, + ExecuteSlowRelayLeafParams +> { + return combineCodec( + getExecuteSlowRelayLeafParamsEncoder(), + getExecuteSlowRelayLeafParamsDecoder() + ); +} + +export function decodeExecuteSlowRelayLeafParams< + TAddress extends string = string, +>( + encodedAccount: EncodedAccount +): Account; +export function decodeExecuteSlowRelayLeafParams< + TAddress extends string = string, +>( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeExecuteSlowRelayLeafParams< + TAddress extends string = string, +>( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getExecuteSlowRelayLeafParamsDecoder() + ); +} + +export async function fetchExecuteSlowRelayLeafParams< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeExecuteSlowRelayLeafParams( + rpc, + address, + config + ); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeExecuteSlowRelayLeafParams< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeExecuteSlowRelayLeafParams(maybeAccount); +} + +export async function fetchAllExecuteSlowRelayLeafParams( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeExecuteSlowRelayLeafParams( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeExecuteSlowRelayLeafParams( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeExecuteSlowRelayLeafParams(maybeAccount) + ); +} diff --git a/src/svm/clients/SvmSpoke/accounts/fillRelayParams.ts b/src/svm/clients/SvmSpoke/accounts/fillRelayParams.ts new file mode 100644 index 000000000..8f7361e3e --- /dev/null +++ b/src/svm/clients/SvmSpoke/accounts/fillRelayParams.ts @@ -0,0 +1,158 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { + getRelayDataDecoder, + getRelayDataEncoder, + type RelayData, + type RelayDataArgs, +} from '../types'; + +export const FILL_RELAY_PARAMS_DISCRIMINATOR = new Uint8Array([ + 50, 243, 51, 185, 89, 60, 43, 202, +]); + +export function getFillRelayParamsDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + FILL_RELAY_PARAMS_DISCRIMINATOR + ); +} + +export type FillRelayParams = { + discriminator: ReadonlyUint8Array; + relayData: RelayData; + repaymentChainId: bigint; + repaymentAddress: Address; +}; + +export type FillRelayParamsArgs = { + relayData: RelayDataArgs; + repaymentChainId: number | bigint; + repaymentAddress: Address; +}; + +export function getFillRelayParamsEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['relayData', getRelayDataEncoder()], + ['repaymentChainId', getU64Encoder()], + ['repaymentAddress', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: FILL_RELAY_PARAMS_DISCRIMINATOR }) + ); +} + +export function getFillRelayParamsDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['relayData', getRelayDataDecoder()], + ['repaymentChainId', getU64Decoder()], + ['repaymentAddress', getAddressDecoder()], + ]); +} + +export function getFillRelayParamsCodec(): Codec< + FillRelayParamsArgs, + FillRelayParams +> { + return combineCodec(getFillRelayParamsEncoder(), getFillRelayParamsDecoder()); +} + +export function decodeFillRelayParams( + encodedAccount: EncodedAccount +): Account; +export function decodeFillRelayParams( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeFillRelayParams( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getFillRelayParamsDecoder() + ); +} + +export async function fetchFillRelayParams( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeFillRelayParams(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeFillRelayParams< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeFillRelayParams(maybeAccount); +} + +export async function fetchAllFillRelayParams( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeFillRelayParams( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeFillRelayParams( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeFillRelayParams(maybeAccount) + ); +} diff --git a/src/svm/clients/SvmSpoke/accounts/fillStatusAccount.ts b/src/svm/clients/SvmSpoke/accounts/fillStatusAccount.ts new file mode 100644 index 000000000..b6041d81e --- /dev/null +++ b/src/svm/clients/SvmSpoke/accounts/fillStatusAccount.ts @@ -0,0 +1,165 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { + getFillStatusDecoder, + getFillStatusEncoder, + type FillStatus, + type FillStatusArgs, +} from '../types'; + +export const FILL_STATUS_ACCOUNT_DISCRIMINATOR = new Uint8Array([ + 105, 89, 88, 35, 24, 147, 178, 137, +]); + +export function getFillStatusAccountDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + FILL_STATUS_ACCOUNT_DISCRIMINATOR + ); +} + +export type FillStatusAccount = { + discriminator: ReadonlyUint8Array; + status: FillStatus; + relayer: Address; + fillDeadline: number; +}; + +export type FillStatusAccountArgs = { + status: FillStatusArgs; + relayer: Address; + fillDeadline: number; +}; + +export function getFillStatusAccountEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['status', getFillStatusEncoder()], + ['relayer', getAddressEncoder()], + ['fillDeadline', getU32Encoder()], + ]), + (value) => ({ ...value, discriminator: FILL_STATUS_ACCOUNT_DISCRIMINATOR }) + ); +} + +export function getFillStatusAccountDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['status', getFillStatusDecoder()], + ['relayer', getAddressDecoder()], + ['fillDeadline', getU32Decoder()], + ]); +} + +export function getFillStatusAccountCodec(): Codec< + FillStatusAccountArgs, + FillStatusAccount +> { + return combineCodec( + getFillStatusAccountEncoder(), + getFillStatusAccountDecoder() + ); +} + +export function decodeFillStatusAccount( + encodedAccount: EncodedAccount +): Account; +export function decodeFillStatusAccount( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeFillStatusAccount( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getFillStatusAccountDecoder() + ); +} + +export async function fetchFillStatusAccount( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeFillStatusAccount(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeFillStatusAccount< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeFillStatusAccount(maybeAccount); +} + +export async function fetchAllFillStatusAccount( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeFillStatusAccount( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeFillStatusAccount( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeFillStatusAccount(maybeAccount) + ); +} + +export function getFillStatusAccountSize(): number { + return 45; +} diff --git a/src/svm/clients/SvmSpoke/accounts/index.ts b/src/svm/clients/SvmSpoke/accounts/index.ts new file mode 100644 index 000000000..4bfae2afd --- /dev/null +++ b/src/svm/clients/SvmSpoke/accounts/index.ts @@ -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. + * + * @see https://github.com/codama-idl/codama + */ + +export * from './claimAccount'; +export * from './executeRelayerRefundLeafParams'; +export * from './executeSlowRelayLeafParams'; +export * from './fillRelayParams'; +export * from './fillStatusAccount'; +export * from './requestSlowFillParams'; +export * from './rootBundle'; +export * from './state'; +export * from './transferLiability'; diff --git a/src/svm/clients/SvmSpoke/accounts/requestSlowFillParams.ts b/src/svm/clients/SvmSpoke/accounts/requestSlowFillParams.ts new file mode 100644 index 000000000..98cb2d075 --- /dev/null +++ b/src/svm/clients/SvmSpoke/accounts/requestSlowFillParams.ts @@ -0,0 +1,156 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { + getRelayDataDecoder, + getRelayDataEncoder, + type RelayData, + type RelayDataArgs, +} from '../types'; + +export const REQUEST_SLOW_FILL_PARAMS_DISCRIMINATOR = new Uint8Array([ + 5, 54, 214, 89, 197, 37, 118, 28, +]); + +export function getRequestSlowFillParamsDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REQUEST_SLOW_FILL_PARAMS_DISCRIMINATOR + ); +} + +export type RequestSlowFillParams = { + discriminator: ReadonlyUint8Array; + relayData: RelayData; +}; + +export type RequestSlowFillParamsArgs = { relayData: RelayDataArgs }; + +export function getRequestSlowFillParamsEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['relayData', getRelayDataEncoder()], + ]), + (value) => ({ + ...value, + discriminator: REQUEST_SLOW_FILL_PARAMS_DISCRIMINATOR, + }) + ); +} + +export function getRequestSlowFillParamsDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['relayData', getRelayDataDecoder()], + ]); +} + +export function getRequestSlowFillParamsCodec(): Codec< + RequestSlowFillParamsArgs, + RequestSlowFillParams +> { + return combineCodec( + getRequestSlowFillParamsEncoder(), + getRequestSlowFillParamsDecoder() + ); +} + +export function decodeRequestSlowFillParams( + encodedAccount: EncodedAccount +): Account; +export function decodeRequestSlowFillParams( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeRequestSlowFillParams( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getRequestSlowFillParamsDecoder() + ); +} + +export async function fetchRequestSlowFillParams< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeRequestSlowFillParams( + rpc, + address, + config + ); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeRequestSlowFillParams< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeRequestSlowFillParams(maybeAccount); +} + +export async function fetchAllRequestSlowFillParams( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeRequestSlowFillParams( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeRequestSlowFillParams( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeRequestSlowFillParams(maybeAccount) + ); +} diff --git a/src/svm/clients/SvmSpoke/accounts/rootBundle.ts b/src/svm/clients/SvmSpoke/accounts/rootBundle.ts new file mode 100644 index 000000000..cdcf37171 --- /dev/null +++ b/src/svm/clients/SvmSpoke/accounts/rootBundle.ts @@ -0,0 +1,140 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const ROOT_BUNDLE_DISCRIMINATOR = new Uint8Array([ + 66, 221, 214, 231, 25, 222, 184, 219, +]); + +export function getRootBundleDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(ROOT_BUNDLE_DISCRIMINATOR); +} + +export type RootBundle = { + discriminator: ReadonlyUint8Array; + relayerRefundRoot: ReadonlyUint8Array; + slowRelayRoot: ReadonlyUint8Array; + claimedBitmap: ReadonlyUint8Array; +}; + +export type RootBundleArgs = { + relayerRefundRoot: ReadonlyUint8Array; + slowRelayRoot: ReadonlyUint8Array; + claimedBitmap: ReadonlyUint8Array; +}; + +export function getRootBundleEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['relayerRefundRoot', fixEncoderSize(getBytesEncoder(), 32)], + ['slowRelayRoot', fixEncoderSize(getBytesEncoder(), 32)], + [ + 'claimedBitmap', + addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), + ], + ]), + (value) => ({ ...value, discriminator: ROOT_BUNDLE_DISCRIMINATOR }) + ); +} + +export function getRootBundleDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['relayerRefundRoot', fixDecoderSize(getBytesDecoder(), 32)], + ['slowRelayRoot', fixDecoderSize(getBytesDecoder(), 32)], + ['claimedBitmap', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getRootBundleCodec(): Codec { + return combineCodec(getRootBundleEncoder(), getRootBundleDecoder()); +} + +export function decodeRootBundle( + encodedAccount: EncodedAccount +): Account; +export function decodeRootBundle( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeRootBundle( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getRootBundleDecoder() + ); +} + +export async function fetchRootBundle( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeRootBundle(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeRootBundle( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeRootBundle(maybeAccount); +} + +export async function fetchAllRootBundle( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeRootBundle(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeRootBundle( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeRootBundle(maybeAccount)); +} diff --git a/src/svm/clients/SvmSpoke/accounts/state.ts b/src/svm/clients/SvmSpoke/accounts/state.ts new file mode 100644 index 000000000..d25efa33d --- /dev/null +++ b/src/svm/clients/SvmSpoke/accounts/state.ts @@ -0,0 +1,181 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBooleanDecoder, + getBooleanEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const STATE_DISCRIMINATOR = new Uint8Array([ + 216, 146, 107, 94, 104, 75, 182, 177, +]); + +export function getStateDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(STATE_DISCRIMINATOR); +} + +export type State = { + discriminator: ReadonlyUint8Array; + pausedDeposits: boolean; + pausedFills: boolean; + owner: Address; + seed: bigint; + numberOfDeposits: number; + chainId: bigint; + currentTime: number; + remoteDomain: number; + crossDomainAdmin: Address; + rootBundleId: number; + depositQuoteTimeBuffer: number; + fillDeadlineBuffer: number; +}; + +export type StateArgs = { + pausedDeposits: boolean; + pausedFills: boolean; + owner: Address; + seed: number | bigint; + numberOfDeposits: number; + chainId: number | bigint; + currentTime: number; + remoteDomain: number; + crossDomainAdmin: Address; + rootBundleId: number; + depositQuoteTimeBuffer: number; + fillDeadlineBuffer: number; +}; + +export function getStateEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['pausedDeposits', getBooleanEncoder()], + ['pausedFills', getBooleanEncoder()], + ['owner', getAddressEncoder()], + ['seed', getU64Encoder()], + ['numberOfDeposits', getU32Encoder()], + ['chainId', getU64Encoder()], + ['currentTime', getU32Encoder()], + ['remoteDomain', getU32Encoder()], + ['crossDomainAdmin', getAddressEncoder()], + ['rootBundleId', getU32Encoder()], + ['depositQuoteTimeBuffer', getU32Encoder()], + ['fillDeadlineBuffer', getU32Encoder()], + ]), + (value) => ({ ...value, discriminator: STATE_DISCRIMINATOR }) + ); +} + +export function getStateDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['pausedDeposits', getBooleanDecoder()], + ['pausedFills', getBooleanDecoder()], + ['owner', getAddressDecoder()], + ['seed', getU64Decoder()], + ['numberOfDeposits', getU32Decoder()], + ['chainId', getU64Decoder()], + ['currentTime', getU32Decoder()], + ['remoteDomain', getU32Decoder()], + ['crossDomainAdmin', getAddressDecoder()], + ['rootBundleId', getU32Decoder()], + ['depositQuoteTimeBuffer', getU32Decoder()], + ['fillDeadlineBuffer', getU32Decoder()], + ]); +} + +export function getStateCodec(): Codec { + return combineCodec(getStateEncoder(), getStateDecoder()); +} + +export function decodeState( + encodedAccount: EncodedAccount +): Account; +export function decodeState( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeState( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getStateDecoder() + ); +} + +export async function fetchState( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeState(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeState( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeState(maybeAccount); +} + +export async function fetchAllState( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeState(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeState( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeState(maybeAccount)); +} + +export function getStateSize(): number { + return 114; +} diff --git a/src/svm/clients/SvmSpoke/accounts/transferLiability.ts b/src/svm/clients/SvmSpoke/accounts/transferLiability.ts new file mode 100644 index 000000000..d604c5882 --- /dev/null +++ b/src/svm/clients/SvmSpoke/accounts/transferLiability.ts @@ -0,0 +1,147 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const TRANSFER_LIABILITY_DISCRIMINATOR = new Uint8Array([ + 157, 137, 86, 109, 206, 241, 183, 79, +]); + +export function getTransferLiabilityDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + TRANSFER_LIABILITY_DISCRIMINATOR + ); +} + +export type TransferLiability = { + discriminator: ReadonlyUint8Array; + pendingToHubPool: bigint; +}; + +export type TransferLiabilityArgs = { pendingToHubPool: number | bigint }; + +export function getTransferLiabilityEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['pendingToHubPool', getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: TRANSFER_LIABILITY_DISCRIMINATOR }) + ); +} + +export function getTransferLiabilityDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['pendingToHubPool', getU64Decoder()], + ]); +} + +export function getTransferLiabilityCodec(): Codec< + TransferLiabilityArgs, + TransferLiability +> { + return combineCodec( + getTransferLiabilityEncoder(), + getTransferLiabilityDecoder() + ); +} + +export function decodeTransferLiability( + encodedAccount: EncodedAccount +): Account; +export function decodeTransferLiability( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeTransferLiability( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getTransferLiabilityDecoder() + ); +} + +export async function fetchTransferLiability( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeTransferLiability(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeTransferLiability< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeTransferLiability(maybeAccount); +} + +export async function fetchAllTransferLiability( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeTransferLiability( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeTransferLiability( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeTransferLiability(maybeAccount) + ); +} + +export function getTransferLiabilitySize(): number { + return 16; +} diff --git a/src/svm/clients/SvmSpoke/errors/index.ts b/src/svm/clients/SvmSpoke/errors/index.ts new file mode 100644 index 000000000..90c874042 --- /dev/null +++ b/src/svm/clients/SvmSpoke/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 './svmSpoke'; diff --git a/src/svm/clients/SvmSpoke/errors/svmSpoke.ts b/src/svm/clients/SvmSpoke/errors/svmSpoke.ts new file mode 100644 index 000000000..0e7c48def --- /dev/null +++ b/src/svm/clients/SvmSpoke/errors/svmSpoke.ts @@ -0,0 +1,112 @@ +/** + * 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/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; + +/** InvalidQuoteTimestamp: Invalid quote timestamp! */ +export const SVM_SPOKE_ERROR__INVALID_QUOTE_TIMESTAMP = 0x1770; // 6000 +/** InvalidFillDeadline: Invalid fill deadline! */ +export const SVM_SPOKE_ERROR__INVALID_FILL_DEADLINE = 0x1771; // 6001 +/** NotExclusiveRelayer: Caller is not the exclusive relayer and exclusivity deadline has not passed! */ +export const SVM_SPOKE_ERROR__NOT_EXCLUSIVE_RELAYER = 0x1772; // 6002 +/** NoSlowFillsInExclusivityWindow: The Deposit is still within the exclusivity window! */ +export const SVM_SPOKE_ERROR__NO_SLOW_FILLS_IN_EXCLUSIVITY_WINDOW = 0x1773; // 6003 +/** RelayFilled: The relay has already been filled! */ +export const SVM_SPOKE_ERROR__RELAY_FILLED = 0x1774; // 6004 +/** InvalidSlowFillRequest: Slow fill requires status of Unfilled! */ +export const SVM_SPOKE_ERROR__INVALID_SLOW_FILL_REQUEST = 0x1775; // 6005 +/** ExpiredFillDeadline: The fill deadline has passed! */ +export const SVM_SPOKE_ERROR__EXPIRED_FILL_DEADLINE = 0x1776; // 6006 +/** InvalidMerkleProof: Invalid Merkle proof! */ +export const SVM_SPOKE_ERROR__INVALID_MERKLE_PROOF = 0x1777; // 6007 +/** InvalidChainId: Invalid chain id! */ +export const SVM_SPOKE_ERROR__INVALID_CHAIN_ID = 0x1778; // 6008 +/** InvalidMerkleLeaf: Invalid Merkle leaf! */ +export const SVM_SPOKE_ERROR__INVALID_MERKLE_LEAF = 0x1779; // 6009 +/** ClaimedMerkleLeaf: Leaf already claimed! */ +export const SVM_SPOKE_ERROR__CLAIMED_MERKLE_LEAF = 0x177a; // 6010 +/** DepositsArePaused: Deposits are currently paused! */ +export const SVM_SPOKE_ERROR__DEPOSITS_ARE_PAUSED = 0x177b; // 6011 +/** FillsArePaused: Fills are currently paused! */ +export const SVM_SPOKE_ERROR__FILLS_ARE_PAUSED = 0x177c; // 6012 +/** InsufficientSpokePoolBalanceToExecuteLeaf: Insufficient spoke pool balance to execute leaf */ +export const SVM_SPOKE_ERROR__INSUFFICIENT_SPOKE_POOL_BALANCE_TO_EXECUTE_LEAF = 0x177d; // 6013 +/** InvalidExclusiveRelayer: Invalid exclusive relayer! */ +export const SVM_SPOKE_ERROR__INVALID_EXCLUSIVE_RELAYER = 0x177e; // 6014 +/** InvalidOutputToken: Invalid output token! */ +export const SVM_SPOKE_ERROR__INVALID_OUTPUT_TOKEN = 0x177f; // 6015 + +export type SvmSpokeError = + | typeof SVM_SPOKE_ERROR__CLAIMED_MERKLE_LEAF + | typeof SVM_SPOKE_ERROR__DEPOSITS_ARE_PAUSED + | typeof SVM_SPOKE_ERROR__EXPIRED_FILL_DEADLINE + | typeof SVM_SPOKE_ERROR__FILLS_ARE_PAUSED + | typeof SVM_SPOKE_ERROR__INSUFFICIENT_SPOKE_POOL_BALANCE_TO_EXECUTE_LEAF + | typeof SVM_SPOKE_ERROR__INVALID_CHAIN_ID + | typeof SVM_SPOKE_ERROR__INVALID_EXCLUSIVE_RELAYER + | typeof SVM_SPOKE_ERROR__INVALID_FILL_DEADLINE + | typeof SVM_SPOKE_ERROR__INVALID_MERKLE_LEAF + | typeof SVM_SPOKE_ERROR__INVALID_MERKLE_PROOF + | typeof SVM_SPOKE_ERROR__INVALID_OUTPUT_TOKEN + | typeof SVM_SPOKE_ERROR__INVALID_QUOTE_TIMESTAMP + | typeof SVM_SPOKE_ERROR__INVALID_SLOW_FILL_REQUEST + | typeof SVM_SPOKE_ERROR__NO_SLOW_FILLS_IN_EXCLUSIVITY_WINDOW + | typeof SVM_SPOKE_ERROR__NOT_EXCLUSIVE_RELAYER + | typeof SVM_SPOKE_ERROR__RELAY_FILLED; + +let svmSpokeErrorMessages: Record | undefined; +if (process.env.NODE_ENV !== 'production') { + svmSpokeErrorMessages = { + [SVM_SPOKE_ERROR__CLAIMED_MERKLE_LEAF]: `Leaf already claimed!`, + [SVM_SPOKE_ERROR__DEPOSITS_ARE_PAUSED]: `Deposits are currently paused!`, + [SVM_SPOKE_ERROR__EXPIRED_FILL_DEADLINE]: `The fill deadline has passed!`, + [SVM_SPOKE_ERROR__FILLS_ARE_PAUSED]: `Fills are currently paused!`, + [SVM_SPOKE_ERROR__INSUFFICIENT_SPOKE_POOL_BALANCE_TO_EXECUTE_LEAF]: `Insufficient spoke pool balance to execute leaf`, + [SVM_SPOKE_ERROR__INVALID_CHAIN_ID]: `Invalid chain id!`, + [SVM_SPOKE_ERROR__INVALID_EXCLUSIVE_RELAYER]: `Invalid exclusive relayer!`, + [SVM_SPOKE_ERROR__INVALID_FILL_DEADLINE]: `Invalid fill deadline!`, + [SVM_SPOKE_ERROR__INVALID_MERKLE_LEAF]: `Invalid Merkle leaf!`, + [SVM_SPOKE_ERROR__INVALID_MERKLE_PROOF]: `Invalid Merkle proof!`, + [SVM_SPOKE_ERROR__INVALID_OUTPUT_TOKEN]: `Invalid output token!`, + [SVM_SPOKE_ERROR__INVALID_QUOTE_TIMESTAMP]: `Invalid quote timestamp!`, + [SVM_SPOKE_ERROR__INVALID_SLOW_FILL_REQUEST]: `Slow fill requires status of Unfilled!`, + [SVM_SPOKE_ERROR__NO_SLOW_FILLS_IN_EXCLUSIVITY_WINDOW]: `The Deposit is still within the exclusivity window!`, + [SVM_SPOKE_ERROR__NOT_EXCLUSIVE_RELAYER]: `Caller is not the exclusive relayer and exclusivity deadline has not passed!`, + [SVM_SPOKE_ERROR__RELAY_FILLED]: `The relay has already been filled!`, + }; +} + +export function getSvmSpokeErrorMessage(code: SvmSpokeError): string { + if (process.env.NODE_ENV !== 'production') { + return (svmSpokeErrorMessages as Record)[code]; + } + + return 'Error message not available in production bundles.'; +} + +export function isSvmSpokeError( + error: unknown, + transactionMessage: { + instructions: Record; + }, + code?: TProgramErrorCode +): error is SolanaError & + Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { + return isProgramError( + error, + transactionMessage, + SVM_SPOKE_PROGRAM_ADDRESS, + code + ); +} diff --git a/src/svm/clients/SvmSpoke/index.ts b/src/svm/clients/SvmSpoke/index.ts new file mode 100644 index 000000000..02964a6ae --- /dev/null +++ b/src/svm/clients/SvmSpoke/index.ts @@ -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. + * + * @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/src/svm/clients/SvmSpoke/instructions/bridgeTokensToHubPool.ts b/src/svm/clients/SvmSpoke/instructions/bridgeTokensToHubPool.ts new file mode 100644 index 000000000..57c023984 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/bridgeTokensToHubPool.ts @@ -0,0 +1,800 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const BRIDGE_TOKENS_TO_HUB_POOL_DISCRIMINATOR = new Uint8Array([ + 1, 83, 255, 59, 232, 55, 64, 216, +]); + +export function getBridgeTokensToHubPoolDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + BRIDGE_TOKENS_TO_HUB_POOL_DISCRIMINATOR + ); +} + +export type BridgeTokensToHubPoolInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountPayer extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountTransferLiability extends string | AccountMeta = string, + TAccountVault extends string | AccountMeta = string, + TAccountTokenMessengerMinterSenderAuthority extends + | string + | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountRemoteTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountCctpEventAuthority extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TAccountMessageTransmitterProgram extends string | AccountMeta = + 'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd', + TAccountTokenMessengerMinterProgram extends string | AccountMeta = + 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3', + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountMint extends string + ? WritableAccount + : TAccountMint, + TAccountState extends string + ? ReadonlyAccount + : TAccountState, + TAccountTransferLiability extends string + ? WritableAccount + : TAccountTransferLiability, + TAccountVault extends string + ? WritableAccount + : TAccountVault, + TAccountTokenMessengerMinterSenderAuthority extends string + ? ReadonlyAccount + : TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountRemoteTokenMessenger extends string + ? ReadonlyAccount + : TAccountRemoteTokenMessenger, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountCctpEventAuthority extends string + ? ReadonlyAccount + : TAccountCctpEventAuthority, + TAccountMessageSentEventData extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountMessageSentEventData, + TAccountMessageTransmitterProgram extends string + ? ReadonlyAccount + : TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram extends string + ? ReadonlyAccount + : TAccountTokenMessengerMinterProgram, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type BridgeTokensToHubPoolInstructionData = { + discriminator: ReadonlyUint8Array; + amount: bigint; +}; + +export type BridgeTokensToHubPoolInstructionDataArgs = { + amount: number | bigint; +}; + +export function getBridgeTokensToHubPoolInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['amount', getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: BRIDGE_TOKENS_TO_HUB_POOL_DISCRIMINATOR, + }) + ); +} + +export function getBridgeTokensToHubPoolInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['amount', getU64Decoder()], + ]); +} + +export function getBridgeTokensToHubPoolInstructionDataCodec(): Codec< + BridgeTokensToHubPoolInstructionDataArgs, + BridgeTokensToHubPoolInstructionData +> { + return combineCodec( + getBridgeTokensToHubPoolInstructionDataEncoder(), + getBridgeTokensToHubPoolInstructionDataDecoder() + ); +} + +export type BridgeTokensToHubPoolAsyncInput< + TAccountSigner extends string = string, + TAccountPayer extends string = string, + TAccountMint extends string = string, + TAccountState extends string = string, + TAccountTransferLiability extends string = string, + TAccountVault extends string = string, + TAccountTokenMessengerMinterSenderAuthority extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountCctpEventAuthority extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + payer: TransactionSigner; + mint: Address; + state: Address; + transferLiability?: Address; + vault?: Address; + tokenMessengerMinterSenderAuthority: Address; + messageTransmitter: Address; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken: Address; + cctpEventAuthority: Address; + messageSentEventData: TransactionSigner; + messageTransmitterProgram?: Address; + tokenMessengerMinterProgram?: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + amount: BridgeTokensToHubPoolInstructionDataArgs['amount']; +}; + +export async function getBridgeTokensToHubPoolInstructionAsync< + TAccountSigner extends string, + TAccountPayer extends string, + TAccountMint extends string, + TAccountState extends string, + TAccountTransferLiability extends string, + TAccountVault extends string, + TAccountTokenMessengerMinterSenderAuthority extends string, + TAccountMessageTransmitter extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountCctpEventAuthority extends string, + TAccountMessageSentEventData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: BridgeTokensToHubPoolAsyncInput< + TAccountSigner, + TAccountPayer, + TAccountMint, + TAccountState, + TAccountTransferLiability, + TAccountVault, + TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCctpEventAuthority, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + BridgeTokensToHubPoolInstruction< + TProgramAddress, + TAccountSigner, + TAccountPayer, + TAccountMint, + TAccountState, + TAccountTransferLiability, + TAccountVault, + TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCctpEventAuthority, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + payer: { value: input.payer ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: false }, + transferLiability: { + value: input.transferLiability ?? null, + isWritable: true, + }, + vault: { value: input.vault ?? null, isWritable: true }, + tokenMessengerMinterSenderAuthority: { + value: input.tokenMessengerMinterSenderAuthority ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + cctpEventAuthority: { + value: input.cctpEventAuthority ?? null, + isWritable: false, + }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.transferLiability.value) { + accounts.transferLiability.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 116, 114, 97, 110, 115, 102, 101, 114, 95, 108, 105, 97, 98, 105, + 108, 105, 116, 121, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.vault.value) { + accounts.vault.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getAddressEncoder().encode(expectAddress(accounts.state.value)), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.messageTransmitterProgram.value) { + accounts.messageTransmitterProgram.value = + 'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd' as Address<'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd'>; + } + if (!accounts.tokenMessengerMinterProgram.value) { + accounts.tokenMessengerMinterProgram.value = + 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3' as Address<'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.payer), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.state), + getAccountMeta(accounts.transferLiability), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.tokenMessengerMinterSenderAuthority), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.cctpEventAuthority), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getBridgeTokensToHubPoolInstructionDataEncoder().encode( + args as BridgeTokensToHubPoolInstructionDataArgs + ), + } as BridgeTokensToHubPoolInstruction< + TProgramAddress, + TAccountSigner, + TAccountPayer, + TAccountMint, + TAccountState, + TAccountTransferLiability, + TAccountVault, + TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCctpEventAuthority, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type BridgeTokensToHubPoolInput< + TAccountSigner extends string = string, + TAccountPayer extends string = string, + TAccountMint extends string = string, + TAccountState extends string = string, + TAccountTransferLiability extends string = string, + TAccountVault extends string = string, + TAccountTokenMessengerMinterSenderAuthority extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountCctpEventAuthority extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + payer: TransactionSigner; + mint: Address; + state: Address; + transferLiability: Address; + vault: Address; + tokenMessengerMinterSenderAuthority: Address; + messageTransmitter: Address; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken: Address; + cctpEventAuthority: Address; + messageSentEventData: TransactionSigner; + messageTransmitterProgram?: Address; + tokenMessengerMinterProgram?: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + amount: BridgeTokensToHubPoolInstructionDataArgs['amount']; +}; + +export function getBridgeTokensToHubPoolInstruction< + TAccountSigner extends string, + TAccountPayer extends string, + TAccountMint extends string, + TAccountState extends string, + TAccountTransferLiability extends string, + TAccountVault extends string, + TAccountTokenMessengerMinterSenderAuthority extends string, + TAccountMessageTransmitter extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountCctpEventAuthority extends string, + TAccountMessageSentEventData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: BridgeTokensToHubPoolInput< + TAccountSigner, + TAccountPayer, + TAccountMint, + TAccountState, + TAccountTransferLiability, + TAccountVault, + TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCctpEventAuthority, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): BridgeTokensToHubPoolInstruction< + TProgramAddress, + TAccountSigner, + TAccountPayer, + TAccountMint, + TAccountState, + TAccountTransferLiability, + TAccountVault, + TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCctpEventAuthority, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + payer: { value: input.payer ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: false }, + transferLiability: { + value: input.transferLiability ?? null, + isWritable: true, + }, + vault: { value: input.vault ?? null, isWritable: true }, + tokenMessengerMinterSenderAuthority: { + value: input.tokenMessengerMinterSenderAuthority ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + cctpEventAuthority: { + value: input.cctpEventAuthority ?? null, + isWritable: false, + }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.messageTransmitterProgram.value) { + accounts.messageTransmitterProgram.value = + 'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd' as Address<'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd'>; + } + if (!accounts.tokenMessengerMinterProgram.value) { + accounts.tokenMessengerMinterProgram.value = + 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3' as Address<'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.payer), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.state), + getAccountMeta(accounts.transferLiability), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.tokenMessengerMinterSenderAuthority), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.cctpEventAuthority), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getBridgeTokensToHubPoolInstructionDataEncoder().encode( + args as BridgeTokensToHubPoolInstructionDataArgs + ), + } as BridgeTokensToHubPoolInstruction< + TProgramAddress, + TAccountSigner, + TAccountPayer, + TAccountMint, + TAccountState, + TAccountTransferLiability, + TAccountVault, + TAccountTokenMessengerMinterSenderAuthority, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCctpEventAuthority, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedBridgeTokensToHubPoolInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + payer: TAccountMetas[1]; + mint: TAccountMetas[2]; + state: TAccountMetas[3]; + transferLiability: TAccountMetas[4]; + vault: TAccountMetas[5]; + tokenMessengerMinterSenderAuthority: TAccountMetas[6]; + messageTransmitter: TAccountMetas[7]; + tokenMessenger: TAccountMetas[8]; + remoteTokenMessenger: TAccountMetas[9]; + tokenMinter: TAccountMetas[10]; + localToken: TAccountMetas[11]; + cctpEventAuthority: TAccountMetas[12]; + messageSentEventData: TAccountMetas[13]; + messageTransmitterProgram: TAccountMetas[14]; + tokenMessengerMinterProgram: TAccountMetas[15]; + tokenProgram: TAccountMetas[16]; + systemProgram: TAccountMetas[17]; + eventAuthority: TAccountMetas[18]; + program: TAccountMetas[19]; + }; + data: BridgeTokensToHubPoolInstructionData; +}; + +export function parseBridgeTokensToHubPoolInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedBridgeTokensToHubPoolInstruction { + if (instruction.accounts.length < 20) { + // 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: { + signer: getNextAccount(), + payer: getNextAccount(), + mint: getNextAccount(), + state: getNextAccount(), + transferLiability: getNextAccount(), + vault: getNextAccount(), + tokenMessengerMinterSenderAuthority: getNextAccount(), + messageTransmitter: getNextAccount(), + tokenMessenger: getNextAccount(), + remoteTokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + cctpEventAuthority: getNextAccount(), + messageSentEventData: getNextAccount(), + messageTransmitterProgram: getNextAccount(), + tokenMessengerMinterProgram: getNextAccount(), + tokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getBridgeTokensToHubPoolInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/claimRelayerRefund.ts b/src/svm/clients/SvmSpoke/instructions/claimRelayerRefund.ts new file mode 100644 index 000000000..08e28458e --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/claimRelayerRefund.ts @@ -0,0 +1,498 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const CLAIM_RELAYER_REFUND_DISCRIMINATOR = new Uint8Array([ + 205, 34, 34, 224, 204, 103, 81, 176, +]); + +export function getClaimRelayerRefundDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + CLAIM_RELAYER_REFUND_DISCRIMINATOR + ); +} + +export type ClaimRelayerRefundInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountInitializer extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountVault extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountRefundAddress extends string | AccountMeta = string, + TAccountTokenAccount extends string | AccountMeta = string, + TAccountClaimAccount extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountInitializer extends string + ? WritableAccount + : TAccountInitializer, + TAccountState extends string + ? ReadonlyAccount + : TAccountState, + TAccountVault extends string + ? WritableAccount + : TAccountVault, + TAccountMint extends string + ? ReadonlyAccount + : TAccountMint, + TAccountRefundAddress extends string + ? ReadonlyAccount + : TAccountRefundAddress, + TAccountTokenAccount extends string + ? WritableAccount + : TAccountTokenAccount, + TAccountClaimAccount extends string + ? WritableAccount + : TAccountClaimAccount, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type ClaimRelayerRefundInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type ClaimRelayerRefundInstructionDataArgs = {}; + +export function getClaimRelayerRefundInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: CLAIM_RELAYER_REFUND_DISCRIMINATOR }) + ); +} + +export function getClaimRelayerRefundInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getClaimRelayerRefundInstructionDataCodec(): Codec< + ClaimRelayerRefundInstructionDataArgs, + ClaimRelayerRefundInstructionData +> { + return combineCodec( + getClaimRelayerRefundInstructionDataEncoder(), + getClaimRelayerRefundInstructionDataDecoder() + ); +} + +export type ClaimRelayerRefundAsyncInput< + TAccountSigner extends string = string, + TAccountInitializer extends string = string, + TAccountState extends string = string, + TAccountVault extends string = string, + TAccountMint extends string = string, + TAccountRefundAddress extends string = string, + TAccountTokenAccount extends string = string, + TAccountClaimAccount extends string = string, + TAccountTokenProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + initializer: Address; + state: Address; + vault?: Address; + mint: Address; + refundAddress: Address; + tokenAccount: Address; + claimAccount?: Address; + tokenProgram?: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getClaimRelayerRefundInstructionAsync< + TAccountSigner extends string, + TAccountInitializer extends string, + TAccountState extends string, + TAccountVault extends string, + TAccountMint extends string, + TAccountRefundAddress extends string, + TAccountTokenAccount extends string, + TAccountClaimAccount extends string, + TAccountTokenProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: ClaimRelayerRefundAsyncInput< + TAccountSigner, + TAccountInitializer, + TAccountState, + TAccountVault, + TAccountMint, + TAccountRefundAddress, + TAccountTokenAccount, + TAccountClaimAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + ClaimRelayerRefundInstruction< + TProgramAddress, + TAccountSigner, + TAccountInitializer, + TAccountState, + TAccountVault, + TAccountMint, + TAccountRefundAddress, + TAccountTokenAccount, + TAccountClaimAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + initializer: { value: input.initializer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: false }, + vault: { value: input.vault ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + refundAddress: { value: input.refundAddress ?? null, isWritable: false }, + tokenAccount: { value: input.tokenAccount ?? null, isWritable: true }, + claimAccount: { value: input.claimAccount ?? null, isWritable: true }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.vault.value) { + accounts.vault.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getAddressEncoder().encode(expectAddress(accounts.state.value)), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.claimAccount.value) { + accounts.claimAccount.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 99, 108, 97, 105, 109, 95, 97, 99, 99, 111, 117, 110, 116, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + getAddressEncoder().encode(expectAddress(accounts.refundAddress.value)), + ], + }); + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.initializer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.refundAddress), + getAccountMeta(accounts.tokenAccount), + getAccountMeta(accounts.claimAccount), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getClaimRelayerRefundInstructionDataEncoder().encode({}), + } as ClaimRelayerRefundInstruction< + TProgramAddress, + TAccountSigner, + TAccountInitializer, + TAccountState, + TAccountVault, + TAccountMint, + TAccountRefundAddress, + TAccountTokenAccount, + TAccountClaimAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ClaimRelayerRefundInput< + TAccountSigner extends string = string, + TAccountInitializer extends string = string, + TAccountState extends string = string, + TAccountVault extends string = string, + TAccountMint extends string = string, + TAccountRefundAddress extends string = string, + TAccountTokenAccount extends string = string, + TAccountClaimAccount extends string = string, + TAccountTokenProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + initializer: Address; + state: Address; + vault: Address; + mint: Address; + refundAddress: Address; + tokenAccount: Address; + claimAccount: Address; + tokenProgram?: Address; + eventAuthority: Address; + program: Address; +}; + +export function getClaimRelayerRefundInstruction< + TAccountSigner extends string, + TAccountInitializer extends string, + TAccountState extends string, + TAccountVault extends string, + TAccountMint extends string, + TAccountRefundAddress extends string, + TAccountTokenAccount extends string, + TAccountClaimAccount extends string, + TAccountTokenProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: ClaimRelayerRefundInput< + TAccountSigner, + TAccountInitializer, + TAccountState, + TAccountVault, + TAccountMint, + TAccountRefundAddress, + TAccountTokenAccount, + TAccountClaimAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): ClaimRelayerRefundInstruction< + TProgramAddress, + TAccountSigner, + TAccountInitializer, + TAccountState, + TAccountVault, + TAccountMint, + TAccountRefundAddress, + TAccountTokenAccount, + TAccountClaimAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + initializer: { value: input.initializer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: false }, + vault: { value: input.vault ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + refundAddress: { value: input.refundAddress ?? null, isWritable: false }, + tokenAccount: { value: input.tokenAccount ?? null, isWritable: true }, + claimAccount: { value: input.claimAccount ?? null, isWritable: true }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.initializer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.refundAddress), + getAccountMeta(accounts.tokenAccount), + getAccountMeta(accounts.claimAccount), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getClaimRelayerRefundInstructionDataEncoder().encode({}), + } as ClaimRelayerRefundInstruction< + TProgramAddress, + TAccountSigner, + TAccountInitializer, + TAccountState, + TAccountVault, + TAccountMint, + TAccountRefundAddress, + TAccountTokenAccount, + TAccountClaimAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedClaimRelayerRefundInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + initializer: TAccountMetas[1]; + state: TAccountMetas[2]; + vault: TAccountMetas[3]; + mint: TAccountMetas[4]; + refundAddress: TAccountMetas[5]; + tokenAccount: TAccountMetas[6]; + claimAccount: TAccountMetas[7]; + tokenProgram: TAccountMetas[8]; + eventAuthority: TAccountMetas[9]; + program: TAccountMetas[10]; + }; + data: ClaimRelayerRefundInstructionData; +}; + +export function parseClaimRelayerRefundInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedClaimRelayerRefundInstruction { + if (instruction.accounts.length < 11) { + // 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: { + signer: getNextAccount(), + initializer: getNextAccount(), + state: getNextAccount(), + vault: getNextAccount(), + mint: getNextAccount(), + refundAddress: getNextAccount(), + tokenAccount: getNextAccount(), + claimAccount: getNextAccount(), + tokenProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getClaimRelayerRefundInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/closeClaimAccount.ts b/src/svm/clients/SvmSpoke/instructions/closeClaimAccount.ts new file mode 100644 index 000000000..bc6c88f85 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/closeClaimAccount.ts @@ -0,0 +1,307 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const CLOSE_CLAIM_ACCOUNT_DISCRIMINATOR = new Uint8Array([ + 241, 146, 203, 216, 58, 222, 91, 118, +]); + +export function getCloseClaimAccountDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + CLOSE_CLAIM_ACCOUNT_DISCRIMINATOR + ); +} + +export type CloseClaimAccountInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountRefundAddress extends string | AccountMeta = string, + TAccountClaimAccount extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountMint extends string + ? ReadonlyAccount + : TAccountMint, + TAccountRefundAddress extends string + ? ReadonlyAccount + : TAccountRefundAddress, + TAccountClaimAccount extends string + ? WritableAccount + : TAccountClaimAccount, + ...TRemainingAccounts, + ] + >; + +export type CloseClaimAccountInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type CloseClaimAccountInstructionDataArgs = {}; + +export function getCloseClaimAccountInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: CLOSE_CLAIM_ACCOUNT_DISCRIMINATOR }) + ); +} + +export function getCloseClaimAccountInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getCloseClaimAccountInstructionDataCodec(): Codec< + CloseClaimAccountInstructionDataArgs, + CloseClaimAccountInstructionData +> { + return combineCodec( + getCloseClaimAccountInstructionDataEncoder(), + getCloseClaimAccountInstructionDataDecoder() + ); +} + +export type CloseClaimAccountAsyncInput< + TAccountSigner extends string = string, + TAccountMint extends string = string, + TAccountRefundAddress extends string = string, + TAccountClaimAccount extends string = string, +> = { + signer: TransactionSigner; + mint: Address; + refundAddress: Address; + claimAccount?: Address; +}; + +export async function getCloseClaimAccountInstructionAsync< + TAccountSigner extends string, + TAccountMint extends string, + TAccountRefundAddress extends string, + TAccountClaimAccount extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: CloseClaimAccountAsyncInput< + TAccountSigner, + TAccountMint, + TAccountRefundAddress, + TAccountClaimAccount + >, + config?: { programAddress?: TProgramAddress } +): Promise< + CloseClaimAccountInstruction< + TProgramAddress, + TAccountSigner, + TAccountMint, + TAccountRefundAddress, + TAccountClaimAccount + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + refundAddress: { value: input.refundAddress ?? null, isWritable: false }, + claimAccount: { value: input.claimAccount ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.claimAccount.value) { + accounts.claimAccount.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 99, 108, 97, 105, 109, 95, 97, 99, 99, 111, 117, 110, 116, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + getAddressEncoder().encode(expectAddress(accounts.refundAddress.value)), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.refundAddress), + getAccountMeta(accounts.claimAccount), + ], + programAddress, + data: getCloseClaimAccountInstructionDataEncoder().encode({}), + } as CloseClaimAccountInstruction< + TProgramAddress, + TAccountSigner, + TAccountMint, + TAccountRefundAddress, + TAccountClaimAccount + >; + + return instruction; +} + +export type CloseClaimAccountInput< + TAccountSigner extends string = string, + TAccountMint extends string = string, + TAccountRefundAddress extends string = string, + TAccountClaimAccount extends string = string, +> = { + signer: TransactionSigner; + mint: Address; + refundAddress: Address; + claimAccount: Address; +}; + +export function getCloseClaimAccountInstruction< + TAccountSigner extends string, + TAccountMint extends string, + TAccountRefundAddress extends string, + TAccountClaimAccount extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: CloseClaimAccountInput< + TAccountSigner, + TAccountMint, + TAccountRefundAddress, + TAccountClaimAccount + >, + config?: { programAddress?: TProgramAddress } +): CloseClaimAccountInstruction< + TProgramAddress, + TAccountSigner, + TAccountMint, + TAccountRefundAddress, + TAccountClaimAccount +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + refundAddress: { value: input.refundAddress ?? null, isWritable: false }, + claimAccount: { value: input.claimAccount ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.refundAddress), + getAccountMeta(accounts.claimAccount), + ], + programAddress, + data: getCloseClaimAccountInstructionDataEncoder().encode({}), + } as CloseClaimAccountInstruction< + TProgramAddress, + TAccountSigner, + TAccountMint, + TAccountRefundAddress, + TAccountClaimAccount + >; + + return instruction; +} + +export type ParsedCloseClaimAccountInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + mint: TAccountMetas[1]; + refundAddress: TAccountMetas[2]; + claimAccount: TAccountMetas[3]; + }; + data: CloseClaimAccountInstructionData; +}; + +export function parseCloseClaimAccountInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedCloseClaimAccountInstruction { + if (instruction.accounts.length < 4) { + // 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: { + signer: getNextAccount(), + mint: getNextAccount(), + refundAddress: getNextAccount(), + claimAccount: getNextAccount(), + }, + data: getCloseClaimAccountInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/closeFillPda.ts b/src/svm/clients/SvmSpoke/instructions/closeFillPda.ts new file mode 100644 index 000000000..868ab5109 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/closeFillPda.ts @@ -0,0 +1,194 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const CLOSE_FILL_PDA_DISCRIMINATOR = new Uint8Array([ + 224, 39, 208, 68, 8, 226, 23, 214, +]); + +export function getCloseFillPdaDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + CLOSE_FILL_PDA_DISCRIMINATOR + ); +} + +export type CloseFillPdaInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountFillStatus extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountState extends string + ? ReadonlyAccount + : TAccountState, + TAccountFillStatus extends string + ? WritableAccount + : TAccountFillStatus, + ...TRemainingAccounts, + ] + >; + +export type CloseFillPdaInstructionData = { discriminator: ReadonlyUint8Array }; + +export type CloseFillPdaInstructionDataArgs = {}; + +export function getCloseFillPdaInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: CLOSE_FILL_PDA_DISCRIMINATOR }) + ); +} + +export function getCloseFillPdaInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getCloseFillPdaInstructionDataCodec(): Codec< + CloseFillPdaInstructionDataArgs, + CloseFillPdaInstructionData +> { + return combineCodec( + getCloseFillPdaInstructionDataEncoder(), + getCloseFillPdaInstructionDataDecoder() + ); +} + +export type CloseFillPdaInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountFillStatus extends string = string, +> = { + signer: TransactionSigner; + state: Address; + fillStatus: Address; +}; + +export function getCloseFillPdaInstruction< + TAccountSigner extends string, + TAccountState extends string, + TAccountFillStatus extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: CloseFillPdaInput, + config?: { programAddress?: TProgramAddress } +): CloseFillPdaInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountFillStatus +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: false }, + fillStatus: { value: input.fillStatus ?? null, isWritable: true }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.fillStatus), + ], + programAddress, + data: getCloseFillPdaInstructionDataEncoder().encode({}), + } as CloseFillPdaInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountFillStatus + >; + + return instruction; +} + +export type ParsedCloseFillPdaInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + state: TAccountMetas[1]; + fillStatus: TAccountMetas[2]; + }; + data: CloseFillPdaInstructionData; +}; + +export function parseCloseFillPdaInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedCloseFillPdaInstruction { + 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: { + signer: getNextAccount(), + state: getNextAccount(), + fillStatus: getNextAccount(), + }, + data: getCloseFillPdaInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/closeInstructionParams.ts b/src/svm/clients/SvmSpoke/instructions/closeInstructionParams.ts new file mode 100644 index 000000000..68b8e6537 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/closeInstructionParams.ts @@ -0,0 +1,270 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const CLOSE_INSTRUCTION_PARAMS_DISCRIMINATOR = new Uint8Array([ + 224, 44, 254, 10, 216, 8, 172, 96, +]); + +export function getCloseInstructionParamsDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + CLOSE_INSTRUCTION_PARAMS_DISCRIMINATOR + ); +} + +export type CloseInstructionParamsInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountInstructionParams extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountInstructionParams extends string + ? WritableAccount + : TAccountInstructionParams, + ...TRemainingAccounts, + ] + >; + +export type CloseInstructionParamsInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type CloseInstructionParamsInstructionDataArgs = {}; + +export function getCloseInstructionParamsInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: CLOSE_INSTRUCTION_PARAMS_DISCRIMINATOR, + }) + ); +} + +export function getCloseInstructionParamsInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getCloseInstructionParamsInstructionDataCodec(): Codec< + CloseInstructionParamsInstructionDataArgs, + CloseInstructionParamsInstructionData +> { + return combineCodec( + getCloseInstructionParamsInstructionDataEncoder(), + getCloseInstructionParamsInstructionDataDecoder() + ); +} + +export type CloseInstructionParamsAsyncInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, +> = { + signer: TransactionSigner; + instructionParams?: Address; +}; + +export async function getCloseInstructionParamsInstructionAsync< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: CloseInstructionParamsAsyncInput< + TAccountSigner, + TAccountInstructionParams + >, + config?: { programAddress?: TProgramAddress } +): Promise< + CloseInstructionParamsInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.instructionParams.value) { + accounts.instructionParams.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, + 114, 97, 109, 115, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.signer.value)), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + ], + programAddress, + data: getCloseInstructionParamsInstructionDataEncoder().encode({}), + } as CloseInstructionParamsInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams + >; + + return instruction; +} + +export type CloseInstructionParamsInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, +> = { + signer: TransactionSigner; + instructionParams: Address; +}; + +export function getCloseInstructionParamsInstruction< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: CloseInstructionParamsInput, + config?: { programAddress?: TProgramAddress } +): CloseInstructionParamsInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + ], + programAddress, + data: getCloseInstructionParamsInstructionDataEncoder().encode({}), + } as CloseInstructionParamsInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams + >; + + return instruction; +} + +export type ParsedCloseInstructionParamsInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + instructionParams: TAccountMetas[1]; + }; + data: CloseInstructionParamsInstructionData; +}; + +export function parseCloseInstructionParamsInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedCloseInstructionParamsInstruction { + if (instruction.accounts.length < 2) { + // 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: { + signer: getNextAccount(), + instructionParams: getNextAccount(), + }, + data: getCloseInstructionParamsInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/createTokenAccounts.ts b/src/svm/clients/SvmSpoke/instructions/createTokenAccounts.ts new file mode 100644 index 000000000..aceebf3be --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/createTokenAccounts.ts @@ -0,0 +1,252 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const CREATE_TOKEN_ACCOUNTS_DISCRIMINATOR = new Uint8Array([ + 163, 216, 49, 204, 97, 16, 80, 167, +]); + +export function getCreateTokenAccountsDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + CREATE_TOKEN_ACCOUNTS_DISCRIMINATOR + ); +} + +export type CreateTokenAccountsInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountAssociatedTokenProgram extends string | AccountMeta = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountMint extends string + ? ReadonlyAccount + : TAccountMint, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountAssociatedTokenProgram extends string + ? ReadonlyAccount + : TAccountAssociatedTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type CreateTokenAccountsInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type CreateTokenAccountsInstructionDataArgs = {}; + +export function getCreateTokenAccountsInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: CREATE_TOKEN_ACCOUNTS_DISCRIMINATOR, + }) + ); +} + +export function getCreateTokenAccountsInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getCreateTokenAccountsInstructionDataCodec(): Codec< + CreateTokenAccountsInstructionDataArgs, + CreateTokenAccountsInstructionData +> { + return combineCodec( + getCreateTokenAccountsInstructionDataEncoder(), + getCreateTokenAccountsInstructionDataDecoder() + ); +} + +export type CreateTokenAccountsInput< + TAccountSigner extends string = string, + TAccountMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountAssociatedTokenProgram extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + mint: Address; + tokenProgram?: Address; + associatedTokenProgram?: Address; + systemProgram?: Address; +}; + +export function getCreateTokenAccountsInstruction< + TAccountSigner extends string, + TAccountMint extends string, + TAccountTokenProgram extends string, + TAccountAssociatedTokenProgram extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: CreateTokenAccountsInput< + TAccountSigner, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): CreateTokenAccountsInstruction< + TProgramAddress, + TAccountSigner, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + associatedTokenProgram: { + value: input.associatedTokenProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.associatedTokenProgram.value) { + accounts.associatedTokenProgram.value = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.associatedTokenProgram), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getCreateTokenAccountsInstructionDataEncoder().encode({}), + } as CreateTokenAccountsInstruction< + TProgramAddress, + TAccountSigner, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedCreateTokenAccountsInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + mint: TAccountMetas[1]; + tokenProgram: TAccountMetas[2]; + associatedTokenProgram: TAccountMetas[3]; + systemProgram: TAccountMetas[4]; + }; + data: CreateTokenAccountsInstructionData; +}; + +export function parseCreateTokenAccountsInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedCreateTokenAccountsInstruction { + if (instruction.accounts.length < 5) { + // 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: { + signer: getNextAccount(), + mint: getNextAccount(), + tokenProgram: getNextAccount(), + associatedTokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getCreateTokenAccountsInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/deposit.ts b/src/svm/clients/SvmSpoke/instructions/deposit.ts new file mode 100644 index 000000000..13ff78c19 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/deposit.ts @@ -0,0 +1,614 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + expectSome, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const DEPOSIT_DISCRIMINATOR = new Uint8Array([ + 242, 35, 198, 137, 82, 225, 242, 182, +]); + +export function getDepositDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(DEPOSIT_DISCRIMINATOR); +} + +export type DepositInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountDelegate extends string | AccountMeta = string, + TAccountDepositorTokenAccount extends string | AccountMeta = string, + TAccountVault extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountAssociatedTokenProgram extends string | AccountMeta = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountState extends string + ? WritableAccount + : TAccountState, + TAccountDelegate extends string + ? ReadonlyAccount + : TAccountDelegate, + TAccountDepositorTokenAccount extends string + ? WritableAccount + : TAccountDepositorTokenAccount, + TAccountVault extends string + ? WritableAccount + : TAccountVault, + TAccountMint extends string + ? ReadonlyAccount + : TAccountMint, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountAssociatedTokenProgram extends string + ? ReadonlyAccount + : TAccountAssociatedTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type DepositInstructionData = { + discriminator: ReadonlyUint8Array; + depositor: Address; + recipient: Address; + inputToken: Address; + outputToken: Address; + inputAmount: bigint; + outputAmount: ReadonlyUint8Array; + destinationChainId: bigint; + exclusiveRelayer: Address; + quoteTimestamp: number; + fillDeadline: number; + exclusivityParameter: number; + message: ReadonlyUint8Array; +}; + +export type DepositInstructionDataArgs = { + depositor: Address; + recipient: Address; + inputToken: Address; + outputToken: Address; + inputAmount: number | bigint; + outputAmount: ReadonlyUint8Array; + destinationChainId: number | bigint; + exclusiveRelayer: Address; + quoteTimestamp: number; + fillDeadline: number; + exclusivityParameter: number; + message: ReadonlyUint8Array; +}; + +export function getDepositInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['depositor', getAddressEncoder()], + ['recipient', getAddressEncoder()], + ['inputToken', getAddressEncoder()], + ['outputToken', getAddressEncoder()], + ['inputAmount', getU64Encoder()], + ['outputAmount', fixEncoderSize(getBytesEncoder(), 32)], + ['destinationChainId', getU64Encoder()], + ['exclusiveRelayer', getAddressEncoder()], + ['quoteTimestamp', getU32Encoder()], + ['fillDeadline', getU32Encoder()], + ['exclusivityParameter', getU32Encoder()], + ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ ...value, discriminator: DEPOSIT_DISCRIMINATOR }) + ); +} + +export function getDepositInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['depositor', getAddressDecoder()], + ['recipient', getAddressDecoder()], + ['inputToken', getAddressDecoder()], + ['outputToken', getAddressDecoder()], + ['inputAmount', getU64Decoder()], + ['outputAmount', fixDecoderSize(getBytesDecoder(), 32)], + ['destinationChainId', getU64Decoder()], + ['exclusiveRelayer', getAddressDecoder()], + ['quoteTimestamp', getU32Decoder()], + ['fillDeadline', getU32Decoder()], + ['exclusivityParameter', getU32Decoder()], + ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getDepositInstructionDataCodec(): Codec< + DepositInstructionDataArgs, + DepositInstructionData +> { + return combineCodec( + getDepositInstructionDataEncoder(), + getDepositInstructionDataDecoder() + ); +} + +export type DepositAsyncInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountDelegate extends string = string, + TAccountDepositorTokenAccount extends string = string, + TAccountVault extends string = string, + TAccountMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountAssociatedTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + delegate: Address; + depositorTokenAccount?: Address; + vault?: Address; + mint: Address; + tokenProgram?: Address; + associatedTokenProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + depositor: DepositInstructionDataArgs['depositor']; + recipient: DepositInstructionDataArgs['recipient']; + inputToken: DepositInstructionDataArgs['inputToken']; + outputToken: DepositInstructionDataArgs['outputToken']; + inputAmount: DepositInstructionDataArgs['inputAmount']; + outputAmount: DepositInstructionDataArgs['outputAmount']; + destinationChainId: DepositInstructionDataArgs['destinationChainId']; + exclusiveRelayer: DepositInstructionDataArgs['exclusiveRelayer']; + quoteTimestamp: DepositInstructionDataArgs['quoteTimestamp']; + fillDeadline: DepositInstructionDataArgs['fillDeadline']; + exclusivityParameter: DepositInstructionDataArgs['exclusivityParameter']; + message: DepositInstructionDataArgs['message']; +}; + +export async function getDepositInstructionAsync< + TAccountSigner extends string, + TAccountState extends string, + TAccountDelegate extends string, + TAccountDepositorTokenAccount extends string, + TAccountVault extends string, + TAccountMint extends string, + TAccountTokenProgram extends string, + TAccountAssociatedTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: DepositAsyncInput< + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + DepositInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + delegate: { value: input.delegate ?? null, isWritable: false }, + depositorTokenAccount: { + value: input.depositorTokenAccount ?? null, + isWritable: true, + }, + vault: { value: input.vault ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + associatedTokenProgram: { + value: input.associatedTokenProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.depositorTokenAccount.value) { + accounts.depositorTokenAccount.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getAddressEncoder().encode(expectSome(args.depositor)), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.vault.value) { + accounts.vault.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getAddressEncoder().encode(expectAddress(accounts.state.value)), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.associatedTokenProgram.value) { + accounts.associatedTokenProgram.value = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.delegate), + getAccountMeta(accounts.depositorTokenAccount), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.associatedTokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDepositInstructionDataEncoder().encode( + args as DepositInstructionDataArgs + ), + } as DepositInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type DepositInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountDelegate extends string = string, + TAccountDepositorTokenAccount extends string = string, + TAccountVault extends string = string, + TAccountMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountAssociatedTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + delegate: Address; + depositorTokenAccount: Address; + vault: Address; + mint: Address; + tokenProgram?: Address; + associatedTokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + depositor: DepositInstructionDataArgs['depositor']; + recipient: DepositInstructionDataArgs['recipient']; + inputToken: DepositInstructionDataArgs['inputToken']; + outputToken: DepositInstructionDataArgs['outputToken']; + inputAmount: DepositInstructionDataArgs['inputAmount']; + outputAmount: DepositInstructionDataArgs['outputAmount']; + destinationChainId: DepositInstructionDataArgs['destinationChainId']; + exclusiveRelayer: DepositInstructionDataArgs['exclusiveRelayer']; + quoteTimestamp: DepositInstructionDataArgs['quoteTimestamp']; + fillDeadline: DepositInstructionDataArgs['fillDeadline']; + exclusivityParameter: DepositInstructionDataArgs['exclusivityParameter']; + message: DepositInstructionDataArgs['message']; +}; + +export function getDepositInstruction< + TAccountSigner extends string, + TAccountState extends string, + TAccountDelegate extends string, + TAccountDepositorTokenAccount extends string, + TAccountVault extends string, + TAccountMint extends string, + TAccountTokenProgram extends string, + TAccountAssociatedTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: DepositInput< + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): DepositInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + delegate: { value: input.delegate ?? null, isWritable: false }, + depositorTokenAccount: { + value: input.depositorTokenAccount ?? null, + isWritable: true, + }, + vault: { value: input.vault ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + associatedTokenProgram: { + value: input.associatedTokenProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.associatedTokenProgram.value) { + accounts.associatedTokenProgram.value = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.delegate), + getAccountMeta(accounts.depositorTokenAccount), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.associatedTokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDepositInstructionDataEncoder().encode( + args as DepositInstructionDataArgs + ), + } as DepositInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedDepositInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + state: TAccountMetas[1]; + delegate: TAccountMetas[2]; + depositorTokenAccount: TAccountMetas[3]; + vault: TAccountMetas[4]; + mint: TAccountMetas[5]; + tokenProgram: TAccountMetas[6]; + associatedTokenProgram: TAccountMetas[7]; + systemProgram: TAccountMetas[8]; + eventAuthority: TAccountMetas[9]; + program: TAccountMetas[10]; + }; + data: DepositInstructionData; +}; + +export function parseDepositInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedDepositInstruction { + if (instruction.accounts.length < 11) { + // 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: { + signer: getNextAccount(), + state: getNextAccount(), + delegate: getNextAccount(), + depositorTokenAccount: getNextAccount(), + vault: getNextAccount(), + mint: getNextAccount(), + tokenProgram: getNextAccount(), + associatedTokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getDepositInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/depositNow.ts b/src/svm/clients/SvmSpoke/instructions/depositNow.ts new file mode 100644 index 000000000..1cae4240e --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/depositNow.ts @@ -0,0 +1,608 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + expectSome, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const DEPOSIT_NOW_DISCRIMINATOR = new Uint8Array([ + 75, 228, 135, 221, 200, 25, 148, 26, +]); + +export function getDepositNowDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(DEPOSIT_NOW_DISCRIMINATOR); +} + +export type DepositNowInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountDelegate extends string | AccountMeta = string, + TAccountDepositorTokenAccount extends string | AccountMeta = string, + TAccountVault extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountAssociatedTokenProgram extends string | AccountMeta = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountState extends string + ? WritableAccount + : TAccountState, + TAccountDelegate extends string + ? ReadonlyAccount + : TAccountDelegate, + TAccountDepositorTokenAccount extends string + ? WritableAccount + : TAccountDepositorTokenAccount, + TAccountVault extends string + ? WritableAccount + : TAccountVault, + TAccountMint extends string + ? ReadonlyAccount + : TAccountMint, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountAssociatedTokenProgram extends string + ? ReadonlyAccount + : TAccountAssociatedTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type DepositNowInstructionData = { + discriminator: ReadonlyUint8Array; + depositor: Address; + recipient: Address; + inputToken: Address; + outputToken: Address; + inputAmount: bigint; + outputAmount: ReadonlyUint8Array; + destinationChainId: bigint; + exclusiveRelayer: Address; + fillDeadlineOffset: number; + exclusivityParameter: number; + message: ReadonlyUint8Array; +}; + +export type DepositNowInstructionDataArgs = { + depositor: Address; + recipient: Address; + inputToken: Address; + outputToken: Address; + inputAmount: number | bigint; + outputAmount: ReadonlyUint8Array; + destinationChainId: number | bigint; + exclusiveRelayer: Address; + fillDeadlineOffset: number; + exclusivityParameter: number; + message: ReadonlyUint8Array; +}; + +export function getDepositNowInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['depositor', getAddressEncoder()], + ['recipient', getAddressEncoder()], + ['inputToken', getAddressEncoder()], + ['outputToken', getAddressEncoder()], + ['inputAmount', getU64Encoder()], + ['outputAmount', fixEncoderSize(getBytesEncoder(), 32)], + ['destinationChainId', getU64Encoder()], + ['exclusiveRelayer', getAddressEncoder()], + ['fillDeadlineOffset', getU32Encoder()], + ['exclusivityParameter', getU32Encoder()], + ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ ...value, discriminator: DEPOSIT_NOW_DISCRIMINATOR }) + ); +} + +export function getDepositNowInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['depositor', getAddressDecoder()], + ['recipient', getAddressDecoder()], + ['inputToken', getAddressDecoder()], + ['outputToken', getAddressDecoder()], + ['inputAmount', getU64Decoder()], + ['outputAmount', fixDecoderSize(getBytesDecoder(), 32)], + ['destinationChainId', getU64Decoder()], + ['exclusiveRelayer', getAddressDecoder()], + ['fillDeadlineOffset', getU32Decoder()], + ['exclusivityParameter', getU32Decoder()], + ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getDepositNowInstructionDataCodec(): Codec< + DepositNowInstructionDataArgs, + DepositNowInstructionData +> { + return combineCodec( + getDepositNowInstructionDataEncoder(), + getDepositNowInstructionDataDecoder() + ); +} + +export type DepositNowAsyncInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountDelegate extends string = string, + TAccountDepositorTokenAccount extends string = string, + TAccountVault extends string = string, + TAccountMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountAssociatedTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + delegate: Address; + depositorTokenAccount?: Address; + vault?: Address; + mint: Address; + tokenProgram?: Address; + associatedTokenProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + depositor: DepositNowInstructionDataArgs['depositor']; + recipient: DepositNowInstructionDataArgs['recipient']; + inputToken: DepositNowInstructionDataArgs['inputToken']; + outputToken: DepositNowInstructionDataArgs['outputToken']; + inputAmount: DepositNowInstructionDataArgs['inputAmount']; + outputAmount: DepositNowInstructionDataArgs['outputAmount']; + destinationChainId: DepositNowInstructionDataArgs['destinationChainId']; + exclusiveRelayer: DepositNowInstructionDataArgs['exclusiveRelayer']; + fillDeadlineOffset: DepositNowInstructionDataArgs['fillDeadlineOffset']; + exclusivityParameter: DepositNowInstructionDataArgs['exclusivityParameter']; + message: DepositNowInstructionDataArgs['message']; +}; + +export async function getDepositNowInstructionAsync< + TAccountSigner extends string, + TAccountState extends string, + TAccountDelegate extends string, + TAccountDepositorTokenAccount extends string, + TAccountVault extends string, + TAccountMint extends string, + TAccountTokenProgram extends string, + TAccountAssociatedTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: DepositNowAsyncInput< + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + DepositNowInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + delegate: { value: input.delegate ?? null, isWritable: false }, + depositorTokenAccount: { + value: input.depositorTokenAccount ?? null, + isWritable: true, + }, + vault: { value: input.vault ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + associatedTokenProgram: { + value: input.associatedTokenProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.depositorTokenAccount.value) { + accounts.depositorTokenAccount.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getAddressEncoder().encode(expectSome(args.depositor)), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.vault.value) { + accounts.vault.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getAddressEncoder().encode(expectAddress(accounts.state.value)), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.associatedTokenProgram.value) { + accounts.associatedTokenProgram.value = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.delegate), + getAccountMeta(accounts.depositorTokenAccount), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.associatedTokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDepositNowInstructionDataEncoder().encode( + args as DepositNowInstructionDataArgs + ), + } as DepositNowInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type DepositNowInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountDelegate extends string = string, + TAccountDepositorTokenAccount extends string = string, + TAccountVault extends string = string, + TAccountMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountAssociatedTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + delegate: Address; + depositorTokenAccount: Address; + vault: Address; + mint: Address; + tokenProgram?: Address; + associatedTokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + depositor: DepositNowInstructionDataArgs['depositor']; + recipient: DepositNowInstructionDataArgs['recipient']; + inputToken: DepositNowInstructionDataArgs['inputToken']; + outputToken: DepositNowInstructionDataArgs['outputToken']; + inputAmount: DepositNowInstructionDataArgs['inputAmount']; + outputAmount: DepositNowInstructionDataArgs['outputAmount']; + destinationChainId: DepositNowInstructionDataArgs['destinationChainId']; + exclusiveRelayer: DepositNowInstructionDataArgs['exclusiveRelayer']; + fillDeadlineOffset: DepositNowInstructionDataArgs['fillDeadlineOffset']; + exclusivityParameter: DepositNowInstructionDataArgs['exclusivityParameter']; + message: DepositNowInstructionDataArgs['message']; +}; + +export function getDepositNowInstruction< + TAccountSigner extends string, + TAccountState extends string, + TAccountDelegate extends string, + TAccountDepositorTokenAccount extends string, + TAccountVault extends string, + TAccountMint extends string, + TAccountTokenProgram extends string, + TAccountAssociatedTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: DepositNowInput< + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): DepositNowInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + delegate: { value: input.delegate ?? null, isWritable: false }, + depositorTokenAccount: { + value: input.depositorTokenAccount ?? null, + isWritable: true, + }, + vault: { value: input.vault ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + associatedTokenProgram: { + value: input.associatedTokenProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.associatedTokenProgram.value) { + accounts.associatedTokenProgram.value = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.delegate), + getAccountMeta(accounts.depositorTokenAccount), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.associatedTokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDepositNowInstructionDataEncoder().encode( + args as DepositNowInstructionDataArgs + ), + } as DepositNowInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedDepositNowInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + state: TAccountMetas[1]; + delegate: TAccountMetas[2]; + depositorTokenAccount: TAccountMetas[3]; + vault: TAccountMetas[4]; + mint: TAccountMetas[5]; + tokenProgram: TAccountMetas[6]; + associatedTokenProgram: TAccountMetas[7]; + systemProgram: TAccountMetas[8]; + eventAuthority: TAccountMetas[9]; + program: TAccountMetas[10]; + }; + data: DepositNowInstructionData; +}; + +export function parseDepositNowInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedDepositNowInstruction { + if (instruction.accounts.length < 11) { + // 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: { + signer: getNextAccount(), + state: getNextAccount(), + delegate: getNextAccount(), + depositorTokenAccount: getNextAccount(), + vault: getNextAccount(), + mint: getNextAccount(), + tokenProgram: getNextAccount(), + associatedTokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getDepositNowInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/emergencyDeleteRootBundle.ts b/src/svm/clients/SvmSpoke/instructions/emergencyDeleteRootBundle.ts new file mode 100644 index 000000000..6dc0c7451 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/emergencyDeleteRootBundle.ts @@ -0,0 +1,371 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const EMERGENCY_DELETE_ROOT_BUNDLE_DISCRIMINATOR = new Uint8Array([ + 226, 158, 1, 74, 84, 113, 24, 152, +]); + +export function getEmergencyDeleteRootBundleDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + EMERGENCY_DELETE_ROOT_BUNDLE_DISCRIMINATOR + ); +} + +export type EmergencyDeleteRootBundleInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountCloser extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountRootBundle extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountCloser extends string + ? WritableAccount + : TAccountCloser, + TAccountState extends string + ? ReadonlyAccount + : TAccountState, + TAccountRootBundle extends string + ? WritableAccount + : TAccountRootBundle, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type EmergencyDeleteRootBundleInstructionData = { + discriminator: ReadonlyUint8Array; + rootBundleId: number; +}; + +export type EmergencyDeleteRootBundleInstructionDataArgs = { + rootBundleId: number; +}; + +export function getEmergencyDeleteRootBundleInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['rootBundleId', getU32Encoder()], + ]), + (value) => ({ + ...value, + discriminator: EMERGENCY_DELETE_ROOT_BUNDLE_DISCRIMINATOR, + }) + ); +} + +export function getEmergencyDeleteRootBundleInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['rootBundleId', getU32Decoder()], + ]); +} + +export function getEmergencyDeleteRootBundleInstructionDataCodec(): Codec< + EmergencyDeleteRootBundleInstructionDataArgs, + EmergencyDeleteRootBundleInstructionData +> { + return combineCodec( + getEmergencyDeleteRootBundleInstructionDataEncoder(), + getEmergencyDeleteRootBundleInstructionDataDecoder() + ); +} + +export type EmergencyDeleteRootBundleAsyncInput< + TAccountSigner extends string = string, + TAccountCloser extends string = string, + TAccountState extends string = string, + TAccountRootBundle extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + closer: Address; + state: Address; + rootBundle: Address; + eventAuthority?: Address; + program: Address; + rootBundleId: EmergencyDeleteRootBundleInstructionDataArgs['rootBundleId']; +}; + +export async function getEmergencyDeleteRootBundleInstructionAsync< + TAccountSigner extends string, + TAccountCloser extends string, + TAccountState extends string, + TAccountRootBundle extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: EmergencyDeleteRootBundleAsyncInput< + TAccountSigner, + TAccountCloser, + TAccountState, + TAccountRootBundle, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + EmergencyDeleteRootBundleInstruction< + TProgramAddress, + TAccountSigner, + TAccountCloser, + TAccountState, + TAccountRootBundle, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + closer: { value: input.closer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: false }, + rootBundle: { value: input.rootBundle ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.closer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.rootBundle), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getEmergencyDeleteRootBundleInstructionDataEncoder().encode( + args as EmergencyDeleteRootBundleInstructionDataArgs + ), + } as EmergencyDeleteRootBundleInstruction< + TProgramAddress, + TAccountSigner, + TAccountCloser, + TAccountState, + TAccountRootBundle, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type EmergencyDeleteRootBundleInput< + TAccountSigner extends string = string, + TAccountCloser extends string = string, + TAccountState extends string = string, + TAccountRootBundle extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + closer: Address; + state: Address; + rootBundle: Address; + eventAuthority: Address; + program: Address; + rootBundleId: EmergencyDeleteRootBundleInstructionDataArgs['rootBundleId']; +}; + +export function getEmergencyDeleteRootBundleInstruction< + TAccountSigner extends string, + TAccountCloser extends string, + TAccountState extends string, + TAccountRootBundle extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: EmergencyDeleteRootBundleInput< + TAccountSigner, + TAccountCloser, + TAccountState, + TAccountRootBundle, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): EmergencyDeleteRootBundleInstruction< + TProgramAddress, + TAccountSigner, + TAccountCloser, + TAccountState, + TAccountRootBundle, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + closer: { value: input.closer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: false }, + rootBundle: { value: input.rootBundle ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.signer), + getAccountMeta(accounts.closer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.rootBundle), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getEmergencyDeleteRootBundleInstructionDataEncoder().encode( + args as EmergencyDeleteRootBundleInstructionDataArgs + ), + } as EmergencyDeleteRootBundleInstruction< + TProgramAddress, + TAccountSigner, + TAccountCloser, + TAccountState, + TAccountRootBundle, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedEmergencyDeleteRootBundleInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + closer: TAccountMetas[1]; + state: TAccountMetas[2]; + rootBundle: TAccountMetas[3]; + eventAuthority: TAccountMetas[4]; + program: TAccountMetas[5]; + }; + data: EmergencyDeleteRootBundleInstructionData; +}; + +export function parseEmergencyDeleteRootBundleInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedEmergencyDeleteRootBundleInstruction { + if (instruction.accounts.length < 6) { + // 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: { + signer: getNextAccount(), + closer: getNextAccount(), + state: getNextAccount(), + rootBundle: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getEmergencyDeleteRootBundleInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeaf.ts b/src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeaf.ts new file mode 100644 index 000000000..7cfed475f --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeaf.ts @@ -0,0 +1,536 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const EXECUTE_RELAYER_REFUND_LEAF_DISCRIMINATOR = new Uint8Array([ + 27, 136, 159, 240, 127, 68, 123, 164, +]); + +export function getExecuteRelayerRefundLeafDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + EXECUTE_RELAYER_REFUND_LEAF_DISCRIMINATOR + ); +} + +export type ExecuteRelayerRefundLeafInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountInstructionParams extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountRootBundle extends string | AccountMeta = string, + TAccountVault extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountTransferLiability extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountInstructionParams extends string + ? WritableAccount + : TAccountInstructionParams, + TAccountState extends string + ? ReadonlyAccount + : TAccountState, + TAccountRootBundle extends string + ? WritableAccount + : TAccountRootBundle, + TAccountVault extends string + ? WritableAccount + : TAccountVault, + TAccountMint extends string + ? ReadonlyAccount + : TAccountMint, + TAccountTransferLiability extends string + ? WritableAccount + : TAccountTransferLiability, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type ExecuteRelayerRefundLeafInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type ExecuteRelayerRefundLeafInstructionDataArgs = {}; + +export function getExecuteRelayerRefundLeafInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: EXECUTE_RELAYER_REFUND_LEAF_DISCRIMINATOR, + }) + ); +} + +export function getExecuteRelayerRefundLeafInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getExecuteRelayerRefundLeafInstructionDataCodec(): Codec< + ExecuteRelayerRefundLeafInstructionDataArgs, + ExecuteRelayerRefundLeafInstructionData +> { + return combineCodec( + getExecuteRelayerRefundLeafInstructionDataEncoder(), + getExecuteRelayerRefundLeafInstructionDataDecoder() + ); +} + +export type ExecuteRelayerRefundLeafAsyncInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountState extends string = string, + TAccountRootBundle extends string = string, + TAccountVault extends string = string, + TAccountMint extends string = string, + TAccountTransferLiability extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams?: Address; + state: Address; + rootBundle: Address; + vault?: Address; + mint: Address; + transferLiability?: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getExecuteRelayerRefundLeafInstructionAsync< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountState extends string, + TAccountRootBundle extends string, + TAccountVault extends string, + TAccountMint extends string, + TAccountTransferLiability extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: ExecuteRelayerRefundLeafAsyncInput< + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountVault, + TAccountMint, + TAccountTransferLiability, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + ExecuteRelayerRefundLeafInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountVault, + TAccountMint, + TAccountTransferLiability, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + state: { value: input.state ?? null, isWritable: false }, + rootBundle: { value: input.rootBundle ?? null, isWritable: true }, + vault: { value: input.vault ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + transferLiability: { + value: input.transferLiability ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.instructionParams.value) { + accounts.instructionParams.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, + 114, 97, 109, 115, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.signer.value)), + ], + }); + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.vault.value) { + accounts.vault.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getAddressEncoder().encode(expectAddress(accounts.state.value)), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.transferLiability.value) { + accounts.transferLiability.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 116, 114, 97, 110, 115, 102, 101, 114, 95, 108, 105, 97, 98, 105, + 108, 105, 116, 121, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.state), + getAccountMeta(accounts.rootBundle), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.transferLiability), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getExecuteRelayerRefundLeafInstructionDataEncoder().encode({}), + } as ExecuteRelayerRefundLeafInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountVault, + TAccountMint, + TAccountTransferLiability, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ExecuteRelayerRefundLeafInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountState extends string = string, + TAccountRootBundle extends string = string, + TAccountVault extends string = string, + TAccountMint extends string = string, + TAccountTransferLiability extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams: Address; + state: Address; + rootBundle: Address; + vault: Address; + mint: Address; + transferLiability: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; +}; + +export function getExecuteRelayerRefundLeafInstruction< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountState extends string, + TAccountRootBundle extends string, + TAccountVault extends string, + TAccountMint extends string, + TAccountTransferLiability extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: ExecuteRelayerRefundLeafInput< + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountVault, + TAccountMint, + TAccountTransferLiability, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): ExecuteRelayerRefundLeafInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountVault, + TAccountMint, + TAccountTransferLiability, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + state: { value: input.state ?? null, isWritable: false }, + rootBundle: { value: input.rootBundle ?? null, isWritable: true }, + vault: { value: input.vault ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + transferLiability: { + value: input.transferLiability ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.state), + getAccountMeta(accounts.rootBundle), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.transferLiability), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getExecuteRelayerRefundLeafInstructionDataEncoder().encode({}), + } as ExecuteRelayerRefundLeafInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountVault, + TAccountMint, + TAccountTransferLiability, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedExecuteRelayerRefundLeafInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + instructionParams: TAccountMetas[1]; + state: TAccountMetas[2]; + rootBundle: TAccountMetas[3]; + vault: TAccountMetas[4]; + mint: TAccountMetas[5]; + transferLiability: TAccountMetas[6]; + tokenProgram: TAccountMetas[7]; + systemProgram: TAccountMetas[8]; + eventAuthority: TAccountMetas[9]; + program: TAccountMetas[10]; + }; + data: ExecuteRelayerRefundLeafInstructionData; +}; + +export function parseExecuteRelayerRefundLeafInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedExecuteRelayerRefundLeafInstruction { + if (instruction.accounts.length < 11) { + // 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: { + signer: getNextAccount(), + instructionParams: getNextAccount(), + state: getNextAccount(), + rootBundle: getNextAccount(), + vault: getNextAccount(), + mint: getNextAccount(), + transferLiability: getNextAccount(), + tokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getExecuteRelayerRefundLeafInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeafDeferred.ts b/src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeafDeferred.ts new file mode 100644 index 000000000..cfeb304f1 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeafDeferred.ts @@ -0,0 +1,539 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const EXECUTE_RELAYER_REFUND_LEAF_DEFERRED_DISCRIMINATOR = + new Uint8Array([110, 112, 89, 208, 38, 116, 93, 10]); + +export function getExecuteRelayerRefundLeafDeferredDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + EXECUTE_RELAYER_REFUND_LEAF_DEFERRED_DISCRIMINATOR + ); +} + +export type ExecuteRelayerRefundLeafDeferredInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountInstructionParams extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountRootBundle extends string | AccountMeta = string, + TAccountVault extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountTransferLiability extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountInstructionParams extends string + ? WritableAccount + : TAccountInstructionParams, + TAccountState extends string + ? ReadonlyAccount + : TAccountState, + TAccountRootBundle extends string + ? WritableAccount + : TAccountRootBundle, + TAccountVault extends string + ? WritableAccount + : TAccountVault, + TAccountMint extends string + ? ReadonlyAccount + : TAccountMint, + TAccountTransferLiability extends string + ? WritableAccount + : TAccountTransferLiability, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type ExecuteRelayerRefundLeafDeferredInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type ExecuteRelayerRefundLeafDeferredInstructionDataArgs = {}; + +export function getExecuteRelayerRefundLeafDeferredInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: EXECUTE_RELAYER_REFUND_LEAF_DEFERRED_DISCRIMINATOR, + }) + ); +} + +export function getExecuteRelayerRefundLeafDeferredInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getExecuteRelayerRefundLeafDeferredInstructionDataCodec(): Codec< + ExecuteRelayerRefundLeafDeferredInstructionDataArgs, + ExecuteRelayerRefundLeafDeferredInstructionData +> { + return combineCodec( + getExecuteRelayerRefundLeafDeferredInstructionDataEncoder(), + getExecuteRelayerRefundLeafDeferredInstructionDataDecoder() + ); +} + +export type ExecuteRelayerRefundLeafDeferredAsyncInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountState extends string = string, + TAccountRootBundle extends string = string, + TAccountVault extends string = string, + TAccountMint extends string = string, + TAccountTransferLiability extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams?: Address; + state: Address; + rootBundle: Address; + vault?: Address; + mint: Address; + transferLiability?: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getExecuteRelayerRefundLeafDeferredInstructionAsync< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountState extends string, + TAccountRootBundle extends string, + TAccountVault extends string, + TAccountMint extends string, + TAccountTransferLiability extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: ExecuteRelayerRefundLeafDeferredAsyncInput< + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountVault, + TAccountMint, + TAccountTransferLiability, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + ExecuteRelayerRefundLeafDeferredInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountVault, + TAccountMint, + TAccountTransferLiability, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + state: { value: input.state ?? null, isWritable: false }, + rootBundle: { value: input.rootBundle ?? null, isWritable: true }, + vault: { value: input.vault ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + transferLiability: { + value: input.transferLiability ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.instructionParams.value) { + accounts.instructionParams.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, + 114, 97, 109, 115, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.signer.value)), + ], + }); + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.vault.value) { + accounts.vault.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getAddressEncoder().encode(expectAddress(accounts.state.value)), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.transferLiability.value) { + accounts.transferLiability.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 116, 114, 97, 110, 115, 102, 101, 114, 95, 108, 105, 97, 98, 105, + 108, 105, 116, 121, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.state), + getAccountMeta(accounts.rootBundle), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.transferLiability), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getExecuteRelayerRefundLeafDeferredInstructionDataEncoder().encode( + {} + ), + } as ExecuteRelayerRefundLeafDeferredInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountVault, + TAccountMint, + TAccountTransferLiability, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ExecuteRelayerRefundLeafDeferredInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountState extends string = string, + TAccountRootBundle extends string = string, + TAccountVault extends string = string, + TAccountMint extends string = string, + TAccountTransferLiability extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams: Address; + state: Address; + rootBundle: Address; + vault: Address; + mint: Address; + transferLiability: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; +}; + +export function getExecuteRelayerRefundLeafDeferredInstruction< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountState extends string, + TAccountRootBundle extends string, + TAccountVault extends string, + TAccountMint extends string, + TAccountTransferLiability extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: ExecuteRelayerRefundLeafDeferredInput< + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountVault, + TAccountMint, + TAccountTransferLiability, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): ExecuteRelayerRefundLeafDeferredInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountVault, + TAccountMint, + TAccountTransferLiability, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + state: { value: input.state ?? null, isWritable: false }, + rootBundle: { value: input.rootBundle ?? null, isWritable: true }, + vault: { value: input.vault ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + transferLiability: { + value: input.transferLiability ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.state), + getAccountMeta(accounts.rootBundle), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.transferLiability), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getExecuteRelayerRefundLeafDeferredInstructionDataEncoder().encode( + {} + ), + } as ExecuteRelayerRefundLeafDeferredInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountVault, + TAccountMint, + TAccountTransferLiability, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedExecuteRelayerRefundLeafDeferredInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + instructionParams: TAccountMetas[1]; + state: TAccountMetas[2]; + rootBundle: TAccountMetas[3]; + vault: TAccountMetas[4]; + mint: TAccountMetas[5]; + transferLiability: TAccountMetas[6]; + tokenProgram: TAccountMetas[7]; + systemProgram: TAccountMetas[8]; + eventAuthority: TAccountMetas[9]; + program: TAccountMetas[10]; + }; + data: ExecuteRelayerRefundLeafDeferredInstructionData; +}; + +export function parseExecuteRelayerRefundLeafDeferredInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedExecuteRelayerRefundLeafDeferredInstruction { + if (instruction.accounts.length < 11) { + // 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: { + signer: getNextAccount(), + instructionParams: getNextAccount(), + state: getNextAccount(), + rootBundle: getNextAccount(), + vault: getNextAccount(), + mint: getNextAccount(), + transferLiability: getNextAccount(), + tokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getExecuteRelayerRefundLeafDeferredInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/executeSlowRelayLeaf.ts b/src/svm/clients/SvmSpoke/instructions/executeSlowRelayLeaf.ts new file mode 100644 index 000000000..b9835f128 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/executeSlowRelayLeaf.ts @@ -0,0 +1,634 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBytesDecoder, + getBytesEncoder, + getOptionDecoder, + getOptionEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type Option, + type OptionOrNullable, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + expectSome, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; +import { + getSlowFillDecoder, + getSlowFillEncoder, + type SlowFill, + type SlowFillArgs, +} from '../types'; + +export const EXECUTE_SLOW_RELAY_LEAF_DISCRIMINATOR = new Uint8Array([ + 26, 207, 3, 168, 193, 252, 59, 127, +]); + +export function getExecuteSlowRelayLeafDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + EXECUTE_SLOW_RELAY_LEAF_DISCRIMINATOR + ); +} + +export type ExecuteSlowRelayLeafInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountInstructionParams extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountRootBundle extends string | AccountMeta = string, + TAccountFillStatus extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountRecipientTokenAccount extends string | AccountMeta = string, + TAccountVault extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountInstructionParams extends string + ? WritableAccount + : TAccountInstructionParams, + TAccountState extends string + ? ReadonlyAccount + : TAccountState, + TAccountRootBundle extends string + ? ReadonlyAccount + : TAccountRootBundle, + TAccountFillStatus extends string + ? WritableAccount + : TAccountFillStatus, + TAccountMint extends string + ? ReadonlyAccount + : TAccountMint, + TAccountRecipientTokenAccount extends string + ? WritableAccount + : TAccountRecipientTokenAccount, + TAccountVault extends string + ? WritableAccount + : TAccountVault, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type ExecuteSlowRelayLeafInstructionData = { + discriminator: ReadonlyUint8Array; + relayHash: ReadonlyUint8Array; + slowFillLeaf: Option; + rootBundleId: Option; + proof: Option>; +}; + +export type ExecuteSlowRelayLeafInstructionDataArgs = { + relayHash: ReadonlyUint8Array; + slowFillLeaf: OptionOrNullable; + rootBundleId: OptionOrNullable; + proof: OptionOrNullable>; +}; + +export function getExecuteSlowRelayLeafInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['relayHash', fixEncoderSize(getBytesEncoder(), 32)], + ['slowFillLeaf', getOptionEncoder(getSlowFillEncoder())], + ['rootBundleId', getOptionEncoder(getU32Encoder())], + [ + 'proof', + getOptionEncoder( + getArrayEncoder(fixEncoderSize(getBytesEncoder(), 32)) + ), + ], + ]), + (value) => ({ + ...value, + discriminator: EXECUTE_SLOW_RELAY_LEAF_DISCRIMINATOR, + }) + ); +} + +export function getExecuteSlowRelayLeafInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['relayHash', fixDecoderSize(getBytesDecoder(), 32)], + ['slowFillLeaf', getOptionDecoder(getSlowFillDecoder())], + ['rootBundleId', getOptionDecoder(getU32Decoder())], + [ + 'proof', + getOptionDecoder(getArrayDecoder(fixDecoderSize(getBytesDecoder(), 32))), + ], + ]); +} + +export function getExecuteSlowRelayLeafInstructionDataCodec(): Codec< + ExecuteSlowRelayLeafInstructionDataArgs, + ExecuteSlowRelayLeafInstructionData +> { + return combineCodec( + getExecuteSlowRelayLeafInstructionDataEncoder(), + getExecuteSlowRelayLeafInstructionDataDecoder() + ); +} + +export type ExecuteSlowRelayLeafAsyncInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountState extends string = string, + TAccountRootBundle extends string = string, + TAccountFillStatus extends string = string, + TAccountMint extends string = string, + TAccountRecipientTokenAccount extends string = string, + TAccountVault extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams?: Address; + state: Address; + rootBundle: Address; + fillStatus?: Address; + mint: Address; + recipientTokenAccount?: Address; + vault?: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + relayHash: ExecuteSlowRelayLeafInstructionDataArgs['relayHash']; + slowFillLeaf: ExecuteSlowRelayLeafInstructionDataArgs['slowFillLeaf']; + rootBundleId: ExecuteSlowRelayLeafInstructionDataArgs['rootBundleId']; + proof: ExecuteSlowRelayLeafInstructionDataArgs['proof']; +}; + +export async function getExecuteSlowRelayLeafInstructionAsync< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountState extends string, + TAccountRootBundle extends string, + TAccountFillStatus extends string, + TAccountMint extends string, + TAccountRecipientTokenAccount extends string, + TAccountVault extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: ExecuteSlowRelayLeafAsyncInput< + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountFillStatus, + TAccountMint, + TAccountRecipientTokenAccount, + TAccountVault, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + ExecuteSlowRelayLeafInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountFillStatus, + TAccountMint, + TAccountRecipientTokenAccount, + TAccountVault, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + state: { value: input.state ?? null, isWritable: false }, + rootBundle: { value: input.rootBundle ?? null, isWritable: false }, + fillStatus: { value: input.fillStatus ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + recipientTokenAccount: { + value: input.recipientTokenAccount ?? null, + isWritable: true, + }, + vault: { value: input.vault ?? null, isWritable: true }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionParams.value) { + accounts.instructionParams.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, + 114, 97, 109, 115, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.signer.value)), + ], + }); + } + if (!accounts.fillStatus.value) { + accounts.fillStatus.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode(new Uint8Array([102, 105, 108, 108, 115])), + fixEncoderSize(getBytesEncoder(), 32).encode( + expectSome(args.relayHash) + ), + ], + }); + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.recipientTokenAccount.value) { + accounts.recipientTokenAccount.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getOptionEncoder(getSlowFillEncoder()).encode( + expectSome(args.slowFillLeaf) + ), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.vault.value) { + accounts.vault.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getAddressEncoder().encode(expectAddress(accounts.state.value)), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.state), + getAccountMeta(accounts.rootBundle), + getAccountMeta(accounts.fillStatus), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.recipientTokenAccount), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getExecuteSlowRelayLeafInstructionDataEncoder().encode( + args as ExecuteSlowRelayLeafInstructionDataArgs + ), + } as ExecuteSlowRelayLeafInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountFillStatus, + TAccountMint, + TAccountRecipientTokenAccount, + TAccountVault, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ExecuteSlowRelayLeafInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountState extends string = string, + TAccountRootBundle extends string = string, + TAccountFillStatus extends string = string, + TAccountMint extends string = string, + TAccountRecipientTokenAccount extends string = string, + TAccountVault extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams?: Address; + state: Address; + rootBundle: Address; + fillStatus: Address; + mint: Address; + recipientTokenAccount: Address; + vault: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + relayHash: ExecuteSlowRelayLeafInstructionDataArgs['relayHash']; + slowFillLeaf: ExecuteSlowRelayLeafInstructionDataArgs['slowFillLeaf']; + rootBundleId: ExecuteSlowRelayLeafInstructionDataArgs['rootBundleId']; + proof: ExecuteSlowRelayLeafInstructionDataArgs['proof']; +}; + +export function getExecuteSlowRelayLeafInstruction< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountState extends string, + TAccountRootBundle extends string, + TAccountFillStatus extends string, + TAccountMint extends string, + TAccountRecipientTokenAccount extends string, + TAccountVault extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: ExecuteSlowRelayLeafInput< + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountFillStatus, + TAccountMint, + TAccountRecipientTokenAccount, + TAccountVault, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): ExecuteSlowRelayLeafInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountFillStatus, + TAccountMint, + TAccountRecipientTokenAccount, + TAccountVault, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + state: { value: input.state ?? null, isWritable: false }, + rootBundle: { value: input.rootBundle ?? null, isWritable: false }, + fillStatus: { value: input.fillStatus ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + recipientTokenAccount: { + value: input.recipientTokenAccount ?? null, + isWritable: true, + }, + vault: { value: input.vault ?? null, isWritable: true }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.state), + getAccountMeta(accounts.rootBundle), + getAccountMeta(accounts.fillStatus), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.recipientTokenAccount), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getExecuteSlowRelayLeafInstructionDataEncoder().encode( + args as ExecuteSlowRelayLeafInstructionDataArgs + ), + } as ExecuteSlowRelayLeafInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountRootBundle, + TAccountFillStatus, + TAccountMint, + TAccountRecipientTokenAccount, + TAccountVault, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedExecuteSlowRelayLeafInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + instructionParams?: TAccountMetas[1] | undefined; + state: TAccountMetas[2]; + rootBundle: TAccountMetas[3]; + fillStatus: TAccountMetas[4]; + mint: TAccountMetas[5]; + recipientTokenAccount: TAccountMetas[6]; + vault: TAccountMetas[7]; + tokenProgram: TAccountMetas[8]; + systemProgram: TAccountMetas[9]; + eventAuthority: TAccountMetas[10]; + program: TAccountMetas[11]; + }; + data: ExecuteSlowRelayLeafInstructionData; +}; + +export function parseExecuteSlowRelayLeafInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedExecuteSlowRelayLeafInstruction { + if (instruction.accounts.length < 12) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = instruction.accounts![accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === SVM_SPOKE_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + signer: getNextAccount(), + instructionParams: getNextOptionalAccount(), + state: getNextAccount(), + rootBundle: getNextAccount(), + fillStatus: getNextAccount(), + mint: getNextAccount(), + recipientTokenAccount: getNextAccount(), + vault: getNextAccount(), + tokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getExecuteSlowRelayLeafInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/fillRelay.ts b/src/svm/clients/SvmSpoke/instructions/fillRelay.ts new file mode 100644 index 000000000..47f307bca --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/fillRelay.ts @@ -0,0 +1,650 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getOptionDecoder, + getOptionEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type Option, + type OptionOrNullable, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + expectSome, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; +import { + getRelayDataDecoder, + getRelayDataEncoder, + type RelayData, + type RelayDataArgs, +} from '../types'; + +export const FILL_RELAY_DISCRIMINATOR = new Uint8Array([ + 100, 84, 222, 90, 106, 209, 58, 222, +]); + +export function getFillRelayDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(FILL_RELAY_DISCRIMINATOR); +} + +export type FillRelayInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountInstructionParams extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountDelegate extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountRelayerTokenAccount extends string | AccountMeta = string, + TAccountRecipientTokenAccount extends string | AccountMeta = string, + TAccountFillStatus extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountAssociatedTokenProgram extends string | AccountMeta = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountInstructionParams extends string + ? WritableAccount + : TAccountInstructionParams, + TAccountState extends string + ? ReadonlyAccount + : TAccountState, + TAccountDelegate extends string + ? ReadonlyAccount + : TAccountDelegate, + TAccountMint extends string + ? ReadonlyAccount + : TAccountMint, + TAccountRelayerTokenAccount extends string + ? WritableAccount + : TAccountRelayerTokenAccount, + TAccountRecipientTokenAccount extends string + ? WritableAccount + : TAccountRecipientTokenAccount, + TAccountFillStatus extends string + ? WritableAccount + : TAccountFillStatus, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountAssociatedTokenProgram extends string + ? ReadonlyAccount + : TAccountAssociatedTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type FillRelayInstructionData = { + discriminator: ReadonlyUint8Array; + relayHash: ReadonlyUint8Array; + relayData: Option; + repaymentChainId: Option; + repaymentAddress: Option
; +}; + +export type FillRelayInstructionDataArgs = { + relayHash: ReadonlyUint8Array; + relayData: OptionOrNullable; + repaymentChainId: OptionOrNullable; + repaymentAddress: OptionOrNullable
; +}; + +export function getFillRelayInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['relayHash', fixEncoderSize(getBytesEncoder(), 32)], + ['relayData', getOptionEncoder(getRelayDataEncoder())], + ['repaymentChainId', getOptionEncoder(getU64Encoder())], + ['repaymentAddress', getOptionEncoder(getAddressEncoder())], + ]), + (value) => ({ ...value, discriminator: FILL_RELAY_DISCRIMINATOR }) + ); +} + +export function getFillRelayInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['relayHash', fixDecoderSize(getBytesDecoder(), 32)], + ['relayData', getOptionDecoder(getRelayDataDecoder())], + ['repaymentChainId', getOptionDecoder(getU64Decoder())], + ['repaymentAddress', getOptionDecoder(getAddressDecoder())], + ]); +} + +export function getFillRelayInstructionDataCodec(): Codec< + FillRelayInstructionDataArgs, + FillRelayInstructionData +> { + return combineCodec( + getFillRelayInstructionDataEncoder(), + getFillRelayInstructionDataDecoder() + ); +} + +export type FillRelayAsyncInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountState extends string = string, + TAccountDelegate extends string = string, + TAccountMint extends string = string, + TAccountRelayerTokenAccount extends string = string, + TAccountRecipientTokenAccount extends string = string, + TAccountFillStatus extends string = string, + TAccountTokenProgram extends string = string, + TAccountAssociatedTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams?: Address; + state: Address; + delegate: Address; + mint: Address; + relayerTokenAccount: Address; + recipientTokenAccount?: Address; + fillStatus?: Address; + tokenProgram?: Address; + associatedTokenProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + relayHash: FillRelayInstructionDataArgs['relayHash']; + relayData: FillRelayInstructionDataArgs['relayData']; + repaymentChainId: FillRelayInstructionDataArgs['repaymentChainId']; + repaymentAddress: FillRelayInstructionDataArgs['repaymentAddress']; +}; + +export async function getFillRelayInstructionAsync< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountState extends string, + TAccountDelegate extends string, + TAccountMint extends string, + TAccountRelayerTokenAccount extends string, + TAccountRecipientTokenAccount extends string, + TAccountFillStatus extends string, + TAccountTokenProgram extends string, + TAccountAssociatedTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: FillRelayAsyncInput< + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountDelegate, + TAccountMint, + TAccountRelayerTokenAccount, + TAccountRecipientTokenAccount, + TAccountFillStatus, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + FillRelayInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountDelegate, + TAccountMint, + TAccountRelayerTokenAccount, + TAccountRecipientTokenAccount, + TAccountFillStatus, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + state: { value: input.state ?? null, isWritable: false }, + delegate: { value: input.delegate ?? null, isWritable: false }, + mint: { value: input.mint ?? null, isWritable: false }, + relayerTokenAccount: { + value: input.relayerTokenAccount ?? null, + isWritable: true, + }, + recipientTokenAccount: { + value: input.recipientTokenAccount ?? null, + isWritable: true, + }, + fillStatus: { value: input.fillStatus ?? null, isWritable: true }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + associatedTokenProgram: { + value: input.associatedTokenProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionParams.value) { + accounts.instructionParams.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, + 114, 97, 109, 115, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.signer.value)), + ], + }); + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.recipientTokenAccount.value) { + accounts.recipientTokenAccount.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getOptionEncoder(getRelayDataEncoder()).encode( + expectSome(args.relayData) + ), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.fillStatus.value) { + accounts.fillStatus.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode(new Uint8Array([102, 105, 108, 108, 115])), + fixEncoderSize(getBytesEncoder(), 32).encode( + expectSome(args.relayHash) + ), + ], + }); + } + if (!accounts.associatedTokenProgram.value) { + accounts.associatedTokenProgram.value = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.state), + getAccountMeta(accounts.delegate), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.relayerTokenAccount), + getAccountMeta(accounts.recipientTokenAccount), + getAccountMeta(accounts.fillStatus), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.associatedTokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getFillRelayInstructionDataEncoder().encode( + args as FillRelayInstructionDataArgs + ), + } as FillRelayInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountDelegate, + TAccountMint, + TAccountRelayerTokenAccount, + TAccountRecipientTokenAccount, + TAccountFillStatus, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type FillRelayInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountState extends string = string, + TAccountDelegate extends string = string, + TAccountMint extends string = string, + TAccountRelayerTokenAccount extends string = string, + TAccountRecipientTokenAccount extends string = string, + TAccountFillStatus extends string = string, + TAccountTokenProgram extends string = string, + TAccountAssociatedTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams?: Address; + state: Address; + delegate: Address; + mint: Address; + relayerTokenAccount: Address; + recipientTokenAccount: Address; + fillStatus: Address; + tokenProgram?: Address; + associatedTokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + relayHash: FillRelayInstructionDataArgs['relayHash']; + relayData: FillRelayInstructionDataArgs['relayData']; + repaymentChainId: FillRelayInstructionDataArgs['repaymentChainId']; + repaymentAddress: FillRelayInstructionDataArgs['repaymentAddress']; +}; + +export function getFillRelayInstruction< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountState extends string, + TAccountDelegate extends string, + TAccountMint extends string, + TAccountRelayerTokenAccount extends string, + TAccountRecipientTokenAccount extends string, + TAccountFillStatus extends string, + TAccountTokenProgram extends string, + TAccountAssociatedTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: FillRelayInput< + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountDelegate, + TAccountMint, + TAccountRelayerTokenAccount, + TAccountRecipientTokenAccount, + TAccountFillStatus, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): FillRelayInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountDelegate, + TAccountMint, + TAccountRelayerTokenAccount, + TAccountRecipientTokenAccount, + TAccountFillStatus, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + state: { value: input.state ?? null, isWritable: false }, + delegate: { value: input.delegate ?? null, isWritable: false }, + mint: { value: input.mint ?? null, isWritable: false }, + relayerTokenAccount: { + value: input.relayerTokenAccount ?? null, + isWritable: true, + }, + recipientTokenAccount: { + value: input.recipientTokenAccount ?? null, + isWritable: true, + }, + fillStatus: { value: input.fillStatus ?? null, isWritable: true }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + associatedTokenProgram: { + value: input.associatedTokenProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.associatedTokenProgram.value) { + accounts.associatedTokenProgram.value = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.state), + getAccountMeta(accounts.delegate), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.relayerTokenAccount), + getAccountMeta(accounts.recipientTokenAccount), + getAccountMeta(accounts.fillStatus), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.associatedTokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getFillRelayInstructionDataEncoder().encode( + args as FillRelayInstructionDataArgs + ), + } as FillRelayInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountDelegate, + TAccountMint, + TAccountRelayerTokenAccount, + TAccountRecipientTokenAccount, + TAccountFillStatus, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedFillRelayInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + instructionParams?: TAccountMetas[1] | undefined; + state: TAccountMetas[2]; + delegate: TAccountMetas[3]; + mint: TAccountMetas[4]; + relayerTokenAccount: TAccountMetas[5]; + recipientTokenAccount: TAccountMetas[6]; + fillStatus: TAccountMetas[7]; + tokenProgram: TAccountMetas[8]; + associatedTokenProgram: TAccountMetas[9]; + systemProgram: TAccountMetas[10]; + eventAuthority: TAccountMetas[11]; + program: TAccountMetas[12]; + }; + data: FillRelayInstructionData; +}; + +export function parseFillRelayInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedFillRelayInstruction { + if (instruction.accounts.length < 13) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = instruction.accounts![accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === SVM_SPOKE_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + signer: getNextAccount(), + instructionParams: getNextOptionalAccount(), + state: getNextAccount(), + delegate: getNextAccount(), + mint: getNextAccount(), + relayerTokenAccount: getNextAccount(), + recipientTokenAccount: getNextAccount(), + fillStatus: getNextAccount(), + tokenProgram: getNextAccount(), + associatedTokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getFillRelayInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/getUnsafeDepositId.ts b/src/svm/clients/SvmSpoke/instructions/getUnsafeDepositId.ts new file mode 100644 index 000000000..1efa25469 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/getUnsafeDepositId.ts @@ -0,0 +1,142 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; + +export const GET_UNSAFE_DEPOSIT_ID_DISCRIMINATOR = new Uint8Array([ + 118, 10, 135, 0, 168, 243, 223, 117, +]); + +export function getGetUnsafeDepositIdDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + GET_UNSAFE_DEPOSIT_ID_DISCRIMINATOR + ); +} + +export type GetUnsafeDepositIdInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts; + +export type GetUnsafeDepositIdInstructionData = { + discriminator: ReadonlyUint8Array; + signer: Address; + depositor: Address; + depositNonce: bigint; +}; + +export type GetUnsafeDepositIdInstructionDataArgs = { + signer: Address; + depositor: Address; + depositNonce: number | bigint; +}; + +export function getGetUnsafeDepositIdInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['signer', getAddressEncoder()], + ['depositor', getAddressEncoder()], + ['depositNonce', getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: GET_UNSAFE_DEPOSIT_ID_DISCRIMINATOR, + }) + ); +} + +export function getGetUnsafeDepositIdInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['signer', getAddressDecoder()], + ['depositor', getAddressDecoder()], + ['depositNonce', getU64Decoder()], + ]); +} + +export function getGetUnsafeDepositIdInstructionDataCodec(): Codec< + GetUnsafeDepositIdInstructionDataArgs, + GetUnsafeDepositIdInstructionData +> { + return combineCodec( + getGetUnsafeDepositIdInstructionDataEncoder(), + getGetUnsafeDepositIdInstructionDataDecoder() + ); +} + +export type GetUnsafeDepositIdInput = { + signer: GetUnsafeDepositIdInstructionDataArgs['signer']; + depositor: GetUnsafeDepositIdInstructionDataArgs['depositor']; + depositNonce: GetUnsafeDepositIdInstructionDataArgs['depositNonce']; +}; + +export function getGetUnsafeDepositIdInstruction< + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: GetUnsafeDepositIdInput, + config?: { programAddress?: TProgramAddress } +): GetUnsafeDepositIdInstruction { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original args. + const args = { ...input }; + + const instruction = { + programAddress, + data: getGetUnsafeDepositIdInstructionDataEncoder().encode( + args as GetUnsafeDepositIdInstructionDataArgs + ), + } as GetUnsafeDepositIdInstruction; + + return instruction; +} + +export type ParsedGetUnsafeDepositIdInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, +> = { + programAddress: Address; + data: GetUnsafeDepositIdInstructionData; +}; + +export function parseGetUnsafeDepositIdInstruction( + instruction: Instruction & InstructionWithData +): ParsedGetUnsafeDepositIdInstruction { + return { + programAddress: instruction.programAddress, + data: getGetUnsafeDepositIdInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/handleReceiveMessage.ts b/src/svm/clients/SvmSpoke/instructions/handleReceiveMessage.ts new file mode 100644 index 000000000..b1124f722 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/handleReceiveMessage.ts @@ -0,0 +1,382 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const HANDLE_RECEIVE_MESSAGE_DISCRIMINATOR = new Uint8Array([ + 133, 102, 1, 180, 145, 11, 138, 180, +]); + +export function getHandleReceiveMessageDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + HANDLE_RECEIVE_MESSAGE_DISCRIMINATOR + ); +} + +export type HandleReceiveMessageInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountAuthorityPda extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountSelfAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = + 'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountAuthorityPda extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthorityPda, + TAccountState extends string + ? ReadonlyAccount + : TAccountState, + TAccountSelfAuthority extends string + ? ReadonlyAccount + : TAccountSelfAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type HandleReceiveMessageInstructionData = { + discriminator: ReadonlyUint8Array; + remoteDomain: number; + sender: Address; + messageBody: ReadonlyUint8Array; + authorityBump: number; +}; + +export type HandleReceiveMessageInstructionDataArgs = { + remoteDomain: number; + sender: Address; + messageBody: ReadonlyUint8Array; + authorityBump: number; +}; + +export function getHandleReceiveMessageInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['remoteDomain', getU32Encoder()], + ['sender', getAddressEncoder()], + ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ['authorityBump', getU8Encoder()], + ]), + (value) => ({ + ...value, + discriminator: HANDLE_RECEIVE_MESSAGE_DISCRIMINATOR, + }) + ); +} + +export function getHandleReceiveMessageInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['remoteDomain', getU32Decoder()], + ['sender', getAddressDecoder()], + ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ['authorityBump', getU8Decoder()], + ]); +} + +export function getHandleReceiveMessageInstructionDataCodec(): Codec< + HandleReceiveMessageInstructionDataArgs, + HandleReceiveMessageInstructionData +> { + return combineCodec( + getHandleReceiveMessageInstructionDataEncoder(), + getHandleReceiveMessageInstructionDataDecoder() + ); +} + +export type HandleReceiveMessageAsyncInput< + TAccountAuthorityPda extends string = string, + TAccountState extends string = string, + TAccountSelfAuthority extends string = string, + TAccountProgram extends string = string, +> = { + authorityPda?: TransactionSigner; + state: Address; + selfAuthority?: Address; + program?: Address; + remoteDomain: HandleReceiveMessageInstructionDataArgs['remoteDomain']; + sender: HandleReceiveMessageInstructionDataArgs['sender']; + messageBody: HandleReceiveMessageInstructionDataArgs['messageBody']; + authorityBump: HandleReceiveMessageInstructionDataArgs['authorityBump']; +}; + +export async function getHandleReceiveMessageInstructionAsync< + TAccountAuthorityPda extends string, + TAccountState extends string, + TAccountSelfAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: HandleReceiveMessageAsyncInput< + TAccountAuthorityPda, + TAccountState, + TAccountSelfAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + HandleReceiveMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountState, + TAccountSelfAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + authorityPda: { value: input.authorityPda ?? null, isWritable: false }, + state: { value: input.state ?? null, isWritable: false }, + selfAuthority: { value: input.selfAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.authorityPda.value) { + accounts.authorityPda.value = await getProgramDerivedAddress({ + programAddress: + 'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd' as Address<'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd'>, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 109, 101, 115, 115, 97, 103, 101, 95, 116, 114, 97, 110, 115, 109, + 105, 116, 116, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, 116, + 121, + ]) + ), + getBytesEncoder().encode( + new Uint8Array([ + 183, 102, 64, 134, 222, 55, 238, 112, 130, 28, 16, 68, 91, 22, 47, + 44, 126, 200, 121, 91, 208, 128, 12, 20, 98, 148, 158, 35, 40, 209, + 221, 90, + ]) + ), + ], + }); + } + if (!accounts.selfAuthority.value) { + accounts.selfAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 115, 101, 108, 102, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121, + ]) + ), + ], + }); + } + if (!accounts.program.value) { + accounts.program.value = + 'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru' as Address<'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.authorityPda), + getAccountMeta(accounts.state), + getAccountMeta(accounts.selfAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getHandleReceiveMessageInstructionDataEncoder().encode( + args as HandleReceiveMessageInstructionDataArgs + ), + } as HandleReceiveMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountState, + TAccountSelfAuthority, + TAccountProgram + >; + + return instruction; +} + +export type HandleReceiveMessageInput< + TAccountAuthorityPda extends string = string, + TAccountState extends string = string, + TAccountSelfAuthority extends string = string, + TAccountProgram extends string = string, +> = { + authorityPda: TransactionSigner; + state: Address; + selfAuthority: Address; + program?: Address; + remoteDomain: HandleReceiveMessageInstructionDataArgs['remoteDomain']; + sender: HandleReceiveMessageInstructionDataArgs['sender']; + messageBody: HandleReceiveMessageInstructionDataArgs['messageBody']; + authorityBump: HandleReceiveMessageInstructionDataArgs['authorityBump']; +}; + +export function getHandleReceiveMessageInstruction< + TAccountAuthorityPda extends string, + TAccountState extends string, + TAccountSelfAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: HandleReceiveMessageInput< + TAccountAuthorityPda, + TAccountState, + TAccountSelfAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): HandleReceiveMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountState, + TAccountSelfAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + authorityPda: { value: input.authorityPda ?? null, isWritable: false }, + state: { value: input.state ?? null, isWritable: false }, + selfAuthority: { value: input.selfAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.program.value) { + accounts.program.value = + 'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru' as Address<'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.authorityPda), + getAccountMeta(accounts.state), + getAccountMeta(accounts.selfAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getHandleReceiveMessageInstructionDataEncoder().encode( + args as HandleReceiveMessageInstructionDataArgs + ), + } as HandleReceiveMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountState, + TAccountSelfAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedHandleReceiveMessageInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + authorityPda: TAccountMetas[0]; + state: TAccountMetas[1]; + selfAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: HandleReceiveMessageInstructionData; +}; + +export function parseHandleReceiveMessageInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedHandleReceiveMessageInstruction { + if (instruction.accounts.length < 4) { + // 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: { + authorityPda: getNextAccount(), + state: getNextAccount(), + selfAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getHandleReceiveMessageInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/index.ts b/src/svm/clients/SvmSpoke/instructions/index.ts new file mode 100644 index 000000000..04e8a76be --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/index.ts @@ -0,0 +1,35 @@ +/** + * 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 './bridgeTokensToHubPool'; +export * from './claimRelayerRefund'; +export * from './closeClaimAccount'; +export * from './closeFillPda'; +export * from './closeInstructionParams'; +export * from './createTokenAccounts'; +export * from './deposit'; +export * from './depositNow'; +export * from './emergencyDeleteRootBundle'; +export * from './executeRelayerRefundLeaf'; +export * from './executeRelayerRefundLeafDeferred'; +export * from './executeSlowRelayLeaf'; +export * from './fillRelay'; +export * from './getUnsafeDepositId'; +export * from './handleReceiveMessage'; +export * from './initialize'; +export * from './initializeClaimAccount'; +export * from './initializeInstructionParams'; +export * from './pauseDeposits'; +export * from './pauseFills'; +export * from './relayRootBundle'; +export * from './requestSlowFill'; +export * from './setCrossDomainAdmin'; +export * from './setCurrentTime'; +export * from './transferOwnership'; +export * from './unsafeDeposit'; +export * from './writeInstructionParamsFragment'; diff --git a/src/svm/clients/SvmSpoke/instructions/initialize.ts b/src/svm/clients/SvmSpoke/instructions/initialize.ts new file mode 100644 index 000000000..d948e53dd --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/initialize.ts @@ -0,0 +1,345 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectSome, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const INITIALIZE_DISCRIMINATOR = new Uint8Array([ + 175, 175, 109, 31, 13, 152, 155, 237, +]); + +export function getInitializeDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_DISCRIMINATOR); +} + +export type InitializeInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountState extends string + ? WritableAccount + : TAccountState, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type InitializeInstructionData = { + discriminator: ReadonlyUint8Array; + seed: bigint; + initialNumberOfDeposits: number; + chainId: bigint; + remoteDomain: number; + crossDomainAdmin: Address; + depositQuoteTimeBuffer: number; + fillDeadlineBuffer: number; +}; + +export type InitializeInstructionDataArgs = { + seed: number | bigint; + initialNumberOfDeposits: number; + chainId: number | bigint; + remoteDomain: number; + crossDomainAdmin: Address; + depositQuoteTimeBuffer: number; + fillDeadlineBuffer: number; +}; + +export function getInitializeInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['seed', getU64Encoder()], + ['initialNumberOfDeposits', getU32Encoder()], + ['chainId', getU64Encoder()], + ['remoteDomain', getU32Encoder()], + ['crossDomainAdmin', getAddressEncoder()], + ['depositQuoteTimeBuffer', getU32Encoder()], + ['fillDeadlineBuffer', getU32Encoder()], + ]), + (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) + ); +} + +export function getInitializeInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['seed', getU64Decoder()], + ['initialNumberOfDeposits', getU32Decoder()], + ['chainId', getU64Decoder()], + ['remoteDomain', getU32Decoder()], + ['crossDomainAdmin', getAddressDecoder()], + ['depositQuoteTimeBuffer', getU32Decoder()], + ['fillDeadlineBuffer', getU32Decoder()], + ]); +} + +export function getInitializeInstructionDataCodec(): Codec< + InitializeInstructionDataArgs, + InitializeInstructionData +> { + return combineCodec( + getInitializeInstructionDataEncoder(), + getInitializeInstructionDataDecoder() + ); +} + +export type InitializeAsyncInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + state?: Address; + systemProgram?: Address; + seed: InitializeInstructionDataArgs['seed']; + initialNumberOfDeposits: InitializeInstructionDataArgs['initialNumberOfDeposits']; + chainId: InitializeInstructionDataArgs['chainId']; + remoteDomain: InitializeInstructionDataArgs['remoteDomain']; + crossDomainAdmin: InitializeInstructionDataArgs['crossDomainAdmin']; + depositQuoteTimeBuffer: InitializeInstructionDataArgs['depositQuoteTimeBuffer']; + fillDeadlineBuffer: InitializeInstructionDataArgs['fillDeadlineBuffer']; +}; + +export async function getInitializeInstructionAsync< + TAccountSigner extends string, + TAccountState extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: InitializeAsyncInput< + TAccountSigner, + TAccountState, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + InitializeInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountSystemProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.state.value) { + accounts.state.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), + getU64Encoder().encode(expectSome(args.seed)), + ], + }); + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitializeInstructionDataEncoder().encode( + args as InitializeInstructionDataArgs + ), + } as InitializeInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountSystemProgram + >; + + return instruction; +} + +export type InitializeInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + systemProgram?: Address; + seed: InitializeInstructionDataArgs['seed']; + initialNumberOfDeposits: InitializeInstructionDataArgs['initialNumberOfDeposits']; + chainId: InitializeInstructionDataArgs['chainId']; + remoteDomain: InitializeInstructionDataArgs['remoteDomain']; + crossDomainAdmin: InitializeInstructionDataArgs['crossDomainAdmin']; + depositQuoteTimeBuffer: InitializeInstructionDataArgs['depositQuoteTimeBuffer']; + fillDeadlineBuffer: InitializeInstructionDataArgs['fillDeadlineBuffer']; +}; + +export function getInitializeInstruction< + TAccountSigner extends string, + TAccountState extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: InitializeInput, + config?: { programAddress?: TProgramAddress } +): InitializeInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountSystemProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitializeInstructionDataEncoder().encode( + args as InitializeInstructionDataArgs + ), + } as InitializeInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedInitializeInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + state: TAccountMetas[1]; + systemProgram: TAccountMetas[2]; + }; + data: InitializeInstructionData; +}; + +export function parseInitializeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedInitializeInstruction { + 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: { + signer: getNextAccount(), + state: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitializeInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/initializeClaimAccount.ts b/src/svm/clients/SvmSpoke/instructions/initializeClaimAccount.ts new file mode 100644 index 000000000..c701674a4 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/initializeClaimAccount.ts @@ -0,0 +1,345 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const INITIALIZE_CLAIM_ACCOUNT_DISCRIMINATOR = new Uint8Array([ + 22, 247, 214, 191, 90, 74, 87, 216, +]); + +export function getInitializeClaimAccountDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INITIALIZE_CLAIM_ACCOUNT_DISCRIMINATOR + ); +} + +export type InitializeClaimAccountInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountRefundAddress extends string | AccountMeta = string, + TAccountClaimAccount extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountMint extends string + ? ReadonlyAccount + : TAccountMint, + TAccountRefundAddress extends string + ? ReadonlyAccount + : TAccountRefundAddress, + TAccountClaimAccount extends string + ? WritableAccount + : TAccountClaimAccount, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type InitializeClaimAccountInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type InitializeClaimAccountInstructionDataArgs = {}; + +export function getInitializeClaimAccountInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: INITIALIZE_CLAIM_ACCOUNT_DISCRIMINATOR, + }) + ); +} + +export function getInitializeClaimAccountInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getInitializeClaimAccountInstructionDataCodec(): Codec< + InitializeClaimAccountInstructionDataArgs, + InitializeClaimAccountInstructionData +> { + return combineCodec( + getInitializeClaimAccountInstructionDataEncoder(), + getInitializeClaimAccountInstructionDataDecoder() + ); +} + +export type InitializeClaimAccountAsyncInput< + TAccountSigner extends string = string, + TAccountMint extends string = string, + TAccountRefundAddress extends string = string, + TAccountClaimAccount extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + mint: Address; + refundAddress: Address; + claimAccount?: Address; + systemProgram?: Address; +}; + +export async function getInitializeClaimAccountInstructionAsync< + TAccountSigner extends string, + TAccountMint extends string, + TAccountRefundAddress extends string, + TAccountClaimAccount extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: InitializeClaimAccountAsyncInput< + TAccountSigner, + TAccountMint, + TAccountRefundAddress, + TAccountClaimAccount, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + InitializeClaimAccountInstruction< + TProgramAddress, + TAccountSigner, + TAccountMint, + TAccountRefundAddress, + TAccountClaimAccount, + TAccountSystemProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + refundAddress: { value: input.refundAddress ?? null, isWritable: false }, + claimAccount: { value: input.claimAccount ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.claimAccount.value) { + accounts.claimAccount.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 99, 108, 97, 105, 109, 95, 97, 99, 99, 111, 117, 110, 116, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + getAddressEncoder().encode(expectAddress(accounts.refundAddress.value)), + ], + }); + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.refundAddress), + getAccountMeta(accounts.claimAccount), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitializeClaimAccountInstructionDataEncoder().encode({}), + } as InitializeClaimAccountInstruction< + TProgramAddress, + TAccountSigner, + TAccountMint, + TAccountRefundAddress, + TAccountClaimAccount, + TAccountSystemProgram + >; + + return instruction; +} + +export type InitializeClaimAccountInput< + TAccountSigner extends string = string, + TAccountMint extends string = string, + TAccountRefundAddress extends string = string, + TAccountClaimAccount extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + mint: Address; + refundAddress: Address; + claimAccount: Address; + systemProgram?: Address; +}; + +export function getInitializeClaimAccountInstruction< + TAccountSigner extends string, + TAccountMint extends string, + TAccountRefundAddress extends string, + TAccountClaimAccount extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: InitializeClaimAccountInput< + TAccountSigner, + TAccountMint, + TAccountRefundAddress, + TAccountClaimAccount, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): InitializeClaimAccountInstruction< + TProgramAddress, + TAccountSigner, + TAccountMint, + TAccountRefundAddress, + TAccountClaimAccount, + TAccountSystemProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + refundAddress: { value: input.refundAddress ?? null, isWritable: false }, + claimAccount: { value: input.claimAccount ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.refundAddress), + getAccountMeta(accounts.claimAccount), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitializeClaimAccountInstructionDataEncoder().encode({}), + } as InitializeClaimAccountInstruction< + TProgramAddress, + TAccountSigner, + TAccountMint, + TAccountRefundAddress, + TAccountClaimAccount, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedInitializeClaimAccountInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + mint: TAccountMetas[1]; + refundAddress: TAccountMetas[2]; + claimAccount: TAccountMetas[3]; + systemProgram: TAccountMetas[4]; + }; + data: InitializeClaimAccountInstructionData; +}; + +export function parseInitializeClaimAccountInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedInitializeClaimAccountInstruction { + if (instruction.accounts.length < 5) { + // 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: { + signer: getNextAccount(), + mint: getNextAccount(), + refundAddress: getNextAccount(), + claimAccount: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitializeClaimAccountInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/initializeInstructionParams.ts b/src/svm/clients/SvmSpoke/instructions/initializeInstructionParams.ts new file mode 100644 index 000000000..d140c328d --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/initializeInstructionParams.ts @@ -0,0 +1,328 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const INITIALIZE_INSTRUCTION_PARAMS_DISCRIMINATOR = new Uint8Array([ + 94, 206, 190, 192, 127, 8, 186, 28, +]); + +export function getInitializeInstructionParamsDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + INITIALIZE_INSTRUCTION_PARAMS_DISCRIMINATOR + ); +} + +export type InitializeInstructionParamsInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountInstructionParams extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountInstructionParams extends string + ? WritableAccount + : TAccountInstructionParams, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type InitializeInstructionParamsInstructionData = { + discriminator: ReadonlyUint8Array; + totalSize: number; +}; + +export type InitializeInstructionParamsInstructionDataArgs = { + totalSize: number; +}; + +export function getInitializeInstructionParamsInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['totalSize', getU32Encoder()], + ]), + (value) => ({ + ...value, + discriminator: INITIALIZE_INSTRUCTION_PARAMS_DISCRIMINATOR, + }) + ); +} + +export function getInitializeInstructionParamsInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['totalSize', getU32Decoder()], + ]); +} + +export function getInitializeInstructionParamsInstructionDataCodec(): Codec< + InitializeInstructionParamsInstructionDataArgs, + InitializeInstructionParamsInstructionData +> { + return combineCodec( + getInitializeInstructionParamsInstructionDataEncoder(), + getInitializeInstructionParamsInstructionDataDecoder() + ); +} + +export type InitializeInstructionParamsAsyncInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams?: Address; + systemProgram?: Address; + totalSize: InitializeInstructionParamsInstructionDataArgs['totalSize']; +}; + +export async function getInitializeInstructionParamsInstructionAsync< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: InitializeInstructionParamsAsyncInput< + TAccountSigner, + TAccountInstructionParams, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + InitializeInstructionParamsInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountSystemProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionParams.value) { + accounts.instructionParams.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, + 114, 97, 109, 115, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.signer.value)), + ], + }); + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitializeInstructionParamsInstructionDataEncoder().encode( + args as InitializeInstructionParamsInstructionDataArgs + ), + } as InitializeInstructionParamsInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountSystemProgram + >; + + return instruction; +} + +export type InitializeInstructionParamsInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams: Address; + systemProgram?: Address; + totalSize: InitializeInstructionParamsInstructionDataArgs['totalSize']; +}; + +export function getInitializeInstructionParamsInstruction< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: InitializeInstructionParamsInput< + TAccountSigner, + TAccountInstructionParams, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): InitializeInstructionParamsInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountSystemProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getInitializeInstructionParamsInstructionDataEncoder().encode( + args as InitializeInstructionParamsInstructionDataArgs + ), + } as InitializeInstructionParamsInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedInitializeInstructionParamsInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + instructionParams: TAccountMetas[1]; + systemProgram: TAccountMetas[2]; + }; + data: InitializeInstructionParamsInstructionData; +}; + +export function parseInitializeInstructionParamsInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedInitializeInstructionParamsInstruction { + 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: { + signer: getNextAccount(), + instructionParams: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getInitializeInstructionParamsInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/pauseDeposits.ts b/src/svm/clients/SvmSpoke/instructions/pauseDeposits.ts new file mode 100644 index 000000000..16661f397 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/pauseDeposits.ts @@ -0,0 +1,320 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBooleanDecoder, + getBooleanEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const PAUSE_DEPOSITS_DISCRIMINATOR = new Uint8Array([ + 206, 186, 203, 153, 253, 61, 206, 122, +]); + +export function getPauseDepositsDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + PAUSE_DEPOSITS_DISCRIMINATOR + ); +} + +export type PauseDepositsInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountState extends string + ? WritableAccount + : TAccountState, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type PauseDepositsInstructionData = { + discriminator: ReadonlyUint8Array; + pause: boolean; +}; + +export type PauseDepositsInstructionDataArgs = { pause: boolean }; + +export function getPauseDepositsInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['pause', getBooleanEncoder()], + ]), + (value) => ({ ...value, discriminator: PAUSE_DEPOSITS_DISCRIMINATOR }) + ); +} + +export function getPauseDepositsInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['pause', getBooleanDecoder()], + ]); +} + +export function getPauseDepositsInstructionDataCodec(): Codec< + PauseDepositsInstructionDataArgs, + PauseDepositsInstructionData +> { + return combineCodec( + getPauseDepositsInstructionDataEncoder(), + getPauseDepositsInstructionDataDecoder() + ); +} + +export type PauseDepositsAsyncInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + eventAuthority?: Address; + program: Address; + pause: PauseDepositsInstructionDataArgs['pause']; +}; + +export async function getPauseDepositsInstructionAsync< + TAccountSigner extends string, + TAccountState extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: PauseDepositsAsyncInput< + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + PauseDepositsInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + state: { value: input.state ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getPauseDepositsInstructionDataEncoder().encode( + args as PauseDepositsInstructionDataArgs + ), + } as PauseDepositsInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type PauseDepositsInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + eventAuthority: Address; + program: Address; + pause: PauseDepositsInstructionDataArgs['pause']; +}; + +export function getPauseDepositsInstruction< + TAccountSigner extends string, + TAccountState extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: PauseDepositsInput< + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): PauseDepositsInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + state: { value: input.state ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getPauseDepositsInstructionDataEncoder().encode( + args as PauseDepositsInstructionDataArgs + ), + } as PauseDepositsInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedPauseDepositsInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + state: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: PauseDepositsInstructionData; +}; + +export function parsePauseDepositsInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedPauseDepositsInstruction { + if (instruction.accounts.length < 4) { + // 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: { + signer: getNextAccount(), + state: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getPauseDepositsInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/pauseFills.ts b/src/svm/clients/SvmSpoke/instructions/pauseFills.ts new file mode 100644 index 000000000..967019a70 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/pauseFills.ts @@ -0,0 +1,318 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBooleanDecoder, + getBooleanEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const PAUSE_FILLS_DISCRIMINATOR = new Uint8Array([ + 92, 114, 214, 49, 13, 243, 73, 35, +]); + +export function getPauseFillsDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(PAUSE_FILLS_DISCRIMINATOR); +} + +export type PauseFillsInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountState extends string + ? WritableAccount + : TAccountState, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type PauseFillsInstructionData = { + discriminator: ReadonlyUint8Array; + pause: boolean; +}; + +export type PauseFillsInstructionDataArgs = { pause: boolean }; + +export function getPauseFillsInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['pause', getBooleanEncoder()], + ]), + (value) => ({ ...value, discriminator: PAUSE_FILLS_DISCRIMINATOR }) + ); +} + +export function getPauseFillsInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['pause', getBooleanDecoder()], + ]); +} + +export function getPauseFillsInstructionDataCodec(): Codec< + PauseFillsInstructionDataArgs, + PauseFillsInstructionData +> { + return combineCodec( + getPauseFillsInstructionDataEncoder(), + getPauseFillsInstructionDataDecoder() + ); +} + +export type PauseFillsAsyncInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + eventAuthority?: Address; + program: Address; + pause: PauseFillsInstructionDataArgs['pause']; +}; + +export async function getPauseFillsInstructionAsync< + TAccountSigner extends string, + TAccountState extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: PauseFillsAsyncInput< + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + PauseFillsInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + state: { value: input.state ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getPauseFillsInstructionDataEncoder().encode( + args as PauseFillsInstructionDataArgs + ), + } as PauseFillsInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type PauseFillsInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + eventAuthority: Address; + program: Address; + pause: PauseFillsInstructionDataArgs['pause']; +}; + +export function getPauseFillsInstruction< + TAccountSigner extends string, + TAccountState extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: PauseFillsInput< + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): PauseFillsInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + state: { value: input.state ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getPauseFillsInstructionDataEncoder().encode( + args as PauseFillsInstructionDataArgs + ), + } as PauseFillsInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedPauseFillsInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + state: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: PauseFillsInstructionData; +}; + +export function parsePauseFillsInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedPauseFillsInstruction { + if (instruction.accounts.length < 4) { + // 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: { + signer: getNextAccount(), + state: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getPauseFillsInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/relayRootBundle.ts b/src/svm/clients/SvmSpoke/instructions/relayRootBundle.ts new file mode 100644 index 000000000..52d9be8cb --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/relayRootBundle.ts @@ -0,0 +1,405 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const RELAY_ROOT_BUNDLE_DISCRIMINATOR = new Uint8Array([ + 69, 13, 223, 204, 251, 61, 105, 6, +]); + +export function getRelayRootBundleDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + RELAY_ROOT_BUNDLE_DISCRIMINATOR + ); +} + +export type RelayRootBundleInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountPayer extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountRootBundle extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountState extends string + ? WritableAccount + : TAccountState, + TAccountRootBundle extends string + ? WritableAccount + : TAccountRootBundle, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type RelayRootBundleInstructionData = { + discriminator: ReadonlyUint8Array; + relayerRefundRoot: ReadonlyUint8Array; + slowRelayRoot: ReadonlyUint8Array; +}; + +export type RelayRootBundleInstructionDataArgs = { + relayerRefundRoot: ReadonlyUint8Array; + slowRelayRoot: ReadonlyUint8Array; +}; + +export function getRelayRootBundleInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['relayerRefundRoot', fixEncoderSize(getBytesEncoder(), 32)], + ['slowRelayRoot', fixEncoderSize(getBytesEncoder(), 32)], + ]), + (value) => ({ ...value, discriminator: RELAY_ROOT_BUNDLE_DISCRIMINATOR }) + ); +} + +export function getRelayRootBundleInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['relayerRefundRoot', fixDecoderSize(getBytesDecoder(), 32)], + ['slowRelayRoot', fixDecoderSize(getBytesDecoder(), 32)], + ]); +} + +export function getRelayRootBundleInstructionDataCodec(): Codec< + RelayRootBundleInstructionDataArgs, + RelayRootBundleInstructionData +> { + return combineCodec( + getRelayRootBundleInstructionDataEncoder(), + getRelayRootBundleInstructionDataDecoder() + ); +} + +export type RelayRootBundleAsyncInput< + TAccountSigner extends string = string, + TAccountPayer extends string = string, + TAccountState extends string = string, + TAccountRootBundle extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + payer: TransactionSigner; + state: Address; + rootBundle: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + relayerRefundRoot: RelayRootBundleInstructionDataArgs['relayerRefundRoot']; + slowRelayRoot: RelayRootBundleInstructionDataArgs['slowRelayRoot']; +}; + +export async function getRelayRootBundleInstructionAsync< + TAccountSigner extends string, + TAccountPayer extends string, + TAccountState extends string, + TAccountRootBundle extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: RelayRootBundleAsyncInput< + TAccountSigner, + TAccountPayer, + TAccountState, + TAccountRootBundle, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + RelayRootBundleInstruction< + TProgramAddress, + TAccountSigner, + TAccountPayer, + TAccountState, + TAccountRootBundle, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + payer: { value: input.payer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + rootBundle: { value: input.rootBundle ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.payer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.rootBundle), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getRelayRootBundleInstructionDataEncoder().encode( + args as RelayRootBundleInstructionDataArgs + ), + } as RelayRootBundleInstruction< + TProgramAddress, + TAccountSigner, + TAccountPayer, + TAccountState, + TAccountRootBundle, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type RelayRootBundleInput< + TAccountSigner extends string = string, + TAccountPayer extends string = string, + TAccountState extends string = string, + TAccountRootBundle extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + payer: TransactionSigner; + state: Address; + rootBundle: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + relayerRefundRoot: RelayRootBundleInstructionDataArgs['relayerRefundRoot']; + slowRelayRoot: RelayRootBundleInstructionDataArgs['slowRelayRoot']; +}; + +export function getRelayRootBundleInstruction< + TAccountSigner extends string, + TAccountPayer extends string, + TAccountState extends string, + TAccountRootBundle extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: RelayRootBundleInput< + TAccountSigner, + TAccountPayer, + TAccountState, + TAccountRootBundle, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): RelayRootBundleInstruction< + TProgramAddress, + TAccountSigner, + TAccountPayer, + TAccountState, + TAccountRootBundle, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + payer: { value: input.payer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + rootBundle: { value: input.rootBundle ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.payer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.rootBundle), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getRelayRootBundleInstructionDataEncoder().encode( + args as RelayRootBundleInstructionDataArgs + ), + } as RelayRootBundleInstruction< + TProgramAddress, + TAccountSigner, + TAccountPayer, + TAccountState, + TAccountRootBundle, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedRelayRootBundleInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + payer: TAccountMetas[1]; + state: TAccountMetas[2]; + rootBundle: TAccountMetas[3]; + systemProgram: TAccountMetas[4]; + eventAuthority: TAccountMetas[5]; + program: TAccountMetas[6]; + }; + data: RelayRootBundleInstructionData; +}; + +export function parseRelayRootBundleInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedRelayRootBundleInstruction { + if (instruction.accounts.length < 7) { + // 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: { + signer: getNextAccount(), + payer: getNextAccount(), + state: getNextAccount(), + rootBundle: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getRelayRootBundleInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/requestSlowFill.ts b/src/svm/clients/SvmSpoke/instructions/requestSlowFill.ts new file mode 100644 index 000000000..2c5b39d2d --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/requestSlowFill.ts @@ -0,0 +1,456 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getOptionDecoder, + getOptionEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type Option, + type OptionOrNullable, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + expectSome, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; +import { + getRelayDataDecoder, + getRelayDataEncoder, + type RelayData, + type RelayDataArgs, +} from '../types'; + +export const REQUEST_SLOW_FILL_DISCRIMINATOR = new Uint8Array([ + 39, 157, 165, 187, 88, 217, 207, 98, +]); + +export function getRequestSlowFillDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REQUEST_SLOW_FILL_DISCRIMINATOR + ); +} + +export type RequestSlowFillInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountInstructionParams extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountFillStatus extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountInstructionParams extends string + ? WritableAccount + : TAccountInstructionParams, + TAccountState extends string + ? ReadonlyAccount + : TAccountState, + TAccountFillStatus extends string + ? WritableAccount + : TAccountFillStatus, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type RequestSlowFillInstructionData = { + discriminator: ReadonlyUint8Array; + relayHash: ReadonlyUint8Array; + relayData: Option; +}; + +export type RequestSlowFillInstructionDataArgs = { + relayHash: ReadonlyUint8Array; + relayData: OptionOrNullable; +}; + +export function getRequestSlowFillInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['relayHash', fixEncoderSize(getBytesEncoder(), 32)], + ['relayData', getOptionEncoder(getRelayDataEncoder())], + ]), + (value) => ({ ...value, discriminator: REQUEST_SLOW_FILL_DISCRIMINATOR }) + ); +} + +export function getRequestSlowFillInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['relayHash', fixDecoderSize(getBytesDecoder(), 32)], + ['relayData', getOptionDecoder(getRelayDataDecoder())], + ]); +} + +export function getRequestSlowFillInstructionDataCodec(): Codec< + RequestSlowFillInstructionDataArgs, + RequestSlowFillInstructionData +> { + return combineCodec( + getRequestSlowFillInstructionDataEncoder(), + getRequestSlowFillInstructionDataDecoder() + ); +} + +export type RequestSlowFillAsyncInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountState extends string = string, + TAccountFillStatus extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams?: Address; + state: Address; + fillStatus?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + relayHash: RequestSlowFillInstructionDataArgs['relayHash']; + relayData: RequestSlowFillInstructionDataArgs['relayData']; +}; + +export async function getRequestSlowFillInstructionAsync< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountState extends string, + TAccountFillStatus extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: RequestSlowFillAsyncInput< + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountFillStatus, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + RequestSlowFillInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountFillStatus, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + state: { value: input.state ?? null, isWritable: false }, + fillStatus: { value: input.fillStatus ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionParams.value) { + accounts.instructionParams.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, + 114, 97, 109, 115, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.signer.value)), + ], + }); + } + if (!accounts.fillStatus.value) { + accounts.fillStatus.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode(new Uint8Array([102, 105, 108, 108, 115])), + fixEncoderSize(getBytesEncoder(), 32).encode( + expectSome(args.relayHash) + ), + ], + }); + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.state), + getAccountMeta(accounts.fillStatus), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getRequestSlowFillInstructionDataEncoder().encode( + args as RequestSlowFillInstructionDataArgs + ), + } as RequestSlowFillInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountFillStatus, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type RequestSlowFillInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountState extends string = string, + TAccountFillStatus extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams?: Address; + state: Address; + fillStatus: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + relayHash: RequestSlowFillInstructionDataArgs['relayHash']; + relayData: RequestSlowFillInstructionDataArgs['relayData']; +}; + +export function getRequestSlowFillInstruction< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountState extends string, + TAccountFillStatus extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: RequestSlowFillInput< + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountFillStatus, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): RequestSlowFillInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountFillStatus, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + state: { value: input.state ?? null, isWritable: false }, + fillStatus: { value: input.fillStatus ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.state), + getAccountMeta(accounts.fillStatus), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getRequestSlowFillInstructionDataEncoder().encode( + args as RequestSlowFillInstructionDataArgs + ), + } as RequestSlowFillInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountState, + TAccountFillStatus, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedRequestSlowFillInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + instructionParams?: TAccountMetas[1] | undefined; + state: TAccountMetas[2]; + fillStatus: TAccountMetas[3]; + systemProgram: TAccountMetas[4]; + eventAuthority: TAccountMetas[5]; + program: TAccountMetas[6]; + }; + data: RequestSlowFillInstructionData; +}; + +export function parseRequestSlowFillInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedRequestSlowFillInstruction { + if (instruction.accounts.length < 7) { + // TODO: Coded error. + throw new Error('Not enough accounts'); + } + let accountIndex = 0; + const getNextAccount = () => { + const accountMeta = instruction.accounts![accountIndex]!; + accountIndex += 1; + return accountMeta; + }; + const getNextOptionalAccount = () => { + const accountMeta = getNextAccount(); + return accountMeta.address === SVM_SPOKE_PROGRAM_ADDRESS + ? undefined + : accountMeta; + }; + return { + programAddress: instruction.programAddress, + accounts: { + signer: getNextAccount(), + instructionParams: getNextOptionalAccount(), + state: getNextAccount(), + fillStatus: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getRequestSlowFillInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/setCrossDomainAdmin.ts b/src/svm/clients/SvmSpoke/instructions/setCrossDomainAdmin.ts new file mode 100644 index 000000000..8484ffa00 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/setCrossDomainAdmin.ts @@ -0,0 +1,327 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_CROSS_DOMAIN_ADMIN_DISCRIMINATOR = new Uint8Array([ + 102, 206, 237, 106, 63, 141, 42, 248, +]); + +export function getSetCrossDomainAdminDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_CROSS_DOMAIN_ADMIN_DISCRIMINATOR + ); +} + +export type SetCrossDomainAdminInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountState extends string + ? WritableAccount + : TAccountState, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type SetCrossDomainAdminInstructionData = { + discriminator: ReadonlyUint8Array; + crossDomainAdmin: Address; +}; + +export type SetCrossDomainAdminInstructionDataArgs = { + crossDomainAdmin: Address; +}; + +export function getSetCrossDomainAdminInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['crossDomainAdmin', getAddressEncoder()], + ]), + (value) => ({ + ...value, + discriminator: SET_CROSS_DOMAIN_ADMIN_DISCRIMINATOR, + }) + ); +} + +export function getSetCrossDomainAdminInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['crossDomainAdmin', getAddressDecoder()], + ]); +} + +export function getSetCrossDomainAdminInstructionDataCodec(): Codec< + SetCrossDomainAdminInstructionDataArgs, + SetCrossDomainAdminInstructionData +> { + return combineCodec( + getSetCrossDomainAdminInstructionDataEncoder(), + getSetCrossDomainAdminInstructionDataDecoder() + ); +} + +export type SetCrossDomainAdminAsyncInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + eventAuthority?: Address; + program: Address; + crossDomainAdmin: SetCrossDomainAdminInstructionDataArgs['crossDomainAdmin']; +}; + +export async function getSetCrossDomainAdminInstructionAsync< + TAccountSigner extends string, + TAccountState extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: SetCrossDomainAdminAsyncInput< + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + SetCrossDomainAdminInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + state: { value: input.state ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetCrossDomainAdminInstructionDataEncoder().encode( + args as SetCrossDomainAdminInstructionDataArgs + ), + } as SetCrossDomainAdminInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type SetCrossDomainAdminInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + eventAuthority: Address; + program: Address; + crossDomainAdmin: SetCrossDomainAdminInstructionDataArgs['crossDomainAdmin']; +}; + +export function getSetCrossDomainAdminInstruction< + TAccountSigner extends string, + TAccountState extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: SetCrossDomainAdminInput< + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): SetCrossDomainAdminInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + state: { value: input.state ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetCrossDomainAdminInstructionDataEncoder().encode( + args as SetCrossDomainAdminInstructionDataArgs + ), + } as SetCrossDomainAdminInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedSetCrossDomainAdminInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + state: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: SetCrossDomainAdminInstructionData; +}; + +export function parseSetCrossDomainAdminInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetCrossDomainAdminInstruction { + if (instruction.accounts.length < 4) { + // 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: { + signer: getNextAccount(), + state: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getSetCrossDomainAdminInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/setCurrentTime.ts b/src/svm/clients/SvmSpoke/instructions/setCurrentTime.ts new file mode 100644 index 000000000..c557fa902 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/setCurrentTime.ts @@ -0,0 +1,188 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_CURRENT_TIME_DISCRIMINATOR = new Uint8Array([ + 69, 100, 169, 193, 125, 0, 150, 69, +]); + +export function getSetCurrentTimeDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_CURRENT_TIME_DISCRIMINATOR + ); +} + +export type SetCurrentTimeInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountState extends string | AccountMeta = string, + TAccountSigner extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountState extends string + ? WritableAccount + : TAccountState, + TAccountSigner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSigner, + ...TRemainingAccounts, + ] + >; + +export type SetCurrentTimeInstructionData = { + discriminator: ReadonlyUint8Array; + newTime: number; +}; + +export type SetCurrentTimeInstructionDataArgs = { newTime: number }; + +export function getSetCurrentTimeInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newTime', getU32Encoder()], + ]), + (value) => ({ ...value, discriminator: SET_CURRENT_TIME_DISCRIMINATOR }) + ); +} + +export function getSetCurrentTimeInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newTime', getU32Decoder()], + ]); +} + +export function getSetCurrentTimeInstructionDataCodec(): Codec< + SetCurrentTimeInstructionDataArgs, + SetCurrentTimeInstructionData +> { + return combineCodec( + getSetCurrentTimeInstructionDataEncoder(), + getSetCurrentTimeInstructionDataDecoder() + ); +} + +export type SetCurrentTimeInput< + TAccountState extends string = string, + TAccountSigner extends string = string, +> = { + state: Address; + signer: TransactionSigner; + newTime: SetCurrentTimeInstructionDataArgs['newTime']; +}; + +export function getSetCurrentTimeInstruction< + TAccountState extends string, + TAccountSigner extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: SetCurrentTimeInput, + config?: { programAddress?: TProgramAddress } +): SetCurrentTimeInstruction { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + state: { value: input.state ?? null, isWritable: true }, + signer: { value: input.signer ?? 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.state), getAccountMeta(accounts.signer)], + programAddress, + data: getSetCurrentTimeInstructionDataEncoder().encode( + args as SetCurrentTimeInstructionDataArgs + ), + } as SetCurrentTimeInstruction< + TProgramAddress, + TAccountState, + TAccountSigner + >; + + return instruction; +} + +export type ParsedSetCurrentTimeInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + state: TAccountMetas[0]; + signer: TAccountMetas[1]; + }; + data: SetCurrentTimeInstructionData; +}; + +export function parseSetCurrentTimeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetCurrentTimeInstruction { + if (instruction.accounts.length < 2) { + // 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: { + state: getNextAccount(), + signer: getNextAccount(), + }, + data: getSetCurrentTimeInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/transferOwnership.ts b/src/svm/clients/SvmSpoke/instructions/transferOwnership.ts new file mode 100644 index 000000000..c23021b57 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/transferOwnership.ts @@ -0,0 +1,320 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const TRANSFER_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ + 65, 177, 215, 73, 53, 45, 99, 47, +]); + +export function getTransferOwnershipDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + TRANSFER_OWNERSHIP_DISCRIMINATOR + ); +} + +export type TransferOwnershipInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountState extends string + ? WritableAccount + : TAccountState, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type TransferOwnershipInstructionData = { + discriminator: ReadonlyUint8Array; + newOwner: Address; +}; + +export type TransferOwnershipInstructionDataArgs = { newOwner: Address }; + +export function getTransferOwnershipInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newOwner', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: TRANSFER_OWNERSHIP_DISCRIMINATOR }) + ); +} + +export function getTransferOwnershipInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newOwner', getAddressDecoder()], + ]); +} + +export function getTransferOwnershipInstructionDataCodec(): Codec< + TransferOwnershipInstructionDataArgs, + TransferOwnershipInstructionData +> { + return combineCodec( + getTransferOwnershipInstructionDataEncoder(), + getTransferOwnershipInstructionDataDecoder() + ); +} + +export type TransferOwnershipAsyncInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + eventAuthority?: Address; + program: Address; + newOwner: TransferOwnershipInstructionDataArgs['newOwner']; +}; + +export async function getTransferOwnershipInstructionAsync< + TAccountSigner extends string, + TAccountState extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: TransferOwnershipAsyncInput< + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + TransferOwnershipInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + state: { value: input.state ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getTransferOwnershipInstructionDataEncoder().encode( + args as TransferOwnershipInstructionDataArgs + ), + } as TransferOwnershipInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type TransferOwnershipInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + eventAuthority: Address; + program: Address; + newOwner: TransferOwnershipInstructionDataArgs['newOwner']; +}; + +export function getTransferOwnershipInstruction< + TAccountSigner extends string, + TAccountState extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: TransferOwnershipInput< + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): TransferOwnershipInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + state: { value: input.state ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getTransferOwnershipInstructionDataEncoder().encode( + args as TransferOwnershipInstructionDataArgs + ), + } as TransferOwnershipInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedTransferOwnershipInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + state: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: TransferOwnershipInstructionData; +}; + +export function parseTransferOwnershipInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedTransferOwnershipInstruction { + if (instruction.accounts.length < 4) { + // 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: { + signer: getNextAccount(), + state: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getTransferOwnershipInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/unsafeDeposit.ts b/src/svm/clients/SvmSpoke/instructions/unsafeDeposit.ts new file mode 100644 index 000000000..d3d8eb447 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/unsafeDeposit.ts @@ -0,0 +1,622 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + expectSome, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const UNSAFE_DEPOSIT_DISCRIMINATOR = new Uint8Array([ + 196, 187, 166, 179, 3, 146, 150, 246, +]); + +export function getUnsafeDepositDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UNSAFE_DEPOSIT_DISCRIMINATOR + ); +} + +export type UnsafeDepositInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountState extends string | AccountMeta = string, + TAccountDelegate extends string | AccountMeta = string, + TAccountDepositorTokenAccount extends string | AccountMeta = string, + TAccountVault extends string | AccountMeta = string, + TAccountMint extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountAssociatedTokenProgram extends string | AccountMeta = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountState extends string + ? WritableAccount + : TAccountState, + TAccountDelegate extends string + ? ReadonlyAccount + : TAccountDelegate, + TAccountDepositorTokenAccount extends string + ? WritableAccount + : TAccountDepositorTokenAccount, + TAccountVault extends string + ? WritableAccount + : TAccountVault, + TAccountMint extends string + ? ReadonlyAccount + : TAccountMint, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountAssociatedTokenProgram extends string + ? ReadonlyAccount + : TAccountAssociatedTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UnsafeDepositInstructionData = { + discriminator: ReadonlyUint8Array; + depositor: Address; + recipient: Address; + inputToken: Address; + outputToken: Address; + inputAmount: bigint; + outputAmount: ReadonlyUint8Array; + destinationChainId: bigint; + exclusiveRelayer: Address; + depositNonce: bigint; + quoteTimestamp: number; + fillDeadline: number; + exclusivityParameter: number; + message: ReadonlyUint8Array; +}; + +export type UnsafeDepositInstructionDataArgs = { + depositor: Address; + recipient: Address; + inputToken: Address; + outputToken: Address; + inputAmount: number | bigint; + outputAmount: ReadonlyUint8Array; + destinationChainId: number | bigint; + exclusiveRelayer: Address; + depositNonce: number | bigint; + quoteTimestamp: number; + fillDeadline: number; + exclusivityParameter: number; + message: ReadonlyUint8Array; +}; + +export function getUnsafeDepositInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['depositor', getAddressEncoder()], + ['recipient', getAddressEncoder()], + ['inputToken', getAddressEncoder()], + ['outputToken', getAddressEncoder()], + ['inputAmount', getU64Encoder()], + ['outputAmount', fixEncoderSize(getBytesEncoder(), 32)], + ['destinationChainId', getU64Encoder()], + ['exclusiveRelayer', getAddressEncoder()], + ['depositNonce', getU64Encoder()], + ['quoteTimestamp', getU32Encoder()], + ['fillDeadline', getU32Encoder()], + ['exclusivityParameter', getU32Encoder()], + ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ ...value, discriminator: UNSAFE_DEPOSIT_DISCRIMINATOR }) + ); +} + +export function getUnsafeDepositInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['depositor', getAddressDecoder()], + ['recipient', getAddressDecoder()], + ['inputToken', getAddressDecoder()], + ['outputToken', getAddressDecoder()], + ['inputAmount', getU64Decoder()], + ['outputAmount', fixDecoderSize(getBytesDecoder(), 32)], + ['destinationChainId', getU64Decoder()], + ['exclusiveRelayer', getAddressDecoder()], + ['depositNonce', getU64Decoder()], + ['quoteTimestamp', getU32Decoder()], + ['fillDeadline', getU32Decoder()], + ['exclusivityParameter', getU32Decoder()], + ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getUnsafeDepositInstructionDataCodec(): Codec< + UnsafeDepositInstructionDataArgs, + UnsafeDepositInstructionData +> { + return combineCodec( + getUnsafeDepositInstructionDataEncoder(), + getUnsafeDepositInstructionDataDecoder() + ); +} + +export type UnsafeDepositAsyncInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountDelegate extends string = string, + TAccountDepositorTokenAccount extends string = string, + TAccountVault extends string = string, + TAccountMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountAssociatedTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + delegate: Address; + depositorTokenAccount?: Address; + vault?: Address; + mint: Address; + tokenProgram?: Address; + associatedTokenProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + depositor: UnsafeDepositInstructionDataArgs['depositor']; + recipient: UnsafeDepositInstructionDataArgs['recipient']; + inputToken: UnsafeDepositInstructionDataArgs['inputToken']; + outputToken: UnsafeDepositInstructionDataArgs['outputToken']; + inputAmount: UnsafeDepositInstructionDataArgs['inputAmount']; + outputAmount: UnsafeDepositInstructionDataArgs['outputAmount']; + destinationChainId: UnsafeDepositInstructionDataArgs['destinationChainId']; + exclusiveRelayer: UnsafeDepositInstructionDataArgs['exclusiveRelayer']; + depositNonce: UnsafeDepositInstructionDataArgs['depositNonce']; + quoteTimestamp: UnsafeDepositInstructionDataArgs['quoteTimestamp']; + fillDeadline: UnsafeDepositInstructionDataArgs['fillDeadline']; + exclusivityParameter: UnsafeDepositInstructionDataArgs['exclusivityParameter']; + message: UnsafeDepositInstructionDataArgs['message']; +}; + +export async function getUnsafeDepositInstructionAsync< + TAccountSigner extends string, + TAccountState extends string, + TAccountDelegate extends string, + TAccountDepositorTokenAccount extends string, + TAccountVault extends string, + TAccountMint extends string, + TAccountTokenProgram extends string, + TAccountAssociatedTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: UnsafeDepositAsyncInput< + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + UnsafeDepositInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + delegate: { value: input.delegate ?? null, isWritable: false }, + depositorTokenAccount: { + value: input.depositorTokenAccount ?? null, + isWritable: true, + }, + vault: { value: input.vault ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + associatedTokenProgram: { + value: input.associatedTokenProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.depositorTokenAccount.value) { + accounts.depositorTokenAccount.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getAddressEncoder().encode(expectSome(args.depositor)), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.vault.value) { + accounts.vault.value = await getProgramDerivedAddress({ + programAddress: + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, + seeds: [ + getAddressEncoder().encode(expectAddress(accounts.state.value)), + getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), + getAddressEncoder().encode(expectAddress(accounts.mint.value)), + ], + }); + } + if (!accounts.associatedTokenProgram.value) { + accounts.associatedTokenProgram.value = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.delegate), + getAccountMeta(accounts.depositorTokenAccount), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.associatedTokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUnsafeDepositInstructionDataEncoder().encode( + args as UnsafeDepositInstructionDataArgs + ), + } as UnsafeDepositInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type UnsafeDepositInput< + TAccountSigner extends string = string, + TAccountState extends string = string, + TAccountDelegate extends string = string, + TAccountDepositorTokenAccount extends string = string, + TAccountVault extends string = string, + TAccountMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountAssociatedTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + signer: TransactionSigner; + state: Address; + delegate: Address; + depositorTokenAccount: Address; + vault: Address; + mint: Address; + tokenProgram?: Address; + associatedTokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + depositor: UnsafeDepositInstructionDataArgs['depositor']; + recipient: UnsafeDepositInstructionDataArgs['recipient']; + inputToken: UnsafeDepositInstructionDataArgs['inputToken']; + outputToken: UnsafeDepositInstructionDataArgs['outputToken']; + inputAmount: UnsafeDepositInstructionDataArgs['inputAmount']; + outputAmount: UnsafeDepositInstructionDataArgs['outputAmount']; + destinationChainId: UnsafeDepositInstructionDataArgs['destinationChainId']; + exclusiveRelayer: UnsafeDepositInstructionDataArgs['exclusiveRelayer']; + depositNonce: UnsafeDepositInstructionDataArgs['depositNonce']; + quoteTimestamp: UnsafeDepositInstructionDataArgs['quoteTimestamp']; + fillDeadline: UnsafeDepositInstructionDataArgs['fillDeadline']; + exclusivityParameter: UnsafeDepositInstructionDataArgs['exclusivityParameter']; + message: UnsafeDepositInstructionDataArgs['message']; +}; + +export function getUnsafeDepositInstruction< + TAccountSigner extends string, + TAccountState extends string, + TAccountDelegate extends string, + TAccountDepositorTokenAccount extends string, + TAccountVault extends string, + TAccountMint extends string, + TAccountTokenProgram extends string, + TAccountAssociatedTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: UnsafeDepositInput< + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UnsafeDepositInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: true }, + state: { value: input.state ?? null, isWritable: true }, + delegate: { value: input.delegate ?? null, isWritable: false }, + depositorTokenAccount: { + value: input.depositorTokenAccount ?? null, + isWritable: true, + }, + vault: { value: input.vault ?? null, isWritable: true }, + mint: { value: input.mint ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + associatedTokenProgram: { + value: input.associatedTokenProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.associatedTokenProgram.value) { + accounts.associatedTokenProgram.value = + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.state), + getAccountMeta(accounts.delegate), + getAccountMeta(accounts.depositorTokenAccount), + getAccountMeta(accounts.vault), + getAccountMeta(accounts.mint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.associatedTokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUnsafeDepositInstructionDataEncoder().encode( + args as UnsafeDepositInstructionDataArgs + ), + } as UnsafeDepositInstruction< + TProgramAddress, + TAccountSigner, + TAccountState, + TAccountDelegate, + TAccountDepositorTokenAccount, + TAccountVault, + TAccountMint, + TAccountTokenProgram, + TAccountAssociatedTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUnsafeDepositInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + state: TAccountMetas[1]; + delegate: TAccountMetas[2]; + depositorTokenAccount: TAccountMetas[3]; + vault: TAccountMetas[4]; + mint: TAccountMetas[5]; + tokenProgram: TAccountMetas[6]; + associatedTokenProgram: TAccountMetas[7]; + systemProgram: TAccountMetas[8]; + eventAuthority: TAccountMetas[9]; + program: TAccountMetas[10]; + }; + data: UnsafeDepositInstructionData; +}; + +export function parseUnsafeDepositInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUnsafeDepositInstruction { + if (instruction.accounts.length < 11) { + // 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: { + signer: getNextAccount(), + state: getNextAccount(), + delegate: getNextAccount(), + depositorTokenAccount: getNextAccount(), + vault: getNextAccount(), + mint: getNextAccount(), + tokenProgram: getNextAccount(), + associatedTokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUnsafeDepositInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/SvmSpoke/instructions/writeInstructionParamsFragment.ts b/src/svm/clients/SvmSpoke/instructions/writeInstructionParamsFragment.ts new file mode 100644 index 000000000..cf863c6b1 --- /dev/null +++ b/src/svm/clients/SvmSpoke/instructions/writeInstructionParamsFragment.ts @@ -0,0 +1,336 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const WRITE_INSTRUCTION_PARAMS_FRAGMENT_DISCRIMINATOR = new Uint8Array([ + 238, 182, 109, 113, 124, 255, 72, 18, +]); + +export function getWriteInstructionParamsFragmentDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + WRITE_INSTRUCTION_PARAMS_FRAGMENT_DISCRIMINATOR + ); +} + +export type WriteInstructionParamsFragmentInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountSigner extends string | AccountMeta = string, + TAccountInstructionParams extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountSigner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountSigner, + TAccountInstructionParams extends string + ? WritableAccount + : TAccountInstructionParams, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + ...TRemainingAccounts, + ] + >; + +export type WriteInstructionParamsFragmentInstructionData = { + discriminator: ReadonlyUint8Array; + offset: number; + fragment: ReadonlyUint8Array; +}; + +export type WriteInstructionParamsFragmentInstructionDataArgs = { + offset: number; + fragment: ReadonlyUint8Array; +}; + +export function getWriteInstructionParamsFragmentInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['offset', getU32Encoder()], + ['fragment', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ + ...value, + discriminator: WRITE_INSTRUCTION_PARAMS_FRAGMENT_DISCRIMINATOR, + }) + ); +} + +export function getWriteInstructionParamsFragmentInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['offset', getU32Decoder()], + ['fragment', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getWriteInstructionParamsFragmentInstructionDataCodec(): Codec< + WriteInstructionParamsFragmentInstructionDataArgs, + WriteInstructionParamsFragmentInstructionData +> { + return combineCodec( + getWriteInstructionParamsFragmentInstructionDataEncoder(), + getWriteInstructionParamsFragmentInstructionDataDecoder() + ); +} + +export type WriteInstructionParamsFragmentAsyncInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams?: Address; + systemProgram?: Address; + offset: WriteInstructionParamsFragmentInstructionDataArgs['offset']; + fragment: WriteInstructionParamsFragmentInstructionDataArgs['fragment']; +}; + +export async function getWriteInstructionParamsFragmentInstructionAsync< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: WriteInstructionParamsFragmentAsyncInput< + TAccountSigner, + TAccountInstructionParams, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + WriteInstructionParamsFragmentInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountSystemProgram + > +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.instructionParams.value) { + accounts.instructionParams.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, + 114, 97, 109, 115, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.signer.value)), + ], + }); + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getWriteInstructionParamsFragmentInstructionDataEncoder().encode( + args as WriteInstructionParamsFragmentInstructionDataArgs + ), + } as WriteInstructionParamsFragmentInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountSystemProgram + >; + + return instruction; +} + +export type WriteInstructionParamsFragmentInput< + TAccountSigner extends string = string, + TAccountInstructionParams extends string = string, + TAccountSystemProgram extends string = string, +> = { + signer: TransactionSigner; + instructionParams: Address; + systemProgram?: Address; + offset: WriteInstructionParamsFragmentInstructionDataArgs['offset']; + fragment: WriteInstructionParamsFragmentInstructionDataArgs['fragment']; +}; + +export function getWriteInstructionParamsFragmentInstruction< + TAccountSigner extends string, + TAccountInstructionParams extends string, + TAccountSystemProgram extends string, + TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, +>( + input: WriteInstructionParamsFragmentInput< + TAccountSigner, + TAccountInstructionParams, + TAccountSystemProgram + >, + config?: { programAddress?: TProgramAddress } +): WriteInstructionParamsFragmentInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountSystemProgram +> { + // Program address. + const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + signer: { value: input.signer ?? null, isWritable: false }, + instructionParams: { + value: input.instructionParams ?? null, + isWritable: true, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.signer), + getAccountMeta(accounts.instructionParams), + getAccountMeta(accounts.systemProgram), + ], + programAddress, + data: getWriteInstructionParamsFragmentInstructionDataEncoder().encode( + args as WriteInstructionParamsFragmentInstructionDataArgs + ), + } as WriteInstructionParamsFragmentInstruction< + TProgramAddress, + TAccountSigner, + TAccountInstructionParams, + TAccountSystemProgram + >; + + return instruction; +} + +export type ParsedWriteInstructionParamsFragmentInstruction< + TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + signer: TAccountMetas[0]; + instructionParams: TAccountMetas[1]; + systemProgram: TAccountMetas[2]; + }; + data: WriteInstructionParamsFragmentInstructionData; +}; + +export function parseWriteInstructionParamsFragmentInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedWriteInstructionParamsFragmentInstruction { + 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: { + signer: getNextAccount(), + instructionParams: getNextAccount(), + systemProgram: getNextAccount(), + }, + data: getWriteInstructionParamsFragmentInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/SvmSpoke/programs/index.ts b/src/svm/clients/SvmSpoke/programs/index.ts new file mode 100644 index 000000000..90c874042 --- /dev/null +++ b/src/svm/clients/SvmSpoke/programs/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 './svmSpoke'; diff --git a/src/svm/clients/SvmSpoke/programs/svmSpoke.ts b/src/svm/clients/SvmSpoke/programs/svmSpoke.ts new file mode 100644 index 000000000..39019c732 --- /dev/null +++ b/src/svm/clients/SvmSpoke/programs/svmSpoke.ts @@ -0,0 +1,588 @@ +/** + * 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/kit'; +import { + type ParsedBridgeTokensToHubPoolInstruction, + type ParsedClaimRelayerRefundInstruction, + type ParsedCloseClaimAccountInstruction, + type ParsedCloseFillPdaInstruction, + type ParsedCloseInstructionParamsInstruction, + type ParsedCreateTokenAccountsInstruction, + type ParsedDepositInstruction, + type ParsedDepositNowInstruction, + type ParsedEmergencyDeleteRootBundleInstruction, + type ParsedExecuteRelayerRefundLeafDeferredInstruction, + type ParsedExecuteRelayerRefundLeafInstruction, + type ParsedExecuteSlowRelayLeafInstruction, + type ParsedFillRelayInstruction, + type ParsedGetUnsafeDepositIdInstruction, + type ParsedHandleReceiveMessageInstruction, + type ParsedInitializeClaimAccountInstruction, + type ParsedInitializeInstruction, + type ParsedInitializeInstructionParamsInstruction, + type ParsedPauseDepositsInstruction, + type ParsedPauseFillsInstruction, + type ParsedRelayRootBundleInstruction, + type ParsedRequestSlowFillInstruction, + type ParsedSetCrossDomainAdminInstruction, + type ParsedSetCurrentTimeInstruction, + type ParsedTransferOwnershipInstruction, + type ParsedUnsafeDepositInstruction, + type ParsedWriteInstructionParamsFragmentInstruction, +} from '../instructions'; + +export const SVM_SPOKE_PROGRAM_ADDRESS = + 'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru' as Address<'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru'>; + +export enum SvmSpokeAccount { + ClaimAccount, + ExecuteRelayerRefundLeafParams, + ExecuteSlowRelayLeafParams, + FillRelayParams, + FillStatusAccount, + RequestSlowFillParams, + RootBundle, + State, + TransferLiability, +} + +export function identifySvmSpokeAccount( + account: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): SvmSpokeAccount { + const data = 'data' in account ? account.data : account; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([113, 109, 47, 96, 242, 219, 61, 165]) + ), + 0 + ) + ) { + return SvmSpokeAccount.ClaimAccount; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([192, 59, 93, 9, 171, 77, 28, 250]) + ), + 0 + ) + ) { + return SvmSpokeAccount.ExecuteRelayerRefundLeafParams; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([135, 208, 119, 251, 14, 222, 66, 155]) + ), + 0 + ) + ) { + return SvmSpokeAccount.ExecuteSlowRelayLeafParams; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([50, 243, 51, 185, 89, 60, 43, 202]) + ), + 0 + ) + ) { + return SvmSpokeAccount.FillRelayParams; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([105, 89, 88, 35, 24, 147, 178, 137]) + ), + 0 + ) + ) { + return SvmSpokeAccount.FillStatusAccount; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([5, 54, 214, 89, 197, 37, 118, 28]) + ), + 0 + ) + ) { + return SvmSpokeAccount.RequestSlowFillParams; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([66, 221, 214, 231, 25, 222, 184, 219]) + ), + 0 + ) + ) { + return SvmSpokeAccount.RootBundle; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([216, 146, 107, 94, 104, 75, 182, 177]) + ), + 0 + ) + ) { + return SvmSpokeAccount.State; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([157, 137, 86, 109, 206, 241, 183, 79]) + ), + 0 + ) + ) { + return SvmSpokeAccount.TransferLiability; + } + throw new Error( + 'The provided account could not be identified as a svmSpoke account.' + ); +} + +export enum SvmSpokeInstruction { + BridgeTokensToHubPool, + ClaimRelayerRefund, + CloseClaimAccount, + CloseFillPda, + CloseInstructionParams, + CreateTokenAccounts, + Deposit, + DepositNow, + EmergencyDeleteRootBundle, + ExecuteRelayerRefundLeaf, + ExecuteRelayerRefundLeafDeferred, + ExecuteSlowRelayLeaf, + FillRelay, + GetUnsafeDepositId, + HandleReceiveMessage, + Initialize, + InitializeClaimAccount, + InitializeInstructionParams, + PauseDeposits, + PauseFills, + RelayRootBundle, + RequestSlowFill, + SetCrossDomainAdmin, + SetCurrentTime, + TransferOwnership, + UnsafeDeposit, + WriteInstructionParamsFragment, +} + +export function identifySvmSpokeInstruction( + instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): SvmSpokeInstruction { + const data = 'data' in instruction ? instruction.data : instruction; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([1, 83, 255, 59, 232, 55, 64, 216]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.BridgeTokensToHubPool; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([205, 34, 34, 224, 204, 103, 81, 176]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.ClaimRelayerRefund; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([241, 146, 203, 216, 58, 222, 91, 118]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.CloseClaimAccount; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([224, 39, 208, 68, 8, 226, 23, 214]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.CloseFillPda; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([224, 44, 254, 10, 216, 8, 172, 96]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.CloseInstructionParams; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([163, 216, 49, 204, 97, 16, 80, 167]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.CreateTokenAccounts; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([242, 35, 198, 137, 82, 225, 242, 182]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.Deposit; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([75, 228, 135, 221, 200, 25, 148, 26]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.DepositNow; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([226, 158, 1, 74, 84, 113, 24, 152]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.EmergencyDeleteRootBundle; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([27, 136, 159, 240, 127, 68, 123, 164]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.ExecuteRelayerRefundLeaf; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([110, 112, 89, 208, 38, 116, 93, 10]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.ExecuteRelayerRefundLeafDeferred; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([26, 207, 3, 168, 193, 252, 59, 127]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.ExecuteSlowRelayLeaf; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([100, 84, 222, 90, 106, 209, 58, 222]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.FillRelay; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([118, 10, 135, 0, 168, 243, 223, 117]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.GetUnsafeDepositId; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([133, 102, 1, 180, 145, 11, 138, 180]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.HandleReceiveMessage; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.Initialize; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([22, 247, 214, 191, 90, 74, 87, 216]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.InitializeClaimAccount; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([94, 206, 190, 192, 127, 8, 186, 28]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.InitializeInstructionParams; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([206, 186, 203, 153, 253, 61, 206, 122]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.PauseDeposits; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([92, 114, 214, 49, 13, 243, 73, 35]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.PauseFills; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([69, 13, 223, 204, 251, 61, 105, 6]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.RelayRootBundle; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([39, 157, 165, 187, 88, 217, 207, 98]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.RequestSlowFill; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([102, 206, 237, 106, 63, 141, 42, 248]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.SetCrossDomainAdmin; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([69, 100, 169, 193, 125, 0, 150, 69]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.SetCurrentTime; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.TransferOwnership; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([196, 187, 166, 179, 3, 146, 150, 246]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.UnsafeDeposit; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([238, 182, 109, 113, 124, 255, 72, 18]) + ), + 0 + ) + ) { + return SvmSpokeInstruction.WriteInstructionParamsFragment; + } + throw new Error( + 'The provided instruction could not be identified as a svmSpoke instruction.' + ); +} + +export type ParsedSvmSpokeInstruction< + TProgram extends string = 'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru', +> = + | ({ + instructionType: SvmSpokeInstruction.BridgeTokensToHubPool; + } & ParsedBridgeTokensToHubPoolInstruction) + | ({ + instructionType: SvmSpokeInstruction.ClaimRelayerRefund; + } & ParsedClaimRelayerRefundInstruction) + | ({ + instructionType: SvmSpokeInstruction.CloseClaimAccount; + } & ParsedCloseClaimAccountInstruction) + | ({ + instructionType: SvmSpokeInstruction.CloseFillPda; + } & ParsedCloseFillPdaInstruction) + | ({ + instructionType: SvmSpokeInstruction.CloseInstructionParams; + } & ParsedCloseInstructionParamsInstruction) + | ({ + instructionType: SvmSpokeInstruction.CreateTokenAccounts; + } & ParsedCreateTokenAccountsInstruction) + | ({ + instructionType: SvmSpokeInstruction.Deposit; + } & ParsedDepositInstruction) + | ({ + instructionType: SvmSpokeInstruction.DepositNow; + } & ParsedDepositNowInstruction) + | ({ + instructionType: SvmSpokeInstruction.EmergencyDeleteRootBundle; + } & ParsedEmergencyDeleteRootBundleInstruction) + | ({ + instructionType: SvmSpokeInstruction.ExecuteRelayerRefundLeaf; + } & ParsedExecuteRelayerRefundLeafInstruction) + | ({ + instructionType: SvmSpokeInstruction.ExecuteRelayerRefundLeafDeferred; + } & ParsedExecuteRelayerRefundLeafDeferredInstruction) + | ({ + instructionType: SvmSpokeInstruction.ExecuteSlowRelayLeaf; + } & ParsedExecuteSlowRelayLeafInstruction) + | ({ + instructionType: SvmSpokeInstruction.FillRelay; + } & ParsedFillRelayInstruction) + | ({ + instructionType: SvmSpokeInstruction.GetUnsafeDepositId; + } & ParsedGetUnsafeDepositIdInstruction) + | ({ + instructionType: SvmSpokeInstruction.HandleReceiveMessage; + } & ParsedHandleReceiveMessageInstruction) + | ({ + instructionType: SvmSpokeInstruction.Initialize; + } & ParsedInitializeInstruction) + | ({ + instructionType: SvmSpokeInstruction.InitializeClaimAccount; + } & ParsedInitializeClaimAccountInstruction) + | ({ + instructionType: SvmSpokeInstruction.InitializeInstructionParams; + } & ParsedInitializeInstructionParamsInstruction) + | ({ + instructionType: SvmSpokeInstruction.PauseDeposits; + } & ParsedPauseDepositsInstruction) + | ({ + instructionType: SvmSpokeInstruction.PauseFills; + } & ParsedPauseFillsInstruction) + | ({ + instructionType: SvmSpokeInstruction.RelayRootBundle; + } & ParsedRelayRootBundleInstruction) + | ({ + instructionType: SvmSpokeInstruction.RequestSlowFill; + } & ParsedRequestSlowFillInstruction) + | ({ + instructionType: SvmSpokeInstruction.SetCrossDomainAdmin; + } & ParsedSetCrossDomainAdminInstruction) + | ({ + instructionType: SvmSpokeInstruction.SetCurrentTime; + } & ParsedSetCurrentTimeInstruction) + | ({ + instructionType: SvmSpokeInstruction.TransferOwnership; + } & ParsedTransferOwnershipInstruction) + | ({ + instructionType: SvmSpokeInstruction.UnsafeDeposit; + } & ParsedUnsafeDepositInstruction) + | ({ + instructionType: SvmSpokeInstruction.WriteInstructionParamsFragment; + } & ParsedWriteInstructionParamsFragmentInstruction); diff --git a/src/svm/clients/SvmSpoke/shared/index.ts b/src/svm/clients/SvmSpoke/shared/index.ts new file mode 100644 index 000000000..7ebc26514 --- /dev/null +++ b/src/svm/clients/SvmSpoke/shared/index.ts @@ -0,0 +1,164 @@ +/** + * 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 { + AccountRole, + isProgramDerivedAddress, + isTransactionSigner as kitIsTransactionSigner, + type AccountMeta, + type AccountSignerMeta, + type Address, + type ProgramDerivedAddress, + type TransactionSigner, + upgradeRoleToSigner, +} from '@solana/kit'; + +/** + * Asserts that the given value is not null or undefined. + * @internal + */ +export function expectSome(value: T | null | undefined): T { + if (value == null) { + throw new Error('Expected a value but received null or undefined.'); + } + return value; +} + +/** + * Asserts that the given value is a PublicKey. + * @internal + */ +export function expectAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): Address { + if (!value) { + throw new Error('Expected a Address.'); + } + if (typeof value === 'object' && 'address' in value) { + return value.address; + } + if (Array.isArray(value)) { + return value[0]; + } + return value as Address; +} + +/** + * Asserts that the given value is a PDA. + * @internal + */ +export function expectProgramDerivedAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): ProgramDerivedAddress { + if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { + throw new Error('Expected a ProgramDerivedAddress.'); + } + return value; +} + +/** + * Asserts that the given value is a TransactionSigner. + * @internal + */ +export function expectTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): TransactionSigner { + if (!value || !isTransactionSigner(value)) { + throw new Error('Expected a TransactionSigner.'); + } + return value; +} + +/** + * Defines an instruction account to resolve. + * @internal + */ +export type ResolvedAccount< + T extends string = string, + U extends + | Address + | ProgramDerivedAddress + | TransactionSigner + | null = + | Address + | ProgramDerivedAddress + | TransactionSigner + | null, +> = { + isWritable: boolean; + value: U; +}; + +/** + * Defines an instruction that stores additional bytes on-chain. + * @internal + */ +export type InstructionWithByteDelta = { + byteDelta: number; +}; + +/** + * Get account metas and signers from resolved accounts. + * @internal + */ +export function getAccountMetaFactory( + programAddress: Address, + optionalAccountStrategy: 'omitted' | 'programId' +) { + return ( + account: ResolvedAccount + ): AccountMeta | AccountSignerMeta | undefined => { + if (!account.value) { + if (optionalAccountStrategy === 'omitted') return; + return Object.freeze({ + address: programAddress, + role: AccountRole.READONLY, + }); + } + + const writableRole = account.isWritable + ? AccountRole.WRITABLE + : AccountRole.READONLY; + return Object.freeze({ + address: expectAddress(account.value), + role: isTransactionSigner(account.value) + ? upgradeRoleToSigner(writableRole) + : writableRole, + ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), + }); + }; +} + +export function isTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner +): value is TransactionSigner { + return ( + !!value && + typeof value === 'object' && + 'address' in value && + kitIsTransactionSigner(value) + ); +} diff --git a/src/svm/clients/SvmSpoke/types/bridgedToHubPool.ts b/src/svm/clients/SvmSpoke/types/bridgedToHubPool.ts new file mode 100644 index 000000000..177836e64 --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/bridgedToHubPool.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, + getAddressDecoder, + getAddressEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type BridgedToHubPool = { amount: bigint; mint: Address }; + +export type BridgedToHubPoolArgs = { amount: number | bigint; mint: Address }; + +export function getBridgedToHubPoolEncoder(): Encoder { + return getStructEncoder([ + ['amount', getU64Encoder()], + ['mint', getAddressEncoder()], + ]); +} + +export function getBridgedToHubPoolDecoder(): Decoder { + return getStructDecoder([ + ['amount', getU64Decoder()], + ['mint', getAddressDecoder()], + ]); +} + +export function getBridgedToHubPoolCodec(): Codec< + BridgedToHubPoolArgs, + BridgedToHubPool +> { + return combineCodec( + getBridgedToHubPoolEncoder(), + getBridgedToHubPoolDecoder() + ); +} diff --git a/src/svm/clients/SvmSpoke/types/claimedRelayerRefund.ts b/src/svm/clients/SvmSpoke/types/claimedRelayerRefund.ts new file mode 100644 index 000000000..72e1aa5e9 --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/claimedRelayerRefund.ts @@ -0,0 +1,59 @@ +/** + * 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, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type ClaimedRelayerRefund = { + l2TokenAddress: Address; + claimAmount: bigint; + refundAddress: Address; +}; + +export type ClaimedRelayerRefundArgs = { + l2TokenAddress: Address; + claimAmount: number | bigint; + refundAddress: Address; +}; + +export function getClaimedRelayerRefundEncoder(): Encoder { + return getStructEncoder([ + ['l2TokenAddress', getAddressEncoder()], + ['claimAmount', getU64Encoder()], + ['refundAddress', getAddressEncoder()], + ]); +} + +export function getClaimedRelayerRefundDecoder(): Decoder { + return getStructDecoder([ + ['l2TokenAddress', getAddressDecoder()], + ['claimAmount', getU64Decoder()], + ['refundAddress', getAddressDecoder()], + ]); +} + +export function getClaimedRelayerRefundCodec(): Codec< + ClaimedRelayerRefundArgs, + ClaimedRelayerRefund +> { + return combineCodec( + getClaimedRelayerRefundEncoder(), + getClaimedRelayerRefundDecoder() + ); +} diff --git a/src/svm/clients/SvmSpoke/types/emergencyDeletedRootBundle.ts b/src/svm/clients/SvmSpoke/types/emergencyDeletedRootBundle.ts new file mode 100644 index 000000000..69272980b --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/emergencyDeletedRootBundle.ts @@ -0,0 +1,40 @@ +/** + * 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, + getU32Decoder, + getU32Encoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type EmergencyDeletedRootBundle = { rootBundleId: number }; + +export type EmergencyDeletedRootBundleArgs = EmergencyDeletedRootBundle; + +export function getEmergencyDeletedRootBundleEncoder(): Encoder { + return getStructEncoder([['rootBundleId', getU32Encoder()]]); +} + +export function getEmergencyDeletedRootBundleDecoder(): Decoder { + return getStructDecoder([['rootBundleId', getU32Decoder()]]); +} + +export function getEmergencyDeletedRootBundleCodec(): Codec< + EmergencyDeletedRootBundleArgs, + EmergencyDeletedRootBundle +> { + return combineCodec( + getEmergencyDeletedRootBundleEncoder(), + getEmergencyDeletedRootBundleDecoder() + ); +} diff --git a/src/svm/clients/SvmSpoke/types/executedRelayerRefundRoot.ts b/src/svm/clients/SvmSpoke/types/executedRelayerRefundRoot.ts new file mode 100644 index 000000000..d6b724d94 --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/executedRelayerRefundRoot.ts @@ -0,0 +1,89 @@ +/** + * 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, + getArrayDecoder, + getArrayEncoder, + getBooleanDecoder, + getBooleanEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type ExecutedRelayerRefundRoot = { + amountToReturn: bigint; + chainId: bigint; + refundAmounts: Array; + rootBundleId: number; + leafId: number; + l2TokenAddress: Address; + refundAddresses: Array
; + deferredRefunds: boolean; + caller: Address; +}; + +export type ExecutedRelayerRefundRootArgs = { + amountToReturn: number | bigint; + chainId: number | bigint; + refundAmounts: Array; + rootBundleId: number; + leafId: number; + l2TokenAddress: Address; + refundAddresses: Array
; + deferredRefunds: boolean; + caller: Address; +}; + +export function getExecutedRelayerRefundRootEncoder(): Encoder { + return getStructEncoder([ + ['amountToReturn', getU64Encoder()], + ['chainId', getU64Encoder()], + ['refundAmounts', getArrayEncoder(getU64Encoder())], + ['rootBundleId', getU32Encoder()], + ['leafId', getU32Encoder()], + ['l2TokenAddress', getAddressEncoder()], + ['refundAddresses', getArrayEncoder(getAddressEncoder())], + ['deferredRefunds', getBooleanEncoder()], + ['caller', getAddressEncoder()], + ]); +} + +export function getExecutedRelayerRefundRootDecoder(): Decoder { + return getStructDecoder([ + ['amountToReturn', getU64Decoder()], + ['chainId', getU64Decoder()], + ['refundAmounts', getArrayDecoder(getU64Decoder())], + ['rootBundleId', getU32Decoder()], + ['leafId', getU32Decoder()], + ['l2TokenAddress', getAddressDecoder()], + ['refundAddresses', getArrayDecoder(getAddressDecoder())], + ['deferredRefunds', getBooleanDecoder()], + ['caller', getAddressDecoder()], + ]); +} + +export function getExecutedRelayerRefundRootCodec(): Codec< + ExecutedRelayerRefundRootArgs, + ExecutedRelayerRefundRoot +> { + return combineCodec( + getExecutedRelayerRefundRootEncoder(), + getExecutedRelayerRefundRootDecoder() + ); +} diff --git a/src/svm/clients/SvmSpoke/types/fillStatus.ts b/src/svm/clients/SvmSpoke/types/fillStatus.ts new file mode 100644 index 000000000..578f49860 --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/fillStatus.ts @@ -0,0 +1,36 @@ +/** + * 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, + getEnumDecoder, + getEnumEncoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export enum FillStatus { + Unfilled, + RequestedSlowFill, + Filled, +} + +export type FillStatusArgs = FillStatus; + +export function getFillStatusEncoder(): Encoder { + return getEnumEncoder(FillStatus); +} + +export function getFillStatusDecoder(): Decoder { + return getEnumDecoder(FillStatus); +} + +export function getFillStatusCodec(): Codec { + return combineCodec(getFillStatusEncoder(), getFillStatusDecoder()); +} diff --git a/src/svm/clients/SvmSpoke/types/fillType.ts b/src/svm/clients/SvmSpoke/types/fillType.ts new file mode 100644 index 000000000..2ec225b26 --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/fillType.ts @@ -0,0 +1,36 @@ +/** + * 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, + getEnumDecoder, + getEnumEncoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export enum FillType { + FastFill, + ReplacedSlowFill, + SlowFill, +} + +export type FillTypeArgs = FillType; + +export function getFillTypeEncoder(): Encoder { + return getEnumEncoder(FillType); +} + +export function getFillTypeDecoder(): Decoder { + return getEnumDecoder(FillType); +} + +export function getFillTypeCodec(): Codec { + return combineCodec(getFillTypeEncoder(), getFillTypeDecoder()); +} diff --git a/src/svm/clients/SvmSpoke/types/filledRelay.ts b/src/svm/clients/SvmSpoke/types/filledRelay.ts new file mode 100644 index 000000000..5facf1648 --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/filledRelay.ts @@ -0,0 +1,114 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { + getRelayExecutionEventInfoDecoder, + getRelayExecutionEventInfoEncoder, + type RelayExecutionEventInfo, + type RelayExecutionEventInfoArgs, +} from '.'; + +export type FilledRelay = { + inputToken: Address; + outputToken: Address; + inputAmount: ReadonlyUint8Array; + outputAmount: bigint; + repaymentChainId: bigint; + originChainId: bigint; + depositId: ReadonlyUint8Array; + fillDeadline: number; + exclusivityDeadline: number; + exclusiveRelayer: Address; + relayer: Address; + depositor: Address; + recipient: Address; + messageHash: ReadonlyUint8Array; + relayExecutionInfo: RelayExecutionEventInfo; +}; + +export type FilledRelayArgs = { + inputToken: Address; + outputToken: Address; + inputAmount: ReadonlyUint8Array; + outputAmount: number | bigint; + repaymentChainId: number | bigint; + originChainId: number | bigint; + depositId: ReadonlyUint8Array; + fillDeadline: number; + exclusivityDeadline: number; + exclusiveRelayer: Address; + relayer: Address; + depositor: Address; + recipient: Address; + messageHash: ReadonlyUint8Array; + relayExecutionInfo: RelayExecutionEventInfoArgs; +}; + +export function getFilledRelayEncoder(): Encoder { + return getStructEncoder([ + ['inputToken', getAddressEncoder()], + ['outputToken', getAddressEncoder()], + ['inputAmount', fixEncoderSize(getBytesEncoder(), 32)], + ['outputAmount', getU64Encoder()], + ['repaymentChainId', getU64Encoder()], + ['originChainId', getU64Encoder()], + ['depositId', fixEncoderSize(getBytesEncoder(), 32)], + ['fillDeadline', getU32Encoder()], + ['exclusivityDeadline', getU32Encoder()], + ['exclusiveRelayer', getAddressEncoder()], + ['relayer', getAddressEncoder()], + ['depositor', getAddressEncoder()], + ['recipient', getAddressEncoder()], + ['messageHash', fixEncoderSize(getBytesEncoder(), 32)], + ['relayExecutionInfo', getRelayExecutionEventInfoEncoder()], + ]); +} + +export function getFilledRelayDecoder(): Decoder { + return getStructDecoder([ + ['inputToken', getAddressDecoder()], + ['outputToken', getAddressDecoder()], + ['inputAmount', fixDecoderSize(getBytesDecoder(), 32)], + ['outputAmount', getU64Decoder()], + ['repaymentChainId', getU64Decoder()], + ['originChainId', getU64Decoder()], + ['depositId', fixDecoderSize(getBytesDecoder(), 32)], + ['fillDeadline', getU32Decoder()], + ['exclusivityDeadline', getU32Decoder()], + ['exclusiveRelayer', getAddressDecoder()], + ['relayer', getAddressDecoder()], + ['depositor', getAddressDecoder()], + ['recipient', getAddressDecoder()], + ['messageHash', fixDecoderSize(getBytesDecoder(), 32)], + ['relayExecutionInfo', getRelayExecutionEventInfoDecoder()], + ]); +} + +export function getFilledRelayCodec(): Codec { + return combineCodec(getFilledRelayEncoder(), getFilledRelayDecoder()); +} diff --git a/src/svm/clients/SvmSpoke/types/fundsDeposited.ts b/src/svm/clients/SvmSpoke/types/fundsDeposited.ts new file mode 100644 index 000000000..8ff28c60e --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/fundsDeposited.ts @@ -0,0 +1,105 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export type FundsDeposited = { + inputToken: Address; + outputToken: Address; + inputAmount: bigint; + outputAmount: ReadonlyUint8Array; + destinationChainId: bigint; + depositId: ReadonlyUint8Array; + quoteTimestamp: number; + fillDeadline: number; + exclusivityDeadline: number; + depositor: Address; + recipient: Address; + exclusiveRelayer: Address; + message: ReadonlyUint8Array; +}; + +export type FundsDepositedArgs = { + inputToken: Address; + outputToken: Address; + inputAmount: number | bigint; + outputAmount: ReadonlyUint8Array; + destinationChainId: number | bigint; + depositId: ReadonlyUint8Array; + quoteTimestamp: number; + fillDeadline: number; + exclusivityDeadline: number; + depositor: Address; + recipient: Address; + exclusiveRelayer: Address; + message: ReadonlyUint8Array; +}; + +export function getFundsDepositedEncoder(): Encoder { + return getStructEncoder([ + ['inputToken', getAddressEncoder()], + ['outputToken', getAddressEncoder()], + ['inputAmount', getU64Encoder()], + ['outputAmount', fixEncoderSize(getBytesEncoder(), 32)], + ['destinationChainId', getU64Encoder()], + ['depositId', fixEncoderSize(getBytesEncoder(), 32)], + ['quoteTimestamp', getU32Encoder()], + ['fillDeadline', getU32Encoder()], + ['exclusivityDeadline', getU32Encoder()], + ['depositor', getAddressEncoder()], + ['recipient', getAddressEncoder()], + ['exclusiveRelayer', getAddressEncoder()], + ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]); +} + +export function getFundsDepositedDecoder(): Decoder { + return getStructDecoder([ + ['inputToken', getAddressDecoder()], + ['outputToken', getAddressDecoder()], + ['inputAmount', getU64Decoder()], + ['outputAmount', fixDecoderSize(getBytesDecoder(), 32)], + ['destinationChainId', getU64Decoder()], + ['depositId', fixDecoderSize(getBytesDecoder(), 32)], + ['quoteTimestamp', getU32Decoder()], + ['fillDeadline', getU32Decoder()], + ['exclusivityDeadline', getU32Decoder()], + ['depositor', getAddressDecoder()], + ['recipient', getAddressDecoder()], + ['exclusiveRelayer', getAddressDecoder()], + ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getFundsDepositedCodec(): Codec< + FundsDepositedArgs, + FundsDeposited +> { + return combineCodec(getFundsDepositedEncoder(), getFundsDepositedDecoder()); +} diff --git a/src/svm/clients/SvmSpoke/types/index.ts b/src/svm/clients/SvmSpoke/types/index.ts new file mode 100644 index 000000000..33b8494ce --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/index.ts @@ -0,0 +1,27 @@ +/** + * 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 './bridgedToHubPool'; +export * from './claimedRelayerRefund'; +export * from './emergencyDeletedRootBundle'; +export * from './executedRelayerRefundRoot'; +export * from './filledRelay'; +export * from './fillStatus'; +export * from './fillType'; +export * from './fundsDeposited'; +export * from './pausedDeposits'; +export * from './pausedFills'; +export * from './relayData'; +export * from './relayedRootBundle'; +export * from './relayerRefundLeaf'; +export * from './relayExecutionEventInfo'; +export * from './requestedSlowFill'; +export * from './setXDomainAdmin'; +export * from './slowFill'; +export * from './tokensBridged'; +export * from './transferredOwnership'; diff --git a/src/svm/clients/SvmSpoke/types/pausedDeposits.ts b/src/svm/clients/SvmSpoke/types/pausedDeposits.ts new file mode 100644 index 000000000..94ad8d991 --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/pausedDeposits.ts @@ -0,0 +1,37 @@ +/** + * 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, + getBooleanDecoder, + getBooleanEncoder, + getStructDecoder, + getStructEncoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type PausedDeposits = { isPaused: boolean }; + +export type PausedDepositsArgs = PausedDeposits; + +export function getPausedDepositsEncoder(): Encoder { + return getStructEncoder([['isPaused', getBooleanEncoder()]]); +} + +export function getPausedDepositsDecoder(): Decoder { + return getStructDecoder([['isPaused', getBooleanDecoder()]]); +} + +export function getPausedDepositsCodec(): Codec< + PausedDepositsArgs, + PausedDeposits +> { + return combineCodec(getPausedDepositsEncoder(), getPausedDepositsDecoder()); +} diff --git a/src/svm/clients/SvmSpoke/types/pausedFills.ts b/src/svm/clients/SvmSpoke/types/pausedFills.ts new file mode 100644 index 000000000..2bf8a0cea --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/pausedFills.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, + getBooleanDecoder, + getBooleanEncoder, + getStructDecoder, + getStructEncoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type PausedFills = { isPaused: boolean }; + +export type PausedFillsArgs = PausedFills; + +export function getPausedFillsEncoder(): Encoder { + return getStructEncoder([['isPaused', getBooleanEncoder()]]); +} + +export function getPausedFillsDecoder(): Decoder { + return getStructDecoder([['isPaused', getBooleanDecoder()]]); +} + +export function getPausedFillsCodec(): Codec { + return combineCodec(getPausedFillsEncoder(), getPausedFillsDecoder()); +} diff --git a/src/svm/clients/SvmSpoke/types/relayData.ts b/src/svm/clients/SvmSpoke/types/relayData.ts new file mode 100644 index 000000000..7104dd7d8 --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/relayData.ts @@ -0,0 +1,98 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export type RelayData = { + depositor: Address; + recipient: Address; + exclusiveRelayer: Address; + inputToken: Address; + outputToken: Address; + inputAmount: ReadonlyUint8Array; + outputAmount: bigint; + originChainId: bigint; + depositId: ReadonlyUint8Array; + fillDeadline: number; + exclusivityDeadline: number; + message: ReadonlyUint8Array; +}; + +export type RelayDataArgs = { + depositor: Address; + recipient: Address; + exclusiveRelayer: Address; + inputToken: Address; + outputToken: Address; + inputAmount: ReadonlyUint8Array; + outputAmount: number | bigint; + originChainId: number | bigint; + depositId: ReadonlyUint8Array; + fillDeadline: number; + exclusivityDeadline: number; + message: ReadonlyUint8Array; +}; + +export function getRelayDataEncoder(): Encoder { + return getStructEncoder([ + ['depositor', getAddressEncoder()], + ['recipient', getAddressEncoder()], + ['exclusiveRelayer', getAddressEncoder()], + ['inputToken', getAddressEncoder()], + ['outputToken', getAddressEncoder()], + ['inputAmount', fixEncoderSize(getBytesEncoder(), 32)], + ['outputAmount', getU64Encoder()], + ['originChainId', getU64Encoder()], + ['depositId', fixEncoderSize(getBytesEncoder(), 32)], + ['fillDeadline', getU32Encoder()], + ['exclusivityDeadline', getU32Encoder()], + ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]); +} + +export function getRelayDataDecoder(): Decoder { + return getStructDecoder([ + ['depositor', getAddressDecoder()], + ['recipient', getAddressDecoder()], + ['exclusiveRelayer', getAddressDecoder()], + ['inputToken', getAddressDecoder()], + ['outputToken', getAddressDecoder()], + ['inputAmount', fixDecoderSize(getBytesDecoder(), 32)], + ['outputAmount', getU64Decoder()], + ['originChainId', getU64Decoder()], + ['depositId', fixDecoderSize(getBytesDecoder(), 32)], + ['fillDeadline', getU32Decoder()], + ['exclusivityDeadline', getU32Decoder()], + ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getRelayDataCodec(): Codec { + return combineCodec(getRelayDataEncoder(), getRelayDataDecoder()); +} diff --git a/src/svm/clients/SvmSpoke/types/relayExecutionEventInfo.ts b/src/svm/clients/SvmSpoke/types/relayExecutionEventInfo.ts new file mode 100644 index 000000000..3ead0d0aa --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/relayExecutionEventInfo.ts @@ -0,0 +1,74 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; +import { + getFillTypeDecoder, + getFillTypeEncoder, + type FillType, + type FillTypeArgs, +} from '.'; + +export type RelayExecutionEventInfo = { + updatedRecipient: Address; + updatedMessageHash: ReadonlyUint8Array; + updatedOutputAmount: bigint; + fillType: FillType; +}; + +export type RelayExecutionEventInfoArgs = { + updatedRecipient: Address; + updatedMessageHash: ReadonlyUint8Array; + updatedOutputAmount: number | bigint; + fillType: FillTypeArgs; +}; + +export function getRelayExecutionEventInfoEncoder(): Encoder { + return getStructEncoder([ + ['updatedRecipient', getAddressEncoder()], + ['updatedMessageHash', fixEncoderSize(getBytesEncoder(), 32)], + ['updatedOutputAmount', getU64Encoder()], + ['fillType', getFillTypeEncoder()], + ]); +} + +export function getRelayExecutionEventInfoDecoder(): Decoder { + return getStructDecoder([ + ['updatedRecipient', getAddressDecoder()], + ['updatedMessageHash', fixDecoderSize(getBytesDecoder(), 32)], + ['updatedOutputAmount', getU64Decoder()], + ['fillType', getFillTypeDecoder()], + ]); +} + +export function getRelayExecutionEventInfoCodec(): Codec< + RelayExecutionEventInfoArgs, + RelayExecutionEventInfo +> { + return combineCodec( + getRelayExecutionEventInfoEncoder(), + getRelayExecutionEventInfoDecoder() + ); +} diff --git a/src/svm/clients/SvmSpoke/types/relayedRootBundle.ts b/src/svm/clients/SvmSpoke/types/relayedRootBundle.ts new file mode 100644 index 000000000..141ddb839 --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/relayedRootBundle.ts @@ -0,0 +1,57 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export type RelayedRootBundle = { + rootBundleId: number; + relayerRefundRoot: ReadonlyUint8Array; + slowRelayRoot: ReadonlyUint8Array; +}; + +export type RelayedRootBundleArgs = RelayedRootBundle; + +export function getRelayedRootBundleEncoder(): Encoder { + return getStructEncoder([ + ['rootBundleId', getU32Encoder()], + ['relayerRefundRoot', fixEncoderSize(getBytesEncoder(), 32)], + ['slowRelayRoot', fixEncoderSize(getBytesEncoder(), 32)], + ]); +} + +export function getRelayedRootBundleDecoder(): Decoder { + return getStructDecoder([ + ['rootBundleId', getU32Decoder()], + ['relayerRefundRoot', fixDecoderSize(getBytesDecoder(), 32)], + ['slowRelayRoot', fixDecoderSize(getBytesDecoder(), 32)], + ]); +} + +export function getRelayedRootBundleCodec(): Codec< + RelayedRootBundleArgs, + RelayedRootBundle +> { + return combineCodec( + getRelayedRootBundleEncoder(), + getRelayedRootBundleDecoder() + ); +} diff --git a/src/svm/clients/SvmSpoke/types/relayerRefundLeaf.ts b/src/svm/clients/SvmSpoke/types/relayerRefundLeaf.ts new file mode 100644 index 000000000..0683ad393 --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/relayerRefundLeaf.ts @@ -0,0 +1,75 @@ +/** + * 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, + getArrayDecoder, + getArrayEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type RelayerRefundLeaf = { + amountToReturn: bigint; + chainId: bigint; + refundAmounts: Array; + leafId: number; + mintPublicKey: Address; + refundAddresses: Array
; +}; + +export type RelayerRefundLeafArgs = { + amountToReturn: number | bigint; + chainId: number | bigint; + refundAmounts: Array; + leafId: number; + mintPublicKey: Address; + refundAddresses: Array
; +}; + +export function getRelayerRefundLeafEncoder(): Encoder { + return getStructEncoder([ + ['amountToReturn', getU64Encoder()], + ['chainId', getU64Encoder()], + ['refundAmounts', getArrayEncoder(getU64Encoder())], + ['leafId', getU32Encoder()], + ['mintPublicKey', getAddressEncoder()], + ['refundAddresses', getArrayEncoder(getAddressEncoder())], + ]); +} + +export function getRelayerRefundLeafDecoder(): Decoder { + return getStructDecoder([ + ['amountToReturn', getU64Decoder()], + ['chainId', getU64Decoder()], + ['refundAmounts', getArrayDecoder(getU64Decoder())], + ['leafId', getU32Decoder()], + ['mintPublicKey', getAddressDecoder()], + ['refundAddresses', getArrayDecoder(getAddressDecoder())], + ]); +} + +export function getRelayerRefundLeafCodec(): Codec< + RelayerRefundLeafArgs, + RelayerRefundLeaf +> { + return combineCodec( + getRelayerRefundLeafEncoder(), + getRelayerRefundLeafDecoder() + ); +} diff --git a/src/svm/clients/SvmSpoke/types/requestedSlowFill.ts b/src/svm/clients/SvmSpoke/types/requestedSlowFill.ts new file mode 100644 index 000000000..af02787ae --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/requestedSlowFill.ts @@ -0,0 +1,102 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export type RequestedSlowFill = { + inputToken: Address; + outputToken: Address; + inputAmount: ReadonlyUint8Array; + outputAmount: bigint; + originChainId: bigint; + depositId: ReadonlyUint8Array; + fillDeadline: number; + exclusivityDeadline: number; + exclusiveRelayer: Address; + depositor: Address; + recipient: Address; + messageHash: ReadonlyUint8Array; +}; + +export type RequestedSlowFillArgs = { + inputToken: Address; + outputToken: Address; + inputAmount: ReadonlyUint8Array; + outputAmount: number | bigint; + originChainId: number | bigint; + depositId: ReadonlyUint8Array; + fillDeadline: number; + exclusivityDeadline: number; + exclusiveRelayer: Address; + depositor: Address; + recipient: Address; + messageHash: ReadonlyUint8Array; +}; + +export function getRequestedSlowFillEncoder(): Encoder { + return getStructEncoder([ + ['inputToken', getAddressEncoder()], + ['outputToken', getAddressEncoder()], + ['inputAmount', fixEncoderSize(getBytesEncoder(), 32)], + ['outputAmount', getU64Encoder()], + ['originChainId', getU64Encoder()], + ['depositId', fixEncoderSize(getBytesEncoder(), 32)], + ['fillDeadline', getU32Encoder()], + ['exclusivityDeadline', getU32Encoder()], + ['exclusiveRelayer', getAddressEncoder()], + ['depositor', getAddressEncoder()], + ['recipient', getAddressEncoder()], + ['messageHash', fixEncoderSize(getBytesEncoder(), 32)], + ]); +} + +export function getRequestedSlowFillDecoder(): Decoder { + return getStructDecoder([ + ['inputToken', getAddressDecoder()], + ['outputToken', getAddressDecoder()], + ['inputAmount', fixDecoderSize(getBytesDecoder(), 32)], + ['outputAmount', getU64Decoder()], + ['originChainId', getU64Decoder()], + ['depositId', fixDecoderSize(getBytesDecoder(), 32)], + ['fillDeadline', getU32Decoder()], + ['exclusivityDeadline', getU32Decoder()], + ['exclusiveRelayer', getAddressDecoder()], + ['depositor', getAddressDecoder()], + ['recipient', getAddressDecoder()], + ['messageHash', fixDecoderSize(getBytesDecoder(), 32)], + ]); +} + +export function getRequestedSlowFillCodec(): Codec< + RequestedSlowFillArgs, + RequestedSlowFill +> { + return combineCodec( + getRequestedSlowFillEncoder(), + getRequestedSlowFillDecoder() + ); +} diff --git a/src/svm/clients/SvmSpoke/types/setXDomainAdmin.ts b/src/svm/clients/SvmSpoke/types/setXDomainAdmin.ts new file mode 100644 index 000000000..ee06f669f --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/setXDomainAdmin.ts @@ -0,0 +1,38 @@ +/** + * 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/kit'; + +export type SetXDomainAdmin = { newAdmin: Address }; + +export type SetXDomainAdminArgs = SetXDomainAdmin; + +export function getSetXDomainAdminEncoder(): Encoder { + return getStructEncoder([['newAdmin', getAddressEncoder()]]); +} + +export function getSetXDomainAdminDecoder(): Decoder { + return getStructDecoder([['newAdmin', getAddressDecoder()]]); +} + +export function getSetXDomainAdminCodec(): Codec< + SetXDomainAdminArgs, + SetXDomainAdmin +> { + return combineCodec(getSetXDomainAdminEncoder(), getSetXDomainAdminDecoder()); +} diff --git a/src/svm/clients/SvmSpoke/types/slowFill.ts b/src/svm/clients/SvmSpoke/types/slowFill.ts new file mode 100644 index 000000000..14de5e442 --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/slowFill.ts @@ -0,0 +1,56 @@ +/** + * 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/kit'; +import { + getRelayDataDecoder, + getRelayDataEncoder, + type RelayData, + type RelayDataArgs, +} from '.'; + +export type SlowFill = { + relayData: RelayData; + chainId: bigint; + updatedOutputAmount: bigint; +}; + +export type SlowFillArgs = { + relayData: RelayDataArgs; + chainId: number | bigint; + updatedOutputAmount: number | bigint; +}; + +export function getSlowFillEncoder(): Encoder { + return getStructEncoder([ + ['relayData', getRelayDataEncoder()], + ['chainId', getU64Encoder()], + ['updatedOutputAmount', getU64Encoder()], + ]); +} + +export function getSlowFillDecoder(): Decoder { + return getStructDecoder([ + ['relayData', getRelayDataDecoder()], + ['chainId', getU64Decoder()], + ['updatedOutputAmount', getU64Decoder()], + ]); +} + +export function getSlowFillCodec(): Codec { + return combineCodec(getSlowFillEncoder(), getSlowFillDecoder()); +} diff --git a/src/svm/clients/SvmSpoke/types/tokensBridged.ts b/src/svm/clients/SvmSpoke/types/tokensBridged.ts new file mode 100644 index 000000000..b22e3c20f --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/tokensBridged.ts @@ -0,0 +1,66 @@ +/** + * 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, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type TokensBridged = { + amountToReturn: bigint; + chainId: bigint; + leafId: number; + l2TokenAddress: Address; + caller: Address; +}; + +export type TokensBridgedArgs = { + amountToReturn: number | bigint; + chainId: number | bigint; + leafId: number; + l2TokenAddress: Address; + caller: Address; +}; + +export function getTokensBridgedEncoder(): Encoder { + return getStructEncoder([ + ['amountToReturn', getU64Encoder()], + ['chainId', getU64Encoder()], + ['leafId', getU32Encoder()], + ['l2TokenAddress', getAddressEncoder()], + ['caller', getAddressEncoder()], + ]); +} + +export function getTokensBridgedDecoder(): Decoder { + return getStructDecoder([ + ['amountToReturn', getU64Decoder()], + ['chainId', getU64Decoder()], + ['leafId', getU32Decoder()], + ['l2TokenAddress', getAddressDecoder()], + ['caller', getAddressDecoder()], + ]); +} + +export function getTokensBridgedCodec(): Codec< + TokensBridgedArgs, + TokensBridged +> { + return combineCodec(getTokensBridgedEncoder(), getTokensBridgedDecoder()); +} diff --git a/src/svm/clients/SvmSpoke/types/transferredOwnership.ts b/src/svm/clients/SvmSpoke/types/transferredOwnership.ts new file mode 100644 index 000000000..13ee0c614 --- /dev/null +++ b/src/svm/clients/SvmSpoke/types/transferredOwnership.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/kit'; + +export type TransferredOwnership = { newOwner: Address }; + +export type TransferredOwnershipArgs = TransferredOwnership; + +export function getTransferredOwnershipEncoder(): Encoder { + return getStructEncoder([['newOwner', getAddressEncoder()]]); +} + +export function getTransferredOwnershipDecoder(): Decoder { + return getStructDecoder([['newOwner', getAddressDecoder()]]); +} + +export function getTransferredOwnershipCodec(): Codec< + TransferredOwnershipArgs, + TransferredOwnership +> { + return combineCodec( + getTransferredOwnershipEncoder(), + getTransferredOwnershipDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinter/accounts/index.ts b/src/svm/clients/TokenMessengerMinter/accounts/index.ts new file mode 100644 index 000000000..fd155b748 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/accounts/index.ts @@ -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. + * + * @see https://github.com/codama-idl/codama + */ + +export * from './localToken'; +export * from './remoteTokenMessenger'; +export * from './tokenMessenger'; +export * from './tokenMinter'; +export * from './tokenPair'; diff --git a/src/svm/clients/TokenMessengerMinter/accounts/localToken.ts b/src/svm/clients/TokenMessengerMinter/accounts/localToken.ts new file mode 100644 index 000000000..9db5966c7 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/accounts/localToken.ts @@ -0,0 +1,169 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU128Decoder, + getU128Encoder, + getU64Decoder, + getU64Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const LOCAL_TOKEN_DISCRIMINATOR = new Uint8Array([ + 159, 131, 58, 170, 193, 84, 128, 182, +]); + +export function getLocalTokenDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(LOCAL_TOKEN_DISCRIMINATOR); +} + +export type LocalToken = { + discriminator: ReadonlyUint8Array; + custody: Address; + mint: Address; + burnLimitPerMessage: bigint; + messagesSent: bigint; + messagesReceived: bigint; + amountSent: bigint; + amountReceived: bigint; + bump: number; + custodyBump: number; +}; + +export type LocalTokenArgs = { + custody: Address; + mint: Address; + burnLimitPerMessage: number | bigint; + messagesSent: number | bigint; + messagesReceived: number | bigint; + amountSent: number | bigint; + amountReceived: number | bigint; + bump: number; + custodyBump: number; +}; + +export function getLocalTokenEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['custody', getAddressEncoder()], + ['mint', getAddressEncoder()], + ['burnLimitPerMessage', getU64Encoder()], + ['messagesSent', getU64Encoder()], + ['messagesReceived', getU64Encoder()], + ['amountSent', getU128Encoder()], + ['amountReceived', getU128Encoder()], + ['bump', getU8Encoder()], + ['custodyBump', getU8Encoder()], + ]), + (value) => ({ ...value, discriminator: LOCAL_TOKEN_DISCRIMINATOR }) + ); +} + +export function getLocalTokenDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['custody', getAddressDecoder()], + ['mint', getAddressDecoder()], + ['burnLimitPerMessage', getU64Decoder()], + ['messagesSent', getU64Decoder()], + ['messagesReceived', getU64Decoder()], + ['amountSent', getU128Decoder()], + ['amountReceived', getU128Decoder()], + ['bump', getU8Decoder()], + ['custodyBump', getU8Decoder()], + ]); +} + +export function getLocalTokenCodec(): Codec { + return combineCodec(getLocalTokenEncoder(), getLocalTokenDecoder()); +} + +export function decodeLocalToken( + encodedAccount: EncodedAccount +): Account; +export function decodeLocalToken( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeLocalToken( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getLocalTokenDecoder() + ); +} + +export async function fetchLocalToken( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeLocalToken(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeLocalToken( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeLocalToken(maybeAccount); +} + +export async function fetchAllLocalToken( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeLocalToken(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeLocalToken( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeLocalToken(maybeAccount)); +} + +export function getLocalTokenSize(): number { + return 130; +} diff --git a/src/svm/clients/TokenMessengerMinter/accounts/remoteTokenMessenger.ts b/src/svm/clients/TokenMessengerMinter/accounts/remoteTokenMessenger.ts new file mode 100644 index 000000000..a2bbc7ecf --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/accounts/remoteTokenMessenger.ts @@ -0,0 +1,164 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const REMOTE_TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ + 105, 115, 174, 34, 95, 233, 138, 252, +]); + +export function getRemoteTokenMessengerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REMOTE_TOKEN_MESSENGER_DISCRIMINATOR + ); +} + +export type RemoteTokenMessenger = { + discriminator: ReadonlyUint8Array; + domain: number; + tokenMessenger: Address; +}; + +export type RemoteTokenMessengerArgs = { + domain: number; + tokenMessenger: Address; +}; + +export function getRemoteTokenMessengerEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['domain', getU32Encoder()], + ['tokenMessenger', getAddressEncoder()], + ]), + (value) => ({ + ...value, + discriminator: REMOTE_TOKEN_MESSENGER_DISCRIMINATOR, + }) + ); +} + +export function getRemoteTokenMessengerDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['domain', getU32Decoder()], + ['tokenMessenger', getAddressDecoder()], + ]); +} + +export function getRemoteTokenMessengerCodec(): Codec< + RemoteTokenMessengerArgs, + RemoteTokenMessenger +> { + return combineCodec( + getRemoteTokenMessengerEncoder(), + getRemoteTokenMessengerDecoder() + ); +} + +export function decodeRemoteTokenMessenger( + encodedAccount: EncodedAccount +): Account; +export function decodeRemoteTokenMessenger( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeRemoteTokenMessenger( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getRemoteTokenMessengerDecoder() + ); +} + +export async function fetchRemoteTokenMessenger< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeRemoteTokenMessenger( + rpc, + address, + config + ); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeRemoteTokenMessenger< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeRemoteTokenMessenger(maybeAccount); +} + +export async function fetchAllRemoteTokenMessenger( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeRemoteTokenMessenger( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeRemoteTokenMessenger( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeRemoteTokenMessenger(maybeAccount) + ); +} + +export function getRemoteTokenMessengerSize(): number { + return 44; +} diff --git a/src/svm/clients/TokenMessengerMinter/accounts/tokenMessenger.ts b/src/svm/clients/TokenMessengerMinter/accounts/tokenMessenger.ts new file mode 100644 index 000000000..df5044649 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/accounts/tokenMessenger.ts @@ -0,0 +1,164 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ + 162, 4, 242, 52, 147, 243, 221, 96, +]); + +export function getTokenMessengerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + TOKEN_MESSENGER_DISCRIMINATOR + ); +} + +export type TokenMessenger = { + discriminator: ReadonlyUint8Array; + owner: Address; + pendingOwner: Address; + localMessageTransmitter: Address; + messageBodyVersion: number; + authorityBump: number; +}; + +export type TokenMessengerArgs = { + owner: Address; + pendingOwner: Address; + localMessageTransmitter: Address; + messageBodyVersion: number; + authorityBump: number; +}; + +export function getTokenMessengerEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['owner', getAddressEncoder()], + ['pendingOwner', getAddressEncoder()], + ['localMessageTransmitter', getAddressEncoder()], + ['messageBodyVersion', getU32Encoder()], + ['authorityBump', getU8Encoder()], + ]), + (value) => ({ ...value, discriminator: TOKEN_MESSENGER_DISCRIMINATOR }) + ); +} + +export function getTokenMessengerDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['owner', getAddressDecoder()], + ['pendingOwner', getAddressDecoder()], + ['localMessageTransmitter', getAddressDecoder()], + ['messageBodyVersion', getU32Decoder()], + ['authorityBump', getU8Decoder()], + ]); +} + +export function getTokenMessengerCodec(): Codec< + TokenMessengerArgs, + TokenMessenger +> { + return combineCodec(getTokenMessengerEncoder(), getTokenMessengerDecoder()); +} + +export function decodeTokenMessenger( + encodedAccount: EncodedAccount +): Account; +export function decodeTokenMessenger( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeTokenMessenger( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getTokenMessengerDecoder() + ); +} + +export async function fetchTokenMessenger( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeTokenMessenger(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeTokenMessenger< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeTokenMessenger(maybeAccount); +} + +export async function fetchAllTokenMessenger( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeTokenMessenger( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeTokenMessenger( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeTokenMessenger(maybeAccount) + ); +} + +export function getTokenMessengerSize(): number { + return 109; +} diff --git a/src/svm/clients/TokenMessengerMinter/accounts/tokenMinter.ts b/src/svm/clients/TokenMessengerMinter/accounts/tokenMinter.ts new file mode 100644 index 000000000..e522ef79d --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/accounts/tokenMinter.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 { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBooleanDecoder, + getBooleanEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const TOKEN_MINTER_DISCRIMINATOR = new Uint8Array([ + 122, 133, 84, 63, 57, 159, 171, 206, +]); + +export function getTokenMinterDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + TOKEN_MINTER_DISCRIMINATOR + ); +} + +export type TokenMinter = { + discriminator: ReadonlyUint8Array; + tokenController: Address; + pauser: Address; + paused: boolean; + bump: number; +}; + +export type TokenMinterArgs = { + tokenController: Address; + pauser: Address; + paused: boolean; + bump: number; +}; + +export function getTokenMinterEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['tokenController', getAddressEncoder()], + ['pauser', getAddressEncoder()], + ['paused', getBooleanEncoder()], + ['bump', getU8Encoder()], + ]), + (value) => ({ ...value, discriminator: TOKEN_MINTER_DISCRIMINATOR }) + ); +} + +export function getTokenMinterDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['tokenController', getAddressDecoder()], + ['pauser', getAddressDecoder()], + ['paused', getBooleanDecoder()], + ['bump', getU8Decoder()], + ]); +} + +export function getTokenMinterCodec(): Codec { + return combineCodec(getTokenMinterEncoder(), getTokenMinterDecoder()); +} + +export function decodeTokenMinter( + encodedAccount: EncodedAccount +): Account; +export function decodeTokenMinter( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeTokenMinter( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getTokenMinterDecoder() + ); +} + +export async function fetchTokenMinter( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeTokenMinter(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeTokenMinter( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeTokenMinter(maybeAccount); +} + +export async function fetchAllTokenMinter( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeTokenMinter(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeTokenMinter( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeTokenMinter(maybeAccount)); +} + +export function getTokenMinterSize(): number { + return 74; +} diff --git a/src/svm/clients/TokenMessengerMinter/accounts/tokenPair.ts b/src/svm/clients/TokenMessengerMinter/accounts/tokenPair.ts new file mode 100644 index 000000000..40fee5627 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/accounts/tokenPair.ts @@ -0,0 +1,147 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const TOKEN_PAIR_DISCRIMINATOR = new Uint8Array([ + 17, 214, 45, 176, 229, 149, 197, 71, +]); + +export function getTokenPairDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(TOKEN_PAIR_DISCRIMINATOR); +} + +export type TokenPair = { + discriminator: ReadonlyUint8Array; + remoteDomain: number; + remoteToken: Address; + localToken: Address; + bump: number; +}; + +export type TokenPairArgs = { + remoteDomain: number; + remoteToken: Address; + localToken: Address; + bump: number; +}; + +export function getTokenPairEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['remoteDomain', getU32Encoder()], + ['remoteToken', getAddressEncoder()], + ['localToken', getAddressEncoder()], + ['bump', getU8Encoder()], + ]), + (value) => ({ ...value, discriminator: TOKEN_PAIR_DISCRIMINATOR }) + ); +} + +export function getTokenPairDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['remoteDomain', getU32Decoder()], + ['remoteToken', getAddressDecoder()], + ['localToken', getAddressDecoder()], + ['bump', getU8Decoder()], + ]); +} + +export function getTokenPairCodec(): Codec { + return combineCodec(getTokenPairEncoder(), getTokenPairDecoder()); +} + +export function decodeTokenPair( + encodedAccount: EncodedAccount +): Account; +export function decodeTokenPair( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeTokenPair( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getTokenPairDecoder() + ); +} + +export async function fetchTokenPair( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeTokenPair(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeTokenPair( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeTokenPair(maybeAccount); +} + +export async function fetchAllTokenPair( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeTokenPair(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeTokenPair( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeTokenPair(maybeAccount)); +} + +export function getTokenPairSize(): number { + return 77; +} diff --git a/src/svm/clients/TokenMessengerMinter/errors/index.ts b/src/svm/clients/TokenMessengerMinter/errors/index.ts new file mode 100644 index 000000000..1e005644b --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/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 './tokenMessengerMinter'; diff --git a/src/svm/clients/TokenMessengerMinter/errors/tokenMessengerMinter.ts b/src/svm/clients/TokenMessengerMinter/errors/tokenMessengerMinter.ts new file mode 100644 index 000000000..aa8f4398c --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/errors/tokenMessengerMinter.ts @@ -0,0 +1,111 @@ +/** + * 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/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; + +/** InvalidAuthority: Invalid authority */ +export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_AUTHORITY = 0x1770; // 6000 +/** InvalidTokenMessengerState: Invalid token messenger state */ +export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MESSENGER_STATE = 0x1771; // 6001 +/** InvalidTokenMessenger: Invalid token messenger */ +export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MESSENGER = 0x1772; // 6002 +/** InvalidOwner: Invalid owner */ +export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_OWNER = 0x1773; // 6003 +/** MalformedMessage: Malformed message */ +export const TOKEN_MESSENGER_MINTER_ERROR__MALFORMED_MESSAGE = 0x1774; // 6004 +/** InvalidMessageBodyVersion: Invalid message body version */ +export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_MESSAGE_BODY_VERSION = 0x1775; // 6005 +/** InvalidAmount: Invalid amount */ +export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_AMOUNT = 0x1776; // 6006 +/** InvalidDestinationDomain: Invalid destination domain */ +export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_DESTINATION_DOMAIN = 0x1777; // 6007 +/** InvalidDestinationCaller: Invalid destination caller */ +export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_DESTINATION_CALLER = 0x1778; // 6008 +/** InvalidMintRecipient: Invalid mint recipient */ +export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_MINT_RECIPIENT = 0x1779; // 6009 +/** InvalidSender: Invalid sender */ +export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_SENDER = 0x177a; // 6010 +/** InvalidTokenPair: Invalid token pair */ +export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_PAIR = 0x177b; // 6011 +/** InvalidTokenMint: Invalid token mint */ +export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MINT = 0x177c; // 6012 + +export type TokenMessengerMinterError = + | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_AMOUNT + | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_AUTHORITY + | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_DESTINATION_CALLER + | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_DESTINATION_DOMAIN + | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_MESSAGE_BODY_VERSION + | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_MINT_RECIPIENT + | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_OWNER + | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_SENDER + | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MESSENGER + | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MESSENGER_STATE + | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MINT + | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_PAIR + | typeof TOKEN_MESSENGER_MINTER_ERROR__MALFORMED_MESSAGE; + +let tokenMessengerMinterErrorMessages: + | Record + | undefined; +if (process.env.NODE_ENV !== 'production') { + tokenMessengerMinterErrorMessages = { + [TOKEN_MESSENGER_MINTER_ERROR__INVALID_AMOUNT]: `Invalid amount`, + [TOKEN_MESSENGER_MINTER_ERROR__INVALID_AUTHORITY]: `Invalid authority`, + [TOKEN_MESSENGER_MINTER_ERROR__INVALID_DESTINATION_CALLER]: `Invalid destination caller`, + [TOKEN_MESSENGER_MINTER_ERROR__INVALID_DESTINATION_DOMAIN]: `Invalid destination domain`, + [TOKEN_MESSENGER_MINTER_ERROR__INVALID_MESSAGE_BODY_VERSION]: `Invalid message body version`, + [TOKEN_MESSENGER_MINTER_ERROR__INVALID_MINT_RECIPIENT]: `Invalid mint recipient`, + [TOKEN_MESSENGER_MINTER_ERROR__INVALID_OWNER]: `Invalid owner`, + [TOKEN_MESSENGER_MINTER_ERROR__INVALID_SENDER]: `Invalid sender`, + [TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MESSENGER]: `Invalid token messenger`, + [TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MESSENGER_STATE]: `Invalid token messenger state`, + [TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MINT]: `Invalid token mint`, + [TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_PAIR]: `Invalid token pair`, + [TOKEN_MESSENGER_MINTER_ERROR__MALFORMED_MESSAGE]: `Malformed message`, + }; +} + +export function getTokenMessengerMinterErrorMessage( + code: TokenMessengerMinterError +): string { + if (process.env.NODE_ENV !== 'production') { + return ( + tokenMessengerMinterErrorMessages as Record< + TokenMessengerMinterError, + string + > + )[code]; + } + + return 'Error message not available in production bundles.'; +} + +export function isTokenMessengerMinterError< + TProgramErrorCode extends TokenMessengerMinterError, +>( + error: unknown, + transactionMessage: { + instructions: Record; + }, + code?: TProgramErrorCode +): error is SolanaError & + Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { + return isProgramError( + error, + transactionMessage, + TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + code + ); +} diff --git a/src/svm/clients/TokenMessengerMinter/index.ts b/src/svm/clients/TokenMessengerMinter/index.ts new file mode 100644 index 000000000..02964a6ae --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/index.ts @@ -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. + * + * @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/src/svm/clients/TokenMessengerMinter/instructions/acceptOwnership.ts b/src/svm/clients/TokenMessengerMinter/instructions/acceptOwnership.ts new file mode 100644 index 000000000..99146d8f4 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/acceptOwnership.ts @@ -0,0 +1,216 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const ACCEPT_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ + 172, 23, 43, 13, 238, 213, 85, 150, +]); + +export function getAcceptOwnershipDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + ACCEPT_OWNERSHIP_DISCRIMINATOR + ); +} + +export type AcceptOwnershipInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountPendingOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPendingOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountPendingOwner, + TAccountTokenMessenger extends string + ? WritableAccount + : TAccountTokenMessenger, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type AcceptOwnershipInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type AcceptOwnershipInstructionDataArgs = {}; + +export function getAcceptOwnershipInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: ACCEPT_OWNERSHIP_DISCRIMINATOR }) + ); +} + +export function getAcceptOwnershipInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getAcceptOwnershipInstructionDataCodec(): Codec< + AcceptOwnershipInstructionDataArgs, + AcceptOwnershipInstructionData +> { + return combineCodec( + getAcceptOwnershipInstructionDataEncoder(), + getAcceptOwnershipInstructionDataDecoder() + ); +} + +export type AcceptOwnershipInput< + TAccountPendingOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pendingOwner: TransactionSigner; + tokenMessenger: Address; + eventAuthority: Address; + program: Address; +}; + +export function getAcceptOwnershipInstruction< + TAccountPendingOwner extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: AcceptOwnershipInput< + TAccountPendingOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): AcceptOwnershipInstruction< + TProgramAddress, + TAccountPendingOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pendingOwner: { value: input.pendingOwner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pendingOwner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getAcceptOwnershipInstructionDataEncoder().encode({}), + } as AcceptOwnershipInstruction< + TProgramAddress, + TAccountPendingOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedAcceptOwnershipInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + pendingOwner: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: AcceptOwnershipInstructionData; +}; + +export function parseAcceptOwnershipInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedAcceptOwnershipInstruction { + if (instruction.accounts.length < 4) { + // 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: { + pendingOwner: getNextAccount(), + tokenMessenger: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getAcceptOwnershipInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/addLocalToken.ts b/src/svm/clients/TokenMessengerMinter/instructions/addLocalToken.ts new file mode 100644 index 000000000..46bdf9dd1 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/addLocalToken.ts @@ -0,0 +1,320 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const ADD_LOCAL_TOKEN_DISCRIMINATOR = new Uint8Array([ + 213, 199, 205, 18, 98, 124, 73, 198, +]); + +export function getAddLocalTokenDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + ADD_LOCAL_TOKEN_DISCRIMINATOR + ); +} + +export type AddLocalTokenInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountTokenController extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountCustodyTokenAccount extends string | AccountMeta = string, + TAccountLocalTokenMint extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountTokenController extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountTokenController, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountCustodyTokenAccount extends string + ? WritableAccount + : TAccountCustodyTokenAccount, + TAccountLocalTokenMint extends string + ? ReadonlyAccount + : TAccountLocalTokenMint, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type AddLocalTokenInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type AddLocalTokenInstructionDataArgs = {}; + +export function getAddLocalTokenInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: ADD_LOCAL_TOKEN_DISCRIMINATOR }) + ); +} + +export function getAddLocalTokenInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getAddLocalTokenInstructionDataCodec(): Codec< + AddLocalTokenInstructionDataArgs, + AddLocalTokenInstructionData +> { + return combineCodec( + getAddLocalTokenInstructionDataEncoder(), + getAddLocalTokenInstructionDataDecoder() + ); +} + +export type AddLocalTokenInput< + TAccountPayer extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountLocalTokenMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + localToken: Address; + custodyTokenAccount: Address; + localTokenMint: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; +}; + +export function getAddLocalTokenInstruction< + TAccountPayer extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountCustodyTokenAccount extends string, + TAccountLocalTokenMint extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: AddLocalTokenInput< + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountLocalTokenMint, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): AddLocalTokenInstruction< + TProgramAddress, + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountLocalTokenMint, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + localTokenMint: { value: input.localTokenMint ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.localTokenMint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getAddLocalTokenInstructionDataEncoder().encode({}), + } as AddLocalTokenInstruction< + TProgramAddress, + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountLocalTokenMint, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedAddLocalTokenInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + tokenController: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + localToken: TAccountMetas[3]; + custodyTokenAccount: TAccountMetas[4]; + localTokenMint: TAccountMetas[5]; + tokenProgram: TAccountMetas[6]; + systemProgram: TAccountMetas[7]; + eventAuthority: TAccountMetas[8]; + program: TAccountMetas[9]; + }; + data: AddLocalTokenInstructionData; +}; + +export function parseAddLocalTokenInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedAddLocalTokenInstruction { + if (instruction.accounts.length < 10) { + // 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: { + payer: getNextAccount(), + tokenController: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + custodyTokenAccount: getNextAccount(), + localTokenMint: getNextAccount(), + tokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getAddLocalTokenInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/addRemoteTokenMessenger.ts b/src/svm/clients/TokenMessengerMinter/instructions/addRemoteTokenMessenger.ts new file mode 100644 index 000000000..f3686285f --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/addRemoteTokenMessenger.ts @@ -0,0 +1,297 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const ADD_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ + 12, 149, 172, 165, 111, 202, 24, 33, +]); + +export function getAddRemoteTokenMessengerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + ADD_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR + ); +} + +export type AddRemoteTokenMessengerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountRemoteTokenMessenger extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountRemoteTokenMessenger extends string + ? WritableAccount + : TAccountRemoteTokenMessenger, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type AddRemoteTokenMessengerInstructionData = { + discriminator: ReadonlyUint8Array; + domain: number; + tokenMessenger: Address; +}; + +export type AddRemoteTokenMessengerInstructionDataArgs = { + domain: number; + tokenMessenger: Address; +}; + +export function getAddRemoteTokenMessengerInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['domain', getU32Encoder()], + ['tokenMessenger', getAddressEncoder()], + ]), + (value) => ({ + ...value, + discriminator: ADD_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR, + }) + ); +} + +export function getAddRemoteTokenMessengerInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['domain', getU32Decoder()], + ['tokenMessenger', getAddressDecoder()], + ]); +} + +export function getAddRemoteTokenMessengerInstructionDataCodec(): Codec< + AddRemoteTokenMessengerInstructionDataArgs, + AddRemoteTokenMessengerInstructionData +> { + return combineCodec( + getAddRemoteTokenMessengerInstructionDataEncoder(), + getAddRemoteTokenMessengerInstructionDataDecoder() + ); +} + +export type AddRemoteTokenMessengerInput< + TAccountPayer extends string = string, + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + owner: TransactionSigner; + tokenMessenger: Address; + remoteTokenMessenger: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + domain: AddRemoteTokenMessengerInstructionDataArgs['domain']; + tokenMessengerArg: AddRemoteTokenMessengerInstructionDataArgs['tokenMessenger']; +}; + +export function getAddRemoteTokenMessengerInstruction< + TAccountPayer extends string, + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: AddRemoteTokenMessengerInput< + TAccountPayer, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): AddRemoteTokenMessengerInstruction< + TProgramAddress, + TAccountPayer, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: true, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input, tokenMessenger: input.tokenMessengerArg }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getAddRemoteTokenMessengerInstructionDataEncoder().encode( + args as AddRemoteTokenMessengerInstructionDataArgs + ), + } as AddRemoteTokenMessengerInstruction< + TProgramAddress, + TAccountPayer, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedAddRemoteTokenMessengerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + owner: TAccountMetas[1]; + tokenMessenger: TAccountMetas[2]; + remoteTokenMessenger: TAccountMetas[3]; + systemProgram: TAccountMetas[4]; + eventAuthority: TAccountMetas[5]; + program: TAccountMetas[6]; + }; + data: AddRemoteTokenMessengerInstructionData; +}; + +export function parseAddRemoteTokenMessengerInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedAddRemoteTokenMessengerInstruction { + if (instruction.accounts.length < 7) { + // 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: { + payer: getNextAccount(), + owner: getNextAccount(), + tokenMessenger: getNextAccount(), + remoteTokenMessenger: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getAddRemoteTokenMessengerInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/burnTokenCustody.ts b/src/svm/clients/TokenMessengerMinter/instructions/burnTokenCustody.ts new file mode 100644 index 000000000..6b98c5544 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/burnTokenCustody.ts @@ -0,0 +1,317 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const BURN_TOKEN_CUSTODY_DISCRIMINATOR = new Uint8Array([ + 233, 136, 180, 175, 112, 41, 62, 71, +]); + +export function getBurnTokenCustodyDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + BURN_TOKEN_CUSTODY_DISCRIMINATOR + ); +} + +export type BurnTokenCustodyInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountPayee extends string | AccountMeta = string, + TAccountTokenController extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountCustodyTokenAccount extends string | AccountMeta = string, + TAccountCustodyTokenMint extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayee extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayee, + TAccountTokenController extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountTokenController, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? ReadonlyAccount + : TAccountLocalToken, + TAccountCustodyTokenAccount extends string + ? WritableAccount + : TAccountCustodyTokenAccount, + TAccountCustodyTokenMint extends string + ? WritableAccount + : TAccountCustodyTokenMint, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type BurnTokenCustodyInstructionData = { + discriminator: ReadonlyUint8Array; + amount: bigint; +}; + +export type BurnTokenCustodyInstructionDataArgs = { amount: number | bigint }; + +export function getBurnTokenCustodyInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['amount', getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: BURN_TOKEN_CUSTODY_DISCRIMINATOR }) + ); +} + +export function getBurnTokenCustodyInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['amount', getU64Decoder()], + ]); +} + +export function getBurnTokenCustodyInstructionDataCodec(): Codec< + BurnTokenCustodyInstructionDataArgs, + BurnTokenCustodyInstructionData +> { + return combineCodec( + getBurnTokenCustodyInstructionDataEncoder(), + getBurnTokenCustodyInstructionDataDecoder() + ); +} + +export type BurnTokenCustodyInput< + TAccountPayee extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountCustodyTokenMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payee: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + localToken: Address; + custodyTokenAccount: Address; + custodyTokenMint: Address; + tokenProgram?: Address; + eventAuthority: Address; + program: Address; + amount: BurnTokenCustodyInstructionDataArgs['amount']; +}; + +export function getBurnTokenCustodyInstruction< + TAccountPayee extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountCustodyTokenAccount extends string, + TAccountCustodyTokenMint extends string, + TAccountTokenProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: BurnTokenCustodyInput< + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): BurnTokenCustodyInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: false }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + custodyTokenMint: { + value: input.custodyTokenMint ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.custodyTokenMint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getBurnTokenCustodyInstructionDataEncoder().encode( + args as BurnTokenCustodyInstructionDataArgs + ), + } as BurnTokenCustodyInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedBurnTokenCustodyInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payee: TAccountMetas[0]; + tokenController: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + localToken: TAccountMetas[3]; + custodyTokenAccount: TAccountMetas[4]; + custodyTokenMint: TAccountMetas[5]; + tokenProgram: TAccountMetas[6]; + eventAuthority: TAccountMetas[7]; + program: TAccountMetas[8]; + }; + data: BurnTokenCustodyInstructionData; +}; + +export function parseBurnTokenCustodyInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedBurnTokenCustodyInstruction { + if (instruction.accounts.length < 9) { + // 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: { + payee: getNextAccount(), + tokenController: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + custodyTokenAccount: getNextAccount(), + custodyTokenMint: getNextAccount(), + tokenProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getBurnTokenCustodyInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/depositForBurn.ts b/src/svm/clients/TokenMessengerMinter/instructions/depositForBurn.ts new file mode 100644 index 000000000..1ccbd5a2b --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/depositForBurn.ts @@ -0,0 +1,465 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const DEPOSIT_FOR_BURN_DISCRIMINATOR = new Uint8Array([ + 215, 60, 61, 46, 114, 55, 128, 176, +]); + +export function getDepositForBurnDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DEPOSIT_FOR_BURN_DISCRIMINATOR + ); +} + +export type DepositForBurnInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountEventRentPayer extends string | AccountMeta = string, + TAccountSenderAuthorityPda extends string | AccountMeta = string, + TAccountBurnTokenAccount extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountRemoteTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountBurnTokenMint extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TAccountMessageTransmitterProgram extends string | AccountMeta = + string, + TAccountTokenMessengerMinterProgram extends string | AccountMeta = + string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountEventRentPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountEventRentPayer, + TAccountSenderAuthorityPda extends string + ? ReadonlyAccount + : TAccountSenderAuthorityPda, + TAccountBurnTokenAccount extends string + ? WritableAccount + : TAccountBurnTokenAccount, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountRemoteTokenMessenger extends string + ? ReadonlyAccount + : TAccountRemoteTokenMessenger, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountBurnTokenMint extends string + ? WritableAccount + : TAccountBurnTokenMint, + TAccountMessageSentEventData extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountMessageSentEventData, + TAccountMessageTransmitterProgram extends string + ? ReadonlyAccount + : TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram extends string + ? ReadonlyAccount + : TAccountTokenMessengerMinterProgram, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type DepositForBurnInstructionData = { + discriminator: ReadonlyUint8Array; + amount: bigint; + destinationDomain: number; + mintRecipient: Address; +}; + +export type DepositForBurnInstructionDataArgs = { + amount: number | bigint; + destinationDomain: number; + mintRecipient: Address; +}; + +export function getDepositForBurnInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['amount', getU64Encoder()], + ['destinationDomain', getU32Encoder()], + ['mintRecipient', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: DEPOSIT_FOR_BURN_DISCRIMINATOR }) + ); +} + +export function getDepositForBurnInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['amount', getU64Decoder()], + ['destinationDomain', getU32Decoder()], + ['mintRecipient', getAddressDecoder()], + ]); +} + +export function getDepositForBurnInstructionDataCodec(): Codec< + DepositForBurnInstructionDataArgs, + DepositForBurnInstructionData +> { + return combineCodec( + getDepositForBurnInstructionDataEncoder(), + getDepositForBurnInstructionDataDecoder() + ); +} + +export type DepositForBurnInput< + TAccountOwner extends string = string, + TAccountEventRentPayer extends string = string, + TAccountSenderAuthorityPda extends string = string, + TAccountBurnTokenAccount extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountBurnTokenMint extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + eventRentPayer: TransactionSigner; + senderAuthorityPda: Address; + burnTokenAccount: Address; + messageTransmitter: Address; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken: Address; + burnTokenMint: Address; + messageSentEventData: TransactionSigner; + messageTransmitterProgram: Address; + tokenMessengerMinterProgram: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + amount: DepositForBurnInstructionDataArgs['amount']; + destinationDomain: DepositForBurnInstructionDataArgs['destinationDomain']; + mintRecipient: DepositForBurnInstructionDataArgs['mintRecipient']; +}; + +export function getDepositForBurnInstruction< + TAccountOwner extends string, + TAccountEventRentPayer extends string, + TAccountSenderAuthorityPda extends string, + TAccountBurnTokenAccount extends string, + TAccountMessageTransmitter extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountBurnTokenMint extends string, + TAccountMessageSentEventData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: DepositForBurnInput< + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): DepositForBurnInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, + senderAuthorityPda: { + value: input.senderAuthorityPda ?? null, + isWritable: false, + }, + burnTokenAccount: { + value: input.burnTokenAccount ?? null, + isWritable: true, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + burnTokenMint: { value: input.burnTokenMint ?? null, isWritable: true }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.eventRentPayer), + getAccountMeta(accounts.senderAuthorityPda), + getAccountMeta(accounts.burnTokenAccount), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.burnTokenMint), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDepositForBurnInstructionDataEncoder().encode( + args as DepositForBurnInstructionDataArgs + ), + } as DepositForBurnInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedDepositForBurnInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + eventRentPayer: TAccountMetas[1]; + senderAuthorityPda: TAccountMetas[2]; + burnTokenAccount: TAccountMetas[3]; + messageTransmitter: TAccountMetas[4]; + tokenMessenger: TAccountMetas[5]; + remoteTokenMessenger: TAccountMetas[6]; + tokenMinter: TAccountMetas[7]; + localToken: TAccountMetas[8]; + burnTokenMint: TAccountMetas[9]; + messageSentEventData: TAccountMetas[10]; + messageTransmitterProgram: TAccountMetas[11]; + tokenMessengerMinterProgram: TAccountMetas[12]; + tokenProgram: TAccountMetas[13]; + systemProgram: TAccountMetas[14]; + eventAuthority: TAccountMetas[15]; + program: TAccountMetas[16]; + }; + data: DepositForBurnInstructionData; +}; + +export function parseDepositForBurnInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedDepositForBurnInstruction { + if (instruction.accounts.length < 17) { + // 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: { + owner: getNextAccount(), + eventRentPayer: getNextAccount(), + senderAuthorityPda: getNextAccount(), + burnTokenAccount: getNextAccount(), + messageTransmitter: getNextAccount(), + tokenMessenger: getNextAccount(), + remoteTokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + burnTokenMint: getNextAccount(), + messageSentEventData: getNextAccount(), + messageTransmitterProgram: getNextAccount(), + tokenMessengerMinterProgram: getNextAccount(), + tokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getDepositForBurnInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/depositForBurnWithCaller.ts b/src/svm/clients/TokenMessengerMinter/instructions/depositForBurnWithCaller.ts new file mode 100644 index 000000000..d8d061f87 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/depositForBurnWithCaller.ts @@ -0,0 +1,475 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const DEPOSIT_FOR_BURN_WITH_CALLER_DISCRIMINATOR = new Uint8Array([ + 167, 222, 19, 114, 85, 21, 14, 118, +]); + +export function getDepositForBurnWithCallerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DEPOSIT_FOR_BURN_WITH_CALLER_DISCRIMINATOR + ); +} + +export type DepositForBurnWithCallerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountEventRentPayer extends string | AccountMeta = string, + TAccountSenderAuthorityPda extends string | AccountMeta = string, + TAccountBurnTokenAccount extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountRemoteTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountBurnTokenMint extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TAccountMessageTransmitterProgram extends string | AccountMeta = + string, + TAccountTokenMessengerMinterProgram extends string | AccountMeta = + string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountEventRentPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountEventRentPayer, + TAccountSenderAuthorityPda extends string + ? ReadonlyAccount + : TAccountSenderAuthorityPda, + TAccountBurnTokenAccount extends string + ? WritableAccount + : TAccountBurnTokenAccount, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountRemoteTokenMessenger extends string + ? ReadonlyAccount + : TAccountRemoteTokenMessenger, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountBurnTokenMint extends string + ? WritableAccount + : TAccountBurnTokenMint, + TAccountMessageSentEventData extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountMessageSentEventData, + TAccountMessageTransmitterProgram extends string + ? ReadonlyAccount + : TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram extends string + ? ReadonlyAccount + : TAccountTokenMessengerMinterProgram, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type DepositForBurnWithCallerInstructionData = { + discriminator: ReadonlyUint8Array; + amount: bigint; + destinationDomain: number; + mintRecipient: Address; + destinationCaller: Address; +}; + +export type DepositForBurnWithCallerInstructionDataArgs = { + amount: number | bigint; + destinationDomain: number; + mintRecipient: Address; + destinationCaller: Address; +}; + +export function getDepositForBurnWithCallerInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['amount', getU64Encoder()], + ['destinationDomain', getU32Encoder()], + ['mintRecipient', getAddressEncoder()], + ['destinationCaller', getAddressEncoder()], + ]), + (value) => ({ + ...value, + discriminator: DEPOSIT_FOR_BURN_WITH_CALLER_DISCRIMINATOR, + }) + ); +} + +export function getDepositForBurnWithCallerInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['amount', getU64Decoder()], + ['destinationDomain', getU32Decoder()], + ['mintRecipient', getAddressDecoder()], + ['destinationCaller', getAddressDecoder()], + ]); +} + +export function getDepositForBurnWithCallerInstructionDataCodec(): Codec< + DepositForBurnWithCallerInstructionDataArgs, + DepositForBurnWithCallerInstructionData +> { + return combineCodec( + getDepositForBurnWithCallerInstructionDataEncoder(), + getDepositForBurnWithCallerInstructionDataDecoder() + ); +} + +export type DepositForBurnWithCallerInput< + TAccountOwner extends string = string, + TAccountEventRentPayer extends string = string, + TAccountSenderAuthorityPda extends string = string, + TAccountBurnTokenAccount extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountBurnTokenMint extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + eventRentPayer: TransactionSigner; + senderAuthorityPda: Address; + burnTokenAccount: Address; + messageTransmitter: Address; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken: Address; + burnTokenMint: Address; + messageSentEventData: TransactionSigner; + messageTransmitterProgram: Address; + tokenMessengerMinterProgram: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + amount: DepositForBurnWithCallerInstructionDataArgs['amount']; + destinationDomain: DepositForBurnWithCallerInstructionDataArgs['destinationDomain']; + mintRecipient: DepositForBurnWithCallerInstructionDataArgs['mintRecipient']; + destinationCaller: DepositForBurnWithCallerInstructionDataArgs['destinationCaller']; +}; + +export function getDepositForBurnWithCallerInstruction< + TAccountOwner extends string, + TAccountEventRentPayer extends string, + TAccountSenderAuthorityPda extends string, + TAccountBurnTokenAccount extends string, + TAccountMessageTransmitter extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountBurnTokenMint extends string, + TAccountMessageSentEventData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: DepositForBurnWithCallerInput< + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): DepositForBurnWithCallerInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, + senderAuthorityPda: { + value: input.senderAuthorityPda ?? null, + isWritable: false, + }, + burnTokenAccount: { + value: input.burnTokenAccount ?? null, + isWritable: true, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + burnTokenMint: { value: input.burnTokenMint ?? null, isWritable: true }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.eventRentPayer), + getAccountMeta(accounts.senderAuthorityPda), + getAccountMeta(accounts.burnTokenAccount), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.burnTokenMint), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDepositForBurnWithCallerInstructionDataEncoder().encode( + args as DepositForBurnWithCallerInstructionDataArgs + ), + } as DepositForBurnWithCallerInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedDepositForBurnWithCallerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + eventRentPayer: TAccountMetas[1]; + senderAuthorityPda: TAccountMetas[2]; + burnTokenAccount: TAccountMetas[3]; + messageTransmitter: TAccountMetas[4]; + tokenMessenger: TAccountMetas[5]; + remoteTokenMessenger: TAccountMetas[6]; + tokenMinter: TAccountMetas[7]; + localToken: TAccountMetas[8]; + burnTokenMint: TAccountMetas[9]; + messageSentEventData: TAccountMetas[10]; + messageTransmitterProgram: TAccountMetas[11]; + tokenMessengerMinterProgram: TAccountMetas[12]; + tokenProgram: TAccountMetas[13]; + systemProgram: TAccountMetas[14]; + eventAuthority: TAccountMetas[15]; + program: TAccountMetas[16]; + }; + data: DepositForBurnWithCallerInstructionData; +}; + +export function parseDepositForBurnWithCallerInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedDepositForBurnWithCallerInstruction { + if (instruction.accounts.length < 17) { + // 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: { + owner: getNextAccount(), + eventRentPayer: getNextAccount(), + senderAuthorityPda: getNextAccount(), + burnTokenAccount: getNextAccount(), + messageTransmitter: getNextAccount(), + tokenMessenger: getNextAccount(), + remoteTokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + burnTokenMint: getNextAccount(), + messageSentEventData: getNextAccount(), + messageTransmitterProgram: getNextAccount(), + tokenMessengerMinterProgram: getNextAccount(), + tokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getDepositForBurnWithCallerInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/handleReceiveMessage.ts b/src/svm/clients/TokenMessengerMinter/instructions/handleReceiveMessage.ts new file mode 100644 index 000000000..e1c7934ca --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/handleReceiveMessage.ts @@ -0,0 +1,371 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const HANDLE_RECEIVE_MESSAGE_DISCRIMINATOR = new Uint8Array([ + 133, 102, 1, 180, 145, 11, 138, 180, +]); + +export function getHandleReceiveMessageDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + HANDLE_RECEIVE_MESSAGE_DISCRIMINATOR + ); +} + +export type HandleReceiveMessageInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountAuthorityPda extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountRemoteTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountTokenPair extends string | AccountMeta = string, + TAccountRecipientTokenAccount extends string | AccountMeta = string, + TAccountCustodyTokenAccount extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountAuthorityPda extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthorityPda, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountRemoteTokenMessenger extends string + ? ReadonlyAccount + : TAccountRemoteTokenMessenger, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountTokenPair extends string + ? ReadonlyAccount + : TAccountTokenPair, + TAccountRecipientTokenAccount extends string + ? WritableAccount + : TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount extends string + ? WritableAccount + : TAccountCustodyTokenAccount, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type HandleReceiveMessageInstructionData = { + discriminator: ReadonlyUint8Array; + remoteDomain: number; + sender: Address; + messageBody: ReadonlyUint8Array; + authorityBump: number; +}; + +export type HandleReceiveMessageInstructionDataArgs = { + remoteDomain: number; + sender: Address; + messageBody: ReadonlyUint8Array; + authorityBump: number; +}; + +export function getHandleReceiveMessageInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['remoteDomain', getU32Encoder()], + ['sender', getAddressEncoder()], + ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ['authorityBump', getU8Encoder()], + ]), + (value) => ({ + ...value, + discriminator: HANDLE_RECEIVE_MESSAGE_DISCRIMINATOR, + }) + ); +} + +export function getHandleReceiveMessageInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['remoteDomain', getU32Decoder()], + ['sender', getAddressDecoder()], + ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ['authorityBump', getU8Decoder()], + ]); +} + +export function getHandleReceiveMessageInstructionDataCodec(): Codec< + HandleReceiveMessageInstructionDataArgs, + HandleReceiveMessageInstructionData +> { + return combineCodec( + getHandleReceiveMessageInstructionDataEncoder(), + getHandleReceiveMessageInstructionDataDecoder() + ); +} + +export type HandleReceiveMessageInput< + TAccountAuthorityPda extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountTokenPair extends string = string, + TAccountRecipientTokenAccount extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountTokenProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + authorityPda: TransactionSigner; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken: Address; + tokenPair: Address; + recipientTokenAccount: Address; + custodyTokenAccount: Address; + tokenProgram?: Address; + eventAuthority: Address; + program: Address; + remoteDomain: HandleReceiveMessageInstructionDataArgs['remoteDomain']; + sender: HandleReceiveMessageInstructionDataArgs['sender']; + messageBody: HandleReceiveMessageInstructionDataArgs['messageBody']; + authorityBump: HandleReceiveMessageInstructionDataArgs['authorityBump']; +}; + +export function getHandleReceiveMessageInstruction< + TAccountAuthorityPda extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountTokenPair extends string, + TAccountRecipientTokenAccount extends string, + TAccountCustodyTokenAccount extends string, + TAccountTokenProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: HandleReceiveMessageInput< + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): HandleReceiveMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + authorityPda: { value: input.authorityPda ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + tokenPair: { value: input.tokenPair ?? null, isWritable: false }, + recipientTokenAccount: { + value: input.recipientTokenAccount ?? null, + isWritable: true, + }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.authorityPda), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.tokenPair), + getAccountMeta(accounts.recipientTokenAccount), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getHandleReceiveMessageInstructionDataEncoder().encode( + args as HandleReceiveMessageInstructionDataArgs + ), + } as HandleReceiveMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedHandleReceiveMessageInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + authorityPda: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + remoteTokenMessenger: TAccountMetas[2]; + tokenMinter: TAccountMetas[3]; + localToken: TAccountMetas[4]; + tokenPair: TAccountMetas[5]; + recipientTokenAccount: TAccountMetas[6]; + custodyTokenAccount: TAccountMetas[7]; + tokenProgram: TAccountMetas[8]; + eventAuthority: TAccountMetas[9]; + program: TAccountMetas[10]; + }; + data: HandleReceiveMessageInstructionData; +}; + +export function parseHandleReceiveMessageInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedHandleReceiveMessageInstruction { + if (instruction.accounts.length < 11) { + // 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: { + authorityPda: getNextAccount(), + tokenMessenger: getNextAccount(), + remoteTokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + tokenPair: getNextAccount(), + recipientTokenAccount: getNextAccount(), + custodyTokenAccount: getNextAccount(), + tokenProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getHandleReceiveMessageInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/index.ts b/src/svm/clients/TokenMessengerMinter/instructions/index.ts new file mode 100644 index 000000000..4f7879d35 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/index.ts @@ -0,0 +1,27 @@ +/** + * 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 './acceptOwnership'; +export * from './addLocalToken'; +export * from './addRemoteTokenMessenger'; +export * from './burnTokenCustody'; +export * from './depositForBurn'; +export * from './depositForBurnWithCaller'; +export * from './handleReceiveMessage'; +export * from './initialize'; +export * from './linkTokenPair'; +export * from './pause'; +export * from './removeLocalToken'; +export * from './removeRemoteTokenMessenger'; +export * from './replaceDepositForBurn'; +export * from './setMaxBurnAmountPerMessage'; +export * from './setTokenController'; +export * from './transferOwnership'; +export * from './unlinkTokenPair'; +export * from './unpause'; +export * from './updatePauser'; diff --git a/src/svm/clients/TokenMessengerMinter/instructions/initialize.ts b/src/svm/clients/TokenMessengerMinter/instructions/initialize.ts new file mode 100644 index 000000000..c41147b19 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/initialize.ts @@ -0,0 +1,345 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const INITIALIZE_DISCRIMINATOR = new Uint8Array([ + 175, 175, 109, 31, 13, 152, 155, 237, +]); + +export function getInitializeDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_DISCRIMINATOR); +} + +export type InitializeInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountUpgradeAuthority extends string | AccountMeta = string, + TAccountAuthorityPda extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountTokenMessengerMinterProgramData extends string | AccountMeta = + string, + TAccountTokenMessengerMinterProgram extends string | AccountMeta = + string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountUpgradeAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountUpgradeAuthority, + TAccountAuthorityPda extends string + ? ReadonlyAccount + : TAccountAuthorityPda, + TAccountTokenMessenger extends string + ? WritableAccount + : TAccountTokenMessenger, + TAccountTokenMinter extends string + ? WritableAccount + : TAccountTokenMinter, + TAccountTokenMessengerMinterProgramData extends string + ? ReadonlyAccount + : TAccountTokenMessengerMinterProgramData, + TAccountTokenMessengerMinterProgram extends string + ? ReadonlyAccount + : TAccountTokenMessengerMinterProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type InitializeInstructionData = { + discriminator: ReadonlyUint8Array; + tokenController: Address; + localMessageTransmitter: Address; + messageBodyVersion: number; +}; + +export type InitializeInstructionDataArgs = { + tokenController: Address; + localMessageTransmitter: Address; + messageBodyVersion: number; +}; + +export function getInitializeInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['tokenController', getAddressEncoder()], + ['localMessageTransmitter', getAddressEncoder()], + ['messageBodyVersion', getU32Encoder()], + ]), + (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) + ); +} + +export function getInitializeInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['tokenController', getAddressDecoder()], + ['localMessageTransmitter', getAddressDecoder()], + ['messageBodyVersion', getU32Decoder()], + ]); +} + +export function getInitializeInstructionDataCodec(): Codec< + InitializeInstructionDataArgs, + InitializeInstructionData +> { + return combineCodec( + getInitializeInstructionDataEncoder(), + getInitializeInstructionDataDecoder() + ); +} + +export type InitializeInput< + TAccountPayer extends string = string, + TAccountUpgradeAuthority extends string = string, + TAccountAuthorityPda extends string = string, + TAccountTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountTokenMessengerMinterProgramData extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + upgradeAuthority: TransactionSigner; + authorityPda: Address; + tokenMessenger: Address; + tokenMinter: Address; + tokenMessengerMinterProgramData: Address; + tokenMessengerMinterProgram: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + tokenController: InitializeInstructionDataArgs['tokenController']; + localMessageTransmitter: InitializeInstructionDataArgs['localMessageTransmitter']; + messageBodyVersion: InitializeInstructionDataArgs['messageBodyVersion']; +}; + +export function getInitializeInstruction< + TAccountPayer extends string, + TAccountUpgradeAuthority extends string, + TAccountAuthorityPda extends string, + TAccountTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountTokenMessengerMinterProgramData extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: InitializeInput< + TAccountPayer, + TAccountUpgradeAuthority, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountTokenMessengerMinterProgramData, + TAccountTokenMessengerMinterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): InitializeInstruction< + TProgramAddress, + TAccountPayer, + TAccountUpgradeAuthority, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountTokenMessengerMinterProgramData, + TAccountTokenMessengerMinterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + upgradeAuthority: { + value: input.upgradeAuthority ?? null, + isWritable: false, + }, + authorityPda: { value: input.authorityPda ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + tokenMessengerMinterProgramData: { + value: input.tokenMessengerMinterProgramData ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.upgradeAuthority), + getAccountMeta(accounts.authorityPda), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.tokenMessengerMinterProgramData), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getInitializeInstructionDataEncoder().encode( + args as InitializeInstructionDataArgs + ), + } as InitializeInstruction< + TProgramAddress, + TAccountPayer, + TAccountUpgradeAuthority, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountTokenMessengerMinterProgramData, + TAccountTokenMessengerMinterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedInitializeInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + upgradeAuthority: TAccountMetas[1]; + authorityPda: TAccountMetas[2]; + tokenMessenger: TAccountMetas[3]; + tokenMinter: TAccountMetas[4]; + tokenMessengerMinterProgramData: TAccountMetas[5]; + tokenMessengerMinterProgram: TAccountMetas[6]; + systemProgram: TAccountMetas[7]; + eventAuthority: TAccountMetas[8]; + program: TAccountMetas[9]; + }; + data: InitializeInstructionData; +}; + +export function parseInitializeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedInitializeInstruction { + if (instruction.accounts.length < 10) { + // 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: { + payer: getNextAccount(), + upgradeAuthority: getNextAccount(), + authorityPda: getNextAccount(), + tokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + tokenMessengerMinterProgramData: getNextAccount(), + tokenMessengerMinterProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getInitializeInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/linkTokenPair.ts b/src/svm/clients/TokenMessengerMinter/instructions/linkTokenPair.ts new file mode 100644 index 000000000..5a514c309 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/linkTokenPair.ts @@ -0,0 +1,297 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const LINK_TOKEN_PAIR_DISCRIMINATOR = new Uint8Array([ + 68, 162, 24, 104, 125, 46, 130, 12, +]); + +export function getLinkTokenPairDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + LINK_TOKEN_PAIR_DISCRIMINATOR + ); +} + +export type LinkTokenPairInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountTokenController extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountTokenPair extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountTokenController extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountTokenController, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountTokenPair extends string + ? WritableAccount + : TAccountTokenPair, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type LinkTokenPairInstructionData = { + discriminator: ReadonlyUint8Array; + localToken: Address; + remoteDomain: number; + remoteToken: Address; +}; + +export type LinkTokenPairInstructionDataArgs = { + localToken: Address; + remoteDomain: number; + remoteToken: Address; +}; + +export function getLinkTokenPairInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['localToken', getAddressEncoder()], + ['remoteDomain', getU32Encoder()], + ['remoteToken', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: LINK_TOKEN_PAIR_DISCRIMINATOR }) + ); +} + +export function getLinkTokenPairInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['localToken', getAddressDecoder()], + ['remoteDomain', getU32Decoder()], + ['remoteToken', getAddressDecoder()], + ]); +} + +export function getLinkTokenPairInstructionDataCodec(): Codec< + LinkTokenPairInstructionDataArgs, + LinkTokenPairInstructionData +> { + return combineCodec( + getLinkTokenPairInstructionDataEncoder(), + getLinkTokenPairInstructionDataDecoder() + ); +} + +export type LinkTokenPairInput< + TAccountPayer extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountTokenPair extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + tokenPair: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + localToken: LinkTokenPairInstructionDataArgs['localToken']; + remoteDomain: LinkTokenPairInstructionDataArgs['remoteDomain']; + remoteToken: LinkTokenPairInstructionDataArgs['remoteToken']; +}; + +export function getLinkTokenPairInstruction< + TAccountPayer extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountTokenPair extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: LinkTokenPairInput< + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): LinkTokenPairInstruction< + TProgramAddress, + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + tokenPair: { value: input.tokenPair ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.tokenPair), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getLinkTokenPairInstructionDataEncoder().encode( + args as LinkTokenPairInstructionDataArgs + ), + } as LinkTokenPairInstruction< + TProgramAddress, + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedLinkTokenPairInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + tokenController: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + tokenPair: TAccountMetas[3]; + systemProgram: TAccountMetas[4]; + eventAuthority: TAccountMetas[5]; + program: TAccountMetas[6]; + }; + data: LinkTokenPairInstructionData; +}; + +export function parseLinkTokenPairInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedLinkTokenPairInstruction { + if (instruction.accounts.length < 7) { + // 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: { + payer: getNextAccount(), + tokenController: getNextAccount(), + tokenMinter: getNextAccount(), + tokenPair: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getLinkTokenPairInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/pause.ts b/src/svm/clients/TokenMessengerMinter/instructions/pause.ts new file mode 100644 index 000000000..0dad6155e --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/pause.ts @@ -0,0 +1,212 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const PAUSE_DISCRIMINATOR = new Uint8Array([ + 211, 22, 221, 251, 74, 121, 193, 47, +]); + +export function getPauseDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(PAUSE_DISCRIMINATOR); +} + +export type PauseInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountPauser extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPauser extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountPauser, + TAccountTokenMinter extends string + ? WritableAccount + : TAccountTokenMinter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type PauseInstructionData = { discriminator: ReadonlyUint8Array }; + +export type PauseInstructionDataArgs = {}; + +export function getPauseInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: PAUSE_DISCRIMINATOR }) + ); +} + +export function getPauseInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getPauseInstructionDataCodec(): Codec< + PauseInstructionDataArgs, + PauseInstructionData +> { + return combineCodec( + getPauseInstructionDataEncoder(), + getPauseInstructionDataDecoder() + ); +} + +export type PauseInput< + TAccountPauser extends string = string, + TAccountTokenMinter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pauser: TransactionSigner; + tokenMinter: Address; + eventAuthority: Address; + program: Address; +}; + +export function getPauseInstruction< + TAccountPauser extends string, + TAccountTokenMinter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: PauseInput< + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): PauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pauser: { value: input.pauser ?? null, isWritable: false }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pauser), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getPauseInstructionDataEncoder().encode({}), + } as PauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedPauseInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + pauser: TAccountMetas[0]; + tokenMinter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: PauseInstructionData; +}; + +export function parsePauseInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedPauseInstruction { + if (instruction.accounts.length < 4) { + // 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: { + pauser: getNextAccount(), + tokenMinter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getPauseInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/removeLocalToken.ts b/src/svm/clients/TokenMessengerMinter/instructions/removeLocalToken.ts new file mode 100644 index 000000000..4ad4e155e --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/removeLocalToken.ts @@ -0,0 +1,287 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const REMOVE_LOCAL_TOKEN_DISCRIMINATOR = new Uint8Array([ + 27, 43, 66, 170, 188, 44, 109, 97, +]); + +export function getRemoveLocalTokenDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REMOVE_LOCAL_TOKEN_DISCRIMINATOR + ); +} + +export type RemoveLocalTokenInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountPayee extends string | AccountMeta = string, + TAccountTokenController extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountCustodyTokenAccount extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayee extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayee, + TAccountTokenController extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountTokenController, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountCustodyTokenAccount extends string + ? WritableAccount + : TAccountCustodyTokenAccount, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type RemoveLocalTokenInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type RemoveLocalTokenInstructionDataArgs = {}; + +export function getRemoveLocalTokenInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: REMOVE_LOCAL_TOKEN_DISCRIMINATOR }) + ); +} + +export function getRemoveLocalTokenInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getRemoveLocalTokenInstructionDataCodec(): Codec< + RemoveLocalTokenInstructionDataArgs, + RemoveLocalTokenInstructionData +> { + return combineCodec( + getRemoveLocalTokenInstructionDataEncoder(), + getRemoveLocalTokenInstructionDataDecoder() + ); +} + +export type RemoveLocalTokenInput< + TAccountPayee extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountTokenProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payee: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + localToken: Address; + custodyTokenAccount: Address; + tokenProgram?: Address; + eventAuthority: Address; + program: Address; +}; + +export function getRemoveLocalTokenInstruction< + TAccountPayee extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountCustodyTokenAccount extends string, + TAccountTokenProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: RemoveLocalTokenInput< + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): RemoveLocalTokenInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getRemoveLocalTokenInstructionDataEncoder().encode({}), + } as RemoveLocalTokenInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedRemoveLocalTokenInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payee: TAccountMetas[0]; + tokenController: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + localToken: TAccountMetas[3]; + custodyTokenAccount: TAccountMetas[4]; + tokenProgram: TAccountMetas[5]; + eventAuthority: TAccountMetas[6]; + program: TAccountMetas[7]; + }; + data: RemoveLocalTokenInstructionData; +}; + +export function parseRemoveLocalTokenInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedRemoveLocalTokenInstruction { + if (instruction.accounts.length < 8) { + // 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: { + payee: getNextAccount(), + tokenController: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + custodyTokenAccount: getNextAccount(), + tokenProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getRemoveLocalTokenInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/removeRemoteTokenMessenger.ts b/src/svm/clients/TokenMessengerMinter/instructions/removeRemoteTokenMessenger.ts new file mode 100644 index 000000000..166b6ca45 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/removeRemoteTokenMessenger.ts @@ -0,0 +1,254 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const REMOVE_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ + 65, 114, 66, 85, 169, 98, 177, 146, +]); + +export function getRemoveRemoteTokenMessengerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REMOVE_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR + ); +} + +export type RemoveRemoteTokenMessengerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountPayee extends string | AccountMeta = string, + TAccountOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountRemoteTokenMessenger extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayee extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayee, + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountRemoteTokenMessenger extends string + ? WritableAccount + : TAccountRemoteTokenMessenger, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type RemoveRemoteTokenMessengerInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type RemoveRemoteTokenMessengerInstructionDataArgs = {}; + +export function getRemoveRemoteTokenMessengerInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: REMOVE_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR, + }) + ); +} + +export function getRemoveRemoteTokenMessengerInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getRemoveRemoteTokenMessengerInstructionDataCodec(): Codec< + RemoveRemoteTokenMessengerInstructionDataArgs, + RemoveRemoteTokenMessengerInstructionData +> { + return combineCodec( + getRemoveRemoteTokenMessengerInstructionDataEncoder(), + getRemoveRemoteTokenMessengerInstructionDataDecoder() + ); +} + +export type RemoveRemoteTokenMessengerInput< + TAccountPayee extends string = string, + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payee: TransactionSigner; + owner: TransactionSigner; + tokenMessenger: Address; + remoteTokenMessenger: Address; + eventAuthority: Address; + program: Address; +}; + +export function getRemoveRemoteTokenMessengerInstruction< + TAccountPayee extends string, + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: RemoveRemoteTokenMessengerInput< + TAccountPayee, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): RemoveRemoteTokenMessengerInstruction< + TProgramAddress, + TAccountPayee, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getRemoveRemoteTokenMessengerInstructionDataEncoder().encode({}), + } as RemoveRemoteTokenMessengerInstruction< + TProgramAddress, + TAccountPayee, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedRemoveRemoteTokenMessengerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payee: TAccountMetas[0]; + owner: TAccountMetas[1]; + tokenMessenger: TAccountMetas[2]; + remoteTokenMessenger: TAccountMetas[3]; + eventAuthority: TAccountMetas[4]; + program: TAccountMetas[5]; + }; + data: RemoveRemoteTokenMessengerInstructionData; +}; + +export function parseRemoveRemoteTokenMessengerInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedRemoveRemoteTokenMessengerInstruction { + if (instruction.accounts.length < 6) { + // 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: { + payee: getNextAccount(), + owner: getNextAccount(), + tokenMessenger: getNextAccount(), + remoteTokenMessenger: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getRemoveRemoteTokenMessengerInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/replaceDepositForBurn.ts b/src/svm/clients/TokenMessengerMinter/instructions/replaceDepositForBurn.ts new file mode 100644 index 000000000..13228bfa4 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/replaceDepositForBurn.ts @@ -0,0 +1,392 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const REPLACE_DEPOSIT_FOR_BURN_DISCRIMINATOR = new Uint8Array([ + 7, 27, 93, 132, 1, 80, 19, 163, +]); + +export function getReplaceDepositForBurnDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REPLACE_DEPOSIT_FOR_BURN_DISCRIMINATOR + ); +} + +export type ReplaceDepositForBurnInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountEventRentPayer extends string | AccountMeta = string, + TAccountSenderAuthorityPda extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TAccountMessageTransmitterProgram extends string | AccountMeta = + string, + TAccountTokenMessengerMinterProgram extends string | AccountMeta = + string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountEventRentPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountEventRentPayer, + TAccountSenderAuthorityPda extends string + ? ReadonlyAccount + : TAccountSenderAuthorityPda, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountMessageSentEventData extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountMessageSentEventData, + TAccountMessageTransmitterProgram extends string + ? ReadonlyAccount + : TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram extends string + ? ReadonlyAccount + : TAccountTokenMessengerMinterProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type ReplaceDepositForBurnInstructionData = { + discriminator: ReadonlyUint8Array; + originalMessage: ReadonlyUint8Array; + originalAttestation: ReadonlyUint8Array; + newDestinationCaller: Address; + newMintRecipient: Address; +}; + +export type ReplaceDepositForBurnInstructionDataArgs = { + originalMessage: ReadonlyUint8Array; + originalAttestation: ReadonlyUint8Array; + newDestinationCaller: Address; + newMintRecipient: Address; +}; + +export function getReplaceDepositForBurnInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + [ + 'originalMessage', + addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), + ], + [ + 'originalAttestation', + addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), + ], + ['newDestinationCaller', getAddressEncoder()], + ['newMintRecipient', getAddressEncoder()], + ]), + (value) => ({ + ...value, + discriminator: REPLACE_DEPOSIT_FOR_BURN_DISCRIMINATOR, + }) + ); +} + +export function getReplaceDepositForBurnInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + [ + 'originalMessage', + addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()), + ], + [ + 'originalAttestation', + addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()), + ], + ['newDestinationCaller', getAddressDecoder()], + ['newMintRecipient', getAddressDecoder()], + ]); +} + +export function getReplaceDepositForBurnInstructionDataCodec(): Codec< + ReplaceDepositForBurnInstructionDataArgs, + ReplaceDepositForBurnInstructionData +> { + return combineCodec( + getReplaceDepositForBurnInstructionDataEncoder(), + getReplaceDepositForBurnInstructionDataDecoder() + ); +} + +export type ReplaceDepositForBurnInput< + TAccountOwner extends string = string, + TAccountEventRentPayer extends string = string, + TAccountSenderAuthorityPda extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountTokenMessenger extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + eventRentPayer: TransactionSigner; + senderAuthorityPda: Address; + messageTransmitter: Address; + tokenMessenger: Address; + messageSentEventData: TransactionSigner; + messageTransmitterProgram: Address; + tokenMessengerMinterProgram: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + originalMessage: ReplaceDepositForBurnInstructionDataArgs['originalMessage']; + originalAttestation: ReplaceDepositForBurnInstructionDataArgs['originalAttestation']; + newDestinationCaller: ReplaceDepositForBurnInstructionDataArgs['newDestinationCaller']; + newMintRecipient: ReplaceDepositForBurnInstructionDataArgs['newMintRecipient']; +}; + +export function getReplaceDepositForBurnInstruction< + TAccountOwner extends string, + TAccountEventRentPayer extends string, + TAccountSenderAuthorityPda extends string, + TAccountMessageTransmitter extends string, + TAccountTokenMessenger extends string, + TAccountMessageSentEventData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: ReplaceDepositForBurnInput< + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): ReplaceDepositForBurnInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, + senderAuthorityPda: { + value: input.senderAuthorityPda ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.eventRentPayer), + getAccountMeta(accounts.senderAuthorityPda), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getReplaceDepositForBurnInstructionDataEncoder().encode( + args as ReplaceDepositForBurnInstructionDataArgs + ), + } as ReplaceDepositForBurnInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedReplaceDepositForBurnInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + eventRentPayer: TAccountMetas[1]; + senderAuthorityPda: TAccountMetas[2]; + messageTransmitter: TAccountMetas[3]; + tokenMessenger: TAccountMetas[4]; + messageSentEventData: TAccountMetas[5]; + messageTransmitterProgram: TAccountMetas[6]; + tokenMessengerMinterProgram: TAccountMetas[7]; + systemProgram: TAccountMetas[8]; + eventAuthority: TAccountMetas[9]; + program: TAccountMetas[10]; + }; + data: ReplaceDepositForBurnInstructionData; +}; + +export function parseReplaceDepositForBurnInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedReplaceDepositForBurnInstruction { + if (instruction.accounts.length < 11) { + // 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: { + owner: getNextAccount(), + eventRentPayer: getNextAccount(), + senderAuthorityPda: getNextAccount(), + messageTransmitter: getNextAccount(), + tokenMessenger: getNextAccount(), + messageSentEventData: getNextAccount(), + messageTransmitterProgram: getNextAccount(), + tokenMessengerMinterProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getReplaceDepositForBurnInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/setMaxBurnAmountPerMessage.ts b/src/svm/clients/TokenMessengerMinter/instructions/setMaxBurnAmountPerMessage.ts new file mode 100644 index 000000000..da1d11b34 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/setMaxBurnAmountPerMessage.ts @@ -0,0 +1,253 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_MAX_BURN_AMOUNT_PER_MESSAGE_DISCRIMINATOR = new Uint8Array([ + 30, 128, 145, 240, 70, 237, 109, 207, +]); + +export function getSetMaxBurnAmountPerMessageDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_MAX_BURN_AMOUNT_PER_MESSAGE_DISCRIMINATOR + ); +} + +export type SetMaxBurnAmountPerMessageInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountTokenController extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountTokenController extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountTokenController, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type SetMaxBurnAmountPerMessageInstructionData = { + discriminator: ReadonlyUint8Array; + burnLimitPerMessage: bigint; +}; + +export type SetMaxBurnAmountPerMessageInstructionDataArgs = { + burnLimitPerMessage: number | bigint; +}; + +export function getSetMaxBurnAmountPerMessageInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['burnLimitPerMessage', getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: SET_MAX_BURN_AMOUNT_PER_MESSAGE_DISCRIMINATOR, + }) + ); +} + +export function getSetMaxBurnAmountPerMessageInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['burnLimitPerMessage', getU64Decoder()], + ]); +} + +export function getSetMaxBurnAmountPerMessageInstructionDataCodec(): Codec< + SetMaxBurnAmountPerMessageInstructionDataArgs, + SetMaxBurnAmountPerMessageInstructionData +> { + return combineCodec( + getSetMaxBurnAmountPerMessageInstructionDataEncoder(), + getSetMaxBurnAmountPerMessageInstructionDataDecoder() + ); +} + +export type SetMaxBurnAmountPerMessageInput< + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + tokenController: TransactionSigner; + tokenMinter: Address; + localToken: Address; + eventAuthority: Address; + program: Address; + burnLimitPerMessage: SetMaxBurnAmountPerMessageInstructionDataArgs['burnLimitPerMessage']; +}; + +export function getSetMaxBurnAmountPerMessageInstruction< + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: SetMaxBurnAmountPerMessageInput< + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): SetMaxBurnAmountPerMessageInstruction< + TProgramAddress, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetMaxBurnAmountPerMessageInstructionDataEncoder().encode( + args as SetMaxBurnAmountPerMessageInstructionDataArgs + ), + } as SetMaxBurnAmountPerMessageInstruction< + TProgramAddress, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedSetMaxBurnAmountPerMessageInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + tokenController: TAccountMetas[0]; + tokenMinter: TAccountMetas[1]; + localToken: TAccountMetas[2]; + eventAuthority: TAccountMetas[3]; + program: TAccountMetas[4]; + }; + data: SetMaxBurnAmountPerMessageInstructionData; +}; + +export function parseSetMaxBurnAmountPerMessageInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetMaxBurnAmountPerMessageInstruction { + if (instruction.accounts.length < 5) { + // 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: { + tokenController: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getSetMaxBurnAmountPerMessageInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/setTokenController.ts b/src/svm/clients/TokenMessengerMinter/instructions/setTokenController.ts new file mode 100644 index 000000000..96eb6c061 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/setTokenController.ts @@ -0,0 +1,247 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_TOKEN_CONTROLLER_DISCRIMINATOR = new Uint8Array([ + 88, 6, 98, 10, 79, 59, 15, 24, +]); + +export function getSetTokenControllerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_TOKEN_CONTROLLER_DISCRIMINATOR + ); +} + +export type SetTokenControllerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountTokenMinter extends string + ? WritableAccount + : TAccountTokenMinter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type SetTokenControllerInstructionData = { + discriminator: ReadonlyUint8Array; + tokenController: Address; +}; + +export type SetTokenControllerInstructionDataArgs = { + tokenController: Address; +}; + +export function getSetTokenControllerInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['tokenController', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: SET_TOKEN_CONTROLLER_DISCRIMINATOR }) + ); +} + +export function getSetTokenControllerInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['tokenController', getAddressDecoder()], + ]); +} + +export function getSetTokenControllerInstructionDataCodec(): Codec< + SetTokenControllerInstructionDataArgs, + SetTokenControllerInstructionData +> { + return combineCodec( + getSetTokenControllerInstructionDataEncoder(), + getSetTokenControllerInstructionDataDecoder() + ); +} + +export type SetTokenControllerInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + tokenMinter: Address; + eventAuthority: Address; + program: Address; + tokenController: SetTokenControllerInstructionDataArgs['tokenController']; +}; + +export function getSetTokenControllerInstruction< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: SetTokenControllerInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): SetTokenControllerInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetTokenControllerInstructionDataEncoder().encode( + args as SetTokenControllerInstructionDataArgs + ), + } as SetTokenControllerInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedSetTokenControllerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + eventAuthority: TAccountMetas[3]; + program: TAccountMetas[4]; + }; + data: SetTokenControllerInstructionData; +}; + +export function parseSetTokenControllerInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetTokenControllerInstruction { + if (instruction.accounts.length < 5) { + // 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: { + owner: getNextAccount(), + tokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getSetTokenControllerInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/transferOwnership.ts b/src/svm/clients/TokenMessengerMinter/instructions/transferOwnership.ts new file mode 100644 index 000000000..3b405916c --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/transferOwnership.ts @@ -0,0 +1,229 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const TRANSFER_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ + 65, 177, 215, 73, 53, 45, 99, 47, +]); + +export function getTransferOwnershipDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + TRANSFER_OWNERSHIP_DISCRIMINATOR + ); +} + +export type TransferOwnershipInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountTokenMessenger extends string + ? WritableAccount + : TAccountTokenMessenger, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type TransferOwnershipInstructionData = { + discriminator: ReadonlyUint8Array; + newOwner: Address; +}; + +export type TransferOwnershipInstructionDataArgs = { newOwner: Address }; + +export function getTransferOwnershipInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newOwner', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: TRANSFER_OWNERSHIP_DISCRIMINATOR }) + ); +} + +export function getTransferOwnershipInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newOwner', getAddressDecoder()], + ]); +} + +export function getTransferOwnershipInstructionDataCodec(): Codec< + TransferOwnershipInstructionDataArgs, + TransferOwnershipInstructionData +> { + return combineCodec( + getTransferOwnershipInstructionDataEncoder(), + getTransferOwnershipInstructionDataDecoder() + ); +} + +export type TransferOwnershipInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + eventAuthority: Address; + program: Address; + newOwner: TransferOwnershipInstructionDataArgs['newOwner']; +}; + +export function getTransferOwnershipInstruction< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: TransferOwnershipInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getTransferOwnershipInstructionDataEncoder().encode( + args as TransferOwnershipInstructionDataArgs + ), + } as TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedTransferOwnershipInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: TransferOwnershipInstructionData; +}; + +export function parseTransferOwnershipInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedTransferOwnershipInstruction { + if (instruction.accounts.length < 4) { + // 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: { + owner: getNextAccount(), + tokenMessenger: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getTransferOwnershipInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/unlinkTokenPair.ts b/src/svm/clients/TokenMessengerMinter/instructions/unlinkTokenPair.ts new file mode 100644 index 000000000..09d89c457 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/unlinkTokenPair.ts @@ -0,0 +1,249 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UNLINK_TOKEN_PAIR_DISCRIMINATOR = new Uint8Array([ + 52, 198, 100, 114, 104, 174, 85, 58, +]); + +export function getUnlinkTokenPairDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UNLINK_TOKEN_PAIR_DISCRIMINATOR + ); +} + +export type UnlinkTokenPairInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountPayee extends string | AccountMeta = string, + TAccountTokenController extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountTokenPair extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayee extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayee, + TAccountTokenController extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountTokenController, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountTokenPair extends string + ? WritableAccount + : TAccountTokenPair, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UnlinkTokenPairInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type UnlinkTokenPairInstructionDataArgs = {}; + +export function getUnlinkTokenPairInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: UNLINK_TOKEN_PAIR_DISCRIMINATOR }) + ); +} + +export function getUnlinkTokenPairInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getUnlinkTokenPairInstructionDataCodec(): Codec< + UnlinkTokenPairInstructionDataArgs, + UnlinkTokenPairInstructionData +> { + return combineCodec( + getUnlinkTokenPairInstructionDataEncoder(), + getUnlinkTokenPairInstructionDataDecoder() + ); +} + +export type UnlinkTokenPairInput< + TAccountPayee extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountTokenPair extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payee: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + tokenPair: Address; + eventAuthority: Address; + program: Address; +}; + +export function getUnlinkTokenPairInstruction< + TAccountPayee extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountTokenPair extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: UnlinkTokenPairInput< + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UnlinkTokenPairInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + tokenPair: { value: input.tokenPair ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.tokenPair), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUnlinkTokenPairInstructionDataEncoder().encode({}), + } as UnlinkTokenPairInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUnlinkTokenPairInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payee: TAccountMetas[0]; + tokenController: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + tokenPair: TAccountMetas[3]; + eventAuthority: TAccountMetas[4]; + program: TAccountMetas[5]; + }; + data: UnlinkTokenPairInstructionData; +}; + +export function parseUnlinkTokenPairInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUnlinkTokenPairInstruction { + if (instruction.accounts.length < 6) { + // 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: { + payee: getNextAccount(), + tokenController: getNextAccount(), + tokenMinter: getNextAccount(), + tokenPair: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUnlinkTokenPairInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/unpause.ts b/src/svm/clients/TokenMessengerMinter/instructions/unpause.ts new file mode 100644 index 000000000..93d7696be --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/unpause.ts @@ -0,0 +1,212 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UNPAUSE_DISCRIMINATOR = new Uint8Array([ + 169, 144, 4, 38, 10, 141, 188, 255, +]); + +export function getUnpauseDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(UNPAUSE_DISCRIMINATOR); +} + +export type UnpauseInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountPauser extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPauser extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountPauser, + TAccountTokenMinter extends string + ? WritableAccount + : TAccountTokenMinter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UnpauseInstructionData = { discriminator: ReadonlyUint8Array }; + +export type UnpauseInstructionDataArgs = {}; + +export function getUnpauseInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: UNPAUSE_DISCRIMINATOR }) + ); +} + +export function getUnpauseInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getUnpauseInstructionDataCodec(): Codec< + UnpauseInstructionDataArgs, + UnpauseInstructionData +> { + return combineCodec( + getUnpauseInstructionDataEncoder(), + getUnpauseInstructionDataDecoder() + ); +} + +export type UnpauseInput< + TAccountPauser extends string = string, + TAccountTokenMinter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pauser: TransactionSigner; + tokenMinter: Address; + eventAuthority: Address; + program: Address; +}; + +export function getUnpauseInstruction< + TAccountPauser extends string, + TAccountTokenMinter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: UnpauseInput< + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UnpauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pauser: { value: input.pauser ?? null, isWritable: false }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pauser), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUnpauseInstructionDataEncoder().encode({}), + } as UnpauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUnpauseInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + pauser: TAccountMetas[0]; + tokenMinter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: UnpauseInstructionData; +}; + +export function parseUnpauseInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUnpauseInstruction { + if (instruction.accounts.length < 4) { + // 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: { + pauser: getNextAccount(), + tokenMinter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUnpauseInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/updatePauser.ts b/src/svm/clients/TokenMessengerMinter/instructions/updatePauser.ts new file mode 100644 index 000000000..2c2cb713f --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/instructions/updatePauser.ts @@ -0,0 +1,243 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UPDATE_PAUSER_DISCRIMINATOR = new Uint8Array([ + 140, 171, 211, 132, 57, 201, 16, 254, +]); + +export function getUpdatePauserDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_PAUSER_DISCRIMINATOR + ); +} + +export type UpdatePauserInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountTokenMinter extends string + ? WritableAccount + : TAccountTokenMinter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UpdatePauserInstructionData = { + discriminator: ReadonlyUint8Array; + newPauser: Address; +}; + +export type UpdatePauserInstructionDataArgs = { newPauser: Address }; + +export function getUpdatePauserInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newPauser', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: UPDATE_PAUSER_DISCRIMINATOR }) + ); +} + +export function getUpdatePauserInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newPauser', getAddressDecoder()], + ]); +} + +export function getUpdatePauserInstructionDataCodec(): Codec< + UpdatePauserInstructionDataArgs, + UpdatePauserInstructionData +> { + return combineCodec( + getUpdatePauserInstructionDataEncoder(), + getUpdatePauserInstructionDataDecoder() + ); +} + +export type UpdatePauserInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + tokenMinter: Address; + eventAuthority: Address; + program: Address; + newPauser: UpdatePauserInstructionDataArgs['newPauser']; +}; + +export function getUpdatePauserInstruction< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, +>( + input: UpdatePauserInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UpdatePauserInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUpdatePauserInstructionDataEncoder().encode( + args as UpdatePauserInstructionDataArgs + ), + } as UpdatePauserInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUpdatePauserInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + eventAuthority: TAccountMetas[3]; + program: TAccountMetas[4]; + }; + data: UpdatePauserInstructionData; +}; + +export function parseUpdatePauserInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUpdatePauserInstruction { + if (instruction.accounts.length < 5) { + // 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: { + owner: getNextAccount(), + tokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUpdatePauserInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinter/programs/index.ts b/src/svm/clients/TokenMessengerMinter/programs/index.ts new file mode 100644 index 000000000..1e005644b --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/programs/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 './tokenMessengerMinter'; diff --git a/src/svm/clients/TokenMessengerMinter/programs/tokenMessengerMinter.ts b/src/svm/clients/TokenMessengerMinter/programs/tokenMessengerMinter.ts new file mode 100644 index 000000000..27e6dbad7 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/programs/tokenMessengerMinter.ts @@ -0,0 +1,412 @@ +/** + * 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/kit'; +import { + type ParsedAcceptOwnershipInstruction, + type ParsedAddLocalTokenInstruction, + type ParsedAddRemoteTokenMessengerInstruction, + type ParsedBurnTokenCustodyInstruction, + type ParsedDepositForBurnInstruction, + type ParsedDepositForBurnWithCallerInstruction, + type ParsedHandleReceiveMessageInstruction, + type ParsedInitializeInstruction, + type ParsedLinkTokenPairInstruction, + type ParsedPauseInstruction, + type ParsedRemoveLocalTokenInstruction, + type ParsedRemoveRemoteTokenMessengerInstruction, + type ParsedReplaceDepositForBurnInstruction, + type ParsedSetMaxBurnAmountPerMessageInstruction, + type ParsedSetTokenControllerInstruction, + type ParsedTransferOwnershipInstruction, + type ParsedUnlinkTokenPairInstruction, + type ParsedUnpauseInstruction, + type ParsedUpdatePauserInstruction, +} from '../instructions'; + +export const TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS = + 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3' as Address<'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3'>; + +export enum TokenMessengerMinterAccount { + TokenMessenger, + RemoteTokenMessenger, + TokenMinter, + TokenPair, + LocalToken, +} + +export function identifyTokenMessengerMinterAccount( + account: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): TokenMessengerMinterAccount { + const data = 'data' in account ? account.data : account; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([162, 4, 242, 52, 147, 243, 221, 96]) + ), + 0 + ) + ) { + return TokenMessengerMinterAccount.TokenMessenger; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([105, 115, 174, 34, 95, 233, 138, 252]) + ), + 0 + ) + ) { + return TokenMessengerMinterAccount.RemoteTokenMessenger; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([122, 133, 84, 63, 57, 159, 171, 206]) + ), + 0 + ) + ) { + return TokenMessengerMinterAccount.TokenMinter; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([17, 214, 45, 176, 229, 149, 197, 71]) + ), + 0 + ) + ) { + return TokenMessengerMinterAccount.TokenPair; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([159, 131, 58, 170, 193, 84, 128, 182]) + ), + 0 + ) + ) { + return TokenMessengerMinterAccount.LocalToken; + } + throw new Error( + 'The provided account could not be identified as a tokenMessengerMinter account.' + ); +} + +export enum TokenMessengerMinterInstruction { + Initialize, + TransferOwnership, + AcceptOwnership, + AddRemoteTokenMessenger, + RemoveRemoteTokenMessenger, + DepositForBurn, + DepositForBurnWithCaller, + ReplaceDepositForBurn, + HandleReceiveMessage, + SetTokenController, + Pause, + Unpause, + UpdatePauser, + SetMaxBurnAmountPerMessage, + AddLocalToken, + RemoveLocalToken, + LinkTokenPair, + UnlinkTokenPair, + BurnTokenCustody, +} + +export function identifyTokenMessengerMinterInstruction( + instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): TokenMessengerMinterInstruction { + 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 TokenMessengerMinterInstruction.Initialize; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.TransferOwnership; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([172, 23, 43, 13, 238, 213, 85, 150]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.AcceptOwnership; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([12, 149, 172, 165, 111, 202, 24, 33]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.AddRemoteTokenMessenger; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([65, 114, 66, 85, 169, 98, 177, 146]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.RemoveRemoteTokenMessenger; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([215, 60, 61, 46, 114, 55, 128, 176]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.DepositForBurn; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([167, 222, 19, 114, 85, 21, 14, 118]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.DepositForBurnWithCaller; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([7, 27, 93, 132, 1, 80, 19, 163]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.ReplaceDepositForBurn; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([133, 102, 1, 180, 145, 11, 138, 180]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.HandleReceiveMessage; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([88, 6, 98, 10, 79, 59, 15, 24]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.SetTokenController; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([211, 22, 221, 251, 74, 121, 193, 47]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.Pause; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([169, 144, 4, 38, 10, 141, 188, 255]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.Unpause; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([140, 171, 211, 132, 57, 201, 16, 254]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.UpdatePauser; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([30, 128, 145, 240, 70, 237, 109, 207]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.SetMaxBurnAmountPerMessage; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([213, 199, 205, 18, 98, 124, 73, 198]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.AddLocalToken; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([27, 43, 66, 170, 188, 44, 109, 97]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.RemoveLocalToken; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([68, 162, 24, 104, 125, 46, 130, 12]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.LinkTokenPair; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([52, 198, 100, 114, 104, 174, 85, 58]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.UnlinkTokenPair; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([233, 136, 180, 175, 112, 41, 62, 71]) + ), + 0 + ) + ) { + return TokenMessengerMinterInstruction.BurnTokenCustody; + } + throw new Error( + 'The provided instruction could not be identified as a tokenMessengerMinter instruction.' + ); +} + +export type ParsedTokenMessengerMinterInstruction< + TProgram extends string = 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3', +> = + | ({ + instructionType: TokenMessengerMinterInstruction.Initialize; + } & ParsedInitializeInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.TransferOwnership; + } & ParsedTransferOwnershipInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.AcceptOwnership; + } & ParsedAcceptOwnershipInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.AddRemoteTokenMessenger; + } & ParsedAddRemoteTokenMessengerInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.RemoveRemoteTokenMessenger; + } & ParsedRemoveRemoteTokenMessengerInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.DepositForBurn; + } & ParsedDepositForBurnInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.DepositForBurnWithCaller; + } & ParsedDepositForBurnWithCallerInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.ReplaceDepositForBurn; + } & ParsedReplaceDepositForBurnInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.HandleReceiveMessage; + } & ParsedHandleReceiveMessageInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.SetTokenController; + } & ParsedSetTokenControllerInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.Pause; + } & ParsedPauseInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.Unpause; + } & ParsedUnpauseInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.UpdatePauser; + } & ParsedUpdatePauserInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.SetMaxBurnAmountPerMessage; + } & ParsedSetMaxBurnAmountPerMessageInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.AddLocalToken; + } & ParsedAddLocalTokenInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.RemoveLocalToken; + } & ParsedRemoveLocalTokenInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.LinkTokenPair; + } & ParsedLinkTokenPairInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.UnlinkTokenPair; + } & ParsedUnlinkTokenPairInstruction) + | ({ + instructionType: TokenMessengerMinterInstruction.BurnTokenCustody; + } & ParsedBurnTokenCustodyInstruction); diff --git a/src/svm/clients/TokenMessengerMinter/shared/index.ts b/src/svm/clients/TokenMessengerMinter/shared/index.ts new file mode 100644 index 000000000..7ebc26514 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/shared/index.ts @@ -0,0 +1,164 @@ +/** + * 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 { + AccountRole, + isProgramDerivedAddress, + isTransactionSigner as kitIsTransactionSigner, + type AccountMeta, + type AccountSignerMeta, + type Address, + type ProgramDerivedAddress, + type TransactionSigner, + upgradeRoleToSigner, +} from '@solana/kit'; + +/** + * Asserts that the given value is not null or undefined. + * @internal + */ +export function expectSome(value: T | null | undefined): T { + if (value == null) { + throw new Error('Expected a value but received null or undefined.'); + } + return value; +} + +/** + * Asserts that the given value is a PublicKey. + * @internal + */ +export function expectAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): Address { + if (!value) { + throw new Error('Expected a Address.'); + } + if (typeof value === 'object' && 'address' in value) { + return value.address; + } + if (Array.isArray(value)) { + return value[0]; + } + return value as Address; +} + +/** + * Asserts that the given value is a PDA. + * @internal + */ +export function expectProgramDerivedAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): ProgramDerivedAddress { + if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { + throw new Error('Expected a ProgramDerivedAddress.'); + } + return value; +} + +/** + * Asserts that the given value is a TransactionSigner. + * @internal + */ +export function expectTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): TransactionSigner { + if (!value || !isTransactionSigner(value)) { + throw new Error('Expected a TransactionSigner.'); + } + return value; +} + +/** + * Defines an instruction account to resolve. + * @internal + */ +export type ResolvedAccount< + T extends string = string, + U extends + | Address + | ProgramDerivedAddress + | TransactionSigner + | null = + | Address + | ProgramDerivedAddress + | TransactionSigner + | null, +> = { + isWritable: boolean; + value: U; +}; + +/** + * Defines an instruction that stores additional bytes on-chain. + * @internal + */ +export type InstructionWithByteDelta = { + byteDelta: number; +}; + +/** + * Get account metas and signers from resolved accounts. + * @internal + */ +export function getAccountMetaFactory( + programAddress: Address, + optionalAccountStrategy: 'omitted' | 'programId' +) { + return ( + account: ResolvedAccount + ): AccountMeta | AccountSignerMeta | undefined => { + if (!account.value) { + if (optionalAccountStrategy === 'omitted') return; + return Object.freeze({ + address: programAddress, + role: AccountRole.READONLY, + }); + } + + const writableRole = account.isWritable + ? AccountRole.WRITABLE + : AccountRole.READONLY; + return Object.freeze({ + address: expectAddress(account.value), + role: isTransactionSigner(account.value) + ? upgradeRoleToSigner(writableRole) + : writableRole, + ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), + }); + }; +} + +export function isTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner +): value is TransactionSigner { + return ( + !!value && + typeof value === 'object' && + 'address' in value && + kitIsTransactionSigner(value) + ); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/depositForBurn.ts b/src/svm/clients/TokenMessengerMinter/types/depositForBurn.ts new file mode 100644 index 000000000..63ac39add --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/depositForBurn.ts @@ -0,0 +1,78 @@ +/** + * 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, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type DepositForBurn = { + nonce: bigint; + burnToken: Address; + amount: bigint; + depositor: Address; + mintRecipient: Address; + destinationDomain: number; + destinationTokenMessenger: Address; + destinationCaller: Address; +}; + +export type DepositForBurnArgs = { + nonce: number | bigint; + burnToken: Address; + amount: number | bigint; + depositor: Address; + mintRecipient: Address; + destinationDomain: number; + destinationTokenMessenger: Address; + destinationCaller: Address; +}; + +export function getDepositForBurnEncoder(): Encoder { + return getStructEncoder([ + ['nonce', getU64Encoder()], + ['burnToken', getAddressEncoder()], + ['amount', getU64Encoder()], + ['depositor', getAddressEncoder()], + ['mintRecipient', getAddressEncoder()], + ['destinationDomain', getU32Encoder()], + ['destinationTokenMessenger', getAddressEncoder()], + ['destinationCaller', getAddressEncoder()], + ]); +} + +export function getDepositForBurnDecoder(): Decoder { + return getStructDecoder([ + ['nonce', getU64Decoder()], + ['burnToken', getAddressDecoder()], + ['amount', getU64Decoder()], + ['depositor', getAddressDecoder()], + ['mintRecipient', getAddressDecoder()], + ['destinationDomain', getU32Decoder()], + ['destinationTokenMessenger', getAddressDecoder()], + ['destinationCaller', getAddressDecoder()], + ]); +} + +export function getDepositForBurnCodec(): Codec< + DepositForBurnArgs, + DepositForBurn +> { + return combineCodec(getDepositForBurnEncoder(), getDepositForBurnDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/index.ts b/src/svm/clients/TokenMessengerMinter/types/index.ts new file mode 100644 index 000000000..65e320f19 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/index.ts @@ -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. + * + * @see https://github.com/codama-idl/codama + */ + +export * from './depositForBurn'; +export * from './localTokenAdded'; +export * from './localTokenRemoved'; +export * from './mintAndWithdraw'; +export * from './ownershipTransferred'; +export * from './ownershipTransferStarted'; +export * from './pause'; +export * from './pauserChanged'; +export * from './remoteTokenMessengerAdded'; +export * from './remoteTokenMessengerRemoved'; +export * from './setBurnLimitPerMessage'; +export * from './setTokenController'; +export * from './tokenCustodyBurned'; +export * from './tokenMinterError'; +export * from './tokenPairLinked'; +export * from './tokenPairUnlinked'; +export * from './unpause'; diff --git a/src/svm/clients/TokenMessengerMinter/types/localTokenAdded.ts b/src/svm/clients/TokenMessengerMinter/types/localTokenAdded.ts new file mode 100644 index 000000000..f74e5a7e5 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/localTokenAdded.ts @@ -0,0 +1,44 @@ +/** + * 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/kit'; + +export type LocalTokenAdded = { custody: Address; mint: Address }; + +export type LocalTokenAddedArgs = LocalTokenAdded; + +export function getLocalTokenAddedEncoder(): Encoder { + return getStructEncoder([ + ['custody', getAddressEncoder()], + ['mint', getAddressEncoder()], + ]); +} + +export function getLocalTokenAddedDecoder(): Decoder { + return getStructDecoder([ + ['custody', getAddressDecoder()], + ['mint', getAddressDecoder()], + ]); +} + +export function getLocalTokenAddedCodec(): Codec< + LocalTokenAddedArgs, + LocalTokenAdded +> { + return combineCodec(getLocalTokenAddedEncoder(), getLocalTokenAddedDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/localTokenRemoved.ts b/src/svm/clients/TokenMessengerMinter/types/localTokenRemoved.ts new file mode 100644 index 000000000..813080526 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/localTokenRemoved.ts @@ -0,0 +1,47 @@ +/** + * 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/kit'; + +export type LocalTokenRemoved = { custody: Address; mint: Address }; + +export type LocalTokenRemovedArgs = LocalTokenRemoved; + +export function getLocalTokenRemovedEncoder(): Encoder { + return getStructEncoder([ + ['custody', getAddressEncoder()], + ['mint', getAddressEncoder()], + ]); +} + +export function getLocalTokenRemovedDecoder(): Decoder { + return getStructDecoder([ + ['custody', getAddressDecoder()], + ['mint', getAddressDecoder()], + ]); +} + +export function getLocalTokenRemovedCodec(): Codec< + LocalTokenRemovedArgs, + LocalTokenRemoved +> { + return combineCodec( + getLocalTokenRemovedEncoder(), + getLocalTokenRemovedDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/mintAndWithdraw.ts b/src/svm/clients/TokenMessengerMinter/types/mintAndWithdraw.ts new file mode 100644 index 000000000..b98ae340d --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/mintAndWithdraw.ts @@ -0,0 +1,56 @@ +/** + * 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, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type MintAndWithdraw = { + mintRecipient: Address; + amount: bigint; + mintToken: Address; +}; + +export type MintAndWithdrawArgs = { + mintRecipient: Address; + amount: number | bigint; + mintToken: Address; +}; + +export function getMintAndWithdrawEncoder(): Encoder { + return getStructEncoder([ + ['mintRecipient', getAddressEncoder()], + ['amount', getU64Encoder()], + ['mintToken', getAddressEncoder()], + ]); +} + +export function getMintAndWithdrawDecoder(): Decoder { + return getStructDecoder([ + ['mintRecipient', getAddressDecoder()], + ['amount', getU64Decoder()], + ['mintToken', getAddressDecoder()], + ]); +} + +export function getMintAndWithdrawCodec(): Codec< + MintAndWithdrawArgs, + MintAndWithdraw +> { + return combineCodec(getMintAndWithdrawEncoder(), getMintAndWithdrawDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/ownershipTransferStarted.ts b/src/svm/clients/TokenMessengerMinter/types/ownershipTransferStarted.ts new file mode 100644 index 000000000..e170a569a --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/ownershipTransferStarted.ts @@ -0,0 +1,50 @@ +/** + * 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/kit'; + +export type OwnershipTransferStarted = { + previousOwner: Address; + newOwner: Address; +}; + +export type OwnershipTransferStartedArgs = OwnershipTransferStarted; + +export function getOwnershipTransferStartedEncoder(): Encoder { + return getStructEncoder([ + ['previousOwner', getAddressEncoder()], + ['newOwner', getAddressEncoder()], + ]); +} + +export function getOwnershipTransferStartedDecoder(): Decoder { + return getStructDecoder([ + ['previousOwner', getAddressDecoder()], + ['newOwner', getAddressDecoder()], + ]); +} + +export function getOwnershipTransferStartedCodec(): Codec< + OwnershipTransferStartedArgs, + OwnershipTransferStarted +> { + return combineCodec( + getOwnershipTransferStartedEncoder(), + getOwnershipTransferStartedDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/ownershipTransferred.ts b/src/svm/clients/TokenMessengerMinter/types/ownershipTransferred.ts new file mode 100644 index 000000000..40f21c661 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/ownershipTransferred.ts @@ -0,0 +1,50 @@ +/** + * 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/kit'; + +export type OwnershipTransferred = { + previousOwner: Address; + newOwner: Address; +}; + +export type OwnershipTransferredArgs = OwnershipTransferred; + +export function getOwnershipTransferredEncoder(): Encoder { + return getStructEncoder([ + ['previousOwner', getAddressEncoder()], + ['newOwner', getAddressEncoder()], + ]); +} + +export function getOwnershipTransferredDecoder(): Decoder { + return getStructDecoder([ + ['previousOwner', getAddressDecoder()], + ['newOwner', getAddressDecoder()], + ]); +} + +export function getOwnershipTransferredCodec(): Codec< + OwnershipTransferredArgs, + OwnershipTransferred +> { + return combineCodec( + getOwnershipTransferredEncoder(), + getOwnershipTransferredDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/pause.ts b/src/svm/clients/TokenMessengerMinter/types/pause.ts new file mode 100644 index 000000000..f1f423325 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/pause.ts @@ -0,0 +1,32 @@ +/** + * 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, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type Pause = {}; + +export type PauseArgs = Pause; + +export function getPauseEncoder(): Encoder { + return getStructEncoder([]); +} + +export function getPauseDecoder(): Decoder { + return getStructDecoder([]); +} + +export function getPauseCodec(): Codec { + return combineCodec(getPauseEncoder(), getPauseDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/pauserChanged.ts b/src/svm/clients/TokenMessengerMinter/types/pauserChanged.ts new file mode 100644 index 000000000..57d7433da --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/pauserChanged.ts @@ -0,0 +1,38 @@ +/** + * 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/kit'; + +export type PauserChanged = { newAddress: Address }; + +export type PauserChangedArgs = PauserChanged; + +export function getPauserChangedEncoder(): Encoder { + return getStructEncoder([['newAddress', getAddressEncoder()]]); +} + +export function getPauserChangedDecoder(): Decoder { + return getStructDecoder([['newAddress', getAddressDecoder()]]); +} + +export function getPauserChangedCodec(): Codec< + PauserChangedArgs, + PauserChanged +> { + return combineCodec(getPauserChangedEncoder(), getPauserChangedDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerAdded.ts b/src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerAdded.ts new file mode 100644 index 000000000..f2586db0b --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerAdded.ts @@ -0,0 +1,52 @@ +/** + * 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, + getU32Decoder, + getU32Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type RemoteTokenMessengerAdded = { + domain: number; + tokenMessenger: Address; +}; + +export type RemoteTokenMessengerAddedArgs = RemoteTokenMessengerAdded; + +export function getRemoteTokenMessengerAddedEncoder(): Encoder { + return getStructEncoder([ + ['domain', getU32Encoder()], + ['tokenMessenger', getAddressEncoder()], + ]); +} + +export function getRemoteTokenMessengerAddedDecoder(): Decoder { + return getStructDecoder([ + ['domain', getU32Decoder()], + ['tokenMessenger', getAddressDecoder()], + ]); +} + +export function getRemoteTokenMessengerAddedCodec(): Codec< + RemoteTokenMessengerAddedArgs, + RemoteTokenMessengerAdded +> { + return combineCodec( + getRemoteTokenMessengerAddedEncoder(), + getRemoteTokenMessengerAddedDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerRemoved.ts b/src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerRemoved.ts new file mode 100644 index 000000000..290c643bc --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerRemoved.ts @@ -0,0 +1,52 @@ +/** + * 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, + getU32Decoder, + getU32Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type RemoteTokenMessengerRemoved = { + domain: number; + tokenMessenger: Address; +}; + +export type RemoteTokenMessengerRemovedArgs = RemoteTokenMessengerRemoved; + +export function getRemoteTokenMessengerRemovedEncoder(): Encoder { + return getStructEncoder([ + ['domain', getU32Encoder()], + ['tokenMessenger', getAddressEncoder()], + ]); +} + +export function getRemoteTokenMessengerRemovedDecoder(): Decoder { + return getStructDecoder([ + ['domain', getU32Decoder()], + ['tokenMessenger', getAddressDecoder()], + ]); +} + +export function getRemoteTokenMessengerRemovedCodec(): Codec< + RemoteTokenMessengerRemovedArgs, + RemoteTokenMessengerRemoved +> { + return combineCodec( + getRemoteTokenMessengerRemovedEncoder(), + getRemoteTokenMessengerRemovedDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/setBurnLimitPerMessage.ts b/src/svm/clients/TokenMessengerMinter/types/setBurnLimitPerMessage.ts new file mode 100644 index 000000000..8c28725c2 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/setBurnLimitPerMessage.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, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type SetBurnLimitPerMessage = { + token: Address; + burnLimitPerMessage: bigint; +}; + +export type SetBurnLimitPerMessageArgs = { + token: Address; + burnLimitPerMessage: number | bigint; +}; + +export function getSetBurnLimitPerMessageEncoder(): Encoder { + return getStructEncoder([ + ['token', getAddressEncoder()], + ['burnLimitPerMessage', getU64Encoder()], + ]); +} + +export function getSetBurnLimitPerMessageDecoder(): Decoder { + return getStructDecoder([ + ['token', getAddressDecoder()], + ['burnLimitPerMessage', getU64Decoder()], + ]); +} + +export function getSetBurnLimitPerMessageCodec(): Codec< + SetBurnLimitPerMessageArgs, + SetBurnLimitPerMessage +> { + return combineCodec( + getSetBurnLimitPerMessageEncoder(), + getSetBurnLimitPerMessageDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/setTokenController.ts b/src/svm/clients/TokenMessengerMinter/types/setTokenController.ts new file mode 100644 index 000000000..3b6c01571 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/setTokenController.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/kit'; + +export type SetTokenController = { tokenController: Address }; + +export type SetTokenControllerArgs = SetTokenController; + +export function getSetTokenControllerEncoder(): Encoder { + return getStructEncoder([['tokenController', getAddressEncoder()]]); +} + +export function getSetTokenControllerDecoder(): Decoder { + return getStructDecoder([['tokenController', getAddressDecoder()]]); +} + +export function getSetTokenControllerCodec(): Codec< + SetTokenControllerArgs, + SetTokenController +> { + return combineCodec( + getSetTokenControllerEncoder(), + getSetTokenControllerDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/tokenCustodyBurned.ts b/src/svm/clients/TokenMessengerMinter/types/tokenCustodyBurned.ts new file mode 100644 index 000000000..4b90fc0d7 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/tokenCustodyBurned.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, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type TokenCustodyBurned = { + custodyTokenAccount: Address; + amount: bigint; +}; + +export type TokenCustodyBurnedArgs = { + custodyTokenAccount: Address; + amount: number | bigint; +}; + +export function getTokenCustodyBurnedEncoder(): Encoder { + return getStructEncoder([ + ['custodyTokenAccount', getAddressEncoder()], + ['amount', getU64Encoder()], + ]); +} + +export function getTokenCustodyBurnedDecoder(): Decoder { + return getStructDecoder([ + ['custodyTokenAccount', getAddressDecoder()], + ['amount', getU64Decoder()], + ]); +} + +export function getTokenCustodyBurnedCodec(): Codec< + TokenCustodyBurnedArgs, + TokenCustodyBurned +> { + return combineCodec( + getTokenCustodyBurnedEncoder(), + getTokenCustodyBurnedDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/tokenMinterError.ts b/src/svm/clients/TokenMessengerMinter/types/tokenMinterError.ts new file mode 100644 index 000000000..298c968de --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/tokenMinterError.ts @@ -0,0 +1,48 @@ +/** + * 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, + getEnumDecoder, + getEnumEncoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export enum TokenMinterError { + InvalidAuthority, + InvalidTokenMinterState, + ProgramPaused, + InvalidTokenPairState, + InvalidLocalTokenState, + InvalidPauser, + InvalidTokenController, + BurnAmountExceeded, + InvalidAmount, +} + +export type TokenMinterErrorArgs = TokenMinterError; + +export function getTokenMinterErrorEncoder(): Encoder { + return getEnumEncoder(TokenMinterError); +} + +export function getTokenMinterErrorDecoder(): Decoder { + return getEnumDecoder(TokenMinterError); +} + +export function getTokenMinterErrorCodec(): Codec< + TokenMinterErrorArgs, + TokenMinterError +> { + return combineCodec( + getTokenMinterErrorEncoder(), + getTokenMinterErrorDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/tokenPairLinked.ts b/src/svm/clients/TokenMessengerMinter/types/tokenPairLinked.ts new file mode 100644 index 000000000..3d4e2027d --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/tokenPairLinked.ts @@ -0,0 +1,52 @@ +/** + * 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, + getU32Decoder, + getU32Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type TokenPairLinked = { + localToken: Address; + remoteDomain: number; + remoteToken: Address; +}; + +export type TokenPairLinkedArgs = TokenPairLinked; + +export function getTokenPairLinkedEncoder(): Encoder { + return getStructEncoder([ + ['localToken', getAddressEncoder()], + ['remoteDomain', getU32Encoder()], + ['remoteToken', getAddressEncoder()], + ]); +} + +export function getTokenPairLinkedDecoder(): Decoder { + return getStructDecoder([ + ['localToken', getAddressDecoder()], + ['remoteDomain', getU32Decoder()], + ['remoteToken', getAddressDecoder()], + ]); +} + +export function getTokenPairLinkedCodec(): Codec< + TokenPairLinkedArgs, + TokenPairLinked +> { + return combineCodec(getTokenPairLinkedEncoder(), getTokenPairLinkedDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/tokenPairUnlinked.ts b/src/svm/clients/TokenMessengerMinter/types/tokenPairUnlinked.ts new file mode 100644 index 000000000..714376fdd --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/tokenPairUnlinked.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, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type TokenPairUnlinked = { + localToken: Address; + remoteDomain: number; + remoteToken: Address; +}; + +export type TokenPairUnlinkedArgs = TokenPairUnlinked; + +export function getTokenPairUnlinkedEncoder(): Encoder { + return getStructEncoder([ + ['localToken', getAddressEncoder()], + ['remoteDomain', getU32Encoder()], + ['remoteToken', getAddressEncoder()], + ]); +} + +export function getTokenPairUnlinkedDecoder(): Decoder { + return getStructDecoder([ + ['localToken', getAddressDecoder()], + ['remoteDomain', getU32Decoder()], + ['remoteToken', getAddressDecoder()], + ]); +} + +export function getTokenPairUnlinkedCodec(): Codec< + TokenPairUnlinkedArgs, + TokenPairUnlinked +> { + return combineCodec( + getTokenPairUnlinkedEncoder(), + getTokenPairUnlinkedDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinter/types/unpause.ts b/src/svm/clients/TokenMessengerMinter/types/unpause.ts new file mode 100644 index 000000000..4fdc009ef --- /dev/null +++ b/src/svm/clients/TokenMessengerMinter/types/unpause.ts @@ -0,0 +1,32 @@ +/** + * 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, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type Unpause = {}; + +export type UnpauseArgs = Unpause; + +export function getUnpauseEncoder(): Encoder { + return getStructEncoder([]); +} + +export function getUnpauseDecoder(): Decoder { + return getStructDecoder([]); +} + +export function getUnpauseCodec(): Codec { + return combineCodec(getUnpauseEncoder(), getUnpauseDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/denylistedAccount.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/denylistedAccount.ts new file mode 100644 index 000000000..54b87bfa7 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/accounts/denylistedAccount.ts @@ -0,0 +1,147 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const DENYLISTED_ACCOUNT_DISCRIMINATOR = new Uint8Array([ + 186, 58, 212, 239, 102, 131, 157, 146, +]); + +export function getDenylistedAccountDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DENYLISTED_ACCOUNT_DISCRIMINATOR + ); +} + +export type DenylistedAccount = { + discriminator: ReadonlyUint8Array; + account: Address; +}; + +export type DenylistedAccountArgs = { account: Address }; + +export function getDenylistedAccountEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['account', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: DENYLISTED_ACCOUNT_DISCRIMINATOR }) + ); +} + +export function getDenylistedAccountDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['account', getAddressDecoder()], + ]); +} + +export function getDenylistedAccountCodec(): Codec< + DenylistedAccountArgs, + DenylistedAccount +> { + return combineCodec( + getDenylistedAccountEncoder(), + getDenylistedAccountDecoder() + ); +} + +export function decodeDenylistedAccount( + encodedAccount: EncodedAccount +): Account; +export function decodeDenylistedAccount( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeDenylistedAccount( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getDenylistedAccountDecoder() + ); +} + +export async function fetchDenylistedAccount( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeDenylistedAccount(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeDenylistedAccount< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeDenylistedAccount(maybeAccount); +} + +export async function fetchAllDenylistedAccount( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeDenylistedAccount( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeDenylistedAccount( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeDenylistedAccount(maybeAccount) + ); +} + +export function getDenylistedAccountSize(): number { + return 40; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/index.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/index.ts new file mode 100644 index 000000000..5fc20562f --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/accounts/index.ts @@ -0,0 +1,15 @@ +/** + * 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 './denylistedAccount'; +export * from './localToken'; +export * from './messageTransmitter'; +export * from './remoteTokenMessenger'; +export * from './tokenMessenger'; +export * from './tokenMinter'; +export * from './tokenPair'; diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/localToken.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/localToken.ts new file mode 100644 index 000000000..9db5966c7 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/accounts/localToken.ts @@ -0,0 +1,169 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU128Decoder, + getU128Encoder, + getU64Decoder, + getU64Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const LOCAL_TOKEN_DISCRIMINATOR = new Uint8Array([ + 159, 131, 58, 170, 193, 84, 128, 182, +]); + +export function getLocalTokenDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(LOCAL_TOKEN_DISCRIMINATOR); +} + +export type LocalToken = { + discriminator: ReadonlyUint8Array; + custody: Address; + mint: Address; + burnLimitPerMessage: bigint; + messagesSent: bigint; + messagesReceived: bigint; + amountSent: bigint; + amountReceived: bigint; + bump: number; + custodyBump: number; +}; + +export type LocalTokenArgs = { + custody: Address; + mint: Address; + burnLimitPerMessage: number | bigint; + messagesSent: number | bigint; + messagesReceived: number | bigint; + amountSent: number | bigint; + amountReceived: number | bigint; + bump: number; + custodyBump: number; +}; + +export function getLocalTokenEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['custody', getAddressEncoder()], + ['mint', getAddressEncoder()], + ['burnLimitPerMessage', getU64Encoder()], + ['messagesSent', getU64Encoder()], + ['messagesReceived', getU64Encoder()], + ['amountSent', getU128Encoder()], + ['amountReceived', getU128Encoder()], + ['bump', getU8Encoder()], + ['custodyBump', getU8Encoder()], + ]), + (value) => ({ ...value, discriminator: LOCAL_TOKEN_DISCRIMINATOR }) + ); +} + +export function getLocalTokenDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['custody', getAddressDecoder()], + ['mint', getAddressDecoder()], + ['burnLimitPerMessage', getU64Decoder()], + ['messagesSent', getU64Decoder()], + ['messagesReceived', getU64Decoder()], + ['amountSent', getU128Decoder()], + ['amountReceived', getU128Decoder()], + ['bump', getU8Decoder()], + ['custodyBump', getU8Decoder()], + ]); +} + +export function getLocalTokenCodec(): Codec { + return combineCodec(getLocalTokenEncoder(), getLocalTokenDecoder()); +} + +export function decodeLocalToken( + encodedAccount: EncodedAccount +): Account; +export function decodeLocalToken( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeLocalToken( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getLocalTokenDecoder() + ); +} + +export async function fetchLocalToken( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeLocalToken(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeLocalToken( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeLocalToken(maybeAccount); +} + +export async function fetchAllLocalToken( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeLocalToken(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeLocalToken( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeLocalToken(maybeAccount)); +} + +export function getLocalTokenSize(): number { + return 130; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/messageTransmitter.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/messageTransmitter.ts new file mode 100644 index 000000000..7f6c300df --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/accounts/messageTransmitter.ts @@ -0,0 +1,189 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getArrayDecoder, + getArrayEncoder, + getBooleanDecoder, + getBooleanEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const MESSAGE_TRANSMITTER_DISCRIMINATOR = new Uint8Array([ + 71, 40, 180, 142, 19, 203, 35, 252, +]); + +export function getMessageTransmitterDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + MESSAGE_TRANSMITTER_DISCRIMINATOR + ); +} + +export type MessageTransmitter = { + discriminator: ReadonlyUint8Array; + owner: Address; + pendingOwner: Address; + attesterManager: Address; + pauser: Address; + paused: boolean; + localDomain: number; + version: number; + signatureThreshold: number; + enabledAttesters: Array
; + maxMessageBodySize: bigint; +}; + +export type MessageTransmitterArgs = { + owner: Address; + pendingOwner: Address; + attesterManager: Address; + pauser: Address; + paused: boolean; + localDomain: number; + version: number; + signatureThreshold: number; + enabledAttesters: Array
; + maxMessageBodySize: number | bigint; +}; + +export function getMessageTransmitterEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['owner', getAddressEncoder()], + ['pendingOwner', getAddressEncoder()], + ['attesterManager', getAddressEncoder()], + ['pauser', getAddressEncoder()], + ['paused', getBooleanEncoder()], + ['localDomain', getU32Encoder()], + ['version', getU32Encoder()], + ['signatureThreshold', getU32Encoder()], + ['enabledAttesters', getArrayEncoder(getAddressEncoder())], + ['maxMessageBodySize', getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: MESSAGE_TRANSMITTER_DISCRIMINATOR }) + ); +} + +export function getMessageTransmitterDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['owner', getAddressDecoder()], + ['pendingOwner', getAddressDecoder()], + ['attesterManager', getAddressDecoder()], + ['pauser', getAddressDecoder()], + ['paused', getBooleanDecoder()], + ['localDomain', getU32Decoder()], + ['version', getU32Decoder()], + ['signatureThreshold', getU32Decoder()], + ['enabledAttesters', getArrayDecoder(getAddressDecoder())], + ['maxMessageBodySize', getU64Decoder()], + ]); +} + +export function getMessageTransmitterCodec(): Codec< + MessageTransmitterArgs, + MessageTransmitter +> { + return combineCodec( + getMessageTransmitterEncoder(), + getMessageTransmitterDecoder() + ); +} + +export function decodeMessageTransmitter( + encodedAccount: EncodedAccount +): Account; +export function decodeMessageTransmitter( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeMessageTransmitter( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getMessageTransmitterDecoder() + ); +} + +export async function fetchMessageTransmitter( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeMessageTransmitter(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeMessageTransmitter< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeMessageTransmitter(maybeAccount); +} + +export async function fetchAllMessageTransmitter( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeMessageTransmitter( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeMessageTransmitter( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeMessageTransmitter(maybeAccount) + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/remoteTokenMessenger.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/remoteTokenMessenger.ts new file mode 100644 index 000000000..a2bbc7ecf --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/accounts/remoteTokenMessenger.ts @@ -0,0 +1,164 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const REMOTE_TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ + 105, 115, 174, 34, 95, 233, 138, 252, +]); + +export function getRemoteTokenMessengerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REMOTE_TOKEN_MESSENGER_DISCRIMINATOR + ); +} + +export type RemoteTokenMessenger = { + discriminator: ReadonlyUint8Array; + domain: number; + tokenMessenger: Address; +}; + +export type RemoteTokenMessengerArgs = { + domain: number; + tokenMessenger: Address; +}; + +export function getRemoteTokenMessengerEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['domain', getU32Encoder()], + ['tokenMessenger', getAddressEncoder()], + ]), + (value) => ({ + ...value, + discriminator: REMOTE_TOKEN_MESSENGER_DISCRIMINATOR, + }) + ); +} + +export function getRemoteTokenMessengerDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['domain', getU32Decoder()], + ['tokenMessenger', getAddressDecoder()], + ]); +} + +export function getRemoteTokenMessengerCodec(): Codec< + RemoteTokenMessengerArgs, + RemoteTokenMessenger +> { + return combineCodec( + getRemoteTokenMessengerEncoder(), + getRemoteTokenMessengerDecoder() + ); +} + +export function decodeRemoteTokenMessenger( + encodedAccount: EncodedAccount +): Account; +export function decodeRemoteTokenMessenger( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeRemoteTokenMessenger( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): + | Account + | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getRemoteTokenMessengerDecoder() + ); +} + +export async function fetchRemoteTokenMessenger< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeRemoteTokenMessenger( + rpc, + address, + config + ); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeRemoteTokenMessenger< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeRemoteTokenMessenger(maybeAccount); +} + +export async function fetchAllRemoteTokenMessenger( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeRemoteTokenMessenger( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeRemoteTokenMessenger( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeRemoteTokenMessenger(maybeAccount) + ); +} + +export function getRemoteTokenMessengerSize(): number { + return 44; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/tokenMessenger.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/tokenMessenger.ts new file mode 100644 index 000000000..72bbc9716 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/accounts/tokenMessenger.ts @@ -0,0 +1,176 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ + 162, 4, 242, 52, 147, 243, 221, 96, +]); + +export function getTokenMessengerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + TOKEN_MESSENGER_DISCRIMINATOR + ); +} + +export type TokenMessenger = { + discriminator: ReadonlyUint8Array; + denylister: Address; + owner: Address; + pendingOwner: Address; + messageBodyVersion: number; + authorityBump: number; + feeRecipient: Address; + minFeeController: Address; + minFee: number; +}; + +export type TokenMessengerArgs = { + denylister: Address; + owner: Address; + pendingOwner: Address; + messageBodyVersion: number; + authorityBump: number; + feeRecipient: Address; + minFeeController: Address; + minFee: number; +}; + +export function getTokenMessengerEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['denylister', getAddressEncoder()], + ['owner', getAddressEncoder()], + ['pendingOwner', getAddressEncoder()], + ['messageBodyVersion', getU32Encoder()], + ['authorityBump', getU8Encoder()], + ['feeRecipient', getAddressEncoder()], + ['minFeeController', getAddressEncoder()], + ['minFee', getU32Encoder()], + ]), + (value) => ({ ...value, discriminator: TOKEN_MESSENGER_DISCRIMINATOR }) + ); +} + +export function getTokenMessengerDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['denylister', getAddressDecoder()], + ['owner', getAddressDecoder()], + ['pendingOwner', getAddressDecoder()], + ['messageBodyVersion', getU32Decoder()], + ['authorityBump', getU8Decoder()], + ['feeRecipient', getAddressDecoder()], + ['minFeeController', getAddressDecoder()], + ['minFee', getU32Decoder()], + ]); +} + +export function getTokenMessengerCodec(): Codec< + TokenMessengerArgs, + TokenMessenger +> { + return combineCodec(getTokenMessengerEncoder(), getTokenMessengerDecoder()); +} + +export function decodeTokenMessenger( + encodedAccount: EncodedAccount +): Account; +export function decodeTokenMessenger( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeTokenMessenger( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getTokenMessengerDecoder() + ); +} + +export async function fetchTokenMessenger( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeTokenMessenger(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeTokenMessenger< + TAddress extends string = string, +>( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeTokenMessenger(maybeAccount); +} + +export async function fetchAllTokenMessenger( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeTokenMessenger( + rpc, + addresses, + config + ); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeTokenMessenger( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => + decodeTokenMessenger(maybeAccount) + ); +} + +export function getTokenMessengerSize(): number { + return 177; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/tokenMinter.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/tokenMinter.ts new file mode 100644 index 000000000..e522ef79d --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/accounts/tokenMinter.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 { + assertAccountExists, + assertAccountsExist, + combineCodec, + decodeAccount, + fetchEncodedAccount, + fetchEncodedAccounts, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBooleanDecoder, + getBooleanEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const TOKEN_MINTER_DISCRIMINATOR = new Uint8Array([ + 122, 133, 84, 63, 57, 159, 171, 206, +]); + +export function getTokenMinterDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + TOKEN_MINTER_DISCRIMINATOR + ); +} + +export type TokenMinter = { + discriminator: ReadonlyUint8Array; + tokenController: Address; + pauser: Address; + paused: boolean; + bump: number; +}; + +export type TokenMinterArgs = { + tokenController: Address; + pauser: Address; + paused: boolean; + bump: number; +}; + +export function getTokenMinterEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['tokenController', getAddressEncoder()], + ['pauser', getAddressEncoder()], + ['paused', getBooleanEncoder()], + ['bump', getU8Encoder()], + ]), + (value) => ({ ...value, discriminator: TOKEN_MINTER_DISCRIMINATOR }) + ); +} + +export function getTokenMinterDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['tokenController', getAddressDecoder()], + ['pauser', getAddressDecoder()], + ['paused', getBooleanDecoder()], + ['bump', getU8Decoder()], + ]); +} + +export function getTokenMinterCodec(): Codec { + return combineCodec(getTokenMinterEncoder(), getTokenMinterDecoder()); +} + +export function decodeTokenMinter( + encodedAccount: EncodedAccount +): Account; +export function decodeTokenMinter( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeTokenMinter( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getTokenMinterDecoder() + ); +} + +export async function fetchTokenMinter( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeTokenMinter(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeTokenMinter( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeTokenMinter(maybeAccount); +} + +export async function fetchAllTokenMinter( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeTokenMinter(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeTokenMinter( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeTokenMinter(maybeAccount)); +} + +export function getTokenMinterSize(): number { + return 74; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/tokenPair.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/tokenPair.ts new file mode 100644 index 000000000..40fee5627 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/accounts/tokenPair.ts @@ -0,0 +1,147 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU8Decoder, + getU8Encoder, + transformEncoder, + type Account, + type Address, + type Codec, + type Decoder, + type EncodedAccount, + type Encoder, + type FetchAccountConfig, + type FetchAccountsConfig, + type MaybeAccount, + type MaybeEncodedAccount, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export const TOKEN_PAIR_DISCRIMINATOR = new Uint8Array([ + 17, 214, 45, 176, 229, 149, 197, 71, +]); + +export function getTokenPairDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(TOKEN_PAIR_DISCRIMINATOR); +} + +export type TokenPair = { + discriminator: ReadonlyUint8Array; + remoteDomain: number; + remoteToken: Address; + localToken: Address; + bump: number; +}; + +export type TokenPairArgs = { + remoteDomain: number; + remoteToken: Address; + localToken: Address; + bump: number; +}; + +export function getTokenPairEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['remoteDomain', getU32Encoder()], + ['remoteToken', getAddressEncoder()], + ['localToken', getAddressEncoder()], + ['bump', getU8Encoder()], + ]), + (value) => ({ ...value, discriminator: TOKEN_PAIR_DISCRIMINATOR }) + ); +} + +export function getTokenPairDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['remoteDomain', getU32Decoder()], + ['remoteToken', getAddressDecoder()], + ['localToken', getAddressDecoder()], + ['bump', getU8Decoder()], + ]); +} + +export function getTokenPairCodec(): Codec { + return combineCodec(getTokenPairEncoder(), getTokenPairDecoder()); +} + +export function decodeTokenPair( + encodedAccount: EncodedAccount +): Account; +export function decodeTokenPair( + encodedAccount: MaybeEncodedAccount +): MaybeAccount; +export function decodeTokenPair( + encodedAccount: EncodedAccount | MaybeEncodedAccount +): Account | MaybeAccount { + return decodeAccount( + encodedAccount as MaybeEncodedAccount, + getTokenPairDecoder() + ); +} + +export async function fetchTokenPair( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchMaybeTokenPair(rpc, address, config); + assertAccountExists(maybeAccount); + return maybeAccount; +} + +export async function fetchMaybeTokenPair( + rpc: Parameters[0], + address: Address, + config?: FetchAccountConfig +): Promise> { + const maybeAccount = await fetchEncodedAccount(rpc, address, config); + return decodeTokenPair(maybeAccount); +} + +export async function fetchAllTokenPair( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchAllMaybeTokenPair(rpc, addresses, config); + assertAccountsExist(maybeAccounts); + return maybeAccounts; +} + +export async function fetchAllMaybeTokenPair( + rpc: Parameters[0], + addresses: Array
, + config?: FetchAccountsConfig +): Promise[]> { + const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); + return maybeAccounts.map((maybeAccount) => decodeTokenPair(maybeAccount)); +} + +export function getTokenPairSize(): number { + return 77; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/errors/index.ts b/src/svm/clients/TokenMessengerMinterV2/errors/index.ts new file mode 100644 index 000000000..f2cacc30e --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/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 './tokenMessengerMinterV2'; diff --git a/src/svm/clients/TokenMessengerMinterV2/errors/tokenMessengerMinterV2.ts b/src/svm/clients/TokenMessengerMinterV2/errors/tokenMessengerMinterV2.ts new file mode 100644 index 000000000..7d01d6fce --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/errors/tokenMessengerMinterV2.ts @@ -0,0 +1,95 @@ +/** + * 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/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; + +/** InvalidAuthority: Invalid authority */ +export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_AUTHORITY = 0x1770; // 6000 +/** InvalidTokenMinterState: Invalid token minter state */ +export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_MINTER_STATE = 0x1771; // 6001 +/** ProgramPaused: Instruction is not allowed at this time */ +export const TOKEN_MESSENGER_MINTER_V2_ERROR__PROGRAM_PAUSED = 0x1772; // 6002 +/** InvalidTokenPairState: Invalid token pair state */ +export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_PAIR_STATE = 0x1773; // 6003 +/** InvalidLocalTokenState: Invalid local token state */ +export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_LOCAL_TOKEN_STATE = 0x1774; // 6004 +/** InvalidPauser: Invalid pauser */ +export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_PAUSER = 0x1775; // 6005 +/** InvalidTokenController: Invalid token controller */ +export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_CONTROLLER = 0x1776; // 6006 +/** BurnAmountExceeded: Burn amount exceeded */ +export const TOKEN_MESSENGER_MINTER_V2_ERROR__BURN_AMOUNT_EXCEEDED = 0x1777; // 6007 +/** InvalidAmount: Invalid amount */ +export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_AMOUNT = 0x1778; // 6008 + +export type TokenMessengerMinterV2Error = + | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__BURN_AMOUNT_EXCEEDED + | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_AMOUNT + | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_AUTHORITY + | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_LOCAL_TOKEN_STATE + | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_PAUSER + | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_CONTROLLER + | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_MINTER_STATE + | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_PAIR_STATE + | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__PROGRAM_PAUSED; + +let tokenMessengerMinterV2ErrorMessages: + | Record + | undefined; +if (process.env.NODE_ENV !== 'production') { + tokenMessengerMinterV2ErrorMessages = { + [TOKEN_MESSENGER_MINTER_V2_ERROR__BURN_AMOUNT_EXCEEDED]: `Burn amount exceeded`, + [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_AMOUNT]: `Invalid amount`, + [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_AUTHORITY]: `Invalid authority`, + [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_LOCAL_TOKEN_STATE]: `Invalid local token state`, + [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_PAUSER]: `Invalid pauser`, + [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_CONTROLLER]: `Invalid token controller`, + [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_MINTER_STATE]: `Invalid token minter state`, + [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_PAIR_STATE]: `Invalid token pair state`, + [TOKEN_MESSENGER_MINTER_V2_ERROR__PROGRAM_PAUSED]: `Instruction is not allowed at this time`, + }; +} + +export function getTokenMessengerMinterV2ErrorMessage( + code: TokenMessengerMinterV2Error +): string { + if (process.env.NODE_ENV !== 'production') { + return ( + tokenMessengerMinterV2ErrorMessages as Record< + TokenMessengerMinterV2Error, + string + > + )[code]; + } + + return 'Error message not available in production bundles.'; +} + +export function isTokenMessengerMinterV2Error< + TProgramErrorCode extends TokenMessengerMinterV2Error, +>( + error: unknown, + transactionMessage: { + instructions: Record; + }, + code?: TProgramErrorCode +): error is SolanaError & + Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { + return isProgramError( + error, + transactionMessage, + TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + code + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/index.ts b/src/svm/clients/TokenMessengerMinterV2/index.ts new file mode 100644 index 000000000..02964a6ae --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/index.ts @@ -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. + * + * @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/src/svm/clients/TokenMessengerMinterV2/instructions/acceptOwnership.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/acceptOwnership.ts new file mode 100644 index 000000000..f0dca6def --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/acceptOwnership.ts @@ -0,0 +1,305 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const ACCEPT_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ + 172, 23, 43, 13, 238, 213, 85, 150, +]); + +export function getAcceptOwnershipDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + ACCEPT_OWNERSHIP_DISCRIMINATOR + ); +} + +export type AcceptOwnershipInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountPendingOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPendingOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountPendingOwner, + TAccountTokenMessenger extends string + ? WritableAccount + : TAccountTokenMessenger, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type AcceptOwnershipInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type AcceptOwnershipInstructionDataArgs = {}; + +export function getAcceptOwnershipInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: ACCEPT_OWNERSHIP_DISCRIMINATOR }) + ); +} + +export function getAcceptOwnershipInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getAcceptOwnershipInstructionDataCodec(): Codec< + AcceptOwnershipInstructionDataArgs, + AcceptOwnershipInstructionData +> { + return combineCodec( + getAcceptOwnershipInstructionDataEncoder(), + getAcceptOwnershipInstructionDataDecoder() + ); +} + +export type AcceptOwnershipAsyncInput< + TAccountPendingOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pendingOwner: TransactionSigner; + tokenMessenger: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getAcceptOwnershipInstructionAsync< + TAccountPendingOwner extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: AcceptOwnershipAsyncInput< + TAccountPendingOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + AcceptOwnershipInstruction< + TProgramAddress, + TAccountPendingOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pendingOwner: { value: input.pendingOwner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pendingOwner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getAcceptOwnershipInstructionDataEncoder().encode({}), + } as AcceptOwnershipInstruction< + TProgramAddress, + TAccountPendingOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type AcceptOwnershipInput< + TAccountPendingOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pendingOwner: TransactionSigner; + tokenMessenger: Address; + eventAuthority: Address; + program: Address; +}; + +export function getAcceptOwnershipInstruction< + TAccountPendingOwner extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: AcceptOwnershipInput< + TAccountPendingOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): AcceptOwnershipInstruction< + TProgramAddress, + TAccountPendingOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pendingOwner: { value: input.pendingOwner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pendingOwner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getAcceptOwnershipInstructionDataEncoder().encode({}), + } as AcceptOwnershipInstruction< + TProgramAddress, + TAccountPendingOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedAcceptOwnershipInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + pendingOwner: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: AcceptOwnershipInstructionData; +}; + +export function parseAcceptOwnershipInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedAcceptOwnershipInstruction { + if (instruction.accounts.length < 4) { + // 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: { + pendingOwner: getNextAccount(), + tokenMessenger: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getAcceptOwnershipInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/addLocalToken.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/addLocalToken.ts new file mode 100644 index 000000000..f54136d91 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/addLocalToken.ts @@ -0,0 +1,502 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const ADD_LOCAL_TOKEN_DISCRIMINATOR = new Uint8Array([ + 213, 199, 205, 18, 98, 124, 73, 198, +]); + +export function getAddLocalTokenDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + ADD_LOCAL_TOKEN_DISCRIMINATOR + ); +} + +export type AddLocalTokenInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountTokenController extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountCustodyTokenAccount extends string | AccountMeta = string, + TAccountLocalTokenMint extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountTokenController extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountTokenController, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountCustodyTokenAccount extends string + ? WritableAccount + : TAccountCustodyTokenAccount, + TAccountLocalTokenMint extends string + ? ReadonlyAccount + : TAccountLocalTokenMint, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type AddLocalTokenInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type AddLocalTokenInstructionDataArgs = {}; + +export function getAddLocalTokenInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: ADD_LOCAL_TOKEN_DISCRIMINATOR }) + ); +} + +export function getAddLocalTokenInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getAddLocalTokenInstructionDataCodec(): Codec< + AddLocalTokenInstructionDataArgs, + AddLocalTokenInstructionData +> { + return combineCodec( + getAddLocalTokenInstructionDataEncoder(), + getAddLocalTokenInstructionDataDecoder() + ); +} + +export type AddLocalTokenAsyncInput< + TAccountPayer extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountLocalTokenMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + localToken?: Address; + custodyTokenAccount?: Address; + localTokenMint: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getAddLocalTokenInstructionAsync< + TAccountPayer extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountCustodyTokenAccount extends string, + TAccountLocalTokenMint extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: AddLocalTokenAsyncInput< + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountLocalTokenMint, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + AddLocalTokenInstruction< + TProgramAddress, + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountLocalTokenMint, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + localTokenMint: { value: input.localTokenMint ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.localToken.value) { + accounts.localToken.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([108, 111, 99, 97, 108, 95, 116, 111, 107, 101, 110]) + ), + getAddressEncoder().encode( + expectAddress(accounts.localTokenMint.value) + ), + ], + }); + } + if (!accounts.custodyTokenAccount.value) { + accounts.custodyTokenAccount.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([99, 117, 115, 116, 111, 100, 121]) + ), + getAddressEncoder().encode( + expectAddress(accounts.localTokenMint.value) + ), + ], + }); + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.localTokenMint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getAddLocalTokenInstructionDataEncoder().encode({}), + } as AddLocalTokenInstruction< + TProgramAddress, + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountLocalTokenMint, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type AddLocalTokenInput< + TAccountPayer extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountLocalTokenMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + localToken: Address; + custodyTokenAccount: Address; + localTokenMint: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; +}; + +export function getAddLocalTokenInstruction< + TAccountPayer extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountCustodyTokenAccount extends string, + TAccountLocalTokenMint extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: AddLocalTokenInput< + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountLocalTokenMint, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): AddLocalTokenInstruction< + TProgramAddress, + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountLocalTokenMint, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + localTokenMint: { value: input.localTokenMint ?? null, isWritable: false }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.localTokenMint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getAddLocalTokenInstructionDataEncoder().encode({}), + } as AddLocalTokenInstruction< + TProgramAddress, + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountLocalTokenMint, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedAddLocalTokenInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + tokenController: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + localToken: TAccountMetas[3]; + custodyTokenAccount: TAccountMetas[4]; + localTokenMint: TAccountMetas[5]; + tokenProgram: TAccountMetas[6]; + systemProgram: TAccountMetas[7]; + eventAuthority: TAccountMetas[8]; + program: TAccountMetas[9]; + }; + data: AddLocalTokenInstructionData; +}; + +export function parseAddLocalTokenInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedAddLocalTokenInstruction { + if (instruction.accounts.length < 10) { + // 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: { + payer: getNextAccount(), + tokenController: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + custodyTokenAccount: getNextAccount(), + localTokenMint: getNextAccount(), + tokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getAddLocalTokenInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/addRemoteTokenMessenger.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/addRemoteTokenMessenger.ts new file mode 100644 index 000000000..0fab7dfd5 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/addRemoteTokenMessenger.ts @@ -0,0 +1,424 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const ADD_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ + 12, 149, 172, 165, 111, 202, 24, 33, +]); + +export function getAddRemoteTokenMessengerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + ADD_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR + ); +} + +export type AddRemoteTokenMessengerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountRemoteTokenMessenger extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountRemoteTokenMessenger extends string + ? WritableAccount + : TAccountRemoteTokenMessenger, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type AddRemoteTokenMessengerInstructionData = { + discriminator: ReadonlyUint8Array; + domain: number; + tokenMessenger: Address; +}; + +export type AddRemoteTokenMessengerInstructionDataArgs = { + domain: number; + tokenMessenger: Address; +}; + +export function getAddRemoteTokenMessengerInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['domain', getU32Encoder()], + ['tokenMessenger', getAddressEncoder()], + ]), + (value) => ({ + ...value, + discriminator: ADD_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR, + }) + ); +} + +export function getAddRemoteTokenMessengerInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['domain', getU32Decoder()], + ['tokenMessenger', getAddressDecoder()], + ]); +} + +export function getAddRemoteTokenMessengerInstructionDataCodec(): Codec< + AddRemoteTokenMessengerInstructionDataArgs, + AddRemoteTokenMessengerInstructionData +> { + return combineCodec( + getAddRemoteTokenMessengerInstructionDataEncoder(), + getAddRemoteTokenMessengerInstructionDataDecoder() + ); +} + +export type AddRemoteTokenMessengerAsyncInput< + TAccountPayer extends string = string, + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + owner: TransactionSigner; + tokenMessenger: Address; + remoteTokenMessenger: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + domain: AddRemoteTokenMessengerInstructionDataArgs['domain']; + tokenMessengerArg: AddRemoteTokenMessengerInstructionDataArgs['tokenMessenger']; +}; + +export async function getAddRemoteTokenMessengerInstructionAsync< + TAccountPayer extends string, + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: AddRemoteTokenMessengerAsyncInput< + TAccountPayer, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + AddRemoteTokenMessengerInstruction< + TProgramAddress, + TAccountPayer, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: true, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input, tokenMessenger: input.tokenMessengerArg }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getAddRemoteTokenMessengerInstructionDataEncoder().encode( + args as AddRemoteTokenMessengerInstructionDataArgs + ), + } as AddRemoteTokenMessengerInstruction< + TProgramAddress, + TAccountPayer, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type AddRemoteTokenMessengerInput< + TAccountPayer extends string = string, + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + owner: TransactionSigner; + tokenMessenger: Address; + remoteTokenMessenger: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + domain: AddRemoteTokenMessengerInstructionDataArgs['domain']; + tokenMessengerArg: AddRemoteTokenMessengerInstructionDataArgs['tokenMessenger']; +}; + +export function getAddRemoteTokenMessengerInstruction< + TAccountPayer extends string, + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: AddRemoteTokenMessengerInput< + TAccountPayer, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): AddRemoteTokenMessengerInstruction< + TProgramAddress, + TAccountPayer, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: true, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input, tokenMessenger: input.tokenMessengerArg }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getAddRemoteTokenMessengerInstructionDataEncoder().encode( + args as AddRemoteTokenMessengerInstructionDataArgs + ), + } as AddRemoteTokenMessengerInstruction< + TProgramAddress, + TAccountPayer, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedAddRemoteTokenMessengerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + owner: TAccountMetas[1]; + tokenMessenger: TAccountMetas[2]; + remoteTokenMessenger: TAccountMetas[3]; + systemProgram: TAccountMetas[4]; + eventAuthority: TAccountMetas[5]; + program: TAccountMetas[6]; + }; + data: AddRemoteTokenMessengerInstructionData; +}; + +export function parseAddRemoteTokenMessengerInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedAddRemoteTokenMessengerInstruction { + if (instruction.accounts.length < 7) { + // 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: { + payer: getNextAccount(), + owner: getNextAccount(), + tokenMessenger: getNextAccount(), + remoteTokenMessenger: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getAddRemoteTokenMessengerInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/burnTokenCustody.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/burnTokenCustody.ts new file mode 100644 index 000000000..bec1d8a82 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/burnTokenCustody.ts @@ -0,0 +1,465 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const BURN_TOKEN_CUSTODY_DISCRIMINATOR = new Uint8Array([ + 233, 136, 180, 175, 112, 41, 62, 71, +]); + +export function getBurnTokenCustodyDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + BURN_TOKEN_CUSTODY_DISCRIMINATOR + ); +} + +export type BurnTokenCustodyInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountPayee extends string | AccountMeta = string, + TAccountTokenController extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountCustodyTokenAccount extends string | AccountMeta = string, + TAccountCustodyTokenMint extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayee extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayee, + TAccountTokenController extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountTokenController, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? ReadonlyAccount + : TAccountLocalToken, + TAccountCustodyTokenAccount extends string + ? WritableAccount + : TAccountCustodyTokenAccount, + TAccountCustodyTokenMint extends string + ? WritableAccount + : TAccountCustodyTokenMint, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type BurnTokenCustodyInstructionData = { + discriminator: ReadonlyUint8Array; + amount: bigint; +}; + +export type BurnTokenCustodyInstructionDataArgs = { amount: number | bigint }; + +export function getBurnTokenCustodyInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['amount', getU64Encoder()], + ]), + (value) => ({ ...value, discriminator: BURN_TOKEN_CUSTODY_DISCRIMINATOR }) + ); +} + +export function getBurnTokenCustodyInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['amount', getU64Decoder()], + ]); +} + +export function getBurnTokenCustodyInstructionDataCodec(): Codec< + BurnTokenCustodyInstructionDataArgs, + BurnTokenCustodyInstructionData +> { + return combineCodec( + getBurnTokenCustodyInstructionDataEncoder(), + getBurnTokenCustodyInstructionDataDecoder() + ); +} + +export type BurnTokenCustodyAsyncInput< + TAccountPayee extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountCustodyTokenMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payee: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + localToken: Address; + custodyTokenAccount: Address; + custodyTokenMint: Address; + tokenProgram?: Address; + eventAuthority?: Address; + program: Address; + amount: BurnTokenCustodyInstructionDataArgs['amount']; +}; + +export async function getBurnTokenCustodyInstructionAsync< + TAccountPayee extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountCustodyTokenAccount extends string, + TAccountCustodyTokenMint extends string, + TAccountTokenProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: BurnTokenCustodyAsyncInput< + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + BurnTokenCustodyInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: false }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + custodyTokenMint: { + value: input.custodyTokenMint ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.custodyTokenMint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getBurnTokenCustodyInstructionDataEncoder().encode( + args as BurnTokenCustodyInstructionDataArgs + ), + } as BurnTokenCustodyInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type BurnTokenCustodyInput< + TAccountPayee extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountCustodyTokenMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payee: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + localToken: Address; + custodyTokenAccount: Address; + custodyTokenMint: Address; + tokenProgram?: Address; + eventAuthority: Address; + program: Address; + amount: BurnTokenCustodyInstructionDataArgs['amount']; +}; + +export function getBurnTokenCustodyInstruction< + TAccountPayee extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountCustodyTokenAccount extends string, + TAccountCustodyTokenMint extends string, + TAccountTokenProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: BurnTokenCustodyInput< + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): BurnTokenCustodyInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: false }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + custodyTokenMint: { + value: input.custodyTokenMint ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.custodyTokenMint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getBurnTokenCustodyInstructionDataEncoder().encode( + args as BurnTokenCustodyInstructionDataArgs + ), + } as BurnTokenCustodyInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedBurnTokenCustodyInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payee: TAccountMetas[0]; + tokenController: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + localToken: TAccountMetas[3]; + custodyTokenAccount: TAccountMetas[4]; + custodyTokenMint: TAccountMetas[5]; + tokenProgram: TAccountMetas[6]; + eventAuthority: TAccountMetas[7]; + program: TAccountMetas[8]; + }; + data: BurnTokenCustodyInstructionData; +}; + +export function parseBurnTokenCustodyInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedBurnTokenCustodyInstruction { + if (instruction.accounts.length < 9) { + // 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: { + payee: getNextAccount(), + tokenController: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + custodyTokenAccount: getNextAccount(), + custodyTokenMint: getNextAccount(), + tokenProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getBurnTokenCustodyInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/denylistAccount.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/denylistAccount.ts new file mode 100644 index 000000000..52fcc61c7 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/denylistAccount.ts @@ -0,0 +1,403 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const DENYLIST_ACCOUNT_DISCRIMINATOR = new Uint8Array([ + 101, 116, 197, 112, 81, 249, 75, 194, +]); + +export function getDenylistAccountDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DENYLIST_ACCOUNT_DISCRIMINATOR + ); +} + +export type DenylistAccountInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountDenylister extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountDenylistAccount extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountDenylister extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountDenylister, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountDenylistAccount extends string + ? WritableAccount + : TAccountDenylistAccount, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type DenylistAccountInstructionData = { + discriminator: ReadonlyUint8Array; + account: Address; +}; + +export type DenylistAccountInstructionDataArgs = { account: Address }; + +export function getDenylistAccountInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['account', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: DENYLIST_ACCOUNT_DISCRIMINATOR }) + ); +} + +export function getDenylistAccountInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['account', getAddressDecoder()], + ]); +} + +export function getDenylistAccountInstructionDataCodec(): Codec< + DenylistAccountInstructionDataArgs, + DenylistAccountInstructionData +> { + return combineCodec( + getDenylistAccountInstructionDataEncoder(), + getDenylistAccountInstructionDataDecoder() + ); +} + +export type DenylistAccountAsyncInput< + TAccountPayer extends string = string, + TAccountDenylister extends string = string, + TAccountTokenMessenger extends string = string, + TAccountDenylistAccount extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + denylister: TransactionSigner; + tokenMessenger: Address; + denylistAccount: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + account: DenylistAccountInstructionDataArgs['account']; +}; + +export async function getDenylistAccountInstructionAsync< + TAccountPayer extends string, + TAccountDenylister extends string, + TAccountTokenMessenger extends string, + TAccountDenylistAccount extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: DenylistAccountAsyncInput< + TAccountPayer, + TAccountDenylister, + TAccountTokenMessenger, + TAccountDenylistAccount, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + DenylistAccountInstruction< + TProgramAddress, + TAccountPayer, + TAccountDenylister, + TAccountTokenMessenger, + TAccountDenylistAccount, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + denylister: { value: input.denylister ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + denylistAccount: { value: input.denylistAccount ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.denylister), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.denylistAccount), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDenylistAccountInstructionDataEncoder().encode( + args as DenylistAccountInstructionDataArgs + ), + } as DenylistAccountInstruction< + TProgramAddress, + TAccountPayer, + TAccountDenylister, + TAccountTokenMessenger, + TAccountDenylistAccount, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type DenylistAccountInput< + TAccountPayer extends string = string, + TAccountDenylister extends string = string, + TAccountTokenMessenger extends string = string, + TAccountDenylistAccount extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + denylister: TransactionSigner; + tokenMessenger: Address; + denylistAccount: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + account: DenylistAccountInstructionDataArgs['account']; +}; + +export function getDenylistAccountInstruction< + TAccountPayer extends string, + TAccountDenylister extends string, + TAccountTokenMessenger extends string, + TAccountDenylistAccount extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: DenylistAccountInput< + TAccountPayer, + TAccountDenylister, + TAccountTokenMessenger, + TAccountDenylistAccount, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): DenylistAccountInstruction< + TProgramAddress, + TAccountPayer, + TAccountDenylister, + TAccountTokenMessenger, + TAccountDenylistAccount, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + denylister: { value: input.denylister ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + denylistAccount: { value: input.denylistAccount ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.denylister), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.denylistAccount), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDenylistAccountInstructionDataEncoder().encode( + args as DenylistAccountInstructionDataArgs + ), + } as DenylistAccountInstruction< + TProgramAddress, + TAccountPayer, + TAccountDenylister, + TAccountTokenMessenger, + TAccountDenylistAccount, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedDenylistAccountInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + denylister: TAccountMetas[1]; + tokenMessenger: TAccountMetas[2]; + denylistAccount: TAccountMetas[3]; + systemProgram: TAccountMetas[4]; + eventAuthority: TAccountMetas[5]; + program: TAccountMetas[6]; + }; + data: DenylistAccountInstructionData; +}; + +export function parseDenylistAccountInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedDenylistAccountInstruction { + if (instruction.accounts.length < 7) { + // 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: { + payer: getNextAccount(), + denylister: getNextAccount(), + tokenMessenger: getNextAccount(), + denylistAccount: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getDenylistAccountInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurn.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurn.ts new file mode 100644 index 000000000..89ae3ab3a --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurn.ts @@ -0,0 +1,802 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const DEPOSIT_FOR_BURN_DISCRIMINATOR = new Uint8Array([ + 215, 60, 61, 46, 114, 55, 128, 176, +]); + +export function getDepositForBurnDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DEPOSIT_FOR_BURN_DISCRIMINATOR + ); +} + +export type DepositForBurnInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountEventRentPayer extends string | AccountMeta = string, + TAccountSenderAuthorityPda extends string | AccountMeta = string, + TAccountBurnTokenAccount extends string | AccountMeta = string, + TAccountDenylistAccount extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountRemoteTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountBurnTokenMint extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TAccountMessageTransmitterProgram extends string | AccountMeta = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC', + TAccountTokenMessengerMinterProgram extends string | AccountMeta = + 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe', + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountEventRentPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountEventRentPayer, + TAccountSenderAuthorityPda extends string + ? ReadonlyAccount + : TAccountSenderAuthorityPda, + TAccountBurnTokenAccount extends string + ? WritableAccount + : TAccountBurnTokenAccount, + TAccountDenylistAccount extends string + ? ReadonlyAccount + : TAccountDenylistAccount, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountRemoteTokenMessenger extends string + ? ReadonlyAccount + : TAccountRemoteTokenMessenger, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountBurnTokenMint extends string + ? WritableAccount + : TAccountBurnTokenMint, + TAccountMessageSentEventData extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountMessageSentEventData, + TAccountMessageTransmitterProgram extends string + ? ReadonlyAccount + : TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram extends string + ? ReadonlyAccount + : TAccountTokenMessengerMinterProgram, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type DepositForBurnInstructionData = { + discriminator: ReadonlyUint8Array; + amount: bigint; + destinationDomain: number; + mintRecipient: Address; + destinationCaller: Address; + maxFee: bigint; + minFinalityThreshold: number; +}; + +export type DepositForBurnInstructionDataArgs = { + amount: number | bigint; + destinationDomain: number; + mintRecipient: Address; + destinationCaller: Address; + maxFee: number | bigint; + minFinalityThreshold: number; +}; + +export function getDepositForBurnInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['amount', getU64Encoder()], + ['destinationDomain', getU32Encoder()], + ['mintRecipient', getAddressEncoder()], + ['destinationCaller', getAddressEncoder()], + ['maxFee', getU64Encoder()], + ['minFinalityThreshold', getU32Encoder()], + ]), + (value) => ({ ...value, discriminator: DEPOSIT_FOR_BURN_DISCRIMINATOR }) + ); +} + +export function getDepositForBurnInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['amount', getU64Decoder()], + ['destinationDomain', getU32Decoder()], + ['mintRecipient', getAddressDecoder()], + ['destinationCaller', getAddressDecoder()], + ['maxFee', getU64Decoder()], + ['minFinalityThreshold', getU32Decoder()], + ]); +} + +export function getDepositForBurnInstructionDataCodec(): Codec< + DepositForBurnInstructionDataArgs, + DepositForBurnInstructionData +> { + return combineCodec( + getDepositForBurnInstructionDataEncoder(), + getDepositForBurnInstructionDataDecoder() + ); +} + +export type DepositForBurnAsyncInput< + TAccountOwner extends string = string, + TAccountEventRentPayer extends string = string, + TAccountSenderAuthorityPda extends string = string, + TAccountBurnTokenAccount extends string = string, + TAccountDenylistAccount extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountBurnTokenMint extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + eventRentPayer: TransactionSigner; + senderAuthorityPda?: Address; + burnTokenAccount: Address; + /** Account is denylisted if the account exists at the expected PDA. */ + denylistAccount?: Address; + messageTransmitter: Address; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken?: Address; + burnTokenMint: Address; + messageSentEventData: TransactionSigner; + messageTransmitterProgram?: Address; + tokenMessengerMinterProgram?: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + amount: DepositForBurnInstructionDataArgs['amount']; + destinationDomain: DepositForBurnInstructionDataArgs['destinationDomain']; + mintRecipient: DepositForBurnInstructionDataArgs['mintRecipient']; + destinationCaller: DepositForBurnInstructionDataArgs['destinationCaller']; + maxFee: DepositForBurnInstructionDataArgs['maxFee']; + minFinalityThreshold: DepositForBurnInstructionDataArgs['minFinalityThreshold']; +}; + +export async function getDepositForBurnInstructionAsync< + TAccountOwner extends string, + TAccountEventRentPayer extends string, + TAccountSenderAuthorityPda extends string, + TAccountBurnTokenAccount extends string, + TAccountDenylistAccount extends string, + TAccountMessageTransmitter extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountBurnTokenMint extends string, + TAccountMessageSentEventData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: DepositForBurnAsyncInput< + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountDenylistAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + DepositForBurnInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountDenylistAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, + senderAuthorityPda: { + value: input.senderAuthorityPda ?? null, + isWritable: false, + }, + burnTokenAccount: { + value: input.burnTokenAccount ?? null, + isWritable: true, + }, + denylistAccount: { + value: input.denylistAccount ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + burnTokenMint: { value: input.burnTokenMint ?? null, isWritable: true }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.senderAuthorityPda.value) { + accounts.senderAuthorityPda.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 115, 101, 110, 100, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, + 116, 121, + ]) + ), + ], + }); + } + if (!accounts.denylistAccount.value) { + accounts.denylistAccount.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 100, 101, 110, 121, 108, 105, 115, 116, 95, 97, 99, 99, 111, 117, + 110, 116, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.owner.value)), + ], + }); + } + if (!accounts.localToken.value) { + accounts.localToken.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([108, 111, 99, 97, 108, 95, 116, 111, 107, 101, 110]) + ), + getAddressEncoder().encode(expectAddress(accounts.burnTokenMint.value)), + ], + }); + } + if (!accounts.messageTransmitterProgram.value) { + accounts.messageTransmitterProgram.value = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; + } + if (!accounts.tokenMessengerMinterProgram.value) { + accounts.tokenMessengerMinterProgram.value = + 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.eventRentPayer), + getAccountMeta(accounts.senderAuthorityPda), + getAccountMeta(accounts.burnTokenAccount), + getAccountMeta(accounts.denylistAccount), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.burnTokenMint), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDepositForBurnInstructionDataEncoder().encode( + args as DepositForBurnInstructionDataArgs + ), + } as DepositForBurnInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountDenylistAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type DepositForBurnInput< + TAccountOwner extends string = string, + TAccountEventRentPayer extends string = string, + TAccountSenderAuthorityPda extends string = string, + TAccountBurnTokenAccount extends string = string, + TAccountDenylistAccount extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountBurnTokenMint extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + eventRentPayer: TransactionSigner; + senderAuthorityPda: Address; + burnTokenAccount: Address; + /** Account is denylisted if the account exists at the expected PDA. */ + denylistAccount: Address; + messageTransmitter: Address; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken: Address; + burnTokenMint: Address; + messageSentEventData: TransactionSigner; + messageTransmitterProgram?: Address; + tokenMessengerMinterProgram?: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + amount: DepositForBurnInstructionDataArgs['amount']; + destinationDomain: DepositForBurnInstructionDataArgs['destinationDomain']; + mintRecipient: DepositForBurnInstructionDataArgs['mintRecipient']; + destinationCaller: DepositForBurnInstructionDataArgs['destinationCaller']; + maxFee: DepositForBurnInstructionDataArgs['maxFee']; + minFinalityThreshold: DepositForBurnInstructionDataArgs['minFinalityThreshold']; +}; + +export function getDepositForBurnInstruction< + TAccountOwner extends string, + TAccountEventRentPayer extends string, + TAccountSenderAuthorityPda extends string, + TAccountBurnTokenAccount extends string, + TAccountDenylistAccount extends string, + TAccountMessageTransmitter extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountBurnTokenMint extends string, + TAccountMessageSentEventData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: DepositForBurnInput< + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountDenylistAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): DepositForBurnInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountDenylistAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, + senderAuthorityPda: { + value: input.senderAuthorityPda ?? null, + isWritable: false, + }, + burnTokenAccount: { + value: input.burnTokenAccount ?? null, + isWritable: true, + }, + denylistAccount: { + value: input.denylistAccount ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + burnTokenMint: { value: input.burnTokenMint ?? null, isWritable: true }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.messageTransmitterProgram.value) { + accounts.messageTransmitterProgram.value = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; + } + if (!accounts.tokenMessengerMinterProgram.value) { + accounts.tokenMessengerMinterProgram.value = + 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.eventRentPayer), + getAccountMeta(accounts.senderAuthorityPda), + getAccountMeta(accounts.burnTokenAccount), + getAccountMeta(accounts.denylistAccount), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.burnTokenMint), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDepositForBurnInstructionDataEncoder().encode( + args as DepositForBurnInstructionDataArgs + ), + } as DepositForBurnInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountDenylistAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedDepositForBurnInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + eventRentPayer: TAccountMetas[1]; + senderAuthorityPda: TAccountMetas[2]; + burnTokenAccount: TAccountMetas[3]; + /** Account is denylisted if the account exists at the expected PDA. */ + denylistAccount: TAccountMetas[4]; + messageTransmitter: TAccountMetas[5]; + tokenMessenger: TAccountMetas[6]; + remoteTokenMessenger: TAccountMetas[7]; + tokenMinter: TAccountMetas[8]; + localToken: TAccountMetas[9]; + burnTokenMint: TAccountMetas[10]; + messageSentEventData: TAccountMetas[11]; + messageTransmitterProgram: TAccountMetas[12]; + tokenMessengerMinterProgram: TAccountMetas[13]; + tokenProgram: TAccountMetas[14]; + systemProgram: TAccountMetas[15]; + eventAuthority: TAccountMetas[16]; + program: TAccountMetas[17]; + }; + data: DepositForBurnInstructionData; +}; + +export function parseDepositForBurnInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedDepositForBurnInstruction { + if (instruction.accounts.length < 18) { + // 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: { + owner: getNextAccount(), + eventRentPayer: getNextAccount(), + senderAuthorityPda: getNextAccount(), + burnTokenAccount: getNextAccount(), + denylistAccount: getNextAccount(), + messageTransmitter: getNextAccount(), + tokenMessenger: getNextAccount(), + remoteTokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + burnTokenMint: getNextAccount(), + messageSentEventData: getNextAccount(), + messageTransmitterProgram: getNextAccount(), + tokenMessengerMinterProgram: getNextAccount(), + tokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getDepositForBurnInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurnWithHook.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurnWithHook.ts new file mode 100644 index 000000000..321409ad2 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurnWithHook.ts @@ -0,0 +1,815 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { + expectAddress, + getAccountMetaFactory, + type ResolvedAccount, +} from '../shared'; + +export const DEPOSIT_FOR_BURN_WITH_HOOK_DISCRIMINATOR = new Uint8Array([ + 111, 245, 62, 131, 204, 108, 223, 155, +]); + +export function getDepositForBurnWithHookDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + DEPOSIT_FOR_BURN_WITH_HOOK_DISCRIMINATOR + ); +} + +export type DepositForBurnWithHookInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountEventRentPayer extends string | AccountMeta = string, + TAccountSenderAuthorityPda extends string | AccountMeta = string, + TAccountBurnTokenAccount extends string | AccountMeta = string, + TAccountDenylistAccount extends string | AccountMeta = string, + TAccountMessageTransmitter extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountRemoteTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountBurnTokenMint extends string | AccountMeta = string, + TAccountMessageSentEventData extends string | AccountMeta = string, + TAccountMessageTransmitterProgram extends string | AccountMeta = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC', + TAccountTokenMessengerMinterProgram extends string | AccountMeta = + 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe', + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountEventRentPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountEventRentPayer, + TAccountSenderAuthorityPda extends string + ? ReadonlyAccount + : TAccountSenderAuthorityPda, + TAccountBurnTokenAccount extends string + ? WritableAccount + : TAccountBurnTokenAccount, + TAccountDenylistAccount extends string + ? ReadonlyAccount + : TAccountDenylistAccount, + TAccountMessageTransmitter extends string + ? WritableAccount + : TAccountMessageTransmitter, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountRemoteTokenMessenger extends string + ? ReadonlyAccount + : TAccountRemoteTokenMessenger, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountBurnTokenMint extends string + ? WritableAccount + : TAccountBurnTokenMint, + TAccountMessageSentEventData extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountMessageSentEventData, + TAccountMessageTransmitterProgram extends string + ? ReadonlyAccount + : TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram extends string + ? ReadonlyAccount + : TAccountTokenMessengerMinterProgram, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type DepositForBurnWithHookInstructionData = { + discriminator: ReadonlyUint8Array; + amount: bigint; + destinationDomain: number; + mintRecipient: Address; + destinationCaller: Address; + maxFee: bigint; + minFinalityThreshold: number; + hookData: ReadonlyUint8Array; +}; + +export type DepositForBurnWithHookInstructionDataArgs = { + amount: number | bigint; + destinationDomain: number; + mintRecipient: Address; + destinationCaller: Address; + maxFee: number | bigint; + minFinalityThreshold: number; + hookData: ReadonlyUint8Array; +}; + +export function getDepositForBurnWithHookInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['amount', getU64Encoder()], + ['destinationDomain', getU32Encoder()], + ['mintRecipient', getAddressEncoder()], + ['destinationCaller', getAddressEncoder()], + ['maxFee', getU64Encoder()], + ['minFinalityThreshold', getU32Encoder()], + ['hookData', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]), + (value) => ({ + ...value, + discriminator: DEPOSIT_FOR_BURN_WITH_HOOK_DISCRIMINATOR, + }) + ); +} + +export function getDepositForBurnWithHookInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['amount', getU64Decoder()], + ['destinationDomain', getU32Decoder()], + ['mintRecipient', getAddressDecoder()], + ['destinationCaller', getAddressDecoder()], + ['maxFee', getU64Decoder()], + ['minFinalityThreshold', getU32Decoder()], + ['hookData', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getDepositForBurnWithHookInstructionDataCodec(): Codec< + DepositForBurnWithHookInstructionDataArgs, + DepositForBurnWithHookInstructionData +> { + return combineCodec( + getDepositForBurnWithHookInstructionDataEncoder(), + getDepositForBurnWithHookInstructionDataDecoder() + ); +} + +export type DepositForBurnWithHookAsyncInput< + TAccountOwner extends string = string, + TAccountEventRentPayer extends string = string, + TAccountSenderAuthorityPda extends string = string, + TAccountBurnTokenAccount extends string = string, + TAccountDenylistAccount extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountBurnTokenMint extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + eventRentPayer: TransactionSigner; + senderAuthorityPda?: Address; + burnTokenAccount: Address; + /** Account is denylisted if the account exists at the expected PDA. */ + denylistAccount?: Address; + messageTransmitter: Address; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken?: Address; + burnTokenMint: Address; + messageSentEventData: TransactionSigner; + messageTransmitterProgram?: Address; + tokenMessengerMinterProgram?: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + amount: DepositForBurnWithHookInstructionDataArgs['amount']; + destinationDomain: DepositForBurnWithHookInstructionDataArgs['destinationDomain']; + mintRecipient: DepositForBurnWithHookInstructionDataArgs['mintRecipient']; + destinationCaller: DepositForBurnWithHookInstructionDataArgs['destinationCaller']; + maxFee: DepositForBurnWithHookInstructionDataArgs['maxFee']; + minFinalityThreshold: DepositForBurnWithHookInstructionDataArgs['minFinalityThreshold']; + hookData: DepositForBurnWithHookInstructionDataArgs['hookData']; +}; + +export async function getDepositForBurnWithHookInstructionAsync< + TAccountOwner extends string, + TAccountEventRentPayer extends string, + TAccountSenderAuthorityPda extends string, + TAccountBurnTokenAccount extends string, + TAccountDenylistAccount extends string, + TAccountMessageTransmitter extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountBurnTokenMint extends string, + TAccountMessageSentEventData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: DepositForBurnWithHookAsyncInput< + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountDenylistAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + DepositForBurnWithHookInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountDenylistAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, + senderAuthorityPda: { + value: input.senderAuthorityPda ?? null, + isWritable: false, + }, + burnTokenAccount: { + value: input.burnTokenAccount ?? null, + isWritable: true, + }, + denylistAccount: { + value: input.denylistAccount ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + burnTokenMint: { value: input.burnTokenMint ?? null, isWritable: true }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.senderAuthorityPda.value) { + accounts.senderAuthorityPda.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 115, 101, 110, 100, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, + 116, 121, + ]) + ), + ], + }); + } + if (!accounts.denylistAccount.value) { + accounts.denylistAccount.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 100, 101, 110, 121, 108, 105, 115, 116, 95, 97, 99, 99, 111, 117, + 110, 116, + ]) + ), + getAddressEncoder().encode(expectAddress(accounts.owner.value)), + ], + }); + } + if (!accounts.localToken.value) { + accounts.localToken.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([108, 111, 99, 97, 108, 95, 116, 111, 107, 101, 110]) + ), + getAddressEncoder().encode(expectAddress(accounts.burnTokenMint.value)), + ], + }); + } + if (!accounts.messageTransmitterProgram.value) { + accounts.messageTransmitterProgram.value = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; + } + if (!accounts.tokenMessengerMinterProgram.value) { + accounts.tokenMessengerMinterProgram.value = + 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.eventRentPayer), + getAccountMeta(accounts.senderAuthorityPda), + getAccountMeta(accounts.burnTokenAccount), + getAccountMeta(accounts.denylistAccount), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.burnTokenMint), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDepositForBurnWithHookInstructionDataEncoder().encode( + args as DepositForBurnWithHookInstructionDataArgs + ), + } as DepositForBurnWithHookInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountDenylistAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type DepositForBurnWithHookInput< + TAccountOwner extends string = string, + TAccountEventRentPayer extends string = string, + TAccountSenderAuthorityPda extends string = string, + TAccountBurnTokenAccount extends string = string, + TAccountDenylistAccount extends string = string, + TAccountMessageTransmitter extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountBurnTokenMint extends string = string, + TAccountMessageSentEventData extends string = string, + TAccountMessageTransmitterProgram extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountTokenProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + eventRentPayer: TransactionSigner; + senderAuthorityPda: Address; + burnTokenAccount: Address; + /** Account is denylisted if the account exists at the expected PDA. */ + denylistAccount: Address; + messageTransmitter: Address; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken: Address; + burnTokenMint: Address; + messageSentEventData: TransactionSigner; + messageTransmitterProgram?: Address; + tokenMessengerMinterProgram?: Address; + tokenProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + amount: DepositForBurnWithHookInstructionDataArgs['amount']; + destinationDomain: DepositForBurnWithHookInstructionDataArgs['destinationDomain']; + mintRecipient: DepositForBurnWithHookInstructionDataArgs['mintRecipient']; + destinationCaller: DepositForBurnWithHookInstructionDataArgs['destinationCaller']; + maxFee: DepositForBurnWithHookInstructionDataArgs['maxFee']; + minFinalityThreshold: DepositForBurnWithHookInstructionDataArgs['minFinalityThreshold']; + hookData: DepositForBurnWithHookInstructionDataArgs['hookData']; +}; + +export function getDepositForBurnWithHookInstruction< + TAccountOwner extends string, + TAccountEventRentPayer extends string, + TAccountSenderAuthorityPda extends string, + TAccountBurnTokenAccount extends string, + TAccountDenylistAccount extends string, + TAccountMessageTransmitter extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountBurnTokenMint extends string, + TAccountMessageSentEventData extends string, + TAccountMessageTransmitterProgram extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountTokenProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: DepositForBurnWithHookInput< + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountDenylistAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): DepositForBurnWithHookInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountDenylistAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, + senderAuthorityPda: { + value: input.senderAuthorityPda ?? null, + isWritable: false, + }, + burnTokenAccount: { + value: input.burnTokenAccount ?? null, + isWritable: true, + }, + denylistAccount: { + value: input.denylistAccount ?? null, + isWritable: false, + }, + messageTransmitter: { + value: input.messageTransmitter ?? null, + isWritable: true, + }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + burnTokenMint: { value: input.burnTokenMint ?? null, isWritable: true }, + messageSentEventData: { + value: input.messageSentEventData ?? null, + isWritable: true, + }, + messageTransmitterProgram: { + value: input.messageTransmitterProgram ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.messageTransmitterProgram.value) { + accounts.messageTransmitterProgram.value = + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; + } + if (!accounts.tokenMessengerMinterProgram.value) { + accounts.tokenMessengerMinterProgram.value = + 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.eventRentPayer), + getAccountMeta(accounts.senderAuthorityPda), + getAccountMeta(accounts.burnTokenAccount), + getAccountMeta(accounts.denylistAccount), + getAccountMeta(accounts.messageTransmitter), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.burnTokenMint), + getAccountMeta(accounts.messageSentEventData), + getAccountMeta(accounts.messageTransmitterProgram), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getDepositForBurnWithHookInstructionDataEncoder().encode( + args as DepositForBurnWithHookInstructionDataArgs + ), + } as DepositForBurnWithHookInstruction< + TProgramAddress, + TAccountOwner, + TAccountEventRentPayer, + TAccountSenderAuthorityPda, + TAccountBurnTokenAccount, + TAccountDenylistAccount, + TAccountMessageTransmitter, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountBurnTokenMint, + TAccountMessageSentEventData, + TAccountMessageTransmitterProgram, + TAccountTokenMessengerMinterProgram, + TAccountTokenProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedDepositForBurnWithHookInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + eventRentPayer: TAccountMetas[1]; + senderAuthorityPda: TAccountMetas[2]; + burnTokenAccount: TAccountMetas[3]; + /** Account is denylisted if the account exists at the expected PDA. */ + denylistAccount: TAccountMetas[4]; + messageTransmitter: TAccountMetas[5]; + tokenMessenger: TAccountMetas[6]; + remoteTokenMessenger: TAccountMetas[7]; + tokenMinter: TAccountMetas[8]; + localToken: TAccountMetas[9]; + burnTokenMint: TAccountMetas[10]; + messageSentEventData: TAccountMetas[11]; + messageTransmitterProgram: TAccountMetas[12]; + tokenMessengerMinterProgram: TAccountMetas[13]; + tokenProgram: TAccountMetas[14]; + systemProgram: TAccountMetas[15]; + eventAuthority: TAccountMetas[16]; + program: TAccountMetas[17]; + }; + data: DepositForBurnWithHookInstructionData; +}; + +export function parseDepositForBurnWithHookInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedDepositForBurnWithHookInstruction { + if (instruction.accounts.length < 18) { + // 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: { + owner: getNextAccount(), + eventRentPayer: getNextAccount(), + senderAuthorityPda: getNextAccount(), + burnTokenAccount: getNextAccount(), + denylistAccount: getNextAccount(), + messageTransmitter: getNextAccount(), + tokenMessenger: getNextAccount(), + remoteTokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + burnTokenMint: getNextAccount(), + messageSentEventData: getNextAccount(), + messageTransmitterProgram: getNextAccount(), + tokenMessengerMinterProgram: getNextAccount(), + tokenProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getDepositForBurnWithHookInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveFinalizedMessage.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveFinalizedMessage.ts new file mode 100644 index 000000000..96630cc35 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveFinalizedMessage.ts @@ -0,0 +1,569 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +import { + getHandleReceiveMessageParamsDecoder, + getHandleReceiveMessageParamsEncoder, + type HandleReceiveMessageParams, + type HandleReceiveMessageParamsArgs, +} from '../types'; + +export const HANDLE_RECEIVE_FINALIZED_MESSAGE_DISCRIMINATOR = new Uint8Array([ + 186, 252, 239, 70, 86, 180, 110, 95, +]); + +export function getHandleReceiveFinalizedMessageDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + HANDLE_RECEIVE_FINALIZED_MESSAGE_DISCRIMINATOR + ); +} + +export type HandleReceiveFinalizedMessageInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountAuthorityPda extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountRemoteTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountTokenPair extends string | AccountMeta = string, + TAccountFeeRecipientTokenAccount extends string | AccountMeta = + string, + TAccountRecipientTokenAccount extends string | AccountMeta = string, + TAccountCustodyTokenAccount extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountAuthorityPda extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthorityPda, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountRemoteTokenMessenger extends string + ? ReadonlyAccount + : TAccountRemoteTokenMessenger, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountTokenPair extends string + ? ReadonlyAccount + : TAccountTokenPair, + TAccountFeeRecipientTokenAccount extends string + ? WritableAccount + : TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount extends string + ? WritableAccount + : TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount extends string + ? WritableAccount + : TAccountCustodyTokenAccount, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type HandleReceiveFinalizedMessageInstructionData = { + discriminator: ReadonlyUint8Array; + params: HandleReceiveMessageParams; +}; + +export type HandleReceiveFinalizedMessageInstructionDataArgs = { + params: HandleReceiveMessageParamsArgs; +}; + +export function getHandleReceiveFinalizedMessageInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['params', getHandleReceiveMessageParamsEncoder()], + ]), + (value) => ({ + ...value, + discriminator: HANDLE_RECEIVE_FINALIZED_MESSAGE_DISCRIMINATOR, + }) + ); +} + +export function getHandleReceiveFinalizedMessageInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['params', getHandleReceiveMessageParamsDecoder()], + ]); +} + +export function getHandleReceiveFinalizedMessageInstructionDataCodec(): Codec< + HandleReceiveFinalizedMessageInstructionDataArgs, + HandleReceiveFinalizedMessageInstructionData +> { + return combineCodec( + getHandleReceiveFinalizedMessageInstructionDataEncoder(), + getHandleReceiveFinalizedMessageInstructionDataDecoder() + ); +} + +export type HandleReceiveFinalizedMessageAsyncInput< + TAccountAuthorityPda extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountTokenPair extends string = string, + TAccountFeeRecipientTokenAccount extends string = string, + TAccountRecipientTokenAccount extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountTokenProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + authorityPda?: TransactionSigner; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken: Address; + tokenPair: Address; + feeRecipientTokenAccount: Address; + recipientTokenAccount: Address; + custodyTokenAccount: Address; + tokenProgram?: Address; + eventAuthority?: Address; + program: Address; + params: HandleReceiveFinalizedMessageInstructionDataArgs['params']; +}; + +export async function getHandleReceiveFinalizedMessageInstructionAsync< + TAccountAuthorityPda extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountTokenPair extends string, + TAccountFeeRecipientTokenAccount extends string, + TAccountRecipientTokenAccount extends string, + TAccountCustodyTokenAccount extends string, + TAccountTokenProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: HandleReceiveFinalizedMessageAsyncInput< + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + HandleReceiveFinalizedMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + authorityPda: { value: input.authorityPda ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + tokenPair: { value: input.tokenPair ?? null, isWritable: false }, + feeRecipientTokenAccount: { + value: input.feeRecipientTokenAccount ?? null, + isWritable: true, + }, + recipientTokenAccount: { + value: input.recipientTokenAccount ?? null, + isWritable: true, + }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.authorityPda.value) { + accounts.authorityPda.value = await getProgramDerivedAddress({ + programAddress: + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 109, 101, 115, 115, 97, 103, 101, 95, 116, 114, 97, 110, 115, 109, + 105, 116, 116, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, 116, + 121, + ]) + ), + getBytesEncoder().encode( + new Uint8Array([ + 166, 95, 200, 29, 15, 239, 168, 134, 12, 179, 184, 63, 8, 155, 2, + 36, 190, 138, 102, 135, 183, 174, 73, 245, 148, 192, 185, 180, 215, + 233, 56, 147, + ]) + ), + ], + }); + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.authorityPda), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.tokenPair), + getAccountMeta(accounts.feeRecipientTokenAccount), + getAccountMeta(accounts.recipientTokenAccount), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getHandleReceiveFinalizedMessageInstructionDataEncoder().encode( + args as HandleReceiveFinalizedMessageInstructionDataArgs + ), + } as HandleReceiveFinalizedMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type HandleReceiveFinalizedMessageInput< + TAccountAuthorityPda extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountTokenPair extends string = string, + TAccountFeeRecipientTokenAccount extends string = string, + TAccountRecipientTokenAccount extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountTokenProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + authorityPda: TransactionSigner; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken: Address; + tokenPair: Address; + feeRecipientTokenAccount: Address; + recipientTokenAccount: Address; + custodyTokenAccount: Address; + tokenProgram?: Address; + eventAuthority: Address; + program: Address; + params: HandleReceiveFinalizedMessageInstructionDataArgs['params']; +}; + +export function getHandleReceiveFinalizedMessageInstruction< + TAccountAuthorityPda extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountTokenPair extends string, + TAccountFeeRecipientTokenAccount extends string, + TAccountRecipientTokenAccount extends string, + TAccountCustodyTokenAccount extends string, + TAccountTokenProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: HandleReceiveFinalizedMessageInput< + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): HandleReceiveFinalizedMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + authorityPda: { value: input.authorityPda ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + tokenPair: { value: input.tokenPair ?? null, isWritable: false }, + feeRecipientTokenAccount: { + value: input.feeRecipientTokenAccount ?? null, + isWritable: true, + }, + recipientTokenAccount: { + value: input.recipientTokenAccount ?? null, + isWritable: true, + }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.authorityPda), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.tokenPair), + getAccountMeta(accounts.feeRecipientTokenAccount), + getAccountMeta(accounts.recipientTokenAccount), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getHandleReceiveFinalizedMessageInstructionDataEncoder().encode( + args as HandleReceiveFinalizedMessageInstructionDataArgs + ), + } as HandleReceiveFinalizedMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedHandleReceiveFinalizedMessageInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + authorityPda: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + remoteTokenMessenger: TAccountMetas[2]; + tokenMinter: TAccountMetas[3]; + localToken: TAccountMetas[4]; + tokenPair: TAccountMetas[5]; + feeRecipientTokenAccount: TAccountMetas[6]; + recipientTokenAccount: TAccountMetas[7]; + custodyTokenAccount: TAccountMetas[8]; + tokenProgram: TAccountMetas[9]; + eventAuthority: TAccountMetas[10]; + program: TAccountMetas[11]; + }; + data: HandleReceiveFinalizedMessageInstructionData; +}; + +export function parseHandleReceiveFinalizedMessageInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedHandleReceiveFinalizedMessageInstruction { + if (instruction.accounts.length < 12) { + // 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: { + authorityPda: getNextAccount(), + tokenMessenger: getNextAccount(), + remoteTokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + tokenPair: getNextAccount(), + feeRecipientTokenAccount: getNextAccount(), + recipientTokenAccount: getNextAccount(), + custodyTokenAccount: getNextAccount(), + tokenProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getHandleReceiveFinalizedMessageInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveUnfinalizedMessage.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveUnfinalizedMessage.ts new file mode 100644 index 000000000..5a18b9f6a --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveUnfinalizedMessage.ts @@ -0,0 +1,569 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; +import { + getHandleReceiveMessageParamsDecoder, + getHandleReceiveMessageParamsEncoder, + type HandleReceiveMessageParams, + type HandleReceiveMessageParamsArgs, +} from '../types'; + +export const HANDLE_RECEIVE_UNFINALIZED_MESSAGE_DISCRIMINATOR = new Uint8Array([ + 200, 169, 175, 20, 200, 58, 182, 61, +]); + +export function getHandleReceiveUnfinalizedMessageDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + HANDLE_RECEIVE_UNFINALIZED_MESSAGE_DISCRIMINATOR + ); +} + +export type HandleReceiveUnfinalizedMessageInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountAuthorityPda extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountRemoteTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountTokenPair extends string | AccountMeta = string, + TAccountFeeRecipientTokenAccount extends string | AccountMeta = + string, + TAccountRecipientTokenAccount extends string | AccountMeta = string, + TAccountCustodyTokenAccount extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountAuthorityPda extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountAuthorityPda, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountRemoteTokenMessenger extends string + ? ReadonlyAccount + : TAccountRemoteTokenMessenger, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountTokenPair extends string + ? ReadonlyAccount + : TAccountTokenPair, + TAccountFeeRecipientTokenAccount extends string + ? WritableAccount + : TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount extends string + ? WritableAccount + : TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount extends string + ? WritableAccount + : TAccountCustodyTokenAccount, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type HandleReceiveUnfinalizedMessageInstructionData = { + discriminator: ReadonlyUint8Array; + params: HandleReceiveMessageParams; +}; + +export type HandleReceiveUnfinalizedMessageInstructionDataArgs = { + params: HandleReceiveMessageParamsArgs; +}; + +export function getHandleReceiveUnfinalizedMessageInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['params', getHandleReceiveMessageParamsEncoder()], + ]), + (value) => ({ + ...value, + discriminator: HANDLE_RECEIVE_UNFINALIZED_MESSAGE_DISCRIMINATOR, + }) + ); +} + +export function getHandleReceiveUnfinalizedMessageInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['params', getHandleReceiveMessageParamsDecoder()], + ]); +} + +export function getHandleReceiveUnfinalizedMessageInstructionDataCodec(): Codec< + HandleReceiveUnfinalizedMessageInstructionDataArgs, + HandleReceiveUnfinalizedMessageInstructionData +> { + return combineCodec( + getHandleReceiveUnfinalizedMessageInstructionDataEncoder(), + getHandleReceiveUnfinalizedMessageInstructionDataDecoder() + ); +} + +export type HandleReceiveUnfinalizedMessageAsyncInput< + TAccountAuthorityPda extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountTokenPair extends string = string, + TAccountFeeRecipientTokenAccount extends string = string, + TAccountRecipientTokenAccount extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountTokenProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + authorityPda?: TransactionSigner; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken: Address; + tokenPair: Address; + feeRecipientTokenAccount: Address; + recipientTokenAccount: Address; + custodyTokenAccount: Address; + tokenProgram?: Address; + eventAuthority?: Address; + program: Address; + params: HandleReceiveUnfinalizedMessageInstructionDataArgs['params']; +}; + +export async function getHandleReceiveUnfinalizedMessageInstructionAsync< + TAccountAuthorityPda extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountTokenPair extends string, + TAccountFeeRecipientTokenAccount extends string, + TAccountRecipientTokenAccount extends string, + TAccountCustodyTokenAccount extends string, + TAccountTokenProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: HandleReceiveUnfinalizedMessageAsyncInput< + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + HandleReceiveUnfinalizedMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + authorityPda: { value: input.authorityPda ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + tokenPair: { value: input.tokenPair ?? null, isWritable: false }, + feeRecipientTokenAccount: { + value: input.feeRecipientTokenAccount ?? null, + isWritable: true, + }, + recipientTokenAccount: { + value: input.recipientTokenAccount ?? null, + isWritable: true, + }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.authorityPda.value) { + accounts.authorityPda.value = await getProgramDerivedAddress({ + programAddress: + 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 109, 101, 115, 115, 97, 103, 101, 95, 116, 114, 97, 110, 115, 109, + 105, 116, 116, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, 116, + 121, + ]) + ), + getBytesEncoder().encode( + new Uint8Array([ + 166, 95, 200, 29, 15, 239, 168, 134, 12, 179, 184, 63, 8, 155, 2, + 36, 190, 138, 102, 135, 183, 174, 73, 245, 148, 192, 185, 180, 215, + 233, 56, 147, + ]) + ), + ], + }); + } + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.authorityPda), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.tokenPair), + getAccountMeta(accounts.feeRecipientTokenAccount), + getAccountMeta(accounts.recipientTokenAccount), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getHandleReceiveUnfinalizedMessageInstructionDataEncoder().encode( + args as HandleReceiveUnfinalizedMessageInstructionDataArgs + ), + } as HandleReceiveUnfinalizedMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type HandleReceiveUnfinalizedMessageInput< + TAccountAuthorityPda extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountTokenPair extends string = string, + TAccountFeeRecipientTokenAccount extends string = string, + TAccountRecipientTokenAccount extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountTokenProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + authorityPda: TransactionSigner; + tokenMessenger: Address; + remoteTokenMessenger: Address; + tokenMinter: Address; + localToken: Address; + tokenPair: Address; + feeRecipientTokenAccount: Address; + recipientTokenAccount: Address; + custodyTokenAccount: Address; + tokenProgram?: Address; + eventAuthority: Address; + program: Address; + params: HandleReceiveUnfinalizedMessageInstructionDataArgs['params']; +}; + +export function getHandleReceiveUnfinalizedMessageInstruction< + TAccountAuthorityPda extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountTokenPair extends string, + TAccountFeeRecipientTokenAccount extends string, + TAccountRecipientTokenAccount extends string, + TAccountCustodyTokenAccount extends string, + TAccountTokenProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: HandleReceiveUnfinalizedMessageInput< + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): HandleReceiveUnfinalizedMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + authorityPda: { value: input.authorityPda ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + tokenPair: { value: input.tokenPair ?? null, isWritable: false }, + feeRecipientTokenAccount: { + value: input.feeRecipientTokenAccount ?? null, + isWritable: true, + }, + recipientTokenAccount: { + value: input.recipientTokenAccount ?? null, + isWritable: true, + }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.authorityPda), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.tokenPair), + getAccountMeta(accounts.feeRecipientTokenAccount), + getAccountMeta(accounts.recipientTokenAccount), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getHandleReceiveUnfinalizedMessageInstructionDataEncoder().encode( + args as HandleReceiveUnfinalizedMessageInstructionDataArgs + ), + } as HandleReceiveUnfinalizedMessageInstruction< + TProgramAddress, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountTokenMinter, + TAccountLocalToken, + TAccountTokenPair, + TAccountFeeRecipientTokenAccount, + TAccountRecipientTokenAccount, + TAccountCustodyTokenAccount, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedHandleReceiveUnfinalizedMessageInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + authorityPda: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + remoteTokenMessenger: TAccountMetas[2]; + tokenMinter: TAccountMetas[3]; + localToken: TAccountMetas[4]; + tokenPair: TAccountMetas[5]; + feeRecipientTokenAccount: TAccountMetas[6]; + recipientTokenAccount: TAccountMetas[7]; + custodyTokenAccount: TAccountMetas[8]; + tokenProgram: TAccountMetas[9]; + eventAuthority: TAccountMetas[10]; + program: TAccountMetas[11]; + }; + data: HandleReceiveUnfinalizedMessageInstructionData; +}; + +export function parseHandleReceiveUnfinalizedMessageInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedHandleReceiveUnfinalizedMessageInstruction { + if (instruction.accounts.length < 12) { + // 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: { + authorityPda: getNextAccount(), + tokenMessenger: getNextAccount(), + remoteTokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + tokenPair: getNextAccount(), + feeRecipientTokenAccount: getNextAccount(), + recipientTokenAccount: getNextAccount(), + custodyTokenAccount: getNextAccount(), + tokenProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getHandleReceiveUnfinalizedMessageInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/index.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/index.ts new file mode 100644 index 000000000..c62b1d984 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/index.ts @@ -0,0 +1,33 @@ +/** + * 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 './acceptOwnership'; +export * from './addLocalToken'; +export * from './addRemoteTokenMessenger'; +export * from './burnTokenCustody'; +export * from './denylistAccount'; +export * from './depositForBurn'; +export * from './depositForBurnWithHook'; +export * from './handleReceiveFinalizedMessage'; +export * from './handleReceiveUnfinalizedMessage'; +export * from './initialize'; +export * from './linkTokenPair'; +export * from './pause'; +export * from './removeLocalToken'; +export * from './removeRemoteTokenMessenger'; +export * from './setFeeRecipient'; +export * from './setMaxBurnAmountPerMessage'; +export * from './setMinFee'; +export * from './setMinFeeController'; +export * from './setTokenController'; +export * from './transferOwnership'; +export * from './undenylistAccount'; +export * from './unlinkTokenPair'; +export * from './unpause'; +export * from './updateDenylister'; +export * from './updatePauser'; diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/initialize.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/initialize.ts new file mode 100644 index 000000000..64e38ddfb --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/initialize.ts @@ -0,0 +1,567 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const INITIALIZE_DISCRIMINATOR = new Uint8Array([ + 175, 175, 109, 31, 13, 152, 155, 237, +]); + +export function getInitializeDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_DISCRIMINATOR); +} + +export type InitializeInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountUpgradeAuthority extends string | AccountMeta = string, + TAccountAuthorityPda extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountTokenMessengerMinterProgramData extends string | AccountMeta = + string, + TAccountTokenMessengerMinterProgram extends string | AccountMeta = + 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe', + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountUpgradeAuthority extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountUpgradeAuthority, + TAccountAuthorityPda extends string + ? ReadonlyAccount + : TAccountAuthorityPda, + TAccountTokenMessenger extends string + ? WritableAccount + : TAccountTokenMessenger, + TAccountTokenMinter extends string + ? WritableAccount + : TAccountTokenMinter, + TAccountTokenMessengerMinterProgramData extends string + ? ReadonlyAccount + : TAccountTokenMessengerMinterProgramData, + TAccountTokenMessengerMinterProgram extends string + ? ReadonlyAccount + : TAccountTokenMessengerMinterProgram, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type InitializeInstructionData = { + discriminator: ReadonlyUint8Array; + tokenController: Address; + denylister: Address; + feeRecipient: Address; + minFeeController: Address; + minFee: number; + messageBodyVersion: number; +}; + +export type InitializeInstructionDataArgs = { + tokenController: Address; + denylister: Address; + feeRecipient: Address; + minFeeController: Address; + minFee: number; + messageBodyVersion: number; +}; + +export function getInitializeInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['tokenController', getAddressEncoder()], + ['denylister', getAddressEncoder()], + ['feeRecipient', getAddressEncoder()], + ['minFeeController', getAddressEncoder()], + ['minFee', getU32Encoder()], + ['messageBodyVersion', getU32Encoder()], + ]), + (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) + ); +} + +export function getInitializeInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['tokenController', getAddressDecoder()], + ['denylister', getAddressDecoder()], + ['feeRecipient', getAddressDecoder()], + ['minFeeController', getAddressDecoder()], + ['minFee', getU32Decoder()], + ['messageBodyVersion', getU32Decoder()], + ]); +} + +export function getInitializeInstructionDataCodec(): Codec< + InitializeInstructionDataArgs, + InitializeInstructionData +> { + return combineCodec( + getInitializeInstructionDataEncoder(), + getInitializeInstructionDataDecoder() + ); +} + +export type InitializeAsyncInput< + TAccountPayer extends string = string, + TAccountUpgradeAuthority extends string = string, + TAccountAuthorityPda extends string = string, + TAccountTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountTokenMessengerMinterProgramData extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + upgradeAuthority: TransactionSigner; + authorityPda?: Address; + tokenMessenger?: Address; + tokenMinter?: Address; + tokenMessengerMinterProgramData: Address; + tokenMessengerMinterProgram?: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + tokenController: InitializeInstructionDataArgs['tokenController']; + denylister: InitializeInstructionDataArgs['denylister']; + feeRecipient: InitializeInstructionDataArgs['feeRecipient']; + minFeeController: InitializeInstructionDataArgs['minFeeController']; + minFee: InitializeInstructionDataArgs['minFee']; + messageBodyVersion: InitializeInstructionDataArgs['messageBodyVersion']; +}; + +export async function getInitializeInstructionAsync< + TAccountPayer extends string, + TAccountUpgradeAuthority extends string, + TAccountAuthorityPda extends string, + TAccountTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountTokenMessengerMinterProgramData extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: InitializeAsyncInput< + TAccountPayer, + TAccountUpgradeAuthority, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountTokenMessengerMinterProgramData, + TAccountTokenMessengerMinterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + InitializeInstruction< + TProgramAddress, + TAccountPayer, + TAccountUpgradeAuthority, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountTokenMessengerMinterProgramData, + TAccountTokenMessengerMinterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + upgradeAuthority: { + value: input.upgradeAuthority ?? null, + isWritable: false, + }, + authorityPda: { value: input.authorityPda ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + tokenMessengerMinterProgramData: { + value: input.tokenMessengerMinterProgramData ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.authorityPda.value) { + accounts.authorityPda.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 115, 101, 110, 100, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, + 116, 121, + ]) + ), + ], + }); + } + if (!accounts.tokenMessenger.value) { + accounts.tokenMessenger.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 116, 111, 107, 101, 110, 95, 109, 101, 115, 115, 101, 110, 103, 101, + 114, + ]) + ), + ], + }); + } + if (!accounts.tokenMinter.value) { + accounts.tokenMinter.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 116, 111, 107, 101, 110, 95, 109, 105, 110, 116, 101, 114, + ]) + ), + ], + }); + } + if (!accounts.tokenMessengerMinterProgram.value) { + accounts.tokenMessengerMinterProgram.value = + 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.upgradeAuthority), + getAccountMeta(accounts.authorityPda), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.tokenMessengerMinterProgramData), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getInitializeInstructionDataEncoder().encode( + args as InitializeInstructionDataArgs + ), + } as InitializeInstruction< + TProgramAddress, + TAccountPayer, + TAccountUpgradeAuthority, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountTokenMessengerMinterProgramData, + TAccountTokenMessengerMinterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type InitializeInput< + TAccountPayer extends string = string, + TAccountUpgradeAuthority extends string = string, + TAccountAuthorityPda extends string = string, + TAccountTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountTokenMessengerMinterProgramData extends string = string, + TAccountTokenMessengerMinterProgram extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + upgradeAuthority: TransactionSigner; + authorityPda: Address; + tokenMessenger: Address; + tokenMinter: Address; + tokenMessengerMinterProgramData: Address; + tokenMessengerMinterProgram?: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + tokenController: InitializeInstructionDataArgs['tokenController']; + denylister: InitializeInstructionDataArgs['denylister']; + feeRecipient: InitializeInstructionDataArgs['feeRecipient']; + minFeeController: InitializeInstructionDataArgs['minFeeController']; + minFee: InitializeInstructionDataArgs['minFee']; + messageBodyVersion: InitializeInstructionDataArgs['messageBodyVersion']; +}; + +export function getInitializeInstruction< + TAccountPayer extends string, + TAccountUpgradeAuthority extends string, + TAccountAuthorityPda extends string, + TAccountTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountTokenMessengerMinterProgramData extends string, + TAccountTokenMessengerMinterProgram extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: InitializeInput< + TAccountPayer, + TAccountUpgradeAuthority, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountTokenMessengerMinterProgramData, + TAccountTokenMessengerMinterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): InitializeInstruction< + TProgramAddress, + TAccountPayer, + TAccountUpgradeAuthority, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountTokenMessengerMinterProgramData, + TAccountTokenMessengerMinterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + upgradeAuthority: { + value: input.upgradeAuthority ?? null, + isWritable: false, + }, + authorityPda: { value: input.authorityPda ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + tokenMessengerMinterProgramData: { + value: input.tokenMessengerMinterProgramData ?? null, + isWritable: false, + }, + tokenMessengerMinterProgram: { + value: input.tokenMessengerMinterProgram ?? null, + isWritable: false, + }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.tokenMessengerMinterProgram.value) { + accounts.tokenMessengerMinterProgram.value = + 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; + } + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.upgradeAuthority), + getAccountMeta(accounts.authorityPda), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.tokenMessengerMinterProgramData), + getAccountMeta(accounts.tokenMessengerMinterProgram), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getInitializeInstructionDataEncoder().encode( + args as InitializeInstructionDataArgs + ), + } as InitializeInstruction< + TProgramAddress, + TAccountPayer, + TAccountUpgradeAuthority, + TAccountAuthorityPda, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountTokenMessengerMinterProgramData, + TAccountTokenMessengerMinterProgram, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedInitializeInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + upgradeAuthority: TAccountMetas[1]; + authorityPda: TAccountMetas[2]; + tokenMessenger: TAccountMetas[3]; + tokenMinter: TAccountMetas[4]; + tokenMessengerMinterProgramData: TAccountMetas[5]; + tokenMessengerMinterProgram: TAccountMetas[6]; + systemProgram: TAccountMetas[7]; + eventAuthority: TAccountMetas[8]; + program: TAccountMetas[9]; + }; + data: InitializeInstructionData; +}; + +export function parseInitializeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedInitializeInstruction { + if (instruction.accounts.length < 10) { + // 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: { + payer: getNextAccount(), + upgradeAuthority: getNextAccount(), + authorityPda: getNextAccount(), + tokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + tokenMessengerMinterProgramData: getNextAccount(), + tokenMessengerMinterProgram: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getInitializeInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/linkTokenPair.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/linkTokenPair.ts new file mode 100644 index 000000000..b71c69dc0 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/linkTokenPair.ts @@ -0,0 +1,425 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const LINK_TOKEN_PAIR_DISCRIMINATOR = new Uint8Array([ + 68, 162, 24, 104, 125, 46, 130, 12, +]); + +export function getLinkTokenPairDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + LINK_TOKEN_PAIR_DISCRIMINATOR + ); +} + +export type LinkTokenPairInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountTokenController extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountTokenPair extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountTokenController extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountTokenController, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountTokenPair extends string + ? WritableAccount + : TAccountTokenPair, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type LinkTokenPairInstructionData = { + discriminator: ReadonlyUint8Array; + localToken: Address; + remoteDomain: number; + remoteToken: Address; +}; + +export type LinkTokenPairInstructionDataArgs = { + localToken: Address; + remoteDomain: number; + remoteToken: Address; +}; + +export function getLinkTokenPairInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['localToken', getAddressEncoder()], + ['remoteDomain', getU32Encoder()], + ['remoteToken', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: LINK_TOKEN_PAIR_DISCRIMINATOR }) + ); +} + +export function getLinkTokenPairInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['localToken', getAddressDecoder()], + ['remoteDomain', getU32Decoder()], + ['remoteToken', getAddressDecoder()], + ]); +} + +export function getLinkTokenPairInstructionDataCodec(): Codec< + LinkTokenPairInstructionDataArgs, + LinkTokenPairInstructionData +> { + return combineCodec( + getLinkTokenPairInstructionDataEncoder(), + getLinkTokenPairInstructionDataDecoder() + ); +} + +export type LinkTokenPairAsyncInput< + TAccountPayer extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountTokenPair extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + tokenPair: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + localToken: LinkTokenPairInstructionDataArgs['localToken']; + remoteDomain: LinkTokenPairInstructionDataArgs['remoteDomain']; + remoteToken: LinkTokenPairInstructionDataArgs['remoteToken']; +}; + +export async function getLinkTokenPairInstructionAsync< + TAccountPayer extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountTokenPair extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: LinkTokenPairAsyncInput< + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + LinkTokenPairInstruction< + TProgramAddress, + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + tokenPair: { value: input.tokenPair ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.tokenPair), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getLinkTokenPairInstructionDataEncoder().encode( + args as LinkTokenPairInstructionDataArgs + ), + } as LinkTokenPairInstruction< + TProgramAddress, + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type LinkTokenPairInput< + TAccountPayer extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountTokenPair extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + tokenPair: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + localToken: LinkTokenPairInstructionDataArgs['localToken']; + remoteDomain: LinkTokenPairInstructionDataArgs['remoteDomain']; + remoteToken: LinkTokenPairInstructionDataArgs['remoteToken']; +}; + +export function getLinkTokenPairInstruction< + TAccountPayer extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountTokenPair extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: LinkTokenPairInput< + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): LinkTokenPairInstruction< + TProgramAddress, + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + tokenPair: { value: input.tokenPair ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.tokenPair), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getLinkTokenPairInstructionDataEncoder().encode( + args as LinkTokenPairInstructionDataArgs + ), + } as LinkTokenPairInstruction< + TProgramAddress, + TAccountPayer, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedLinkTokenPairInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + tokenController: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + tokenPair: TAccountMetas[3]; + systemProgram: TAccountMetas[4]; + eventAuthority: TAccountMetas[5]; + program: TAccountMetas[6]; + }; + data: LinkTokenPairInstructionData; +}; + +export function parseLinkTokenPairInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedLinkTokenPairInstruction { + if (instruction.accounts.length < 7) { + // 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: { + payer: getNextAccount(), + tokenController: getNextAccount(), + tokenMinter: getNextAccount(), + tokenPair: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getLinkTokenPairInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/pause.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/pause.ts new file mode 100644 index 000000000..c74faf922 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/pause.ts @@ -0,0 +1,301 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const PAUSE_DISCRIMINATOR = new Uint8Array([ + 211, 22, 221, 251, 74, 121, 193, 47, +]); + +export function getPauseDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(PAUSE_DISCRIMINATOR); +} + +export type PauseInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountPauser extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPauser extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountPauser, + TAccountTokenMinter extends string + ? WritableAccount + : TAccountTokenMinter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type PauseInstructionData = { discriminator: ReadonlyUint8Array }; + +export type PauseInstructionDataArgs = {}; + +export function getPauseInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: PAUSE_DISCRIMINATOR }) + ); +} + +export function getPauseInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getPauseInstructionDataCodec(): Codec< + PauseInstructionDataArgs, + PauseInstructionData +> { + return combineCodec( + getPauseInstructionDataEncoder(), + getPauseInstructionDataDecoder() + ); +} + +export type PauseAsyncInput< + TAccountPauser extends string = string, + TAccountTokenMinter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pauser: TransactionSigner; + tokenMinter: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getPauseInstructionAsync< + TAccountPauser extends string, + TAccountTokenMinter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: PauseAsyncInput< + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + PauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pauser: { value: input.pauser ?? null, isWritable: false }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pauser), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getPauseInstructionDataEncoder().encode({}), + } as PauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type PauseInput< + TAccountPauser extends string = string, + TAccountTokenMinter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pauser: TransactionSigner; + tokenMinter: Address; + eventAuthority: Address; + program: Address; +}; + +export function getPauseInstruction< + TAccountPauser extends string, + TAccountTokenMinter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: PauseInput< + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): PauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pauser: { value: input.pauser ?? null, isWritable: false }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pauser), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getPauseInstructionDataEncoder().encode({}), + } as PauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedPauseInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + pauser: TAccountMetas[0]; + tokenMinter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: PauseInstructionData; +}; + +export function parsePauseInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedPauseInstruction { + if (instruction.accounts.length < 4) { + // 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: { + pauser: getNextAccount(), + tokenMinter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getPauseInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/removeLocalToken.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/removeLocalToken.ts new file mode 100644 index 000000000..7977fc73f --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/removeLocalToken.ts @@ -0,0 +1,446 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const REMOVE_LOCAL_TOKEN_DISCRIMINATOR = new Uint8Array([ + 27, 43, 66, 170, 188, 44, 109, 97, +]); + +export function getRemoveLocalTokenDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REMOVE_LOCAL_TOKEN_DISCRIMINATOR + ); +} + +export type RemoveLocalTokenInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountPayee extends string | AccountMeta = string, + TAccountTokenController extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountCustodyTokenAccount extends string | AccountMeta = string, + TAccountCustodyTokenMint extends string | AccountMeta = string, + TAccountTokenProgram extends string | AccountMeta = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayee extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayee, + TAccountTokenController extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountTokenController, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountCustodyTokenAccount extends string + ? WritableAccount + : TAccountCustodyTokenAccount, + TAccountCustodyTokenMint extends string + ? WritableAccount + : TAccountCustodyTokenMint, + TAccountTokenProgram extends string + ? ReadonlyAccount + : TAccountTokenProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type RemoveLocalTokenInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type RemoveLocalTokenInstructionDataArgs = {}; + +export function getRemoveLocalTokenInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: REMOVE_LOCAL_TOKEN_DISCRIMINATOR }) + ); +} + +export function getRemoveLocalTokenInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getRemoveLocalTokenInstructionDataCodec(): Codec< + RemoveLocalTokenInstructionDataArgs, + RemoveLocalTokenInstructionData +> { + return combineCodec( + getRemoveLocalTokenInstructionDataEncoder(), + getRemoveLocalTokenInstructionDataDecoder() + ); +} + +export type RemoveLocalTokenAsyncInput< + TAccountPayee extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountCustodyTokenMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payee: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + localToken: Address; + custodyTokenAccount: Address; + custodyTokenMint: Address; + tokenProgram?: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getRemoveLocalTokenInstructionAsync< + TAccountPayee extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountCustodyTokenAccount extends string, + TAccountCustodyTokenMint extends string, + TAccountTokenProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: RemoveLocalTokenAsyncInput< + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + RemoveLocalTokenInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + custodyTokenMint: { + value: input.custodyTokenMint ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.custodyTokenMint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getRemoveLocalTokenInstructionDataEncoder().encode({}), + } as RemoveLocalTokenInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type RemoveLocalTokenInput< + TAccountPayee extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountCustodyTokenAccount extends string = string, + TAccountCustodyTokenMint extends string = string, + TAccountTokenProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payee: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + localToken: Address; + custodyTokenAccount: Address; + custodyTokenMint: Address; + tokenProgram?: Address; + eventAuthority: Address; + program: Address; +}; + +export function getRemoveLocalTokenInstruction< + TAccountPayee extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountCustodyTokenAccount extends string, + TAccountCustodyTokenMint extends string, + TAccountTokenProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: RemoveLocalTokenInput< + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): RemoveLocalTokenInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + custodyTokenAccount: { + value: input.custodyTokenAccount ?? null, + isWritable: true, + }, + custodyTokenMint: { + value: input.custodyTokenMint ?? null, + isWritable: true, + }, + tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.tokenProgram.value) { + accounts.tokenProgram.value = + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.custodyTokenAccount), + getAccountMeta(accounts.custodyTokenMint), + getAccountMeta(accounts.tokenProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getRemoveLocalTokenInstructionDataEncoder().encode({}), + } as RemoveLocalTokenInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountCustodyTokenAccount, + TAccountCustodyTokenMint, + TAccountTokenProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedRemoveLocalTokenInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payee: TAccountMetas[0]; + tokenController: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + localToken: TAccountMetas[3]; + custodyTokenAccount: TAccountMetas[4]; + custodyTokenMint: TAccountMetas[5]; + tokenProgram: TAccountMetas[6]; + eventAuthority: TAccountMetas[7]; + program: TAccountMetas[8]; + }; + data: RemoveLocalTokenInstructionData; +}; + +export function parseRemoveLocalTokenInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedRemoveLocalTokenInstruction { + if (instruction.accounts.length < 9) { + // 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: { + payee: getNextAccount(), + tokenController: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + custodyTokenAccount: getNextAccount(), + custodyTokenMint: getNextAccount(), + tokenProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getRemoveLocalTokenInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/removeRemoteTokenMessenger.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/removeRemoteTokenMessenger.ts new file mode 100644 index 000000000..c62e19a40 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/removeRemoteTokenMessenger.ts @@ -0,0 +1,362 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const REMOVE_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ + 65, 114, 66, 85, 169, 98, 177, 146, +]); + +export function getRemoveRemoteTokenMessengerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + REMOVE_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR + ); +} + +export type RemoveRemoteTokenMessengerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountPayee extends string | AccountMeta = string, + TAccountOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountRemoteTokenMessenger extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayee extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayee, + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountRemoteTokenMessenger extends string + ? WritableAccount + : TAccountRemoteTokenMessenger, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type RemoveRemoteTokenMessengerInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type RemoveRemoteTokenMessengerInstructionDataArgs = {}; + +export function getRemoveRemoteTokenMessengerInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ + ...value, + discriminator: REMOVE_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR, + }) + ); +} + +export function getRemoveRemoteTokenMessengerInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getRemoveRemoteTokenMessengerInstructionDataCodec(): Codec< + RemoveRemoteTokenMessengerInstructionDataArgs, + RemoveRemoteTokenMessengerInstructionData +> { + return combineCodec( + getRemoveRemoteTokenMessengerInstructionDataEncoder(), + getRemoveRemoteTokenMessengerInstructionDataDecoder() + ); +} + +export type RemoveRemoteTokenMessengerAsyncInput< + TAccountPayee extends string = string, + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payee: TransactionSigner; + owner: TransactionSigner; + tokenMessenger: Address; + remoteTokenMessenger: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getRemoveRemoteTokenMessengerInstructionAsync< + TAccountPayee extends string, + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: RemoveRemoteTokenMessengerAsyncInput< + TAccountPayee, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + RemoveRemoteTokenMessengerInstruction< + TProgramAddress, + TAccountPayee, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getRemoveRemoteTokenMessengerInstructionDataEncoder().encode({}), + } as RemoveRemoteTokenMessengerInstruction< + TProgramAddress, + TAccountPayee, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type RemoveRemoteTokenMessengerInput< + TAccountPayee extends string = string, + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountRemoteTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payee: TransactionSigner; + owner: TransactionSigner; + tokenMessenger: Address; + remoteTokenMessenger: Address; + eventAuthority: Address; + program: Address; +}; + +export function getRemoveRemoteTokenMessengerInstruction< + TAccountPayee extends string, + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountRemoteTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: RemoveRemoteTokenMessengerInput< + TAccountPayee, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): RemoveRemoteTokenMessengerInstruction< + TProgramAddress, + TAccountPayee, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + remoteTokenMessenger: { + value: input.remoteTokenMessenger ?? null, + isWritable: true, + }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.remoteTokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getRemoveRemoteTokenMessengerInstructionDataEncoder().encode({}), + } as RemoveRemoteTokenMessengerInstruction< + TProgramAddress, + TAccountPayee, + TAccountOwner, + TAccountTokenMessenger, + TAccountRemoteTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedRemoveRemoteTokenMessengerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payee: TAccountMetas[0]; + owner: TAccountMetas[1]; + tokenMessenger: TAccountMetas[2]; + remoteTokenMessenger: TAccountMetas[3]; + eventAuthority: TAccountMetas[4]; + program: TAccountMetas[5]; + }; + data: RemoveRemoteTokenMessengerInstructionData; +}; + +export function parseRemoveRemoteTokenMessengerInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedRemoveRemoteTokenMessengerInstruction { + if (instruction.accounts.length < 6) { + // 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: { + payee: getNextAccount(), + owner: getNextAccount(), + tokenMessenger: getNextAccount(), + remoteTokenMessenger: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getRemoveRemoteTokenMessengerInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/setFeeRecipient.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/setFeeRecipient.ts new file mode 100644 index 000000000..1249199fc --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/setFeeRecipient.ts @@ -0,0 +1,324 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_FEE_RECIPIENT_DISCRIMINATOR = new Uint8Array([ + 227, 18, 215, 42, 237, 246, 151, 66, +]); + +export function getSetFeeRecipientDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_FEE_RECIPIENT_DISCRIMINATOR + ); +} + +export type SetFeeRecipientInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountTokenMessenger extends string + ? WritableAccount + : TAccountTokenMessenger, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type SetFeeRecipientInstructionData = { + discriminator: ReadonlyUint8Array; + newFeeRecipient: Address; +}; + +export type SetFeeRecipientInstructionDataArgs = { newFeeRecipient: Address }; + +export function getSetFeeRecipientInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newFeeRecipient', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: SET_FEE_RECIPIENT_DISCRIMINATOR }) + ); +} + +export function getSetFeeRecipientInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newFeeRecipient', getAddressDecoder()], + ]); +} + +export function getSetFeeRecipientInstructionDataCodec(): Codec< + SetFeeRecipientInstructionDataArgs, + SetFeeRecipientInstructionData +> { + return combineCodec( + getSetFeeRecipientInstructionDataEncoder(), + getSetFeeRecipientInstructionDataDecoder() + ); +} + +export type SetFeeRecipientAsyncInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + eventAuthority?: Address; + program: Address; + newFeeRecipient: SetFeeRecipientInstructionDataArgs['newFeeRecipient']; +}; + +export async function getSetFeeRecipientInstructionAsync< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: SetFeeRecipientAsyncInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + SetFeeRecipientInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetFeeRecipientInstructionDataEncoder().encode( + args as SetFeeRecipientInstructionDataArgs + ), + } as SetFeeRecipientInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type SetFeeRecipientInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + eventAuthority: Address; + program: Address; + newFeeRecipient: SetFeeRecipientInstructionDataArgs['newFeeRecipient']; +}; + +export function getSetFeeRecipientInstruction< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: SetFeeRecipientInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): SetFeeRecipientInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetFeeRecipientInstructionDataEncoder().encode( + args as SetFeeRecipientInstructionDataArgs + ), + } as SetFeeRecipientInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedSetFeeRecipientInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: SetFeeRecipientInstructionData; +}; + +export function parseSetFeeRecipientInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetFeeRecipientInstruction { + if (instruction.accounts.length < 4) { + // 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: { + owner: getNextAccount(), + tokenMessenger: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getSetFeeRecipientInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/setMaxBurnAmountPerMessage.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/setMaxBurnAmountPerMessage.ts new file mode 100644 index 000000000..136e7a2f9 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/setMaxBurnAmountPerMessage.ts @@ -0,0 +1,359 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_MAX_BURN_AMOUNT_PER_MESSAGE_DISCRIMINATOR = new Uint8Array([ + 30, 128, 145, 240, 70, 237, 109, 207, +]); + +export function getSetMaxBurnAmountPerMessageDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_MAX_BURN_AMOUNT_PER_MESSAGE_DISCRIMINATOR + ); +} + +export type SetMaxBurnAmountPerMessageInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountTokenController extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountLocalToken extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountTokenController extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountTokenController, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountLocalToken extends string + ? WritableAccount + : TAccountLocalToken, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type SetMaxBurnAmountPerMessageInstructionData = { + discriminator: ReadonlyUint8Array; + burnLimitPerMessage: bigint; +}; + +export type SetMaxBurnAmountPerMessageInstructionDataArgs = { + burnLimitPerMessage: number | bigint; +}; + +export function getSetMaxBurnAmountPerMessageInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['burnLimitPerMessage', getU64Encoder()], + ]), + (value) => ({ + ...value, + discriminator: SET_MAX_BURN_AMOUNT_PER_MESSAGE_DISCRIMINATOR, + }) + ); +} + +export function getSetMaxBurnAmountPerMessageInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['burnLimitPerMessage', getU64Decoder()], + ]); +} + +export function getSetMaxBurnAmountPerMessageInstructionDataCodec(): Codec< + SetMaxBurnAmountPerMessageInstructionDataArgs, + SetMaxBurnAmountPerMessageInstructionData +> { + return combineCodec( + getSetMaxBurnAmountPerMessageInstructionDataEncoder(), + getSetMaxBurnAmountPerMessageInstructionDataDecoder() + ); +} + +export type SetMaxBurnAmountPerMessageAsyncInput< + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + tokenController: TransactionSigner; + tokenMinter: Address; + localToken: Address; + eventAuthority?: Address; + program: Address; + burnLimitPerMessage: SetMaxBurnAmountPerMessageInstructionDataArgs['burnLimitPerMessage']; +}; + +export async function getSetMaxBurnAmountPerMessageInstructionAsync< + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: SetMaxBurnAmountPerMessageAsyncInput< + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + SetMaxBurnAmountPerMessageInstruction< + TProgramAddress, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetMaxBurnAmountPerMessageInstructionDataEncoder().encode( + args as SetMaxBurnAmountPerMessageInstructionDataArgs + ), + } as SetMaxBurnAmountPerMessageInstruction< + TProgramAddress, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type SetMaxBurnAmountPerMessageInput< + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountLocalToken extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + tokenController: TransactionSigner; + tokenMinter: Address; + localToken: Address; + eventAuthority: Address; + program: Address; + burnLimitPerMessage: SetMaxBurnAmountPerMessageInstructionDataArgs['burnLimitPerMessage']; +}; + +export function getSetMaxBurnAmountPerMessageInstruction< + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountLocalToken extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: SetMaxBurnAmountPerMessageInput< + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): SetMaxBurnAmountPerMessageInstruction< + TProgramAddress, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + localToken: { value: input.localToken ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.localToken), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetMaxBurnAmountPerMessageInstructionDataEncoder().encode( + args as SetMaxBurnAmountPerMessageInstructionDataArgs + ), + } as SetMaxBurnAmountPerMessageInstruction< + TProgramAddress, + TAccountTokenController, + TAccountTokenMinter, + TAccountLocalToken, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedSetMaxBurnAmountPerMessageInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + tokenController: TAccountMetas[0]; + tokenMinter: TAccountMetas[1]; + localToken: TAccountMetas[2]; + eventAuthority: TAccountMetas[3]; + program: TAccountMetas[4]; + }; + data: SetMaxBurnAmountPerMessageInstructionData; +}; + +export function parseSetMaxBurnAmountPerMessageInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetMaxBurnAmountPerMessageInstruction { + if (instruction.accounts.length < 5) { + // 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: { + tokenController: getNextAccount(), + tokenMinter: getNextAccount(), + localToken: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getSetMaxBurnAmountPerMessageInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/setMinFee.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/setMinFee.ts new file mode 100644 index 000000000..410b8ec6a --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/setMinFee.ts @@ -0,0 +1,328 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_MIN_FEE_DISCRIMINATOR = new Uint8Array([ + 114, 198, 35, 3, 41, 196, 194, 246, +]); + +export function getSetMinFeeDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(SET_MIN_FEE_DISCRIMINATOR); +} + +export type SetMinFeeInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMinFeeController extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountMinFeeController extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountMinFeeController, + TAccountTokenMessenger extends string + ? WritableAccount + : TAccountTokenMessenger, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type SetMinFeeInstructionData = { + discriminator: ReadonlyUint8Array; + newMinFee: number; +}; + +export type SetMinFeeInstructionDataArgs = { newMinFee: number }; + +export function getSetMinFeeInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newMinFee', getU32Encoder()], + ]), + (value) => ({ ...value, discriminator: SET_MIN_FEE_DISCRIMINATOR }) + ); +} + +export function getSetMinFeeInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newMinFee', getU32Decoder()], + ]); +} + +export function getSetMinFeeInstructionDataCodec(): Codec< + SetMinFeeInstructionDataArgs, + SetMinFeeInstructionData +> { + return combineCodec( + getSetMinFeeInstructionDataEncoder(), + getSetMinFeeInstructionDataDecoder() + ); +} + +export type SetMinFeeAsyncInput< + TAccountMinFeeController extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + minFeeController: TransactionSigner; + tokenMessenger: Address; + eventAuthority?: Address; + program: Address; + newMinFee: SetMinFeeInstructionDataArgs['newMinFee']; +}; + +export async function getSetMinFeeInstructionAsync< + TAccountMinFeeController extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: SetMinFeeAsyncInput< + TAccountMinFeeController, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + SetMinFeeInstruction< + TProgramAddress, + TAccountMinFeeController, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + minFeeController: { + value: input.minFeeController ?? null, + isWritable: false, + }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.minFeeController), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetMinFeeInstructionDataEncoder().encode( + args as SetMinFeeInstructionDataArgs + ), + } as SetMinFeeInstruction< + TProgramAddress, + TAccountMinFeeController, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type SetMinFeeInput< + TAccountMinFeeController extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + minFeeController: TransactionSigner; + tokenMessenger: Address; + eventAuthority: Address; + program: Address; + newMinFee: SetMinFeeInstructionDataArgs['newMinFee']; +}; + +export function getSetMinFeeInstruction< + TAccountMinFeeController extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: SetMinFeeInput< + TAccountMinFeeController, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): SetMinFeeInstruction< + TProgramAddress, + TAccountMinFeeController, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + minFeeController: { + value: input.minFeeController ?? null, + isWritable: false, + }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.minFeeController), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetMinFeeInstructionDataEncoder().encode( + args as SetMinFeeInstructionDataArgs + ), + } as SetMinFeeInstruction< + TProgramAddress, + TAccountMinFeeController, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedSetMinFeeInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + minFeeController: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: SetMinFeeInstructionData; +}; + +export function parseSetMinFeeInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetMinFeeInstruction { + if (instruction.accounts.length < 4) { + // 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: { + minFeeController: getNextAccount(), + tokenMessenger: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getSetMinFeeInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/setMinFeeController.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/setMinFeeController.ts new file mode 100644 index 000000000..ee003d2a5 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/setMinFeeController.ts @@ -0,0 +1,331 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_MIN_FEE_CONTROLLER_DISCRIMINATOR = new Uint8Array([ + 195, 142, 74, 84, 234, 94, 180, 113, +]); + +export function getSetMinFeeControllerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_MIN_FEE_CONTROLLER_DISCRIMINATOR + ); +} + +export type SetMinFeeControllerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountTokenMessenger extends string + ? WritableAccount + : TAccountTokenMessenger, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type SetMinFeeControllerInstructionData = { + discriminator: ReadonlyUint8Array; + newMinFeeController: Address; +}; + +export type SetMinFeeControllerInstructionDataArgs = { + newMinFeeController: Address; +}; + +export function getSetMinFeeControllerInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newMinFeeController', getAddressEncoder()], + ]), + (value) => ({ + ...value, + discriminator: SET_MIN_FEE_CONTROLLER_DISCRIMINATOR, + }) + ); +} + +export function getSetMinFeeControllerInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newMinFeeController', getAddressDecoder()], + ]); +} + +export function getSetMinFeeControllerInstructionDataCodec(): Codec< + SetMinFeeControllerInstructionDataArgs, + SetMinFeeControllerInstructionData +> { + return combineCodec( + getSetMinFeeControllerInstructionDataEncoder(), + getSetMinFeeControllerInstructionDataDecoder() + ); +} + +export type SetMinFeeControllerAsyncInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + eventAuthority?: Address; + program: Address; + newMinFeeController: SetMinFeeControllerInstructionDataArgs['newMinFeeController']; +}; + +export async function getSetMinFeeControllerInstructionAsync< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: SetMinFeeControllerAsyncInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + SetMinFeeControllerInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetMinFeeControllerInstructionDataEncoder().encode( + args as SetMinFeeControllerInstructionDataArgs + ), + } as SetMinFeeControllerInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type SetMinFeeControllerInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + eventAuthority: Address; + program: Address; + newMinFeeController: SetMinFeeControllerInstructionDataArgs['newMinFeeController']; +}; + +export function getSetMinFeeControllerInstruction< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: SetMinFeeControllerInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): SetMinFeeControllerInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetMinFeeControllerInstructionDataEncoder().encode( + args as SetMinFeeControllerInstructionDataArgs + ), + } as SetMinFeeControllerInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedSetMinFeeControllerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: SetMinFeeControllerInstructionData; +}; + +export function parseSetMinFeeControllerInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetMinFeeControllerInstruction { + if (instruction.accounts.length < 4) { + // 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: { + owner: getNextAccount(), + tokenMessenger: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getSetMinFeeControllerInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/setTokenController.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/setTokenController.ts new file mode 100644 index 000000000..d3c7fdbbd --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/setTokenController.ts @@ -0,0 +1,350 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const SET_TOKEN_CONTROLLER_DISCRIMINATOR = new Uint8Array([ + 88, 6, 98, 10, 79, 59, 15, 24, +]); + +export function getSetTokenControllerDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + SET_TOKEN_CONTROLLER_DISCRIMINATOR + ); +} + +export type SetTokenControllerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountTokenMinter extends string + ? WritableAccount + : TAccountTokenMinter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type SetTokenControllerInstructionData = { + discriminator: ReadonlyUint8Array; + tokenController: Address; +}; + +export type SetTokenControllerInstructionDataArgs = { + tokenController: Address; +}; + +export function getSetTokenControllerInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['tokenController', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: SET_TOKEN_CONTROLLER_DISCRIMINATOR }) + ); +} + +export function getSetTokenControllerInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['tokenController', getAddressDecoder()], + ]); +} + +export function getSetTokenControllerInstructionDataCodec(): Codec< + SetTokenControllerInstructionDataArgs, + SetTokenControllerInstructionData +> { + return combineCodec( + getSetTokenControllerInstructionDataEncoder(), + getSetTokenControllerInstructionDataDecoder() + ); +} + +export type SetTokenControllerAsyncInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + tokenMinter: Address; + eventAuthority?: Address; + program: Address; + tokenController: SetTokenControllerInstructionDataArgs['tokenController']; +}; + +export async function getSetTokenControllerInstructionAsync< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: SetTokenControllerAsyncInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + SetTokenControllerInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetTokenControllerInstructionDataEncoder().encode( + args as SetTokenControllerInstructionDataArgs + ), + } as SetTokenControllerInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type SetTokenControllerInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + tokenMinter: Address; + eventAuthority: Address; + program: Address; + tokenController: SetTokenControllerInstructionDataArgs['tokenController']; +}; + +export function getSetTokenControllerInstruction< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: SetTokenControllerInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): SetTokenControllerInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getSetTokenControllerInstructionDataEncoder().encode( + args as SetTokenControllerInstructionDataArgs + ), + } as SetTokenControllerInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedSetTokenControllerInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + eventAuthority: TAccountMetas[3]; + program: TAccountMetas[4]; + }; + data: SetTokenControllerInstructionData; +}; + +export function parseSetTokenControllerInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedSetTokenControllerInstruction { + if (instruction.accounts.length < 5) { + // 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: { + owner: getNextAccount(), + tokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getSetTokenControllerInstructionDataDecoder().decode( + instruction.data + ), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/transferOwnership.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/transferOwnership.ts new file mode 100644 index 000000000..1e01e6da2 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/transferOwnership.ts @@ -0,0 +1,324 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const TRANSFER_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ + 65, 177, 215, 73, 53, 45, 99, 47, +]); + +export function getTransferOwnershipDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + TRANSFER_OWNERSHIP_DISCRIMINATOR + ); +} + +export type TransferOwnershipInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountTokenMessenger extends string + ? WritableAccount + : TAccountTokenMessenger, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type TransferOwnershipInstructionData = { + discriminator: ReadonlyUint8Array; + newOwner: Address; +}; + +export type TransferOwnershipInstructionDataArgs = { newOwner: Address }; + +export function getTransferOwnershipInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newOwner', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: TRANSFER_OWNERSHIP_DISCRIMINATOR }) + ); +} + +export function getTransferOwnershipInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newOwner', getAddressDecoder()], + ]); +} + +export function getTransferOwnershipInstructionDataCodec(): Codec< + TransferOwnershipInstructionDataArgs, + TransferOwnershipInstructionData +> { + return combineCodec( + getTransferOwnershipInstructionDataEncoder(), + getTransferOwnershipInstructionDataDecoder() + ); +} + +export type TransferOwnershipAsyncInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + eventAuthority?: Address; + program: Address; + newOwner: TransferOwnershipInstructionDataArgs['newOwner']; +}; + +export async function getTransferOwnershipInstructionAsync< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: TransferOwnershipAsyncInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getTransferOwnershipInstructionDataEncoder().encode( + args as TransferOwnershipInstructionDataArgs + ), + } as TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type TransferOwnershipInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + eventAuthority: Address; + program: Address; + newOwner: TransferOwnershipInstructionDataArgs['newOwner']; +}; + +export function getTransferOwnershipInstruction< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: TransferOwnershipInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getTransferOwnershipInstructionDataEncoder().encode( + args as TransferOwnershipInstructionDataArgs + ), + } as TransferOwnershipInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedTransferOwnershipInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: TransferOwnershipInstructionData; +}; + +export function parseTransferOwnershipInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedTransferOwnershipInstruction { + if (instruction.accounts.length < 4) { + // 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: { + owner: getNextAccount(), + tokenMessenger: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getTransferOwnershipInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/undenylistAccount.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/undenylistAccount.ts new file mode 100644 index 000000000..a80c7e9d6 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/undenylistAccount.ts @@ -0,0 +1,403 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UNDENYLIST_ACCOUNT_DISCRIMINATOR = new Uint8Array([ + 57, 36, 43, 168, 62, 172, 33, 39, +]); + +export function getUndenylistAccountDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UNDENYLIST_ACCOUNT_DISCRIMINATOR + ); +} + +export type UndenylistAccountInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountPayer extends string | AccountMeta = string, + TAccountDenylister extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountDenylistAccount extends string | AccountMeta = string, + TAccountSystemProgram extends string | AccountMeta = + '11111111111111111111111111111111', + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayer extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayer, + TAccountDenylister extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountDenylister, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountDenylistAccount extends string + ? WritableAccount + : TAccountDenylistAccount, + TAccountSystemProgram extends string + ? ReadonlyAccount + : TAccountSystemProgram, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UndenylistAccountInstructionData = { + discriminator: ReadonlyUint8Array; + account: Address; +}; + +export type UndenylistAccountInstructionDataArgs = { account: Address }; + +export function getUndenylistAccountInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['account', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: UNDENYLIST_ACCOUNT_DISCRIMINATOR }) + ); +} + +export function getUndenylistAccountInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['account', getAddressDecoder()], + ]); +} + +export function getUndenylistAccountInstructionDataCodec(): Codec< + UndenylistAccountInstructionDataArgs, + UndenylistAccountInstructionData +> { + return combineCodec( + getUndenylistAccountInstructionDataEncoder(), + getUndenylistAccountInstructionDataDecoder() + ); +} + +export type UndenylistAccountAsyncInput< + TAccountPayer extends string = string, + TAccountDenylister extends string = string, + TAccountTokenMessenger extends string = string, + TAccountDenylistAccount extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + denylister: TransactionSigner; + tokenMessenger: Address; + denylistAccount: Address; + systemProgram?: Address; + eventAuthority?: Address; + program: Address; + account: UndenylistAccountInstructionDataArgs['account']; +}; + +export async function getUndenylistAccountInstructionAsync< + TAccountPayer extends string, + TAccountDenylister extends string, + TAccountTokenMessenger extends string, + TAccountDenylistAccount extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: UndenylistAccountAsyncInput< + TAccountPayer, + TAccountDenylister, + TAccountTokenMessenger, + TAccountDenylistAccount, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + UndenylistAccountInstruction< + TProgramAddress, + TAccountPayer, + TAccountDenylister, + TAccountTokenMessenger, + TAccountDenylistAccount, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + denylister: { value: input.denylister ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + denylistAccount: { value: input.denylistAccount ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.denylister), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.denylistAccount), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUndenylistAccountInstructionDataEncoder().encode( + args as UndenylistAccountInstructionDataArgs + ), + } as UndenylistAccountInstruction< + TProgramAddress, + TAccountPayer, + TAccountDenylister, + TAccountTokenMessenger, + TAccountDenylistAccount, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type UndenylistAccountInput< + TAccountPayer extends string = string, + TAccountDenylister extends string = string, + TAccountTokenMessenger extends string = string, + TAccountDenylistAccount extends string = string, + TAccountSystemProgram extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payer: TransactionSigner; + denylister: TransactionSigner; + tokenMessenger: Address; + denylistAccount: Address; + systemProgram?: Address; + eventAuthority: Address; + program: Address; + account: UndenylistAccountInstructionDataArgs['account']; +}; + +export function getUndenylistAccountInstruction< + TAccountPayer extends string, + TAccountDenylister extends string, + TAccountTokenMessenger extends string, + TAccountDenylistAccount extends string, + TAccountSystemProgram extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: UndenylistAccountInput< + TAccountPayer, + TAccountDenylister, + TAccountTokenMessenger, + TAccountDenylistAccount, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UndenylistAccountInstruction< + TProgramAddress, + TAccountPayer, + TAccountDenylister, + TAccountTokenMessenger, + TAccountDenylistAccount, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payer: { value: input.payer ?? null, isWritable: true }, + denylister: { value: input.denylister ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + denylistAccount: { value: input.denylistAccount ?? null, isWritable: true }, + systemProgram: { value: input.systemProgram ?? null, isWritable: false }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.systemProgram.value) { + accounts.systemProgram.value = + '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payer), + getAccountMeta(accounts.denylister), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.denylistAccount), + getAccountMeta(accounts.systemProgram), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUndenylistAccountInstructionDataEncoder().encode( + args as UndenylistAccountInstructionDataArgs + ), + } as UndenylistAccountInstruction< + TProgramAddress, + TAccountPayer, + TAccountDenylister, + TAccountTokenMessenger, + TAccountDenylistAccount, + TAccountSystemProgram, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUndenylistAccountInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payer: TAccountMetas[0]; + denylister: TAccountMetas[1]; + tokenMessenger: TAccountMetas[2]; + denylistAccount: TAccountMetas[3]; + systemProgram: TAccountMetas[4]; + eventAuthority: TAccountMetas[5]; + program: TAccountMetas[6]; + }; + data: UndenylistAccountInstructionData; +}; + +export function parseUndenylistAccountInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUndenylistAccountInstruction { + if (instruction.accounts.length < 7) { + // 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: { + payer: getNextAccount(), + denylister: getNextAccount(), + tokenMessenger: getNextAccount(), + denylistAccount: getNextAccount(), + systemProgram: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUndenylistAccountInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/unlinkTokenPair.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/unlinkTokenPair.ts new file mode 100644 index 000000000..aa29b3ec3 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/unlinkTokenPair.ts @@ -0,0 +1,357 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, + type WritableSignerAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UNLINK_TOKEN_PAIR_DISCRIMINATOR = new Uint8Array([ + 52, 198, 100, 114, 104, 174, 85, 58, +]); + +export function getUnlinkTokenPairDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UNLINK_TOKEN_PAIR_DISCRIMINATOR + ); +} + +export type UnlinkTokenPairInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountPayee extends string | AccountMeta = string, + TAccountTokenController extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountTokenPair extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPayee extends string + ? WritableSignerAccount & + AccountSignerMeta + : TAccountPayee, + TAccountTokenController extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountTokenController, + TAccountTokenMinter extends string + ? ReadonlyAccount + : TAccountTokenMinter, + TAccountTokenPair extends string + ? WritableAccount + : TAccountTokenPair, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UnlinkTokenPairInstructionData = { + discriminator: ReadonlyUint8Array; +}; + +export type UnlinkTokenPairInstructionDataArgs = {}; + +export function getUnlinkTokenPairInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: UNLINK_TOKEN_PAIR_DISCRIMINATOR }) + ); +} + +export function getUnlinkTokenPairInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getUnlinkTokenPairInstructionDataCodec(): Codec< + UnlinkTokenPairInstructionDataArgs, + UnlinkTokenPairInstructionData +> { + return combineCodec( + getUnlinkTokenPairInstructionDataEncoder(), + getUnlinkTokenPairInstructionDataDecoder() + ); +} + +export type UnlinkTokenPairAsyncInput< + TAccountPayee extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountTokenPair extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payee: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + tokenPair: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getUnlinkTokenPairInstructionAsync< + TAccountPayee extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountTokenPair extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: UnlinkTokenPairAsyncInput< + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + UnlinkTokenPairInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + tokenPair: { value: input.tokenPair ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.tokenPair), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUnlinkTokenPairInstructionDataEncoder().encode({}), + } as UnlinkTokenPairInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type UnlinkTokenPairInput< + TAccountPayee extends string = string, + TAccountTokenController extends string = string, + TAccountTokenMinter extends string = string, + TAccountTokenPair extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + payee: TransactionSigner; + tokenController: TransactionSigner; + tokenMinter: Address; + tokenPair: Address; + eventAuthority: Address; + program: Address; +}; + +export function getUnlinkTokenPairInstruction< + TAccountPayee extends string, + TAccountTokenController extends string, + TAccountTokenMinter extends string, + TAccountTokenPair extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: UnlinkTokenPairInput< + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UnlinkTokenPairInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + payee: { value: input.payee ?? null, isWritable: true }, + tokenController: { + value: input.tokenController ?? null, + isWritable: false, + }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, + tokenPair: { value: input.tokenPair ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.payee), + getAccountMeta(accounts.tokenController), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.tokenPair), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUnlinkTokenPairInstructionDataEncoder().encode({}), + } as UnlinkTokenPairInstruction< + TProgramAddress, + TAccountPayee, + TAccountTokenController, + TAccountTokenMinter, + TAccountTokenPair, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUnlinkTokenPairInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + payee: TAccountMetas[0]; + tokenController: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + tokenPair: TAccountMetas[3]; + eventAuthority: TAccountMetas[4]; + program: TAccountMetas[5]; + }; + data: UnlinkTokenPairInstructionData; +}; + +export function parseUnlinkTokenPairInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUnlinkTokenPairInstruction { + if (instruction.accounts.length < 6) { + // 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: { + payee: getNextAccount(), + tokenController: getNextAccount(), + tokenMinter: getNextAccount(), + tokenPair: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUnlinkTokenPairInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/unpause.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/unpause.ts new file mode 100644 index 000000000..10bd0d65a --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/unpause.ts @@ -0,0 +1,301 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UNPAUSE_DISCRIMINATOR = new Uint8Array([ + 169, 144, 4, 38, 10, 141, 188, 255, +]); + +export function getUnpauseDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode(UNPAUSE_DISCRIMINATOR); +} + +export type UnpauseInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountPauser extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountPauser extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountPauser, + TAccountTokenMinter extends string + ? WritableAccount + : TAccountTokenMinter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UnpauseInstructionData = { discriminator: ReadonlyUint8Array }; + +export type UnpauseInstructionDataArgs = {}; + +export function getUnpauseInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), + (value) => ({ ...value, discriminator: UNPAUSE_DISCRIMINATOR }) + ); +} + +export function getUnpauseInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ]); +} + +export function getUnpauseInstructionDataCodec(): Codec< + UnpauseInstructionDataArgs, + UnpauseInstructionData +> { + return combineCodec( + getUnpauseInstructionDataEncoder(), + getUnpauseInstructionDataDecoder() + ); +} + +export type UnpauseAsyncInput< + TAccountPauser extends string = string, + TAccountTokenMinter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pauser: TransactionSigner; + tokenMinter: Address; + eventAuthority?: Address; + program: Address; +}; + +export async function getUnpauseInstructionAsync< + TAccountPauser extends string, + TAccountTokenMinter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: UnpauseAsyncInput< + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + UnpauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pauser: { value: input.pauser ?? null, isWritable: false }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pauser), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUnpauseInstructionDataEncoder().encode({}), + } as UnpauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type UnpauseInput< + TAccountPauser extends string = string, + TAccountTokenMinter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + pauser: TransactionSigner; + tokenMinter: Address; + eventAuthority: Address; + program: Address; +}; + +export function getUnpauseInstruction< + TAccountPauser extends string, + TAccountTokenMinter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: UnpauseInput< + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UnpauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + pauser: { value: input.pauser ?? null, isWritable: false }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.pauser), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUnpauseInstructionDataEncoder().encode({}), + } as UnpauseInstruction< + TProgramAddress, + TAccountPauser, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUnpauseInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + pauser: TAccountMetas[0]; + tokenMinter: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: UnpauseInstructionData; +}; + +export function parseUnpauseInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUnpauseInstruction { + if (instruction.accounts.length < 4) { + // 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: { + pauser: getNextAccount(), + tokenMinter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUnpauseInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/updateDenylister.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/updateDenylister.ts new file mode 100644 index 000000000..31645028b --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/updateDenylister.ts @@ -0,0 +1,324 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UPDATE_DENYLISTER_DISCRIMINATOR = new Uint8Array([ + 193, 66, 198, 201, 84, 57, 14, 222, +]); + +export function getUpdateDenylisterDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_DENYLISTER_DISCRIMINATOR + ); +} + +export type UpdateDenylisterInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountTokenMessenger extends string + ? WritableAccount + : TAccountTokenMessenger, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UpdateDenylisterInstructionData = { + discriminator: ReadonlyUint8Array; + newDenylister: Address; +}; + +export type UpdateDenylisterInstructionDataArgs = { newDenylister: Address }; + +export function getUpdateDenylisterInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newDenylister', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: UPDATE_DENYLISTER_DISCRIMINATOR }) + ); +} + +export function getUpdateDenylisterInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newDenylister', getAddressDecoder()], + ]); +} + +export function getUpdateDenylisterInstructionDataCodec(): Codec< + UpdateDenylisterInstructionDataArgs, + UpdateDenylisterInstructionData +> { + return combineCodec( + getUpdateDenylisterInstructionDataEncoder(), + getUpdateDenylisterInstructionDataDecoder() + ); +} + +export type UpdateDenylisterAsyncInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + eventAuthority?: Address; + program: Address; + newDenylister: UpdateDenylisterInstructionDataArgs['newDenylister']; +}; + +export async function getUpdateDenylisterInstructionAsync< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: UpdateDenylisterAsyncInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + UpdateDenylisterInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUpdateDenylisterInstructionDataEncoder().encode( + args as UpdateDenylisterInstructionDataArgs + ), + } as UpdateDenylisterInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type UpdateDenylisterInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + eventAuthority: Address; + program: Address; + newDenylister: UpdateDenylisterInstructionDataArgs['newDenylister']; +}; + +export function getUpdateDenylisterInstruction< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: UpdateDenylisterInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UpdateDenylisterInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUpdateDenylisterInstructionDataEncoder().encode( + args as UpdateDenylisterInstructionDataArgs + ), + } as UpdateDenylisterInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUpdateDenylisterInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + eventAuthority: TAccountMetas[2]; + program: TAccountMetas[3]; + }; + data: UpdateDenylisterInstructionData; +}; + +export function parseUpdateDenylisterInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUpdateDenylisterInstruction { + if (instruction.accounts.length < 4) { + // 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: { + owner: getNextAccount(), + tokenMessenger: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUpdateDenylisterInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/updatePauser.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/updatePauser.ts new file mode 100644 index 000000000..6b65e6855 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/instructions/updatePauser.ts @@ -0,0 +1,346 @@ +/** + * 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, + fixDecoderSize, + fixEncoderSize, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getProgramDerivedAddress, + getStructDecoder, + getStructEncoder, + transformEncoder, + type AccountMeta, + type AccountSignerMeta, + type Address, + type Codec, + type Decoder, + type Encoder, + type Instruction, + type InstructionWithAccounts, + type InstructionWithData, + type ReadonlyAccount, + type ReadonlySignerAccount, + type ReadonlyUint8Array, + type TransactionSigner, + type WritableAccount, +} from '@solana/kit'; +import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; +import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; + +export const UPDATE_PAUSER_DISCRIMINATOR = new Uint8Array([ + 140, 171, 211, 132, 57, 201, 16, 254, +]); + +export function getUpdatePauserDiscriminatorBytes() { + return fixEncoderSize(getBytesEncoder(), 8).encode( + UPDATE_PAUSER_DISCRIMINATOR + ); +} + +export type UpdatePauserInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountOwner extends string | AccountMeta = string, + TAccountTokenMessenger extends string | AccountMeta = string, + TAccountTokenMinter extends string | AccountMeta = string, + TAccountEventAuthority extends string | AccountMeta = string, + TAccountProgram extends string | AccountMeta = string, + TRemainingAccounts extends readonly AccountMeta[] = [], +> = Instruction & + InstructionWithData & + InstructionWithAccounts< + [ + TAccountOwner extends string + ? ReadonlySignerAccount & + AccountSignerMeta + : TAccountOwner, + TAccountTokenMessenger extends string + ? ReadonlyAccount + : TAccountTokenMessenger, + TAccountTokenMinter extends string + ? WritableAccount + : TAccountTokenMinter, + TAccountEventAuthority extends string + ? ReadonlyAccount + : TAccountEventAuthority, + TAccountProgram extends string + ? ReadonlyAccount + : TAccountProgram, + ...TRemainingAccounts, + ] + >; + +export type UpdatePauserInstructionData = { + discriminator: ReadonlyUint8Array; + newPauser: Address; +}; + +export type UpdatePauserInstructionDataArgs = { newPauser: Address }; + +export function getUpdatePauserInstructionDataEncoder(): Encoder { + return transformEncoder( + getStructEncoder([ + ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], + ['newPauser', getAddressEncoder()], + ]), + (value) => ({ ...value, discriminator: UPDATE_PAUSER_DISCRIMINATOR }) + ); +} + +export function getUpdatePauserInstructionDataDecoder(): Decoder { + return getStructDecoder([ + ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], + ['newPauser', getAddressDecoder()], + ]); +} + +export function getUpdatePauserInstructionDataCodec(): Codec< + UpdatePauserInstructionDataArgs, + UpdatePauserInstructionData +> { + return combineCodec( + getUpdatePauserInstructionDataEncoder(), + getUpdatePauserInstructionDataDecoder() + ); +} + +export type UpdatePauserAsyncInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + tokenMinter: Address; + eventAuthority?: Address; + program: Address; + newPauser: UpdatePauserInstructionDataArgs['newPauser']; +}; + +export async function getUpdatePauserInstructionAsync< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: UpdatePauserAsyncInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): Promise< + UpdatePauserInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + > +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? null, isWritable: false }, + }; + const accounts = originalAccounts as Record< + keyof typeof originalAccounts, + ResolvedAccount + >; + + // Original args. + const args = { ...input }; + + // Resolve default values. + if (!accounts.eventAuthority.value) { + accounts.eventAuthority.value = await getProgramDerivedAddress({ + programAddress, + seeds: [ + getBytesEncoder().encode( + new Uint8Array([ + 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, + 105, 116, 121, + ]) + ), + ], + }); + } + + const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); + const instruction = { + accounts: [ + getAccountMeta(accounts.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUpdatePauserInstructionDataEncoder().encode( + args as UpdatePauserInstructionDataArgs + ), + } as UpdatePauserInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type UpdatePauserInput< + TAccountOwner extends string = string, + TAccountTokenMessenger extends string = string, + TAccountTokenMinter extends string = string, + TAccountEventAuthority extends string = string, + TAccountProgram extends string = string, +> = { + owner: TransactionSigner; + tokenMessenger: Address; + tokenMinter: Address; + eventAuthority: Address; + program: Address; + newPauser: UpdatePauserInstructionDataArgs['newPauser']; +}; + +export function getUpdatePauserInstruction< + TAccountOwner extends string, + TAccountTokenMessenger extends string, + TAccountTokenMinter extends string, + TAccountEventAuthority extends string, + TAccountProgram extends string, + TProgramAddress extends Address = + typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, +>( + input: UpdatePauserInput< + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >, + config?: { programAddress?: TProgramAddress } +): UpdatePauserInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram +> { + // Program address. + const programAddress = + config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; + + // Original accounts. + const originalAccounts = { + owner: { value: input.owner ?? null, isWritable: false }, + tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, + tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, + eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, + program: { value: input.program ?? 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.owner), + getAccountMeta(accounts.tokenMessenger), + getAccountMeta(accounts.tokenMinter), + getAccountMeta(accounts.eventAuthority), + getAccountMeta(accounts.program), + ], + programAddress, + data: getUpdatePauserInstructionDataEncoder().encode( + args as UpdatePauserInstructionDataArgs + ), + } as UpdatePauserInstruction< + TProgramAddress, + TAccountOwner, + TAccountTokenMessenger, + TAccountTokenMinter, + TAccountEventAuthority, + TAccountProgram + >; + + return instruction; +} + +export type ParsedUpdatePauserInstruction< + TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, + TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], +> = { + programAddress: Address; + accounts: { + owner: TAccountMetas[0]; + tokenMessenger: TAccountMetas[1]; + tokenMinter: TAccountMetas[2]; + eventAuthority: TAccountMetas[3]; + program: TAccountMetas[4]; + }; + data: UpdatePauserInstructionData; +}; + +export function parseUpdatePauserInstruction< + TProgram extends string, + TAccountMetas extends readonly AccountMeta[], +>( + instruction: Instruction & + InstructionWithAccounts & + InstructionWithData +): ParsedUpdatePauserInstruction { + if (instruction.accounts.length < 5) { + // 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: { + owner: getNextAccount(), + tokenMessenger: getNextAccount(), + tokenMinter: getNextAccount(), + eventAuthority: getNextAccount(), + program: getNextAccount(), + }, + data: getUpdatePauserInstructionDataDecoder().decode(instruction.data), + }; +} diff --git a/src/svm/clients/TokenMessengerMinterV2/programs/index.ts b/src/svm/clients/TokenMessengerMinterV2/programs/index.ts new file mode 100644 index 000000000..f2cacc30e --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/programs/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 './tokenMessengerMinterV2'; diff --git a/src/svm/clients/TokenMessengerMinterV2/programs/tokenMessengerMinterV2.ts b/src/svm/clients/TokenMessengerMinterV2/programs/tokenMessengerMinterV2.ts new file mode 100644 index 000000000..04a3fc6de --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/programs/tokenMessengerMinterV2.ts @@ -0,0 +1,532 @@ +/** + * 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/kit'; +import { + type ParsedAcceptOwnershipInstruction, + type ParsedAddLocalTokenInstruction, + type ParsedAddRemoteTokenMessengerInstruction, + type ParsedBurnTokenCustodyInstruction, + type ParsedDenylistAccountInstruction, + type ParsedDepositForBurnInstruction, + type ParsedDepositForBurnWithHookInstruction, + type ParsedHandleReceiveFinalizedMessageInstruction, + type ParsedHandleReceiveUnfinalizedMessageInstruction, + type ParsedInitializeInstruction, + type ParsedLinkTokenPairInstruction, + type ParsedPauseInstruction, + type ParsedRemoveLocalTokenInstruction, + type ParsedRemoveRemoteTokenMessengerInstruction, + type ParsedSetFeeRecipientInstruction, + type ParsedSetMaxBurnAmountPerMessageInstruction, + type ParsedSetMinFeeControllerInstruction, + type ParsedSetMinFeeInstruction, + type ParsedSetTokenControllerInstruction, + type ParsedTransferOwnershipInstruction, + type ParsedUndenylistAccountInstruction, + type ParsedUnlinkTokenPairInstruction, + type ParsedUnpauseInstruction, + type ParsedUpdateDenylisterInstruction, + type ParsedUpdatePauserInstruction, +} from '../instructions'; + +export const TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS = + 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; + +export enum TokenMessengerMinterV2Account { + DenylistedAccount, + LocalToken, + MessageTransmitter, + RemoteTokenMessenger, + TokenMessenger, + TokenMinter, + TokenPair, +} + +export function identifyTokenMessengerMinterV2Account( + account: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): TokenMessengerMinterV2Account { + const data = 'data' in account ? account.data : account; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([186, 58, 212, 239, 102, 131, 157, 146]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Account.DenylistedAccount; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([159, 131, 58, 170, 193, 84, 128, 182]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Account.LocalToken; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([71, 40, 180, 142, 19, 203, 35, 252]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Account.MessageTransmitter; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([105, 115, 174, 34, 95, 233, 138, 252]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Account.RemoteTokenMessenger; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([162, 4, 242, 52, 147, 243, 221, 96]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Account.TokenMessenger; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([122, 133, 84, 63, 57, 159, 171, 206]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Account.TokenMinter; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([17, 214, 45, 176, 229, 149, 197, 71]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Account.TokenPair; + } + throw new Error( + 'The provided account could not be identified as a tokenMessengerMinterV2 account.' + ); +} + +export enum TokenMessengerMinterV2Instruction { + AcceptOwnership, + AddLocalToken, + AddRemoteTokenMessenger, + BurnTokenCustody, + DenylistAccount, + DepositForBurn, + DepositForBurnWithHook, + HandleReceiveFinalizedMessage, + HandleReceiveUnfinalizedMessage, + Initialize, + LinkTokenPair, + Pause, + RemoveLocalToken, + RemoveRemoteTokenMessenger, + SetFeeRecipient, + SetMaxBurnAmountPerMessage, + SetMinFee, + SetMinFeeController, + SetTokenController, + TransferOwnership, + UndenylistAccount, + UnlinkTokenPair, + Unpause, + UpdateDenylister, + UpdatePauser, +} + +export function identifyTokenMessengerMinterV2Instruction( + instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array +): TokenMessengerMinterV2Instruction { + const data = 'data' in instruction ? instruction.data : instruction; + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([172, 23, 43, 13, 238, 213, 85, 150]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.AcceptOwnership; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([213, 199, 205, 18, 98, 124, 73, 198]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.AddLocalToken; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([12, 149, 172, 165, 111, 202, 24, 33]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.AddRemoteTokenMessenger; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([233, 136, 180, 175, 112, 41, 62, 71]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.BurnTokenCustody; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([101, 116, 197, 112, 81, 249, 75, 194]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.DenylistAccount; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([215, 60, 61, 46, 114, 55, 128, 176]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.DepositForBurn; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([111, 245, 62, 131, 204, 108, 223, 155]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.DepositForBurnWithHook; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([186, 252, 239, 70, 86, 180, 110, 95]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.HandleReceiveFinalizedMessage; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([200, 169, 175, 20, 200, 58, 182, 61]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.HandleReceiveUnfinalizedMessage; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.Initialize; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([68, 162, 24, 104, 125, 46, 130, 12]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.LinkTokenPair; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([211, 22, 221, 251, 74, 121, 193, 47]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.Pause; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([27, 43, 66, 170, 188, 44, 109, 97]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.RemoveLocalToken; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([65, 114, 66, 85, 169, 98, 177, 146]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.RemoveRemoteTokenMessenger; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([227, 18, 215, 42, 237, 246, 151, 66]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.SetFeeRecipient; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([30, 128, 145, 240, 70, 237, 109, 207]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.SetMaxBurnAmountPerMessage; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([114, 198, 35, 3, 41, 196, 194, 246]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.SetMinFee; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([195, 142, 74, 84, 234, 94, 180, 113]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.SetMinFeeController; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([88, 6, 98, 10, 79, 59, 15, 24]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.SetTokenController; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.TransferOwnership; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([57, 36, 43, 168, 62, 172, 33, 39]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.UndenylistAccount; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([52, 198, 100, 114, 104, 174, 85, 58]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.UnlinkTokenPair; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([169, 144, 4, 38, 10, 141, 188, 255]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.Unpause; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([193, 66, 198, 201, 84, 57, 14, 222]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.UpdateDenylister; + } + if ( + containsBytes( + data, + fixEncoderSize(getBytesEncoder(), 8).encode( + new Uint8Array([140, 171, 211, 132, 57, 201, 16, 254]) + ), + 0 + ) + ) { + return TokenMessengerMinterV2Instruction.UpdatePauser; + } + throw new Error( + 'The provided instruction could not be identified as a tokenMessengerMinterV2 instruction.' + ); +} + +export type ParsedTokenMessengerMinterV2Instruction< + TProgram extends string = 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe', +> = + | ({ + instructionType: TokenMessengerMinterV2Instruction.AcceptOwnership; + } & ParsedAcceptOwnershipInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.AddLocalToken; + } & ParsedAddLocalTokenInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.AddRemoteTokenMessenger; + } & ParsedAddRemoteTokenMessengerInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.BurnTokenCustody; + } & ParsedBurnTokenCustodyInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.DenylistAccount; + } & ParsedDenylistAccountInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.DepositForBurn; + } & ParsedDepositForBurnInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.DepositForBurnWithHook; + } & ParsedDepositForBurnWithHookInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.HandleReceiveFinalizedMessage; + } & ParsedHandleReceiveFinalizedMessageInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.HandleReceiveUnfinalizedMessage; + } & ParsedHandleReceiveUnfinalizedMessageInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.Initialize; + } & ParsedInitializeInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.LinkTokenPair; + } & ParsedLinkTokenPairInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.Pause; + } & ParsedPauseInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.RemoveLocalToken; + } & ParsedRemoveLocalTokenInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.RemoveRemoteTokenMessenger; + } & ParsedRemoveRemoteTokenMessengerInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.SetFeeRecipient; + } & ParsedSetFeeRecipientInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.SetMaxBurnAmountPerMessage; + } & ParsedSetMaxBurnAmountPerMessageInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.SetMinFee; + } & ParsedSetMinFeeInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.SetMinFeeController; + } & ParsedSetMinFeeControllerInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.SetTokenController; + } & ParsedSetTokenControllerInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.TransferOwnership; + } & ParsedTransferOwnershipInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.UndenylistAccount; + } & ParsedUndenylistAccountInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.UnlinkTokenPair; + } & ParsedUnlinkTokenPairInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.Unpause; + } & ParsedUnpauseInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.UpdateDenylister; + } & ParsedUpdateDenylisterInstruction) + | ({ + instructionType: TokenMessengerMinterV2Instruction.UpdatePauser; + } & ParsedUpdatePauserInstruction); diff --git a/src/svm/clients/TokenMessengerMinterV2/shared/index.ts b/src/svm/clients/TokenMessengerMinterV2/shared/index.ts new file mode 100644 index 000000000..7ebc26514 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/shared/index.ts @@ -0,0 +1,164 @@ +/** + * 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 { + AccountRole, + isProgramDerivedAddress, + isTransactionSigner as kitIsTransactionSigner, + type AccountMeta, + type AccountSignerMeta, + type Address, + type ProgramDerivedAddress, + type TransactionSigner, + upgradeRoleToSigner, +} from '@solana/kit'; + +/** + * Asserts that the given value is not null or undefined. + * @internal + */ +export function expectSome(value: T | null | undefined): T { + if (value == null) { + throw new Error('Expected a value but received null or undefined.'); + } + return value; +} + +/** + * Asserts that the given value is a PublicKey. + * @internal + */ +export function expectAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): Address { + if (!value) { + throw new Error('Expected a Address.'); + } + if (typeof value === 'object' && 'address' in value) { + return value.address; + } + if (Array.isArray(value)) { + return value[0]; + } + return value as Address; +} + +/** + * Asserts that the given value is a PDA. + * @internal + */ +export function expectProgramDerivedAddress( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): ProgramDerivedAddress { + if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { + throw new Error('Expected a ProgramDerivedAddress.'); + } + return value; +} + +/** + * Asserts that the given value is a TransactionSigner. + * @internal + */ +export function expectTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner + | null + | undefined +): TransactionSigner { + if (!value || !isTransactionSigner(value)) { + throw new Error('Expected a TransactionSigner.'); + } + return value; +} + +/** + * Defines an instruction account to resolve. + * @internal + */ +export type ResolvedAccount< + T extends string = string, + U extends + | Address + | ProgramDerivedAddress + | TransactionSigner + | null = + | Address + | ProgramDerivedAddress + | TransactionSigner + | null, +> = { + isWritable: boolean; + value: U; +}; + +/** + * Defines an instruction that stores additional bytes on-chain. + * @internal + */ +export type InstructionWithByteDelta = { + byteDelta: number; +}; + +/** + * Get account metas and signers from resolved accounts. + * @internal + */ +export function getAccountMetaFactory( + programAddress: Address, + optionalAccountStrategy: 'omitted' | 'programId' +) { + return ( + account: ResolvedAccount + ): AccountMeta | AccountSignerMeta | undefined => { + if (!account.value) { + if (optionalAccountStrategy === 'omitted') return; + return Object.freeze({ + address: programAddress, + role: AccountRole.READONLY, + }); + } + + const writableRole = account.isWritable + ? AccountRole.WRITABLE + : AccountRole.READONLY; + return Object.freeze({ + address: expectAddress(account.value), + role: isTransactionSigner(account.value) + ? upgradeRoleToSigner(writableRole) + : writableRole, + ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), + }); + }; +} + +export function isTransactionSigner( + value: + | Address + | ProgramDerivedAddress + | TransactionSigner +): value is TransactionSigner { + return ( + !!value && + typeof value === 'object' && + 'address' in value && + kitIsTransactionSigner(value) + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/denylisted.ts b/src/svm/clients/TokenMessengerMinterV2/types/denylisted.ts new file mode 100644 index 000000000..04f33c71c --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/denylisted.ts @@ -0,0 +1,35 @@ +/** + * 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/kit'; + +export type Denylisted = { account: Address }; + +export type DenylistedArgs = Denylisted; + +export function getDenylistedEncoder(): Encoder { + return getStructEncoder([['account', getAddressEncoder()]]); +} + +export function getDenylistedDecoder(): Decoder { + return getStructDecoder([['account', getAddressDecoder()]]); +} + +export function getDenylistedCodec(): Codec { + return combineCodec(getDenylistedEncoder(), getDenylistedDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/denylisterChanged.ts b/src/svm/clients/TokenMessengerMinterV2/types/denylisterChanged.ts new file mode 100644 index 000000000..1a6433281 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/denylisterChanged.ts @@ -0,0 +1,50 @@ +/** + * 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/kit'; + +export type DenylisterChanged = { + oldDenylister: Address; + newDenylister: Address; +}; + +export type DenylisterChangedArgs = DenylisterChanged; + +export function getDenylisterChangedEncoder(): Encoder { + return getStructEncoder([ + ['oldDenylister', getAddressEncoder()], + ['newDenylister', getAddressEncoder()], + ]); +} + +export function getDenylisterChangedDecoder(): Decoder { + return getStructDecoder([ + ['oldDenylister', getAddressDecoder()], + ['newDenylister', getAddressDecoder()], + ]); +} + +export function getDenylisterChangedCodec(): Codec< + DenylisterChangedArgs, + DenylisterChanged +> { + return combineCodec( + getDenylisterChangedEncoder(), + getDenylisterChangedDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/depositForBurn.ts b/src/svm/clients/TokenMessengerMinterV2/types/depositForBurn.ts new file mode 100644 index 000000000..e8e7478fe --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/depositForBurn.ts @@ -0,0 +1,91 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export type DepositForBurn = { + burnToken: Address; + amount: bigint; + depositor: Address; + mintRecipient: Address; + destinationDomain: number; + destinationTokenMessenger: Address; + destinationCaller: Address; + maxFee: bigint; + minFinalityThreshold: number; + hookData: ReadonlyUint8Array; +}; + +export type DepositForBurnArgs = { + burnToken: Address; + amount: number | bigint; + depositor: Address; + mintRecipient: Address; + destinationDomain: number; + destinationTokenMessenger: Address; + destinationCaller: Address; + maxFee: number | bigint; + minFinalityThreshold: number; + hookData: ReadonlyUint8Array; +}; + +export function getDepositForBurnEncoder(): Encoder { + return getStructEncoder([ + ['burnToken', getAddressEncoder()], + ['amount', getU64Encoder()], + ['depositor', getAddressEncoder()], + ['mintRecipient', getAddressEncoder()], + ['destinationDomain', getU32Encoder()], + ['destinationTokenMessenger', getAddressEncoder()], + ['destinationCaller', getAddressEncoder()], + ['maxFee', getU64Encoder()], + ['minFinalityThreshold', getU32Encoder()], + ['hookData', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ]); +} + +export function getDepositForBurnDecoder(): Decoder { + return getStructDecoder([ + ['burnToken', getAddressDecoder()], + ['amount', getU64Decoder()], + ['depositor', getAddressDecoder()], + ['mintRecipient', getAddressDecoder()], + ['destinationDomain', getU32Decoder()], + ['destinationTokenMessenger', getAddressDecoder()], + ['destinationCaller', getAddressDecoder()], + ['maxFee', getU64Decoder()], + ['minFinalityThreshold', getU32Decoder()], + ['hookData', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ]); +} + +export function getDepositForBurnCodec(): Codec< + DepositForBurnArgs, + DepositForBurn +> { + return combineCodec(getDepositForBurnEncoder(), getDepositForBurnDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/feeRecipientSet.ts b/src/svm/clients/TokenMessengerMinterV2/types/feeRecipientSet.ts new file mode 100644 index 000000000..299a364c9 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/feeRecipientSet.ts @@ -0,0 +1,38 @@ +/** + * 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/kit'; + +export type FeeRecipientSet = { newFeeRecipient: Address }; + +export type FeeRecipientSetArgs = FeeRecipientSet; + +export function getFeeRecipientSetEncoder(): Encoder { + return getStructEncoder([['newFeeRecipient', getAddressEncoder()]]); +} + +export function getFeeRecipientSetDecoder(): Decoder { + return getStructDecoder([['newFeeRecipient', getAddressDecoder()]]); +} + +export function getFeeRecipientSetCodec(): Codec< + FeeRecipientSetArgs, + FeeRecipientSet +> { + return combineCodec(getFeeRecipientSetEncoder(), getFeeRecipientSetDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/handleReceiveMessageParams.ts b/src/svm/clients/TokenMessengerMinterV2/types/handleReceiveMessageParams.ts new file mode 100644 index 000000000..f99a66b9f --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/handleReceiveMessageParams.ts @@ -0,0 +1,68 @@ +/** + * 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 { + addDecoderSizePrefix, + addEncoderSizePrefix, + combineCodec, + getAddressDecoder, + getAddressEncoder, + getBytesDecoder, + getBytesEncoder, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + getU8Decoder, + getU8Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, + type ReadonlyUint8Array, +} from '@solana/kit'; + +export type HandleReceiveMessageParams = { + remoteDomain: number; + sender: Address; + finalityThresholdExecuted: number; + messageBody: ReadonlyUint8Array; + authorityBump: number; +}; + +export type HandleReceiveMessageParamsArgs = HandleReceiveMessageParams; + +export function getHandleReceiveMessageParamsEncoder(): Encoder { + return getStructEncoder([ + ['remoteDomain', getU32Encoder()], + ['sender', getAddressEncoder()], + ['finalityThresholdExecuted', getU32Encoder()], + ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], + ['authorityBump', getU8Encoder()], + ]); +} + +export function getHandleReceiveMessageParamsDecoder(): Decoder { + return getStructDecoder([ + ['remoteDomain', getU32Decoder()], + ['sender', getAddressDecoder()], + ['finalityThresholdExecuted', getU32Decoder()], + ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], + ['authorityBump', getU8Decoder()], + ]); +} + +export function getHandleReceiveMessageParamsCodec(): Codec< + HandleReceiveMessageParamsArgs, + HandleReceiveMessageParams +> { + return combineCodec( + getHandleReceiveMessageParamsEncoder(), + getHandleReceiveMessageParamsDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/index.ts b/src/svm/clients/TokenMessengerMinterV2/types/index.ts new file mode 100644 index 000000000..d7b73048e --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/index.ts @@ -0,0 +1,31 @@ +/** + * 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 './denylisted'; +export * from './denylisterChanged'; +export * from './depositForBurn'; +export * from './feeRecipientSet'; +export * from './handleReceiveMessageParams'; +export * from './localTokenAdded'; +export * from './localTokenRemoved'; +export * from './minFeeControllerSet'; +export * from './minFeeSet'; +export * from './mintAndWithdraw'; +export * from './ownershipTransferred'; +export * from './ownershipTransferStarted'; +export * from './pause'; +export * from './pauserChanged'; +export * from './remoteTokenMessengerAdded'; +export * from './remoteTokenMessengerRemoved'; +export * from './setBurnLimitPerMessage'; +export * from './setTokenController'; +export * from './tokenCustodyBurned'; +export * from './tokenPairLinked'; +export * from './tokenPairUnlinked'; +export * from './unDenylisted'; +export * from './unpause'; diff --git a/src/svm/clients/TokenMessengerMinterV2/types/localTokenAdded.ts b/src/svm/clients/TokenMessengerMinterV2/types/localTokenAdded.ts new file mode 100644 index 000000000..f74e5a7e5 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/localTokenAdded.ts @@ -0,0 +1,44 @@ +/** + * 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/kit'; + +export type LocalTokenAdded = { custody: Address; mint: Address }; + +export type LocalTokenAddedArgs = LocalTokenAdded; + +export function getLocalTokenAddedEncoder(): Encoder { + return getStructEncoder([ + ['custody', getAddressEncoder()], + ['mint', getAddressEncoder()], + ]); +} + +export function getLocalTokenAddedDecoder(): Decoder { + return getStructDecoder([ + ['custody', getAddressDecoder()], + ['mint', getAddressDecoder()], + ]); +} + +export function getLocalTokenAddedCodec(): Codec< + LocalTokenAddedArgs, + LocalTokenAdded +> { + return combineCodec(getLocalTokenAddedEncoder(), getLocalTokenAddedDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/localTokenRemoved.ts b/src/svm/clients/TokenMessengerMinterV2/types/localTokenRemoved.ts new file mode 100644 index 000000000..813080526 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/localTokenRemoved.ts @@ -0,0 +1,47 @@ +/** + * 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/kit'; + +export type LocalTokenRemoved = { custody: Address; mint: Address }; + +export type LocalTokenRemovedArgs = LocalTokenRemoved; + +export function getLocalTokenRemovedEncoder(): Encoder { + return getStructEncoder([ + ['custody', getAddressEncoder()], + ['mint', getAddressEncoder()], + ]); +} + +export function getLocalTokenRemovedDecoder(): Decoder { + return getStructDecoder([ + ['custody', getAddressDecoder()], + ['mint', getAddressDecoder()], + ]); +} + +export function getLocalTokenRemovedCodec(): Codec< + LocalTokenRemovedArgs, + LocalTokenRemoved +> { + return combineCodec( + getLocalTokenRemovedEncoder(), + getLocalTokenRemovedDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/minFeeControllerSet.ts b/src/svm/clients/TokenMessengerMinterV2/types/minFeeControllerSet.ts new file mode 100644 index 000000000..459cd7b5c --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/minFeeControllerSet.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/kit'; + +export type MinFeeControllerSet = { newMinFeeController: Address }; + +export type MinFeeControllerSetArgs = MinFeeControllerSet; + +export function getMinFeeControllerSetEncoder(): Encoder { + return getStructEncoder([['newMinFeeController', getAddressEncoder()]]); +} + +export function getMinFeeControllerSetDecoder(): Decoder { + return getStructDecoder([['newMinFeeController', getAddressDecoder()]]); +} + +export function getMinFeeControllerSetCodec(): Codec< + MinFeeControllerSetArgs, + MinFeeControllerSet +> { + return combineCodec( + getMinFeeControllerSetEncoder(), + getMinFeeControllerSetDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/minFeeSet.ts b/src/svm/clients/TokenMessengerMinterV2/types/minFeeSet.ts new file mode 100644 index 000000000..2a7cad1cb --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/minFeeSet.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, + getU32Decoder, + getU32Encoder, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type MinFeeSet = { newMinFee: number }; + +export type MinFeeSetArgs = MinFeeSet; + +export function getMinFeeSetEncoder(): Encoder { + return getStructEncoder([['newMinFee', getU32Encoder()]]); +} + +export function getMinFeeSetDecoder(): Decoder { + return getStructDecoder([['newMinFee', getU32Decoder()]]); +} + +export function getMinFeeSetCodec(): Codec { + return combineCodec(getMinFeeSetEncoder(), getMinFeeSetDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/mintAndWithdraw.ts b/src/svm/clients/TokenMessengerMinterV2/types/mintAndWithdraw.ts new file mode 100644 index 000000000..8d73db814 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/mintAndWithdraw.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, + getAddressDecoder, + getAddressEncoder, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type MintAndWithdraw = { + mintRecipient: Address; + amount: bigint; + mintToken: Address; + feeCollected: bigint; +}; + +export type MintAndWithdrawArgs = { + mintRecipient: Address; + amount: number | bigint; + mintToken: Address; + feeCollected: number | bigint; +}; + +export function getMintAndWithdrawEncoder(): Encoder { + return getStructEncoder([ + ['mintRecipient', getAddressEncoder()], + ['amount', getU64Encoder()], + ['mintToken', getAddressEncoder()], + ['feeCollected', getU64Encoder()], + ]); +} + +export function getMintAndWithdrawDecoder(): Decoder { + return getStructDecoder([ + ['mintRecipient', getAddressDecoder()], + ['amount', getU64Decoder()], + ['mintToken', getAddressDecoder()], + ['feeCollected', getU64Decoder()], + ]); +} + +export function getMintAndWithdrawCodec(): Codec< + MintAndWithdrawArgs, + MintAndWithdraw +> { + return combineCodec(getMintAndWithdrawEncoder(), getMintAndWithdrawDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferStarted.ts b/src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferStarted.ts new file mode 100644 index 000000000..e170a569a --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferStarted.ts @@ -0,0 +1,50 @@ +/** + * 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/kit'; + +export type OwnershipTransferStarted = { + previousOwner: Address; + newOwner: Address; +}; + +export type OwnershipTransferStartedArgs = OwnershipTransferStarted; + +export function getOwnershipTransferStartedEncoder(): Encoder { + return getStructEncoder([ + ['previousOwner', getAddressEncoder()], + ['newOwner', getAddressEncoder()], + ]); +} + +export function getOwnershipTransferStartedDecoder(): Decoder { + return getStructDecoder([ + ['previousOwner', getAddressDecoder()], + ['newOwner', getAddressDecoder()], + ]); +} + +export function getOwnershipTransferStartedCodec(): Codec< + OwnershipTransferStartedArgs, + OwnershipTransferStarted +> { + return combineCodec( + getOwnershipTransferStartedEncoder(), + getOwnershipTransferStartedDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferred.ts b/src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferred.ts new file mode 100644 index 000000000..40f21c661 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferred.ts @@ -0,0 +1,50 @@ +/** + * 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/kit'; + +export type OwnershipTransferred = { + previousOwner: Address; + newOwner: Address; +}; + +export type OwnershipTransferredArgs = OwnershipTransferred; + +export function getOwnershipTransferredEncoder(): Encoder { + return getStructEncoder([ + ['previousOwner', getAddressEncoder()], + ['newOwner', getAddressEncoder()], + ]); +} + +export function getOwnershipTransferredDecoder(): Decoder { + return getStructDecoder([ + ['previousOwner', getAddressDecoder()], + ['newOwner', getAddressDecoder()], + ]); +} + +export function getOwnershipTransferredCodec(): Codec< + OwnershipTransferredArgs, + OwnershipTransferred +> { + return combineCodec( + getOwnershipTransferredEncoder(), + getOwnershipTransferredDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/pause.ts b/src/svm/clients/TokenMessengerMinterV2/types/pause.ts new file mode 100644 index 000000000..f1f423325 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/pause.ts @@ -0,0 +1,32 @@ +/** + * 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, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type Pause = {}; + +export type PauseArgs = Pause; + +export function getPauseEncoder(): Encoder { + return getStructEncoder([]); +} + +export function getPauseDecoder(): Decoder { + return getStructDecoder([]); +} + +export function getPauseCodec(): Codec { + return combineCodec(getPauseEncoder(), getPauseDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/pauserChanged.ts b/src/svm/clients/TokenMessengerMinterV2/types/pauserChanged.ts new file mode 100644 index 000000000..57d7433da --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/pauserChanged.ts @@ -0,0 +1,38 @@ +/** + * 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/kit'; + +export type PauserChanged = { newAddress: Address }; + +export type PauserChangedArgs = PauserChanged; + +export function getPauserChangedEncoder(): Encoder { + return getStructEncoder([['newAddress', getAddressEncoder()]]); +} + +export function getPauserChangedDecoder(): Decoder { + return getStructDecoder([['newAddress', getAddressDecoder()]]); +} + +export function getPauserChangedCodec(): Codec< + PauserChangedArgs, + PauserChanged +> { + return combineCodec(getPauserChangedEncoder(), getPauserChangedDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerAdded.ts b/src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerAdded.ts new file mode 100644 index 000000000..f2586db0b --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerAdded.ts @@ -0,0 +1,52 @@ +/** + * 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, + getU32Decoder, + getU32Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type RemoteTokenMessengerAdded = { + domain: number; + tokenMessenger: Address; +}; + +export type RemoteTokenMessengerAddedArgs = RemoteTokenMessengerAdded; + +export function getRemoteTokenMessengerAddedEncoder(): Encoder { + return getStructEncoder([ + ['domain', getU32Encoder()], + ['tokenMessenger', getAddressEncoder()], + ]); +} + +export function getRemoteTokenMessengerAddedDecoder(): Decoder { + return getStructDecoder([ + ['domain', getU32Decoder()], + ['tokenMessenger', getAddressDecoder()], + ]); +} + +export function getRemoteTokenMessengerAddedCodec(): Codec< + RemoteTokenMessengerAddedArgs, + RemoteTokenMessengerAdded +> { + return combineCodec( + getRemoteTokenMessengerAddedEncoder(), + getRemoteTokenMessengerAddedDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerRemoved.ts b/src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerRemoved.ts new file mode 100644 index 000000000..290c643bc --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerRemoved.ts @@ -0,0 +1,52 @@ +/** + * 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, + getU32Decoder, + getU32Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type RemoteTokenMessengerRemoved = { + domain: number; + tokenMessenger: Address; +}; + +export type RemoteTokenMessengerRemovedArgs = RemoteTokenMessengerRemoved; + +export function getRemoteTokenMessengerRemovedEncoder(): Encoder { + return getStructEncoder([ + ['domain', getU32Encoder()], + ['tokenMessenger', getAddressEncoder()], + ]); +} + +export function getRemoteTokenMessengerRemovedDecoder(): Decoder { + return getStructDecoder([ + ['domain', getU32Decoder()], + ['tokenMessenger', getAddressDecoder()], + ]); +} + +export function getRemoteTokenMessengerRemovedCodec(): Codec< + RemoteTokenMessengerRemovedArgs, + RemoteTokenMessengerRemoved +> { + return combineCodec( + getRemoteTokenMessengerRemovedEncoder(), + getRemoteTokenMessengerRemovedDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/setBurnLimitPerMessage.ts b/src/svm/clients/TokenMessengerMinterV2/types/setBurnLimitPerMessage.ts new file mode 100644 index 000000000..8c28725c2 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/setBurnLimitPerMessage.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, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type SetBurnLimitPerMessage = { + token: Address; + burnLimitPerMessage: bigint; +}; + +export type SetBurnLimitPerMessageArgs = { + token: Address; + burnLimitPerMessage: number | bigint; +}; + +export function getSetBurnLimitPerMessageEncoder(): Encoder { + return getStructEncoder([ + ['token', getAddressEncoder()], + ['burnLimitPerMessage', getU64Encoder()], + ]); +} + +export function getSetBurnLimitPerMessageDecoder(): Decoder { + return getStructDecoder([ + ['token', getAddressDecoder()], + ['burnLimitPerMessage', getU64Decoder()], + ]); +} + +export function getSetBurnLimitPerMessageCodec(): Codec< + SetBurnLimitPerMessageArgs, + SetBurnLimitPerMessage +> { + return combineCodec( + getSetBurnLimitPerMessageEncoder(), + getSetBurnLimitPerMessageDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/setTokenController.ts b/src/svm/clients/TokenMessengerMinterV2/types/setTokenController.ts new file mode 100644 index 000000000..3b6c01571 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/setTokenController.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/kit'; + +export type SetTokenController = { tokenController: Address }; + +export type SetTokenControllerArgs = SetTokenController; + +export function getSetTokenControllerEncoder(): Encoder { + return getStructEncoder([['tokenController', getAddressEncoder()]]); +} + +export function getSetTokenControllerDecoder(): Decoder { + return getStructDecoder([['tokenController', getAddressDecoder()]]); +} + +export function getSetTokenControllerCodec(): Codec< + SetTokenControllerArgs, + SetTokenController +> { + return combineCodec( + getSetTokenControllerEncoder(), + getSetTokenControllerDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/tokenCustodyBurned.ts b/src/svm/clients/TokenMessengerMinterV2/types/tokenCustodyBurned.ts new file mode 100644 index 000000000..4b90fc0d7 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/tokenCustodyBurned.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, + getStructDecoder, + getStructEncoder, + getU64Decoder, + getU64Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type TokenCustodyBurned = { + custodyTokenAccount: Address; + amount: bigint; +}; + +export type TokenCustodyBurnedArgs = { + custodyTokenAccount: Address; + amount: number | bigint; +}; + +export function getTokenCustodyBurnedEncoder(): Encoder { + return getStructEncoder([ + ['custodyTokenAccount', getAddressEncoder()], + ['amount', getU64Encoder()], + ]); +} + +export function getTokenCustodyBurnedDecoder(): Decoder { + return getStructDecoder([ + ['custodyTokenAccount', getAddressDecoder()], + ['amount', getU64Decoder()], + ]); +} + +export function getTokenCustodyBurnedCodec(): Codec< + TokenCustodyBurnedArgs, + TokenCustodyBurned +> { + return combineCodec( + getTokenCustodyBurnedEncoder(), + getTokenCustodyBurnedDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/tokenPairLinked.ts b/src/svm/clients/TokenMessengerMinterV2/types/tokenPairLinked.ts new file mode 100644 index 000000000..3d4e2027d --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/tokenPairLinked.ts @@ -0,0 +1,52 @@ +/** + * 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, + getU32Decoder, + getU32Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type TokenPairLinked = { + localToken: Address; + remoteDomain: number; + remoteToken: Address; +}; + +export type TokenPairLinkedArgs = TokenPairLinked; + +export function getTokenPairLinkedEncoder(): Encoder { + return getStructEncoder([ + ['localToken', getAddressEncoder()], + ['remoteDomain', getU32Encoder()], + ['remoteToken', getAddressEncoder()], + ]); +} + +export function getTokenPairLinkedDecoder(): Decoder { + return getStructDecoder([ + ['localToken', getAddressDecoder()], + ['remoteDomain', getU32Decoder()], + ['remoteToken', getAddressDecoder()], + ]); +} + +export function getTokenPairLinkedCodec(): Codec< + TokenPairLinkedArgs, + TokenPairLinked +> { + return combineCodec(getTokenPairLinkedEncoder(), getTokenPairLinkedDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/tokenPairUnlinked.ts b/src/svm/clients/TokenMessengerMinterV2/types/tokenPairUnlinked.ts new file mode 100644 index 000000000..714376fdd --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/tokenPairUnlinked.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, + getStructDecoder, + getStructEncoder, + getU32Decoder, + getU32Encoder, + type Address, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type TokenPairUnlinked = { + localToken: Address; + remoteDomain: number; + remoteToken: Address; +}; + +export type TokenPairUnlinkedArgs = TokenPairUnlinked; + +export function getTokenPairUnlinkedEncoder(): Encoder { + return getStructEncoder([ + ['localToken', getAddressEncoder()], + ['remoteDomain', getU32Encoder()], + ['remoteToken', getAddressEncoder()], + ]); +} + +export function getTokenPairUnlinkedDecoder(): Decoder { + return getStructDecoder([ + ['localToken', getAddressDecoder()], + ['remoteDomain', getU32Decoder()], + ['remoteToken', getAddressDecoder()], + ]); +} + +export function getTokenPairUnlinkedCodec(): Codec< + TokenPairUnlinkedArgs, + TokenPairUnlinked +> { + return combineCodec( + getTokenPairUnlinkedEncoder(), + getTokenPairUnlinkedDecoder() + ); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/unDenylisted.ts b/src/svm/clients/TokenMessengerMinterV2/types/unDenylisted.ts new file mode 100644 index 000000000..e60f24876 --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/unDenylisted.ts @@ -0,0 +1,35 @@ +/** + * 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/kit'; + +export type UnDenylisted = { account: Address }; + +export type UnDenylistedArgs = UnDenylisted; + +export function getUnDenylistedEncoder(): Encoder { + return getStructEncoder([['account', getAddressEncoder()]]); +} + +export function getUnDenylistedDecoder(): Decoder { + return getStructDecoder([['account', getAddressDecoder()]]); +} + +export function getUnDenylistedCodec(): Codec { + return combineCodec(getUnDenylistedEncoder(), getUnDenylistedDecoder()); +} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/unpause.ts b/src/svm/clients/TokenMessengerMinterV2/types/unpause.ts new file mode 100644 index 000000000..4fdc009ef --- /dev/null +++ b/src/svm/clients/TokenMessengerMinterV2/types/unpause.ts @@ -0,0 +1,32 @@ +/** + * 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, + type Codec, + type Decoder, + type Encoder, +} from '@solana/kit'; + +export type Unpause = {}; + +export type UnpauseArgs = Unpause; + +export function getUnpauseEncoder(): Encoder { + return getStructEncoder([]); +} + +export function getUnpauseDecoder(): Decoder { + return getStructDecoder([]); +} + +export function getUnpauseCodec(): Codec { + return combineCodec(getUnpauseEncoder(), getUnpauseDecoder()); +} diff --git a/src/svm/clients/index.ts b/src/svm/clients/index.ts new file mode 100644 index 000000000..e5857a0c7 --- /dev/null +++ b/src/svm/clients/index.ts @@ -0,0 +1,17 @@ +import * as MulticallHandlerClient from "./MulticallHandler"; +import * as SvmSpokeClient from "./SvmSpoke"; +import * as MessageTransmitterClient from "./MessageTransmitter"; +import * as TokenMessengerMinterClient from "./TokenMessengerMinter"; +import * as MessageTransmitterV2Client from "./MessageTransmitterV2"; +import * as TokenMessengerMinterV2Client from "./TokenMessengerMinterV2"; +import * as SponsoredCctpSrcPeripheryClient from "./SponsoredCctpSrcPeriphery"; + +export { + MulticallHandlerClient, + SvmSpokeClient, + MessageTransmitterClient, + TokenMessengerMinterClient, + MessageTransmitterV2Client, + TokenMessengerMinterV2Client, + SponsoredCctpSrcPeripheryClient, +}; diff --git a/src/svm/index.ts b/src/svm/index.ts new file mode 100644 index 000000000..b9851e1b0 --- /dev/null +++ b/src/svm/index.ts @@ -0,0 +1,26 @@ +// SVM (Solana) utilities — moved from @across-protocol/contracts +// See ACP-56 for context on this migration. + +// Re-export SVM types +export * from "./types.svm"; + +// web3-v1 (Anchor/web3.js v1) — selective top-level exports +// (matches the original @across-protocol/contracts public API) +// Additional web3-v1 utils are accessible via deep imports: +// import { ... } from "@across-protocol/sdk/dist/cjs/src/svm/web3-v1" +export { + AcrossPlusMessageCoder, + calculateRelayHashUint8Array, + findProgramAddress, + MulticallHandlerCoder, + relayerRefundHashFn, +} from "./web3-v1"; + +// web3-v2 (Solana Kit) — all exports +export * from "./web3-v2"; + +// Auto-generated assets (IDL definitions and Anchor types) +export * from "./assets"; + +// Auto-generated Codama clients +export * from "./clients"; diff --git a/src/svm/types.svm.ts b/src/svm/types.svm.ts new file mode 100644 index 000000000..b3fd17ee7 --- /dev/null +++ b/src/svm/types.svm.ts @@ -0,0 +1,138 @@ +import { BN } from "@coral-xyz/anchor"; +import { PublicKey } from "@solana/web3.js"; +import { BigNumber } from "ethers"; + +/** + * Relayer Refund Interfaces + */ +export interface RelayerRefundLeaf { + isSolana: boolean; + amountToReturn: BigNumber; + chainId: BigNumber; + refundAmounts: BigNumber[]; + leafId: BigNumber; + l2TokenAddress: string; + refundAddresses: string[]; +} + +export interface RelayerRefundLeafSolana { + isSolana: boolean; + amountToReturn: BN; + chainId: BN; + refundAmounts: BN[]; + leafId: BN; + mintPublicKey: PublicKey; + refundAddresses: PublicKey[]; +} + +export type RelayerRefundLeafType = RelayerRefundLeaf | RelayerRefundLeafSolana; + +/** + * Slow Fill Leaf Interface + */ +export interface SlowFillLeaf { + relayData: RelayData; + chainId: BN; + updatedOutputAmount: BN; +} + +/** + * Relay Data Interface + */ +export type RelayData = { + depositor: PublicKey; + recipient: PublicKey; + exclusiveRelayer: PublicKey; + inputToken: PublicKey; + outputToken: PublicKey; + inputAmount: number[]; + outputAmount: BN; + originChainId: BN; + depositId: number[]; + fillDeadline: number; + exclusivityDeadline: number; + message: Buffer; +}; + +/** + * Deposit Data Interfaces + */ +export interface DepositData { + depositor: PublicKey | null; + recipient: PublicKey; + inputToken: PublicKey | null; + outputToken: PublicKey; + inputAmount: BN; + outputAmount: number[]; + destinationChainId: BN; + exclusiveRelayer: PublicKey; + quoteTimestamp: BN; + fillDeadline: BN; + exclusivityParameter: BN; + message: Buffer; +} + +export type DepositDataValues = [ + PublicKey, + PublicKey, + PublicKey, + PublicKey, + BN, + number[], + BN, + PublicKey, + number, + number, + number, + Buffer, +]; + +/** + * Fill Data Interfaces + */ +export type FillDataValues = [number[], RelayData, BN, PublicKey]; + +export type FillDataParams = [number[], RelayData | null, BN | null, PublicKey | null]; + +/** + * Request Slow Fill Data Interfaces + */ +export type RequestSlowFillDataValues = [number[], RelayData]; + +export type RequestSlowFillDataParams = [number[], RelayData | null]; + +/** + * Execute Slow Relay Leaf Data Interfaces + */ +export type ExecuteSlowRelayLeafDataValues = [number[], SlowFillLeaf, number, number[][]]; + +export type ExecuteSlowRelayLeafDataParams = [number[], SlowFillLeaf | null, number | null, number[][] | null]; + +/** + * Across+ Message Interface + */ +export type AcrossPlusMessage = { + handler: PublicKey; + readOnlyLen: number; + valueAmount: BN; + accounts: PublicKey[]; + handlerMessage: Buffer; +}; + +/** + * Event Type Interface + */ +export interface EventType { + program: PublicKey; + data: any; + name: string; + slot: number; + confirmationStatus: string; + blockTime: number; + signature: string; +} + +/** + * Supported Networks + */ +export type SupportedNetworks = "mainnet" | "devnet"; diff --git a/src/svm/web3-v1/buffer-layout.d.ts b/src/svm/web3-v1/buffer-layout.d.ts new file mode 100644 index 000000000..a319c3fb6 --- /dev/null +++ b/src/svm/web3-v1/buffer-layout.d.ts @@ -0,0 +1,10 @@ +declare module "buffer-layout" { + export class Layout { + span: number; + property?: string; + decode(b: Buffer, offset?: number): T; + encode(src: T, b: Buffer, offset?: number): number; + getSpan(b?: Buffer, offset?: number): number; + replicate(name: string): this; + } +} diff --git a/src/svm/web3-v1/cctpHelpers.ts b/src/svm/web3-v1/cctpHelpers.ts new file mode 100644 index 000000000..520f43fdd --- /dev/null +++ b/src/svm/web3-v1/cctpHelpers.ts @@ -0,0 +1,181 @@ +import * as anchor from "@coral-xyz/anchor"; +import { array, object, optional, string, Struct } from "superstruct"; +import { readUInt256BE } from "./relayHashUtils"; + +// Index positions to decode Message Header from +// https://developers.circle.com/cctp/v1/message-format#cctp-v1-message-header +const HEADER_VERSION_INDEX = 0; +const SOURCE_DOMAIN_INDEX = 4; +const DESTINATION_DOMAIN_INDEX = 8; +const NONCE_INDEX = 12; +const HEADER_SENDER_INDEX = 20; +const HEADER_RECIPIENT_INDEX = 52; +const DESTINATION_CALLER_INDEX = 84; +const MESSAGE_BODY_INDEX = 116; + +// Index positions to decode Message Body for TokenMessenger from +// https://developers.circle.com/cctp/v1/message-format#cctp-v1-message-body +const BODY_VERSION_INDEX = 0; +const BURN_TOKEN_INDEX = 4; +const MINT_RECIPIENT_INDEX = 36; +const AMOUNT_INDEX = 68; +const MESSAGE_SENDER_INDEX = 100; + +/** + * Type for the body of a TokenMessenger message. + */ +export type TokenMessengerMessageBody = { + version: number; + burnToken: anchor.web3.PublicKey; + mintRecipient: anchor.web3.PublicKey; + amount: BigInt; + messageSender: anchor.web3.PublicKey; +}; + +/** + * Type for the header of a CCTP message. + */ +export type MessageHeader = { + version: number; + sourceDomain: number; + destinationDomain: number; + nonce: bigint; + sender: anchor.web3.PublicKey; + recipient: anchor.web3.PublicKey; + destinationCaller: anchor.web3.PublicKey; + messageBody: Buffer; +}; + +/** + * Decodes a CCTP message into a MessageHeader and TokenMessengerMessageBody. + */ +export const decodeMessageSentData = (message: Buffer) => { + const messageHeader = decodeMessageHeader(message); + + const messageBodyData = message.slice(MESSAGE_BODY_INDEX); + + const messageBody = decodeTokenMessengerMessageBody(messageBodyData); + + return { ...messageHeader, messageBody }; +}; + +/** + * Decodes a CCTP message header. + */ +export const decodeMessageHeader = (data: Buffer): MessageHeader => { + const version = data.readUInt32BE(HEADER_VERSION_INDEX); + const sourceDomain = data.readUInt32BE(SOURCE_DOMAIN_INDEX); + const destinationDomain = data.readUInt32BE(DESTINATION_DOMAIN_INDEX); + const nonce = data.readBigUInt64BE(NONCE_INDEX); + const sender = new anchor.web3.PublicKey(data.slice(HEADER_SENDER_INDEX, HEADER_SENDER_INDEX + 32)); + const recipient = new anchor.web3.PublicKey(data.slice(HEADER_RECIPIENT_INDEX, HEADER_RECIPIENT_INDEX + 32)); + const destinationCaller = new anchor.web3.PublicKey( + data.slice(DESTINATION_CALLER_INDEX, DESTINATION_CALLER_INDEX + 32) + ); + const messageBody = data.slice(MESSAGE_BODY_INDEX); + return { + version, + sourceDomain, + destinationDomain, + nonce, + sender, + recipient, + destinationCaller, + messageBody, + }; +}; + +/** + * Decodes a TokenMessenger message body. + */ +export const decodeTokenMessengerMessageBody = (data: Buffer): TokenMessengerMessageBody => { + const version = data.readUInt32BE(BODY_VERSION_INDEX); + const burnToken = new anchor.web3.PublicKey(data.slice(BURN_TOKEN_INDEX, BURN_TOKEN_INDEX + 32)); + const mintRecipient = new anchor.web3.PublicKey(data.slice(MINT_RECIPIENT_INDEX, MINT_RECIPIENT_INDEX + 32)); + const amount = readUInt256BE(data.slice(AMOUNT_INDEX, AMOUNT_INDEX + 32)); + const messageSender = new anchor.web3.PublicKey(data.slice(MESSAGE_SENDER_INDEX, MESSAGE_SENDER_INDEX + 32)); + return { version, burnToken, mintRecipient, amount, messageSender }; +}; + +/** + * Encodes a MessageHeader into a Buffer. + */ +export const encodeMessageHeader = (header: MessageHeader): Buffer => { + const message = Buffer.alloc(MESSAGE_BODY_INDEX + header.messageBody.length); + + message.writeUInt32BE(header.version, HEADER_VERSION_INDEX); + message.writeUInt32BE(header.sourceDomain, SOURCE_DOMAIN_INDEX); + message.writeUInt32BE(header.destinationDomain, DESTINATION_DOMAIN_INDEX); + message.writeBigUInt64BE(header.nonce, NONCE_INDEX); + header.sender.toBuffer().copy(message, HEADER_SENDER_INDEX); + header.recipient.toBuffer().copy(message, HEADER_RECIPIENT_INDEX); + header.destinationCaller.toBuffer().copy(message, DESTINATION_CALLER_INDEX); + header.messageBody.copy(message, MESSAGE_BODY_INDEX); + + return message; +}; + +/** + * Type for the attestation response from the attestation service. + */ +type AttestationResponse = { + error?: string; + messages: { + attestation: string; + message: string; + eventNonce: string; + }[]; +}; + +/** + * Structure for the attestation response from the attestation service. + */ +const AttestationResponseStruct: Struct = object({ + error: optional(string()), + messages: array( + object({ + attestation: string(), + message: string(), + eventNonce: string(), + }) + ), +}); + +/** + * Fetches attestation from attestation service given the txHash. + */ +export const getMessages = async ( + txHash: string, + srcDomain: number, + irisApiUrl: string +): Promise => { + console.log("Fetching attestations and messages for tx...", txHash); + let attestationResponse: any = {}; + while ( + attestationResponse.error || + !attestationResponse.messages || + attestationResponse.messages?.[0]?.attestation === "PENDING" + ) { + const response = await fetch(`${irisApiUrl}/messages/${srcDomain}/${txHash}`); + attestationResponse = await response.json(); + + // Wait 2 seconds to avoid getting rate limited + if ( + attestationResponse.error || + !attestationResponse.messages || + attestationResponse.messages?.[0]?.attestation === "PENDING" + ) { + await new Promise((r) => setTimeout(r, 2000)); + } + } + + // Validate the response structure + try { + AttestationResponseStruct.assert(attestationResponse); + } catch (error) { + console.error("Invalid attestation response structure:", error); + throw new Error("Invalid attestation response structure"); + } + + return attestationResponse; +}; diff --git a/src/svm/web3-v1/cctpV2Helpers.ts b/src/svm/web3-v1/cctpV2Helpers.ts new file mode 100644 index 000000000..b34b3ab96 --- /dev/null +++ b/src/svm/web3-v1/cctpV2Helpers.ts @@ -0,0 +1,253 @@ +import * as anchor from "@coral-xyz/anchor"; +import { array, enums, object, optional, string, union, nullable, Infer, coerce } from "superstruct"; +import { ethers } from "ethers"; +import { assert } from "superstruct"; +import { readUInt256BE } from "./relayHashUtils"; +import { addressOrBase58ToBytes32 } from "./conversionUtils"; + +// Index positions to decode Message Header from +// https://developers.circle.com/cctp/technical-guide#message-header +const HEADER_VERSION_INDEX = 0; +const SOURCE_DOMAIN_INDEX = 4; +const DESTINATION_DOMAIN_INDEX = 8; +const NONCE_INDEX = 12; +const HEADER_SENDER_INDEX = 44; +const HEADER_RECIPIENT_INDEX = 76; +const DESTINATION_CALLER_INDEX = 108; +const MIN_FINALITY_THRESHOLD_INDEX = 140; +const FINALITY_THRESHOLD_EXECUTED_INDEX = 144; +const MESSAGE_BODY_INDEX = 148; + +// Index positions to decode Message Body for TokenMessengerV2 from +// https://developers.circle.com/cctp/technical-guide#message-body +const BODY_VERSION_INDEX = 0; +const BURN_TOKEN_INDEX = 4; +const MINT_RECIPIENT_INDEX = 36; +const AMOUNT_INDEX = 68; +const MESSAGE_SENDER_INDEX = 100; +const MAX_FEE_INDEX = 132; +const FEE_EXECUTED_INDEX = 164; +const EXPIRATION_BLOCK = 196; +const HOOK_DATA_INDEX = 228; + +export const EVENT_ACCOUNT_WINDOW_SECONDS = 60 * 60 * 24 * 5; // 60 secs * 60 mins * 24 hours * 5 days = 5 days in seconds + +/** + * Type for the body of a TokenMessengerV2 message. + */ +export type TokenMessengerV2MessageBody = { + version: number; + burnToken: anchor.web3.PublicKey; + mintRecipient: anchor.web3.PublicKey; + amount: BigInt; + messageSender: anchor.web3.PublicKey; + maxFee: BigInt; + feeExecuted: BigInt; + expirationBlock: BigInt; + hookData: Buffer; +}; + +/** + * Type for the header of a CCTPv2 message. + */ +export type MessageHeaderV2 = { + version: number; + sourceDomain: number; + destinationDomain: number; + nonce: BigInt; + sender: anchor.web3.PublicKey; + recipient: anchor.web3.PublicKey; + destinationCaller: anchor.web3.PublicKey; + minFinalityThreshold: number; + finalityThresholdExecuted: number; + messageBody: Buffer; +}; + +/** + * Decodes a CCTPv2 message into a MessageHeaderV2 and TokenMessengerV2MessageBody. + */ +export const decodeMessageSentDataV2 = (message: Buffer) => { + const messageHeader = decodeMessageHeaderV2(message); + + const messageBodyData = message.slice(MESSAGE_BODY_INDEX); + + const messageBody = decodeTokenMessengerV2MessageBody(messageBodyData); + + return { ...messageHeader, messageBody }; +}; + +/** + * Decodes a CCTPv2 message header. + */ +export const decodeMessageHeaderV2 = (data: Buffer): MessageHeaderV2 => { + const version = data.readUInt32BE(HEADER_VERSION_INDEX); + const sourceDomain = data.readUInt32BE(SOURCE_DOMAIN_INDEX); + const destinationDomain = data.readUInt32BE(DESTINATION_DOMAIN_INDEX); + const nonce = readUInt256BE(data.slice(NONCE_INDEX, NONCE_INDEX + 32)); + const sender = new anchor.web3.PublicKey(data.slice(HEADER_SENDER_INDEX, HEADER_SENDER_INDEX + 32)); + const recipient = new anchor.web3.PublicKey(data.slice(HEADER_RECIPIENT_INDEX, HEADER_RECIPIENT_INDEX + 32)); + const destinationCaller = new anchor.web3.PublicKey( + data.slice(DESTINATION_CALLER_INDEX, DESTINATION_CALLER_INDEX + 32) + ); + const minFinalityThreshold = data.readUInt32BE(MIN_FINALITY_THRESHOLD_INDEX); + const finalityThresholdExecuted = data.readUInt32BE(FINALITY_THRESHOLD_EXECUTED_INDEX); + const messageBody = data.slice(MESSAGE_BODY_INDEX); + return { + version, + sourceDomain, + destinationDomain, + nonce, + sender, + recipient, + destinationCaller, + minFinalityThreshold, + finalityThresholdExecuted, + messageBody, + }; +}; + +/** + * Decodes a TokenMessenger message body. + */ +export const decodeTokenMessengerV2MessageBody = (data: Buffer): TokenMessengerV2MessageBody => { + const version = data.readUInt32BE(BODY_VERSION_INDEX); + const burnToken = new anchor.web3.PublicKey(data.slice(BURN_TOKEN_INDEX, BURN_TOKEN_INDEX + 32)); + const mintRecipient = new anchor.web3.PublicKey(data.slice(MINT_RECIPIENT_INDEX, MINT_RECIPIENT_INDEX + 32)); + const amount = readUInt256BE(data.slice(AMOUNT_INDEX, AMOUNT_INDEX + 32)); + const messageSender = new anchor.web3.PublicKey(data.slice(MESSAGE_SENDER_INDEX, MESSAGE_SENDER_INDEX + 32)); + const maxFee = readUInt256BE(data.slice(MAX_FEE_INDEX, MAX_FEE_INDEX + 32)); + const feeExecuted = readUInt256BE(data.slice(FEE_EXECUTED_INDEX, FEE_EXECUTED_INDEX + 32)); + const expirationBlock = readUInt256BE(data.slice(EXPIRATION_BLOCK, EXPIRATION_BLOCK + 32)); + const hookData = data.slice(HOOK_DATA_INDEX); + return { version, burnToken, mintRecipient, amount, messageSender, maxFee, feeExecuted, expirationBlock, hookData }; +}; + +// Below structs defines the types for CCTP attestation API as documented in +// https://developers.circle.com/api-reference/cctp/all/get-messages-v-2 + +// DecodedMessage.decodedMessageBody (V1/V2; some fields V2-only) +export const DecodedMessageBody = object({ + burnToken: string(), + mintRecipient: string(), + amount: string(), + messageSender: string(), + // V2-only + maxFee: optional(string()), + feeExecuted: optional(string()), + expirationBlock: optional(string()), + hookData: optional(string()), +}); + +// DecodedMessage (nullable/empty if decoding fails) +// minFinalityThreshold & finalityThresholdExecuted are V2-only +export const DecodedMessage = object({ + sourceDomain: string(), + destinationDomain: string(), + nonce: string(), + sender: string(), + recipient: string(), + destinationCaller: string(), + minFinalityThreshold: optional(enums(["1000", "2000"])), + finalityThresholdExecuted: optional(enums(["1000", "2000"])), + messageBody: string(), + decodedMessageBody: optional( + coerce(nullable(DecodedMessageBody), union([nullable(DecodedMessageBody), object({})]), (v) => + isEmptyObject(v) ? null : v + ) + ), +}); + +// Each message item +export const AttestationMessage = object({ + message: string(), // "0x" when not available + eventNonce: string(), + attestation: string(), // "PENDING" when not available + decodedMessage: optional( + coerce(nullable(DecodedMessage), union([nullable(DecodedMessage), object({})]), (v) => + isEmptyObject(v) ? null : v + ) + ), + cctpVersion: enums([1, 2]), + status: enums(["complete", "pending_confirmations"]), + // Only present in some delayed cases + delayReason: optional(nullable(enums(["insufficient_fee", "amount_above_max", "insufficient_allowance_available"]))), +}); + +// Top-level 200 response +export const AttestationResponse = object({ + messages: array(AttestationMessage), +}); + +export type TAttestationResponse = Infer; +export type TAttestationMessage = Infer; +export type TDecodedMessage = Infer; +export type TDecodedMessageBody = Infer; + +const isEmptyObject = (v: unknown) => + v != null && typeof v === "object" && !Array.isArray(v) && Object.keys(v).length === 0; + +/** + * Fetches attestation from attestation service given the txHash and source message for CCTP V2 token burn. + */ +export async function getV2BurnAttestation( + txSignature: string, + sourceMessageData: Buffer, + irisApiUrl: string +): Promise<{ destinationMessage: Buffer; attestation: Buffer } | null> { + const sourceMessage = decodeMessageSentDataV2(sourceMessageData); + + const attestationResponse = await ( + await fetch(`${irisApiUrl}/v2/messages/${sourceMessage.sourceDomain}/?transactionHash=${txSignature}`) + ).json(); + if (attestationResponse.error) return null; + assert(attestationResponse, AttestationResponse); + + // Return the first attested message that matches the source message. + for (const message of attestationResponse.messages) { + if ( + message.message !== "0x" && + message.attestation !== "PENDING" && + !!message.decodedMessage && + isMatchingV2BurnMessage(sourceMessage, message.decodedMessage) + ) { + return { + destinationMessage: Buffer.from(ethers.utils.arrayify(message.message)), + attestation: Buffer.from(ethers.utils.arrayify(message.attestation)), + }; + } + } + return null; +} + +function isMatchingV2BurnMessage( + sourceMessage: ReturnType, + destinationMessage: TDecodedMessage +): boolean { + if (!destinationMessage.decodedMessageBody) return false; + + return ( + sourceMessage.sourceDomain.toString() === destinationMessage.sourceDomain && + sourceMessage.destinationDomain.toString() === destinationMessage.destinationDomain && + // nonce is only set on destination + addressOrBase58ToBytes32(sourceMessage.sender.toString()) === addressOrBase58ToBytes32(destinationMessage.sender) && + addressOrBase58ToBytes32(sourceMessage.recipient.toString()) === + addressOrBase58ToBytes32(destinationMessage.recipient) && + addressOrBase58ToBytes32(sourceMessage.destinationCaller.toString()) === + addressOrBase58ToBytes32(destinationMessage.destinationCaller) && + sourceMessage.minFinalityThreshold.toString() === destinationMessage.minFinalityThreshold && + // finalityThresholdExecuted is only set on destination + addressOrBase58ToBytes32(sourceMessage.messageBody.burnToken.toString()) === + addressOrBase58ToBytes32(destinationMessage.decodedMessageBody.burnToken) && + addressOrBase58ToBytes32(sourceMessage.messageBody.mintRecipient.toString()) === + addressOrBase58ToBytes32(destinationMessage.decodedMessageBody.mintRecipient) && + sourceMessage.messageBody.amount.toString() === destinationMessage.decodedMessageBody.amount && + addressOrBase58ToBytes32(sourceMessage.messageBody.messageSender.toString()) === + addressOrBase58ToBytes32(destinationMessage.decodedMessageBody.messageSender) && + sourceMessage.messageBody.maxFee.toString() === destinationMessage.decodedMessageBody.maxFee && + // feeExecuted is only set on destination + // expirationBlock is only set on destination + sourceMessage.messageBody.hookData.equals( + Buffer.from(ethers.utils.arrayify(destinationMessage.decodedMessageBody.hookData || "0x")) + ) + ); +} diff --git a/src/svm/web3-v1/coders.ts b/src/svm/web3-v1/coders.ts new file mode 100644 index 000000000..1694daf9a --- /dev/null +++ b/src/svm/web3-v1/coders.ts @@ -0,0 +1,268 @@ +import { BorshAccountsCoder } from "@coral-xyz/anchor"; +import { IdlCoder } from "@coral-xyz/anchor/dist/cjs/coder/borsh/idl"; +import { IdlTypeDef } from "@coral-xyz/anchor/dist/cjs/idl"; +import * as borsh from "@coral-xyz/borsh"; +import { + CompiledInstruction, + Message, + MessageAccountKeys, + MessageCompiledInstruction, + MessageHeader, + PublicKey, + TransactionInstruction, +} from "@solana/web3.js"; +import bs58 from "bs58"; +import { Layout } from "buffer-layout"; +import { AcrossPlusMessage } from "../types.svm"; + +/** + * Extended Anchor accounts coder to handle large account data. + */ +export class LargeAccountsCoder extends BorshAccountsCoder { + // Getter to access the private accountLayouts property from base class. + private getAccountLayouts() { + // Base class has `Map; + } + + public async encode(accountName: A, account: T): Promise { + const buffer = Buffer.alloc(10240); // We don't currently need anything above instruction data account reallocation limit. + const layout = this.getAccountLayouts().get(accountName); + if (!layout) { + throw new Error(`Unknown account: ${accountName}`); + } + const len = layout.layout.encode(account, buffer); + const accountData = buffer.slice(0, len); + const discriminator = this.accountDiscriminator(accountName); + return Buffer.concat([discriminator, accountData]); + } +} + +type KeyModeMap = Map; + +/** + * Extended version of legacy CompiledKeys to handle compilation of unsigned transactions. Base implementation is here: + * https://github.com/solana-labs/solana-web3.js/blob/v1.95.3/src/message/compiled-keys.ts + */ +class UnsignedCompiledKeys { + keyModeMap: KeyModeMap; + payer?: PublicKey; + + constructor(keyModeMap: KeyModeMap, payer?: PublicKey) { + this.keyModeMap = keyModeMap; + this.payer = payer; + } + + static compileUnsigned(instructions: TransactionInstruction[], payer?: PublicKey): UnsignedCompiledKeys { + const keyModeMap: KeyModeMap = new Map(); + const getOrInsertDefault = (pubkey: PublicKey): { isWritable: boolean } => { + const address = pubkey.toBase58(); + let keyMode = keyModeMap.get(address); + if (keyMode === undefined) { + keyMode = { + isWritable: false, + }; + keyModeMap.set(address, keyMode); + } + return keyMode; + }; + + if (payer !== undefined) { + const payerKeyMode = getOrInsertDefault(payer); + payerKeyMode.isWritable = true; + } + + for (const ix of instructions) { + getOrInsertDefault(ix.programId); + for (const accountMeta of ix.keys) { + const keyMode = getOrInsertDefault(accountMeta.pubkey); + keyMode.isWritable ||= accountMeta.isWritable; + } + } + + return new UnsignedCompiledKeys(keyModeMap, payer); + } + + getMessageComponents(): [MessageHeader, PublicKey[]] { + const mapEntries = Array.from(this.keyModeMap.entries()); + if (mapEntries.length > 256) throw new Error("Max static account keys length exceeded"); + + const writableNonSigners = mapEntries.filter(([, mode]) => mode.isWritable); + const readonlyNonSigners = mapEntries.filter(([, mode]) => !mode.isWritable); + + const header: MessageHeader = { + numRequiredSignatures: 0, + numReadonlySignedAccounts: 0, + numReadonlyUnsignedAccounts: readonlyNonSigners.length, + }; + + const staticAccountKeys = [ + ...writableNonSigners.map(([address]) => new PublicKey(address)), + ...readonlyNonSigners.map(([address]) => new PublicKey(address)), + ]; + + return [header, staticAccountKeys]; + } +} + +/** + * Extended version of legacy Message to handle compilation of unsigned transactions. Base implementation is here: + * https://github.com/solana-labs/solana-web3.js/blob/v1.95.3/src/message/legacy.ts + */ +class UnsignedMessage extends Message { + static compileUnsigned(instructions: TransactionInstruction[], payer?: PublicKey): Message { + const compiledKeys = UnsignedCompiledKeys.compileUnsigned(instructions, payer); + const [header, staticAccountKeys] = compiledKeys.getMessageComponents(); + const accountKeys = new MessageAccountKeys(staticAccountKeys); + const compiledInstructions = accountKeys.compileInstructions(instructions).map( + (ix: MessageCompiledInstruction): CompiledInstruction => ({ + programIdIndex: ix.programIdIndex, + accounts: ix.accountKeyIndexes, + data: bs58.encode(ix.data), + }) + ); + return new Message({ + header, + accountKeys: staticAccountKeys, + recentBlockhash: "", // Not used as we are not signing the transaction. + instructions: compiledInstructions, + }); + } +} + +/** + * Helper to encode MulticallHandler transactions. + */ +export class MulticallHandlerCoder { + readonly compiledMessage: Message; + + private readonly layout: Layout; + + constructor(instructions: TransactionInstruction[], payerKey?: PublicKey) { + // Compile transaction message and keys. + this.compiledMessage = UnsignedMessage.compileUnsigned(instructions, payerKey); + + // Setup the layout for the encoder. + const fieldLayouts = [IdlCoder.fieldLayout(MulticallHandlerCoder.coderArg, MulticallHandlerCoder.coderTypes)]; + this.layout = borsh.struct(fieldLayouts); + } + + private static coderArg = { + name: "compiledIxs", + type: { + vec: { + defined: { + name: "compiledIx", + }, + }, + }, + }; + + private static coderTypes: IdlTypeDef[] = [ + { + name: "compiledIx", + type: { + kind: "struct", + fields: [ + { + name: "programIdIndex", + type: "u8", + }, + { + name: "accountKeyIndexes", + type: { + vec: "u8", + }, + }, + { + name: "data", + type: "bytes", + }, + ], + }, + }, + ]; + + get readOnlyLen() { + return ( + this.compiledMessage.header.numReadonlySignedAccounts + this.compiledMessage.header.numReadonlyUnsignedAccounts + ); + } + + get compiledKeyMetas() { + return this.compiledMessage.accountKeys.map((key, index) => { + return { + pubkey: key, + isSigner: this.compiledMessage.isAccountSigner(index), + isWritable: this.compiledMessage.isAccountWritable(index), + }; + }); + } + + encode() { + const buffer = Buffer.alloc(1280); + const len = this.layout.encode({ compiledIxs: this.compiledMessage.compiledInstructions }, buffer); + return buffer.slice(0, len); + } +} + +/** + * Helper to encode Across+ messages. + */ +export class AcrossPlusMessageCoder { + private acrossPlusMessage: AcrossPlusMessage; + + constructor(acrossPlusMessage: AcrossPlusMessage) { + this.acrossPlusMessage = acrossPlusMessage; + } + + private static coderArg = { + name: "message", + type: { + defined: { + name: "acrossPlusMessage", + }, + }, + }; + + private static coderTypes: IdlTypeDef[] = [ + { + name: "acrossPlusMessage", + type: { + kind: "struct", + fields: [ + { + name: "handler", + type: "pubkey", + }, + { + name: "readOnlyLen", + type: "u8", + }, + { + name: "valueAmount", + type: "u64", + }, + { + name: "accounts", + type: { + vec: "pubkey", + }, + }, + { + name: "handlerMessage", + type: "bytes", + }, + ], + }, + }, + ]; + + encode() { + const fieldLayouts = [IdlCoder.fieldLayout(AcrossPlusMessageCoder.coderArg, AcrossPlusMessageCoder.coderTypes)]; + const layout = borsh.struct(fieldLayouts); + const buffer = Buffer.alloc(12800); + const len = layout.encode({ message: this.acrossPlusMessage }, buffer); + return buffer.slice(0, len); + } +} diff --git a/src/svm/web3-v1/constants.ts b/src/svm/web3-v1/constants.ts new file mode 100644 index 000000000..353b530f2 --- /dev/null +++ b/src/svm/web3-v1/constants.ts @@ -0,0 +1,9 @@ +import BN from "bn.js"; + +export const CIRCLE_IRIS_API_URL_DEVNET = "https://iris-api-sandbox.circle.com"; +export const CIRCLE_IRIS_API_URL_MAINNET = "https://iris-api.circle.com"; +export const SOLANA_USDC_MAINNET = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; +export const SOLANA_USDC_DEVNET = "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU"; +export const SEPOLIA_CCTP_MESSAGE_TRANSMITTER_ADDRESS = "0x7865fAfC2db2093669d92c0F33AeEF291086BEFD"; +export const MAINNET_CCTP_MESSAGE_TRANSMITTER_ADDRESS = "0x0a992d191deec32afe36203ad87d7d289a738f81"; +export const SOLANA_SPOKE_STATE_SEED = new BN(0); diff --git a/src/svm/web3-v1/conversionUtils.ts b/src/svm/web3-v1/conversionUtils.ts new file mode 100644 index 000000000..64b5152ee --- /dev/null +++ b/src/svm/web3-v1/conversionUtils.ts @@ -0,0 +1,107 @@ +import { utils as anchorUtils, BN } from "@coral-xyz/anchor"; +import { PublicKey } from "@solana/web3.js"; +import { BigNumber, ethers } from "ethers"; + +/** + * Converts an integer to a 32-byte Uint8Array. + */ +export function intToU8Array32(num: number | BN): number[] { + const bigIntValue = BigInt(num instanceof BN ? num.toString() : num); + if (bigIntValue < 0) throw new Error("Input must be a non-negative integer or BN"); + + const hexString = bigIntValue.toString(16).padStart(64, "0"); // 32 bytes = 64 hex chars + const u8Array = Array.from(Buffer.from(hexString, "hex")); + + return u8Array; +} + +/** + * Converts a 32-byte Uint8Array to a bigint. + */ +export function u8Array32ToInt(u8Array: Uint8Array | number[]): bigint { + const isValidArray = (arr: any): arr is number[] => Array.isArray(arr) && arr.every(Number.isInteger); + + if ((u8Array instanceof Uint8Array || isValidArray(u8Array)) && u8Array.length === 32) { + return Array.from(u8Array).reduce((num, byte) => (num << BigInt(8)) | BigInt(byte), BigInt(0)); + } + + throw new Error("Input must be a Uint8Array or an array of 32 numbers."); +} + +/** + * Converts a 32-byte Uint8Array to a BigNumber. + */ +export function u8Array32ToBigNumber(u8Array: Uint8Array | number[]): BigNumber { + const isValidArray = (arr: any): arr is number[] => Array.isArray(arr) && arr.every(Number.isInteger); + if ((u8Array instanceof Uint8Array || isValidArray(u8Array)) && u8Array.length === 32) { + const hexString = "0x" + Buffer.from(u8Array).toString("hex"); + return BigNumber.from(hexString); + } + + throw new Error("Input must be a Uint8Array or an array of 32 numbers."); +} + +/** + * Converts a string to a PublicKey. + */ +export function strPublicKey(publicKey: PublicKey): string { + return new PublicKey(publicKey).toString(); +} + +/** + * Converts an EVM address to a Solana PublicKey. + */ +export const evmAddressToPublicKey = (address: string): PublicKey => { + const bytes32Address = `0x000000000000000000000000${address.replace("0x", "")}`; + return new PublicKey(ethers.utils.arrayify(bytes32Address)); +}; + +/** + * Converts a Solana PublicKey to an EVM address. + */ +export const publicKeyToEvmAddress = (publicKey: PublicKey | string): string => { + // Convert the input to a PublicKey if it's a string + const pubKeyBuffer = typeof publicKey === "string" ? new PublicKey(publicKey).toBuffer() : publicKey.toBuffer(); + + // Extract the last 20 bytes to get the Ethereum address + const addressBuffer = pubKeyBuffer.slice(-20); + + // Convert the buffer to a hex string and prepend '0x' + return `0x${addressBuffer.toString("hex")}`; +}; + +/** + * Converts a base58 string to a bytes32 string. + */ +export const fromBase58ToBytes32 = (input: string): string => { + const decodedBytes = anchorUtils.bytes.bs58.decode(input); + return "0x" + Buffer.from(decodedBytes).toString("hex"); +}; + +/** + * Converts a bytes32 string to an EVM address. + */ +export const fromBytes32ToAddress = (input: string): string => { + const hexString = input.startsWith("0x") ? input.slice(2) : input; + + if (hexString.length !== 64) { + throw new Error("Invalid bytes32 string"); + } + + const address = hexString.slice(-40); + + return "0x" + address; +}; + +/** + * Converts EVM or SVM address to a bytes32 string. + */ +export const addressOrBase58ToBytes32 = (input: string): string => { + if (ethers.utils.isAddress(input)) { + return ethers.utils.hexZeroPad(input, 32); + } else if (ethers.utils.isHexString(input, 32)) { + return input; + } else { + return fromBase58ToBytes32(input); + } +}; diff --git a/src/svm/web3-v1/helpers.ts b/src/svm/web3-v1/helpers.ts new file mode 100644 index 000000000..d589e59cc --- /dev/null +++ b/src/svm/web3-v1/helpers.ts @@ -0,0 +1,303 @@ +import { AnchorProvider, BN } from "@coral-xyz/anchor"; +import { BigNumber } from "@ethersproject/bignumber"; +import { ethers } from "ethers"; +import { PublicKey } from "@solana/web3.js"; +import { serialize } from "borsh"; +import { keccak256 } from "ethers/lib/utils"; + +/** + * Returns the chainId for a given solana cluster. + */ +export const getSolanaChainId = (cluster: "devnet" | "mainnet"): BigNumber => { + return BigNumber.from( + BigInt(ethers.utils.keccak256(ethers.utils.toUtf8Bytes(`solana-${cluster}`))) & BigInt("0xFFFFFFFFFFFF") + ); +}; + +/** + * Returns true if the provider is on the devnet cluster. + */ +export const isSolanaDevnet = (provider: AnchorProvider): boolean => { + const solanaRpcEndpoint = provider.connection.rpcEndpoint; + if (solanaRpcEndpoint.includes("devnet")) return true; + else if (solanaRpcEndpoint.includes("mainnet")) return false; + else throw new Error(`Unsupported solanaCluster endpoint: ${solanaRpcEndpoint}`); +}; + +/** + * Generic helper: serialize + keccak256 → 32‑byte Uint8Array + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +function deriveSeedHash(schema: any, seedObj: T): Uint8Array { + const serialized = serialize(schema, seedObj); + const hashHex = keccak256(serialized); + return Buffer.from(hashHex.slice(2), "hex"); +} + +/** + * “Absolute‐deadline” deposit data + */ +export class DepositSeedData { + depositor!: Uint8Array; + recipient!: Uint8Array; + inputToken!: Uint8Array; + outputToken!: Uint8Array; + inputAmount!: BN; + outputAmount!: number[]; + destinationChainId!: BN; + exclusiveRelayer!: Uint8Array; + quoteTimestamp!: BN; + fillDeadline!: BN; + exclusivityParameter!: BN; + message!: Uint8Array; + + constructor(fields: { + depositor: Uint8Array; + recipient: Uint8Array; + inputToken: Uint8Array; + outputToken: Uint8Array; + inputAmount: BN; + outputAmount: number[]; + destinationChainId: BN; + exclusiveRelayer: Uint8Array; + quoteTimestamp: BN; + fillDeadline: BN; + exclusivityParameter: BN; + message: Uint8Array; + }) { + Object.assign(this, fields); + } +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const depositSeedSchema: any = new Map([ + [ + DepositSeedData, + { + kind: "struct", + fields: [ + ["depositor", [32]], + ["recipient", [32]], + ["inputToken", [32]], + ["outputToken", [32]], + ["inputAmount", "u64"], + ["outputAmount", [32]], + ["destinationChainId", "u64"], + ["exclusiveRelayer", [32]], + ["quoteTimestamp", "u32"], + ["fillDeadline", "u32"], + ["exclusivityParameter", "u32"], + ["message", ["u8"]], + ], + }, + ], +]); + +/** + * Hash for the standard `deposit(...)` flow + */ +export function getDepositSeedHash(depositData: { + depositor: PublicKey; + recipient: PublicKey; + inputToken: PublicKey; + outputToken: PublicKey; + inputAmount: BN; + outputAmount: number[]; + destinationChainId: BN; + exclusiveRelayer: PublicKey; + quoteTimestamp: BN; + fillDeadline: BN; + exclusivityParameter: BN; + message: Uint8Array; +}): Uint8Array { + const ds = new DepositSeedData({ + depositor: depositData.depositor.toBuffer(), + recipient: depositData.recipient.toBuffer(), + inputToken: depositData.inputToken.toBuffer(), + outputToken: depositData.outputToken.toBuffer(), + inputAmount: depositData.inputAmount, + outputAmount: depositData.outputAmount, + destinationChainId: depositData.destinationChainId, + exclusiveRelayer: depositData.exclusiveRelayer.toBuffer(), + quoteTimestamp: depositData.quoteTimestamp, + fillDeadline: depositData.fillDeadline, + exclusivityParameter: depositData.exclusivityParameter, + message: depositData.message, + }); + + return deriveSeedHash(depositSeedSchema, ds); +} + +/** + * Returns the delegate PDA for `deposit(...)` + */ +export function getDepositPda(depositData: Parameters[0], programId: PublicKey): PublicKey { + const seedHash = getDepositSeedHash(depositData); + const [pda] = PublicKey.findProgramAddressSync([Buffer.from("delegate"), seedHash], programId); + return pda; +} + +/** + * “Offset/now” deposit data + */ +export class DepositNowSeedData { + depositor!: Uint8Array; + recipient!: Uint8Array; + inputToken!: Uint8Array; + outputToken!: Uint8Array; + inputAmount!: BN; + outputAmount!: number[]; + destinationChainId!: BN; + exclusiveRelayer!: Uint8Array; + fillDeadlineOffset!: BN; + exclusivityPeriod!: BN; + message!: Uint8Array; + + constructor(fields: { + depositor: Uint8Array; + recipient: Uint8Array; + inputToken: Uint8Array; + outputToken: Uint8Array; + inputAmount: BN; + outputAmount: number[]; + destinationChainId: BN; + exclusiveRelayer: Uint8Array; + fillDeadlineOffset: BN; + exclusivityPeriod: BN; + message: Uint8Array; + }) { + Object.assign(this, fields); + } +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const depositNowSeedSchema: any = new Map([ + [ + DepositNowSeedData, + { + kind: "struct", + fields: [ + ["depositor", [32]], + ["recipient", [32]], + ["inputToken", [32]], + ["outputToken", [32]], + ["inputAmount", "u64"], + ["outputAmount", [32]], + ["destinationChainId", "u64"], + ["exclusiveRelayer", [32]], + ["fillDeadlineOffset", "u32"], + ["exclusivityPeriod", "u32"], + ["message", ["u8"]], + ], + }, + ], +]); + +/** + * Hash for the `deposit_now(...)` flow + */ +export function getDepositNowSeedHash(depositData: { + depositor: PublicKey; + recipient: PublicKey; + inputToken: PublicKey; + outputToken: PublicKey; + inputAmount: BN; + outputAmount: number[]; + destinationChainId: BN; + exclusiveRelayer: PublicKey; + fillDeadlineOffset: BN; + exclusivityPeriod: BN; + message: Uint8Array; +}): Uint8Array { + const dns = new DepositNowSeedData({ + depositor: depositData.depositor.toBuffer(), + recipient: depositData.recipient.toBuffer(), + inputToken: depositData.inputToken.toBuffer(), + outputToken: depositData.outputToken.toBuffer(), + inputAmount: depositData.inputAmount, + outputAmount: depositData.outputAmount, + destinationChainId: depositData.destinationChainId, + exclusiveRelayer: depositData.exclusiveRelayer.toBuffer(), + fillDeadlineOffset: depositData.fillDeadlineOffset, + exclusivityPeriod: depositData.exclusivityPeriod, + message: depositData.message, + }); + + return deriveSeedHash(depositNowSeedSchema, dns); +} + +/** + * Returns the delegate PDA for `deposit_now(...)` + */ +export function getDepositNowPda( + depositData: Parameters[0], + programId: PublicKey +): PublicKey { + const seedHash = getDepositNowSeedHash(depositData); + const [pda] = PublicKey.findProgramAddressSync([Buffer.from("delegate"), seedHash], programId); + return pda; +} + +/** + * Fill Delegate Seed Data + */ +class FillDelegateSeedData { + relayHash: Uint8Array; + repaymentChainId: BN; + repaymentAddress: Uint8Array; + constructor(fields: { relayHash: Uint8Array; repaymentChainId: BN; repaymentAddress: Uint8Array }) { + this.relayHash = fields.relayHash; + this.repaymentChainId = fields.repaymentChainId; + this.repaymentAddress = fields.repaymentAddress; + } +} + +/** + * Borsh schema for FillDelegateSeedData + */ +const fillDelegateSeedSchema = new Map([ + [ + FillDelegateSeedData, + { + kind: "struct", + fields: [ + ["relayHash", [32]], + ["repaymentChainId", "u64"], + ["repaymentAddress", [32]], + ], + }, + ], +]); + +/** + * Returns the fill delegate seed hash. + */ + +export function getFillRelayDelegateSeedHash( + relayHash: Uint8Array, + repaymentChainId: BN, + repaymentAddress: PublicKey +): Uint8Array { + const ds = new FillDelegateSeedData({ + relayHash, + repaymentChainId, + repaymentAddress: repaymentAddress.toBuffer(), + }); + + return deriveSeedHash(fillDelegateSeedSchema, ds); +} + +/** + * Returns the fill delegate PDA. + */ +export function getFillRelayDelegatePda( + relayHash: Uint8Array, + repaymentChainId: BN, + repaymentAddress: PublicKey, + programId: PublicKey +): { seedHash: Uint8Array; pda: PublicKey } { + const seedHash = getFillRelayDelegateSeedHash(relayHash, repaymentChainId, repaymentAddress); + const [pda] = PublicKey.findProgramAddressSync([Buffer.from("delegate"), seedHash], programId); + + return { seedHash, pda }; +} diff --git a/src/svm/web3-v1/index.ts b/src/svm/web3-v1/index.ts new file mode 100644 index 000000000..dbbd53044 --- /dev/null +++ b/src/svm/web3-v1/index.ts @@ -0,0 +1,11 @@ +export * from "./relayHashUtils"; +export * from "./instructionParamsUtils"; +export * from "./conversionUtils"; +export * from "./transactionUtils"; +export * from "./solanaProgramUtils"; +export * from "./coders"; +export * from "./programConnectors"; +export * from "./constants"; +export * from "./helpers"; +export * from "./cctpHelpers"; +export * from "./cctpV2Helpers"; diff --git a/src/svm/web3-v1/instructionParamsUtils.ts b/src/svm/web3-v1/instructionParamsUtils.ts new file mode 100644 index 000000000..1ecbcf2ea --- /dev/null +++ b/src/svm/web3-v1/instructionParamsUtils.ts @@ -0,0 +1,198 @@ +import { Keypair, TransactionInstruction, Transaction, sendAndConfirmTransaction, PublicKey } from "@solana/web3.js"; +import { Program, BN } from "@coral-xyz/anchor"; +import { RelayData, SlowFillLeaf, RelayerRefundLeafSolana } from "../types.svm"; +import { SvmSpokeAnchor as SvmSpoke } from "../assets"; +import { LargeAccountsCoder } from "./coders"; + +/** + * Loads execute relayer refund leaf parameters. + */ +export async function loadExecuteRelayerRefundLeafParams( + program: Program, + caller: PublicKey, + rootBundleId: number, + relayerRefundLeaf: RelayerRefundLeafSolana, + proof: number[][] +) { + const maxInstructionParamsFragment = 900; // Should not exceed message size limit when writing to the data account. + + // Close the instruction params account if the caller has used it before. + const [instructionParams] = PublicKey.findProgramAddressSync( + [Buffer.from("instruction_params"), caller.toBuffer()], + program.programId + ); + const accountInfo = await program.provider.connection.getAccountInfo(instructionParams); + if (accountInfo !== null) await program.methods.closeInstructionParams().rpc(); + + const accountCoder = new LargeAccountsCoder(program.idl); + const instructionParamsBytes = await accountCoder.encode("executeRelayerRefundLeafParams", { + rootBundleId, + relayerRefundLeaf, + proof, + }); + + await program.methods.initializeInstructionParams(instructionParamsBytes.length).rpc(); + + for (let i = 0; i < instructionParamsBytes.length; i += maxInstructionParamsFragment) { + const fragment = instructionParamsBytes.slice(i, i + maxInstructionParamsFragment); + await program.methods.writeInstructionParamsFragment(i, fragment).rpc(); + } + return instructionParams; +} + +/** + * Closes the instruction parameters account. + */ +export async function closeInstructionParams(program: Program, signer: Keypair) { + const [instructionParams] = PublicKey.findProgramAddressSync( + [Buffer.from("instruction_params"), signer.publicKey.toBuffer()], + program.programId + ); + const accountInfo = await program.provider.connection.getAccountInfo(instructionParams); + if (accountInfo !== null) { + const closeIx = await program.methods.closeInstructionParams().accounts({ signer: signer.publicKey }).instruction(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + await sendAndConfirmTransaction(program.provider.connection as any, new Transaction().add(closeIx), [signer]); + } +} + +/** + * Creates instructions to load fill relay parameters. + */ +export async function createFillRelayParamsInstructions( + program: Program, + signer: PublicKey, + relayData: RelayData, + repaymentChainId: BN, + repaymentAddress: PublicKey +): Promise<{ loadInstructions: TransactionInstruction[]; closeInstruction: TransactionInstruction }> { + const maxInstructionParamsFragment = 900; // Should not exceed message size limit when writing to the data account. + + const accountCoder = new LargeAccountsCoder(program.idl); + const instructionParamsBytes = await accountCoder.encode("fillRelayParams", { + relayData, + repaymentChainId, + repaymentAddress, + }); + + const loadInstructions: TransactionInstruction[] = []; + loadInstructions.push( + await program.methods.initializeInstructionParams(instructionParamsBytes.length).accounts({ signer }).instruction() + ); + + for (let i = 0; i < instructionParamsBytes.length; i += maxInstructionParamsFragment) { + const fragment = instructionParamsBytes.slice(i, i + maxInstructionParamsFragment); + loadInstructions.push( + await program.methods.writeInstructionParamsFragment(i, fragment).accounts({ signer }).instruction() + ); + } + + const closeInstruction = await program.methods.closeInstructionParams().accounts({ signer }).instruction(); + + return { loadInstructions, closeInstruction }; +} + +/** + * Loads fill relay parameters. + */ +export async function loadFillRelayParams( + program: Program, + signer: Keypair, + relayData: RelayData, + repaymentChainId: BN, + repaymentAddress: PublicKey +) { + // Close the instruction params account if the caller has used it before. + await closeInstructionParams(program, signer); + + // Execute load instructions sequentially. + const { loadInstructions } = await createFillRelayParamsInstructions( + program, + signer.publicKey, + relayData, + repaymentChainId, + repaymentAddress + ); + for (let i = 0; i < loadInstructions.length; i += 1) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + await sendAndConfirmTransaction(program.provider.connection as any, new Transaction().add(loadInstructions[i]), [signer]); + } +} + +/** + * Loads request slow fill parameters. + */ +export async function loadRequestSlowFillParams(program: Program, signer: Keypair, relayData: RelayData) { + // Close the instruction params account if the caller has used it before. + await closeInstructionParams(program, signer); + + // Execute load instructions sequentially. + const maxInstructionParamsFragment = 900; // Should not exceed message size limit when writing to the data account. + + const accountCoder = new LargeAccountsCoder(program.idl); + const instructionParamsBytes = await accountCoder.encode("requestSlowFillParams", { relayData }); + + const loadInstructions: TransactionInstruction[] = []; + loadInstructions.push( + await program.methods + .initializeInstructionParams(instructionParamsBytes.length) + .accounts({ signer: signer.publicKey }) + .instruction() + ); + + for (let i = 0; i < instructionParamsBytes.length; i += maxInstructionParamsFragment) { + const fragment = instructionParamsBytes.slice(i, i + maxInstructionParamsFragment); + loadInstructions.push( + await program.methods + .writeInstructionParamsFragment(i, fragment) + .accounts({ signer: signer.publicKey }) + .instruction() + ); + } + + return loadInstructions; +} + +/** + * Loads execute slow relay leaf parameters. + */ +export async function loadExecuteSlowRelayLeafParams( + program: Program, + signer: Keypair, + slowFillLeaf: SlowFillLeaf, + rootBundleId: number, + proof: number[][] +) { + // Close the instruction params account if the caller has used it before. + await closeInstructionParams(program, signer); + + // Execute load instructions sequentially. + const maxInstructionParamsFragment = 900; // Should not exceed message size limit when writing to the data account. + + const accountCoder = new LargeAccountsCoder(program.idl); + const instructionParamsBytes = await accountCoder.encode("executeSlowRelayLeafParams", { + slowFillLeaf, + rootBundleId, + proof, + }); + + const loadInstructions: TransactionInstruction[] = []; + loadInstructions.push( + await program.methods + .initializeInstructionParams(instructionParamsBytes.length) + .accounts({ signer: signer.publicKey }) + .instruction() + ); + + for (let i = 0; i < instructionParamsBytes.length; i += maxInstructionParamsFragment) { + const fragment = instructionParamsBytes.slice(i, i + maxInstructionParamsFragment); + loadInstructions.push( + await program.methods + .writeInstructionParamsFragment(i, fragment) + .accounts({ signer: signer.publicKey }) + .instruction() + ); + } + + return loadInstructions; +} diff --git a/src/svm/web3-v1/programConnectors.ts b/src/svm/web3-v1/programConnectors.ts new file mode 100644 index 000000000..fc915104c --- /dev/null +++ b/src/svm/web3-v1/programConnectors.ts @@ -0,0 +1,82 @@ +import { AnchorProvider, Idl, Program } from "@coral-xyz/anchor"; +import { getDeployedAddress } from "@across-protocol/contracts"; +import { SupportedNetworks } from "../types.svm"; +import { + MessageTransmitterAnchor, + MessageTransmitterIdl, + MulticallHandlerAnchor, + MulticallHandlerIdl, + SvmSpokeAnchor, + SvmSpokeIdl, + TokenMessengerMinterAnchor, + TokenMessengerMinterIdl, + MessageTransmitterV2Anchor, + MessageTransmitterV2Idl, + TokenMessengerMinterV2Anchor, + TokenMessengerMinterV2Idl, + SponsoredCctpSrcPeripheryAnchor, + SponsoredCctpSrcPeripheryIdl, +} from "../assets"; +import { getSolanaChainId, isSolanaDevnet } from "./helpers"; + +type ProgramOptions = { network?: SupportedNetworks; programId?: string }; + +export function getConnectedProgram

(idl: P, provider: AnchorProvider, programId: string) { + idl.address = programId; + return new Program

(idl, provider); +} + +// Resolves the program ID from options or defaults to the deployed address. Prioritizes programId, falls back to +// network, and if network is not defined, determines the network from the provider's RPC URL. Throws an error if +// the program ID cannot be resolved. +function resolveProgramId(programName: string, provider: AnchorProvider, options?: ProgramOptions): string { + const { network, programId } = options ?? {}; + + if (programId) { + return programId; // Prioritize explicitly provided programId + } + + const resolvedNetwork = network ?? (isSolanaDevnet(provider) ? "devnet" : "mainnet"); + const deployedAddress = getDeployedAddress(programName, getSolanaChainId(resolvedNetwork).toString()); + + if (!deployedAddress) { + throw new Error(`${programName} Program ID not found for ${resolvedNetwork}`); + } + + return deployedAddress; +} + +export function getSpokePoolProgram(provider: AnchorProvider, options?: ProgramOptions) { + const id = resolveProgramId("SvmSpoke", provider, options); + return getConnectedProgram(SvmSpokeIdl, provider, id); +} + +export function getMessageTransmitterProgram(provider: AnchorProvider, options?: ProgramOptions) { + const id = resolveProgramId("MessageTransmitter", provider, options); + return getConnectedProgram(MessageTransmitterIdl, provider, id); +} + +export function getTokenMessengerMinterProgram(provider: AnchorProvider, options?: ProgramOptions) { + const id = resolveProgramId("TokenMessengerMinter", provider, options); + return getConnectedProgram(TokenMessengerMinterIdl, provider, id); +} + +export function getMulticallHandlerProgram(provider: AnchorProvider, options?: ProgramOptions) { + const id = resolveProgramId("MulticallHandler", provider, options); + return getConnectedProgram(MulticallHandlerIdl, provider, id); +} + +export function getMessageTransmitterV2Program(provider: AnchorProvider, options?: ProgramOptions) { + const id = resolveProgramId("MessageTransmitterV2", provider, options); + return getConnectedProgram(MessageTransmitterV2Idl, provider, id); +} + +export function getTokenMessengerMinterV2Program(provider: AnchorProvider, options?: ProgramOptions) { + const id = resolveProgramId("TokenMessengerMinterV2", provider, options); + return getConnectedProgram(TokenMessengerMinterV2Idl, provider, id); +} + +export function getSponsoredCctpSrcPeripheryProgram(provider: AnchorProvider, options?: ProgramOptions) { + const id = resolveProgramId("SponsoredCctpSrcPeriphery", provider, options); + return getConnectedProgram(SponsoredCctpSrcPeripheryIdl, provider, id); +} diff --git a/src/svm/web3-v1/relayHashUtils.ts b/src/svm/web3-v1/relayHashUtils.ts new file mode 100644 index 000000000..7cfd73825 --- /dev/null +++ b/src/svm/web3-v1/relayHashUtils.ts @@ -0,0 +1,224 @@ +import { BN } from "@coral-xyz/anchor"; +import { ethers } from "ethers"; +import { RelayerRefundLeaf, RelayerRefundLeafSolana, SlowFillLeaf } from "../types.svm"; +import { serialize } from "borsh"; + +/** + * Calculates the relay hash from relay data and chain ID. + */ +export function calculateRelayHashUint8Array(relayData: any, chainId: BN): Uint8Array { + const contentToHash = Buffer.concat([ + relayData.depositor.toBuffer(), + relayData.recipient.toBuffer(), + relayData.exclusiveRelayer.toBuffer(), + relayData.inputToken.toBuffer(), + relayData.outputToken.toBuffer(), + Buffer.from(relayData.inputAmount), + relayData.outputAmount.toArrayLike(Buffer, "le", 8), + relayData.originChainId.toArrayLike(Buffer, "le", 8), + Buffer.from(relayData.depositId), + new BN(relayData.fillDeadline).toArrayLike(Buffer, "le", 4), + new BN(relayData.exclusivityDeadline).toArrayLike(Buffer, "le", 4), + hashNonEmptyMessage(relayData.message), // Replace with hash of message, so that relay hash can be recovered from event. + chainId.toArrayLike(Buffer, "le", 8), + ]); + + const relayHash = ethers.utils.keccak256(contentToHash); + const relayHashBuffer = Buffer.from(relayHash.slice(2), "hex"); + return new Uint8Array(relayHashBuffer); +} + +/** + * Calculates the relay event hash from relay event data and chain ID. + */ +export function calculateRelayEventHashUint8Array(relayEventData: any, chainId: BN): Uint8Array { + const contentToHash = Buffer.concat([ + relayEventData.depositor.toBuffer(), + relayEventData.recipient.toBuffer(), + relayEventData.exclusiveRelayer.toBuffer(), + relayEventData.inputToken.toBuffer(), + relayEventData.outputToken.toBuffer(), + Buffer.from(relayEventData.inputAmount), + relayEventData.outputAmount.toArrayLike(Buffer, "le", 8), + relayEventData.originChainId.toArrayLike(Buffer, "le", 8), + Buffer.from(relayEventData.depositId), + new BN(relayEventData.fillDeadline).toArrayLike(Buffer, "le", 4), + new BN(relayEventData.exclusivityDeadline).toArrayLike(Buffer, "le", 4), + Buffer.from(relayEventData.messageHash), // Renamed to messageHash in the event data. + chainId.toArrayLike(Buffer, "le", 8), + ]); + + const relayHash = ethers.utils.keccak256(contentToHash); + const relayHashBuffer = Buffer.from(relayHash.slice(2), "hex"); + return new Uint8Array(relayHashBuffer); +} + +/** + * Reads a 256-bit unsigned integer from a buffer. + */ +export const readUInt256BE = (buffer: Buffer): BigInt => { + let result = BigInt(0); + for (let i = 0; i < buffer.length; i++) { + result = (result << BigInt(8)) + BigInt(buffer[i]); + } + return result; +}; + +/** + * Hashes a non-empty message using Keccak256. + */ +export function hashNonEmptyMessage(message: Buffer) { + if (message.length > 0) { + const hash = ethers.utils.keccak256(message); + return Uint8Array.from(Buffer.from(hash.slice(2), "hex")); + } + // else return zeroed bytes32 + return new Uint8Array(32); +} + +/** + * Class for relay data. + */ +class RelayData { + constructor(properties: any) { + Object.assign(this, properties); + } +} + +/** + * Schema for relay data. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const relayDataSchema: any = new Map([ + [ + RelayData, + { + kind: "struct", + fields: [ + ["amountToReturn", "u64"], + ["chainId", "u64"], + ["refundAmounts", ["u64"]], + ["leafId", "u32"], + ["mintPublicKey", [32]], + ["refundAddresses", [[32]]], + ], + }, + ], +]); + +/** + * Calculates the relayer refund leaf hash for Solana. + */ +export function calculateRelayerRefundLeafHashUint8Array(relayData: RelayerRefundLeafSolana): string { + const refundAddresses = relayData.refundAddresses.map((address) => address.toBuffer()); + + const data = new RelayData({ + amountToReturn: relayData.amountToReturn, + chainId: relayData.chainId, + refundAmounts: relayData.refundAmounts, + leafId: relayData.leafId, + mintPublicKey: relayData.mintPublicKey.toBuffer(), + refundAddresses: refundAddresses, + }); + + const serializedData = serialize(relayDataSchema, data); + + // SVM leaves require the first 64 bytes to be 0 to ensure EVM leaves can never be played on SVM and vice versa. + const contentToHash = Buffer.concat([Buffer.alloc(64, 0), serializedData]); + + return ethers.utils.keccak256(contentToHash); +} + +/** + * Hash function for relayer refund leaves. + */ +export const relayerRefundHashFn = (input: RelayerRefundLeaf | RelayerRefundLeafSolana) => { + if (!input.isSolana) { + const abiCoder = new ethers.utils.AbiCoder(); + const encodedData = abiCoder.encode( + [ + "tuple( uint256 amountToReturn, uint256 chainId, uint256[] refundAmounts, uint256 leafId, address l2TokenAddress, address[] refundAddresses)", + ], + [ + { + leafId: input.leafId, + chainId: input.chainId, + amountToReturn: input.amountToReturn, + l2TokenAddress: (input as RelayerRefundLeaf).l2TokenAddress, // Type assertion + refundAddresses: (input as RelayerRefundLeaf).refundAddresses, // Type assertion + refundAmounts: (input as RelayerRefundLeaf).refundAmounts, // Type assertion + }, + ] + ); + return ethers.utils.keccak256(encodedData); + } else { + return calculateRelayerRefundLeafHashUint8Array(input as RelayerRefundLeafSolana); + } +}; + +/** + * Class for slow fill data. + */ +class SlowFillData { + constructor(properties: any) { + Object.assign(this, properties); + } +} + +/** + * Schema for slow fill data. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const slowFillDataSchema: any = new Map([ + [ + SlowFillData, + { + kind: "struct", + fields: [ + ["depositor", [32]], + ["recipient", [32]], + ["exclusiveRelayer", [32]], + ["inputToken", [32]], + ["outputToken", [32]], + ["inputAmount", [32]], + ["outputAmount", "u64"], + ["originChainId", "u64"], + ["depositId", [32]], + ["fillDeadline", "u32"], + ["exclusivityDeadline", "u32"], + ["message", ["u8"]], + ["chainId", "u64"], + ["updatedOutputAmount", "u64"], + ], + }, + ], +]); + +/** + * Hash function for slow fill leaves. + */ +export function slowFillHashFn(slowFillLeaf: SlowFillLeaf): string { + const data = new SlowFillData({ + depositor: Uint8Array.from(slowFillLeaf.relayData.depositor.toBuffer()), + recipient: Uint8Array.from(slowFillLeaf.relayData.recipient.toBuffer()), + exclusiveRelayer: Uint8Array.from(slowFillLeaf.relayData.exclusiveRelayer.toBuffer()), + inputToken: Uint8Array.from(slowFillLeaf.relayData.inputToken.toBuffer()), + outputToken: Uint8Array.from(slowFillLeaf.relayData.outputToken.toBuffer()), + inputAmount: slowFillLeaf.relayData.inputAmount, + outputAmount: slowFillLeaf.relayData.outputAmount, + originChainId: slowFillLeaf.relayData.originChainId, + depositId: Uint8Array.from(Buffer.from(slowFillLeaf.relayData.depositId)), + fillDeadline: slowFillLeaf.relayData.fillDeadline, + exclusivityDeadline: slowFillLeaf.relayData.exclusivityDeadline, + message: Uint8Array.from(slowFillLeaf.relayData.message), + chainId: slowFillLeaf.chainId, + updatedOutputAmount: slowFillLeaf.updatedOutputAmount, + }); + + const serializedData = serialize(slowFillDataSchema, data); + + // SVM leaves require the first 64 bytes to be 0 to ensure EVM leaves cannot be played on SVM and vice versa + const contentToHash = Buffer.concat([Buffer.alloc(64, 0), serializedData]); + + return ethers.utils.keccak256(contentToHash); +} diff --git a/src/svm/web3-v1/solanaProgramUtils.ts b/src/svm/web3-v1/solanaProgramUtils.ts new file mode 100644 index 000000000..c9313bddc --- /dev/null +++ b/src/svm/web3-v1/solanaProgramUtils.ts @@ -0,0 +1,277 @@ +import { BN, Idl, Program, utils, web3 } from "@coral-xyz/anchor"; +import { + ConfirmedSignatureInfo, + Connection, + Finality, + Logs, + PublicKey, + SignaturesForAddressOptions, +} from "@solana/web3.js"; +import { deserialize } from "borsh"; +import { EventType } from "../types.svm"; +import { publicKeyToEvmAddress, u8Array32ToInt } from "./conversionUtils"; + +/** + * Finds a program address with a given label and optional extra seeds. + */ +export function findProgramAddress(label: string, program: PublicKey, extraSeeds?: string[]) { + const seeds: Buffer[] = [Buffer.from(utils.bytes.utf8.encode(label))]; + if (extraSeeds) { + for (const extraSeed of extraSeeds) { + if (typeof extraSeed === "string") { + seeds.push(Buffer.from(utils.bytes.utf8.encode(extraSeed))); + } else if (Array.isArray(extraSeed)) { + seeds.push(Buffer.from(extraSeed)); + } else if (Buffer.isBuffer(extraSeed)) { + seeds.push(extraSeed); + } else { + seeds.push((extraSeed as any).toBuffer()); + } + } + } + const res = PublicKey.findProgramAddressSync(seeds, program); + return { publicKey: res[0], bump: res[1] }; +} + +/** + * Reads events from a transaction. + */ +export async function readEvents( + connection: Connection, + txSignature: string, + programs: Program[], + commitment: Finality = "confirmed" +) { + const txResult = await connection.getTransaction(txSignature, { commitment, maxSupportedTransactionVersion: 0 }); + + if (txResult === null) return []; + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return processEventFromTx(txResult as any, programs); +} + +/** + * Processes events from a transaction. + */ +export function processEventFromTx(txResult: web3.VersionedTransactionResponse, programs: Program[]) { + const eventAuthorities: Map = new Map(); + for (const program of programs) { + eventAuthorities.set( + program.programId.toString(), + findProgramAddress("__event_authority", program.programId).publicKey + ); + } + + const events = []; + + // Resolve any potential addresses that were passed from address lookup tables. + const messageAccountKeys = txResult.transaction.message.getAccountKeys({ + accountKeysFromLookups: txResult.meta?.loadedAddresses, + }); + + for (const ixBlock of txResult.meta?.innerInstructions ?? []) { + for (const ix of ixBlock.instructions) { + for (const program of programs) { + const ixProgramId = messageAccountKeys.get(ix.programIdIndex); + const singleIxAccount = ix.accounts.length === 1 ? messageAccountKeys.get(ix.accounts[0]) : undefined; + if ( + ixProgramId !== undefined && + singleIxAccount !== undefined && + program.programId.equals(ixProgramId) && + eventAuthorities.get(ixProgramId.toString())?.equals(singleIxAccount) + ) { + const ixData = utils.bytes.bs58.decode(ix.data); + const eventData = utils.bytes.base64.encode(Buffer.from(new Uint8Array(ixData).slice(8))); + const event = program.coder.events.decode(eventData); + events.push({ + program: program.programId, + data: event?.data, + name: event?.name, + }); + } + } + } + } + return events; +} + +/** + * Helper function to wait for an event to be emitted. Should only be used in tests where txSignature is known to emit. + */ +export async function readEventsUntilFound( + connection: Connection, + txSignature: string, + programs: Program[] +) { + const startTime = Date.now(); + let txResult = null; + + while (Date.now() - startTime < 5000) { + // 5 seconds timeout to wait to find the event. + txResult = await connection.getTransaction(txSignature, { + commitment: "confirmed", + maxSupportedTransactionVersion: 0, + }); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + if (txResult !== null) return processEventFromTx(txResult as any, programs); + + await new Promise((resolve) => setTimeout(resolve, 50)); // 50 ms delay between retries. + } + + throw new Error("No event found within 5 seconds"); +} + +/** + * Retrieves a specific event by name from a list of events. + */ +export function getEvent(events: any[], program: PublicKey, eventName: string) { + for (const event of events) { + if (event.name === eventName && program.toString() === event.program.toString()) { + return event.data; + } + } + throw new Error("Event " + eventName + " not found"); +} + +/** + * Reads all events for a specific program. + */ +export async function readProgramEvents( + connection: Connection, + program: Program, + finality: Finality = "confirmed", + options: SignaturesForAddressOptions = { limit: 1000 } +): Promise { + const allSignatures: ConfirmedSignatureInfo[] = []; + + // Fetch all signatures in sequential batches + while (true) { + const signatures = await connection.getSignaturesForAddress(program.programId, options, finality); + allSignatures.push(...signatures); + + // Update options for the next batch. Set before to the last fetched signature. + if (signatures.length > 0) { + options = { ...options, before: signatures[signatures.length - 1].signature }; + } + + if (options.limit && signatures.length < options.limit) break; // Exit early if the number of signatures < limit + } + + // Fetch events for all signatures in parallel + const eventsWithSlots = await Promise.all( + allSignatures.map(async (signature) => { + const events = await readEvents(connection, signature.signature, [program], finality); + return events.map((event) => ({ + ...event, + confirmationStatus: signature.confirmationStatus || "Unknown", + blockTime: signature.blockTime || 0, + signature: signature.signature, + slot: signature.slot, + name: event.name || "Unknown", + })); + }) + ); + + return eventsWithSlots.flat(); // Flatten the array of events & return. +} + +/** + * Subscribes to CPI events for a program. + */ +export async function subscribeToCpiEventsForProgram( + connection: Connection, + program: Program, + callback: (events: any[]) => void +) { + const subscriptionId = connection.onLogs( + new PublicKey(findProgramAddress("__event_authority", program.programId).publicKey.toString()), + async (logs: Logs) => { + callback(await readEvents(connection, logs.signature, [program], "confirmed")); + }, + "confirmed" + ); + + return subscriptionId; +} + +/** + * Class for DepositId. + */ +class DepositId { + value: Uint8Array; // Fixed-length array as Uint8Array + + constructor(properties: { value: Uint8Array }) { + this.value = properties.value; + } +} + +/** + * Borsh schema for deserializing DepositId. + */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any +const depositIdSchema: any = new Map( + [[DepositId, { kind: "struct", fields: [["value", [32]]] }]] // Fixed array [u8; 32] +); + +/** + * Parses depositId: checks if only the first 4 bytes are non-zero and returns a u32 or deserializes the full array. + */ +function parseDepositId(value: Uint8Array): string { + const restAreZero = value.slice(4).every((byte) => byte === 0); + + if (restAreZero) { + // Parse the first 4 bytes as a little-endian u32 + const u32Value = new DataView(value.buffer).getUint32(0, true); // true for little-endian + return u32Value.toString(); + } + + // Deserialize the full depositId using the Borsh schema + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const depositId = (deserialize as any)(depositIdSchema, DepositId, Buffer.from(value)) as DepositId; + return new BN(depositId.value).toString(); +} + +/** + * Stringifies a CPI event. + */ +export function stringifyCpiEvent(obj: any, eventName: string): any { + if (obj?.constructor?.toString()?.includes("PublicKey")) { + if (obj.toString().startsWith("111111111111")) { + // First 12 bytes are 0 for EVM addresses. + return publicKeyToEvmAddress(obj); + } + return obj.toString(); + } else if (BN.isBN(obj)) { + return obj.toString(); + } else if (typeof obj === "bigint") { + return obj.toString(); + } else if (Array.isArray(obj) && obj.length == 32) { + return Buffer.from(obj).toString("hex"); // Hex representation for fixed-length arrays + } else if (Array.isArray(obj)) { + return obj.map((obj) => stringifyCpiEvent(obj, eventName)); + } else if (obj !== null && typeof obj === "object") { + return Object.fromEntries( + Object.entries(obj).map(([key, value]) => { + if (Array.isArray(value) && value.length === 32) { + if (key === "depositId" || key === "deposit_id") { + // Parse depositId using the helper function + const parsedValue = parseDepositId(new Uint8Array(value)); + return [key, parsedValue]; + } else if ( + eventName.toLowerCase() === "fundsdeposited" && + (key === "outputAmount" || key === "output_amount") + ) { + return [key, u8Array32ToInt(new Uint8Array(value)).toString()]; + } else if ( + (eventName.toLowerCase() === "filledrelay" || eventName.toLowerCase() === "requestedslowfill") && + (key === "inputAmount" || key === "input_amount") + ) { + return [key, u8Array32ToInt(new Uint8Array(value)).toString()]; + } + } + return [key, stringifyCpiEvent(value, eventName)]; + }) + ); + } + return obj; +} diff --git a/src/svm/web3-v1/transactionUtils.ts b/src/svm/web3-v1/transactionUtils.ts new file mode 100644 index 000000000..568abb6c8 --- /dev/null +++ b/src/svm/web3-v1/transactionUtils.ts @@ -0,0 +1,129 @@ +import { web3 } from "@coral-xyz/anchor"; +import { + AddressLookupTableAccount, + AddressLookupTableProgram, + Connection, + Keypair, + PublicKey, + TransactionInstruction, + TransactionMessage, + VersionedTransaction, +} from "@solana/web3.js"; + +/** + * Sends a transaction using an Address Lookup Table for large numbers of accounts. + */ +export async function sendTransactionWithLookupTable( + connection: Connection, + instructions: TransactionInstruction[], + sender: Keypair, + additionalSigners: Keypair[] = [] +): Promise<{ txSignature: string; lookupTableAddress: PublicKey }> { + // Maximum number of accounts that can be added to Address Lookup Table (ALT) in a single transaction. + const maxExtendedAccounts = 30; + + // Consolidate addresses from all instructions into a single array for the ALT. + const lookupAddresses = Array.from( + new Set( + instructions.flatMap((instruction) => [ + instruction.programId, + ...instruction.keys.map((accountMeta) => accountMeta.pubkey), + ]) + ) + ); + + // Create instructions for creating and extending the ALT. + const [lookupTableInstruction, lookupTableAddress] = await AddressLookupTableProgram.createLookupTable({ + authority: sender.publicKey, + payer: sender.publicKey, + recentSlot: await connection.getSlot(), + }); + + // Submit the ALT creation transaction + // eslint-disable-next-line @typescript-eslint/no-explicit-any + await web3.sendAndConfirmTransaction(connection as any, new web3.Transaction().add(lookupTableInstruction), [sender], { + commitment: "confirmed", + skipPreflight: true, + }); + + // Extend the ALT with all accounts making sure not to exceed the maximum number of accounts per transaction. + for (let i = 0; i < lookupAddresses.length; i += maxExtendedAccounts) { + const extendInstruction = AddressLookupTableProgram.extendLookupTable({ + lookupTable: lookupTableAddress, + authority: sender.publicKey, + payer: sender.publicKey, + addresses: lookupAddresses.slice(i, i + maxExtendedAccounts), + }); + + // eslint-disable-next-line @typescript-eslint/no-explicit-any + await web3.sendAndConfirmTransaction(connection as any, new web3.Transaction().add(extendInstruction), [sender], { + commitment: "confirmed", + skipPreflight: true, + }); + } + + // Wait for slot to advance. LUTs only active after slot advance. + const initialSlot = await connection.getSlot(); + while ((await connection.getSlot()) === initialSlot) { + await new Promise((resolve) => setTimeout(resolve, 50)); + } + + // Fetch the AddressLookupTableAccount + const lookupTableAccount = (await connection.getAddressLookupTable(lookupTableAddress)).value; + if (lookupTableAccount === null) throw new Error("AddressLookupTableAccount not fetched"); + + // Create the versioned transaction + const versionedTx = new VersionedTransaction( + new TransactionMessage({ + payerKey: sender.publicKey, + recentBlockhash: (await connection.getLatestBlockhash()).blockhash, + instructions, + }).compileToV0Message([lookupTableAccount]) + ); + + // Sign and submit the versioned transaction. + versionedTx.sign([sender, ...additionalSigners]); + const txSignature = await connection.sendTransaction(versionedTx); + + // Confirm the versioned transaction + let block = await connection.getLatestBlockhash(); + await connection.confirmTransaction( + { signature: txSignature, blockhash: block.blockhash, lastValidBlockHeight: block.lastValidBlockHeight }, + "confirmed" + ); + + return { txSignature, lookupTableAddress }; +} + +/** + * Sends a transaction using existing Address Lookup Table. + */ +export async function sendTransactionWithExistingLookupTable( + connection: Connection, + instructions: TransactionInstruction[], + lookupTableAccount: AddressLookupTableAccount, + sender: Keypair, + additionalSigners: Keypair[] = [] +): Promise { + // Create the versioned transaction + const versionedTx = new VersionedTransaction( + new TransactionMessage({ + payerKey: sender.publicKey, + recentBlockhash: (await connection.getLatestBlockhash()).blockhash, + instructions, + }).compileToV0Message([lookupTableAccount]) + ); + + // Sign and submit the versioned transaction. + versionedTx.sign([sender, ...additionalSigners]); + const txSignature = await connection.sendTransaction(versionedTx); + + // Confirm the versioned transaction + let block = await connection.getLatestBlockhash(); + await connection.confirmTransaction( + { signature: txSignature, blockhash: block.blockhash, lastValidBlockHeight: block.lastValidBlockHeight }, + "confirmed" + ); + + return txSignature; +} diff --git a/src/svm/web3-v2/index.ts b/src/svm/web3-v2/index.ts new file mode 100644 index 000000000..49f77b728 --- /dev/null +++ b/src/svm/web3-v2/index.ts @@ -0,0 +1,3 @@ +export * from "./solanaProgramUtils"; +export * from "./transactionUtils"; +export * from "./types"; diff --git a/src/svm/web3-v2/solanaProgramUtils.ts b/src/svm/web3-v2/solanaProgramUtils.ts new file mode 100644 index 000000000..51bf899bd --- /dev/null +++ b/src/svm/web3-v2/solanaProgramUtils.ts @@ -0,0 +1,145 @@ +import { BorshEventCoder, Idl, utils } from "@coral-xyz/anchor"; +import web3, { Address, Commitment, GetSignaturesForAddressApi, GetTransactionApi, Signature } from "@solana/kit"; +import { RpcClient } from "./types"; + +type GetTransactionReturnType = ReturnType; + +type GetSignaturesForAddressConfig = Parameters[1]; + +type GetSignaturesForAddressTransaction = ReturnType[number]; + +/** + * Reads all events for a specific program. + */ +export async function readProgramEvents( + rpc: RpcClient, + program: Address, + anchorIdl: Idl, + finality: Commitment = "confirmed", + options: GetSignaturesForAddressConfig = { limit: 1000 } +) { + const allSignatures: GetSignaturesForAddressTransaction[] = await searchSignaturesUntilLimit(rpc, program, options); + + // Fetch events for all signatures in parallel + const eventsWithSlots = await Promise.all( + allSignatures.map(async (signatureTransaction) => { + const events = await readEvents(rpc, signatureTransaction.signature, program, anchorIdl, finality); + + return events.map((event) => ({ + ...event, + confirmationStatus: signatureTransaction.confirmationStatus || "Unknown", + blockTime: signatureTransaction.blockTime || 0, + signature: signatureTransaction.signature, + slot: signatureTransaction.slot, + name: event.name || "Unknown", + })); + }) + ); + return eventsWithSlots.flat(); +} + +async function searchSignaturesUntilLimit( + client: RpcClient, + program: Address, + options: GetSignaturesForAddressConfig = { limit: 1000 } +): Promise { + const allSignatures: GetSignaturesForAddressTransaction[] = []; + // Fetch all signatures in sequential batches + while (true) { + const signatures = await client.rpc.getSignaturesForAddress(program, options).send(); + allSignatures.push(...signatures); + + // Update options for the next batch. Set before to the last fetched signature. + if (signatures.length > 0) { + options = { ...options, before: signatures[signatures.length - 1].signature }; + } + + if (options.limit && signatures.length < options.limit) break; // Exit early if the number of signatures < limit + } + return allSignatures; +} + +/** + * Reads events from a transaction. + */ +export async function readEvents( + client: RpcClient, + txSignature: Signature, + programId: Address, + programIdl: Idl, + commitment: Commitment = "confirmed" +) { + const txResult = await client.rpc + .getTransaction(txSignature, { encoding: "json", commitment, maxSupportedTransactionVersion: 0 }) + .send(); + + if (txResult === null) return []; + + // Ensure `version` field is always present in the response. @todo Drop this with next Anchor upgrade. + const txWithVersion = { ...txResult, version: txResult.version ?? 0 }; + return processEventFromTx(txWithVersion, programId, programIdl); +} + +/** + * Processes events from a transaction. + */ +async function processEventFromTx( + txResult: GetTransactionReturnType, + programId: Address, + programIdl: Idl +): Promise<{ program: Address; data: any; name: string | undefined }[]> { + if (!txResult) return []; + const eventAuthorities: Map = new Map(); + const events: { program: Address; data: any; name: string | undefined }[] = []; + const [pda] = await web3.getProgramDerivedAddress({ programAddress: programId, seeds: ["__event_authority"] }); + eventAuthorities.set(programId, pda); + + const accountKeys = txResult.transaction.message.accountKeys; + const messageAccountKeys = [...accountKeys]; + // Order matters here. writable accounts must be processed before readonly accounts. + // See https://docs.anza.xyz/proposals/versioned-transactions#new-transaction-format + messageAccountKeys.push(...(txResult?.meta?.loadedAddresses?.writable ?? [])); + messageAccountKeys.push(...(txResult?.meta?.loadedAddresses?.readonly ?? [])); + + for (const ixBlock of txResult.meta?.innerInstructions ?? []) { + for (const ix of ixBlock.instructions) { + const ixProgramId = messageAccountKeys[ix.programIdIndex]; + const singleIxAccount = ix.accounts.length === 1 ? messageAccountKeys[ix.accounts[0]] : undefined; + if ( + ixProgramId !== undefined && + singleIxAccount !== undefined && + programId == ixProgramId && + eventAuthorities.get(ixProgramId.toString()) == singleIxAccount + ) { + const ixData = utils.bytes.bs58.decode(ix.data); + const eventData = utils.bytes.base64.encode(Buffer.from(new Uint8Array(ixData).slice(8))); + let event = new BorshEventCoder(programIdl).decode(eventData); + events.push({ + program: programId, + data: event?.data, + name: event?.name, + }); + } + } + } + + return events; +} + +/** + * For a given fillStatusPDa & associated spokePool ProgramID, return the fill event. + */ +export async function readFillEventFromFillStatusPda( + client: RpcClient, + fillStatusPda: Address, + programId: Address, + programIdl: Idl +): Promise<{ event: any; slot: number }> { + const signatures = await searchSignaturesUntilLimit(client, fillStatusPda); + if (signatures.length === 0) return { event: null, slot: 0 }; + + // The first signature will always be PDA creation, and therefore CPI event carrying signature. Any older signatures + // will therefore be either spam or PDA closure signatures and can be ignored when looking for the fill event. + const events = await readEvents(client, signatures[signatures.length - 1].signature, programId, programIdl); + return { event: events[0], slot: Number(signatures[signatures.length - 1].slot) }; +} diff --git a/src/svm/web3-v2/transactionUtils.ts b/src/svm/web3-v2/transactionUtils.ts new file mode 100644 index 000000000..3a3ad55d8 --- /dev/null +++ b/src/svm/web3-v2/transactionUtils.ts @@ -0,0 +1,143 @@ +import { + Address, + AddressesByLookupTableAddress, + appendTransactionMessageInstruction, + appendTransactionMessageInstructions, + assertIsTransactionWithBlockhashLifetime, + assertIsTransactionWithinSizeLimit, + BaseTransactionMessage, + Commitment, + compressTransactionMessageUsingAddressLookupTables as compressTxWithAlt, + createTransactionMessage, + getSignatureFromTransaction, + Instruction, + KeyPairSigner, + pipe, + sendAndConfirmTransactionFactory, + setTransactionMessageFeePayerSigner, + setTransactionMessageLifetimeUsingBlockhash, + signTransactionMessageWithSigners, + TransactionMessageWithBlockhashLifetime, + TransactionMessageWithFeePayer, + TransactionSigner, +} from "@solana/kit"; + +import { + fetchAddressLookupTable, + findAddressLookupTablePda, + getCreateLookupTableInstructionAsync, + getExtendLookupTableInstruction, +} from "@solana-program/address-lookup-table"; +import { RpcClient } from "./types"; + +/** + * Signs and sends a transaction. + */ +export const signAndSendTransaction = async ( + rpcClient: RpcClient, + transactionMessage: BaseTransactionMessage & TransactionMessageWithFeePayer & TransactionMessageWithBlockhashLifetime, + commitment: Commitment = "confirmed" +) => { + const signedTransaction = await signTransactionMessageWithSigners(transactionMessage); + assertIsTransactionWithBlockhashLifetime(signedTransaction); + assertIsTransactionWithinSizeLimit(signedTransaction); + const signature = getSignatureFromTransaction(signedTransaction); + await sendAndConfirmTransactionFactory(rpcClient)(signedTransaction, { + commitment, + }); + return signature; +}; + +export const createDefaultTransaction = async (rpcClient: RpcClient, signer: TransactionSigner) => { + const { value: latestBlockhash } = await rpcClient.rpc.getLatestBlockhash().send(); + return pipe( + createTransactionMessage({ version: 0 }), + (tx) => setTransactionMessageFeePayerSigner(signer, tx), + (tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx) + ); +}; + +/** + * Sends a transaction with an Address Lookup Table. + */ +export async function sendTransactionWithLookupTable( + client: RpcClient, + payer: KeyPairSigner, + instructions: Instruction[], + addressesByLookupTableAddress: AddressesByLookupTableAddress +) { + return pipe( + await createDefaultTransaction(client, payer), + (tx) => appendTransactionMessageInstructions(instructions, tx), + (tx) => compressTxWithAlt(tx, addressesByLookupTableAddress), + (tx) => signTransactionMessageWithSigners(tx), + async (tx) => { + const signedTx = await tx; + assertIsTransactionWithBlockhashLifetime(signedTx); + assertIsTransactionWithinSizeLimit(signedTx); + await sendAndConfirmTransactionFactory(client)(signedTx, { + commitment: "confirmed", + skipPreflight: false, + }); + return getSignatureFromTransaction(signedTx); + } + ); +} + +/** + * Creates an Address Lookup Table. + */ +export async function createLookupTable(client: RpcClient, authority: KeyPairSigner): Promise

{ + const recentSlot = await client.rpc.getSlot({ commitment: "finalized" }).send(); + + const [alt] = await findAddressLookupTablePda({ + authority: authority.address, + recentSlot, + }); + + const createAltIx = await getCreateLookupTableInstructionAsync({ + authority, + recentSlot, + }); + + await pipe( + await createDefaultTransaction(client, authority), + (tx) => appendTransactionMessageInstruction(createAltIx, tx), + (tx) => signAndSendTransaction(client, tx) + ); + + return alt; +} + +/** + * Extends an Address Lookup Table. + */ +export async function extendLookupTable( + client: RpcClient, + authority: KeyPairSigner, + alt: Address, + addresses: Address[] +) { + const extendAltIx = getExtendLookupTableInstruction({ + address: alt, + authority, + payer: authority, + addresses, + }); + + await pipe( + await createDefaultTransaction(client, authority), + (tx) => appendTransactionMessageInstruction(extendAltIx, tx), + (tx) => signAndSendTransaction(client, tx) + ); + + const altAccount = await fetchAddressLookupTable(client.rpc, alt); + + const addressesByLookupTableAddress: AddressesByLookupTableAddress = {}; + addressesByLookupTableAddress[alt] = altAccount.data.addresses; + + // Delay a second here to let lookup table warm up + await new Promise((resolve) => setTimeout(resolve, 1000)); + + return addressesByLookupTableAddress; +} diff --git a/src/svm/web3-v2/types.ts b/src/svm/web3-v2/types.ts new file mode 100644 index 000000000..50677589d --- /dev/null +++ b/src/svm/web3-v2/types.ts @@ -0,0 +1,16 @@ +import { + Rpc, + RpcSubscriptions, + RpcTransport, + SignatureNotificationsApi, + SlotNotificationsApi, + SolanaRpcApiFromTransport, +} from "@solana/kit"; + +/** + * A client for the Solana RPC. + */ +export type RpcClient = { + rpc: Rpc>; + rpcSubscriptions: RpcSubscriptions; +}; diff --git a/yarn.lock b/yarn.lock index ca4f19940..4ed6efb32 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2271,7 +2271,7 @@ color "^5.0.2" text-hex "1.0.x" -"@solana-program/address-lookup-table@0.10.0": +"@solana-program/address-lookup-table@0.10.0", "@solana-program/address-lookup-table@^0.10.0": version "0.10.0" resolved "https://registry.yarnpkg.com/@solana-program/address-lookup-table/-/address-lookup-table-0.10.0.tgz#a7e9dd0a37e9a960396ec608d756ef5d44e485c6" integrity sha512-lcp+IYwoFBODhg8vXsh5vpxweLxpSKqjAu8P1LyqQxgk2yqwYmJGA79YKa+lZvsQjP/c0rzIZYWIGxFMMes2zA== @@ -2675,7 +2675,7 @@ dependencies: "@solana/codecs" "2.0.0-rc.1" -"@solana/spl-token@0.4.14": +"@solana/spl-token@0.4.14", "@solana/spl-token@^0.4.14": version "0.4.14" resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.4.14.tgz#b86bc8a17f50e9680137b585eca5f5eb9d55c025" integrity sha512-u09zr96UBpX4U685MnvQsNzlvw9TiY005hk1vJmJr7gMJldoPG1eYU5/wNEyOA5lkMLiR/gOi9SFD4MefOYEsA== @@ -2791,7 +2791,7 @@ rpc-websockets "^9.0.2" superstruct "^2.0.2" -"@solana/web3.js@^1.31.0", "@solana/web3.js@^1.68.0": +"@solana/web3.js@^1.68.0": version "1.95.4" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.95.4.tgz#771603f60d75cf7556ad867e1fd2efae32f9ad09" integrity sha512-sdewnNEA42ZSMxqkzdwEWi6fDgzwtJHaQa5ndUGEJYtoOnM6X5cvPmjoTUp7/k7bRrVAxfBgDnvQQHD6yhlLYw== @@ -2812,6 +2812,27 @@ rpc-websockets "^9.0.2" superstruct "^2.0.2" +"@solana/web3.js@^1.98.2": + version "1.98.4" + resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.4.tgz#df51d78be9d865181ec5138b4e699d48e6895bbe" + integrity sha512-vv9lfnvjUsRiq//+j5pBdXig0IQdtzA0BRZ3bXEP4KaIyF1CcaydWqgyzQgfZMNIsWNWmG+AUHwPy4AHOD6gpw== + dependencies: + "@babel/runtime" "^7.25.0" + "@noble/curves" "^1.4.2" + "@noble/hashes" "^1.4.0" + "@solana/buffer-layout" "^4.0.1" + "@solana/codecs-numbers" "^2.1.0" + agentkeepalive "^4.5.0" + bn.js "^5.2.1" + borsh "^0.7.0" + bs58 "^4.0.1" + buffer "6.0.3" + fast-stable-stringify "^1.0.0" + jayson "^4.1.1" + node-fetch "^2.7.0" + rpc-websockets "^9.0.2" + superstruct "^2.0.2" + "@solidity-parser/parser@^0.14.0": version "0.14.1" resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.14.1.tgz#179afb29f4e295a77cc141151f26b3848abc3c46" @@ -4911,6 +4932,11 @@ borsh@^0.7.0: bs58 "^4.0.0" text-encoding-utf-8 "^1.0.2" +borsh@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/borsh/-/borsh-2.0.0.tgz#042a9f109565caac3c6a21297cd8c0ae8db3149d" + integrity sha512-kc9+BgR3zz9+cjbwM8ODoUB4fs3X3I5A/HtX7LZKxCLaMrEeDFoBpnhZY//DTS1VZBSs6S5v46RZRbZjRFspEg== + boxen@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/boxen/-/boxen-5.1.2.tgz#788cb686fc83c1f486dfa8a40c68fc2b831d2b50" From 40a8970bc250e9f6e09e46333bdab3c8812eebb7 Mon Sep 17 00:00:00 2001 From: Faisal Usmani Date: Wed, 1 Apr 2026 11:29:43 -0700 Subject: [PATCH 02/12] chore: gitignore auto-generated SVM assets and clients These files are synced from the contracts repo via `yarn sync-svm-clients` and should not be committed, matching the contracts repo's approach. Only clients/index.ts (the hand-written barrel) is tracked. Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitignore | 5 + src/svm/assets/idl/index.ts | 21 - src/svm/assets/idl/message_transmitter.json | 1675 ----- .../assets/idl/message_transmitter_v2.json | 1863 ------ src/svm/assets/idl/multicall_handler.json | 31 - .../idl/sponsored_cctp_src_periphery.json | 1965 ------ src/svm/assets/idl/svm_spoke.json | 5496 ---------------- src/svm/assets/idl/test.json | 243 - .../assets/idl/token_messenger_minter.json | 2049 ------ .../assets/idl/token_messenger_minter_v2.json | 4441 ------------- src/svm/assets/index.ts | 12 - src/svm/assets/message_transmitter.ts | 1681 ----- src/svm/assets/message_transmitter_v2.ts | 1869 ------ src/svm/assets/multicall_handler.ts | 37 - .../assets/sponsored_cctp_src_periphery.ts | 1971 ------ src/svm/assets/svm_spoke.ts | 5502 ----------------- src/svm/assets/test.ts | 249 - src/svm/assets/token_messenger_minter.ts | 2055 ------ src/svm/assets/token_messenger_minter_v2.ts | 4447 ------------- .../MessageTransmitter/accounts/index.ts | 11 - .../accounts/messageSent.ts | 137 - .../accounts/messageTransmitter.ts | 193 - .../MessageTransmitter/accounts/usedNonces.ts | 143 - .../MessageTransmitter/errors/index.ts | 9 - .../errors/messageTransmitter.ts | 184 - src/svm/clients/MessageTransmitter/index.ts | 13 - .../instructions/acceptOwnership.ts | 218 - .../instructions/disableAttester.ts | 271 - .../instructions/enableAttester.ts | 271 - .../instructions/getNoncePda.ts | 183 - .../MessageTransmitter/instructions/index.ts | 26 - .../instructions/initialize.ts | 326 - .../instructions/isNonceUsed.ts | 171 - .../MessageTransmitter/instructions/pause.ts | 214 - .../instructions/receiveMessage.ts | 319 - .../instructions/reclaimEventAccount.ts | 230 - .../instructions/replaceMessage.ts | 314 - .../instructions/sendMessage.ts | 291 - .../instructions/sendMessageWithCaller.ts | 301 - .../instructions/setMaxMessageBodySize.ts | 238 - .../instructions/setSignatureThreshold.ts | 241 - .../instructions/transferOwnership.ts | 231 - .../instructions/unpause.ts | 214 - .../instructions/updateAttesterManager.ts | 238 - .../instructions/updatePauser.ts | 231 - .../MessageTransmitter/programs/index.ts | 9 - .../programs/messageTransmitter.ts | 372 -- .../MessageTransmitter/shared/index.ts | 164 - .../types/attesterDisabled.ts | 41 - .../types/attesterEnabled.ts | 38 - .../types/attesterManagerUpdated.ts | 50 - .../types/handleReceiveMessageParams.ts | 65 - .../clients/MessageTransmitter/types/index.ts | 21 - .../MessageTransmitter/types/mathError.ts | 36 - .../types/maxMessageBodySizeUpdated.ts | 42 - .../types/messageReceived.ts | 71 - .../types/ownershipTransferStarted.ts | 50 - .../types/ownershipTransferred.ts | 50 - .../clients/MessageTransmitter/types/pause.ts | 32 - .../MessageTransmitter/types/pauserChanged.ts | 38 - .../types/signatureThresholdUpdated.ts | 49 - .../MessageTransmitter/types/unpause.ts | 32 - .../MessageTransmitterV2/accounts/index.ts | 11 - .../accounts/messageSent.ts | 143 - .../accounts/messageTransmitter.ts | 189 - .../accounts/usedNonce.ts | 126 - .../MessageTransmitterV2/errors/index.ts | 9 - .../errors/messageTransmitterV2.ts | 199 - src/svm/clients/MessageTransmitterV2/index.ts | 13 - .../instructions/acceptOwnership.ts | 311 - .../instructions/disableAttester.ts | 393 -- .../instructions/enableAttester.ts | 393 -- .../instructions/index.ts | 23 - .../instructions/initialize.ts | 494 -- .../instructions/isNonceUsed.ts | 157 - .../instructions/pause.ts | 307 - .../instructions/receiveMessage.ts | 486 -- .../instructions/reclaimEventAccount.ts | 242 - .../instructions/sendMessage.ts | 302 - .../instructions/setMaxMessageBodySize.ts | 337 - .../instructions/setSignatureThreshold.ts | 343 - .../instructions/transferOwnership.ts | 330 - .../instructions/unpause.ts | 307 - .../instructions/updateAttesterManager.ts | 337 - .../instructions/updatePauser.ts | 330 - .../MessageTransmitterV2/programs/index.ts | 9 - .../programs/messageTransmitterV2.ts | 324 - .../MessageTransmitterV2/shared/index.ts | 164 - .../types/attesterDisabled.ts | 41 - .../types/attesterEnabled.ts | 38 - .../types/attesterManagerUpdated.ts | 50 - .../MessageTransmitterV2/types/index.ts | 19 - .../types/maxMessageBodySizeUpdated.ts | 42 - .../types/messageReceived.ts | 68 - .../types/ownershipTransferStarted.ts | 50 - .../types/ownershipTransferred.ts | 50 - .../MessageTransmitterV2/types/pause.ts | 32 - .../types/pauserChanged.ts | 38 - .../types/signatureThresholdUpdated.ts | 49 - .../MessageTransmitterV2/types/unpause.ts | 32 - src/svm/clients/MulticallHandler/index.ts | 10 - .../instructions/handleV3AcrossMessage.ts | 133 - .../MulticallHandler/instructions/index.ts | 9 - .../MulticallHandler/programs/index.ts | 9 - .../programs/multicallHandler.ts | 49 - .../clients/MulticallHandler/shared/index.ts | 164 - .../accounts/index.ts | 13 - .../accounts/messageSent.ts | 143 - .../accounts/minimumDeposit.ts | 147 - .../accounts/rentClaim.ts | 126 - .../accounts/state.ts | 139 - .../accounts/usedNonce.ts | 129 - .../SponsoredCctpSrcPeriphery/errors/index.ts | 9 - .../errors/sponsoredCctpSrcPeriphery.ts | 103 - .../SponsoredCctpSrcPeriphery/index.ts | 13 - .../instructions/depositForBurn.ts | 914 --- .../instructions/getUsedNonceCloseInfo.ts | 275 - .../instructions/index.ts | 18 - .../instructions/initialize.ts | 369 -- .../instructions/reclaimEventAccount.ts | 436 -- .../instructions/reclaimUsedNonceAccount.ts | 371 -- .../instructions/repayRentFundDebt.ts | 382 -- .../instructions/setCurrentTime.ts | 254 - .../instructions/setMinimumDepositAmount.ts | 401 -- .../instructions/setSigner.ts | 328 - .../instructions/withdrawRentFund.ts | 385 -- .../programs/index.ts | 9 - .../programs/sponsoredCctpSrcPeriphery.ts | 268 - .../SponsoredCctpSrcPeriphery/shared/index.ts | 164 - .../types/accruedRentFundLiability.ts | 59 - .../types/createdEventAccount.ts | 41 - .../SponsoredCctpSrcPeriphery/types/index.ts | 20 - .../types/minimumDepositAmountSet.ts | 52 - .../types/reclaimedEventAccount.ts | 41 - .../types/reclaimedUsedNonceAccount.ts | 57 - .../types/repaidRentFundDebt.ts | 59 - .../types/signerSet.ts | 41 - .../types/sponsoredCCTPQuote.ts | 130 - .../types/sponsoredDepositForBurn.ts | 96 - .../types/usedNonceAccountParams.ts | 43 - .../types/usedNonceCloseInfo.ts | 54 - .../types/withdrawnRentFund.ts | 52 - .../clients/SvmSpoke/accounts/claimAccount.ts | 139 - .../executeRelayerRefundLeafParams.ts | 176 - .../accounts/executeSlowRelayLeafParams.ts | 176 - .../SvmSpoke/accounts/fillRelayParams.ts | 158 - .../SvmSpoke/accounts/fillStatusAccount.ts | 165 - src/svm/clients/SvmSpoke/accounts/index.ts | 17 - .../accounts/requestSlowFillParams.ts | 156 - .../clients/SvmSpoke/accounts/rootBundle.ts | 140 - src/svm/clients/SvmSpoke/accounts/state.ts | 181 - .../SvmSpoke/accounts/transferLiability.ts | 147 - src/svm/clients/SvmSpoke/errors/index.ts | 9 - src/svm/clients/SvmSpoke/errors/svmSpoke.ts | 112 - src/svm/clients/SvmSpoke/index.ts | 13 - .../instructions/bridgeTokensToHubPool.ts | 800 --- .../instructions/claimRelayerRefund.ts | 498 -- .../instructions/closeClaimAccount.ts | 307 - .../SvmSpoke/instructions/closeFillPda.ts | 194 - .../instructions/closeInstructionParams.ts | 270 - .../instructions/createTokenAccounts.ts | 252 - .../clients/SvmSpoke/instructions/deposit.ts | 614 -- .../SvmSpoke/instructions/depositNow.ts | 608 -- .../instructions/emergencyDeleteRootBundle.ts | 371 -- .../instructions/executeRelayerRefundLeaf.ts | 536 -- .../executeRelayerRefundLeafDeferred.ts | 539 -- .../instructions/executeSlowRelayLeaf.ts | 634 -- .../SvmSpoke/instructions/fillRelay.ts | 650 -- .../instructions/getUnsafeDepositId.ts | 142 - .../instructions/handleReceiveMessage.ts | 382 -- .../clients/SvmSpoke/instructions/index.ts | 35 - .../SvmSpoke/instructions/initialize.ts | 345 -- .../instructions/initializeClaimAccount.ts | 345 -- .../initializeInstructionParams.ts | 328 - .../SvmSpoke/instructions/pauseDeposits.ts | 320 - .../SvmSpoke/instructions/pauseFills.ts | 318 - .../SvmSpoke/instructions/relayRootBundle.ts | 405 -- .../SvmSpoke/instructions/requestSlowFill.ts | 456 -- .../instructions/setCrossDomainAdmin.ts | 327 - .../SvmSpoke/instructions/setCurrentTime.ts | 188 - .../instructions/transferOwnership.ts | 320 - .../SvmSpoke/instructions/unsafeDeposit.ts | 622 -- .../writeInstructionParamsFragment.ts | 336 - src/svm/clients/SvmSpoke/programs/index.ts | 9 - src/svm/clients/SvmSpoke/programs/svmSpoke.ts | 588 -- src/svm/clients/SvmSpoke/shared/index.ts | 164 - .../SvmSpoke/types/bridgedToHubPool.ts | 49 - .../SvmSpoke/types/claimedRelayerRefund.ts | 59 - .../types/emergencyDeletedRootBundle.ts | 40 - .../types/executedRelayerRefundRoot.ts | 89 - src/svm/clients/SvmSpoke/types/fillStatus.ts | 36 - src/svm/clients/SvmSpoke/types/fillType.ts | 36 - src/svm/clients/SvmSpoke/types/filledRelay.ts | 114 - .../clients/SvmSpoke/types/fundsDeposited.ts | 105 - src/svm/clients/SvmSpoke/types/index.ts | 27 - .../clients/SvmSpoke/types/pausedDeposits.ts | 37 - src/svm/clients/SvmSpoke/types/pausedFills.ts | 34 - src/svm/clients/SvmSpoke/types/relayData.ts | 98 - .../SvmSpoke/types/relayExecutionEventInfo.ts | 74 - .../SvmSpoke/types/relayedRootBundle.ts | 57 - .../SvmSpoke/types/relayerRefundLeaf.ts | 75 - .../SvmSpoke/types/requestedSlowFill.ts | 102 - .../clients/SvmSpoke/types/setXDomainAdmin.ts | 38 - src/svm/clients/SvmSpoke/types/slowFill.ts | 56 - .../clients/SvmSpoke/types/tokensBridged.ts | 66 - .../SvmSpoke/types/transferredOwnership.ts | 41 - .../TokenMessengerMinter/accounts/index.ts | 13 - .../accounts/localToken.ts | 169 - .../accounts/remoteTokenMessenger.ts | 164 - .../accounts/tokenMessenger.ts | 164 - .../accounts/tokenMinter.ts | 149 - .../accounts/tokenPair.ts | 147 - .../TokenMessengerMinter/errors/index.ts | 9 - .../errors/tokenMessengerMinter.ts | 111 - src/svm/clients/TokenMessengerMinter/index.ts | 13 - .../instructions/acceptOwnership.ts | 216 - .../instructions/addLocalToken.ts | 320 - .../instructions/addRemoteTokenMessenger.ts | 297 - .../instructions/burnTokenCustody.ts | 317 - .../instructions/depositForBurn.ts | 465 -- .../instructions/depositForBurnWithCaller.ts | 475 -- .../instructions/handleReceiveMessage.ts | 371 -- .../instructions/index.ts | 27 - .../instructions/initialize.ts | 345 -- .../instructions/linkTokenPair.ts | 297 - .../instructions/pause.ts | 212 - .../instructions/removeLocalToken.ts | 287 - .../removeRemoteTokenMessenger.ts | 254 - .../instructions/replaceDepositForBurn.ts | 392 -- .../setMaxBurnAmountPerMessage.ts | 253 - .../instructions/setTokenController.ts | 247 - .../instructions/transferOwnership.ts | 229 - .../instructions/unlinkTokenPair.ts | 249 - .../instructions/unpause.ts | 212 - .../instructions/updatePauser.ts | 243 - .../TokenMessengerMinter/programs/index.ts | 9 - .../programs/tokenMessengerMinter.ts | 412 -- .../TokenMessengerMinter/shared/index.ts | 164 - .../types/depositForBurn.ts | 78 - .../TokenMessengerMinter/types/index.ts | 25 - .../types/localTokenAdded.ts | 44 - .../types/localTokenRemoved.ts | 47 - .../types/mintAndWithdraw.ts | 56 - .../types/ownershipTransferStarted.ts | 50 - .../types/ownershipTransferred.ts | 50 - .../TokenMessengerMinter/types/pause.ts | 32 - .../types/pauserChanged.ts | 38 - .../types/remoteTokenMessengerAdded.ts | 52 - .../types/remoteTokenMessengerRemoved.ts | 52 - .../types/setBurnLimitPerMessage.ts | 55 - .../types/setTokenController.ts | 41 - .../types/tokenCustodyBurned.ts | 55 - .../types/tokenMinterError.ts | 48 - .../types/tokenPairLinked.ts | 52 - .../types/tokenPairUnlinked.ts | 55 - .../TokenMessengerMinter/types/unpause.ts | 32 - .../accounts/denylistedAccount.ts | 147 - .../TokenMessengerMinterV2/accounts/index.ts | 15 - .../accounts/localToken.ts | 169 - .../accounts/messageTransmitter.ts | 189 - .../accounts/remoteTokenMessenger.ts | 164 - .../accounts/tokenMessenger.ts | 176 - .../accounts/tokenMinter.ts | 149 - .../accounts/tokenPair.ts | 147 - .../TokenMessengerMinterV2/errors/index.ts | 9 - .../errors/tokenMessengerMinterV2.ts | 95 - .../clients/TokenMessengerMinterV2/index.ts | 13 - .../instructions/acceptOwnership.ts | 305 - .../instructions/addLocalToken.ts | 502 -- .../instructions/addRemoteTokenMessenger.ts | 424 -- .../instructions/burnTokenCustody.ts | 465 -- .../instructions/denylistAccount.ts | 403 -- .../instructions/depositForBurn.ts | 802 --- .../instructions/depositForBurnWithHook.ts | 815 --- .../handleReceiveFinalizedMessage.ts | 569 -- .../handleReceiveUnfinalizedMessage.ts | 569 -- .../instructions/index.ts | 33 - .../instructions/initialize.ts | 567 -- .../instructions/linkTokenPair.ts | 425 -- .../instructions/pause.ts | 301 - .../instructions/removeLocalToken.ts | 446 -- .../removeRemoteTokenMessenger.ts | 362 -- .../instructions/setFeeRecipient.ts | 324 - .../setMaxBurnAmountPerMessage.ts | 359 -- .../instructions/setMinFee.ts | 328 - .../instructions/setMinFeeController.ts | 331 - .../instructions/setTokenController.ts | 350 -- .../instructions/transferOwnership.ts | 324 - .../instructions/undenylistAccount.ts | 403 -- .../instructions/unlinkTokenPair.ts | 357 -- .../instructions/unpause.ts | 301 - .../instructions/updateDenylister.ts | 324 - .../instructions/updatePauser.ts | 346 -- .../TokenMessengerMinterV2/programs/index.ts | 9 - .../programs/tokenMessengerMinterV2.ts | 532 -- .../TokenMessengerMinterV2/shared/index.ts | 164 - .../types/denylisted.ts | 35 - .../types/denylisterChanged.ts | 50 - .../types/depositForBurn.ts | 91 - .../types/feeRecipientSet.ts | 38 - .../types/handleReceiveMessageParams.ts | 68 - .../TokenMessengerMinterV2/types/index.ts | 31 - .../types/localTokenAdded.ts | 44 - .../types/localTokenRemoved.ts | 47 - .../types/minFeeControllerSet.ts | 41 - .../TokenMessengerMinterV2/types/minFeeSet.ts | 34 - .../types/mintAndWithdraw.ts | 60 - .../types/ownershipTransferStarted.ts | 50 - .../types/ownershipTransferred.ts | 50 - .../TokenMessengerMinterV2/types/pause.ts | 32 - .../types/pauserChanged.ts | 38 - .../types/remoteTokenMessengerAdded.ts | 52 - .../types/remoteTokenMessengerRemoved.ts | 52 - .../types/setBurnLimitPerMessage.ts | 55 - .../types/setTokenController.ts | 41 - .../types/tokenCustodyBurned.ts | 55 - .../types/tokenPairLinked.ts | 52 - .../types/tokenPairUnlinked.ts | 55 - .../types/unDenylisted.ts | 35 - .../TokenMessengerMinterV2/types/unpause.ts | 32 - 320 files changed, 5 insertions(+), 91958 deletions(-) delete mode 100644 src/svm/assets/idl/index.ts delete mode 100644 src/svm/assets/idl/message_transmitter.json delete mode 100644 src/svm/assets/idl/message_transmitter_v2.json delete mode 100644 src/svm/assets/idl/multicall_handler.json delete mode 100644 src/svm/assets/idl/sponsored_cctp_src_periphery.json delete mode 100644 src/svm/assets/idl/svm_spoke.json delete mode 100644 src/svm/assets/idl/test.json delete mode 100644 src/svm/assets/idl/token_messenger_minter.json delete mode 100644 src/svm/assets/idl/token_messenger_minter_v2.json delete mode 100644 src/svm/assets/index.ts delete mode 100644 src/svm/assets/message_transmitter.ts delete mode 100644 src/svm/assets/message_transmitter_v2.ts delete mode 100644 src/svm/assets/multicall_handler.ts delete mode 100644 src/svm/assets/sponsored_cctp_src_periphery.ts delete mode 100644 src/svm/assets/svm_spoke.ts delete mode 100644 src/svm/assets/test.ts delete mode 100644 src/svm/assets/token_messenger_minter.ts delete mode 100644 src/svm/assets/token_messenger_minter_v2.ts delete mode 100644 src/svm/clients/MessageTransmitter/accounts/index.ts delete mode 100644 src/svm/clients/MessageTransmitter/accounts/messageSent.ts delete mode 100644 src/svm/clients/MessageTransmitter/accounts/messageTransmitter.ts delete mode 100644 src/svm/clients/MessageTransmitter/accounts/usedNonces.ts delete mode 100644 src/svm/clients/MessageTransmitter/errors/index.ts delete mode 100644 src/svm/clients/MessageTransmitter/errors/messageTransmitter.ts delete mode 100644 src/svm/clients/MessageTransmitter/index.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/acceptOwnership.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/disableAttester.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/enableAttester.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/getNoncePda.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/index.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/initialize.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/isNonceUsed.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/pause.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/receiveMessage.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/reclaimEventAccount.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/replaceMessage.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/sendMessage.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/sendMessageWithCaller.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/setMaxMessageBodySize.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/setSignatureThreshold.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/transferOwnership.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/unpause.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/updateAttesterManager.ts delete mode 100644 src/svm/clients/MessageTransmitter/instructions/updatePauser.ts delete mode 100644 src/svm/clients/MessageTransmitter/programs/index.ts delete mode 100644 src/svm/clients/MessageTransmitter/programs/messageTransmitter.ts delete mode 100644 src/svm/clients/MessageTransmitter/shared/index.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/attesterDisabled.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/attesterEnabled.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/attesterManagerUpdated.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/handleReceiveMessageParams.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/index.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/mathError.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/maxMessageBodySizeUpdated.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/messageReceived.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/ownershipTransferStarted.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/ownershipTransferred.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/pause.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/pauserChanged.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/signatureThresholdUpdated.ts delete mode 100644 src/svm/clients/MessageTransmitter/types/unpause.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/accounts/index.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/accounts/messageSent.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/accounts/messageTransmitter.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/accounts/usedNonce.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/errors/index.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/errors/messageTransmitterV2.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/index.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/acceptOwnership.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/disableAttester.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/enableAttester.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/index.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/initialize.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/isNonceUsed.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/pause.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/receiveMessage.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/reclaimEventAccount.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/sendMessage.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/setMaxMessageBodySize.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/setSignatureThreshold.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/transferOwnership.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/unpause.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/updateAttesterManager.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/instructions/updatePauser.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/programs/index.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/programs/messageTransmitterV2.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/shared/index.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/types/attesterDisabled.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/types/attesterEnabled.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/types/attesterManagerUpdated.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/types/index.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/types/maxMessageBodySizeUpdated.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/types/messageReceived.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/types/ownershipTransferStarted.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/types/ownershipTransferred.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/types/pause.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/types/pauserChanged.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/types/signatureThresholdUpdated.ts delete mode 100644 src/svm/clients/MessageTransmitterV2/types/unpause.ts delete mode 100644 src/svm/clients/MulticallHandler/index.ts delete mode 100644 src/svm/clients/MulticallHandler/instructions/handleV3AcrossMessage.ts delete mode 100644 src/svm/clients/MulticallHandler/instructions/index.ts delete mode 100644 src/svm/clients/MulticallHandler/programs/index.ts delete mode 100644 src/svm/clients/MulticallHandler/programs/multicallHandler.ts delete mode 100644 src/svm/clients/MulticallHandler/shared/index.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/accounts/index.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/accounts/messageSent.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/accounts/minimumDeposit.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/accounts/rentClaim.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/accounts/state.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/accounts/usedNonce.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/errors/index.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/errors/sponsoredCctpSrcPeriphery.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/index.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/depositForBurn.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/getUsedNonceCloseInfo.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/index.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/initialize.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimEventAccount.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimUsedNonceAccount.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/repayRentFundDebt.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setCurrentTime.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setMinimumDepositAmount.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setSigner.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/instructions/withdrawRentFund.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/programs/index.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/programs/sponsoredCctpSrcPeriphery.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/shared/index.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/accruedRentFundLiability.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/createdEventAccount.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/index.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/minimumDepositAmountSet.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedEventAccount.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedUsedNonceAccount.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/repaidRentFundDebt.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/signerSet.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredCCTPQuote.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredDepositForBurn.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceAccountParams.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceCloseInfo.ts delete mode 100644 src/svm/clients/SponsoredCctpSrcPeriphery/types/withdrawnRentFund.ts delete mode 100644 src/svm/clients/SvmSpoke/accounts/claimAccount.ts delete mode 100644 src/svm/clients/SvmSpoke/accounts/executeRelayerRefundLeafParams.ts delete mode 100644 src/svm/clients/SvmSpoke/accounts/executeSlowRelayLeafParams.ts delete mode 100644 src/svm/clients/SvmSpoke/accounts/fillRelayParams.ts delete mode 100644 src/svm/clients/SvmSpoke/accounts/fillStatusAccount.ts delete mode 100644 src/svm/clients/SvmSpoke/accounts/index.ts delete mode 100644 src/svm/clients/SvmSpoke/accounts/requestSlowFillParams.ts delete mode 100644 src/svm/clients/SvmSpoke/accounts/rootBundle.ts delete mode 100644 src/svm/clients/SvmSpoke/accounts/state.ts delete mode 100644 src/svm/clients/SvmSpoke/accounts/transferLiability.ts delete mode 100644 src/svm/clients/SvmSpoke/errors/index.ts delete mode 100644 src/svm/clients/SvmSpoke/errors/svmSpoke.ts delete mode 100644 src/svm/clients/SvmSpoke/index.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/bridgeTokensToHubPool.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/claimRelayerRefund.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/closeClaimAccount.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/closeFillPda.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/closeInstructionParams.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/createTokenAccounts.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/deposit.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/depositNow.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/emergencyDeleteRootBundle.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeaf.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeafDeferred.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/executeSlowRelayLeaf.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/fillRelay.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/getUnsafeDepositId.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/handleReceiveMessage.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/index.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/initialize.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/initializeClaimAccount.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/initializeInstructionParams.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/pauseDeposits.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/pauseFills.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/relayRootBundle.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/requestSlowFill.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/setCrossDomainAdmin.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/setCurrentTime.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/transferOwnership.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/unsafeDeposit.ts delete mode 100644 src/svm/clients/SvmSpoke/instructions/writeInstructionParamsFragment.ts delete mode 100644 src/svm/clients/SvmSpoke/programs/index.ts delete mode 100644 src/svm/clients/SvmSpoke/programs/svmSpoke.ts delete mode 100644 src/svm/clients/SvmSpoke/shared/index.ts delete mode 100644 src/svm/clients/SvmSpoke/types/bridgedToHubPool.ts delete mode 100644 src/svm/clients/SvmSpoke/types/claimedRelayerRefund.ts delete mode 100644 src/svm/clients/SvmSpoke/types/emergencyDeletedRootBundle.ts delete mode 100644 src/svm/clients/SvmSpoke/types/executedRelayerRefundRoot.ts delete mode 100644 src/svm/clients/SvmSpoke/types/fillStatus.ts delete mode 100644 src/svm/clients/SvmSpoke/types/fillType.ts delete mode 100644 src/svm/clients/SvmSpoke/types/filledRelay.ts delete mode 100644 src/svm/clients/SvmSpoke/types/fundsDeposited.ts delete mode 100644 src/svm/clients/SvmSpoke/types/index.ts delete mode 100644 src/svm/clients/SvmSpoke/types/pausedDeposits.ts delete mode 100644 src/svm/clients/SvmSpoke/types/pausedFills.ts delete mode 100644 src/svm/clients/SvmSpoke/types/relayData.ts delete mode 100644 src/svm/clients/SvmSpoke/types/relayExecutionEventInfo.ts delete mode 100644 src/svm/clients/SvmSpoke/types/relayedRootBundle.ts delete mode 100644 src/svm/clients/SvmSpoke/types/relayerRefundLeaf.ts delete mode 100644 src/svm/clients/SvmSpoke/types/requestedSlowFill.ts delete mode 100644 src/svm/clients/SvmSpoke/types/setXDomainAdmin.ts delete mode 100644 src/svm/clients/SvmSpoke/types/slowFill.ts delete mode 100644 src/svm/clients/SvmSpoke/types/tokensBridged.ts delete mode 100644 src/svm/clients/SvmSpoke/types/transferredOwnership.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/accounts/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/accounts/localToken.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/accounts/remoteTokenMessenger.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/accounts/tokenMessenger.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/accounts/tokenMinter.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/accounts/tokenPair.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/errors/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/errors/tokenMessengerMinter.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/acceptOwnership.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/addLocalToken.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/addRemoteTokenMessenger.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/burnTokenCustody.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/depositForBurn.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/depositForBurnWithCaller.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/handleReceiveMessage.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/initialize.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/linkTokenPair.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/pause.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/removeLocalToken.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/removeRemoteTokenMessenger.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/replaceDepositForBurn.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/setMaxBurnAmountPerMessage.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/setTokenController.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/transferOwnership.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/unlinkTokenPair.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/unpause.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/instructions/updatePauser.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/programs/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/programs/tokenMessengerMinter.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/shared/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/depositForBurn.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/localTokenAdded.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/localTokenRemoved.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/mintAndWithdraw.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/ownershipTransferStarted.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/ownershipTransferred.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/pause.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/pauserChanged.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerAdded.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerRemoved.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/setBurnLimitPerMessage.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/setTokenController.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/tokenCustodyBurned.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/tokenMinterError.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/tokenPairLinked.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/tokenPairUnlinked.ts delete mode 100644 src/svm/clients/TokenMessengerMinter/types/unpause.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/denylistedAccount.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/localToken.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/messageTransmitter.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/remoteTokenMessenger.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/tokenMessenger.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/tokenMinter.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/accounts/tokenPair.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/errors/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/errors/tokenMessengerMinterV2.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/acceptOwnership.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/addLocalToken.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/addRemoteTokenMessenger.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/burnTokenCustody.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/denylistAccount.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurn.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurnWithHook.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveFinalizedMessage.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveUnfinalizedMessage.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/initialize.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/linkTokenPair.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/pause.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/removeLocalToken.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/removeRemoteTokenMessenger.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/setFeeRecipient.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/setMaxBurnAmountPerMessage.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/setMinFee.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/setMinFeeController.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/setTokenController.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/transferOwnership.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/undenylistAccount.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/unlinkTokenPair.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/unpause.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/updateDenylister.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/instructions/updatePauser.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/programs/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/programs/tokenMessengerMinterV2.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/shared/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/denylisted.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/denylisterChanged.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/depositForBurn.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/feeRecipientSet.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/handleReceiveMessageParams.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/index.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/localTokenAdded.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/localTokenRemoved.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/minFeeControllerSet.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/minFeeSet.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/mintAndWithdraw.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferStarted.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferred.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/pause.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/pauserChanged.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerAdded.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerRemoved.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/setBurnLimitPerMessage.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/setTokenController.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/tokenCustodyBurned.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/tokenPairLinked.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/tokenPairUnlinked.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/unDenylisted.ts delete mode 100644 src/svm/clients/TokenMessengerMinterV2/types/unpause.ts diff --git a/.gitignore b/.gitignore index c531f7c57..116c5b1ca 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,11 @@ dist src/utils/abi/contracts/*.json src/utils/abi/typechain +# Auto-generated SVM artifacts (synced from contracts repo via yarn sync-svm-clients) +src/svm/assets +src/svm/clients/* +!src/svm/clients/index.ts + .ledger /target *.tar.gz diff --git a/src/svm/assets/idl/index.ts b/src/svm/assets/idl/index.ts deleted file mode 100644 index 9574894d8..000000000 --- a/src/svm/assets/idl/index.ts +++ /dev/null @@ -1,21 +0,0 @@ -// This file has been autogenerated. Do not edit manually. -// Generated by a script. - -const MessageTransmitterV2Idl = require("./message_transmitter_v2.json"); -const MessageTransmitterIdl = require("./message_transmitter.json"); -const MulticallHandlerIdl = require("./multicall_handler.json"); -const SponsoredCctpSrcPeripheryIdl = require("./sponsored_cctp_src_periphery.json"); -const SvmSpokeIdl = require("./svm_spoke.json"); -const TestIdl = require("./test.json"); -const TokenMessengerMinterV2Idl = require("./token_messenger_minter_v2.json"); -const TokenMessengerMinterIdl = require("./token_messenger_minter.json"); -export { - MessageTransmitterV2Idl, - MessageTransmitterIdl, - MulticallHandlerIdl, - SponsoredCctpSrcPeripheryIdl, - SvmSpokeIdl, - TestIdl, - TokenMessengerMinterV2Idl, - TokenMessengerMinterIdl -}; diff --git a/src/svm/assets/idl/message_transmitter.json b/src/svm/assets/idl/message_transmitter.json deleted file mode 100644 index 27504df15..000000000 --- a/src/svm/assets/idl/message_transmitter.json +++ /dev/null @@ -1,1675 +0,0 @@ -{ - "address": "CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd", - "metadata": { - "name": "message_transmitter", - "version": "0.1.0", - "spec": "0.1.0" - }, - "instructions": [ - { - "name": "initialize", - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "upgrade_authority", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "message_transmitter_program_data" - }, - { - "name": "message_transmitter_program" - }, - { - "name": "system_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "InitializeParams" - } - } - } - ] - }, - { - "name": "transfer_ownership", - "discriminator": [ - 65, - 177, - 215, - 73, - 53, - 45, - 99, - 47 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "TransferOwnershipParams" - } - } - } - ] - }, - { - "name": "accept_ownership", - "discriminator": [ - 172, - 23, - 43, - 13, - 238, - 213, - 85, - 150 - ], - "accounts": [ - { - "name": "pending_owner", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "AcceptOwnershipParams" - } - } - } - ] - }, - { - "name": "update_pauser", - "discriminator": [ - 140, - 171, - 211, - 132, - 57, - 201, - 16, - 254 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UpdatePauserParams" - } - } - } - ] - }, - { - "name": "update_attester_manager", - "discriminator": [ - 175, - 245, - 178, - 104, - 85, - 179, - 71, - 16 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UpdateAttesterManagerParams" - } - } - } - ] - }, - { - "name": "pause", - "discriminator": [ - 211, - 22, - 221, - 251, - 74, - 121, - 193, - 47 - ], - "accounts": [ - { - "name": "pauser", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "PauseParams" - } - } - } - ] - }, - { - "name": "unpause", - "discriminator": [ - 169, - 144, - 4, - 38, - 10, - 141, - 188, - 255 - ], - "accounts": [ - { - "name": "pauser", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UnpauseParams" - } - } - } - ] - }, - { - "name": "set_max_message_body_size", - "discriminator": [ - 168, - 178, - 8, - 117, - 217, - 167, - 219, - 31 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetMaxMessageBodySizeParams" - } - } - } - ] - }, - { - "name": "enable_attester", - "discriminator": [ - 2, - 11, - 193, - 115, - 5, - 148, - 4, - 198 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "attester_manager", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "system_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "EnableAttesterParams" - } - } - } - ] - }, - { - "name": "disable_attester", - "discriminator": [ - 61, - 171, - 131, - 95, - 172, - 15, - 227, - 229 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "attester_manager", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "system_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "DisableAttesterParams" - } - } - } - ] - }, - { - "name": "set_signature_threshold", - "discriminator": [ - 163, - 19, - 154, - 168, - 82, - 209, - 214, - 219 - ], - "accounts": [ - { - "name": "attester_manager", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetSignatureThresholdParams" - } - } - } - ] - }, - { - "name": "send_message", - "discriminator": [ - 57, - 40, - 34, - 178, - 189, - 10, - 65, - 26 - ], - "accounts": [ - { - "name": "event_rent_payer", - "writable": true, - "signer": true - }, - { - "name": "sender_authority_pda", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "message_sent_event_data", - "writable": true, - "signer": true - }, - { - "name": "sender_program" - }, - { - "name": "system_program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SendMessageParams" - } - } - } - ], - "returns": "u64" - }, - { - "name": "send_message_with_caller", - "discriminator": [ - 212, - 47, - 34, - 52, - 91, - 32, - 176, - 204 - ], - "accounts": [ - { - "name": "event_rent_payer", - "writable": true, - "signer": true - }, - { - "name": "sender_authority_pda", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "message_sent_event_data", - "writable": true, - "signer": true - }, - { - "name": "sender_program" - }, - { - "name": "system_program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SendMessageWithCallerParams" - } - } - } - ], - "returns": "u64" - }, - { - "name": "replace_message", - "discriminator": [ - 189, - 189, - 210, - 163, - 149, - 205, - 69, - 229 - ], - "accounts": [ - { - "name": "event_rent_payer", - "writable": true, - "signer": true - }, - { - "name": "sender_authority_pda", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "message_sent_event_data", - "writable": true, - "signer": true - }, - { - "name": "sender_program" - }, - { - "name": "system_program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "ReplaceMessageParams" - } - } - } - ], - "returns": "u64" - }, - { - "name": "receive_message", - "discriminator": [ - 38, - 144, - 127, - 225, - 31, - 225, - 238, - 25 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "caller", - "signer": true - }, - { - "name": "authority_pda" - }, - { - "name": "message_transmitter" - }, - { - "name": "used_nonces", - "writable": true - }, - { - "name": "receiver" - }, - { - "name": "system_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "ReceiveMessageParams" - } - } - } - ] - }, - { - "name": "reclaim_event_account", - "discriminator": [ - 94, - 198, - 180, - 159, - 131, - 236, - 15, - 174 - ], - "accounts": [ - { - "name": "payee", - "docs": [ - "rent SOL receiver, should match original rent payer" - ], - "writable": true, - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "message_sent_event_data", - "writable": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "ReclaimEventAccountParams" - } - } - } - ] - }, - { - "name": "get_nonce_pda", - "discriminator": [ - 114, - 70, - 229, - 212, - 223, - 50, - 33, - 39 - ], - "accounts": [ - { - "name": "message_transmitter" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "GetNoncePDAParams" - } - } - } - ], - "returns": "pubkey" - }, - { - "name": "is_nonce_used", - "discriminator": [ - 144, - 72, - 107, - 148, - 35, - 218, - 31, - 187 - ], - "accounts": [ - { - "name": "used_nonces", - "docs": [ - "Account will be explicitly loaded to avoid error when it's not initialized" - ] - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "IsNonceUsedParams" - } - } - } - ], - "returns": "bool" - } - ], - "accounts": [ - { - "name": "MessageSent", - "discriminator": [ - 131, - 100, - 133, - 56, - 166, - 225, - 151, - 60 - ] - }, - { - "name": "MessageTransmitter", - "discriminator": [ - 71, - 40, - 180, - 142, - 19, - 203, - 35, - 252 - ] - }, - { - "name": "UsedNonces", - "discriminator": [ - 60, - 112, - 18, - 72, - 138, - 181, - 100, - 138 - ] - } - ], - "events": [ - { - "name": "OwnershipTransferStarted", - "discriminator": [ - 183, - 253, - 239, - 246, - 140, - 179, - 133, - 105 - ] - }, - { - "name": "OwnershipTransferred", - "discriminator": [ - 172, - 61, - 205, - 183, - 250, - 50, - 38, - 98 - ] - }, - { - "name": "PauserChanged", - "discriminator": [ - 142, - 157, - 158, - 87, - 127, - 8, - 119, - 55 - ] - }, - { - "name": "AttesterManagerUpdated", - "discriminator": [ - 5, - 97, - 191, - 108, - 44, - 189, - 69, - 88 - ] - }, - { - "name": "MessageReceived", - "discriminator": [ - 231, - 68, - 47, - 77, - 173, - 241, - 157, - 166 - ] - }, - { - "name": "SignatureThresholdUpdated", - "discriminator": [ - 156, - 99, - 103, - 200, - 15, - 38, - 122, - 189 - ] - }, - { - "name": "AttesterEnabled", - "discriminator": [ - 88, - 57, - 14, - 133, - 5, - 219, - 62, - 190 - ] - }, - { - "name": "AttesterDisabled", - "discriminator": [ - 186, - 136, - 186, - 14, - 229, - 2, - 121, - 211 - ] - }, - { - "name": "MaxMessageBodySizeUpdated", - "discriminator": [ - 134, - 206, - 151, - 111, - 137, - 11, - 160, - 225 - ] - }, - { - "name": "Pause", - "discriminator": [ - 194, - 251, - 232, - 196, - 118, - 95, - 111, - 219 - ] - }, - { - "name": "Unpause", - "discriminator": [ - 241, - 149, - 104, - 90, - 199, - 136, - 219, - 146 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "InvalidAuthority", - "msg": "Invalid authority" - }, - { - "code": 6001, - "name": "ProgramPaused", - "msg": "Instruction is not allowed at this time" - }, - { - "code": 6002, - "name": "InvalidMessageTransmitterState", - "msg": "Invalid message transmitter state" - }, - { - "code": 6003, - "name": "InvalidSignatureThreshold", - "msg": "Invalid signature threshold" - }, - { - "code": 6004, - "name": "SignatureThresholdAlreadySet", - "msg": "Signature threshold already set" - }, - { - "code": 6005, - "name": "InvalidOwner", - "msg": "Invalid owner" - }, - { - "code": 6006, - "name": "InvalidPauser", - "msg": "Invalid pauser" - }, - { - "code": 6007, - "name": "InvalidAttesterManager", - "msg": "Invalid attester manager" - }, - { - "code": 6008, - "name": "InvalidAttester", - "msg": "Invalid attester" - }, - { - "code": 6009, - "name": "AttesterAlreadyEnabled", - "msg": "Attester already enabled" - }, - { - "code": 6010, - "name": "TooFewEnabledAttesters", - "msg": "Too few enabled attesters" - }, - { - "code": 6011, - "name": "SignatureThresholdTooLow", - "msg": "Signature threshold is too low" - }, - { - "code": 6012, - "name": "AttesterAlreadyDisabled", - "msg": "Attester already disabled" - }, - { - "code": 6013, - "name": "MessageBodyLimitExceeded", - "msg": "Message body exceeds max size" - }, - { - "code": 6014, - "name": "InvalidDestinationCaller", - "msg": "Invalid destination caller" - }, - { - "code": 6015, - "name": "InvalidRecipient", - "msg": "Invalid message recipient" - }, - { - "code": 6016, - "name": "SenderNotPermitted", - "msg": "Sender is not permitted" - }, - { - "code": 6017, - "name": "InvalidSourceDomain", - "msg": "Invalid source domain" - }, - { - "code": 6018, - "name": "InvalidDestinationDomain", - "msg": "Invalid destination domain" - }, - { - "code": 6019, - "name": "InvalidMessageVersion", - "msg": "Invalid message version" - }, - { - "code": 6020, - "name": "InvalidUsedNoncesAccount", - "msg": "Invalid used nonces account" - }, - { - "code": 6021, - "name": "InvalidRecipientProgram", - "msg": "Invalid recipient program" - }, - { - "code": 6022, - "name": "InvalidNonce", - "msg": "Invalid nonce" - }, - { - "code": 6023, - "name": "NonceAlreadyUsed", - "msg": "Nonce already used" - }, - { - "code": 6024, - "name": "MessageTooShort", - "msg": "Message is too short" - }, - { - "code": 6025, - "name": "MalformedMessage", - "msg": "Malformed message" - }, - { - "code": 6026, - "name": "InvalidSignatureOrderOrDupe", - "msg": "Invalid signature order or dupe" - }, - { - "code": 6027, - "name": "InvalidAttesterSignature", - "msg": "Invalid attester signature" - }, - { - "code": 6028, - "name": "InvalidAttestationLength", - "msg": "Invalid attestation length" - }, - { - "code": 6029, - "name": "InvalidSignatureRecoveryId", - "msg": "Invalid signature recovery ID" - }, - { - "code": 6030, - "name": "InvalidSignatureSValue", - "msg": "Invalid signature S value" - }, - { - "code": 6031, - "name": "InvalidMessageHash", - "msg": "Invalid message hash" - } - ], - "types": [ - { - "name": "AcceptOwnershipParams", - "type": { - "kind": "struct" - } - }, - { - "name": "DisableAttesterParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "EnableAttesterParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "GetNoncePDAParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "nonce", - "type": "u64" - }, - { - "name": "source_domain", - "type": "u32" - } - ] - } - }, - { - "name": "InitializeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "local_domain", - "type": "u32" - }, - { - "name": "attester", - "type": "pubkey" - }, - { - "name": "max_message_body_size", - "type": "u64" - }, - { - "name": "version", - "type": "u32" - } - ] - } - }, - { - "name": "IsNonceUsedParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "nonce", - "type": "u64" - } - ] - } - }, - { - "name": "PauseParams", - "type": { - "kind": "struct" - } - }, - { - "name": "ReceiveMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "message", - "type": "bytes" - }, - { - "name": "attestation", - "type": "bytes" - } - ] - } - }, - { - "name": "HandleReceiveMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "sender", - "type": "pubkey" - }, - { - "name": "message_body", - "type": "bytes" - }, - { - "name": "authority_bump", - "type": "u8" - } - ] - } - }, - { - "name": "ReclaimEventAccountParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attestation", - "type": "bytes" - } - ] - } - }, - { - "name": "ReplaceMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "original_message", - "type": "bytes" - }, - { - "name": "original_attestation", - "type": "bytes" - }, - { - "name": "new_message_body", - "type": "bytes" - }, - { - "name": "new_destination_caller", - "type": "pubkey" - } - ] - } - }, - { - "name": "SendMessageWithCallerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "destination_domain", - "type": "u32" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "message_body", - "type": "bytes" - }, - { - "name": "destination_caller", - "type": "pubkey" - } - ] - } - }, - { - "name": "SendMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "destination_domain", - "type": "u32" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "message_body", - "type": "bytes" - } - ] - } - }, - { - "name": "SetMaxMessageBodySizeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_max_message_body_size", - "type": "u64" - } - ] - } - }, - { - "name": "SetSignatureThresholdParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_signature_threshold", - "type": "u32" - } - ] - } - }, - { - "name": "TransferOwnershipParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "UnpauseParams", - "type": { - "kind": "struct" - } - }, - { - "name": "UpdateAttesterManagerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_attester_manager", - "type": "pubkey" - } - ] - } - }, - { - "name": "UpdatePauserParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_pauser", - "type": "pubkey" - } - ] - } - }, - { - "name": "MathError", - "type": { - "kind": "enum", - "variants": [ - { - "name": "MathOverflow" - }, - { - "name": "MathUnderflow" - }, - { - "name": "ErrorInDivision" - } - ] - } - }, - { - "name": "MessageSent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rent_payer", - "type": "pubkey" - }, - { - "name": "message", - "type": "bytes" - } - ] - } - }, - { - "name": "MessageTransmitter", - "docs": [ - "Main state of the MessageTransmitter program" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "pending_owner", - "type": "pubkey" - }, - { - "name": "attester_manager", - "type": "pubkey" - }, - { - "name": "pauser", - "type": "pubkey" - }, - { - "name": "paused", - "type": "bool" - }, - { - "name": "local_domain", - "type": "u32" - }, - { - "name": "version", - "type": "u32" - }, - { - "name": "signature_threshold", - "type": "u32" - }, - { - "name": "enabled_attesters", - "type": { - "vec": "pubkey" - } - }, - { - "name": "max_message_body_size", - "type": "u64" - }, - { - "name": "next_available_nonce", - "type": "u64" - } - ] - } - }, - { - "name": "UsedNonces", - "docs": [ - "UsedNonces account holds an array of bits that indicate which nonces were already used", - "so they can't be resused to receive new messages. Array starts with the first_nonce and", - "holds flags for UsedNonces::MAX_NONCES. Nonces are recorded separately for each remote_domain." - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "first_nonce", - "type": "u64" - }, - { - "name": "used_nonces", - "type": { - "array": [ - "u64", - 100 - ] - } - } - ] - } - }, - { - "name": "OwnershipTransferStarted", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previous_owner", - "type": "pubkey" - }, - { - "name": "new_owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "OwnershipTransferred", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previous_owner", - "type": "pubkey" - }, - { - "name": "new_owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "PauserChanged", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_address", - "type": "pubkey" - } - ] - } - }, - { - "name": "AttesterManagerUpdated", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previous_attester_manager", - "type": "pubkey" - }, - { - "name": "new_attester_manager", - "type": "pubkey" - } - ] - } - }, - { - "name": "MessageReceived", - "type": { - "kind": "struct", - "fields": [ - { - "name": "caller", - "type": "pubkey" - }, - { - "name": "source_domain", - "type": "u32" - }, - { - "name": "nonce", - "type": "u64" - }, - { - "name": "sender", - "type": "pubkey" - }, - { - "name": "message_body", - "type": "bytes" - } - ] - } - }, - { - "name": "SignatureThresholdUpdated", - "type": { - "kind": "struct", - "fields": [ - { - "name": "old_signature_threshold", - "type": "u32" - }, - { - "name": "new_signature_threshold", - "type": "u32" - } - ] - } - }, - { - "name": "AttesterEnabled", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "AttesterDisabled", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "MaxMessageBodySizeUpdated", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_max_message_body_size", - "type": "u64" - } - ] - } - }, - { - "name": "Pause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "Unpause", - "type": { - "kind": "struct", - "fields": [] - } - } - ] -} \ No newline at end of file diff --git a/src/svm/assets/idl/message_transmitter_v2.json b/src/svm/assets/idl/message_transmitter_v2.json deleted file mode 100644 index 722d98d77..000000000 --- a/src/svm/assets/idl/message_transmitter_v2.json +++ /dev/null @@ -1,1863 +0,0 @@ -{ - "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC", - "metadata": { - "name": "message_transmitter_v2", - "version": "0.2.0", - "spec": "0.1.0", - "description": "Message Transmitter for Cross-Chain Transfer Protocol V2", - "repository": "https://github.com/circlefin/solana-cctp-contracts" - }, - "instructions": [ - { - "name": "accept_ownership", - "discriminator": [ - 172, - 23, - 43, - 13, - 238, - 213, - 85, - 150 - ], - "accounts": [ - { - "name": "pending_owner", - "signer": true, - "relations": [ - "message_transmitter" - ] - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "AcceptOwnershipParams" - } - } - } - ] - }, - { - "name": "disable_attester", - "discriminator": [ - 61, - 171, - 131, - 95, - 172, - 15, - 227, - 229 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "attester_manager", - "signer": true, - "relations": [ - "message_transmitter" - ] - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "DisableAttesterParams" - } - } - } - ] - }, - { - "name": "enable_attester", - "discriminator": [ - 2, - 11, - 193, - 115, - 5, - 148, - 4, - 198 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "attester_manager", - "signer": true, - "relations": [ - "message_transmitter" - ] - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "EnableAttesterParams" - } - } - } - ] - }, - { - "name": "initialize", - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "upgrade_authority", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 115, - 115, - 97, - 103, - 101, - 95, - 116, - 114, - 97, - 110, - 115, - 109, - 105, - 116, - 116, - 101, - 114 - ] - } - ] - } - }, - { - "name": "message_transmitter_program_data" - }, - { - "name": "message_transmitter_program", - "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "InitializeParams" - } - } - } - ] - }, - { - "name": "is_nonce_used", - "discriminator": [ - 144, - 72, - 107, - 148, - 35, - 218, - 31, - 187 - ], - "accounts": [ - { - "name": "used_nonce", - "docs": [ - "Account will be explicitly loaded to avoid error when it's not initialized" - ] - } - ], - "args": [], - "returns": "bool" - }, - { - "name": "pause", - "discriminator": [ - 211, - 22, - 221, - 251, - 74, - 121, - 193, - 47 - ], - "accounts": [ - { - "name": "pauser", - "signer": true, - "relations": [ - "message_transmitter" - ] - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "PauseParams" - } - } - } - ] - }, - { - "name": "receive_message", - "discriminator": [ - 38, - 144, - 127, - 225, - 31, - 225, - 238, - 25 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "caller", - "signer": true - }, - { - "name": "authority_pda", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 115, - 115, - 97, - 103, - 101, - 95, - 116, - 114, - 97, - 110, - 115, - 109, - 105, - 116, - 116, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "receiver" - } - ] - } - }, - { - "name": "message_transmitter" - }, - { - "name": "used_nonce", - "docs": [ - "Each nonce is stored in a separate PDA" - ], - "writable": true - }, - { - "name": "receiver" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "ReceiveMessageParams" - } - } - } - ] - }, - { - "name": "reclaim_event_account", - "discriminator": [ - 94, - 198, - 180, - 159, - 131, - 236, - 15, - 174 - ], - "accounts": [ - { - "name": "payee", - "docs": [ - "rent SOL receiver, should match original rent payer" - ], - "writable": true, - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "message_sent_event_data", - "writable": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "ReclaimEventAccountParams" - } - } - } - ] - }, - { - "name": "send_message", - "discriminator": [ - 57, - 40, - 34, - 178, - 189, - 10, - 65, - 26 - ], - "accounts": [ - { - "name": "event_rent_payer", - "writable": true, - "signer": true - }, - { - "name": "sender_authority_pda", - "signer": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "message_sent_event_data", - "writable": true, - "signer": true - }, - { - "name": "sender_program" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SendMessageParams" - } - } - } - ] - }, - { - "name": "set_max_message_body_size", - "discriminator": [ - 168, - 178, - 8, - 117, - 217, - 167, - 219, - 31 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "message_transmitter" - ] - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetMaxMessageBodySizeParams" - } - } - } - ] - }, - { - "name": "set_signature_threshold", - "discriminator": [ - 163, - 19, - 154, - 168, - 82, - 209, - 214, - 219 - ], - "accounts": [ - { - "name": "attester_manager", - "signer": true, - "relations": [ - "message_transmitter" - ] - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetSignatureThresholdParams" - } - } - } - ] - }, - { - "name": "transfer_ownership", - "discriminator": [ - 65, - 177, - 215, - 73, - 53, - 45, - 99, - 47 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "message_transmitter" - ] - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "TransferOwnershipParams" - } - } - } - ] - }, - { - "name": "unpause", - "discriminator": [ - 169, - 144, - 4, - 38, - 10, - 141, - 188, - 255 - ], - "accounts": [ - { - "name": "pauser", - "signer": true, - "relations": [ - "message_transmitter" - ] - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UnpauseParams" - } - } - } - ] - }, - { - "name": "update_attester_manager", - "discriminator": [ - 175, - 245, - 178, - 104, - 85, - 179, - 71, - 16 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "message_transmitter" - ] - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UpdateAttesterManagerParams" - } - } - } - ] - }, - { - "name": "update_pauser", - "discriminator": [ - 140, - 171, - 211, - 132, - 57, - 201, - 16, - 254 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "message_transmitter" - ] - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UpdatePauserParams" - } - } - } - ] - } - ], - "accounts": [ - { - "name": "MessageSent", - "discriminator": [ - 131, - 100, - 133, - 56, - 166, - 225, - 151, - 60 - ] - }, - { - "name": "MessageTransmitter", - "discriminator": [ - 71, - 40, - 180, - 142, - 19, - 203, - 35, - 252 - ] - }, - { - "name": "UsedNonce", - "discriminator": [ - 212, - 222, - 157, - 252, - 130, - 71, - 179, - 238 - ] - } - ], - "events": [ - { - "name": "AttesterDisabled", - "discriminator": [ - 186, - 136, - 186, - 14, - 229, - 2, - 121, - 211 - ] - }, - { - "name": "AttesterEnabled", - "discriminator": [ - 88, - 57, - 14, - 133, - 5, - 219, - 62, - 190 - ] - }, - { - "name": "AttesterManagerUpdated", - "discriminator": [ - 5, - 97, - 191, - 108, - 44, - 189, - 69, - 88 - ] - }, - { - "name": "MaxMessageBodySizeUpdated", - "discriminator": [ - 134, - 206, - 151, - 111, - 137, - 11, - 160, - 225 - ] - }, - { - "name": "MessageReceived", - "discriminator": [ - 231, - 68, - 47, - 77, - 173, - 241, - 157, - 166 - ] - }, - { - "name": "OwnershipTransferStarted", - "discriminator": [ - 183, - 253, - 239, - 246, - 140, - 179, - 133, - 105 - ] - }, - { - "name": "OwnershipTransferred", - "discriminator": [ - 172, - 61, - 205, - 183, - 250, - 50, - 38, - 98 - ] - }, - { - "name": "Pause", - "discriminator": [ - 194, - 251, - 232, - 196, - 118, - 95, - 111, - 219 - ] - }, - { - "name": "PauserChanged", - "discriminator": [ - 142, - 157, - 158, - 87, - 127, - 8, - 119, - 55 - ] - }, - { - "name": "SignatureThresholdUpdated", - "discriminator": [ - 156, - 99, - 103, - 200, - 15, - 38, - 122, - 189 - ] - }, - { - "name": "Unpause", - "discriminator": [ - 241, - 149, - 104, - 90, - 199, - 136, - 219, - 146 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "InvalidAuthority", - "msg": "Invalid authority" - }, - { - "code": 6001, - "name": "ProgramPaused", - "msg": "Instruction is not allowed at this time" - }, - { - "code": 6002, - "name": "InvalidMessageTransmitterState", - "msg": "Invalid message transmitter state" - }, - { - "code": 6003, - "name": "InvalidSignatureThreshold", - "msg": "Invalid signature threshold" - }, - { - "code": 6004, - "name": "SignatureThresholdAlreadySet", - "msg": "Signature threshold already set" - }, - { - "code": 6005, - "name": "InvalidOwner", - "msg": "Invalid owner" - }, - { - "code": 6006, - "name": "InvalidPauser", - "msg": "Invalid pauser" - }, - { - "code": 6007, - "name": "InvalidAttesterManager", - "msg": "Invalid attester manager" - }, - { - "code": 6008, - "name": "InvalidAttester", - "msg": "Invalid attester" - }, - { - "code": 6009, - "name": "AttesterAlreadyEnabled", - "msg": "Attester already enabled" - }, - { - "code": 6010, - "name": "TooFewEnabledAttesters", - "msg": "Too few enabled attesters" - }, - { - "code": 6011, - "name": "SignatureThresholdTooLow", - "msg": "Signature threshold is too low" - }, - { - "code": 6012, - "name": "AttesterAlreadyDisabled", - "msg": "Attester already disabled" - }, - { - "code": 6013, - "name": "MessageBodyLimitExceeded", - "msg": "Message body exceeds max size" - }, - { - "code": 6014, - "name": "InvalidDestinationCaller", - "msg": "Invalid destination caller" - }, - { - "code": 6015, - "name": "InvalidRecipient", - "msg": "Invalid message recipient" - }, - { - "code": 6016, - "name": "SenderNotPermitted", - "msg": "Sender is not permitted" - }, - { - "code": 6017, - "name": "InvalidSourceDomain", - "msg": "Invalid source domain" - }, - { - "code": 6018, - "name": "InvalidDestinationDomain", - "msg": "Invalid destination domain" - }, - { - "code": 6019, - "name": "InvalidMessageVersion", - "msg": "Invalid message version" - }, - { - "code": 6020, - "name": "InvalidUsedNoncesAccount", - "msg": "Invalid used nonces account" - }, - { - "code": 6021, - "name": "InvalidRecipientProgram", - "msg": "Invalid recipient program" - }, - { - "code": 6022, - "name": "InvalidNonce", - "msg": "Invalid nonce" - }, - { - "code": 6023, - "name": "NonceAlreadyUsed", - "msg": "Nonce already used" - }, - { - "code": 6024, - "name": "MessageTooShort", - "msg": "Message is too short" - }, - { - "code": 6025, - "name": "MalformedMessage", - "msg": "Malformed message" - }, - { - "code": 6026, - "name": "InvalidSignatureOrderOrDupe", - "msg": "Invalid signature order or dupe" - }, - { - "code": 6027, - "name": "InvalidAttesterSignature", - "msg": "Invalid attester signature" - }, - { - "code": 6028, - "name": "InvalidAttestationLength", - "msg": "Invalid attestation length" - }, - { - "code": 6029, - "name": "InvalidSignatureRecoveryId", - "msg": "Invalid signature recovery ID" - }, - { - "code": 6030, - "name": "InvalidSignatureSValue", - "msg": "Invalid signature S value" - }, - { - "code": 6031, - "name": "InvalidMessageHash", - "msg": "Invalid message hash" - }, - { - "code": 6032, - "name": "InvalidDestinationMessage", - "msg": "Invalid destination message" - }, - { - "code": 6033, - "name": "EventAccountWindowNotExpired", - "msg": "Event account window not expired" - }, - { - "code": 6034, - "name": "DestinationDomainIsLocalDomain", - "msg": "Destination domain is local domain" - } - ], - "types": [ - { - "name": "AcceptOwnershipParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "AttesterDisabled", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "AttesterEnabled", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "AttesterManagerUpdated", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previous_attester_manager", - "type": "pubkey" - }, - { - "name": "new_attester_manager", - "type": "pubkey" - } - ] - } - }, - { - "name": "DisableAttesterParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "EnableAttesterParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "InitializeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "local_domain", - "type": "u32" - }, - { - "name": "attester", - "type": "pubkey" - }, - { - "name": "max_message_body_size", - "type": "u64" - }, - { - "name": "version", - "type": "u32" - } - ] - } - }, - { - "name": "MaxMessageBodySizeUpdated", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_max_message_body_size", - "type": "u64" - } - ] - } - }, - { - "name": "MessageReceived", - "type": { - "kind": "struct", - "fields": [ - { - "name": "caller", - "type": "pubkey" - }, - { - "name": "source_domain", - "type": "u32" - }, - { - "name": "nonce", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "sender", - "type": "pubkey" - }, - { - "name": "finality_threshold_executed", - "type": "u32" - }, - { - "name": "message_body", - "type": "bytes" - } - ] - } - }, - { - "name": "MessageSent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rent_payer", - "type": "pubkey" - }, - { - "name": "created_at", - "type": "i64" - }, - { - "name": "message", - "type": "bytes" - } - ] - } - }, - { - "name": "MessageTransmitter", - "docs": [ - "Main state of the MessageTransmitter program" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "pending_owner", - "type": "pubkey" - }, - { - "name": "attester_manager", - "type": "pubkey" - }, - { - "name": "pauser", - "type": "pubkey" - }, - { - "name": "paused", - "type": "bool" - }, - { - "name": "local_domain", - "type": "u32" - }, - { - "name": "version", - "type": "u32" - }, - { - "name": "signature_threshold", - "type": "u32" - }, - { - "name": "enabled_attesters", - "type": { - "vec": "pubkey" - } - }, - { - "name": "max_message_body_size", - "type": "u64" - } - ] - } - }, - { - "name": "OwnershipTransferStarted", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previous_owner", - "type": "pubkey" - }, - { - "name": "new_owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "OwnershipTransferred", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previous_owner", - "type": "pubkey" - }, - { - "name": "new_owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "Pause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "PauseParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "PauserChanged", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_address", - "type": "pubkey" - } - ] - } - }, - { - "name": "ReceiveMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "message", - "type": "bytes" - }, - { - "name": "attestation", - "type": "bytes" - } - ] - } - }, - { - "name": "ReclaimEventAccountParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attestation", - "type": "bytes" - }, - { - "name": "destination_message", - "type": "bytes" - } - ] - } - }, - { - "name": "SendMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "destination_domain", - "type": "u32" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "destination_caller", - "type": "pubkey" - }, - { - "name": "min_finality_threshold", - "type": "u32" - }, - { - "name": "message_body", - "type": "bytes" - } - ] - } - }, - { - "name": "SetMaxMessageBodySizeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_max_message_body_size", - "type": "u64" - } - ] - } - }, - { - "name": "SetSignatureThresholdParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_signature_threshold", - "type": "u32" - } - ] - } - }, - { - "name": "SignatureThresholdUpdated", - "type": { - "kind": "struct", - "fields": [ - { - "name": "old_signature_threshold", - "type": "u32" - }, - { - "name": "new_signature_threshold", - "type": "u32" - } - ] - } - }, - { - "name": "TransferOwnershipParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "Unpause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "UnpauseParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "UpdateAttesterManagerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_attester_manager", - "type": "pubkey" - } - ] - } - }, - { - "name": "UpdatePauserParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_pauser", - "type": "pubkey" - } - ] - } - }, - { - "name": "UsedNonce", - "type": { - "kind": "struct", - "fields": [ - { - "name": "is_used", - "type": "bool" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/src/svm/assets/idl/multicall_handler.json b/src/svm/assets/idl/multicall_handler.json deleted file mode 100644 index 22813ecf4..000000000 --- a/src/svm/assets/idl/multicall_handler.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "address": "HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be", - "metadata": { - "name": "multicall_handler", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "handle_v3_across_message", - "discriminator": [ - 131, - 141, - 52, - 71, - 16, - 59, - 196, - 92 - ], - "accounts": [], - "args": [ - { - "name": "message", - "type": "bytes" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/svm/assets/idl/sponsored_cctp_src_periphery.json b/src/svm/assets/idl/sponsored_cctp_src_periphery.json deleted file mode 100644 index 8de96f91a..000000000 --- a/src/svm/assets/idl/sponsored_cctp_src_periphery.json +++ /dev/null @@ -1,1965 +0,0 @@ -{ - "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq", - "metadata": { - "name": "sponsored_cctp_src_periphery", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "docs": [ - "# Across Sponsored CCTP Source Periphery", - "", - "Source chain periphery program for users to interact with to start a sponsored or a non-sponsored flow that allows", - "custom Across-supported flows on destination chain. Uses Circle's CCTPv2 as an underlying bridge" - ], - "instructions": [ - { - "name": "deposit_for_burn", - "docs": [ - "Verifies a sponsored CCTP quote, records its nonce, and burns the user's tokens via CCTPv2 with hook data.", - "", - "The user's depositor ATA is burned via `deposit_for_burn_with_hook` CPI on the CCTPv2. The rent cost for the", - "per-quote `used_nonce` PDA is refunded to the signer from the `rent_fund` and `rent_fund` also funds the", - "creation of CCTP `MessageSent` event account.", - "On success, this emits a `SponsoredDepositForBurn` event to be consumed by offchain infrastructure. This also", - "emits a `CreatedEventAccount` event containing the address of the created CCTP `MessageSent` event account that", - "can be reclaimed later using the `reclaim_event_account` instruction.", - "", - "Required Accounts:", - "- signer (Signer, Writable): The user authorizing the burn.", - "- state (Account): Program state PDA. Seed: [\"state\"].", - "- rent_fund (SystemAccount, Writable): PDA used to sponsor rent and event accounts. Seed: [\"rent_fund\"].", - "- minimum_deposit (Account): Minimum deposit state PDA. Seed: [\"minimum_deposit\", burn_token.key()].", - "- used_nonce (Account, Writable, Init): Per-quote nonce PDA. Seed: [\"used_nonce\", nonce].", - "- rent_claim (Optional Account, Writable, Init-If-Needed): Optional PDA to accrue rent_fund debt to the user.", - "Seed: [\"rent_claim\", signer.key()].", - "- depositor_token_account (InterfaceAccount, Writable): Signer ATA of the burn token.", - "- burn_token (InterfaceAccount, Mutable): Mint of the token to burn. Must match quote.burn_token.", - "- denylist_account (Unchecked): CCTP denylist PDA, validated within CCTP.", - "- token_messenger_minter_sender_authority (Unchecked): CCTP sender authority PDA.", - "- message_transmitter (Unchecked, Mutable): CCTP MessageTransmitter account.", - "- token_messenger (Unchecked): CCTP TokenMessenger account.", - "- remote_token_messenger (Unchecked): Remote TokenMessenger account for destination domain.", - "- token_minter (Unchecked): CCTP TokenMinter account.", - "- local_token (Unchecked, Mutable): Local token account (CCTP).", - "- cctp_event_authority (Unchecked): CCTP event authority account.", - "- message_sent_event_data (Signer, Mutable): Fresh account to store CCTP MessageSent event data.", - "- message_transmitter_program (Program): CCTPv2 MessageTransmitter program.", - "- token_messenger_minter_program (Program): CCTPv2 TokenMessengerMinter program.", - "- token_program (Interface): SPL token program.", - "- system_program (Program): System program.", - "", - "Parameters:", - "- quote: SponsoredCCTPQuote struct serialized by Anchor:", - "- source_domain: CCTP domain ID of the source chain.", - "- destination_domain: CCTP domain ID of the destination chain.", - "- mint_recipient: The recipient of the minted tokens on the destination chain.", - "- amount: The amount of tokens that the user pays on the source chain.", - "- burn_token: The token that will be burned on the source chain.", - "- destination_caller: The caller of the destination chain.", - "- max_fee: Maximum fee to pay on the destination domain, specified in units of burn_token.", - "- min_finality_threshold: Minimum finality threshold before allowed to attest.", - "- nonce: Nonce is used to prevent replay attacks.", - "- deadline: Timestamp of the quote after which it can no longer be used.", - "- max_bps_to_sponsor: The maximum basis points of the amount that can be sponsored.", - "- max_user_slippage_bps: Slippage tolerance for the fees on the destination. Used in swap flow, enforced on", - "destination.", - "- final_recipient: The final recipient of the sponsored deposit. This is needed as the mint_recipient will be", - "the handler contract address instead of the final recipient.", - "- final_token: The final token that final recipient will receive. This is needed as it can be different from", - "the burn_token in which case we perform a swap on the destination chain.", - "- execution_mode: Execution mode: DirectToCore (0), ArbitraryActionsToCore (1), or ArbitraryActionsToEVM (2).", - "- action_data: Encoded action data for arbitrary execution. Empty for DirectToCore mode.", - "- signature: 65-byte EVM signature authorizing the quote by the trusted signer.", - "", - "Notes:", - "- The upgrade authority must have set the valid EVM signer for this instruction to succeed.", - "- The operator of this program must have funded the `rent_fund` PDA with sufficient lamports to cover", - "rent for the `used_nonce` PDA and the CCTP `MessageSent` event account." - ], - "discriminator": [ - 215, - 60, - 61, - 46, - 114, - 55, - 128, - 176 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "rent_fund", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 102, - 117, - 110, - 100 - ] - } - ] - } - }, - { - "name": "minimum_deposit", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 105, - 110, - 105, - 109, - 117, - 109, - 95, - 100, - 101, - 112, - 111, - 115, - 105, - 116 - ] - }, - { - "kind": "account", - "path": "burn_token" - } - ] - } - }, - { - "name": "used_nonce", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 100, - 95, - 110, - 111, - 110, - 99, - 101 - ] - }, - { - "kind": "arg", - "path": "params.quote.nonce" - } - ] - } - }, - { - "name": "rent_claim", - "writable": true, - "optional": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 99, - 108, - 97, - 105, - 109 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "depositor_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "signer" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "burn_token" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "burn_token", - "writable": true - }, - { - "name": "denylist_account" - }, - { - "name": "token_messenger_minter_sender_authority" - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "token_messenger" - }, - { - "name": "remote_token_messenger" - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true - }, - { - "name": "cctp_event_authority" - }, - { - "name": "message_sent_event_data", - "writable": true, - "signer": true - }, - { - "name": "message_transmitter_program", - "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" - }, - { - "name": "token_messenger_minter_program", - "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" - }, - { - "name": "token_program" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "DepositForBurnParams" - } - } - } - ] - }, - { - "name": "get_used_nonce_close_info", - "docs": [ - "Returns whether a `used_nonce` PDA can be closed now and the timestamp after which it can be closed.", - "", - "This is a convenience \"view\" helper for off-chain systems to determine when rent can be reclaimed for a", - "specific quote nonce.", - "", - "Required Accounts:", - "- state (Account): Program state PDA. Seed: [\"state\"].", - "- used_nonce (Account): The `used_nonce` PDA. Seed: [\"used_nonce\", nonce].", - "", - "Parameters:", - "- _params.nonce: The 32-byte nonce identifying the PDA to check.", - "", - "Returns:", - "- UsedNonceCloseInfo { can_close_after, can_close_now }" - ], - "discriminator": [ - 19, - 183, - 42, - 151, - 118, - 234, - 57, - 92 - ], - "accounts": [ - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "used_nonce", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 100, - 95, - 110, - 111, - 110, - 99, - 101 - ] - }, - { - "kind": "arg", - "path": "_params.nonce" - } - ] - } - } - ], - "args": [ - { - "name": "_params", - "type": { - "defined": { - "name": "UsedNonceAccountParams" - } - } - } - ], - "returns": { - "defined": { - "name": "UsedNonceCloseInfo" - } - } - }, - { - "name": "initialize", - "docs": [ - "Initializes immutable program state and sets the trusted EVM quote signer.", - "", - "This can only be called once by the upgrade authority. It stores the local CCTP source domain and the", - "quote `signer` that must authorize sponsored deposits.", - "", - "Required Accounts:", - "- signer (Signer, Writable): Must be the program upgrade authority.", - "- state (Writable): Program state PDA. Seed: [\"state\"].", - "- program_data (Account): Program data account to verify the upgrade authority.", - "- this_program (Program): This program account, used to resolve `programdata_address`.", - "- system_program (Program): System program for account creation.", - "", - "Parameters:", - "- source_domain: CCTP domain for this chain (e.g., 5 for Solana).", - "- signer: EVM address (encoded as `Pubkey`) authorized to sign sponsored quotes." - ], - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "program_data" - }, - { - "name": "this_program", - "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "InitializeParams" - } - } - } - ] - }, - { - "name": "reclaim_event_account", - "docs": [ - "Reclaims the CCTP `MessageSent` event account, returning rent to the rent fund.", - "", - "Required Accounts:", - "- rent_fund (SystemAccount, Writable): PDA to receive reclaimed lamports. Seed: [\"rent_fund\"].", - "- message_transmitter (Unchecked, Mutable): CCTP MessageTransmitter account.", - "- message_sent_event_data (Account, Mutable): The `MessageSent` event account created during `deposit_for_burn`.", - "- message_transmitter_program (Program): CCTPv2 MessageTransmitter program.", - "", - "Parameters:", - "- params: Parameters struct required to construct reclaim_event_account instruction on the CCTPv2.", - "- attestation: Attestation obtained from the CCTP attestation service.", - "- nonce: bytes32 from the attested destination message.", - "- finality_threshold_executed: uint32 BE encoded from the attested destination message.", - "- fee_executed: uint256 BE encoded from the attested destination message body.", - "- expiration_block: uint256 BE encoded from the attested destination message body.", - "", - "Notes:", - "- This can only be called after the CCTP attestation service has processed the message and sufficient time has", - "passed since the `MessageSent` event was created. The operator can track the closable accounts from the", - "emitted `CreatedEventAccount` events and using the `EVENT_ACCOUNT_WINDOW_SECONDS` set in CCTP program." - ], - "discriminator": [ - 94, - 198, - 180, - 159, - 131, - 236, - 15, - 174 - ], - "accounts": [ - { - "name": "rent_fund", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 102, - 117, - 110, - 100 - ] - } - ] - } - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "message_sent_event_data", - "writable": true - }, - { - "name": "message_transmitter_program", - "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "ReclaimEventAccountParams" - } - } - } - ] - }, - { - "name": "reclaim_used_nonce_account", - "docs": [ - "Closes a `used_nonce` PDA once its quote deadline has passed, returning rent to the rent fund.", - "", - "Required Accounts:", - "- state (Account): Program state PDA. Seed: [\"state\"]. Used to fetch current time.", - "- rent_fund (SystemAccount, Writable): PDA receiving lamports upon close. Seed: [\"rent_fund\"].", - "- used_nonce (Account, Writable, Close=rent_fund): PDA to close. Seed: [\"used_nonce\", nonce].", - "", - "Parameters:", - "- params.nonce: The 32-byte nonce identifying the PDA to close.", - "", - "Notes:", - "- This can only be called after the quote's deadline has passed. The operator can track closable `used_nonce`", - "accounts from the emitted `SponsoredDepositForBurn` events (`quote_nonce` and `quote_deadline`) and using the", - "`get_used_nonce_close_info` helper." - ], - "discriminator": [ - 153, - 152, - 111, - 172, - 156, - 104, - 116, - 3 - ], - "accounts": [ - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "rent_fund", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 102, - 117, - 110, - 100 - ] - } - ] - } - }, - { - "name": "used_nonce", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 100, - 95, - 110, - 111, - 110, - 99, - 101 - ] - }, - { - "kind": "arg", - "path": "params.nonce" - } - ] - } - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UsedNonceAccountParams" - } - } - } - ] - }, - { - "name": "repay_rent_fund_debt", - "docs": [ - "Repays rent_fund liability for a user if rent_fund had insufficient balance at the time of deposit.", - "", - "Required Accounts:", - "- rent_fund (SystemAccount, Writable): PDA used to sponsor rent and event accounts. Seed: [\"rent_fund\"].", - "- recipient (Unchecked, Writable): The user account to repay rent fund debt to.", - "- rent_claim (Account, Writable, Close=recipient): PDA with accrued rent_fund debt to the user.", - "Seed: [\"rent_claim\", recipient.key()].", - "- system_program (Program): System program." - ], - "discriminator": [ - 111, - 95, - 222, - 174, - 241, - 41, - 61, - 78 - ], - "accounts": [ - { - "name": "rent_fund", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 102, - 117, - 110, - 100 - ] - } - ] - } - }, - { - "name": "recipient", - "writable": true - }, - { - "name": "rent_claim", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 99, - 108, - 97, - 105, - 109 - ] - }, - { - "kind": "account", - "path": "recipient" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "set_current_time", - "docs": [ - "Sets the current time in test mode. No-op on mainnet builds.", - "", - "Required Accounts:", - "- state (Writable): Program state PDA. Seed: [\"state\"].", - "- signer (Signer): Any signer. Only enabled when built with `--features test`.", - "", - "Parameters:", - "- new_time: New unix timestamp to set for tests." - ], - "discriminator": [ - 69, - 100, - 169, - 193, - 125, - 0, - 150, - 69 - ], - "accounts": [ - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "signer", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetCurrentTimeParams" - } - } - } - ] - }, - { - "name": "set_minimum_deposit_amount", - "docs": [ - "Updates the minimum deposit amount for a given burn token.", - "", - "Only callable by the upgrade authority. This must be set at least once for a supported burn token as otherwise", - "deposits would be blocked.", - "", - "Required Accounts:", - "- signer (Signer, Writable): Must be the program upgrade authority.", - "- minimum_deposit (Writable): Minimum deposit state PDA. Seed: [\"minimum_deposit\", burn_token.key()].", - "- burn_token: Supported burn token for which the minimum deposit amount is being set.", - "- program_data (Account): Program data account to verify the upgrade authority.", - "- this_program (Program): This program account, used to resolve `programdata_address`.", - "- system_program (Program): System program for transfers.", - "", - "Parameters:", - "- amount: New minimum deposit amount for a given burn token." - ], - "discriminator": [ - 176, - 4, - 74, - 229, - 206, - 148, - 151, - 138 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "minimum_deposit", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 105, - 110, - 105, - 109, - 117, - 109, - 95, - 100, - 101, - 112, - 111, - 115, - 105, - 116 - ] - }, - { - "kind": "account", - "path": "burn_token" - } - ] - } - }, - { - "name": "burn_token" - }, - { - "name": "program_data" - }, - { - "name": "this_program", - "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetMinimumDepositAmountParams" - } - } - } - ] - }, - { - "name": "set_signer", - "docs": [ - "Updates the trusted EVM quote signer.", - "", - "Only callable by the upgrade authority. Setting this to an invalid address (including `Pubkey::default()`) will", - "effectively disable deposits.", - "", - "Required Accounts:", - "- signer (Signer, Writable): Must be the program upgrade authority.", - "- state (Writable): Program state PDA. Seed: [\"state\"].", - "- program_data (Account): Program data account to verify the upgrade authority.", - "- this_program (Program): This program account, used to resolve `programdata_address`.", - "", - "Parameters:", - "- new_signer: New EVM signer address (encoded as `Pubkey`)." - ], - "discriminator": [ - 127, - 120, - 252, - 184, - 97, - 4, - 88, - 68 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "program_data" - }, - { - "name": "this_program", - "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetSignerParams" - } - } - } - ] - }, - { - "name": "withdraw_rent_fund", - "docs": [ - "Withdraws lamports from the rent fund PDA to an arbitrary recipient.", - "", - "The rent fund is used to sponsor temporary account creation (e.g., CCTP event accounts or per-quote nonce PDAs).", - "Only callable by the upgrade authority.", - "", - "Required Accounts:", - "- signer (Signer, Writable): Must be the program upgrade authority.", - "- rent_fund (SystemAccount, Writable): PDA holding lamports used for rent sponsorship. Seed: [\"rent_fund\"].", - "- recipient (UncheckedAccount, Writable): Destination account for the withdrawn lamports.", - "- program_data (Account): Program data account to verify the upgrade authority.", - "- this_program (Program): This program account, used to resolve `programdata_address`.", - "- system_program (Program): System program for transfers.", - "", - "Parameters:", - "- amount: Amount of lamports to transfer to the recipient." - ], - "discriminator": [ - 153, - 28, - 108, - 116, - 132, - 70, - 161, - 125 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "rent_fund", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 102, - 117, - 110, - 100 - ] - } - ] - } - }, - { - "name": "recipient", - "writable": true - }, - { - "name": "program_data" - }, - { - "name": "this_program", - "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "WithdrawRentFundParams" - } - } - } - ] - } - ], - "accounts": [ - { - "name": "MessageSent", - "discriminator": [ - 131, - 100, - 133, - 56, - 166, - 225, - 151, - 60 - ] - }, - { - "name": "MinimumDeposit", - "discriminator": [ - 218, - 139, - 120, - 202, - 3, - 12, - 233, - 65 - ] - }, - { - "name": "RentClaim", - "discriminator": [ - 13, - 5, - 183, - 82, - 60, - 122, - 72, - 11 - ] - }, - { - "name": "State", - "discriminator": [ - 216, - 146, - 107, - 94, - 104, - 75, - 182, - 177 - ] - }, - { - "name": "UsedNonce", - "discriminator": [ - 212, - 222, - 157, - 252, - 130, - 71, - 179, - 238 - ] - } - ], - "events": [ - { - "name": "AccruedRentFundLiability", - "discriminator": [ - 56, - 17, - 203, - 169, - 27, - 139, - 36, - 225 - ] - }, - { - "name": "CreatedEventAccount", - "discriminator": [ - 178, - 224, - 189, - 92, - 50, - 100, - 128, - 204 - ] - }, - { - "name": "MinimumDepositAmountSet", - "discriminator": [ - 134, - 237, - 176, - 205, - 21, - 44, - 95, - 177 - ] - }, - { - "name": "ReclaimedEventAccount", - "discriminator": [ - 210, - 180, - 74, - 27, - 92, - 74, - 46, - 216 - ] - }, - { - "name": "ReclaimedUsedNonceAccount", - "discriminator": [ - 6, - 199, - 109, - 7, - 58, - 150, - 119, - 103 - ] - }, - { - "name": "RepaidRentFundDebt", - "discriminator": [ - 134, - 86, - 59, - 173, - 10, - 250, - 191, - 190 - ] - }, - { - "name": "SignerSet", - "discriminator": [ - 137, - 203, - 187, - 74, - 141, - 187, - 226, - 95 - ] - }, - { - "name": "SponsoredDepositForBurn", - "discriminator": [ - 55, - 106, - 70, - 41, - 59, - 102, - 172, - 42 - ] - }, - { - "name": "WithdrawnRentFund", - "discriminator": [ - 110, - 180, - 127, - 254, - 32, - 122, - 209, - 22 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "NotUpgradeAuthority", - "msg": "Only the upgrade authority can call this instruction" - }, - { - "code": 6001, - "name": "InvalidProgramData", - "msg": "Invalid program data account" - }, - { - "code": 6002, - "name": "CannotSetCurrentTime", - "msg": "Cannot set time if not in test mode" - }, - { - "code": 6003, - "name": "InvalidBurnToken", - "msg": "Invalid burn_token key" - }, - { - "code": 6004, - "name": "AmountNotPositive", - "msg": "Amount must be greater than 0" - }, - { - "code": 6005, - "name": "QuoteDeadlineNotPassed", - "msg": "The quote deadline has not passed!" - }, - { - "code": 6006, - "name": "SignerUnchanged", - "msg": "New signer unchanged" - }, - { - "code": 6007, - "name": "DepositAmountBelowMinimum", - "msg": "Deposit amount below minimum" - }, - { - "code": 6008, - "name": "MissingRentClaimAccount", - "msg": "Missing rent claim account" - }, - { - "code": 6009, - "name": "RentClaimOverflow", - "msg": "Rent claim amount overflow" - }, - { - "code": 6010, - "name": "InvalidRecipientKey", - "msg": "Invalid recipient key" - } - ], - "types": [ - { - "name": "AccruedRentFundLiability", - "type": { - "kind": "struct", - "fields": [ - { - "name": "user", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "total_user_claim", - "type": "u64" - } - ] - } - }, - { - "name": "CreatedEventAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "message_sent_event_data", - "type": "pubkey" - } - ] - } - }, - { - "name": "DepositForBurnParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "quote", - "type": { - "defined": { - "name": "SponsoredCCTPQuote" - } - } - }, - { - "name": "signature", - "type": { - "array": [ - "u8", - 65 - ] - } - } - ] - } - }, - { - "name": "InitializeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "source_domain", - "type": "u32" - }, - { - "name": "signer", - "type": "pubkey" - } - ] - } - }, - { - "name": "MessageSent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rent_payer", - "type": "pubkey" - }, - { - "name": "created_at", - "type": "i64" - }, - { - "name": "message", - "type": "bytes" - } - ] - } - }, - { - "name": "MinimumDeposit", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "bump", - "type": "u8" - } - ] - } - }, - { - "name": "MinimumDepositAmountSet", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "burn_token", - "type": "pubkey" - } - ] - } - }, - { - "name": "ReclaimEventAccountParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attestation", - "type": "bytes" - }, - { - "name": "nonce", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "finality_threshold_executed", - "type": { - "array": [ - "u8", - 4 - ] - } - }, - { - "name": "fee_executed", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "expiration_block", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - } - }, - { - "name": "ReclaimedEventAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "message_sent_event_data", - "type": "pubkey" - } - ] - } - }, - { - "name": "ReclaimedUsedNonceAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "nonce", - "type": "bytes" - }, - { - "name": "used_nonce", - "type": "pubkey" - } - ] - } - }, - { - "name": "RentClaim", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "RepaidRentFundDebt", - "type": { - "kind": "struct", - "fields": [ - { - "name": "user", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "remaining_user_claim", - "type": "u64" - } - ] - } - }, - { - "name": "SetCurrentTimeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_time", - "type": "u64" - } - ] - } - }, - { - "name": "SetMinimumDepositAmountParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "SetSignerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_signer", - "type": "pubkey" - } - ] - } - }, - { - "name": "SignerSet", - "type": { - "kind": "struct", - "fields": [ - { - "name": "old_signer", - "type": "pubkey" - }, - { - "name": "new_signer", - "type": "pubkey" - } - ] - } - }, - { - "name": "SponsoredCCTPQuote", - "type": { - "kind": "struct", - "fields": [ - { - "name": "source_domain", - "type": "u32" - }, - { - "name": "destination_domain", - "type": "u32" - }, - { - "name": "mint_recipient", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "burn_token", - "type": "pubkey" - }, - { - "name": "destination_caller", - "type": "pubkey" - }, - { - "name": "max_fee", - "type": "u64" - }, - { - "name": "min_finality_threshold", - "type": "u32" - }, - { - "name": "nonce", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "deadline", - "type": "u64" - }, - { - "name": "max_bps_to_sponsor", - "type": "u64" - }, - { - "name": "max_user_slippage_bps", - "type": "u64" - }, - { - "name": "final_recipient", - "type": "pubkey" - }, - { - "name": "final_token", - "type": "pubkey" - }, - { - "name": "destination_dex", - "type": "u32" - }, - { - "name": "account_creation_mode", - "type": "u8" - }, - { - "name": "execution_mode", - "type": "u8" - }, - { - "name": "action_data", - "type": "bytes" - } - ] - } - }, - { - "name": "SponsoredDepositForBurn", - "type": { - "kind": "struct", - "fields": [ - { - "name": "quote_nonce", - "type": "bytes" - }, - { - "name": "origin_sender", - "type": "pubkey" - }, - { - "name": "final_recipient", - "type": "pubkey" - }, - { - "name": "quote_deadline", - "type": "u64" - }, - { - "name": "max_bps_to_sponsor", - "type": "u64" - }, - { - "name": "max_user_slippage_bps", - "type": "u64" - }, - { - "name": "final_token", - "type": "pubkey" - }, - { - "name": "destination_dex", - "type": "u32" - }, - { - "name": "account_creation_mode", - "type": "u8" - }, - { - "name": "signature", - "type": "bytes" - } - ] - } - }, - { - "name": "State", - "type": { - "kind": "struct", - "fields": [ - { - "name": "source_domain", - "type": "u32" - }, - { - "name": "signer", - "type": "pubkey" - }, - { - "name": "bump", - "type": "u8" - } - ] - } - }, - { - "name": "UsedNonce", - "type": { - "kind": "struct", - "fields": [ - { - "name": "quote_deadline", - "type": "u64" - } - ] - } - }, - { - "name": "UsedNonceAccountParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "nonce", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - } - }, - { - "name": "UsedNonceCloseInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "can_close_after", - "type": "u64" - }, - { - "name": "can_close_now", - "type": "bool" - } - ] - } - }, - { - "name": "WithdrawRentFundParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "WithdrawnRentFund", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "recipient", - "type": "pubkey" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/src/svm/assets/idl/svm_spoke.json b/src/svm/assets/idl/svm_spoke.json deleted file mode 100644 index 7a667114e..000000000 --- a/src/svm/assets/idl/svm_spoke.json +++ /dev/null @@ -1,5496 +0,0 @@ -{ - "address": "DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru", - "metadata": { - "name": "svm_spoke", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "bridge_tokens_to_hub_pool", - "docs": [ - "Bridges tokens to the Hub Pool.", - "", - "This function initiates the process of sending tokens from the vault to the Hub Pool based on the outstanding", - "token liability this Spoke Pool has accrued. Enables the caller to choose a custom amount to work around CCTP", - "bridging limits. enforces that amount is less than or equal to liability. On execution decrements liability.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the bridge operation.", - "- payer (Signer): The account responsible for paying the transaction fees.", - "- mint (InterfaceAccount): The mint account for the token being bridged.", - "- state (Account): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- transfer_liability (Account): Account tracking the pending amount to be sent to the Hub Pool. Incremented on", - "relayRootBundle() and decremented on when this function is called. Seed: [\"transfer_liability\",mint].", - "- vault (InterfaceAccount): The ATA for the token being bridged. Authority must be the state.", - "- token_messenger_minter_sender_authority (UncheckedAccount): Authority for the token messenger minter.", - "- message_transmitter (UncheckedAccount): Account for the message transmitter.", - "- token_messenger (UncheckedAccount): Account for the token messenger.", - "- remote_token_messenger (UncheckedAccount): Account for the remote token messenger.", - "- token_minter (UncheckedAccount): Account for the token minter.", - "- local_token (UncheckedAccount): Account for the local token.", - "- cctp_event_authority (UncheckedAccount): Authority for CCTP events.", - "- message_sent_event_data (Signer): Account for message sent event data.", - "- message_transmitter_program (Program): Program for the message transmitter.", - "- token_messenger_minter_program (Program): Program for the token messenger minter.", - "- token_program (Interface): The token program.", - "- system_program (Program): The system program.", - "", - "### Parameters:", - "- amount: The amount of tokens to bridge to the Hub Pool." - ], - "discriminator": [ - 1, - 83, - 255, - 59, - 232, - 55, - 64, - 216 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "mint", - "writable": true - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "transfer_liability", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 114, - 97, - 110, - 115, - 102, - 101, - 114, - 95, - 108, - 105, - 97, - 98, - 105, - 108, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "token_messenger_minter_sender_authority" - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "token_messenger" - }, - { - "name": "remote_token_messenger" - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true - }, - { - "name": "cctp_event_authority" - }, - { - "name": "message_sent_event_data", - "writable": true, - "signer": true - }, - { - "name": "message_transmitter_program", - "address": "CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd" - }, - { - "name": "token_messenger_minter_program", - "address": "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3" - }, - { - "name": "token_program" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "claim_relayer_refund", - "docs": [ - "Claims a relayer refund for the caller.", - "", - "In the event a relayer refund was sent to a claim account, then this function enables the relayer to claim it by", - "transferring the claim amount from the vault to their token account. The claim account is closed after refund.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the claim.", - "- initializer (UncheckedAccount): Must be the same account that initialized the claim account.", - "- state (Account): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- vault (InterfaceAccount): The ATA for the refunded mint. Authority must be the state.", - "- mint (InterfaceAccount): The mint account for the token being refunded.", - "- refund_address: token account authority receiving the refund.", - "- token_account (InterfaceAccount): The receiving token account for the refund. When refund_address is different", - "from the signer, this must match its ATA.", - "- claim_account (Account): The claim account PDA. Seed: [\"claim_account\",mint,refund_address].", - "- token_program (Interface): The token program." - ], - "discriminator": [ - 205, - 34, - 34, - 224, - 204, - 103, - 81, - 176 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "initializer", - "writable": true - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "mint" - }, - { - "name": "refund_address" - }, - { - "name": "token_account", - "writable": true - }, - { - "name": "claim_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 108, - 97, - 105, - 109, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - }, - { - "kind": "account", - "path": "refund_address" - } - ] - } - }, - { - "name": "token_program" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "close_claim_account", - "docs": [ - "Closes a claim account for a relayer refund.", - "", - "This function is used to close the claim account associated with a specific mint and refund address,", - "effectively marking the end of its lifecycle. It can only be called once the claim account is empty. It", - "transfers any remaining lamports to the signer and resets the account.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the closure. Must be the initializer of the claim account.", - "- mint: The mint associated with the claim account.", - "- refund_address: The refund address associated with the claim account.", - "- claim_account (Writable): The claim account PDA to be closed. Seed: [\"claim_account\",mint,refund_address]." - ], - "discriminator": [ - 241, - 146, - 203, - 216, - 58, - 222, - 91, - 118 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "mint" - }, - { - "name": "refund_address" - }, - { - "name": "claim_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 108, - 97, - 105, - 109, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - }, - { - "kind": "account", - "path": "refund_address" - } - ] - } - } - ], - "args": [] - }, - { - "name": "close_fill_pda", - "docs": [ - "Closes the FillStatusAccount PDA to reclaim relayer rent.", - "", - "This function is used to close the FillStatusAccount associated with a specific relay hash, effectively marking", - "the end of its lifecycle. This can only be done once the fill deadline has passed. Relayers should do this for", - "all fills once they expire to reclaim their rent.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the closure. Must be the relayer in the fill_status PDA.", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- fill_status (Writable): The FillStatusAccount PDA to be closed." - ], - "discriminator": [ - 224, - 39, - 208, - 68, - 8, - 226, - 23, - 214 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "fill_status", - "writable": true - } - ], - "args": [] - }, - { - "name": "close_instruction_params", - "docs": [ - "Closes the instruction parameters account.", - "", - "This function is used to close the instruction parameters account, effectively marking the end of its lifecycle.", - "It transfers any remaining lamports to the signer and resets the account.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the closure.", - "- instruction_params (UncheckedAccount): The account to be closed. seed: [\"instruction_params\",signer]. Not", - "the signer being within the seed here implicitly protects this from only being called by the creator." - ], - "discriminator": [ - 224, - 44, - 254, - 10, - 216, - 8, - 172, - 96 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "instruction_params", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - } - ], - "args": [] - }, - { - "name": "create_token_accounts", - "docs": [ - "Creates token accounts in batch for a set of addresses.", - "", - "This helper function allows the caller to pass in a set of remaining accounts to create a batch of Associated", - "Token Accounts (ATAs) for addresses. It is particularly useful for relayers to call before filling a deposit.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the creation of token accounts.", - "- mint (InterfaceAccount): The mint account for the token.", - "- token_program (Interface): The token program.", - "- associated_token_program (Program): The associated token program.", - "- system_program (Program): The system program required for account creation." - ], - "discriminator": [ - 163, - 216, - 49, - 204, - 97, - 16, - 80, - 167 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "mint" - }, - { - "name": "token_program" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "deposit", - "docs": [ - "Request to bridge input_token to a target chain and receive output_token.", - "", - "The fee paid to relayers and the system is captured in the spread between the input and output amounts,", - "denominated in the input token. A relayer on the destination chain will send `output_amount` of `output_token`", - "to the recipient and receive `input_token` on a repayment chain of their choice. The fee accounts for:", - "destination transaction costs, relayer's opportunity cost of capital while waiting for a refund during the", - "optimistic challenge window in the HubPool, and the system fee charged to the relayer.", - "", - "On the destination chain, a unique hash of the deposit data is used to identify this deposit. Modifying any", - "parameters will result in a different hash, creating a separate deposit. The hash is computed using all parameters", - "of this function along with the chain's `chainId()`. Relayers are refunded only for deposits with hashes that", - "exactly match those emitted by this contract.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the deposit.", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- depositor_token_account (Writable): The depositor's ATA for the input token.", - "- vault (Writable): Programs ATA for the associated input token. This is where the depositor's assets are sent.", - "Authority must be the state.", - "- mint (Account): The mint account for the input token.", - "- token_program (Interface): The token program.", - "- delegate (Account): The account used to delegate the input amount of the input token.", - "", - "### Parameters", - "- depositor: The account credited with the deposit. Can be different from the signer.", - "- recipient: The account receiving funds on the destination chain. Depending on the output chain can be an ETH", - "address or a contract address or any other address type encoded as a bytes32 field.", - "- input_token: The token pulled from the caller's account and locked into this program's vault on deposit.", - "- output_token: The token that the relayer will send to the recipient on the destination chain.", - "- input_amount: The amount of input tokens to pull from the caller's account and lock into the vault. This", - "amount will be sent to the relayer on their repayment chain of choice as a refund following an optimistic", - "challenge window in the HubPool, less a system fee.", - "- output_amount: The amount of output tokens that the relayer will send to the recipient on the destination.", - "This is big-endian encoded as a 32-byte array to match its underlying byte representation on EVM side.", - "- destination_chain_id: The destination chain identifier where the fill should be made.", - "- exclusive_relayer: The relayer that will be exclusively allowed to fill this deposit before the exclusivity", - "deadline timestamp. This must be a valid, non-zero address if the exclusivity deadline is greater than the", - "current block timestamp.", - "- quote_timestamp: The HubPool timestamp that is used to determine the system fee paid by the depositor. This", - "must be set to some time between [currentTime - depositQuoteTimeBuffer, currentTime].", - "- fill_deadline: The deadline for the relayer to fill the deposit. After this destination chain timestamp, the", - "fill will revert on the destination chain. Must be set before currentTime + fillDeadlineBuffer.", - "- exclusivity_parameter: Sets the exclusivity deadline timestamp for the exclusiveRelayer to fill the deposit.", - "1. If 0, no exclusivity period.", - "2. If less than MAX_EXCLUSIVITY_PERIOD_SECONDS, adds this value to the current block timestamp.", - "3. Otherwise, uses this value as the exclusivity deadline timestamp.", - "- message: The message to send to the recipient on the destination chain if the recipient is a contract.", - "If not empty, the recipient contract must implement handleV3AcrossMessage() or the fill will revert." - ], - "discriminator": [ - 242, - 35, - 198, - 137, - 82, - 225, - 242, - 182 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "delegate" - }, - { - "name": "depositor_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "arg", - "path": "depositor" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "mint" - }, - { - "name": "token_program" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "input_token", - "type": "pubkey" - }, - { - "name": "output_token", - "type": "pubkey" - }, - { - "name": "input_amount", - "type": "u64" - }, - { - "name": "output_amount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "destination_chain_id", - "type": "u64" - }, - { - "name": "exclusive_relayer", - "type": "pubkey" - }, - { - "name": "quote_timestamp", - "type": "u32" - }, - { - "name": "fill_deadline", - "type": "u32" - }, - { - "name": "exclusivity_parameter", - "type": "u32" - }, - { - "name": "message", - "type": "bytes" - } - ] - }, - { - "name": "deposit_now", - "docs": [ - "Equivalent to deposit except quote_timestamp is set to the current time.", - "The deposit `fill_deadline` is calculated as the current time plus `fill_deadline_offset`." - ], - "discriminator": [ - 75, - 228, - 135, - 221, - 200, - 25, - 148, - 26 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "delegate" - }, - { - "name": "depositor_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "arg", - "path": "depositor" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "mint" - }, - { - "name": "token_program" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "input_token", - "type": "pubkey" - }, - { - "name": "output_token", - "type": "pubkey" - }, - { - "name": "input_amount", - "type": "u64" - }, - { - "name": "output_amount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "destination_chain_id", - "type": "u64" - }, - { - "name": "exclusive_relayer", - "type": "pubkey" - }, - { - "name": "fill_deadline_offset", - "type": "u32" - }, - { - "name": "exclusivity_parameter", - "type": "u32" - }, - { - "name": "message", - "type": "bytes" - } - ] - }, - { - "name": "emergency_delete_root_bundle", - "docs": [ - "Deletes a root bundle in case of emergencies where bad bundle has reached the Spoke. Only callable by the owner.", - "", - "This function will close the PDA for the associated `root_bundle_id`.", - "Note: Using this function does not decrement `state.root_bundle_id`.", - "", - "### Required Accounts:", - "- signer (Signer): The account that must be the owner to authorize the deletion.", - "- closer (SystemAccount): The account that will receive the lamports from closing the root_bundle account.", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- root_bundle (Writable): The root bundle PDA to be closed. Seed: [\"root_bundle\",state.seed,root_bundle_id].", - "", - "### Parameters:", - "- root_bundle_id: Index of the root bundle that needs to be deleted." - ], - "discriminator": [ - 226, - 158, - 1, - 74, - 84, - 113, - 24, - 152 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "closer", - "writable": true - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "root_bundle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 111, - 111, - 116, - 95, - 98, - 117, - 110, - 100, - 108, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - }, - { - "kind": "arg", - "path": "root_bundle_id" - } - ] - } - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "root_bundle_id", - "type": "u32" - } - ] - }, - { - "name": "execute_relayer_refund_leaf", - "docs": [ - "Executes relayer refund leaf.", - "", - "Processes a relayer refund leaf, verifying its inclusion in a previous Merkle root and that it was not", - "previously executed. Function has two modes of operation: a) transfers all relayer refunds directly to", - "relayers ATA or b) credits relayers with claimable claim_account PDA that they can use later to claim their", - "refund. In the happy path, (a) should be used. (b) should only be used if there is a relayer within the bundle", - "who can't receive the transfer for some reason, such as failed token transfers due to blacklisting. Executing", - "relayer refunds requires the caller to create a LUT and load the execution params into it. This is needed to", - "fit the data in a single instruction. The exact structure and validation of the leaf is defined in the Accross", - "UMIP: https://github.com/UMAprotocol/UMIPs/blob/master/UMIPs/umip-179.md", - "", - "instruction_params Parameters:", - "- root_bundle_id: The ID of the root bundle containing the relayer refund root.", - "- relayer_refund_leaf: The relayer refund leaf to be executed. Contents must include:", - "- amount_to_return: The amount to be to be sent back to mainnet Ethereum from this Spoke pool.", - "- chain_id: The targeted chainId for the refund. Validated against state.chain_id.", - "- refund_amounts: The amounts to be returned to the relayer for each refund_address.", - "- leaf_id: The leaf ID of the relayer refund leaf.", - "- mint_public_key: The public key of the mint (refunded token) being refunded.", - "- refund_addresses: The addresses to be refunded.", - "- proof: The Merkle proof for the relayer refund leaf.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the execution. No permission requirements.", - "- instruction_params (Account): LUT containing the execution parameters. seed: [\"instruction_params\",signer]", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- root_bundle (Writable): The root bundle PDA containing the relayer refund root, created when the root bundle", - "was initially bridged. seed: [\"root_bundle\",state.seed,root_bundle_id].", - "- vault (Writable): The ATA for refunded mint. Authority must be the state.", - "- mint (Account): The mint account for the token being refunded.", - "- transfer_liability (Writable): Account to track pending refunds to be sent to the Ethereum hub pool. Only used", - "if the amount_to_return value is non-zero within the leaf. Seed: [\"transfer_liability\",mint]", - "- token_program: The token program.", - "- system_program: The system program required for account creation.", - "", - "execute_relayer_refund_leaf executes in mode where refunds are sent to ATA directly." - ], - "discriminator": [ - 27, - 136, - 159, - 240, - 127, - 68, - 123, - 164 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "instruction_params", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "root_bundle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 111, - 111, - 116, - 95, - 98, - 117, - 110, - 100, - 108, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - }, - { - "kind": "account", - "path": "instruction_params.root_bundle_id", - "account": "ExecuteRelayerRefundLeafParams" - } - ] - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "mint" - }, - { - "name": "transfer_liability", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 114, - 97, - 110, - 115, - 102, - 101, - 114, - 95, - 108, - 105, - 97, - 98, - 105, - 108, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "token_program" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "execute_relayer_refund_leaf_deferred", - "docs": [ - "Similar to execute_relayer_refund_leaf, but executes in mode where refunds are allocated to claim_account PDAs." - ], - "discriminator": [ - 110, - 112, - 89, - 208, - 38, - 116, - 93, - 10 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "instruction_params", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "root_bundle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 111, - 111, - 116, - 95, - 98, - 117, - 110, - 100, - 108, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - }, - { - "kind": "account", - "path": "instruction_params.root_bundle_id", - "account": "ExecuteRelayerRefundLeafParams" - } - ] - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "mint" - }, - { - "name": "transfer_liability", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 114, - 97, - 110, - 115, - 102, - 101, - 114, - 95, - 108, - 105, - 97, - 98, - 105, - 108, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "token_program" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "execute_slow_relay_leaf", - "docs": [ - "Executes a slow relay leaf stored as part of a root bundle relayed by the HubPool.", - "", - "Executing a slow fill leaf is equivalent to filling the relayData, so this function cannot be used to", - "double fill a recipient. The relayData that is filled is included in the slowFillLeaf and is hashed", - "like any other fill sent through fillRelay(). There is no relayer credited with filling this relay since funds", - "are sent directly out of this program's vault.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the execution. No permission requirements.", - "- instruction_params (Account): Optional account to load instruction parameters when they are not passed in the", - "instruction data due to message size constraints. Pass this program ID to represent None. When Some, this must", - "be derived from the signer's public key with seed [\"instruction_params\",signer].", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- root_bundle (Account): Root bundle PDA with slowRelayRoot. Seed: [\"root_bundle\",state.seed,root_bundle_id].", - "- fill_status (Writable): The fill status PDA, created when slow request was made. Updated to track slow fill.", - "Used to prevent double request and fill. Seed: [\"fills\",relay_hash].", - "- mint (Account): The mint account for the output token.", - "- recipient_token_account (Writable): The recipient's ATA for the output token.", - "- vault (Writable): The ATA for refunded mint. Authority must be the state.", - "- token_program (Interface): The token program.", - "- system_program (Program): The system program.", - "", - "### Parameters:", - "- _relay_hash: The hash identifying the deposit to be filled. Used to identify the deposit to be filled.", - "- slow_fill_leaf: Contains all data necessary to uniquely verify the slow fill. This struct contains:", - "- relayData: Struct containing all the data needed to identify the original deposit to be slow filled. Same", - "as the relay_data struct in fill_relay().", - "- chainId: Chain identifier where slow fill leaf should be executed. If this doesn't match this chain's", - "chainId, then this function will revert.", - "- updatedOutputAmount: Amount to be sent to recipient out of this contract's balance. Can be set differently", - "from relayData.outputAmount to charge a different fee because this deposit was \"slow\" filled. Usually,", - "this will be set higher to reimburse the recipient for waiting for the slow fill.", - "- _root_bundle_id: Unique ID of root bundle containing slow relay root that this leaf is contained in.", - "- proof: Inclusion proof for this leaf in slow relay root in root bundle.", - "Note: slow_fill_leaf, _root_bundle_id, and proof are optional parameters. If None for any of these is passed,", - "the caller must load them via the instruction_params account.", - "Note: When verifying the slow fill leaf, the relay data is hashed using AnchorSerialize::serialize that encodes", - "output token amounts to little-endian format while input token amount preserves its big-endian encoding as it", - "is passed as [u8; 32] array." - ], - "discriminator": [ - 26, - 207, - 3, - 168, - 193, - 252, - 59, - 127 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "instruction_params", - "writable": true, - "optional": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "root_bundle", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 111, - 111, - 116, - 95, - 98, - 117, - 110, - 100, - 108, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - }, - { - "kind": "arg", - "path": "_root_bundle_id.unwrap_or_else(| |\ninstruction_params" - } - ] - } - }, - { - "name": "fill_status", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 102, - 105, - 108, - 108, - 115 - ] - }, - { - "kind": "arg", - "path": "_relay_hash" - } - ] - } - }, - { - "name": "mint" - }, - { - "name": "recipient_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "arg", - "path": "slow_fill_leaf" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "token_program" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "_relay_hash", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "slow_fill_leaf", - "type": { - "option": { - "defined": { - "name": "SlowFill" - } - } - } - }, - { - "name": "_root_bundle_id", - "type": { - "option": "u32" - } - }, - { - "name": "proof", - "type": { - "option": { - "vec": { - "array": [ - "u8", - 32 - ] - } - } - } - } - ] - }, - { - "name": "fill_relay", - "docs": [ - "Fulfill request to bridge cross chain by sending specified output tokens to recipient.", - "", - "Relayer & system fee is captured in the spread between input and output amounts. This fee accounts for tx costs,", - "relayer's capital opportunity cost, and a system fee. The relay_data hash uniquely identifies the deposit to", - "fill, ensuring relayers are refunded only for deposits matching the original hash from the origin SpokePool.", - "This hash includes all parameters from deposit() and must match the destination_chain_id. Note the relayer", - "creates an ATA in calling this method to store the fill_status. This should be closed once the deposit has", - "expired to let the relayer re-claim their rent. Cannot fill more than once. Partial fills are not supported.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the fill (filler). No permission requirements.", - "- instruction_params (Account): Optional account to load instruction parameters when they are not passed in the", - "instruction data due to message size constraints. Pass this program ID to represent None. When Some, this must", - "be derived from the signer's public key with seed [\"instruction_params\",signer].", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- mint (Account): The mint of the output token, sent from the relayer to the recipient.", - "- relayer_token_account (Writable): The relayer's ATA for the input token.", - "- recipient_token_account (Writable): The recipient's ATA for the output token.", - "- fill_status (Writable): The fill status PDA, created on this function call to track the fill status to prevent", - "re-entrancy & double fills. Also used to track requested slow fills. Seed: [\"fills\",relay_hash].", - "- token_program (Interface): The token program.", - "- associated_token_program (Interface): The associated token program.", - "- system_program (Interface): The system program.", - "- delegate (Account): The account used to delegate the output amount of the output token.", - "", - "### Parameters:", - "- relay_hash: The hash identifying the deposit to be filled. Caller must pass this in. Computed as hash of", - "the flattened relay_data & destination_chain_id.", - "- relay_data: Struct containing all the data needed to identify the deposit to be filled. Should match", - "all the same-named parameters emitted in the origin chain FundsDeposited event.", - "- depositor: The account credited with the deposit.", - "- recipient: The account receiving funds on this chain.", - "- input_token: The token pulled from the caller's account to initiate the deposit. The equivalent of this", - "token on the repayment chain will be sent as a refund to the caller.", - "- output_token: The token that the caller will send to the recipient on this chain.", - "- input_amount: This amount, less a system fee, will be sent to the caller on their repayment chain.", - "This is big-endian encoded as a 32-byte array to match its underlying byte representation on EVM side", - "- output_amount: The amount of output tokens that the caller will send to the recipient.", - "- origin_chain_id: The origin chain identifier.", - "- exclusive_relayer: The relayer that will be exclusively allowed to fill this deposit before the", - "exclusivity deadline timestamp.", - "- fill_deadline: The deadline for the caller to fill the deposit. After this timestamp, the deposit will be", - "cancelled and the depositor will be refunded on the origin chain.", - "- exclusivity_deadline: The deadline for the exclusive relayer to fill the deposit. After this timestamp,", - "anyone can fill this deposit.", - "- message: The message to send to the recipient if the recipient is a contract that implements a", - "handle_across_message() public function.", - "- repayment_chain_id: Chain of SpokePool where relayer wants to be refunded after the challenge window has", - "passed. Will receive input_amount of the equivalent token to input_token on the repayment chain.", - "- repayment_address: The address of the recipient on the repayment chain that they want to be refunded to.", - "Note: relay_data, repayment_chain_id, and repayment_address are optional parameters. If None for any of these", - "is passed, the caller must load them via the instruction_params account." - ], - "discriminator": [ - 100, - 84, - 222, - 90, - 106, - 209, - 58, - 222 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "instruction_params", - "writable": true, - "optional": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "delegate" - }, - { - "name": "mint" - }, - { - "name": "relayer_token_account", - "writable": true - }, - { - "name": "recipient_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "arg", - "path": "relay_data" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "fill_status", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 102, - 105, - 108, - 108, - 115 - ] - }, - { - "kind": "arg", - "path": "relay_hash" - } - ] - } - }, - { - "name": "token_program" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "relay_hash", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "relay_data", - "type": { - "option": { - "defined": { - "name": "RelayData" - } - } - } - }, - { - "name": "repayment_chain_id", - "type": { - "option": "u64" - } - }, - { - "name": "repayment_address", - "type": { - "option": "pubkey" - } - } - ] - }, - { - "name": "get_unsafe_deposit_id", - "docs": [ - "Computes the deposit ID for the depositor using the provided deposit_nonce. This acts like a \"view\" function for", - "off-chain actors to compute what the expected deposit ID is for a given depositor and deposit nonce will be.", - "", - "### Parameters:", - "- signer: The public key of the depositor sender.", - "- depositor: The public key of the depositor.", - "- deposit_nonce: The nonce used to derive the deposit ID." - ], - "discriminator": [ - 118, - 10, - 135, - 0, - 168, - 243, - 223, - 117 - ], - "accounts": [], - "args": [ - { - "name": "signer", - "type": "pubkey" - }, - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "deposit_nonce", - "type": "u64" - } - ], - "returns": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "handle_receive_message", - "docs": [ - "Handles cross-chain messages received from L1 Ethereum over CCTP.", - "", - "This function serves as the permissioned entry point for messages sent from the Ethereum mainnet to the Solana", - "SVM Spoke program over CCTP. It processes the incoming message by translating it into a corresponding Solana", - "instruction and then invokes the instruction within this program.", - "", - "### Required Accounts:", - "- authority_pda: A signer account that ensures this instruction can only be called by the Message Transmitter.", - "This acts to block that only the CCTP Message Transmitter can send messages to this program.", - "seed:[\"message_transmitter_authority\", program_id]", - "- state (Account): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet. Enforces that the", - "remote domain and sender are valid.", - "- self_authority: An unchecked account used for authenticating self-CPI invoked by the received message.", - "seed: [\"self_authority\"].", - "- program: The SVM Spoke program account.", - "", - "### Parameters:", - "- params: Contains information to process the received message, containing the following fields:", - "- remote_domain: The remote domain of the message sender.", - "- sender: The sender of the message.", - "- message_body: The body of the message.", - "- authority_bump: The authority bump for the message transmitter." - ], - "discriminator": [ - 133, - 102, - 1, - 180, - 145, - 11, - 138, - 180 - ], - "accounts": [ - { - "name": "authority_pda", - "signer": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 115, - 115, - 97, - 103, - 101, - 95, - 116, - 114, - 97, - 110, - 115, - 109, - 105, - 116, - 116, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "const", - "value": [ - 183, - 102, - 64, - 134, - 222, - 55, - 238, - 112, - 130, - 28, - 16, - 68, - 91, - 22, - 47, - 44, - 126, - 200, - 121, - 91, - 208, - 128, - 12, - 20, - 98, - 148, - 158, - 35, - 40, - 209, - 221, - 90 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 166, - 95, - 201, - 137, - 219, - 95, - 93, - 66, - 117, - 159, - 58, - 84, - 96, - 88, - 239, - 205, - 205, - 192, - 191, - 60, - 24, - 152, - 7, - 45, - 142, - 180, - 93, - 209, - 216, - 5, - 8, - 206 - ] - } - } - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "self_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 101, - 108, - 102, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program", - "address": "DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "HandleReceiveMessageParams" - } - } - } - ] - }, - { - "name": "initialize", - "docs": [ - "Initializes the state for the SVM Spoke Pool. Only callable once.", - "", - "### Required Accounts:", - "- signer (Writable, Signer): The account that pays for the transaction and will own the state.", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- system_program: The system program required for account creation.", - "", - "### Parameters:", - "- seed: A unique seed used to derive the state account's address. Must be 0 on Mainnet.", - "- initial_number_of_deposits: The initial number of deposits. Used to offset in upgrades.", - "- chain_id: The chain ID for Solana, used to identify the Solana spoke in the rest of the Across protocol.", - "- remote_domain: The CCTP domain for Mainnet Ethereum.", - "- cross_domain_admin: The HubPool on Mainnet Ethereum.", - "- deposit_quote_time_buffer: Quote timestamps can't be set more than this amount into the past from deposit.", - "- fill_deadline_buffer: Fill deadlines can't be set more than this amount into the future from deposit." - ], - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "arg", - "path": "seed" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "seed", - "type": "u64" - }, - { - "name": "initial_number_of_deposits", - "type": "u32" - }, - { - "name": "chain_id", - "type": "u64" - }, - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "cross_domain_admin", - "type": "pubkey" - }, - { - "name": "deposit_quote_time_buffer", - "type": "u32" - }, - { - "name": "fill_deadline_buffer", - "type": "u32" - } - ] - }, - { - "name": "initialize_claim_account", - "docs": [ - "Initializes a claim account for a relayer refund.", - "", - "This function sets up a claim account for a relayer to claim their refund at a later time and should only be", - "used in the un-happy path where a bundle cant not be executed due to a recipient in the bundle having a blocked", - "or uninitialized claim ATA. The refund address becomes the \"owner\" of the claim_account.", - "", - "### Required Accounts:", - "- signer (Signer): The account that pays for the transaction and initializes the claim account.", - "- mint: The mint associated with the claim account.", - "- refund_address: The refund address associated with the claim account.", - "- claim_account (Writable): The newly created claim account PDA to store claim data for this associated mint.", - "Seed: [\"claim_account\",mint,refund_address].", - "- system_program: The system program required for account creation." - ], - "discriminator": [ - 22, - 247, - 214, - 191, - 90, - 74, - 87, - 216 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "mint" - }, - { - "name": "refund_address" - }, - { - "name": "claim_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 108, - 97, - 105, - 109, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - }, - { - "kind": "account", - "path": "refund_address" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "initialize_instruction_params", - "docs": [ - "Initializes the instruction parameters account. Used by data worker when relaying bundles", - "", - "This function sets up an account to store raw data fragments for instructions (LUT).", - "", - "### Required Accounts:", - "- signer (Signer): The account that pays for the transaction and initializes the instruction parameters.", - "- instruction_params (UncheckedAccount): The account where raw data will be stored. Initialized with specified", - "size. seed: [\"instruction_params\",signer].", - "- system_program: The system program required for account creation.", - "", - "### Parameters:", - "- _total_size: The total size of the instruction parameters account." - ], - "discriminator": [ - 94, - 206, - 190, - 192, - 127, - 8, - 186, - 28 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "instruction_params", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "_total_size", - "type": "u32" - } - ] - }, - { - "name": "pause_deposits", - "docs": [ - "Pauses the Spoke Pool from accepting deposits. Only callable by the owner.", - "", - "### Required Accounts:", - "- signer (Signer): The account that must be the owner to authorize the pause.", - "- state (Writable): The Spoke state PDA. Seed: [\"state\",state.seed], where `seed` is 0 on mainnet.", - "", - "### Parameters:", - "- pause: `true` to pause the system, `false` to unpause it." - ], - "discriminator": [ - 206, - 186, - 203, - 153, - 253, - 61, - 206, - 122 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "pause", - "type": "bool" - } - ] - }, - { - "name": "pause_fills", - "docs": [ - "Pauses the Spoke Pool from processing fills. Only callable by the owner.", - "", - "### Required Accounts:", - "- signer (Signer): The account that must be the owner to authorize the pause.", - "- state (Writable): The Spoke state PDA. Seed: [\"state\",state.seed], where `seed` is 0 on mainnet.", - "", - "### Parameters:", - "- pause: `true` to pause the system, `false` to unpause it." - ], - "discriminator": [ - 92, - 114, - 214, - 49, - 13, - 243, - 73, - 35 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "pause", - "type": "bool" - } - ] - }, - { - "name": "relay_root_bundle", - "docs": [ - "Stores a new root bundle for later execution. Only callable by the owner.", - "", - "Once stored, these roots are used to execute relayer refunds, slow fills, and pool rebalancing actions.", - "This method initializes a root_bundle PDA to store the root bundle data. The caller", - "of this method is responsible for paying the rent for this PDA.", - "", - "### Required Accounts:", - "- signer (Signer): The account that must be the owner to authorize the addition of the new root bundle.", - "- payer (Signer): The account who pays rent to create root_bundle PDA.", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- root_bundle (Writable): The newly created bundle PDA to store root bundle data. Each root bundle has an", - "incrementing ID, stored in the state. Seed: [\"root_bundle\",state.seed,root_bundle_id].", - "- system_program (Program): The system program required for account creation.", - "", - "### Parameters:", - "- relayer_refund_root: Merkle root of the relayer refund tree.", - "- slow_relay_root: Merkle root of the slow relay tree." - ], - "discriminator": [ - 69, - 13, - 223, - 204, - 251, - 61, - 105, - 6 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "root_bundle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 111, - 111, - 116, - 95, - 98, - 117, - 110, - 100, - 108, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - }, - { - "kind": "account", - "path": "state.root_bundle_id", - "account": "State" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "relayer_refund_root", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "slow_relay_root", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "request_slow_fill", - "docs": [ - "Requests Across to send LP funds to this program to fulfill a slow fill.", - "", - "Slow fills are not possible unless the input and output tokens are \"equivalent\", i.e., they route to the same L1", - "token via PoolRebalanceRoutes. Slow fills are created by inserting slow fill objects into a Merkle tree that is", - "included in the next HubPool \"root bundle\". Once the optimistic challenge window has passed, the HubPool will", - "relay the slow root to this chain via relayRootBundle(). Once the slow root is relayed, the slow fill can be", - "executed by anyone who calls executeSlowRelayLeaf(). Cant request a slow fill if the fill deadline has", - "passed. Cant request a slow fill if the relay has already been filled or a slow fill has already been requested.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the slow fill request.", - "- instruction_params (Account): Optional account to load instruction parameters when they are not passed in the", - "instruction data due to message size constraints. Pass this program ID to represent None. When Some, this must", - "be derived from the signer's public key with seed [\"instruction_params\",signer].", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- fill_status (Writable): The fill status PDA, created on this function call. Updated to track slow fill status.", - "Used to prevent double request and fill. Seed: [\"fills\",relay_hash].", - "- system_program (Interface): The system program.", - "", - "### Parameters:", - "- _relay_hash: The hash identifying the deposit to be filled. Caller must pass this in. Computed as hash of", - "the flattened relay_data & destination_chain_id.", - "- relay_data: Struct containing all the data needed to identify the deposit that should be slow filled. If any", - "of the params are missing or different from the origin chain deposit, then Across will not include a slow", - "fill for the intended deposit. See fill_relay & RelayData struct for more details.", - "Note: relay_data is optional parameter. If None for it is passed, the caller must load it via the", - "instruction_params account." - ], - "discriminator": [ - 39, - 157, - 165, - 187, - 88, - 217, - 207, - 98 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "instruction_params", - "writable": true, - "optional": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "fill_status", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 102, - 105, - 108, - 108, - 115 - ] - }, - { - "kind": "arg", - "path": "_relay_hash" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "_relay_hash", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "relay_data", - "type": { - "option": { - "defined": { - "name": "RelayData" - } - } - } - } - ] - }, - { - "name": "set_cross_domain_admin", - "docs": [ - "Sets the cross-domain admin for the Spoke Pool. Only callable by owner. Used if Hubpool upgrades.", - "", - "### Required Accounts:", - "- signer (Signer): The account that must be the owner to authorize the admin change.", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "", - "### Parameters:", - "- cross_domain_admin: The public key of the new cross-domain admin." - ], - "discriminator": [ - 102, - 206, - 237, - 106, - 63, - 141, - 42, - 248 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "cross_domain_admin", - "type": "pubkey" - } - ] - }, - { - "name": "set_current_time", - "docs": [ - "Sets the current time for the SVM Spoke Pool when running in test mode. Disabled on Mainnet." - ], - "discriminator": [ - 69, - 100, - 169, - 193, - 125, - 0, - 150, - 69 - ], - "accounts": [ - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "signer", - "signer": true - } - ], - "args": [ - { - "name": "new_time", - "type": "u32" - } - ] - }, - { - "name": "transfer_ownership", - "docs": [ - "Transfers ownership of the Spoke Pool. Only callable by the current owner.", - "", - "### Required Accounts:", - "- signer (Signer): The account that must be the current owner to authorize the transfer.", - "- state (Writable): The Spoke state PDA. Seed: [\"state\",state.seed] where `seed` is 0 on mainnet.", - "", - "### Parameters:", - "- new_owner: The public key of the new owner." - ], - "discriminator": [ - 65, - 177, - 215, - 73, - 53, - 45, - 99, - 47 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "new_owner", - "type": "pubkey" - } - ] - }, - { - "name": "unsafe_deposit", - "docs": [ - "Equivalent to deposit, except that it doesn't use the global `number_of_deposits` counter as the deposit", - "nonce. Instead, it allows the caller to pass a `deposit_nonce`. This function is designed for anyone who", - "wants to pre-compute their resultant deposit ID, which can be useful for filling a deposit faster and", - "avoiding the risk of a deposit ID unexpectedly changing due to another deposit front-running this one and", - "incrementing the global deposit ID counter. This enables the caller to influence the deposit ID, making it", - "deterministic for the depositor. The computed `depositID` is the keccak256 hash of [signer, depositor, deposit_nonce]." - ], - "discriminator": [ - 196, - 187, - 166, - 179, - 3, - 146, - 150, - 246 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "State" - } - ] - } - }, - { - "name": "delegate" - }, - { - "name": "depositor_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "arg", - "path": "depositor" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "token_program" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "mint" - }, - { - "name": "token_program" - }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "input_token", - "type": "pubkey" - }, - { - "name": "output_token", - "type": "pubkey" - }, - { - "name": "input_amount", - "type": "u64" - }, - { - "name": "output_amount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "destination_chain_id", - "type": "u64" - }, - { - "name": "exclusive_relayer", - "type": "pubkey" - }, - { - "name": "deposit_nonce", - "type": "u64" - }, - { - "name": "quote_timestamp", - "type": "u32" - }, - { - "name": "fill_deadline", - "type": "u32" - }, - { - "name": "exclusivity_parameter", - "type": "u32" - }, - { - "name": "message", - "type": "bytes" - } - ] - }, - { - "name": "write_instruction_params_fragment", - "docs": [ - "Writes a fragment of raw data into the instruction parameters account.", - "", - "This function allows writing a fragment of data into a specified offset within the instruction parameters", - "account. It ensures that the data does not overflow the account's allocated space.", - "", - "### Required Accounts:", - "- signer (Signer): Account that authorizes the write operation.", - "- instruction_params (UncheckedAccount): Account to write raw data to. seed: [\"instruction_params\",signer].", - "- system_program: The system program required for account operations.", - "", - "### Parameters:", - "- offset: The starting position within the account's data where the fragment will be written.", - "- fragment: The raw data fragment to be written into the account." - ], - "discriminator": [ - 238, - 182, - 109, - 113, - 124, - 255, - 72, - 18 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "instruction_params", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "offset", - "type": "u32" - }, - { - "name": "fragment", - "type": "bytes" - } - ] - } - ], - "accounts": [ - { - "name": "ClaimAccount", - "discriminator": [ - 113, - 109, - 47, - 96, - 242, - 219, - 61, - 165 - ] - }, - { - "name": "ExecuteRelayerRefundLeafParams", - "discriminator": [ - 192, - 59, - 93, - 9, - 171, - 77, - 28, - 250 - ] - }, - { - "name": "ExecuteSlowRelayLeafParams", - "discriminator": [ - 135, - 208, - 119, - 251, - 14, - 222, - 66, - 155 - ] - }, - { - "name": "FillRelayParams", - "discriminator": [ - 50, - 243, - 51, - 185, - 89, - 60, - 43, - 202 - ] - }, - { - "name": "FillStatusAccount", - "discriminator": [ - 105, - 89, - 88, - 35, - 24, - 147, - 178, - 137 - ] - }, - { - "name": "RequestSlowFillParams", - "discriminator": [ - 5, - 54, - 214, - 89, - 197, - 37, - 118, - 28 - ] - }, - { - "name": "RootBundle", - "discriminator": [ - 66, - 221, - 214, - 231, - 25, - 222, - 184, - 219 - ] - }, - { - "name": "State", - "discriminator": [ - 216, - 146, - 107, - 94, - 104, - 75, - 182, - 177 - ] - }, - { - "name": "TransferLiability", - "discriminator": [ - 157, - 137, - 86, - 109, - 206, - 241, - 183, - 79 - ] - } - ], - "events": [ - { - "name": "BridgedToHubPool", - "discriminator": [ - 181, - 111, - 52, - 218, - 105, - 53, - 240, - 205 - ] - }, - { - "name": "ClaimedRelayerRefund", - "discriminator": [ - 161, - 134, - 155, - 159, - 211, - 37, - 150, - 41 - ] - }, - { - "name": "EmergencyDeletedRootBundle", - "discriminator": [ - 45, - 150, - 89, - 248, - 134, - 142, - 200, - 114 - ] - }, - { - "name": "ExecutedRelayerRefundRoot", - "discriminator": [ - 198, - 167, - 248, - 175, - 34, - 3, - 4, - 240 - ] - }, - { - "name": "FilledRelay", - "discriminator": [ - 25, - 58, - 182, - 0, - 50, - 99, - 160, - 117 - ] - }, - { - "name": "FundsDeposited", - "discriminator": [ - 157, - 209, - 100, - 95, - 59, - 100, - 3, - 68 - ] - }, - { - "name": "PausedDeposits", - "discriminator": [ - 94, - 129, - 187, - 122, - 94, - 30, - 91, - 247 - ] - }, - { - "name": "PausedFills", - "discriminator": [ - 81, - 4, - 134, - 23, - 170, - 56, - 234, - 234 - ] - }, - { - "name": "RelayedRootBundle", - "discriminator": [ - 188, - 206, - 117, - 10, - 66, - 78, - 77, - 115 - ] - }, - { - "name": "RequestedSlowFill", - "discriminator": [ - 221, - 123, - 11, - 14, - 71, - 37, - 178, - 167 - ] - }, - { - "name": "SetXDomainAdmin", - "discriminator": [ - 164, - 13, - 119, - 18, - 103, - 226, - 98, - 66 - ] - }, - { - "name": "TokensBridged", - "discriminator": [ - 200, - 201, - 199, - 39, - 5, - 238, - 214, - 196 - ] - }, - { - "name": "TransferredOwnership", - "discriminator": [ - 235, - 235, - 154, - 16, - 153, - 94, - 21, - 117 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "InvalidQuoteTimestamp", - "msg": "Invalid quote timestamp!" - }, - { - "code": 6001, - "name": "InvalidFillDeadline", - "msg": "Invalid fill deadline!" - }, - { - "code": 6002, - "name": "NotExclusiveRelayer", - "msg": "Caller is not the exclusive relayer and exclusivity deadline has not passed!" - }, - { - "code": 6003, - "name": "NoSlowFillsInExclusivityWindow", - "msg": "The Deposit is still within the exclusivity window!" - }, - { - "code": 6004, - "name": "RelayFilled", - "msg": "The relay has already been filled!" - }, - { - "code": 6005, - "name": "InvalidSlowFillRequest", - "msg": "Slow fill requires status of Unfilled!" - }, - { - "code": 6006, - "name": "ExpiredFillDeadline", - "msg": "The fill deadline has passed!" - }, - { - "code": 6007, - "name": "InvalidMerkleProof", - "msg": "Invalid Merkle proof!" - }, - { - "code": 6008, - "name": "InvalidChainId", - "msg": "Invalid chain id!" - }, - { - "code": 6009, - "name": "InvalidMerkleLeaf", - "msg": "Invalid Merkle leaf!" - }, - { - "code": 6010, - "name": "ClaimedMerkleLeaf", - "msg": "Leaf already claimed!" - }, - { - "code": 6011, - "name": "DepositsArePaused", - "msg": "Deposits are currently paused!" - }, - { - "code": 6012, - "name": "FillsArePaused", - "msg": "Fills are currently paused!" - }, - { - "code": 6013, - "name": "InsufficientSpokePoolBalanceToExecuteLeaf", - "msg": "Insufficient spoke pool balance to execute leaf" - }, - { - "code": 6014, - "name": "InvalidExclusiveRelayer", - "msg": "Invalid exclusive relayer!" - }, - { - "code": 6015, - "name": "InvalidOutputToken", - "msg": "Invalid output token!" - } - ], - "types": [ - { - "name": "BridgedToHubPool", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "ClaimAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "initializer", - "type": "pubkey" - } - ] - } - }, - { - "name": "ClaimedRelayerRefund", - "type": { - "kind": "struct", - "fields": [ - { - "name": "l2_token_address", - "type": "pubkey" - }, - { - "name": "claim_amount", - "type": "u64" - }, - { - "name": "refund_address", - "type": "pubkey" - } - ] - } - }, - { - "name": "EmergencyDeletedRootBundle", - "type": { - "kind": "struct", - "fields": [ - { - "name": "root_bundle_id", - "type": "u32" - } - ] - } - }, - { - "name": "ExecuteRelayerRefundLeafParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "root_bundle_id", - "type": "u32" - }, - { - "name": "relayer_refund_leaf", - "type": { - "defined": { - "name": "RelayerRefundLeaf" - } - } - }, - { - "name": "proof", - "type": { - "vec": { - "array": [ - "u8", - 32 - ] - } - } - } - ] - } - }, - { - "name": "ExecuteSlowRelayLeafParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "slow_fill_leaf", - "type": { - "defined": { - "name": "SlowFill" - } - } - }, - { - "name": "root_bundle_id", - "type": "u32" - }, - { - "name": "proof", - "type": { - "vec": { - "array": [ - "u8", - 32 - ] - } - } - } - ] - } - }, - { - "name": "ExecutedRelayerRefundRoot", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount_to_return", - "type": "u64" - }, - { - "name": "chain_id", - "type": "u64" - }, - { - "name": "refund_amounts", - "type": { - "vec": "u64" - } - }, - { - "name": "root_bundle_id", - "type": "u32" - }, - { - "name": "leaf_id", - "type": "u32" - }, - { - "name": "l2_token_address", - "type": "pubkey" - }, - { - "name": "refund_addresses", - "type": { - "vec": "pubkey" - } - }, - { - "name": "deferred_refunds", - "type": "bool" - }, - { - "name": "caller", - "type": "pubkey" - } - ] - } - }, - { - "name": "FillRelayParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "relay_data", - "type": { - "defined": { - "name": "RelayData" - } - } - }, - { - "name": "repayment_chain_id", - "type": "u64" - }, - { - "name": "repayment_address", - "type": "pubkey" - } - ] - } - }, - { - "name": "FillStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "Unfilled" - }, - { - "name": "RequestedSlowFill" - }, - { - "name": "Filled" - } - ] - } - }, - { - "name": "FillStatusAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "status", - "type": { - "defined": { - "name": "FillStatus" - } - } - }, - { - "name": "relayer", - "type": "pubkey" - }, - { - "name": "fill_deadline", - "type": "u32" - } - ] - } - }, - { - "name": "FillType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "FastFill" - }, - { - "name": "ReplacedSlowFill" - }, - { - "name": "SlowFill" - } - ] - } - }, - { - "name": "FilledRelay", - "type": { - "kind": "struct", - "fields": [ - { - "name": "input_token", - "type": "pubkey" - }, - { - "name": "output_token", - "type": "pubkey" - }, - { - "name": "input_amount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "output_amount", - "type": "u64" - }, - { - "name": "repayment_chain_id", - "type": "u64" - }, - { - "name": "origin_chain_id", - "type": "u64" - }, - { - "name": "deposit_id", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "fill_deadline", - "type": "u32" - }, - { - "name": "exclusivity_deadline", - "type": "u32" - }, - { - "name": "exclusive_relayer", - "type": "pubkey" - }, - { - "name": "relayer", - "type": "pubkey" - }, - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "message_hash", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "relay_execution_info", - "type": { - "defined": { - "name": "RelayExecutionEventInfo" - } - } - } - ] - } - }, - { - "name": "FundsDeposited", - "type": { - "kind": "struct", - "fields": [ - { - "name": "input_token", - "type": "pubkey" - }, - { - "name": "output_token", - "type": "pubkey" - }, - { - "name": "input_amount", - "type": "u64" - }, - { - "name": "output_amount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "destination_chain_id", - "type": "u64" - }, - { - "name": "deposit_id", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "quote_timestamp", - "type": "u32" - }, - { - "name": "fill_deadline", - "type": "u32" - }, - { - "name": "exclusivity_deadline", - "type": "u32" - }, - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "exclusive_relayer", - "type": "pubkey" - }, - { - "name": "message", - "type": "bytes" - } - ] - } - }, - { - "name": "HandleReceiveMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "sender", - "type": "pubkey" - }, - { - "name": "message_body", - "type": "bytes" - }, - { - "name": "authority_bump", - "type": "u8" - } - ] - } - }, - { - "name": "PausedDeposits", - "type": { - "kind": "struct", - "fields": [ - { - "name": "is_paused", - "type": "bool" - } - ] - } - }, - { - "name": "PausedFills", - "type": { - "kind": "struct", - "fields": [ - { - "name": "is_paused", - "type": "bool" - } - ] - } - }, - { - "name": "RelayData", - "type": { - "kind": "struct", - "fields": [ - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "exclusive_relayer", - "type": "pubkey" - }, - { - "name": "input_token", - "type": "pubkey" - }, - { - "name": "output_token", - "type": "pubkey" - }, - { - "name": "input_amount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "output_amount", - "type": "u64" - }, - { - "name": "origin_chain_id", - "type": "u64" - }, - { - "name": "deposit_id", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "fill_deadline", - "type": "u32" - }, - { - "name": "exclusivity_deadline", - "type": "u32" - }, - { - "name": "message", - "type": "bytes" - } - ] - } - }, - { - "name": "RelayExecutionEventInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "updated_recipient", - "type": "pubkey" - }, - { - "name": "updated_message_hash", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "updated_output_amount", - "type": "u64" - }, - { - "name": "fill_type", - "type": { - "defined": { - "name": "FillType" - } - } - } - ] - } - }, - { - "name": "RelayedRootBundle", - "type": { - "kind": "struct", - "fields": [ - { - "name": "root_bundle_id", - "type": "u32" - }, - { - "name": "relayer_refund_root", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "slow_relay_root", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - } - }, - { - "name": "RelayerRefundLeaf", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount_to_return", - "type": "u64" - }, - { - "name": "chain_id", - "type": "u64" - }, - { - "name": "refund_amounts", - "type": { - "vec": "u64" - } - }, - { - "name": "leaf_id", - "type": "u32" - }, - { - "name": "mint_public_key", - "type": "pubkey" - }, - { - "name": "refund_addresses", - "type": { - "vec": "pubkey" - } - } - ] - } - }, - { - "name": "RequestSlowFillParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "relay_data", - "type": { - "defined": { - "name": "RelayData" - } - } - } - ] - } - }, - { - "name": "RequestedSlowFill", - "type": { - "kind": "struct", - "fields": [ - { - "name": "input_token", - "type": "pubkey" - }, - { - "name": "output_token", - "type": "pubkey" - }, - { - "name": "input_amount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "output_amount", - "type": "u64" - }, - { - "name": "origin_chain_id", - "type": "u64" - }, - { - "name": "deposit_id", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "fill_deadline", - "type": "u32" - }, - { - "name": "exclusivity_deadline", - "type": "u32" - }, - { - "name": "exclusive_relayer", - "type": "pubkey" - }, - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "message_hash", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - } - }, - { - "name": "RootBundle", - "type": { - "kind": "struct", - "fields": [ - { - "name": "relayer_refund_root", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "slow_relay_root", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "claimed_bitmap", - "type": "bytes" - } - ] - } - }, - { - "name": "SetXDomainAdmin", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_admin", - "type": "pubkey" - } - ] - } - }, - { - "name": "SlowFill", - "type": { - "kind": "struct", - "fields": [ - { - "name": "relay_data", - "type": { - "defined": { - "name": "RelayData" - } - } - }, - { - "name": "chain_id", - "type": "u64" - }, - { - "name": "updated_output_amount", - "type": "u64" - } - ] - } - }, - { - "name": "State", - "type": { - "kind": "struct", - "fields": [ - { - "name": "paused_deposits", - "type": "bool" - }, - { - "name": "paused_fills", - "type": "bool" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "seed", - "type": "u64" - }, - { - "name": "number_of_deposits", - "type": "u32" - }, - { - "name": "chain_id", - "type": "u64" - }, - { - "name": "current_time", - "type": "u32" - }, - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "cross_domain_admin", - "type": "pubkey" - }, - { - "name": "root_bundle_id", - "type": "u32" - }, - { - "name": "deposit_quote_time_buffer", - "type": "u32" - }, - { - "name": "fill_deadline_buffer", - "type": "u32" - } - ] - } - }, - { - "name": "TokensBridged", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount_to_return", - "type": "u64" - }, - { - "name": "chain_id", - "type": "u64" - }, - { - "name": "leaf_id", - "type": "u32" - }, - { - "name": "l2_token_address", - "type": "pubkey" - }, - { - "name": "caller", - "type": "pubkey" - } - ] - } - }, - { - "name": "TransferLiability", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pending_to_hub_pool", - "type": "u64" - } - ] - } - }, - { - "name": "TransferredOwnership", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_owner", - "type": "pubkey" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/src/svm/assets/idl/test.json b/src/svm/assets/idl/test.json deleted file mode 100644 index 4d23674d9..000000000 --- a/src/svm/assets/idl/test.json +++ /dev/null @@ -1,243 +0,0 @@ -{ - "address": "8tsEfDSiE4WUMf97oyyyasLAvWwjeRZb2GByh4w7HckA", - "metadata": { - "name": "test", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "initialize", - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "bitmap_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 105, - 116, - 109, - 97, - 112, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - } - ] - } - }, - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "test_emit_large_log", - "discriminator": [ - 126, - 64, - 160, - 189, - 160, - 160, - 238, - 68 - ], - "accounts": [], - "args": [ - { - "name": "length", - "type": "u32" - } - ] - }, - { - "name": "test_is_claimed", - "discriminator": [ - 82, - 227, - 141, - 60, - 27, - 165, - 109, - 90 - ], - "accounts": [ - { - "name": "bitmap_account" - } - ], - "args": [ - { - "name": "index", - "type": "u32" - } - ], - "returns": "bool" - }, - { - "name": "test_set_claimed", - "discriminator": [ - 15, - 155, - 67, - 241, - 20, - 247, - 21, - 189 - ], - "accounts": [ - { - "name": "bitmap_account", - "writable": true - }, - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "index", - "type": "u32" - } - ] - }, - { - "name": "verify", - "discriminator": [ - 133, - 161, - 141, - 48, - 120, - 198, - 88, - 150 - ], - "accounts": [], - "args": [ - { - "name": "root", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "leaf", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "proof", - "type": { - "vec": { - "array": [ - "u8", - 32 - ] - } - } - } - ] - } - ], - "accounts": [ - { - "name": "BitmapAccount", - "discriminator": [ - 152, - 161, - 147, - 85, - 213, - 38, - 59, - 48 - ] - } - ], - "events": [ - { - "name": "TestEvent", - "discriminator": [ - 28, - 52, - 39, - 105, - 8, - 210, - 91, - 9 - ] - } - ], - "types": [ - { - "name": "BitmapAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "claimed_bitmap", - "type": "bytes" - } - ] - } - }, - { - "name": "TestEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "message", - "type": "string" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/src/svm/assets/idl/token_messenger_minter.json b/src/svm/assets/idl/token_messenger_minter.json deleted file mode 100644 index ba9a2ad93..000000000 --- a/src/svm/assets/idl/token_messenger_minter.json +++ /dev/null @@ -1,2049 +0,0 @@ -{ - "address": "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3", - "metadata": { - "name": "token_messenger_minter", - "version": "0.1.0", - "spec": "0.1.0" - }, - "instructions": [ - { - "name": "initialize", - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "upgrade_authority", - "signer": true - }, - { - "name": "authority_pda" - }, - { - "name": "token_messenger", - "writable": true - }, - { - "name": "token_minter", - "writable": true - }, - { - "name": "token_messenger_minter_program_data" - }, - { - "name": "token_messenger_minter_program" - }, - { - "name": "system_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "InitializeParams" - } - } - } - ] - }, - { - "name": "transfer_ownership", - "discriminator": [ - 65, - 177, - 215, - 73, - 53, - 45, - 99, - 47 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "token_messenger", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "TransferOwnershipParams" - } - } - } - ] - }, - { - "name": "accept_ownership", - "discriminator": [ - 172, - 23, - 43, - 13, - 238, - 213, - 85, - 150 - ], - "accounts": [ - { - "name": "pending_owner", - "signer": true - }, - { - "name": "token_messenger", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "AcceptOwnershipParams" - } - } - } - ] - }, - { - "name": "add_remote_token_messenger", - "discriminator": [ - 12, - 149, - 172, - 165, - 111, - 202, - 24, - 33 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "owner", - "signer": true - }, - { - "name": "token_messenger" - }, - { - "name": "remote_token_messenger", - "writable": true - }, - { - "name": "system_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "AddRemoteTokenMessengerParams" - } - } - } - ] - }, - { - "name": "remove_remote_token_messenger", - "discriminator": [ - 65, - 114, - 66, - 85, - 169, - 98, - 177, - 146 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "owner", - "signer": true - }, - { - "name": "token_messenger" - }, - { - "name": "remote_token_messenger", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "RemoveRemoteTokenMessengerParams" - } - } - } - ] - }, - { - "name": "deposit_for_burn", - "discriminator": [ - 215, - 60, - 61, - 46, - 114, - 55, - 128, - 176 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "event_rent_payer", - "writable": true, - "signer": true - }, - { - "name": "sender_authority_pda" - }, - { - "name": "burn_token_account", - "writable": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "token_messenger" - }, - { - "name": "remote_token_messenger" - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true - }, - { - "name": "burn_token_mint", - "writable": true - }, - { - "name": "message_sent_event_data", - "writable": true, - "signer": true - }, - { - "name": "message_transmitter_program" - }, - { - "name": "token_messenger_minter_program" - }, - { - "name": "token_program" - }, - { - "name": "system_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "DepositForBurnParams" - } - } - } - ], - "returns": "u64" - }, - { - "name": "deposit_for_burn_with_caller", - "discriminator": [ - 167, - 222, - 19, - 114, - 85, - 21, - 14, - 118 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "event_rent_payer", - "writable": true, - "signer": true - }, - { - "name": "sender_authority_pda" - }, - { - "name": "burn_token_account", - "writable": true - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "token_messenger" - }, - { - "name": "remote_token_messenger" - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true - }, - { - "name": "burn_token_mint", - "writable": true - }, - { - "name": "message_sent_event_data", - "writable": true, - "signer": true - }, - { - "name": "message_transmitter_program" - }, - { - "name": "token_messenger_minter_program" - }, - { - "name": "token_program" - }, - { - "name": "system_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "DepositForBurnWithCallerParams" - } - } - } - ], - "returns": "u64" - }, - { - "name": "replace_deposit_for_burn", - "discriminator": [ - 7, - 27, - 93, - 132, - 1, - 80, - 19, - 163 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "event_rent_payer", - "writable": true, - "signer": true - }, - { - "name": "sender_authority_pda" - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "token_messenger" - }, - { - "name": "message_sent_event_data", - "writable": true, - "signer": true - }, - { - "name": "message_transmitter_program" - }, - { - "name": "token_messenger_minter_program" - }, - { - "name": "system_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "ReplaceDepositForBurnParams" - } - } - } - ], - "returns": "u64" - }, - { - "name": "handle_receive_message", - "discriminator": [ - 133, - 102, - 1, - 180, - 145, - 11, - 138, - 180 - ], - "accounts": [ - { - "name": "authority_pda", - "signer": true - }, - { - "name": "token_messenger" - }, - { - "name": "remote_token_messenger" - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true - }, - { - "name": "token_pair" - }, - { - "name": "recipient_token_account", - "writable": true - }, - { - "name": "custody_token_account", - "writable": true - }, - { - "name": "token_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "HandleReceiveMessageParams" - } - } - } - ] - }, - { - "name": "set_token_controller", - "discriminator": [ - 88, - 6, - 98, - 10, - 79, - 59, - 15, - 24 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "token_messenger" - }, - { - "name": "token_minter", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetTokenControllerParams" - } - } - } - ] - }, - { - "name": "pause", - "discriminator": [ - 211, - 22, - 221, - 251, - 74, - 121, - 193, - 47 - ], - "accounts": [ - { - "name": "pauser", - "signer": true - }, - { - "name": "token_minter", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "PauseParams" - } - } - } - ] - }, - { - "name": "unpause", - "discriminator": [ - 169, - 144, - 4, - 38, - 10, - 141, - 188, - 255 - ], - "accounts": [ - { - "name": "pauser", - "signer": true - }, - { - "name": "token_minter", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UnpauseParams" - } - } - } - ] - }, - { - "name": "update_pauser", - "discriminator": [ - 140, - 171, - 211, - 132, - 57, - 201, - 16, - 254 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "token_messenger" - }, - { - "name": "token_minter", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UpdatePauserParams" - } - } - } - ] - }, - { - "name": "set_max_burn_amount_per_message", - "discriminator": [ - 30, - 128, - 145, - 240, - 70, - 237, - 109, - 207 - ], - "accounts": [ - { - "name": "token_controller", - "signer": true - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetMaxBurnAmountPerMessageParams" - } - } - } - ] - }, - { - "name": "add_local_token", - "discriminator": [ - 213, - 199, - 205, - 18, - 98, - 124, - 73, - 198 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "token_controller", - "signer": true - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true - }, - { - "name": "custody_token_account", - "writable": true - }, - { - "name": "local_token_mint" - }, - { - "name": "token_program" - }, - { - "name": "system_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "AddLocalTokenParams" - } - } - } - ] - }, - { - "name": "remove_local_token", - "discriminator": [ - 27, - 43, - 66, - 170, - 188, - 44, - 109, - 97 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "token_controller", - "signer": true - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true - }, - { - "name": "custody_token_account", - "writable": true - }, - { - "name": "token_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "RemoveLocalTokenParams" - } - } - } - ] - }, - { - "name": "link_token_pair", - "discriminator": [ - 68, - 162, - 24, - 104, - 125, - 46, - 130, - 12 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "token_controller", - "signer": true - }, - { - "name": "token_minter" - }, - { - "name": "token_pair", - "writable": true - }, - { - "name": "system_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "LinkTokenPairParams" - } - } - } - ] - }, - { - "name": "unlink_token_pair", - "discriminator": [ - 52, - 198, - 100, - 114, - 104, - 174, - 85, - 58 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "token_controller", - "signer": true - }, - { - "name": "token_minter" - }, - { - "name": "token_pair", - "writable": true - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UninkTokenPairParams" - } - } - } - ] - }, - { - "name": "burn_token_custody", - "discriminator": [ - 233, - 136, - 180, - 175, - 112, - 41, - 62, - 71 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "token_controller", - "signer": true - }, - { - "name": "token_minter" - }, - { - "name": "local_token" - }, - { - "name": "custody_token_account", - "writable": true - }, - { - "name": "custody_token_mint", - "writable": true - }, - { - "name": "token_program" - }, - { - "name": "event_authority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "BurnTokenCustodyParams" - } - } - } - ] - } - ], - "accounts": [ - { - "name": "TokenMessenger", - "discriminator": [ - 162, - 4, - 242, - 52, - 147, - 243, - 221, - 96 - ] - }, - { - "name": "RemoteTokenMessenger", - "discriminator": [ - 105, - 115, - 174, - 34, - 95, - 233, - 138, - 252 - ] - }, - { - "name": "TokenMinter", - "discriminator": [ - 122, - 133, - 84, - 63, - 57, - 159, - 171, - 206 - ] - }, - { - "name": "TokenPair", - "discriminator": [ - 17, - 214, - 45, - 176, - 229, - 149, - 197, - 71 - ] - }, - { - "name": "LocalToken", - "discriminator": [ - 159, - 131, - 58, - 170, - 193, - 84, - 128, - 182 - ] - } - ], - "events": [ - { - "name": "OwnershipTransferStarted", - "discriminator": [ - 183, - 253, - 239, - 246, - 140, - 179, - 133, - 105 - ] - }, - { - "name": "OwnershipTransferred", - "discriminator": [ - 172, - 61, - 205, - 183, - 250, - 50, - 38, - 98 - ] - }, - { - "name": "DepositForBurn", - "discriminator": [ - 144, - 252, - 145, - 146, - 6, - 74, - 167, - 235 - ] - }, - { - "name": "MintAndWithdraw", - "discriminator": [ - 75, - 67, - 229, - 70, - 162, - 126, - 0, - 71 - ] - }, - { - "name": "RemoteTokenMessengerAdded", - "discriminator": [ - 251, - 29, - 63, - 244, - 48, - 114, - 210, - 175 - ] - }, - { - "name": "RemoteTokenMessengerRemoved", - "discriminator": [ - 255, - 121, - 137, - 39, - 230, - 125, - 11, - 30 - ] - }, - { - "name": "SetTokenController", - "discriminator": [ - 193, - 44, - 243, - 83, - 230, - 72, - 120, - 216 - ] - }, - { - "name": "PauserChanged", - "discriminator": [ - 142, - 157, - 158, - 87, - 127, - 8, - 119, - 55 - ] - }, - { - "name": "SetBurnLimitPerMessage", - "discriminator": [ - 98, - 152, - 88, - 191, - 245, - 30, - 27, - 209 - ] - }, - { - "name": "LocalTokenAdded", - "discriminator": [ - 146, - 8, - 224, - 150, - 122, - 173, - 23, - 39 - ] - }, - { - "name": "LocalTokenRemoved", - "discriminator": [ - 181, - 204, - 1, - 95, - 2, - 50, - 66, - 210 - ] - }, - { - "name": "TokenPairLinked", - "discriminator": [ - 2, - 14, - 177, - 64, - 155, - 93, - 196, - 141 - ] - }, - { - "name": "TokenPairUnlinked", - "discriminator": [ - 78, - 232, - 230, - 208, - 180, - 212, - 246, - 72 - ] - }, - { - "name": "Pause", - "discriminator": [ - 194, - 251, - 232, - 196, - 118, - 95, - 111, - 219 - ] - }, - { - "name": "Unpause", - "discriminator": [ - 241, - 149, - 104, - 90, - 199, - 136, - 219, - 146 - ] - }, - { - "name": "TokenCustodyBurned", - "discriminator": [ - 219, - 143, - 107, - 226, - 67, - 75, - 178, - 46 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "InvalidAuthority", - "msg": "Invalid authority" - }, - { - "code": 6001, - "name": "InvalidTokenMessengerState", - "msg": "Invalid token messenger state" - }, - { - "code": 6002, - "name": "InvalidTokenMessenger", - "msg": "Invalid token messenger" - }, - { - "code": 6003, - "name": "InvalidOwner", - "msg": "Invalid owner" - }, - { - "code": 6004, - "name": "MalformedMessage", - "msg": "Malformed message" - }, - { - "code": 6005, - "name": "InvalidMessageBodyVersion", - "msg": "Invalid message body version" - }, - { - "code": 6006, - "name": "InvalidAmount", - "msg": "Invalid amount" - }, - { - "code": 6007, - "name": "InvalidDestinationDomain", - "msg": "Invalid destination domain" - }, - { - "code": 6008, - "name": "InvalidDestinationCaller", - "msg": "Invalid destination caller" - }, - { - "code": 6009, - "name": "InvalidMintRecipient", - "msg": "Invalid mint recipient" - }, - { - "code": 6010, - "name": "InvalidSender", - "msg": "Invalid sender" - }, - { - "code": 6011, - "name": "InvalidTokenPair", - "msg": "Invalid token pair" - }, - { - "code": 6012, - "name": "InvalidTokenMint", - "msg": "Invalid token mint" - } - ], - "types": [ - { - "name": "AcceptOwnershipParams", - "type": { - "kind": "struct" - } - }, - { - "name": "AddRemoteTokenMessengerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "token_messenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "DepositForBurnWithCallerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "destination_domain", - "type": "u32" - }, - { - "name": "mint_recipient", - "type": "pubkey" - }, - { - "name": "destination_caller", - "type": "pubkey" - } - ] - } - }, - { - "name": "DepositForBurnParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "destination_domain", - "type": "u32" - }, - { - "name": "mint_recipient", - "type": "pubkey" - } - ] - } - }, - { - "name": "HandleReceiveMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "sender", - "type": "pubkey" - }, - { - "name": "message_body", - "type": "bytes" - }, - { - "name": "authority_bump", - "type": "u8" - } - ] - } - }, - { - "name": "InitializeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "token_controller", - "type": "pubkey" - }, - { - "name": "local_message_transmitter", - "type": "pubkey" - }, - { - "name": "message_body_version", - "type": "u32" - } - ] - } - }, - { - "name": "RemoveRemoteTokenMessengerParams", - "type": { - "kind": "struct" - } - }, - { - "name": "ReplaceDepositForBurnParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "original_message", - "type": "bytes" - }, - { - "name": "original_attestation", - "type": "bytes" - }, - { - "name": "new_destination_caller", - "type": "pubkey" - }, - { - "name": "new_mint_recipient", - "type": "pubkey" - } - ] - } - }, - { - "name": "TransferOwnershipParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "AddLocalTokenParams", - "type": { - "kind": "struct" - } - }, - { - "name": "BurnTokenCustodyParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "LinkTokenPairParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "local_token", - "type": "pubkey" - }, - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "remote_token", - "type": "pubkey" - } - ] - } - }, - { - "name": "PauseParams", - "type": { - "kind": "struct" - } - }, - { - "name": "RemoveLocalTokenParams", - "type": { - "kind": "struct" - } - }, - { - "name": "SetMaxBurnAmountPerMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "burn_limit_per_message", - "type": "u64" - } - ] - } - }, - { - "name": "SetTokenControllerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "token_controller", - "type": "pubkey" - } - ] - } - }, - { - "name": "UninkTokenPairParams", - "type": { - "kind": "struct" - } - }, - { - "name": "UnpauseParams", - "type": { - "kind": "struct" - } - }, - { - "name": "UpdatePauserParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_pauser", - "type": "pubkey" - } - ] - } - }, - { - "name": "TokenMinterError", - "type": { - "kind": "enum", - "variants": [ - { - "name": "InvalidAuthority" - }, - { - "name": "InvalidTokenMinterState" - }, - { - "name": "ProgramPaused" - }, - { - "name": "InvalidTokenPairState" - }, - { - "name": "InvalidLocalTokenState" - }, - { - "name": "InvalidPauser" - }, - { - "name": "InvalidTokenController" - }, - { - "name": "BurnAmountExceeded" - }, - { - "name": "InvalidAmount" - } - ] - } - }, - { - "name": "TokenMessenger", - "type": { - "kind": "struct", - "fields": [ - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "pending_owner", - "type": "pubkey" - }, - { - "name": "local_message_transmitter", - "type": "pubkey" - }, - { - "name": "message_body_version", - "type": "u32" - }, - { - "name": "authority_bump", - "type": "u8" - } - ] - } - }, - { - "name": "RemoteTokenMessenger", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "token_messenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "TokenMinter", - "type": { - "kind": "struct", - "fields": [ - { - "name": "token_controller", - "type": "pubkey" - }, - { - "name": "pauser", - "type": "pubkey" - }, - { - "name": "paused", - "type": "bool" - }, - { - "name": "bump", - "type": "u8" - } - ] - } - }, - { - "name": "TokenPair", - "type": { - "kind": "struct", - "fields": [ - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "remote_token", - "type": "pubkey" - }, - { - "name": "local_token", - "type": "pubkey" - }, - { - "name": "bump", - "type": "u8" - } - ] - } - }, - { - "name": "LocalToken", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "burn_limit_per_message", - "type": "u64" - }, - { - "name": "messages_sent", - "type": "u64" - }, - { - "name": "messages_received", - "type": "u64" - }, - { - "name": "amount_sent", - "type": "u128" - }, - { - "name": "amount_received", - "type": "u128" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "custody_bump", - "type": "u8" - } - ] - } - }, - { - "name": "OwnershipTransferStarted", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previous_owner", - "type": "pubkey" - }, - { - "name": "new_owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "OwnershipTransferred", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previous_owner", - "type": "pubkey" - }, - { - "name": "new_owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "DepositForBurn", - "type": { - "kind": "struct", - "fields": [ - { - "name": "nonce", - "type": "u64" - }, - { - "name": "burn_token", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "mint_recipient", - "type": "pubkey" - }, - { - "name": "destination_domain", - "type": "u32" - }, - { - "name": "destination_token_messenger", - "type": "pubkey" - }, - { - "name": "destination_caller", - "type": "pubkey" - } - ] - } - }, - { - "name": "MintAndWithdraw", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mint_recipient", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "mint_token", - "type": "pubkey" - } - ] - } - }, - { - "name": "RemoteTokenMessengerAdded", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "token_messenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "RemoteTokenMessengerRemoved", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "token_messenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "SetTokenController", - "type": { - "kind": "struct", - "fields": [ - { - "name": "token_controller", - "type": "pubkey" - } - ] - } - }, - { - "name": "PauserChanged", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_address", - "type": "pubkey" - } - ] - } - }, - { - "name": "SetBurnLimitPerMessage", - "type": { - "kind": "struct", - "fields": [ - { - "name": "token", - "type": "pubkey" - }, - { - "name": "burn_limit_per_message", - "type": "u64" - } - ] - } - }, - { - "name": "LocalTokenAdded", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "LocalTokenRemoved", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "TokenPairLinked", - "type": { - "kind": "struct", - "fields": [ - { - "name": "local_token", - "type": "pubkey" - }, - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "remote_token", - "type": "pubkey" - } - ] - } - }, - { - "name": "TokenPairUnlinked", - "type": { - "kind": "struct", - "fields": [ - { - "name": "local_token", - "type": "pubkey" - }, - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "remote_token", - "type": "pubkey" - } - ] - } - }, - { - "name": "Pause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "Unpause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "TokenCustodyBurned", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody_token_account", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/src/svm/assets/idl/token_messenger_minter_v2.json b/src/svm/assets/idl/token_messenger_minter_v2.json deleted file mode 100644 index 670896b85..000000000 --- a/src/svm/assets/idl/token_messenger_minter_v2.json +++ /dev/null @@ -1,4441 +0,0 @@ -{ - "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe", - "metadata": { - "name": "token_messenger_minter_v2", - "version": "0.2.0", - "spec": "0.1.0", - "description": "Token Messenger and Minter for Cross-Chain Transfer Protocol V2", - "repository": "https://github.com/circlefin/solana-cctp-contracts" - }, - "instructions": [ - { - "name": "accept_ownership", - "discriminator": [ - 172, - 23, - 43, - 13, - 238, - 213, - 85, - 150 - ], - "accounts": [ - { - "name": "pending_owner", - "signer": true, - "relations": [ - "token_messenger" - ] - }, - { - "name": "token_messenger", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "AcceptOwnershipParams" - } - } - } - ] - }, - { - "name": "add_local_token", - "discriminator": [ - 213, - 199, - 205, - 18, - 98, - 124, - 73, - 198 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "token_controller", - "signer": true, - "relations": [ - "token_minter" - ] - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "local_token_mint" - } - ] - } - }, - { - "name": "custody_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "local_token_mint" - } - ] - } - }, - { - "name": "local_token_mint" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "AddLocalTokenParams" - } - } - } - ] - }, - { - "name": "add_remote_token_messenger", - "discriminator": [ - 12, - 149, - 172, - 165, - 111, - 202, - 24, - 33 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "owner", - "signer": true, - "relations": [ - "token_messenger" - ] - }, - { - "name": "token_messenger" - }, - { - "name": "remote_token_messenger", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 109, - 111, - 116, - 101, - 95, - 116, - 111, - 107, - 101, - 110, - 95, - 109, - 101, - 115, - 115, - 101, - 110, - 103, - 101, - 114 - ] - }, - { - "kind": "arg", - "path": "params.domain" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "AddRemoteTokenMessengerParams" - } - } - } - ] - }, - { - "name": "burn_token_custody", - "discriminator": [ - 233, - 136, - 180, - 175, - 112, - 41, - 62, - 71 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "token_controller", - "signer": true, - "relations": [ - "token_minter" - ] - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "LocalToken" - } - ] - } - }, - { - "name": "custody_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "LocalToken" - } - ] - } - }, - { - "name": "custody_token_mint", - "writable": true - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "BurnTokenCustodyParams" - } - } - } - ] - }, - { - "name": "denylist_account", - "discriminator": [ - 101, - 116, - 197, - 112, - 81, - 249, - 75, - 194 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "denylister", - "signer": true, - "relations": [ - "token_messenger" - ] - }, - { - "name": "token_messenger" - }, - { - "name": "denylist_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 100, - 101, - 110, - 121, - 108, - 105, - 115, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "arg", - "path": "params.account" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "DenylistParams" - } - } - } - ] - }, - { - "name": "deposit_for_burn", - "discriminator": [ - 215, - 60, - 61, - 46, - 114, - 55, - 128, - 176 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "burn_token_account" - ] - }, - { - "name": "event_rent_payer", - "writable": true, - "signer": true - }, - { - "name": "sender_authority_pda", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 101, - 110, - 100, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "burn_token_account", - "writable": true - }, - { - "name": "denylist_account", - "docs": [ - "Account is denylisted if the account exists at the expected PDA." - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 100, - 101, - 110, - 121, - 108, - 105, - 115, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "owner" - } - ] - } - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "token_messenger" - }, - { - "name": "remote_token_messenger" - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "burn_token_mint" - } - ] - } - }, - { - "name": "burn_token_mint", - "writable": true - }, - { - "name": "message_sent_event_data", - "writable": true, - "signer": true - }, - { - "name": "message_transmitter_program", - "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" - }, - { - "name": "token_messenger_minter_program", - "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "DepositForBurnParams" - } - } - } - ] - }, - { - "name": "deposit_for_burn_with_hook", - "discriminator": [ - 111, - 245, - 62, - 131, - 204, - 108, - 223, - 155 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "burn_token_account" - ] - }, - { - "name": "event_rent_payer", - "writable": true, - "signer": true - }, - { - "name": "sender_authority_pda", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 101, - 110, - 100, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "burn_token_account", - "writable": true - }, - { - "name": "denylist_account", - "docs": [ - "Account is denylisted if the account exists at the expected PDA." - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 100, - 101, - 110, - 121, - 108, - 105, - 115, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "owner" - } - ] - } - }, - { - "name": "message_transmitter", - "writable": true - }, - { - "name": "token_messenger" - }, - { - "name": "remote_token_messenger" - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "burn_token_mint" - } - ] - } - }, - { - "name": "burn_token_mint", - "writable": true - }, - { - "name": "message_sent_event_data", - "writable": true, - "signer": true - }, - { - "name": "message_transmitter_program", - "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" - }, - { - "name": "token_messenger_minter_program", - "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "DepositForBurnWithHookParams" - } - } - } - ] - }, - { - "name": "handle_receive_finalized_message", - "discriminator": [ - 186, - 252, - 239, - 70, - 86, - 180, - 110, - 95 - ], - "accounts": [ - { - "name": "authority_pda", - "signer": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 115, - 115, - 97, - 103, - 101, - 95, - 116, - 114, - 97, - 110, - 115, - 109, - 105, - 116, - 116, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "const", - "value": [ - 166, - 95, - 200, - 29, - 15, - 239, - 168, - 134, - 12, - 179, - 184, - 63, - 8, - 155, - 2, - 36, - 190, - 138, - 102, - 135, - 183, - 174, - 73, - 245, - 148, - 192, - 185, - 180, - 215, - 233, - 56, - 147 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 166, - 95, - 200, - 28, - 225, - 158, - 220, - 210, - 210, - 195, - 64, - 176, - 47, - 166, - 27, - 225, - 213, - 186, - 221, - 225, - 89, - 40, - 51, - 221, - 249, - 32, - 9, - 216, - 207, - 104, - 84, - 85 - ] - } - } - }, - { - "name": "token_messenger" - }, - { - "name": "remote_token_messenger" - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "LocalToken" - } - ] - } - }, - { - "name": "token_pair" - }, - { - "name": "fee_recipient_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "token_messenger.fee_recipient", - "account": "TokenMessenger" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "LocalToken" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "recipient_token_account", - "writable": true - }, - { - "name": "custody_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "LocalToken" - } - ] - } - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "HandleReceiveMessageParams" - } - } - } - ] - }, - { - "name": "handle_receive_unfinalized_message", - "discriminator": [ - 200, - 169, - 175, - 20, - 200, - 58, - 182, - 61 - ], - "accounts": [ - { - "name": "authority_pda", - "signer": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 115, - 115, - 97, - 103, - 101, - 95, - 116, - 114, - 97, - 110, - 115, - 109, - 105, - 116, - 116, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "const", - "value": [ - 166, - 95, - 200, - 29, - 15, - 239, - 168, - 134, - 12, - 179, - 184, - 63, - 8, - 155, - 2, - 36, - 190, - 138, - 102, - 135, - 183, - 174, - 73, - 245, - 148, - 192, - 185, - 180, - 215, - 233, - 56, - 147 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 166, - 95, - 200, - 28, - 225, - 158, - 220, - 210, - 210, - 195, - 64, - 176, - 47, - 166, - 27, - 225, - 213, - 186, - 221, - 225, - 89, - 40, - 51, - 221, - 249, - 32, - 9, - 216, - 207, - 104, - 84, - 85 - ] - } - } - }, - { - "name": "token_messenger" - }, - { - "name": "remote_token_messenger" - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "LocalToken" - } - ] - } - }, - { - "name": "token_pair" - }, - { - "name": "fee_recipient_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "token_messenger.fee_recipient", - "account": "TokenMessenger" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "LocalToken" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "recipient_token_account", - "writable": true - }, - { - "name": "custody_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "LocalToken" - } - ] - } - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "HandleReceiveMessageParams" - } - } - } - ] - }, - { - "name": "initialize", - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "upgrade_authority", - "signer": true - }, - { - "name": "authority_pda", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 101, - 110, - 100, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "token_messenger", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 109, - 101, - 115, - 115, - 101, - 110, - 103, - 101, - 114 - ] - } - ] - } - }, - { - "name": "token_minter", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 109, - 105, - 110, - 116, - 101, - 114 - ] - } - ] - } - }, - { - "name": "token_messenger_minter_program_data" - }, - { - "name": "token_messenger_minter_program", - "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "InitializeParams" - } - } - } - ] - }, - { - "name": "link_token_pair", - "discriminator": [ - 68, - 162, - 24, - 104, - 125, - 46, - 130, - 12 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "token_controller", - "signer": true, - "relations": [ - "token_minter" - ] - }, - { - "name": "token_minter" - }, - { - "name": "token_pair", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 112, - 97, - 105, - 114 - ] - }, - { - "kind": "arg", - "path": "params.remote_domain" - }, - { - "kind": "arg", - "path": "params.remote_token" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "LinkTokenPairParams" - } - } - } - ] - }, - { - "name": "pause", - "discriminator": [ - 211, - 22, - 221, - 251, - 74, - 121, - 193, - 47 - ], - "accounts": [ - { - "name": "pauser", - "signer": true, - "relations": [ - "token_minter" - ] - }, - { - "name": "token_minter", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "PauseParams" - } - } - } - ] - }, - { - "name": "remove_local_token", - "discriminator": [ - 27, - 43, - 66, - 170, - 188, - 44, - 109, - 97 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "token_controller", - "signer": true, - "relations": [ - "token_minter" - ] - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "LocalToken" - } - ] - } - }, - { - "name": "custody_token_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "LocalToken" - } - ] - } - }, - { - "name": "custody_token_mint", - "writable": true - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "RemoveLocalTokenParams" - } - } - } - ] - }, - { - "name": "remove_remote_token_messenger", - "discriminator": [ - 65, - 114, - 66, - 85, - 169, - 98, - 177, - 146 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "owner", - "signer": true, - "relations": [ - "token_messenger" - ] - }, - { - "name": "token_messenger" - }, - { - "name": "remote_token_messenger", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 109, - 111, - 116, - 101, - 95, - 116, - 111, - 107, - 101, - 110, - 95, - 109, - 101, - 115, - 115, - 101, - 110, - 103, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "remote_token_messenger.domain", - "account": "RemoteTokenMessenger" - } - ] - } - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "RemoveRemoteTokenMessengerParams" - } - } - } - ] - }, - { - "name": "set_fee_recipient", - "discriminator": [ - 227, - 18, - 215, - 42, - 237, - 246, - 151, - 66 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "token_messenger" - ] - }, - { - "name": "token_messenger", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetFeeRecipientParams" - } - } - } - ] - }, - { - "name": "set_max_burn_amount_per_message", - "discriminator": [ - 30, - 128, - 145, - 240, - 70, - 237, - 109, - 207 - ], - "accounts": [ - { - "name": "token_controller", - "signer": true, - "relations": [ - "token_minter" - ] - }, - { - "name": "token_minter" - }, - { - "name": "local_token", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "LocalToken" - } - ] - } - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetMaxBurnAmountPerMessageParams" - } - } - } - ] - }, - { - "name": "set_min_fee", - "discriminator": [ - 114, - 198, - 35, - 3, - 41, - 196, - 194, - 246 - ], - "accounts": [ - { - "name": "min_fee_controller", - "signer": true, - "relations": [ - "token_messenger" - ] - }, - { - "name": "token_messenger", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetMinFeeParams" - } - } - } - ] - }, - { - "name": "set_min_fee_controller", - "discriminator": [ - 195, - 142, - 74, - 84, - 234, - 94, - 180, - 113 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "token_messenger" - ] - }, - { - "name": "token_messenger", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetMinFeeControllerParams" - } - } - } - ] - }, - { - "name": "set_token_controller", - "discriminator": [ - 88, - 6, - 98, - 10, - 79, - 59, - 15, - 24 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "token_messenger" - ] - }, - { - "name": "token_messenger" - }, - { - "name": "token_minter", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "SetTokenControllerParams" - } - } - } - ] - }, - { - "name": "transfer_ownership", - "discriminator": [ - 65, - 177, - 215, - 73, - 53, - 45, - 99, - 47 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "token_messenger" - ] - }, - { - "name": "token_messenger", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "TransferOwnershipParams" - } - } - } - ] - }, - { - "name": "undenylist_account", - "discriminator": [ - 57, - 36, - 43, - 168, - 62, - 172, - 33, - 39 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "denylister", - "signer": true, - "relations": [ - "token_messenger" - ] - }, - { - "name": "token_messenger" - }, - { - "name": "denylist_account", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 100, - 101, - 110, - 121, - 108, - 105, - 115, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "arg", - "path": "params.account" - } - ] - } - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UndenylistParams" - } - } - } - ] - }, - { - "name": "unlink_token_pair", - "discriminator": [ - 52, - 198, - 100, - 114, - 104, - 174, - 85, - 58 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "token_controller", - "signer": true, - "relations": [ - "token_minter" - ] - }, - { - "name": "token_minter" - }, - { - "name": "token_pair", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 112, - 97, - 105, - 114 - ] - }, - { - "kind": "account", - "path": "token_pair.remote_domain", - "account": "TokenPair" - }, - { - "kind": "account", - "path": "token_pair.remote_token", - "account": "TokenPair" - } - ] - } - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UninkTokenPairParams" - } - } - } - ] - }, - { - "name": "unpause", - "discriminator": [ - 169, - 144, - 4, - 38, - 10, - 141, - 188, - 255 - ], - "accounts": [ - { - "name": "pauser", - "signer": true, - "relations": [ - "token_minter" - ] - }, - { - "name": "token_minter", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UnpauseParams" - } - } - } - ] - }, - { - "name": "update_denylister", - "discriminator": [ - 193, - 66, - 198, - 201, - 84, - 57, - 14, - 222 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "token_messenger" - ] - }, - { - "name": "token_messenger", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UpdateDenylisterParams" - } - } - } - ] - }, - { - "name": "update_pauser", - "discriminator": [ - 140, - 171, - 211, - 132, - 57, - 201, - 16, - 254 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "token_messenger" - ] - }, - { - "name": "token_messenger" - }, - { - "name": "token_minter", - "writable": true - }, - { - "name": "event_authority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "UpdatePauserParams" - } - } - } - ] - } - ], - "accounts": [ - { - "name": "DenylistedAccount", - "discriminator": [ - 186, - 58, - 212, - 239, - 102, - 131, - 157, - 146 - ] - }, - { - "name": "LocalToken", - "discriminator": [ - 159, - 131, - 58, - 170, - 193, - 84, - 128, - 182 - ] - }, - { - "name": "MessageTransmitter", - "discriminator": [ - 71, - 40, - 180, - 142, - 19, - 203, - 35, - 252 - ] - }, - { - "name": "RemoteTokenMessenger", - "discriminator": [ - 105, - 115, - 174, - 34, - 95, - 233, - 138, - 252 - ] - }, - { - "name": "TokenMessenger", - "discriminator": [ - 162, - 4, - 242, - 52, - 147, - 243, - 221, - 96 - ] - }, - { - "name": "TokenMinter", - "discriminator": [ - 122, - 133, - 84, - 63, - 57, - 159, - 171, - 206 - ] - }, - { - "name": "TokenPair", - "discriminator": [ - 17, - 214, - 45, - 176, - 229, - 149, - 197, - 71 - ] - } - ], - "events": [ - { - "name": "Denylisted", - "discriminator": [ - 20, - 145, - 173, - 200, - 182, - 17, - 234, - 154 - ] - }, - { - "name": "DenylisterChanged", - "discriminator": [ - 249, - 170, - 81, - 180, - 185, - 175, - 138, - 72 - ] - }, - { - "name": "DepositForBurn", - "discriminator": [ - 144, - 252, - 145, - 146, - 6, - 74, - 167, - 235 - ] - }, - { - "name": "FeeRecipientSet", - "discriminator": [ - 99, - 140, - 80, - 35, - 245, - 176, - 179, - 110 - ] - }, - { - "name": "LocalTokenAdded", - "discriminator": [ - 146, - 8, - 224, - 150, - 122, - 173, - 23, - 39 - ] - }, - { - "name": "LocalTokenRemoved", - "discriminator": [ - 181, - 204, - 1, - 95, - 2, - 50, - 66, - 210 - ] - }, - { - "name": "MinFeeControllerSet", - "discriminator": [ - 239, - 12, - 122, - 105, - 231, - 114, - 13, - 196 - ] - }, - { - "name": "MinFeeSet", - "discriminator": [ - 60, - 127, - 101, - 230, - 216, - 129, - 188, - 98 - ] - }, - { - "name": "MintAndWithdraw", - "discriminator": [ - 75, - 67, - 229, - 70, - 162, - 126, - 0, - 71 - ] - }, - { - "name": "OwnershipTransferStarted", - "discriminator": [ - 183, - 253, - 239, - 246, - 140, - 179, - 133, - 105 - ] - }, - { - "name": "OwnershipTransferred", - "discriminator": [ - 172, - 61, - 205, - 183, - 250, - 50, - 38, - 98 - ] - }, - { - "name": "Pause", - "discriminator": [ - 194, - 251, - 232, - 196, - 118, - 95, - 111, - 219 - ] - }, - { - "name": "PauserChanged", - "discriminator": [ - 142, - 157, - 158, - 87, - 127, - 8, - 119, - 55 - ] - }, - { - "name": "RemoteTokenMessengerAdded", - "discriminator": [ - 251, - 29, - 63, - 244, - 48, - 114, - 210, - 175 - ] - }, - { - "name": "RemoteTokenMessengerRemoved", - "discriminator": [ - 255, - 121, - 137, - 39, - 230, - 125, - 11, - 30 - ] - }, - { - "name": "SetBurnLimitPerMessage", - "discriminator": [ - 98, - 152, - 88, - 191, - 245, - 30, - 27, - 209 - ] - }, - { - "name": "SetTokenController", - "discriminator": [ - 193, - 44, - 243, - 83, - 230, - 72, - 120, - 216 - ] - }, - { - "name": "TokenCustodyBurned", - "discriminator": [ - 219, - 143, - 107, - 226, - 67, - 75, - 178, - 46 - ] - }, - { - "name": "TokenPairLinked", - "discriminator": [ - 2, - 14, - 177, - 64, - 155, - 93, - 196, - 141 - ] - }, - { - "name": "TokenPairUnlinked", - "discriminator": [ - 78, - 232, - 230, - 208, - 180, - 212, - 246, - 72 - ] - }, - { - "name": "UnDenylisted", - "discriminator": [ - 150, - 39, - 227, - 20, - 162, - 180, - 5, - 242 - ] - }, - { - "name": "Unpause", - "discriminator": [ - 241, - 149, - 104, - 90, - 199, - 136, - 219, - 146 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "InvalidAuthority", - "msg": "Invalid authority" - }, - { - "code": 6001, - "name": "InvalidTokenMinterState", - "msg": "Invalid token minter state" - }, - { - "code": 6002, - "name": "ProgramPaused", - "msg": "Instruction is not allowed at this time" - }, - { - "code": 6003, - "name": "InvalidTokenPairState", - "msg": "Invalid token pair state" - }, - { - "code": 6004, - "name": "InvalidLocalTokenState", - "msg": "Invalid local token state" - }, - { - "code": 6005, - "name": "InvalidPauser", - "msg": "Invalid pauser" - }, - { - "code": 6006, - "name": "InvalidTokenController", - "msg": "Invalid token controller" - }, - { - "code": 6007, - "name": "BurnAmountExceeded", - "msg": "Burn amount exceeded" - }, - { - "code": 6008, - "name": "InvalidAmount", - "msg": "Invalid amount" - } - ], - "types": [ - { - "name": "AcceptOwnershipParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "AddLocalTokenParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "AddRemoteTokenMessengerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "token_messenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "BurnTokenCustodyParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "DenylistParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "account", - "type": "pubkey" - } - ] - } - }, - { - "name": "Denylisted", - "type": { - "kind": "struct", - "fields": [ - { - "name": "account", - "type": "pubkey" - } - ] - } - }, - { - "name": "DenylistedAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "account", - "type": "pubkey" - } - ] - } - }, - { - "name": "DenylisterChanged", - "type": { - "kind": "struct", - "fields": [ - { - "name": "old_denylister", - "type": "pubkey" - }, - { - "name": "new_denylister", - "type": "pubkey" - } - ] - } - }, - { - "name": "DepositForBurn", - "type": { - "kind": "struct", - "fields": [ - { - "name": "burn_token", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "mint_recipient", - "type": "pubkey" - }, - { - "name": "destination_domain", - "type": "u32" - }, - { - "name": "destination_token_messenger", - "type": "pubkey" - }, - { - "name": "destination_caller", - "type": "pubkey" - }, - { - "name": "max_fee", - "type": "u64" - }, - { - "name": "min_finality_threshold", - "type": "u32" - }, - { - "name": "hook_data", - "type": "bytes" - } - ] - } - }, - { - "name": "DepositForBurnParams", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "destination_domain", - "type": "u32" - }, - { - "name": "mint_recipient", - "type": "pubkey" - }, - { - "name": "destination_caller", - "type": "pubkey" - }, - { - "name": "max_fee", - "type": "u64" - }, - { - "name": "min_finality_threshold", - "type": "u32" - } - ] - } - }, - { - "name": "DepositForBurnWithHookParams", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "destination_domain", - "type": "u32" - }, - { - "name": "mint_recipient", - "type": "pubkey" - }, - { - "name": "destination_caller", - "type": "pubkey" - }, - { - "name": "max_fee", - "type": "u64" - }, - { - "name": "min_finality_threshold", - "type": "u32" - }, - { - "name": "hook_data", - "type": "bytes" - } - ] - } - }, - { - "name": "FeeRecipientSet", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_fee_recipient", - "type": "pubkey" - } - ] - } - }, - { - "name": "HandleReceiveMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "sender", - "type": "pubkey" - }, - { - "name": "finality_threshold_executed", - "type": "u32" - }, - { - "name": "message_body", - "type": "bytes" - }, - { - "name": "authority_bump", - "type": "u8" - } - ] - } - }, - { - "name": "InitializeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "token_controller", - "type": "pubkey" - }, - { - "name": "denylister", - "type": "pubkey" - }, - { - "name": "fee_recipient", - "type": "pubkey" - }, - { - "name": "min_fee_controller", - "type": "pubkey" - }, - { - "name": "min_fee", - "type": "u32" - }, - { - "name": "message_body_version", - "type": "u32" - } - ] - } - }, - { - "name": "LinkTokenPairParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "local_token", - "type": "pubkey" - }, - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "remote_token", - "type": "pubkey" - } - ] - } - }, - { - "name": "LocalToken", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "burn_limit_per_message", - "type": "u64" - }, - { - "name": "messages_sent", - "type": "u64" - }, - { - "name": "messages_received", - "type": "u64" - }, - { - "name": "amount_sent", - "type": "u128" - }, - { - "name": "amount_received", - "type": "u128" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "custody_bump", - "type": "u8" - } - ] - } - }, - { - "name": "LocalTokenAdded", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "LocalTokenRemoved", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "MessageTransmitter", - "docs": [ - "Main state of the MessageTransmitter program" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "pending_owner", - "type": "pubkey" - }, - { - "name": "attester_manager", - "type": "pubkey" - }, - { - "name": "pauser", - "type": "pubkey" - }, - { - "name": "paused", - "type": "bool" - }, - { - "name": "local_domain", - "type": "u32" - }, - { - "name": "version", - "type": "u32" - }, - { - "name": "signature_threshold", - "type": "u32" - }, - { - "name": "enabled_attesters", - "type": { - "vec": "pubkey" - } - }, - { - "name": "max_message_body_size", - "type": "u64" - } - ] - } - }, - { - "name": "MinFeeControllerSet", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_min_fee_controller", - "type": "pubkey" - } - ] - } - }, - { - "name": "MinFeeSet", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_min_fee", - "type": "u32" - } - ] - } - }, - { - "name": "MintAndWithdraw", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mint_recipient", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "mint_token", - "type": "pubkey" - }, - { - "name": "fee_collected", - "type": "u64" - } - ] - } - }, - { - "name": "OwnershipTransferStarted", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previous_owner", - "type": "pubkey" - }, - { - "name": "new_owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "OwnershipTransferred", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previous_owner", - "type": "pubkey" - }, - { - "name": "new_owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "Pause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "PauseParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "PauserChanged", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_address", - "type": "pubkey" - } - ] - } - }, - { - "name": "RemoteTokenMessenger", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "token_messenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "RemoteTokenMessengerAdded", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "token_messenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "RemoteTokenMessengerRemoved", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "token_messenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "RemoveLocalTokenParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "RemoveRemoteTokenMessengerParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "SetBurnLimitPerMessage", - "type": { - "kind": "struct", - "fields": [ - { - "name": "token", - "type": "pubkey" - }, - { - "name": "burn_limit_per_message", - "type": "u64" - } - ] - } - }, - { - "name": "SetFeeRecipientParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_fee_recipient", - "type": "pubkey" - } - ] - } - }, - { - "name": "SetMaxBurnAmountPerMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "burn_limit_per_message", - "type": "u64" - } - ] - } - }, - { - "name": "SetMinFeeControllerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_min_fee_controller", - "type": "pubkey" - } - ] - } - }, - { - "name": "SetMinFeeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_min_fee", - "type": "u32" - } - ] - } - }, - { - "name": "SetTokenController", - "type": { - "kind": "struct", - "fields": [ - { - "name": "token_controller", - "type": "pubkey" - } - ] - } - }, - { - "name": "SetTokenControllerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "token_controller", - "type": "pubkey" - } - ] - } - }, - { - "name": "TokenCustodyBurned", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody_token_account", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "TokenMessenger", - "type": { - "kind": "struct", - "fields": [ - { - "name": "denylister", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "pending_owner", - "type": "pubkey" - }, - { - "name": "message_body_version", - "type": "u32" - }, - { - "name": "authority_bump", - "type": "u8" - }, - { - "name": "fee_recipient", - "type": "pubkey" - }, - { - "name": "min_fee_controller", - "type": "pubkey" - }, - { - "name": "min_fee", - "type": "u32" - } - ] - } - }, - { - "name": "TokenMinter", - "type": { - "kind": "struct", - "fields": [ - { - "name": "token_controller", - "type": "pubkey" - }, - { - "name": "pauser", - "type": "pubkey" - }, - { - "name": "paused", - "type": "bool" - }, - { - "name": "bump", - "type": "u8" - } - ] - } - }, - { - "name": "TokenPair", - "type": { - "kind": "struct", - "fields": [ - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "remote_token", - "type": "pubkey" - }, - { - "name": "local_token", - "type": "pubkey" - }, - { - "name": "bump", - "type": "u8" - } - ] - } - }, - { - "name": "TokenPairLinked", - "type": { - "kind": "struct", - "fields": [ - { - "name": "local_token", - "type": "pubkey" - }, - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "remote_token", - "type": "pubkey" - } - ] - } - }, - { - "name": "TokenPairUnlinked", - "type": { - "kind": "struct", - "fields": [ - { - "name": "local_token", - "type": "pubkey" - }, - { - "name": "remote_domain", - "type": "u32" - }, - { - "name": "remote_token", - "type": "pubkey" - } - ] - } - }, - { - "name": "TransferOwnershipParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_owner", - "type": "pubkey" - } - ] - } - }, - { - "name": "UnDenylisted", - "type": { - "kind": "struct", - "fields": [ - { - "name": "account", - "type": "pubkey" - } - ] - } - }, - { - "name": "UndenylistParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "account", - "type": "pubkey" - } - ] - } - }, - { - "name": "UninkTokenPairParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "Unpause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "UnpauseParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "UpdateDenylisterParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_denylister", - "type": "pubkey" - } - ] - } - }, - { - "name": "UpdatePauserParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "new_pauser", - "type": "pubkey" - } - ] - } - } - ] -} \ No newline at end of file diff --git a/src/svm/assets/index.ts b/src/svm/assets/index.ts deleted file mode 100644 index a9f2785d3..000000000 --- a/src/svm/assets/index.ts +++ /dev/null @@ -1,12 +0,0 @@ -// This file has been autogenerated. Do not edit manually. -// Generated by a script. - -export * from "./idl"; -export {MessageTransmitterV2 as MessageTransmitterV2Anchor} from "./message_transmitter_v2"; -export {MessageTransmitter as MessageTransmitterAnchor} from "./message_transmitter"; -export {MulticallHandler as MulticallHandlerAnchor} from "./multicall_handler"; -export {SponsoredCctpSrcPeriphery as SponsoredCctpSrcPeripheryAnchor} from "./sponsored_cctp_src_periphery"; -export {SvmSpoke as SvmSpokeAnchor} from "./svm_spoke"; -export {Test as TestAnchor} from "./test"; -export {TokenMessengerMinterV2 as TokenMessengerMinterV2Anchor} from "./token_messenger_minter_v2"; -export {TokenMessengerMinter as TokenMessengerMinterAnchor} from "./token_messenger_minter"; diff --git a/src/svm/assets/message_transmitter.ts b/src/svm/assets/message_transmitter.ts deleted file mode 100644 index 7f54e1107..000000000 --- a/src/svm/assets/message_transmitter.ts +++ /dev/null @@ -1,1681 +0,0 @@ -/** - * Program IDL in camelCase format in order to be used in JS/TS. - * - * Note that this is only a type helper and is not the actual IDL. The original - * IDL can be found at `target/idl/message_transmitter.json`. - */ -export type MessageTransmitter = { - "address": "CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd", - "metadata": { - "name": "messageTransmitter", - "version": "0.1.0", - "spec": "0.1.0" - }, - "instructions": [ - { - "name": "initialize", - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "upgradeAuthority", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "messageTransmitterProgramData" - }, - { - "name": "messageTransmitterProgram" - }, - { - "name": "systemProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "initializeParams" - } - } - } - ] - }, - { - "name": "transferOwnership", - "discriminator": [ - 65, - 177, - 215, - 73, - 53, - 45, - 99, - 47 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "transferOwnershipParams" - } - } - } - ] - }, - { - "name": "acceptOwnership", - "discriminator": [ - 172, - 23, - 43, - 13, - 238, - 213, - 85, - 150 - ], - "accounts": [ - { - "name": "pendingOwner", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "acceptOwnershipParams" - } - } - } - ] - }, - { - "name": "updatePauser", - "discriminator": [ - 140, - 171, - 211, - 132, - 57, - 201, - 16, - 254 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "updatePauserParams" - } - } - } - ] - }, - { - "name": "updateAttesterManager", - "discriminator": [ - 175, - 245, - 178, - 104, - 85, - 179, - 71, - 16 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "updateAttesterManagerParams" - } - } - } - ] - }, - { - "name": "pause", - "discriminator": [ - 211, - 22, - 221, - 251, - 74, - 121, - 193, - 47 - ], - "accounts": [ - { - "name": "pauser", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "pauseParams" - } - } - } - ] - }, - { - "name": "unpause", - "discriminator": [ - 169, - 144, - 4, - 38, - 10, - 141, - 188, - 255 - ], - "accounts": [ - { - "name": "pauser", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "unpauseParams" - } - } - } - ] - }, - { - "name": "setMaxMessageBodySize", - "discriminator": [ - 168, - 178, - 8, - 117, - 217, - 167, - 219, - 31 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setMaxMessageBodySizeParams" - } - } - } - ] - }, - { - "name": "enableAttester", - "discriminator": [ - 2, - 11, - 193, - 115, - 5, - 148, - 4, - 198 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "attesterManager", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "systemProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "enableAttesterParams" - } - } - } - ] - }, - { - "name": "disableAttester", - "discriminator": [ - 61, - 171, - 131, - 95, - 172, - 15, - 227, - 229 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "attesterManager", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "systemProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "disableAttesterParams" - } - } - } - ] - }, - { - "name": "setSignatureThreshold", - "discriminator": [ - 163, - 19, - 154, - 168, - 82, - 209, - 214, - 219 - ], - "accounts": [ - { - "name": "attesterManager", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setSignatureThresholdParams" - } - } - } - ] - }, - { - "name": "sendMessage", - "discriminator": [ - 57, - 40, - 34, - 178, - 189, - 10, - 65, - 26 - ], - "accounts": [ - { - "name": "eventRentPayer", - "writable": true, - "signer": true - }, - { - "name": "senderAuthorityPda", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "messageSentEventData", - "writable": true, - "signer": true - }, - { - "name": "senderProgram" - }, - { - "name": "systemProgram" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "sendMessageParams" - } - } - } - ], - "returns": "u64" - }, - { - "name": "sendMessageWithCaller", - "discriminator": [ - 212, - 47, - 34, - 52, - 91, - 32, - 176, - 204 - ], - "accounts": [ - { - "name": "eventRentPayer", - "writable": true, - "signer": true - }, - { - "name": "senderAuthorityPda", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "messageSentEventData", - "writable": true, - "signer": true - }, - { - "name": "senderProgram" - }, - { - "name": "systemProgram" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "sendMessageWithCallerParams" - } - } - } - ], - "returns": "u64" - }, - { - "name": "replaceMessage", - "discriminator": [ - 189, - 189, - 210, - 163, - 149, - 205, - 69, - 229 - ], - "accounts": [ - { - "name": "eventRentPayer", - "writable": true, - "signer": true - }, - { - "name": "senderAuthorityPda", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "messageSentEventData", - "writable": true, - "signer": true - }, - { - "name": "senderProgram" - }, - { - "name": "systemProgram" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "replaceMessageParams" - } - } - } - ], - "returns": "u64" - }, - { - "name": "receiveMessage", - "discriminator": [ - 38, - 144, - 127, - 225, - 31, - 225, - 238, - 25 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "caller", - "signer": true - }, - { - "name": "authorityPda" - }, - { - "name": "messageTransmitter" - }, - { - "name": "usedNonces", - "writable": true - }, - { - "name": "receiver" - }, - { - "name": "systemProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "receiveMessageParams" - } - } - } - ] - }, - { - "name": "reclaimEventAccount", - "discriminator": [ - 94, - 198, - 180, - 159, - 131, - 236, - 15, - 174 - ], - "accounts": [ - { - "name": "payee", - "docs": [ - "rent SOL receiver, should match original rent payer" - ], - "writable": true, - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "messageSentEventData", - "writable": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "reclaimEventAccountParams" - } - } - } - ] - }, - { - "name": "getNoncePda", - "discriminator": [ - 114, - 70, - 229, - 212, - 223, - 50, - 33, - 39 - ], - "accounts": [ - { - "name": "messageTransmitter" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "getNoncePdaParams" - } - } - } - ], - "returns": "pubkey" - }, - { - "name": "isNonceUsed", - "discriminator": [ - 144, - 72, - 107, - 148, - 35, - 218, - 31, - 187 - ], - "accounts": [ - { - "name": "usedNonces", - "docs": [ - "Account will be explicitly loaded to avoid error when it's not initialized" - ] - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "isNonceUsedParams" - } - } - } - ], - "returns": "bool" - } - ], - "accounts": [ - { - "name": "messageSent", - "discriminator": [ - 131, - 100, - 133, - 56, - 166, - 225, - 151, - 60 - ] - }, - { - "name": "messageTransmitter", - "discriminator": [ - 71, - 40, - 180, - 142, - 19, - 203, - 35, - 252 - ] - }, - { - "name": "usedNonces", - "discriminator": [ - 60, - 112, - 18, - 72, - 138, - 181, - 100, - 138 - ] - } - ], - "events": [ - { - "name": "ownershipTransferStarted", - "discriminator": [ - 183, - 253, - 239, - 246, - 140, - 179, - 133, - 105 - ] - }, - { - "name": "ownershipTransferred", - "discriminator": [ - 172, - 61, - 205, - 183, - 250, - 50, - 38, - 98 - ] - }, - { - "name": "pauserChanged", - "discriminator": [ - 142, - 157, - 158, - 87, - 127, - 8, - 119, - 55 - ] - }, - { - "name": "attesterManagerUpdated", - "discriminator": [ - 5, - 97, - 191, - 108, - 44, - 189, - 69, - 88 - ] - }, - { - "name": "messageReceived", - "discriminator": [ - 231, - 68, - 47, - 77, - 173, - 241, - 157, - 166 - ] - }, - { - "name": "signatureThresholdUpdated", - "discriminator": [ - 156, - 99, - 103, - 200, - 15, - 38, - 122, - 189 - ] - }, - { - "name": "attesterEnabled", - "discriminator": [ - 88, - 57, - 14, - 133, - 5, - 219, - 62, - 190 - ] - }, - { - "name": "attesterDisabled", - "discriminator": [ - 186, - 136, - 186, - 14, - 229, - 2, - 121, - 211 - ] - }, - { - "name": "maxMessageBodySizeUpdated", - "discriminator": [ - 134, - 206, - 151, - 111, - 137, - 11, - 160, - 225 - ] - }, - { - "name": "pause", - "discriminator": [ - 194, - 251, - 232, - 196, - 118, - 95, - 111, - 219 - ] - }, - { - "name": "unpause", - "discriminator": [ - 241, - 149, - 104, - 90, - 199, - 136, - 219, - 146 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "invalidAuthority", - "msg": "Invalid authority" - }, - { - "code": 6001, - "name": "programPaused", - "msg": "Instruction is not allowed at this time" - }, - { - "code": 6002, - "name": "invalidMessageTransmitterState", - "msg": "Invalid message transmitter state" - }, - { - "code": 6003, - "name": "invalidSignatureThreshold", - "msg": "Invalid signature threshold" - }, - { - "code": 6004, - "name": "signatureThresholdAlreadySet", - "msg": "Signature threshold already set" - }, - { - "code": 6005, - "name": "invalidOwner", - "msg": "Invalid owner" - }, - { - "code": 6006, - "name": "invalidPauser", - "msg": "Invalid pauser" - }, - { - "code": 6007, - "name": "invalidAttesterManager", - "msg": "Invalid attester manager" - }, - { - "code": 6008, - "name": "invalidAttester", - "msg": "Invalid attester" - }, - { - "code": 6009, - "name": "attesterAlreadyEnabled", - "msg": "Attester already enabled" - }, - { - "code": 6010, - "name": "tooFewEnabledAttesters", - "msg": "Too few enabled attesters" - }, - { - "code": 6011, - "name": "signatureThresholdTooLow", - "msg": "Signature threshold is too low" - }, - { - "code": 6012, - "name": "attesterAlreadyDisabled", - "msg": "Attester already disabled" - }, - { - "code": 6013, - "name": "messageBodyLimitExceeded", - "msg": "Message body exceeds max size" - }, - { - "code": 6014, - "name": "invalidDestinationCaller", - "msg": "Invalid destination caller" - }, - { - "code": 6015, - "name": "invalidRecipient", - "msg": "Invalid message recipient" - }, - { - "code": 6016, - "name": "senderNotPermitted", - "msg": "Sender is not permitted" - }, - { - "code": 6017, - "name": "invalidSourceDomain", - "msg": "Invalid source domain" - }, - { - "code": 6018, - "name": "invalidDestinationDomain", - "msg": "Invalid destination domain" - }, - { - "code": 6019, - "name": "invalidMessageVersion", - "msg": "Invalid message version" - }, - { - "code": 6020, - "name": "invalidUsedNoncesAccount", - "msg": "Invalid used nonces account" - }, - { - "code": 6021, - "name": "invalidRecipientProgram", - "msg": "Invalid recipient program" - }, - { - "code": 6022, - "name": "invalidNonce", - "msg": "Invalid nonce" - }, - { - "code": 6023, - "name": "nonceAlreadyUsed", - "msg": "Nonce already used" - }, - { - "code": 6024, - "name": "messageTooShort", - "msg": "Message is too short" - }, - { - "code": 6025, - "name": "malformedMessage", - "msg": "Malformed message" - }, - { - "code": 6026, - "name": "invalidSignatureOrderOrDupe", - "msg": "Invalid signature order or dupe" - }, - { - "code": 6027, - "name": "invalidAttesterSignature", - "msg": "Invalid attester signature" - }, - { - "code": 6028, - "name": "invalidAttestationLength", - "msg": "Invalid attestation length" - }, - { - "code": 6029, - "name": "invalidSignatureRecoveryId", - "msg": "Invalid signature recovery ID" - }, - { - "code": 6030, - "name": "invalidSignatureSValue", - "msg": "Invalid signature S value" - }, - { - "code": 6031, - "name": "invalidMessageHash", - "msg": "Invalid message hash" - } - ], - "types": [ - { - "name": "acceptOwnershipParams", - "type": { - "kind": "struct" - } - }, - { - "name": "disableAttesterParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "enableAttesterParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newAttester", - "type": "pubkey" - } - ] - } - }, - { - "name": "getNoncePdaParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "nonce", - "type": "u64" - }, - { - "name": "sourceDomain", - "type": "u32" - } - ] - } - }, - { - "name": "initializeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "localDomain", - "type": "u32" - }, - { - "name": "attester", - "type": "pubkey" - }, - { - "name": "maxMessageBodySize", - "type": "u64" - }, - { - "name": "version", - "type": "u32" - } - ] - } - }, - { - "name": "isNonceUsedParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "nonce", - "type": "u64" - } - ] - } - }, - { - "name": "pauseParams", - "type": { - "kind": "struct" - } - }, - { - "name": "receiveMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "message", - "type": "bytes" - }, - { - "name": "attestation", - "type": "bytes" - } - ] - } - }, - { - "name": "handleReceiveMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "sender", - "type": "pubkey" - }, - { - "name": "messageBody", - "type": "bytes" - }, - { - "name": "authorityBump", - "type": "u8" - } - ] - } - }, - { - "name": "reclaimEventAccountParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attestation", - "type": "bytes" - } - ] - } - }, - { - "name": "replaceMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "originalMessage", - "type": "bytes" - }, - { - "name": "originalAttestation", - "type": "bytes" - }, - { - "name": "newMessageBody", - "type": "bytes" - }, - { - "name": "newDestinationCaller", - "type": "pubkey" - } - ] - } - }, - { - "name": "sendMessageWithCallerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "destinationDomain", - "type": "u32" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "messageBody", - "type": "bytes" - }, - { - "name": "destinationCaller", - "type": "pubkey" - } - ] - } - }, - { - "name": "sendMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "destinationDomain", - "type": "u32" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "messageBody", - "type": "bytes" - } - ] - } - }, - { - "name": "setMaxMessageBodySizeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newMaxMessageBodySize", - "type": "u64" - } - ] - } - }, - { - "name": "setSignatureThresholdParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newSignatureThreshold", - "type": "u32" - } - ] - } - }, - { - "name": "transferOwnershipParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newOwner", - "type": "pubkey" - } - ] - } - }, - { - "name": "unpauseParams", - "type": { - "kind": "struct" - } - }, - { - "name": "updateAttesterManagerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newAttesterManager", - "type": "pubkey" - } - ] - } - }, - { - "name": "updatePauserParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newPauser", - "type": "pubkey" - } - ] - } - }, - { - "name": "mathError", - "type": { - "kind": "enum", - "variants": [ - { - "name": "mathOverflow" - }, - { - "name": "mathUnderflow" - }, - { - "name": "errorInDivision" - } - ] - } - }, - { - "name": "messageSent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rentPayer", - "type": "pubkey" - }, - { - "name": "message", - "type": "bytes" - } - ] - } - }, - { - "name": "messageTransmitter", - "docs": [ - "Main state of the MessageTransmitter program" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "pendingOwner", - "type": "pubkey" - }, - { - "name": "attesterManager", - "type": "pubkey" - }, - { - "name": "pauser", - "type": "pubkey" - }, - { - "name": "paused", - "type": "bool" - }, - { - "name": "localDomain", - "type": "u32" - }, - { - "name": "version", - "type": "u32" - }, - { - "name": "signatureThreshold", - "type": "u32" - }, - { - "name": "enabledAttesters", - "type": { - "vec": "pubkey" - } - }, - { - "name": "maxMessageBodySize", - "type": "u64" - }, - { - "name": "nextAvailableNonce", - "type": "u64" - } - ] - } - }, - { - "name": "usedNonces", - "docs": [ - "UsedNonces account holds an array of bits that indicate which nonces were already used", - "so they can't be resused to receive new messages. Array starts with the first_nonce and", - "holds flags for UsedNonces::MAX_NONCES. Nonces are recorded separately for each remote_domain." - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "firstNonce", - "type": "u64" - }, - { - "name": "usedNonces", - "type": { - "array": [ - "u64", - 100 - ] - } - } - ] - } - }, - { - "name": "ownershipTransferStarted", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previousOwner", - "type": "pubkey" - }, - { - "name": "newOwner", - "type": "pubkey" - } - ] - } - }, - { - "name": "ownershipTransferred", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previousOwner", - "type": "pubkey" - }, - { - "name": "newOwner", - "type": "pubkey" - } - ] - } - }, - { - "name": "pauserChanged", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newAddress", - "type": "pubkey" - } - ] - } - }, - { - "name": "attesterManagerUpdated", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previousAttesterManager", - "type": "pubkey" - }, - { - "name": "newAttesterManager", - "type": "pubkey" - } - ] - } - }, - { - "name": "messageReceived", - "type": { - "kind": "struct", - "fields": [ - { - "name": "caller", - "type": "pubkey" - }, - { - "name": "sourceDomain", - "type": "u32" - }, - { - "name": "nonce", - "type": "u64" - }, - { - "name": "sender", - "type": "pubkey" - }, - { - "name": "messageBody", - "type": "bytes" - } - ] - } - }, - { - "name": "signatureThresholdUpdated", - "type": { - "kind": "struct", - "fields": [ - { - "name": "oldSignatureThreshold", - "type": "u32" - }, - { - "name": "newSignatureThreshold", - "type": "u32" - } - ] - } - }, - { - "name": "attesterEnabled", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "attesterDisabled", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "maxMessageBodySizeUpdated", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newMaxMessageBodySize", - "type": "u64" - } - ] - } - }, - { - "name": "pause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "unpause", - "type": { - "kind": "struct", - "fields": [] - } - } - ] -}; diff --git a/src/svm/assets/message_transmitter_v2.ts b/src/svm/assets/message_transmitter_v2.ts deleted file mode 100644 index 79168e7f3..000000000 --- a/src/svm/assets/message_transmitter_v2.ts +++ /dev/null @@ -1,1869 +0,0 @@ -/** - * Program IDL in camelCase format in order to be used in JS/TS. - * - * Note that this is only a type helper and is not the actual IDL. The original - * IDL can be found at `target/idl/message_transmitter_v2.json`. - */ -export type MessageTransmitterV2 = { - "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC", - "metadata": { - "name": "messageTransmitterV2", - "version": "0.2.0", - "spec": "0.1.0", - "description": "Message Transmitter for Cross-Chain Transfer Protocol V2", - "repository": "https://github.com/circlefin/solana-cctp-contracts" - }, - "instructions": [ - { - "name": "acceptOwnership", - "discriminator": [ - 172, - 23, - 43, - 13, - 238, - 213, - 85, - 150 - ], - "accounts": [ - { - "name": "pendingOwner", - "signer": true, - "relations": [ - "messageTransmitter" - ] - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "acceptOwnershipParams" - } - } - } - ] - }, - { - "name": "disableAttester", - "discriminator": [ - 61, - 171, - 131, - 95, - 172, - 15, - 227, - 229 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "attesterManager", - "signer": true, - "relations": [ - "messageTransmitter" - ] - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "disableAttesterParams" - } - } - } - ] - }, - { - "name": "enableAttester", - "discriminator": [ - 2, - 11, - 193, - 115, - 5, - 148, - 4, - 198 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "attesterManager", - "signer": true, - "relations": [ - "messageTransmitter" - ] - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "enableAttesterParams" - } - } - } - ] - }, - { - "name": "initialize", - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "upgradeAuthority", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 115, - 115, - 97, - 103, - 101, - 95, - 116, - 114, - 97, - 110, - 115, - 109, - 105, - 116, - 116, - 101, - 114 - ] - } - ] - } - }, - { - "name": "messageTransmitterProgramData" - }, - { - "name": "messageTransmitterProgram", - "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "initializeParams" - } - } - } - ] - }, - { - "name": "isNonceUsed", - "discriminator": [ - 144, - 72, - 107, - 148, - 35, - 218, - 31, - 187 - ], - "accounts": [ - { - "name": "usedNonce", - "docs": [ - "Account will be explicitly loaded to avoid error when it's not initialized" - ] - } - ], - "args": [], - "returns": "bool" - }, - { - "name": "pause", - "discriminator": [ - 211, - 22, - 221, - 251, - 74, - 121, - 193, - 47 - ], - "accounts": [ - { - "name": "pauser", - "signer": true, - "relations": [ - "messageTransmitter" - ] - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "pauseParams" - } - } - } - ] - }, - { - "name": "receiveMessage", - "discriminator": [ - 38, - 144, - 127, - 225, - 31, - 225, - 238, - 25 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "caller", - "signer": true - }, - { - "name": "authorityPda", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 115, - 115, - 97, - 103, - 101, - 95, - 116, - 114, - 97, - 110, - 115, - 109, - 105, - 116, - 116, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "receiver" - } - ] - } - }, - { - "name": "messageTransmitter" - }, - { - "name": "usedNonce", - "docs": [ - "Each nonce is stored in a separate PDA" - ], - "writable": true - }, - { - "name": "receiver" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "receiveMessageParams" - } - } - } - ] - }, - { - "name": "reclaimEventAccount", - "discriminator": [ - 94, - 198, - 180, - 159, - 131, - 236, - 15, - 174 - ], - "accounts": [ - { - "name": "payee", - "docs": [ - "rent SOL receiver, should match original rent payer" - ], - "writable": true, - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "messageSentEventData", - "writable": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "reclaimEventAccountParams" - } - } - } - ] - }, - { - "name": "sendMessage", - "discriminator": [ - 57, - 40, - 34, - 178, - 189, - 10, - 65, - 26 - ], - "accounts": [ - { - "name": "eventRentPayer", - "writable": true, - "signer": true - }, - { - "name": "senderAuthorityPda", - "signer": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "messageSentEventData", - "writable": true, - "signer": true - }, - { - "name": "senderProgram" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "sendMessageParams" - } - } - } - ] - }, - { - "name": "setMaxMessageBodySize", - "discriminator": [ - 168, - 178, - 8, - 117, - 217, - 167, - 219, - 31 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "messageTransmitter" - ] - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setMaxMessageBodySizeParams" - } - } - } - ] - }, - { - "name": "setSignatureThreshold", - "discriminator": [ - 163, - 19, - 154, - 168, - 82, - 209, - 214, - 219 - ], - "accounts": [ - { - "name": "attesterManager", - "signer": true, - "relations": [ - "messageTransmitter" - ] - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setSignatureThresholdParams" - } - } - } - ] - }, - { - "name": "transferOwnership", - "discriminator": [ - 65, - 177, - 215, - 73, - 53, - 45, - 99, - 47 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "messageTransmitter" - ] - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "transferOwnershipParams" - } - } - } - ] - }, - { - "name": "unpause", - "discriminator": [ - 169, - 144, - 4, - 38, - 10, - 141, - 188, - 255 - ], - "accounts": [ - { - "name": "pauser", - "signer": true, - "relations": [ - "messageTransmitter" - ] - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "unpauseParams" - } - } - } - ] - }, - { - "name": "updateAttesterManager", - "discriminator": [ - 175, - 245, - 178, - 104, - 85, - 179, - 71, - 16 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "messageTransmitter" - ] - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "updateAttesterManagerParams" - } - } - } - ] - }, - { - "name": "updatePauser", - "discriminator": [ - 140, - 171, - 211, - 132, - 57, - 201, - 16, - 254 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "messageTransmitter" - ] - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "updatePauserParams" - } - } - } - ] - } - ], - "accounts": [ - { - "name": "messageSent", - "discriminator": [ - 131, - 100, - 133, - 56, - 166, - 225, - 151, - 60 - ] - }, - { - "name": "messageTransmitter", - "discriminator": [ - 71, - 40, - 180, - 142, - 19, - 203, - 35, - 252 - ] - }, - { - "name": "usedNonce", - "discriminator": [ - 212, - 222, - 157, - 252, - 130, - 71, - 179, - 238 - ] - } - ], - "events": [ - { - "name": "attesterDisabled", - "discriminator": [ - 186, - 136, - 186, - 14, - 229, - 2, - 121, - 211 - ] - }, - { - "name": "attesterEnabled", - "discriminator": [ - 88, - 57, - 14, - 133, - 5, - 219, - 62, - 190 - ] - }, - { - "name": "attesterManagerUpdated", - "discriminator": [ - 5, - 97, - 191, - 108, - 44, - 189, - 69, - 88 - ] - }, - { - "name": "maxMessageBodySizeUpdated", - "discriminator": [ - 134, - 206, - 151, - 111, - 137, - 11, - 160, - 225 - ] - }, - { - "name": "messageReceived", - "discriminator": [ - 231, - 68, - 47, - 77, - 173, - 241, - 157, - 166 - ] - }, - { - "name": "ownershipTransferStarted", - "discriminator": [ - 183, - 253, - 239, - 246, - 140, - 179, - 133, - 105 - ] - }, - { - "name": "ownershipTransferred", - "discriminator": [ - 172, - 61, - 205, - 183, - 250, - 50, - 38, - 98 - ] - }, - { - "name": "pause", - "discriminator": [ - 194, - 251, - 232, - 196, - 118, - 95, - 111, - 219 - ] - }, - { - "name": "pauserChanged", - "discriminator": [ - 142, - 157, - 158, - 87, - 127, - 8, - 119, - 55 - ] - }, - { - "name": "signatureThresholdUpdated", - "discriminator": [ - 156, - 99, - 103, - 200, - 15, - 38, - 122, - 189 - ] - }, - { - "name": "unpause", - "discriminator": [ - 241, - 149, - 104, - 90, - 199, - 136, - 219, - 146 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "invalidAuthority", - "msg": "Invalid authority" - }, - { - "code": 6001, - "name": "programPaused", - "msg": "Instruction is not allowed at this time" - }, - { - "code": 6002, - "name": "invalidMessageTransmitterState", - "msg": "Invalid message transmitter state" - }, - { - "code": 6003, - "name": "invalidSignatureThreshold", - "msg": "Invalid signature threshold" - }, - { - "code": 6004, - "name": "signatureThresholdAlreadySet", - "msg": "Signature threshold already set" - }, - { - "code": 6005, - "name": "invalidOwner", - "msg": "Invalid owner" - }, - { - "code": 6006, - "name": "invalidPauser", - "msg": "Invalid pauser" - }, - { - "code": 6007, - "name": "invalidAttesterManager", - "msg": "Invalid attester manager" - }, - { - "code": 6008, - "name": "invalidAttester", - "msg": "Invalid attester" - }, - { - "code": 6009, - "name": "attesterAlreadyEnabled", - "msg": "Attester already enabled" - }, - { - "code": 6010, - "name": "tooFewEnabledAttesters", - "msg": "Too few enabled attesters" - }, - { - "code": 6011, - "name": "signatureThresholdTooLow", - "msg": "Signature threshold is too low" - }, - { - "code": 6012, - "name": "attesterAlreadyDisabled", - "msg": "Attester already disabled" - }, - { - "code": 6013, - "name": "messageBodyLimitExceeded", - "msg": "Message body exceeds max size" - }, - { - "code": 6014, - "name": "invalidDestinationCaller", - "msg": "Invalid destination caller" - }, - { - "code": 6015, - "name": "invalidRecipient", - "msg": "Invalid message recipient" - }, - { - "code": 6016, - "name": "senderNotPermitted", - "msg": "Sender is not permitted" - }, - { - "code": 6017, - "name": "invalidSourceDomain", - "msg": "Invalid source domain" - }, - { - "code": 6018, - "name": "invalidDestinationDomain", - "msg": "Invalid destination domain" - }, - { - "code": 6019, - "name": "invalidMessageVersion", - "msg": "Invalid message version" - }, - { - "code": 6020, - "name": "invalidUsedNoncesAccount", - "msg": "Invalid used nonces account" - }, - { - "code": 6021, - "name": "invalidRecipientProgram", - "msg": "Invalid recipient program" - }, - { - "code": 6022, - "name": "invalidNonce", - "msg": "Invalid nonce" - }, - { - "code": 6023, - "name": "nonceAlreadyUsed", - "msg": "Nonce already used" - }, - { - "code": 6024, - "name": "messageTooShort", - "msg": "Message is too short" - }, - { - "code": 6025, - "name": "malformedMessage", - "msg": "Malformed message" - }, - { - "code": 6026, - "name": "invalidSignatureOrderOrDupe", - "msg": "Invalid signature order or dupe" - }, - { - "code": 6027, - "name": "invalidAttesterSignature", - "msg": "Invalid attester signature" - }, - { - "code": 6028, - "name": "invalidAttestationLength", - "msg": "Invalid attestation length" - }, - { - "code": 6029, - "name": "invalidSignatureRecoveryId", - "msg": "Invalid signature recovery ID" - }, - { - "code": 6030, - "name": "invalidSignatureSValue", - "msg": "Invalid signature S value" - }, - { - "code": 6031, - "name": "invalidMessageHash", - "msg": "Invalid message hash" - }, - { - "code": 6032, - "name": "invalidDestinationMessage", - "msg": "Invalid destination message" - }, - { - "code": 6033, - "name": "eventAccountWindowNotExpired", - "msg": "Event account window not expired" - }, - { - "code": 6034, - "name": "destinationDomainIsLocalDomain", - "msg": "Destination domain is local domain" - } - ], - "types": [ - { - "name": "acceptOwnershipParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "attesterDisabled", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "attesterEnabled", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "attesterManagerUpdated", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previousAttesterManager", - "type": "pubkey" - }, - { - "name": "newAttesterManager", - "type": "pubkey" - } - ] - } - }, - { - "name": "disableAttesterParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attester", - "type": "pubkey" - } - ] - } - }, - { - "name": "enableAttesterParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newAttester", - "type": "pubkey" - } - ] - } - }, - { - "name": "initializeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "localDomain", - "type": "u32" - }, - { - "name": "attester", - "type": "pubkey" - }, - { - "name": "maxMessageBodySize", - "type": "u64" - }, - { - "name": "version", - "type": "u32" - } - ] - } - }, - { - "name": "maxMessageBodySizeUpdated", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newMaxMessageBodySize", - "type": "u64" - } - ] - } - }, - { - "name": "messageReceived", - "type": { - "kind": "struct", - "fields": [ - { - "name": "caller", - "type": "pubkey" - }, - { - "name": "sourceDomain", - "type": "u32" - }, - { - "name": "nonce", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "sender", - "type": "pubkey" - }, - { - "name": "finalityThresholdExecuted", - "type": "u32" - }, - { - "name": "messageBody", - "type": "bytes" - } - ] - } - }, - { - "name": "messageSent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rentPayer", - "type": "pubkey" - }, - { - "name": "createdAt", - "type": "i64" - }, - { - "name": "message", - "type": "bytes" - } - ] - } - }, - { - "name": "messageTransmitter", - "docs": [ - "Main state of the MessageTransmitter program" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "pendingOwner", - "type": "pubkey" - }, - { - "name": "attesterManager", - "type": "pubkey" - }, - { - "name": "pauser", - "type": "pubkey" - }, - { - "name": "paused", - "type": "bool" - }, - { - "name": "localDomain", - "type": "u32" - }, - { - "name": "version", - "type": "u32" - }, - { - "name": "signatureThreshold", - "type": "u32" - }, - { - "name": "enabledAttesters", - "type": { - "vec": "pubkey" - } - }, - { - "name": "maxMessageBodySize", - "type": "u64" - } - ] - } - }, - { - "name": "ownershipTransferStarted", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previousOwner", - "type": "pubkey" - }, - { - "name": "newOwner", - "type": "pubkey" - } - ] - } - }, - { - "name": "ownershipTransferred", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previousOwner", - "type": "pubkey" - }, - { - "name": "newOwner", - "type": "pubkey" - } - ] - } - }, - { - "name": "pause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "pauseParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "pauserChanged", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newAddress", - "type": "pubkey" - } - ] - } - }, - { - "name": "receiveMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "message", - "type": "bytes" - }, - { - "name": "attestation", - "type": "bytes" - } - ] - } - }, - { - "name": "reclaimEventAccountParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attestation", - "type": "bytes" - }, - { - "name": "destinationMessage", - "type": "bytes" - } - ] - } - }, - { - "name": "sendMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "destinationDomain", - "type": "u32" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "destinationCaller", - "type": "pubkey" - }, - { - "name": "minFinalityThreshold", - "type": "u32" - }, - { - "name": "messageBody", - "type": "bytes" - } - ] - } - }, - { - "name": "setMaxMessageBodySizeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newMaxMessageBodySize", - "type": "u64" - } - ] - } - }, - { - "name": "setSignatureThresholdParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newSignatureThreshold", - "type": "u32" - } - ] - } - }, - { - "name": "signatureThresholdUpdated", - "type": { - "kind": "struct", - "fields": [ - { - "name": "oldSignatureThreshold", - "type": "u32" - }, - { - "name": "newSignatureThreshold", - "type": "u32" - } - ] - } - }, - { - "name": "transferOwnershipParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newOwner", - "type": "pubkey" - } - ] - } - }, - { - "name": "unpause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "unpauseParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "updateAttesterManagerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newAttesterManager", - "type": "pubkey" - } - ] - } - }, - { - "name": "updatePauserParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newPauser", - "type": "pubkey" - } - ] - } - }, - { - "name": "usedNonce", - "type": { - "kind": "struct", - "fields": [ - { - "name": "isUsed", - "type": "bool" - } - ] - } - } - ] -}; diff --git a/src/svm/assets/multicall_handler.ts b/src/svm/assets/multicall_handler.ts deleted file mode 100644 index 81be4b1df..000000000 --- a/src/svm/assets/multicall_handler.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Program IDL in camelCase format in order to be used in JS/TS. - * - * Note that this is only a type helper and is not the actual IDL. The original - * IDL can be found at `target/idl/multicall_handler.json`. - */ -export type MulticallHandler = { - "address": "HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be", - "metadata": { - "name": "multicallHandler", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "handleV3AcrossMessage", - "discriminator": [ - 131, - 141, - 52, - 71, - 16, - 59, - 196, - 92 - ], - "accounts": [], - "args": [ - { - "name": "message", - "type": "bytes" - } - ] - } - ] -}; diff --git a/src/svm/assets/sponsored_cctp_src_periphery.ts b/src/svm/assets/sponsored_cctp_src_periphery.ts deleted file mode 100644 index cded111ed..000000000 --- a/src/svm/assets/sponsored_cctp_src_periphery.ts +++ /dev/null @@ -1,1971 +0,0 @@ -/** - * Program IDL in camelCase format in order to be used in JS/TS. - * - * Note that this is only a type helper and is not the actual IDL. The original - * IDL can be found at `target/idl/sponsored_cctp_src_periphery.json`. - */ -export type SponsoredCctpSrcPeriphery = { - "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq", - "metadata": { - "name": "sponsoredCctpSrcPeriphery", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "docs": [ - "# Across Sponsored CCTP Source Periphery", - "", - "Source chain periphery program for users to interact with to start a sponsored or a non-sponsored flow that allows", - "custom Across-supported flows on destination chain. Uses Circle's CCTPv2 as an underlying bridge" - ], - "instructions": [ - { - "name": "depositForBurn", - "docs": [ - "Verifies a sponsored CCTP quote, records its nonce, and burns the user's tokens via CCTPv2 with hook data.", - "", - "The user's depositor ATA is burned via `deposit_for_burn_with_hook` CPI on the CCTPv2. The rent cost for the", - "per-quote `used_nonce` PDA is refunded to the signer from the `rent_fund` and `rent_fund` also funds the", - "creation of CCTP `MessageSent` event account.", - "On success, this emits a `SponsoredDepositForBurn` event to be consumed by offchain infrastructure. This also", - "emits a `CreatedEventAccount` event containing the address of the created CCTP `MessageSent` event account that", - "can be reclaimed later using the `reclaim_event_account` instruction.", - "", - "Required Accounts:", - "- signer (Signer, Writable): The user authorizing the burn.", - "- state (Account): Program state PDA. Seed: [\"state\"].", - "- rent_fund (SystemAccount, Writable): PDA used to sponsor rent and event accounts. Seed: [\"rent_fund\"].", - "- minimum_deposit (Account): Minimum deposit state PDA. Seed: [\"minimum_deposit\", burn_token.key()].", - "- used_nonce (Account, Writable, Init): Per-quote nonce PDA. Seed: [\"used_nonce\", nonce].", - "- rent_claim (Optional Account, Writable, Init-If-Needed): Optional PDA to accrue rent_fund debt to the user.", - "Seed: [\"rent_claim\", signer.key()].", - "- depositor_token_account (InterfaceAccount, Writable): Signer ATA of the burn token.", - "- burn_token (InterfaceAccount, Mutable): Mint of the token to burn. Must match quote.burn_token.", - "- denylist_account (Unchecked): CCTP denylist PDA, validated within CCTP.", - "- token_messenger_minter_sender_authority (Unchecked): CCTP sender authority PDA.", - "- message_transmitter (Unchecked, Mutable): CCTP MessageTransmitter account.", - "- token_messenger (Unchecked): CCTP TokenMessenger account.", - "- remote_token_messenger (Unchecked): Remote TokenMessenger account for destination domain.", - "- token_minter (Unchecked): CCTP TokenMinter account.", - "- local_token (Unchecked, Mutable): Local token account (CCTP).", - "- cctp_event_authority (Unchecked): CCTP event authority account.", - "- message_sent_event_data (Signer, Mutable): Fresh account to store CCTP MessageSent event data.", - "- message_transmitter_program (Program): CCTPv2 MessageTransmitter program.", - "- token_messenger_minter_program (Program): CCTPv2 TokenMessengerMinter program.", - "- token_program (Interface): SPL token program.", - "- system_program (Program): System program.", - "", - "Parameters:", - "- quote: SponsoredCCTPQuote struct serialized by Anchor:", - "- source_domain: CCTP domain ID of the source chain.", - "- destination_domain: CCTP domain ID of the destination chain.", - "- mint_recipient: The recipient of the minted tokens on the destination chain.", - "- amount: The amount of tokens that the user pays on the source chain.", - "- burn_token: The token that will be burned on the source chain.", - "- destination_caller: The caller of the destination chain.", - "- max_fee: Maximum fee to pay on the destination domain, specified in units of burn_token.", - "- min_finality_threshold: Minimum finality threshold before allowed to attest.", - "- nonce: Nonce is used to prevent replay attacks.", - "- deadline: Timestamp of the quote after which it can no longer be used.", - "- max_bps_to_sponsor: The maximum basis points of the amount that can be sponsored.", - "- max_user_slippage_bps: Slippage tolerance for the fees on the destination. Used in swap flow, enforced on", - "destination.", - "- final_recipient: The final recipient of the sponsored deposit. This is needed as the mint_recipient will be", - "the handler contract address instead of the final recipient.", - "- final_token: The final token that final recipient will receive. This is needed as it can be different from", - "the burn_token in which case we perform a swap on the destination chain.", - "- execution_mode: Execution mode: DirectToCore (0), ArbitraryActionsToCore (1), or ArbitraryActionsToEVM (2).", - "- action_data: Encoded action data for arbitrary execution. Empty for DirectToCore mode.", - "- signature: 65-byte EVM signature authorizing the quote by the trusted signer.", - "", - "Notes:", - "- The upgrade authority must have set the valid EVM signer for this instruction to succeed.", - "- The operator of this program must have funded the `rent_fund` PDA with sufficient lamports to cover", - "rent for the `used_nonce` PDA and the CCTP `MessageSent` event account." - ], - "discriminator": [ - 215, - 60, - 61, - 46, - 114, - 55, - 128, - 176 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "rentFund", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 102, - 117, - 110, - 100 - ] - } - ] - } - }, - { - "name": "minimumDeposit", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 105, - 110, - 105, - 109, - 117, - 109, - 95, - 100, - 101, - 112, - 111, - 115, - 105, - 116 - ] - }, - { - "kind": "account", - "path": "burnToken" - } - ] - } - }, - { - "name": "usedNonce", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 100, - 95, - 110, - 111, - 110, - 99, - 101 - ] - }, - { - "kind": "arg", - "path": "params.quote.nonce" - } - ] - } - }, - { - "name": "rentClaim", - "writable": true, - "optional": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 99, - 108, - 97, - 105, - 109 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "depositorTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "signer" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "burnToken" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "burnToken", - "writable": true - }, - { - "name": "denylistAccount" - }, - { - "name": "tokenMessengerMinterSenderAuthority" - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "tokenMessenger" - }, - { - "name": "remoteTokenMessenger" - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true - }, - { - "name": "cctpEventAuthority" - }, - { - "name": "messageSentEventData", - "writable": true, - "signer": true - }, - { - "name": "messageTransmitterProgram", - "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" - }, - { - "name": "tokenMessengerMinterProgram", - "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" - }, - { - "name": "tokenProgram" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "depositForBurnParams" - } - } - } - ] - }, - { - "name": "getUsedNonceCloseInfo", - "docs": [ - "Returns whether a `used_nonce` PDA can be closed now and the timestamp after which it can be closed.", - "", - "This is a convenience \"view\" helper for off-chain systems to determine when rent can be reclaimed for a", - "specific quote nonce.", - "", - "Required Accounts:", - "- state (Account): Program state PDA. Seed: [\"state\"].", - "- used_nonce (Account): The `used_nonce` PDA. Seed: [\"used_nonce\", nonce].", - "", - "Parameters:", - "- _params.nonce: The 32-byte nonce identifying the PDA to check.", - "", - "Returns:", - "- UsedNonceCloseInfo { can_close_after, can_close_now }" - ], - "discriminator": [ - 19, - 183, - 42, - 151, - 118, - 234, - 57, - 92 - ], - "accounts": [ - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "usedNonce", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 100, - 95, - 110, - 111, - 110, - 99, - 101 - ] - }, - { - "kind": "arg", - "path": "_params.nonce" - } - ] - } - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "usedNonceAccountParams" - } - } - } - ], - "returns": { - "defined": { - "name": "usedNonceCloseInfo" - } - } - }, - { - "name": "initialize", - "docs": [ - "Initializes immutable program state and sets the trusted EVM quote signer.", - "", - "This can only be called once by the upgrade authority. It stores the local CCTP source domain and the", - "quote `signer` that must authorize sponsored deposits.", - "", - "Required Accounts:", - "- signer (Signer, Writable): Must be the program upgrade authority.", - "- state (Writable): Program state PDA. Seed: [\"state\"].", - "- program_data (Account): Program data account to verify the upgrade authority.", - "- this_program (Program): This program account, used to resolve `programdata_address`.", - "- system_program (Program): System program for account creation.", - "", - "Parameters:", - "- source_domain: CCTP domain for this chain (e.g., 5 for Solana).", - "- signer: EVM address (encoded as `Pubkey`) authorized to sign sponsored quotes." - ], - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "programData" - }, - { - "name": "thisProgram", - "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "initializeParams" - } - } - } - ] - }, - { - "name": "reclaimEventAccount", - "docs": [ - "Reclaims the CCTP `MessageSent` event account, returning rent to the rent fund.", - "", - "Required Accounts:", - "- rent_fund (SystemAccount, Writable): PDA to receive reclaimed lamports. Seed: [\"rent_fund\"].", - "- message_transmitter (Unchecked, Mutable): CCTP MessageTransmitter account.", - "- message_sent_event_data (Account, Mutable): The `MessageSent` event account created during `deposit_for_burn`.", - "- message_transmitter_program (Program): CCTPv2 MessageTransmitter program.", - "", - "Parameters:", - "- params: Parameters struct required to construct reclaim_event_account instruction on the CCTPv2.", - "- attestation: Attestation obtained from the CCTP attestation service.", - "- nonce: bytes32 from the attested destination message.", - "- finality_threshold_executed: uint32 BE encoded from the attested destination message.", - "- fee_executed: uint256 BE encoded from the attested destination message body.", - "- expiration_block: uint256 BE encoded from the attested destination message body.", - "", - "Notes:", - "- This can only be called after the CCTP attestation service has processed the message and sufficient time has", - "passed since the `MessageSent` event was created. The operator can track the closable accounts from the", - "emitted `CreatedEventAccount` events and using the `EVENT_ACCOUNT_WINDOW_SECONDS` set in CCTP program." - ], - "discriminator": [ - 94, - 198, - 180, - 159, - 131, - 236, - 15, - 174 - ], - "accounts": [ - { - "name": "rentFund", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 102, - 117, - 110, - 100 - ] - } - ] - } - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "messageSentEventData", - "writable": true - }, - { - "name": "messageTransmitterProgram", - "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "reclaimEventAccountParams" - } - } - } - ] - }, - { - "name": "reclaimUsedNonceAccount", - "docs": [ - "Closes a `used_nonce` PDA once its quote deadline has passed, returning rent to the rent fund.", - "", - "Required Accounts:", - "- state (Account): Program state PDA. Seed: [\"state\"]. Used to fetch current time.", - "- rent_fund (SystemAccount, Writable): PDA receiving lamports upon close. Seed: [\"rent_fund\"].", - "- used_nonce (Account, Writable, Close=rent_fund): PDA to close. Seed: [\"used_nonce\", nonce].", - "", - "Parameters:", - "- params.nonce: The 32-byte nonce identifying the PDA to close.", - "", - "Notes:", - "- This can only be called after the quote's deadline has passed. The operator can track closable `used_nonce`", - "accounts from the emitted `SponsoredDepositForBurn` events (`quote_nonce` and `quote_deadline`) and using the", - "`get_used_nonce_close_info` helper." - ], - "discriminator": [ - 153, - 152, - 111, - 172, - 156, - 104, - 116, - 3 - ], - "accounts": [ - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "rentFund", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 102, - 117, - 110, - 100 - ] - } - ] - } - }, - { - "name": "usedNonce", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 117, - 115, - 101, - 100, - 95, - 110, - 111, - 110, - 99, - 101 - ] - }, - { - "kind": "arg", - "path": "params.nonce" - } - ] - } - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "usedNonceAccountParams" - } - } - } - ] - }, - { - "name": "repayRentFundDebt", - "docs": [ - "Repays rent_fund liability for a user if rent_fund had insufficient balance at the time of deposit.", - "", - "Required Accounts:", - "- rent_fund (SystemAccount, Writable): PDA used to sponsor rent and event accounts. Seed: [\"rent_fund\"].", - "- recipient (Unchecked, Writable): The user account to repay rent fund debt to.", - "- rent_claim (Account, Writable, Close=recipient): PDA with accrued rent_fund debt to the user.", - "Seed: [\"rent_claim\", recipient.key()].", - "- system_program (Program): System program." - ], - "discriminator": [ - 111, - 95, - 222, - 174, - 241, - 41, - 61, - 78 - ], - "accounts": [ - { - "name": "rentFund", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 102, - 117, - 110, - 100 - ] - } - ] - } - }, - { - "name": "recipient", - "writable": true - }, - { - "name": "rentClaim", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 99, - 108, - 97, - 105, - 109 - ] - }, - { - "kind": "account", - "path": "recipient" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "setCurrentTime", - "docs": [ - "Sets the current time in test mode. No-op on mainnet builds.", - "", - "Required Accounts:", - "- state (Writable): Program state PDA. Seed: [\"state\"].", - "- signer (Signer): Any signer. Only enabled when built with `--features test`.", - "", - "Parameters:", - "- new_time: New unix timestamp to set for tests." - ], - "discriminator": [ - 69, - 100, - 169, - 193, - 125, - 0, - 150, - 69 - ], - "accounts": [ - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "signer", - "signer": true - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setCurrentTimeParams" - } - } - } - ] - }, - { - "name": "setMinimumDepositAmount", - "docs": [ - "Updates the minimum deposit amount for a given burn token.", - "", - "Only callable by the upgrade authority. This must be set at least once for a supported burn token as otherwise", - "deposits would be blocked.", - "", - "Required Accounts:", - "- signer (Signer, Writable): Must be the program upgrade authority.", - "- minimum_deposit (Writable): Minimum deposit state PDA. Seed: [\"minimum_deposit\", burn_token.key()].", - "- burn_token: Supported burn token for which the minimum deposit amount is being set.", - "- program_data (Account): Program data account to verify the upgrade authority.", - "- this_program (Program): This program account, used to resolve `programdata_address`.", - "- system_program (Program): System program for transfers.", - "", - "Parameters:", - "- amount: New minimum deposit amount for a given burn token." - ], - "discriminator": [ - 176, - 4, - 74, - 229, - 206, - 148, - 151, - 138 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "minimumDeposit", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 105, - 110, - 105, - 109, - 117, - 109, - 95, - 100, - 101, - 112, - 111, - 115, - 105, - 116 - ] - }, - { - "kind": "account", - "path": "burnToken" - } - ] - } - }, - { - "name": "burnToken" - }, - { - "name": "programData" - }, - { - "name": "thisProgram", - "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setMinimumDepositAmountParams" - } - } - } - ] - }, - { - "name": "setSigner", - "docs": [ - "Updates the trusted EVM quote signer.", - "", - "Only callable by the upgrade authority. Setting this to an invalid address (including `Pubkey::default()`) will", - "effectively disable deposits.", - "", - "Required Accounts:", - "- signer (Signer, Writable): Must be the program upgrade authority.", - "- state (Writable): Program state PDA. Seed: [\"state\"].", - "- program_data (Account): Program data account to verify the upgrade authority.", - "- this_program (Program): This program account, used to resolve `programdata_address`.", - "", - "Parameters:", - "- new_signer: New EVM signer address (encoded as `Pubkey`)." - ], - "discriminator": [ - 127, - 120, - 252, - 184, - 97, - 4, - 88, - 68 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - } - ] - } - }, - { - "name": "programData" - }, - { - "name": "thisProgram", - "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setSignerParams" - } - } - } - ] - }, - { - "name": "withdrawRentFund", - "docs": [ - "Withdraws lamports from the rent fund PDA to an arbitrary recipient.", - "", - "The rent fund is used to sponsor temporary account creation (e.g., CCTP event accounts or per-quote nonce PDAs).", - "Only callable by the upgrade authority.", - "", - "Required Accounts:", - "- signer (Signer, Writable): Must be the program upgrade authority.", - "- rent_fund (SystemAccount, Writable): PDA holding lamports used for rent sponsorship. Seed: [\"rent_fund\"].", - "- recipient (UncheckedAccount, Writable): Destination account for the withdrawn lamports.", - "- program_data (Account): Program data account to verify the upgrade authority.", - "- this_program (Program): This program account, used to resolve `programdata_address`.", - "- system_program (Program): System program for transfers.", - "", - "Parameters:", - "- amount: Amount of lamports to transfer to the recipient." - ], - "discriminator": [ - 153, - 28, - 108, - 116, - 132, - 70, - 161, - 125 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "rentFund", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 110, - 116, - 95, - 102, - 117, - 110, - 100 - ] - } - ] - } - }, - { - "name": "recipient", - "writable": true - }, - { - "name": "programData" - }, - { - "name": "thisProgram", - "address": "CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "withdrawRentFundParams" - } - } - } - ] - } - ], - "accounts": [ - { - "name": "messageSent", - "discriminator": [ - 131, - 100, - 133, - 56, - 166, - 225, - 151, - 60 - ] - }, - { - "name": "minimumDeposit", - "discriminator": [ - 218, - 139, - 120, - 202, - 3, - 12, - 233, - 65 - ] - }, - { - "name": "rentClaim", - "discriminator": [ - 13, - 5, - 183, - 82, - 60, - 122, - 72, - 11 - ] - }, - { - "name": "state", - "discriminator": [ - 216, - 146, - 107, - 94, - 104, - 75, - 182, - 177 - ] - }, - { - "name": "usedNonce", - "discriminator": [ - 212, - 222, - 157, - 252, - 130, - 71, - 179, - 238 - ] - } - ], - "events": [ - { - "name": "accruedRentFundLiability", - "discriminator": [ - 56, - 17, - 203, - 169, - 27, - 139, - 36, - 225 - ] - }, - { - "name": "createdEventAccount", - "discriminator": [ - 178, - 224, - 189, - 92, - 50, - 100, - 128, - 204 - ] - }, - { - "name": "minimumDepositAmountSet", - "discriminator": [ - 134, - 237, - 176, - 205, - 21, - 44, - 95, - 177 - ] - }, - { - "name": "reclaimedEventAccount", - "discriminator": [ - 210, - 180, - 74, - 27, - 92, - 74, - 46, - 216 - ] - }, - { - "name": "reclaimedUsedNonceAccount", - "discriminator": [ - 6, - 199, - 109, - 7, - 58, - 150, - 119, - 103 - ] - }, - { - "name": "repaidRentFundDebt", - "discriminator": [ - 134, - 86, - 59, - 173, - 10, - 250, - 191, - 190 - ] - }, - { - "name": "signerSet", - "discriminator": [ - 137, - 203, - 187, - 74, - 141, - 187, - 226, - 95 - ] - }, - { - "name": "sponsoredDepositForBurn", - "discriminator": [ - 55, - 106, - 70, - 41, - 59, - 102, - 172, - 42 - ] - }, - { - "name": "withdrawnRentFund", - "discriminator": [ - 110, - 180, - 127, - 254, - 32, - 122, - 209, - 22 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "notUpgradeAuthority", - "msg": "Only the upgrade authority can call this instruction" - }, - { - "code": 6001, - "name": "invalidProgramData", - "msg": "Invalid program data account" - }, - { - "code": 6002, - "name": "cannotSetCurrentTime", - "msg": "Cannot set time if not in test mode" - }, - { - "code": 6003, - "name": "invalidBurnToken", - "msg": "Invalid burn_token key" - }, - { - "code": 6004, - "name": "amountNotPositive", - "msg": "Amount must be greater than 0" - }, - { - "code": 6005, - "name": "quoteDeadlineNotPassed", - "msg": "The quote deadline has not passed!" - }, - { - "code": 6006, - "name": "signerUnchanged", - "msg": "New signer unchanged" - }, - { - "code": 6007, - "name": "depositAmountBelowMinimum", - "msg": "Deposit amount below minimum" - }, - { - "code": 6008, - "name": "missingRentClaimAccount", - "msg": "Missing rent claim account" - }, - { - "code": 6009, - "name": "rentClaimOverflow", - "msg": "Rent claim amount overflow" - }, - { - "code": 6010, - "name": "invalidRecipientKey", - "msg": "Invalid recipient key" - } - ], - "types": [ - { - "name": "accruedRentFundLiability", - "type": { - "kind": "struct", - "fields": [ - { - "name": "user", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "totalUserClaim", - "type": "u64" - } - ] - } - }, - { - "name": "createdEventAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "messageSentEventData", - "type": "pubkey" - } - ] - } - }, - { - "name": "depositForBurnParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "quote", - "type": { - "defined": { - "name": "sponsoredCctpQuote" - } - } - }, - { - "name": "signature", - "type": { - "array": [ - "u8", - 65 - ] - } - } - ] - } - }, - { - "name": "initializeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "sourceDomain", - "type": "u32" - }, - { - "name": "signer", - "type": "pubkey" - } - ] - } - }, - { - "name": "messageSent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rentPayer", - "type": "pubkey" - }, - { - "name": "createdAt", - "type": "i64" - }, - { - "name": "message", - "type": "bytes" - } - ] - } - }, - { - "name": "minimumDeposit", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "bump", - "type": "u8" - } - ] - } - }, - { - "name": "minimumDepositAmountSet", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "burnToken", - "type": "pubkey" - } - ] - } - }, - { - "name": "reclaimEventAccountParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "attestation", - "type": "bytes" - }, - { - "name": "nonce", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "finalityThresholdExecuted", - "type": { - "array": [ - "u8", - 4 - ] - } - }, - { - "name": "feeExecuted", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "expirationBlock", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - } - }, - { - "name": "reclaimedEventAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "messageSentEventData", - "type": "pubkey" - } - ] - } - }, - { - "name": "reclaimedUsedNonceAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "nonce", - "type": "bytes" - }, - { - "name": "usedNonce", - "type": "pubkey" - } - ] - } - }, - { - "name": "rentClaim", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "repaidRentFundDebt", - "type": { - "kind": "struct", - "fields": [ - { - "name": "user", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "remainingUserClaim", - "type": "u64" - } - ] - } - }, - { - "name": "setCurrentTimeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newTime", - "type": "u64" - } - ] - } - }, - { - "name": "setMinimumDepositAmountParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "setSignerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newSigner", - "type": "pubkey" - } - ] - } - }, - { - "name": "signerSet", - "type": { - "kind": "struct", - "fields": [ - { - "name": "oldSigner", - "type": "pubkey" - }, - { - "name": "newSigner", - "type": "pubkey" - } - ] - } - }, - { - "name": "sponsoredCctpQuote", - "type": { - "kind": "struct", - "fields": [ - { - "name": "sourceDomain", - "type": "u32" - }, - { - "name": "destinationDomain", - "type": "u32" - }, - { - "name": "mintRecipient", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "burnToken", - "type": "pubkey" - }, - { - "name": "destinationCaller", - "type": "pubkey" - }, - { - "name": "maxFee", - "type": "u64" - }, - { - "name": "minFinalityThreshold", - "type": "u32" - }, - { - "name": "nonce", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "deadline", - "type": "u64" - }, - { - "name": "maxBpsToSponsor", - "type": "u64" - }, - { - "name": "maxUserSlippageBps", - "type": "u64" - }, - { - "name": "finalRecipient", - "type": "pubkey" - }, - { - "name": "finalToken", - "type": "pubkey" - }, - { - "name": "destinationDex", - "type": "u32" - }, - { - "name": "accountCreationMode", - "type": "u8" - }, - { - "name": "executionMode", - "type": "u8" - }, - { - "name": "actionData", - "type": "bytes" - } - ] - } - }, - { - "name": "sponsoredDepositForBurn", - "type": { - "kind": "struct", - "fields": [ - { - "name": "quoteNonce", - "type": "bytes" - }, - { - "name": "originSender", - "type": "pubkey" - }, - { - "name": "finalRecipient", - "type": "pubkey" - }, - { - "name": "quoteDeadline", - "type": "u64" - }, - { - "name": "maxBpsToSponsor", - "type": "u64" - }, - { - "name": "maxUserSlippageBps", - "type": "u64" - }, - { - "name": "finalToken", - "type": "pubkey" - }, - { - "name": "destinationDex", - "type": "u32" - }, - { - "name": "accountCreationMode", - "type": "u8" - }, - { - "name": "signature", - "type": "bytes" - } - ] - } - }, - { - "name": "state", - "type": { - "kind": "struct", - "fields": [ - { - "name": "sourceDomain", - "type": "u32" - }, - { - "name": "signer", - "type": "pubkey" - }, - { - "name": "bump", - "type": "u8" - } - ] - } - }, - { - "name": "usedNonce", - "type": { - "kind": "struct", - "fields": [ - { - "name": "quoteDeadline", - "type": "u64" - } - ] - } - }, - { - "name": "usedNonceAccountParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "nonce", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - } - }, - { - "name": "usedNonceCloseInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "canCloseAfter", - "type": "u64" - }, - { - "name": "canCloseNow", - "type": "bool" - } - ] - } - }, - { - "name": "withdrawRentFundParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "withdrawnRentFund", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "recipient", - "type": "pubkey" - } - ] - } - } - ] -}; diff --git a/src/svm/assets/svm_spoke.ts b/src/svm/assets/svm_spoke.ts deleted file mode 100644 index a22419014..000000000 --- a/src/svm/assets/svm_spoke.ts +++ /dev/null @@ -1,5502 +0,0 @@ -/** - * Program IDL in camelCase format in order to be used in JS/TS. - * - * Note that this is only a type helper and is not the actual IDL. The original - * IDL can be found at `target/idl/svm_spoke.json`. - */ -export type SvmSpoke = { - "address": "DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru", - "metadata": { - "name": "svmSpoke", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "bridgeTokensToHubPool", - "docs": [ - "Bridges tokens to the Hub Pool.", - "", - "This function initiates the process of sending tokens from the vault to the Hub Pool based on the outstanding", - "token liability this Spoke Pool has accrued. Enables the caller to choose a custom amount to work around CCTP", - "bridging limits. enforces that amount is less than or equal to liability. On execution decrements liability.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the bridge operation.", - "- payer (Signer): The account responsible for paying the transaction fees.", - "- mint (InterfaceAccount): The mint account for the token being bridged.", - "- state (Account): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- transfer_liability (Account): Account tracking the pending amount to be sent to the Hub Pool. Incremented on", - "relayRootBundle() and decremented on when this function is called. Seed: [\"transfer_liability\",mint].", - "- vault (InterfaceAccount): The ATA for the token being bridged. Authority must be the state.", - "- token_messenger_minter_sender_authority (UncheckedAccount): Authority for the token messenger minter.", - "- message_transmitter (UncheckedAccount): Account for the message transmitter.", - "- token_messenger (UncheckedAccount): Account for the token messenger.", - "- remote_token_messenger (UncheckedAccount): Account for the remote token messenger.", - "- token_minter (UncheckedAccount): Account for the token minter.", - "- local_token (UncheckedAccount): Account for the local token.", - "- cctp_event_authority (UncheckedAccount): Authority for CCTP events.", - "- message_sent_event_data (Signer): Account for message sent event data.", - "- message_transmitter_program (Program): Program for the message transmitter.", - "- token_messenger_minter_program (Program): Program for the token messenger minter.", - "- token_program (Interface): The token program.", - "- system_program (Program): The system program.", - "", - "### Parameters:", - "- amount: The amount of tokens to bridge to the Hub Pool." - ], - "discriminator": [ - 1, - 83, - 255, - 59, - 232, - 55, - 64, - 216 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "mint", - "writable": true - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "transferLiability", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 114, - 97, - 110, - 115, - 102, - 101, - 114, - 95, - 108, - 105, - 97, - 98, - 105, - 108, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "tokenMessengerMinterSenderAuthority" - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "tokenMessenger" - }, - { - "name": "remoteTokenMessenger" - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true - }, - { - "name": "cctpEventAuthority" - }, - { - "name": "messageSentEventData", - "writable": true, - "signer": true - }, - { - "name": "messageTransmitterProgram", - "address": "CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd" - }, - { - "name": "tokenMessengerMinterProgram", - "address": "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3" - }, - { - "name": "tokenProgram" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" - } - ] - }, - { - "name": "claimRelayerRefund", - "docs": [ - "Claims a relayer refund for the caller.", - "", - "In the event a relayer refund was sent to a claim account, then this function enables the relayer to claim it by", - "transferring the claim amount from the vault to their token account. The claim account is closed after refund.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the claim.", - "- initializer (UncheckedAccount): Must be the same account that initialized the claim account.", - "- state (Account): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- vault (InterfaceAccount): The ATA for the refunded mint. Authority must be the state.", - "- mint (InterfaceAccount): The mint account for the token being refunded.", - "- refund_address: token account authority receiving the refund.", - "- token_account (InterfaceAccount): The receiving token account for the refund. When refund_address is different", - "from the signer, this must match its ATA.", - "- claim_account (Account): The claim account PDA. Seed: [\"claim_account\",mint,refund_address].", - "- token_program (Interface): The token program." - ], - "discriminator": [ - 205, - 34, - 34, - 224, - 204, - 103, - 81, - 176 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "initializer", - "writable": true - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "mint" - }, - { - "name": "refundAddress" - }, - { - "name": "tokenAccount", - "writable": true - }, - { - "name": "claimAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 108, - 97, - 105, - 109, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - }, - { - "kind": "account", - "path": "refundAddress" - } - ] - } - }, - { - "name": "tokenProgram" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "closeClaimAccount", - "docs": [ - "Closes a claim account for a relayer refund.", - "", - "This function is used to close the claim account associated with a specific mint and refund address,", - "effectively marking the end of its lifecycle. It can only be called once the claim account is empty. It", - "transfers any remaining lamports to the signer and resets the account.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the closure. Must be the initializer of the claim account.", - "- mint: The mint associated with the claim account.", - "- refund_address: The refund address associated with the claim account.", - "- claim_account (Writable): The claim account PDA to be closed. Seed: [\"claim_account\",mint,refund_address]." - ], - "discriminator": [ - 241, - 146, - 203, - 216, - 58, - 222, - 91, - 118 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "mint" - }, - { - "name": "refundAddress" - }, - { - "name": "claimAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 108, - 97, - 105, - 109, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - }, - { - "kind": "account", - "path": "refundAddress" - } - ] - } - } - ], - "args": [] - }, - { - "name": "closeFillPda", - "docs": [ - "Closes the FillStatusAccount PDA to reclaim relayer rent.", - "", - "This function is used to close the FillStatusAccount associated with a specific relay hash, effectively marking", - "the end of its lifecycle. This can only be done once the fill deadline has passed. Relayers should do this for", - "all fills once they expire to reclaim their rent.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the closure. Must be the relayer in the fill_status PDA.", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- fill_status (Writable): The FillStatusAccount PDA to be closed." - ], - "discriminator": [ - 224, - 39, - 208, - 68, - 8, - 226, - 23, - 214 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "fillStatus", - "writable": true - } - ], - "args": [] - }, - { - "name": "closeInstructionParams", - "docs": [ - "Closes the instruction parameters account.", - "", - "This function is used to close the instruction parameters account, effectively marking the end of its lifecycle.", - "It transfers any remaining lamports to the signer and resets the account.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the closure.", - "- instruction_params (UncheckedAccount): The account to be closed. seed: [\"instruction_params\",signer]. Not", - "the signer being within the seed here implicitly protects this from only being called by the creator." - ], - "discriminator": [ - 224, - 44, - 254, - 10, - 216, - 8, - 172, - 96 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "instructionParams", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - } - ], - "args": [] - }, - { - "name": "createTokenAccounts", - "docs": [ - "Creates token accounts in batch for a set of addresses.", - "", - "This helper function allows the caller to pass in a set of remaining accounts to create a batch of Associated", - "Token Accounts (ATAs) for addresses. It is particularly useful for relayers to call before filling a deposit.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the creation of token accounts.", - "- mint (InterfaceAccount): The mint account for the token.", - "- token_program (Interface): The token program.", - "- associated_token_program (Program): The associated token program.", - "- system_program (Program): The system program required for account creation." - ], - "discriminator": [ - 163, - 216, - 49, - 204, - 97, - 16, - 80, - 167 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "mint" - }, - { - "name": "tokenProgram" - }, - { - "name": "associatedTokenProgram", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "deposit", - "docs": [ - "Request to bridge input_token to a target chain and receive output_token.", - "", - "The fee paid to relayers and the system is captured in the spread between the input and output amounts,", - "denominated in the input token. A relayer on the destination chain will send `output_amount` of `output_token`", - "to the recipient and receive `input_token` on a repayment chain of their choice. The fee accounts for:", - "destination transaction costs, relayer's opportunity cost of capital while waiting for a refund during the", - "optimistic challenge window in the HubPool, and the system fee charged to the relayer.", - "", - "On the destination chain, a unique hash of the deposit data is used to identify this deposit. Modifying any", - "parameters will result in a different hash, creating a separate deposit. The hash is computed using all parameters", - "of this function along with the chain's `chainId()`. Relayers are refunded only for deposits with hashes that", - "exactly match those emitted by this contract.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the deposit.", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- depositor_token_account (Writable): The depositor's ATA for the input token.", - "- vault (Writable): Programs ATA for the associated input token. This is where the depositor's assets are sent.", - "Authority must be the state.", - "- mint (Account): The mint account for the input token.", - "- token_program (Interface): The token program.", - "- delegate (Account): The account used to delegate the input amount of the input token.", - "", - "### Parameters", - "- depositor: The account credited with the deposit. Can be different from the signer.", - "- recipient: The account receiving funds on the destination chain. Depending on the output chain can be an ETH", - "address or a contract address or any other address type encoded as a bytes32 field.", - "- input_token: The token pulled from the caller's account and locked into this program's vault on deposit.", - "- output_token: The token that the relayer will send to the recipient on the destination chain.", - "- input_amount: The amount of input tokens to pull from the caller's account and lock into the vault. This", - "amount will be sent to the relayer on their repayment chain of choice as a refund following an optimistic", - "challenge window in the HubPool, less a system fee.", - "- output_amount: The amount of output tokens that the relayer will send to the recipient on the destination.", - "This is big-endian encoded as a 32-byte array to match its underlying byte representation on EVM side.", - "- destination_chain_id: The destination chain identifier where the fill should be made.", - "- exclusive_relayer: The relayer that will be exclusively allowed to fill this deposit before the exclusivity", - "deadline timestamp. This must be a valid, non-zero address if the exclusivity deadline is greater than the", - "current block timestamp.", - "- quote_timestamp: The HubPool timestamp that is used to determine the system fee paid by the depositor. This", - "must be set to some time between [currentTime - depositQuoteTimeBuffer, currentTime].", - "- fill_deadline: The deadline for the relayer to fill the deposit. After this destination chain timestamp, the", - "fill will revert on the destination chain. Must be set before currentTime + fillDeadlineBuffer.", - "- exclusivity_parameter: Sets the exclusivity deadline timestamp for the exclusiveRelayer to fill the deposit.", - "1. If 0, no exclusivity period.", - "2. If less than MAX_EXCLUSIVITY_PERIOD_SECONDS, adds this value to the current block timestamp.", - "3. Otherwise, uses this value as the exclusivity deadline timestamp.", - "- message: The message to send to the recipient on the destination chain if the recipient is a contract.", - "If not empty, the recipient contract must implement handleV3AcrossMessage() or the fill will revert." - ], - "discriminator": [ - 242, - 35, - 198, - 137, - 82, - 225, - 242, - 182 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "delegate" - }, - { - "name": "depositorTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "arg", - "path": "depositor" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "mint" - }, - { - "name": "tokenProgram" - }, - { - "name": "associatedTokenProgram", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "inputToken", - "type": "pubkey" - }, - { - "name": "outputToken", - "type": "pubkey" - }, - { - "name": "inputAmount", - "type": "u64" - }, - { - "name": "outputAmount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "destinationChainId", - "type": "u64" - }, - { - "name": "exclusiveRelayer", - "type": "pubkey" - }, - { - "name": "quoteTimestamp", - "type": "u32" - }, - { - "name": "fillDeadline", - "type": "u32" - }, - { - "name": "exclusivityParameter", - "type": "u32" - }, - { - "name": "message", - "type": "bytes" - } - ] - }, - { - "name": "depositNow", - "docs": [ - "Equivalent to deposit except quote_timestamp is set to the current time.", - "The deposit `fill_deadline` is calculated as the current time plus `fill_deadline_offset`." - ], - "discriminator": [ - 75, - 228, - 135, - 221, - 200, - 25, - 148, - 26 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "delegate" - }, - { - "name": "depositorTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "arg", - "path": "depositor" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "mint" - }, - { - "name": "tokenProgram" - }, - { - "name": "associatedTokenProgram", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "inputToken", - "type": "pubkey" - }, - { - "name": "outputToken", - "type": "pubkey" - }, - { - "name": "inputAmount", - "type": "u64" - }, - { - "name": "outputAmount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "destinationChainId", - "type": "u64" - }, - { - "name": "exclusiveRelayer", - "type": "pubkey" - }, - { - "name": "fillDeadlineOffset", - "type": "u32" - }, - { - "name": "exclusivityParameter", - "type": "u32" - }, - { - "name": "message", - "type": "bytes" - } - ] - }, - { - "name": "emergencyDeleteRootBundle", - "docs": [ - "Deletes a root bundle in case of emergencies where bad bundle has reached the Spoke. Only callable by the owner.", - "", - "This function will close the PDA for the associated `root_bundle_id`.", - "Note: Using this function does not decrement `state.root_bundle_id`.", - "", - "### Required Accounts:", - "- signer (Signer): The account that must be the owner to authorize the deletion.", - "- closer (SystemAccount): The account that will receive the lamports from closing the root_bundle account.", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- root_bundle (Writable): The root bundle PDA to be closed. Seed: [\"root_bundle\",state.seed,root_bundle_id].", - "", - "### Parameters:", - "- root_bundle_id: Index of the root bundle that needs to be deleted." - ], - "discriminator": [ - 226, - 158, - 1, - 74, - 84, - 113, - 24, - 152 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "closer", - "writable": true - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "rootBundle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 111, - 111, - 116, - 95, - 98, - 117, - 110, - 100, - 108, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - }, - { - "kind": "arg", - "path": "rootBundleId" - } - ] - } - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "rootBundleId", - "type": "u32" - } - ] - }, - { - "name": "executeRelayerRefundLeaf", - "docs": [ - "Executes relayer refund leaf.", - "", - "Processes a relayer refund leaf, verifying its inclusion in a previous Merkle root and that it was not", - "previously executed. Function has two modes of operation: a) transfers all relayer refunds directly to", - "relayers ATA or b) credits relayers with claimable claim_account PDA that they can use later to claim their", - "refund. In the happy path, (a) should be used. (b) should only be used if there is a relayer within the bundle", - "who can't receive the transfer for some reason, such as failed token transfers due to blacklisting. Executing", - "relayer refunds requires the caller to create a LUT and load the execution params into it. This is needed to", - "fit the data in a single instruction. The exact structure and validation of the leaf is defined in the Accross", - "UMIP: https://github.com/UMAprotocol/UMIPs/blob/master/UMIPs/umip-179.md", - "", - "instruction_params Parameters:", - "- root_bundle_id: The ID of the root bundle containing the relayer refund root.", - "- relayer_refund_leaf: The relayer refund leaf to be executed. Contents must include:", - "- amount_to_return: The amount to be to be sent back to mainnet Ethereum from this Spoke pool.", - "- chain_id: The targeted chainId for the refund. Validated against state.chain_id.", - "- refund_amounts: The amounts to be returned to the relayer for each refund_address.", - "- leaf_id: The leaf ID of the relayer refund leaf.", - "- mint_public_key: The public key of the mint (refunded token) being refunded.", - "- refund_addresses: The addresses to be refunded.", - "- proof: The Merkle proof for the relayer refund leaf.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the execution. No permission requirements.", - "- instruction_params (Account): LUT containing the execution parameters. seed: [\"instruction_params\",signer]", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- root_bundle (Writable): The root bundle PDA containing the relayer refund root, created when the root bundle", - "was initially bridged. seed: [\"root_bundle\",state.seed,root_bundle_id].", - "- vault (Writable): The ATA for refunded mint. Authority must be the state.", - "- mint (Account): The mint account for the token being refunded.", - "- transfer_liability (Writable): Account to track pending refunds to be sent to the Ethereum hub pool. Only used", - "if the amount_to_return value is non-zero within the leaf. Seed: [\"transfer_liability\",mint]", - "- token_program: The token program.", - "- system_program: The system program required for account creation.", - "", - "execute_relayer_refund_leaf executes in mode where refunds are sent to ATA directly." - ], - "discriminator": [ - 27, - 136, - 159, - 240, - 127, - 68, - 123, - 164 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "instructionParams", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "rootBundle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 111, - 111, - 116, - 95, - 98, - 117, - 110, - 100, - 108, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - }, - { - "kind": "account", - "path": "instruction_params.root_bundle_id", - "account": "executeRelayerRefundLeafParams" - } - ] - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "mint" - }, - { - "name": "transferLiability", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 114, - 97, - 110, - 115, - 102, - 101, - 114, - 95, - 108, - 105, - 97, - 98, - 105, - 108, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "tokenProgram" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "executeRelayerRefundLeafDeferred", - "docs": [ - "Similar to execute_relayer_refund_leaf, but executes in mode where refunds are allocated to claim_account PDAs." - ], - "discriminator": [ - 110, - 112, - 89, - 208, - 38, - 116, - 93, - 10 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "instructionParams", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "rootBundle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 111, - 111, - 116, - 95, - 98, - 117, - 110, - 100, - 108, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - }, - { - "kind": "account", - "path": "instruction_params.root_bundle_id", - "account": "executeRelayerRefundLeafParams" - } - ] - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "mint" - }, - { - "name": "transferLiability", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 114, - 97, - 110, - 115, - 102, - 101, - 114, - 95, - 108, - 105, - 97, - 98, - 105, - 108, - 105, - 116, - 121 - ] - }, - { - "kind": "account", - "path": "mint" - } - ] - } - }, - { - "name": "tokenProgram" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [] - }, - { - "name": "executeSlowRelayLeaf", - "docs": [ - "Executes a slow relay leaf stored as part of a root bundle relayed by the HubPool.", - "", - "Executing a slow fill leaf is equivalent to filling the relayData, so this function cannot be used to", - "double fill a recipient. The relayData that is filled is included in the slowFillLeaf and is hashed", - "like any other fill sent through fillRelay(). There is no relayer credited with filling this relay since funds", - "are sent directly out of this program's vault.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the execution. No permission requirements.", - "- instruction_params (Account): Optional account to load instruction parameters when they are not passed in the", - "instruction data due to message size constraints. Pass this program ID to represent None. When Some, this must", - "be derived from the signer's public key with seed [\"instruction_params\",signer].", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- root_bundle (Account): Root bundle PDA with slowRelayRoot. Seed: [\"root_bundle\",state.seed,root_bundle_id].", - "- fill_status (Writable): The fill status PDA, created when slow request was made. Updated to track slow fill.", - "Used to prevent double request and fill. Seed: [\"fills\",relay_hash].", - "- mint (Account): The mint account for the output token.", - "- recipient_token_account (Writable): The recipient's ATA for the output token.", - "- vault (Writable): The ATA for refunded mint. Authority must be the state.", - "- token_program (Interface): The token program.", - "- system_program (Program): The system program.", - "", - "### Parameters:", - "- _relay_hash: The hash identifying the deposit to be filled. Used to identify the deposit to be filled.", - "- slow_fill_leaf: Contains all data necessary to uniquely verify the slow fill. This struct contains:", - "- relayData: Struct containing all the data needed to identify the original deposit to be slow filled. Same", - "as the relay_data struct in fill_relay().", - "- chainId: Chain identifier where slow fill leaf should be executed. If this doesn't match this chain's", - "chainId, then this function will revert.", - "- updatedOutputAmount: Amount to be sent to recipient out of this contract's balance. Can be set differently", - "from relayData.outputAmount to charge a different fee because this deposit was \"slow\" filled. Usually,", - "this will be set higher to reimburse the recipient for waiting for the slow fill.", - "- _root_bundle_id: Unique ID of root bundle containing slow relay root that this leaf is contained in.", - "- proof: Inclusion proof for this leaf in slow relay root in root bundle.", - "Note: slow_fill_leaf, _root_bundle_id, and proof are optional parameters. If None for any of these is passed,", - "the caller must load them via the instruction_params account.", - "Note: When verifying the slow fill leaf, the relay data is hashed using AnchorSerialize::serialize that encodes", - "output token amounts to little-endian format while input token amount preserves its big-endian encoding as it", - "is passed as [u8; 32] array." - ], - "discriminator": [ - 26, - 207, - 3, - 168, - 193, - 252, - 59, - 127 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "instructionParams", - "writable": true, - "optional": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "rootBundle", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 111, - 111, - 116, - 95, - 98, - 117, - 110, - 100, - 108, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - }, - { - "kind": "arg", - "path": "_root_bundle_id.unwrap_or_else(| |\ninstruction_params" - } - ] - } - }, - { - "name": "fillStatus", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 102, - 105, - 108, - 108, - 115 - ] - }, - { - "kind": "arg", - "path": "relayHash" - } - ] - } - }, - { - "name": "mint" - }, - { - "name": "recipientTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "arg", - "path": "slowFillLeaf" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "tokenProgram" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "relayHash", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "slowFillLeaf", - "type": { - "option": { - "defined": { - "name": "slowFill" - } - } - } - }, - { - "name": "rootBundleId", - "type": { - "option": "u32" - } - }, - { - "name": "proof", - "type": { - "option": { - "vec": { - "array": [ - "u8", - 32 - ] - } - } - } - } - ] - }, - { - "name": "fillRelay", - "docs": [ - "Fulfill request to bridge cross chain by sending specified output tokens to recipient.", - "", - "Relayer & system fee is captured in the spread between input and output amounts. This fee accounts for tx costs,", - "relayer's capital opportunity cost, and a system fee. The relay_data hash uniquely identifies the deposit to", - "fill, ensuring relayers are refunded only for deposits matching the original hash from the origin SpokePool.", - "This hash includes all parameters from deposit() and must match the destination_chain_id. Note the relayer", - "creates an ATA in calling this method to store the fill_status. This should be closed once the deposit has", - "expired to let the relayer re-claim their rent. Cannot fill more than once. Partial fills are not supported.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the fill (filler). No permission requirements.", - "- instruction_params (Account): Optional account to load instruction parameters when they are not passed in the", - "instruction data due to message size constraints. Pass this program ID to represent None. When Some, this must", - "be derived from the signer's public key with seed [\"instruction_params\",signer].", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- mint (Account): The mint of the output token, sent from the relayer to the recipient.", - "- relayer_token_account (Writable): The relayer's ATA for the input token.", - "- recipient_token_account (Writable): The recipient's ATA for the output token.", - "- fill_status (Writable): The fill status PDA, created on this function call to track the fill status to prevent", - "re-entrancy & double fills. Also used to track requested slow fills. Seed: [\"fills\",relay_hash].", - "- token_program (Interface): The token program.", - "- associated_token_program (Interface): The associated token program.", - "- system_program (Interface): The system program.", - "- delegate (Account): The account used to delegate the output amount of the output token.", - "", - "### Parameters:", - "- relay_hash: The hash identifying the deposit to be filled. Caller must pass this in. Computed as hash of", - "the flattened relay_data & destination_chain_id.", - "- relay_data: Struct containing all the data needed to identify the deposit to be filled. Should match", - "all the same-named parameters emitted in the origin chain FundsDeposited event.", - "- depositor: The account credited with the deposit.", - "- recipient: The account receiving funds on this chain.", - "- input_token: The token pulled from the caller's account to initiate the deposit. The equivalent of this", - "token on the repayment chain will be sent as a refund to the caller.", - "- output_token: The token that the caller will send to the recipient on this chain.", - "- input_amount: This amount, less a system fee, will be sent to the caller on their repayment chain.", - "This is big-endian encoded as a 32-byte array to match its underlying byte representation on EVM side", - "- output_amount: The amount of output tokens that the caller will send to the recipient.", - "- origin_chain_id: The origin chain identifier.", - "- exclusive_relayer: The relayer that will be exclusively allowed to fill this deposit before the", - "exclusivity deadline timestamp.", - "- fill_deadline: The deadline for the caller to fill the deposit. After this timestamp, the deposit will be", - "cancelled and the depositor will be refunded on the origin chain.", - "- exclusivity_deadline: The deadline for the exclusive relayer to fill the deposit. After this timestamp,", - "anyone can fill this deposit.", - "- message: The message to send to the recipient if the recipient is a contract that implements a", - "handle_across_message() public function.", - "- repayment_chain_id: Chain of SpokePool where relayer wants to be refunded after the challenge window has", - "passed. Will receive input_amount of the equivalent token to input_token on the repayment chain.", - "- repayment_address: The address of the recipient on the repayment chain that they want to be refunded to.", - "Note: relay_data, repayment_chain_id, and repayment_address are optional parameters. If None for any of these", - "is passed, the caller must load them via the instruction_params account." - ], - "discriminator": [ - 100, - 84, - 222, - 90, - 106, - 209, - 58, - 222 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "instructionParams", - "writable": true, - "optional": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "delegate" - }, - { - "name": "mint" - }, - { - "name": "relayerTokenAccount", - "writable": true - }, - { - "name": "recipientTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "arg", - "path": "relayData" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "fillStatus", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 102, - 105, - 108, - 108, - 115 - ] - }, - { - "kind": "arg", - "path": "relayHash" - } - ] - } - }, - { - "name": "tokenProgram" - }, - { - "name": "associatedTokenProgram", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "relayHash", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "relayData", - "type": { - "option": { - "defined": { - "name": "relayData" - } - } - } - }, - { - "name": "repaymentChainId", - "type": { - "option": "u64" - } - }, - { - "name": "repaymentAddress", - "type": { - "option": "pubkey" - } - } - ] - }, - { - "name": "getUnsafeDepositId", - "docs": [ - "Computes the deposit ID for the depositor using the provided deposit_nonce. This acts like a \"view\" function for", - "off-chain actors to compute what the expected deposit ID is for a given depositor and deposit nonce will be.", - "", - "### Parameters:", - "- signer: The public key of the depositor sender.", - "- depositor: The public key of the depositor.", - "- deposit_nonce: The nonce used to derive the deposit ID." - ], - "discriminator": [ - 118, - 10, - 135, - 0, - 168, - 243, - 223, - 117 - ], - "accounts": [], - "args": [ - { - "name": "signer", - "type": "pubkey" - }, - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "depositNonce", - "type": "u64" - } - ], - "returns": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "handleReceiveMessage", - "docs": [ - "Handles cross-chain messages received from L1 Ethereum over CCTP.", - "", - "This function serves as the permissioned entry point for messages sent from the Ethereum mainnet to the Solana", - "SVM Spoke program over CCTP. It processes the incoming message by translating it into a corresponding Solana", - "instruction and then invokes the instruction within this program.", - "", - "### Required Accounts:", - "- authority_pda: A signer account that ensures this instruction can only be called by the Message Transmitter.", - "This acts to block that only the CCTP Message Transmitter can send messages to this program.", - "seed:[\"message_transmitter_authority\", program_id]", - "- state (Account): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet. Enforces that the", - "remote domain and sender are valid.", - "- self_authority: An unchecked account used for authenticating self-CPI invoked by the received message.", - "seed: [\"self_authority\"].", - "- program: The SVM Spoke program account.", - "", - "### Parameters:", - "- params: Contains information to process the received message, containing the following fields:", - "- remote_domain: The remote domain of the message sender.", - "- sender: The sender of the message.", - "- message_body: The body of the message.", - "- authority_bump: The authority bump for the message transmitter." - ], - "discriminator": [ - 133, - 102, - 1, - 180, - 145, - 11, - 138, - 180 - ], - "accounts": [ - { - "name": "authorityPda", - "signer": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 115, - 115, - 97, - 103, - 101, - 95, - 116, - 114, - 97, - 110, - 115, - 109, - 105, - 116, - 116, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "const", - "value": [ - 183, - 102, - 64, - 134, - 222, - 55, - 238, - 112, - 130, - 28, - 16, - 68, - 91, - 22, - 47, - 44, - 126, - 200, - 121, - 91, - 208, - 128, - 12, - 20, - 98, - 148, - 158, - 35, - 40, - 209, - 221, - 90 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 166, - 95, - 201, - 137, - 219, - 95, - 93, - 66, - 117, - 159, - 58, - 84, - 96, - 88, - 239, - 205, - 205, - 192, - 191, - 60, - 24, - 152, - 7, - 45, - 142, - 180, - 93, - 209, - 216, - 5, - 8, - 206 - ] - } - } - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "selfAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 101, - 108, - 102, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program", - "address": "DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "handleReceiveMessageParams" - } - } - } - ] - }, - { - "name": "initialize", - "docs": [ - "Initializes the state for the SVM Spoke Pool. Only callable once.", - "", - "### Required Accounts:", - "- signer (Writable, Signer): The account that pays for the transaction and will own the state.", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- system_program: The system program required for account creation.", - "", - "### Parameters:", - "- seed: A unique seed used to derive the state account's address. Must be 0 on Mainnet.", - "- initial_number_of_deposits: The initial number of deposits. Used to offset in upgrades.", - "- chain_id: The chain ID for Solana, used to identify the Solana spoke in the rest of the Across protocol.", - "- remote_domain: The CCTP domain for Mainnet Ethereum.", - "- cross_domain_admin: The HubPool on Mainnet Ethereum.", - "- deposit_quote_time_buffer: Quote timestamps can't be set more than this amount into the past from deposit.", - "- fill_deadline_buffer: Fill deadlines can't be set more than this amount into the future from deposit." - ], - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "arg", - "path": "seed" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "seed", - "type": "u64" - }, - { - "name": "initialNumberOfDeposits", - "type": "u32" - }, - { - "name": "chainId", - "type": "u64" - }, - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "crossDomainAdmin", - "type": "pubkey" - }, - { - "name": "depositQuoteTimeBuffer", - "type": "u32" - }, - { - "name": "fillDeadlineBuffer", - "type": "u32" - } - ] - }, - { - "name": "initializeClaimAccount", - "docs": [ - "Initializes a claim account for a relayer refund.", - "", - "This function sets up a claim account for a relayer to claim their refund at a later time and should only be", - "used in the un-happy path where a bundle cant not be executed due to a recipient in the bundle having a blocked", - "or uninitialized claim ATA. The refund address becomes the \"owner\" of the claim_account.", - "", - "### Required Accounts:", - "- signer (Signer): The account that pays for the transaction and initializes the claim account.", - "- mint: The mint associated with the claim account.", - "- refund_address: The refund address associated with the claim account.", - "- claim_account (Writable): The newly created claim account PDA to store claim data for this associated mint.", - "Seed: [\"claim_account\",mint,refund_address].", - "- system_program: The system program required for account creation." - ], - "discriminator": [ - 22, - 247, - 214, - 191, - 90, - 74, - 87, - 216 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "mint" - }, - { - "name": "refundAddress" - }, - { - "name": "claimAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 108, - 97, - 105, - 109, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "mint" - }, - { - "kind": "account", - "path": "refundAddress" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "initializeInstructionParams", - "docs": [ - "Initializes the instruction parameters account. Used by data worker when relaying bundles", - "", - "This function sets up an account to store raw data fragments for instructions (LUT).", - "", - "### Required Accounts:", - "- signer (Signer): The account that pays for the transaction and initializes the instruction parameters.", - "- instruction_params (UncheckedAccount): The account where raw data will be stored. Initialized with specified", - "size. seed: [\"instruction_params\",signer].", - "- system_program: The system program required for account creation.", - "", - "### Parameters:", - "- _total_size: The total size of the instruction parameters account." - ], - "discriminator": [ - 94, - 206, - 190, - 192, - 127, - 8, - 186, - 28 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "instructionParams", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "totalSize", - "type": "u32" - } - ] - }, - { - "name": "pauseDeposits", - "docs": [ - "Pauses the Spoke Pool from accepting deposits. Only callable by the owner.", - "", - "### Required Accounts:", - "- signer (Signer): The account that must be the owner to authorize the pause.", - "- state (Writable): The Spoke state PDA. Seed: [\"state\",state.seed], where `seed` is 0 on mainnet.", - "", - "### Parameters:", - "- pause: `true` to pause the system, `false` to unpause it." - ], - "discriminator": [ - 206, - 186, - 203, - 153, - 253, - 61, - 206, - 122 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "pause", - "type": "bool" - } - ] - }, - { - "name": "pauseFills", - "docs": [ - "Pauses the Spoke Pool from processing fills. Only callable by the owner.", - "", - "### Required Accounts:", - "- signer (Signer): The account that must be the owner to authorize the pause.", - "- state (Writable): The Spoke state PDA. Seed: [\"state\",state.seed], where `seed` is 0 on mainnet.", - "", - "### Parameters:", - "- pause: `true` to pause the system, `false` to unpause it." - ], - "discriminator": [ - 92, - 114, - 214, - 49, - 13, - 243, - 73, - 35 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "pause", - "type": "bool" - } - ] - }, - { - "name": "relayRootBundle", - "docs": [ - "Stores a new root bundle for later execution. Only callable by the owner.", - "", - "Once stored, these roots are used to execute relayer refunds, slow fills, and pool rebalancing actions.", - "This method initializes a root_bundle PDA to store the root bundle data. The caller", - "of this method is responsible for paying the rent for this PDA.", - "", - "### Required Accounts:", - "- signer (Signer): The account that must be the owner to authorize the addition of the new root bundle.", - "- payer (Signer): The account who pays rent to create root_bundle PDA.", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- root_bundle (Writable): The newly created bundle PDA to store root bundle data. Each root bundle has an", - "incrementing ID, stored in the state. Seed: [\"root_bundle\",state.seed,root_bundle_id].", - "- system_program (Program): The system program required for account creation.", - "", - "### Parameters:", - "- relayer_refund_root: Merkle root of the relayer refund tree.", - "- slow_relay_root: Merkle root of the slow relay tree." - ], - "discriminator": [ - 69, - 13, - 223, - 204, - 251, - 61, - 105, - 6 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "rootBundle", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 111, - 111, - 116, - 95, - 98, - 117, - 110, - 100, - 108, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - }, - { - "kind": "account", - "path": "state.root_bundle_id", - "account": "state" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "relayerRefundRoot", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "slowRelayRoot", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - }, - { - "name": "requestSlowFill", - "docs": [ - "Requests Across to send LP funds to this program to fulfill a slow fill.", - "", - "Slow fills are not possible unless the input and output tokens are \"equivalent\", i.e., they route to the same L1", - "token via PoolRebalanceRoutes. Slow fills are created by inserting slow fill objects into a Merkle tree that is", - "included in the next HubPool \"root bundle\". Once the optimistic challenge window has passed, the HubPool will", - "relay the slow root to this chain via relayRootBundle(). Once the slow root is relayed, the slow fill can be", - "executed by anyone who calls executeSlowRelayLeaf(). Cant request a slow fill if the fill deadline has", - "passed. Cant request a slow fill if the relay has already been filled or a slow fill has already been requested.", - "", - "### Required Accounts:", - "- signer (Signer): The account that authorizes the slow fill request.", - "- instruction_params (Account): Optional account to load instruction parameters when they are not passed in the", - "instruction data due to message size constraints. Pass this program ID to represent None. When Some, this must", - "be derived from the signer's public key with seed [\"instruction_params\",signer].", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "- fill_status (Writable): The fill status PDA, created on this function call. Updated to track slow fill status.", - "Used to prevent double request and fill. Seed: [\"fills\",relay_hash].", - "- system_program (Interface): The system program.", - "", - "### Parameters:", - "- _relay_hash: The hash identifying the deposit to be filled. Caller must pass this in. Computed as hash of", - "the flattened relay_data & destination_chain_id.", - "- relay_data: Struct containing all the data needed to identify the deposit that should be slow filled. If any", - "of the params are missing or different from the origin chain deposit, then Across will not include a slow", - "fill for the intended deposit. See fill_relay & RelayData struct for more details.", - "Note: relay_data is optional parameter. If None for it is passed, the caller must load it via the", - "instruction_params account." - ], - "discriminator": [ - 39, - 157, - 165, - 187, - 88, - 217, - 207, - 98 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "instructionParams", - "writable": true, - "optional": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "state", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "fillStatus", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 102, - 105, - 108, - 108, - 115 - ] - }, - { - "kind": "arg", - "path": "relayHash" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "relayHash", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "relayData", - "type": { - "option": { - "defined": { - "name": "relayData" - } - } - } - } - ] - }, - { - "name": "setCrossDomainAdmin", - "docs": [ - "Sets the cross-domain admin for the Spoke Pool. Only callable by owner. Used if Hubpool upgrades.", - "", - "### Required Accounts:", - "- signer (Signer): The account that must be the owner to authorize the admin change.", - "- state (Writable): Spoke state PDA. Seed: [\"state\",state.seed] where seed is 0 on mainnet.", - "", - "### Parameters:", - "- cross_domain_admin: The public key of the new cross-domain admin." - ], - "discriminator": [ - 102, - 206, - 237, - 106, - 63, - 141, - 42, - 248 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "crossDomainAdmin", - "type": "pubkey" - } - ] - }, - { - "name": "setCurrentTime", - "docs": [ - "Sets the current time for the SVM Spoke Pool when running in test mode. Disabled on Mainnet." - ], - "discriminator": [ - 69, - 100, - 169, - 193, - 125, - 0, - 150, - 69 - ], - "accounts": [ - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "signer", - "signer": true - } - ], - "args": [ - { - "name": "newTime", - "type": "u32" - } - ] - }, - { - "name": "transferOwnership", - "docs": [ - "Transfers ownership of the Spoke Pool. Only callable by the current owner.", - "", - "### Required Accounts:", - "- signer (Signer): The account that must be the current owner to authorize the transfer.", - "- state (Writable): The Spoke state PDA. Seed: [\"state\",state.seed] where `seed` is 0 on mainnet.", - "", - "### Parameters:", - "- new_owner: The public key of the new owner." - ], - "discriminator": [ - 65, - 177, - 215, - 73, - 53, - 45, - 99, - 47 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "newOwner", - "type": "pubkey" - } - ] - }, - { - "name": "unsafeDeposit", - "docs": [ - "Equivalent to deposit, except that it doesn't use the global `number_of_deposits` counter as the deposit", - "nonce. Instead, it allows the caller to pass a `deposit_nonce`. This function is designed for anyone who", - "wants to pre-compute their resultant deposit ID, which can be useful for filling a deposit faster and", - "avoiding the risk of a deposit ID unexpectedly changing due to another deposit front-running this one and", - "incrementing the global deposit ID counter. This enables the caller to influence the deposit ID, making it", - "deterministic for the depositor. The computed `depositID` is the keccak256 hash of [signer, depositor, deposit_nonce]." - ], - "discriminator": [ - 196, - 187, - 166, - 179, - 3, - 146, - 150, - 246 - ], - "accounts": [ - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "state", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 116, - 97, - 116, - 101 - ] - }, - { - "kind": "account", - "path": "state.seed", - "account": "state" - } - ] - } - }, - { - "name": "delegate" - }, - { - "name": "depositorTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "arg", - "path": "depositor" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "vault", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "state" - }, - { - "kind": "account", - "path": "tokenProgram" - }, - { - "kind": "account", - "path": "mint" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "mint" - }, - { - "name": "tokenProgram" - }, - { - "name": "associatedTokenProgram", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "inputToken", - "type": "pubkey" - }, - { - "name": "outputToken", - "type": "pubkey" - }, - { - "name": "inputAmount", - "type": "u64" - }, - { - "name": "outputAmount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "destinationChainId", - "type": "u64" - }, - { - "name": "exclusiveRelayer", - "type": "pubkey" - }, - { - "name": "depositNonce", - "type": "u64" - }, - { - "name": "quoteTimestamp", - "type": "u32" - }, - { - "name": "fillDeadline", - "type": "u32" - }, - { - "name": "exclusivityParameter", - "type": "u32" - }, - { - "name": "message", - "type": "bytes" - } - ] - }, - { - "name": "writeInstructionParamsFragment", - "docs": [ - "Writes a fragment of raw data into the instruction parameters account.", - "", - "This function allows writing a fragment of data into a specified offset within the instruction parameters", - "account. It ensures that the data does not overflow the account's allocated space.", - "", - "### Required Accounts:", - "- signer (Signer): Account that authorizes the write operation.", - "- instruction_params (UncheckedAccount): Account to write raw data to. seed: [\"instruction_params\",signer].", - "- system_program: The system program required for account operations.", - "", - "### Parameters:", - "- offset: The starting position within the account's data where the fragment will be written.", - "- fragment: The raw data fragment to be written into the account." - ], - "discriminator": [ - 238, - 182, - 109, - 113, - 124, - 255, - 72, - 18 - ], - "accounts": [ - { - "name": "signer", - "signer": true - }, - { - "name": "instructionParams", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 105, - 110, - 115, - 116, - 114, - 117, - 99, - 116, - 105, - 111, - 110, - 95, - 112, - 97, - 114, - 97, - 109, - 115 - ] - }, - { - "kind": "account", - "path": "signer" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "offset", - "type": "u32" - }, - { - "name": "fragment", - "type": "bytes" - } - ] - } - ], - "accounts": [ - { - "name": "claimAccount", - "discriminator": [ - 113, - 109, - 47, - 96, - 242, - 219, - 61, - 165 - ] - }, - { - "name": "executeRelayerRefundLeafParams", - "discriminator": [ - 192, - 59, - 93, - 9, - 171, - 77, - 28, - 250 - ] - }, - { - "name": "executeSlowRelayLeafParams", - "discriminator": [ - 135, - 208, - 119, - 251, - 14, - 222, - 66, - 155 - ] - }, - { - "name": "fillRelayParams", - "discriminator": [ - 50, - 243, - 51, - 185, - 89, - 60, - 43, - 202 - ] - }, - { - "name": "fillStatusAccount", - "discriminator": [ - 105, - 89, - 88, - 35, - 24, - 147, - 178, - 137 - ] - }, - { - "name": "requestSlowFillParams", - "discriminator": [ - 5, - 54, - 214, - 89, - 197, - 37, - 118, - 28 - ] - }, - { - "name": "rootBundle", - "discriminator": [ - 66, - 221, - 214, - 231, - 25, - 222, - 184, - 219 - ] - }, - { - "name": "state", - "discriminator": [ - 216, - 146, - 107, - 94, - 104, - 75, - 182, - 177 - ] - }, - { - "name": "transferLiability", - "discriminator": [ - 157, - 137, - 86, - 109, - 206, - 241, - 183, - 79 - ] - } - ], - "events": [ - { - "name": "bridgedToHubPool", - "discriminator": [ - 181, - 111, - 52, - 218, - 105, - 53, - 240, - 205 - ] - }, - { - "name": "claimedRelayerRefund", - "discriminator": [ - 161, - 134, - 155, - 159, - 211, - 37, - 150, - 41 - ] - }, - { - "name": "emergencyDeletedRootBundle", - "discriminator": [ - 45, - 150, - 89, - 248, - 134, - 142, - 200, - 114 - ] - }, - { - "name": "executedRelayerRefundRoot", - "discriminator": [ - 198, - 167, - 248, - 175, - 34, - 3, - 4, - 240 - ] - }, - { - "name": "filledRelay", - "discriminator": [ - 25, - 58, - 182, - 0, - 50, - 99, - 160, - 117 - ] - }, - { - "name": "fundsDeposited", - "discriminator": [ - 157, - 209, - 100, - 95, - 59, - 100, - 3, - 68 - ] - }, - { - "name": "pausedDeposits", - "discriminator": [ - 94, - 129, - 187, - 122, - 94, - 30, - 91, - 247 - ] - }, - { - "name": "pausedFills", - "discriminator": [ - 81, - 4, - 134, - 23, - 170, - 56, - 234, - 234 - ] - }, - { - "name": "relayedRootBundle", - "discriminator": [ - 188, - 206, - 117, - 10, - 66, - 78, - 77, - 115 - ] - }, - { - "name": "requestedSlowFill", - "discriminator": [ - 221, - 123, - 11, - 14, - 71, - 37, - 178, - 167 - ] - }, - { - "name": "setXDomainAdmin", - "discriminator": [ - 164, - 13, - 119, - 18, - 103, - 226, - 98, - 66 - ] - }, - { - "name": "tokensBridged", - "discriminator": [ - 200, - 201, - 199, - 39, - 5, - 238, - 214, - 196 - ] - }, - { - "name": "transferredOwnership", - "discriminator": [ - 235, - 235, - 154, - 16, - 153, - 94, - 21, - 117 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "invalidQuoteTimestamp", - "msg": "Invalid quote timestamp!" - }, - { - "code": 6001, - "name": "invalidFillDeadline", - "msg": "Invalid fill deadline!" - }, - { - "code": 6002, - "name": "notExclusiveRelayer", - "msg": "Caller is not the exclusive relayer and exclusivity deadline has not passed!" - }, - { - "code": 6003, - "name": "noSlowFillsInExclusivityWindow", - "msg": "The Deposit is still within the exclusivity window!" - }, - { - "code": 6004, - "name": "relayFilled", - "msg": "The relay has already been filled!" - }, - { - "code": 6005, - "name": "invalidSlowFillRequest", - "msg": "Slow fill requires status of Unfilled!" - }, - { - "code": 6006, - "name": "expiredFillDeadline", - "msg": "The fill deadline has passed!" - }, - { - "code": 6007, - "name": "invalidMerkleProof", - "msg": "Invalid Merkle proof!" - }, - { - "code": 6008, - "name": "invalidChainId", - "msg": "Invalid chain id!" - }, - { - "code": 6009, - "name": "invalidMerkleLeaf", - "msg": "Invalid Merkle leaf!" - }, - { - "code": 6010, - "name": "claimedMerkleLeaf", - "msg": "Leaf already claimed!" - }, - { - "code": 6011, - "name": "depositsArePaused", - "msg": "Deposits are currently paused!" - }, - { - "code": 6012, - "name": "fillsArePaused", - "msg": "Fills are currently paused!" - }, - { - "code": 6013, - "name": "insufficientSpokePoolBalanceToExecuteLeaf", - "msg": "Insufficient spoke pool balance to execute leaf" - }, - { - "code": 6014, - "name": "invalidExclusiveRelayer", - "msg": "Invalid exclusive relayer!" - }, - { - "code": 6015, - "name": "invalidOutputToken", - "msg": "Invalid output token!" - } - ], - "types": [ - { - "name": "bridgedToHubPool", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "claimAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "initializer", - "type": "pubkey" - } - ] - } - }, - { - "name": "claimedRelayerRefund", - "type": { - "kind": "struct", - "fields": [ - { - "name": "l2TokenAddress", - "type": "pubkey" - }, - { - "name": "claimAmount", - "type": "u64" - }, - { - "name": "refundAddress", - "type": "pubkey" - } - ] - } - }, - { - "name": "emergencyDeletedRootBundle", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rootBundleId", - "type": "u32" - } - ] - } - }, - { - "name": "executeRelayerRefundLeafParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rootBundleId", - "type": "u32" - }, - { - "name": "relayerRefundLeaf", - "type": { - "defined": { - "name": "relayerRefundLeaf" - } - } - }, - { - "name": "proof", - "type": { - "vec": { - "array": [ - "u8", - 32 - ] - } - } - } - ] - } - }, - { - "name": "executeSlowRelayLeafParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "slowFillLeaf", - "type": { - "defined": { - "name": "slowFill" - } - } - }, - { - "name": "rootBundleId", - "type": "u32" - }, - { - "name": "proof", - "type": { - "vec": { - "array": [ - "u8", - 32 - ] - } - } - } - ] - } - }, - { - "name": "executedRelayerRefundRoot", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amountToReturn", - "type": "u64" - }, - { - "name": "chainId", - "type": "u64" - }, - { - "name": "refundAmounts", - "type": { - "vec": "u64" - } - }, - { - "name": "rootBundleId", - "type": "u32" - }, - { - "name": "leafId", - "type": "u32" - }, - { - "name": "l2TokenAddress", - "type": "pubkey" - }, - { - "name": "refundAddresses", - "type": { - "vec": "pubkey" - } - }, - { - "name": "deferredRefunds", - "type": "bool" - }, - { - "name": "caller", - "type": "pubkey" - } - ] - } - }, - { - "name": "fillRelayParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "relayData", - "type": { - "defined": { - "name": "relayData" - } - } - }, - { - "name": "repaymentChainId", - "type": "u64" - }, - { - "name": "repaymentAddress", - "type": "pubkey" - } - ] - } - }, - { - "name": "fillStatus", - "type": { - "kind": "enum", - "variants": [ - { - "name": "unfilled" - }, - { - "name": "requestedSlowFill" - }, - { - "name": "filled" - } - ] - } - }, - { - "name": "fillStatusAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "status", - "type": { - "defined": { - "name": "fillStatus" - } - } - }, - { - "name": "relayer", - "type": "pubkey" - }, - { - "name": "fillDeadline", - "type": "u32" - } - ] - } - }, - { - "name": "fillType", - "type": { - "kind": "enum", - "variants": [ - { - "name": "fastFill" - }, - { - "name": "replacedSlowFill" - }, - { - "name": "slowFill" - } - ] - } - }, - { - "name": "filledRelay", - "type": { - "kind": "struct", - "fields": [ - { - "name": "inputToken", - "type": "pubkey" - }, - { - "name": "outputToken", - "type": "pubkey" - }, - { - "name": "inputAmount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "outputAmount", - "type": "u64" - }, - { - "name": "repaymentChainId", - "type": "u64" - }, - { - "name": "originChainId", - "type": "u64" - }, - { - "name": "depositId", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "fillDeadline", - "type": "u32" - }, - { - "name": "exclusivityDeadline", - "type": "u32" - }, - { - "name": "exclusiveRelayer", - "type": "pubkey" - }, - { - "name": "relayer", - "type": "pubkey" - }, - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "messageHash", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "relayExecutionInfo", - "type": { - "defined": { - "name": "relayExecutionEventInfo" - } - } - } - ] - } - }, - { - "name": "fundsDeposited", - "type": { - "kind": "struct", - "fields": [ - { - "name": "inputToken", - "type": "pubkey" - }, - { - "name": "outputToken", - "type": "pubkey" - }, - { - "name": "inputAmount", - "type": "u64" - }, - { - "name": "outputAmount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "destinationChainId", - "type": "u64" - }, - { - "name": "depositId", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "quoteTimestamp", - "type": "u32" - }, - { - "name": "fillDeadline", - "type": "u32" - }, - { - "name": "exclusivityDeadline", - "type": "u32" - }, - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "exclusiveRelayer", - "type": "pubkey" - }, - { - "name": "message", - "type": "bytes" - } - ] - } - }, - { - "name": "handleReceiveMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "sender", - "type": "pubkey" - }, - { - "name": "messageBody", - "type": "bytes" - }, - { - "name": "authorityBump", - "type": "u8" - } - ] - } - }, - { - "name": "pausedDeposits", - "type": { - "kind": "struct", - "fields": [ - { - "name": "isPaused", - "type": "bool" - } - ] - } - }, - { - "name": "pausedFills", - "type": { - "kind": "struct", - "fields": [ - { - "name": "isPaused", - "type": "bool" - } - ] - } - }, - { - "name": "relayData", - "type": { - "kind": "struct", - "fields": [ - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "exclusiveRelayer", - "type": "pubkey" - }, - { - "name": "inputToken", - "type": "pubkey" - }, - { - "name": "outputToken", - "type": "pubkey" - }, - { - "name": "inputAmount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "outputAmount", - "type": "u64" - }, - { - "name": "originChainId", - "type": "u64" - }, - { - "name": "depositId", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "fillDeadline", - "type": "u32" - }, - { - "name": "exclusivityDeadline", - "type": "u32" - }, - { - "name": "message", - "type": "bytes" - } - ] - } - }, - { - "name": "relayExecutionEventInfo", - "type": { - "kind": "struct", - "fields": [ - { - "name": "updatedRecipient", - "type": "pubkey" - }, - { - "name": "updatedMessageHash", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "updatedOutputAmount", - "type": "u64" - }, - { - "name": "fillType", - "type": { - "defined": { - "name": "fillType" - } - } - } - ] - } - }, - { - "name": "relayedRootBundle", - "type": { - "kind": "struct", - "fields": [ - { - "name": "rootBundleId", - "type": "u32" - }, - { - "name": "relayerRefundRoot", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "slowRelayRoot", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - } - }, - { - "name": "relayerRefundLeaf", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amountToReturn", - "type": "u64" - }, - { - "name": "chainId", - "type": "u64" - }, - { - "name": "refundAmounts", - "type": { - "vec": "u64" - } - }, - { - "name": "leafId", - "type": "u32" - }, - { - "name": "mintPublicKey", - "type": "pubkey" - }, - { - "name": "refundAddresses", - "type": { - "vec": "pubkey" - } - } - ] - } - }, - { - "name": "requestSlowFillParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "relayData", - "type": { - "defined": { - "name": "relayData" - } - } - } - ] - } - }, - { - "name": "requestedSlowFill", - "type": { - "kind": "struct", - "fields": [ - { - "name": "inputToken", - "type": "pubkey" - }, - { - "name": "outputToken", - "type": "pubkey" - }, - { - "name": "inputAmount", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "outputAmount", - "type": "u64" - }, - { - "name": "originChainId", - "type": "u64" - }, - { - "name": "depositId", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "fillDeadline", - "type": "u32" - }, - { - "name": "exclusivityDeadline", - "type": "u32" - }, - { - "name": "exclusiveRelayer", - "type": "pubkey" - }, - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "recipient", - "type": "pubkey" - }, - { - "name": "messageHash", - "type": { - "array": [ - "u8", - 32 - ] - } - } - ] - } - }, - { - "name": "rootBundle", - "type": { - "kind": "struct", - "fields": [ - { - "name": "relayerRefundRoot", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "slowRelayRoot", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "claimedBitmap", - "type": "bytes" - } - ] - } - }, - { - "name": "setXDomainAdmin", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newAdmin", - "type": "pubkey" - } - ] - } - }, - { - "name": "slowFill", - "type": { - "kind": "struct", - "fields": [ - { - "name": "relayData", - "type": { - "defined": { - "name": "relayData" - } - } - }, - { - "name": "chainId", - "type": "u64" - }, - { - "name": "updatedOutputAmount", - "type": "u64" - } - ] - } - }, - { - "name": "state", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pausedDeposits", - "type": "bool" - }, - { - "name": "pausedFills", - "type": "bool" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "seed", - "type": "u64" - }, - { - "name": "numberOfDeposits", - "type": "u32" - }, - { - "name": "chainId", - "type": "u64" - }, - { - "name": "currentTime", - "type": "u32" - }, - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "crossDomainAdmin", - "type": "pubkey" - }, - { - "name": "rootBundleId", - "type": "u32" - }, - { - "name": "depositQuoteTimeBuffer", - "type": "u32" - }, - { - "name": "fillDeadlineBuffer", - "type": "u32" - } - ] - } - }, - { - "name": "tokensBridged", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amountToReturn", - "type": "u64" - }, - { - "name": "chainId", - "type": "u64" - }, - { - "name": "leafId", - "type": "u32" - }, - { - "name": "l2TokenAddress", - "type": "pubkey" - }, - { - "name": "caller", - "type": "pubkey" - } - ] - } - }, - { - "name": "transferLiability", - "type": { - "kind": "struct", - "fields": [ - { - "name": "pendingToHubPool", - "type": "u64" - } - ] - } - }, - { - "name": "transferredOwnership", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newOwner", - "type": "pubkey" - } - ] - } - } - ] -}; diff --git a/src/svm/assets/test.ts b/src/svm/assets/test.ts deleted file mode 100644 index b18b39b2b..000000000 --- a/src/svm/assets/test.ts +++ /dev/null @@ -1,249 +0,0 @@ -/** - * Program IDL in camelCase format in order to be used in JS/TS. - * - * Note that this is only a type helper and is not the actual IDL. The original - * IDL can be found at `target/idl/test.json`. - */ -export type Test = { - "address": "8tsEfDSiE4WUMf97oyyyasLAvWwjeRZb2GByh4w7HckA", - "metadata": { - "name": "test", - "version": "0.1.0", - "spec": "0.1.0", - "description": "Created with Anchor" - }, - "instructions": [ - { - "name": "initialize", - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "bitmapAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 98, - 105, - 116, - 109, - 97, - 112, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - } - ] - } - }, - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "testEmitLargeLog", - "discriminator": [ - 126, - 64, - 160, - 189, - 160, - 160, - 238, - 68 - ], - "accounts": [], - "args": [ - { - "name": "length", - "type": "u32" - } - ] - }, - { - "name": "testIsClaimed", - "discriminator": [ - 82, - 227, - 141, - 60, - 27, - 165, - 109, - 90 - ], - "accounts": [ - { - "name": "bitmapAccount" - } - ], - "args": [ - { - "name": "index", - "type": "u32" - } - ], - "returns": "bool" - }, - { - "name": "testSetClaimed", - "discriminator": [ - 15, - 155, - 67, - 241, - 20, - 247, - 21, - 189 - ], - "accounts": [ - { - "name": "bitmapAccount", - "writable": true - }, - { - "name": "signer", - "writable": true, - "signer": true - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - } - ], - "args": [ - { - "name": "index", - "type": "u32" - } - ] - }, - { - "name": "verify", - "discriminator": [ - 133, - 161, - 141, - 48, - 120, - 198, - 88, - 150 - ], - "accounts": [], - "args": [ - { - "name": "root", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "leaf", - "type": { - "array": [ - "u8", - 32 - ] - } - }, - { - "name": "proof", - "type": { - "vec": { - "array": [ - "u8", - 32 - ] - } - } - } - ] - } - ], - "accounts": [ - { - "name": "bitmapAccount", - "discriminator": [ - 152, - 161, - 147, - 85, - 213, - 38, - 59, - 48 - ] - } - ], - "events": [ - { - "name": "testEvent", - "discriminator": [ - 28, - 52, - 39, - 105, - 8, - 210, - 91, - 9 - ] - } - ], - "types": [ - { - "name": "bitmapAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "claimedBitmap", - "type": "bytes" - } - ] - } - }, - { - "name": "testEvent", - "type": { - "kind": "struct", - "fields": [ - { - "name": "message", - "type": "string" - } - ] - } - } - ] -}; diff --git a/src/svm/assets/token_messenger_minter.ts b/src/svm/assets/token_messenger_minter.ts deleted file mode 100644 index 7ecacc2b5..000000000 --- a/src/svm/assets/token_messenger_minter.ts +++ /dev/null @@ -1,2055 +0,0 @@ -/** - * Program IDL in camelCase format in order to be used in JS/TS. - * - * Note that this is only a type helper and is not the actual IDL. The original - * IDL can be found at `target/idl/token_messenger_minter.json`. - */ -export type TokenMessengerMinter = { - "address": "CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3", - "metadata": { - "name": "tokenMessengerMinter", - "version": "0.1.0", - "spec": "0.1.0" - }, - "instructions": [ - { - "name": "initialize", - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "upgradeAuthority", - "signer": true - }, - { - "name": "authorityPda" - }, - { - "name": "tokenMessenger", - "writable": true - }, - { - "name": "tokenMinter", - "writable": true - }, - { - "name": "tokenMessengerMinterProgramData" - }, - { - "name": "tokenMessengerMinterProgram" - }, - { - "name": "systemProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "initializeParams" - } - } - } - ] - }, - { - "name": "transferOwnership", - "discriminator": [ - 65, - 177, - 215, - 73, - 53, - 45, - 99, - 47 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "tokenMessenger", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "transferOwnershipParams" - } - } - } - ] - }, - { - "name": "acceptOwnership", - "discriminator": [ - 172, - 23, - 43, - 13, - 238, - 213, - 85, - 150 - ], - "accounts": [ - { - "name": "pendingOwner", - "signer": true - }, - { - "name": "tokenMessenger", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "acceptOwnershipParams" - } - } - } - ] - }, - { - "name": "addRemoteTokenMessenger", - "discriminator": [ - 12, - 149, - 172, - 165, - 111, - 202, - 24, - 33 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "owner", - "signer": true - }, - { - "name": "tokenMessenger" - }, - { - "name": "remoteTokenMessenger", - "writable": true - }, - { - "name": "systemProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "addRemoteTokenMessengerParams" - } - } - } - ] - }, - { - "name": "removeRemoteTokenMessenger", - "discriminator": [ - 65, - 114, - 66, - 85, - 169, - 98, - 177, - 146 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "owner", - "signer": true - }, - { - "name": "tokenMessenger" - }, - { - "name": "remoteTokenMessenger", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "removeRemoteTokenMessengerParams" - } - } - } - ] - }, - { - "name": "depositForBurn", - "discriminator": [ - 215, - 60, - 61, - 46, - 114, - 55, - 128, - 176 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "eventRentPayer", - "writable": true, - "signer": true - }, - { - "name": "senderAuthorityPda" - }, - { - "name": "burnTokenAccount", - "writable": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "tokenMessenger" - }, - { - "name": "remoteTokenMessenger" - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true - }, - { - "name": "burnTokenMint", - "writable": true - }, - { - "name": "messageSentEventData", - "writable": true, - "signer": true - }, - { - "name": "messageTransmitterProgram" - }, - { - "name": "tokenMessengerMinterProgram" - }, - { - "name": "tokenProgram" - }, - { - "name": "systemProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "depositForBurnParams" - } - } - } - ], - "returns": "u64" - }, - { - "name": "depositForBurnWithCaller", - "discriminator": [ - 167, - 222, - 19, - 114, - 85, - 21, - 14, - 118 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "eventRentPayer", - "writable": true, - "signer": true - }, - { - "name": "senderAuthorityPda" - }, - { - "name": "burnTokenAccount", - "writable": true - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "tokenMessenger" - }, - { - "name": "remoteTokenMessenger" - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true - }, - { - "name": "burnTokenMint", - "writable": true - }, - { - "name": "messageSentEventData", - "writable": true, - "signer": true - }, - { - "name": "messageTransmitterProgram" - }, - { - "name": "tokenMessengerMinterProgram" - }, - { - "name": "tokenProgram" - }, - { - "name": "systemProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "depositForBurnWithCallerParams" - } - } - } - ], - "returns": "u64" - }, - { - "name": "replaceDepositForBurn", - "discriminator": [ - 7, - 27, - 93, - 132, - 1, - 80, - 19, - 163 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "eventRentPayer", - "writable": true, - "signer": true - }, - { - "name": "senderAuthorityPda" - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "tokenMessenger" - }, - { - "name": "messageSentEventData", - "writable": true, - "signer": true - }, - { - "name": "messageTransmitterProgram" - }, - { - "name": "tokenMessengerMinterProgram" - }, - { - "name": "systemProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "replaceDepositForBurnParams" - } - } - } - ], - "returns": "u64" - }, - { - "name": "handleReceiveMessage", - "discriminator": [ - 133, - 102, - 1, - 180, - 145, - 11, - 138, - 180 - ], - "accounts": [ - { - "name": "authorityPda", - "signer": true - }, - { - "name": "tokenMessenger" - }, - { - "name": "remoteTokenMessenger" - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true - }, - { - "name": "tokenPair" - }, - { - "name": "recipientTokenAccount", - "writable": true - }, - { - "name": "custodyTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "handleReceiveMessageParams" - } - } - } - ] - }, - { - "name": "setTokenController", - "discriminator": [ - 88, - 6, - 98, - 10, - 79, - 59, - 15, - 24 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "tokenMessenger" - }, - { - "name": "tokenMinter", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setTokenControllerParams" - } - } - } - ] - }, - { - "name": "pause", - "discriminator": [ - 211, - 22, - 221, - 251, - 74, - 121, - 193, - 47 - ], - "accounts": [ - { - "name": "pauser", - "signer": true - }, - { - "name": "tokenMinter", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "pauseParams" - } - } - } - ] - }, - { - "name": "unpause", - "discriminator": [ - 169, - 144, - 4, - 38, - 10, - 141, - 188, - 255 - ], - "accounts": [ - { - "name": "pauser", - "signer": true - }, - { - "name": "tokenMinter", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "unpauseParams" - } - } - } - ] - }, - { - "name": "updatePauser", - "discriminator": [ - 140, - 171, - 211, - 132, - 57, - 201, - 16, - 254 - ], - "accounts": [ - { - "name": "owner", - "signer": true - }, - { - "name": "tokenMessenger" - }, - { - "name": "tokenMinter", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "updatePauserParams" - } - } - } - ] - }, - { - "name": "setMaxBurnAmountPerMessage", - "discriminator": [ - 30, - 128, - 145, - 240, - 70, - 237, - 109, - 207 - ], - "accounts": [ - { - "name": "tokenController", - "signer": true - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setMaxBurnAmountPerMessageParams" - } - } - } - ] - }, - { - "name": "addLocalToken", - "discriminator": [ - 213, - 199, - 205, - 18, - 98, - 124, - 73, - 198 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "tokenController", - "signer": true - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true - }, - { - "name": "custodyTokenAccount", - "writable": true - }, - { - "name": "localTokenMint" - }, - { - "name": "tokenProgram" - }, - { - "name": "systemProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "addLocalTokenParams" - } - } - } - ] - }, - { - "name": "removeLocalToken", - "discriminator": [ - 27, - 43, - 66, - 170, - 188, - 44, - 109, - 97 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "tokenController", - "signer": true - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true - }, - { - "name": "custodyTokenAccount", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "removeLocalTokenParams" - } - } - } - ] - }, - { - "name": "linkTokenPair", - "discriminator": [ - 68, - 162, - 24, - 104, - 125, - 46, - 130, - 12 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "tokenController", - "signer": true - }, - { - "name": "tokenMinter" - }, - { - "name": "tokenPair", - "writable": true - }, - { - "name": "systemProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "linkTokenPairParams" - } - } - } - ] - }, - { - "name": "unlinkTokenPair", - "discriminator": [ - 52, - 198, - 100, - 114, - 104, - 174, - 85, - 58 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "tokenController", - "signer": true - }, - { - "name": "tokenMinter" - }, - { - "name": "tokenPair", - "writable": true - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "uninkTokenPairParams" - } - } - } - ] - }, - { - "name": "burnTokenCustody", - "discriminator": [ - 233, - 136, - 180, - 175, - 112, - 41, - 62, - 71 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "tokenController", - "signer": true - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken" - }, - { - "name": "custodyTokenAccount", - "writable": true - }, - { - "name": "custodyTokenMint", - "writable": true - }, - { - "name": "tokenProgram" - }, - { - "name": "eventAuthority" - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "burnTokenCustodyParams" - } - } - } - ] - } - ], - "accounts": [ - { - "name": "tokenMessenger", - "discriminator": [ - 162, - 4, - 242, - 52, - 147, - 243, - 221, - 96 - ] - }, - { - "name": "remoteTokenMessenger", - "discriminator": [ - 105, - 115, - 174, - 34, - 95, - 233, - 138, - 252 - ] - }, - { - "name": "tokenMinter", - "discriminator": [ - 122, - 133, - 84, - 63, - 57, - 159, - 171, - 206 - ] - }, - { - "name": "tokenPair", - "discriminator": [ - 17, - 214, - 45, - 176, - 229, - 149, - 197, - 71 - ] - }, - { - "name": "localToken", - "discriminator": [ - 159, - 131, - 58, - 170, - 193, - 84, - 128, - 182 - ] - } - ], - "events": [ - { - "name": "ownershipTransferStarted", - "discriminator": [ - 183, - 253, - 239, - 246, - 140, - 179, - 133, - 105 - ] - }, - { - "name": "ownershipTransferred", - "discriminator": [ - 172, - 61, - 205, - 183, - 250, - 50, - 38, - 98 - ] - }, - { - "name": "depositForBurn", - "discriminator": [ - 144, - 252, - 145, - 146, - 6, - 74, - 167, - 235 - ] - }, - { - "name": "mintAndWithdraw", - "discriminator": [ - 75, - 67, - 229, - 70, - 162, - 126, - 0, - 71 - ] - }, - { - "name": "remoteTokenMessengerAdded", - "discriminator": [ - 251, - 29, - 63, - 244, - 48, - 114, - 210, - 175 - ] - }, - { - "name": "remoteTokenMessengerRemoved", - "discriminator": [ - 255, - 121, - 137, - 39, - 230, - 125, - 11, - 30 - ] - }, - { - "name": "setTokenController", - "discriminator": [ - 193, - 44, - 243, - 83, - 230, - 72, - 120, - 216 - ] - }, - { - "name": "pauserChanged", - "discriminator": [ - 142, - 157, - 158, - 87, - 127, - 8, - 119, - 55 - ] - }, - { - "name": "setBurnLimitPerMessage", - "discriminator": [ - 98, - 152, - 88, - 191, - 245, - 30, - 27, - 209 - ] - }, - { - "name": "localTokenAdded", - "discriminator": [ - 146, - 8, - 224, - 150, - 122, - 173, - 23, - 39 - ] - }, - { - "name": "localTokenRemoved", - "discriminator": [ - 181, - 204, - 1, - 95, - 2, - 50, - 66, - 210 - ] - }, - { - "name": "tokenPairLinked", - "discriminator": [ - 2, - 14, - 177, - 64, - 155, - 93, - 196, - 141 - ] - }, - { - "name": "tokenPairUnlinked", - "discriminator": [ - 78, - 232, - 230, - 208, - 180, - 212, - 246, - 72 - ] - }, - { - "name": "pause", - "discriminator": [ - 194, - 251, - 232, - 196, - 118, - 95, - 111, - 219 - ] - }, - { - "name": "unpause", - "discriminator": [ - 241, - 149, - 104, - 90, - 199, - 136, - 219, - 146 - ] - }, - { - "name": "tokenCustodyBurned", - "discriminator": [ - 219, - 143, - 107, - 226, - 67, - 75, - 178, - 46 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "invalidAuthority", - "msg": "Invalid authority" - }, - { - "code": 6001, - "name": "invalidTokenMessengerState", - "msg": "Invalid token messenger state" - }, - { - "code": 6002, - "name": "invalidTokenMessenger", - "msg": "Invalid token messenger" - }, - { - "code": 6003, - "name": "invalidOwner", - "msg": "Invalid owner" - }, - { - "code": 6004, - "name": "malformedMessage", - "msg": "Malformed message" - }, - { - "code": 6005, - "name": "invalidMessageBodyVersion", - "msg": "Invalid message body version" - }, - { - "code": 6006, - "name": "invalidAmount", - "msg": "Invalid amount" - }, - { - "code": 6007, - "name": "invalidDestinationDomain", - "msg": "Invalid destination domain" - }, - { - "code": 6008, - "name": "invalidDestinationCaller", - "msg": "Invalid destination caller" - }, - { - "code": 6009, - "name": "invalidMintRecipient", - "msg": "Invalid mint recipient" - }, - { - "code": 6010, - "name": "invalidSender", - "msg": "Invalid sender" - }, - { - "code": 6011, - "name": "invalidTokenPair", - "msg": "Invalid token pair" - }, - { - "code": 6012, - "name": "invalidTokenMint", - "msg": "Invalid token mint" - } - ], - "types": [ - { - "name": "acceptOwnershipParams", - "type": { - "kind": "struct" - } - }, - { - "name": "addRemoteTokenMessengerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "tokenMessenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "depositForBurnWithCallerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "destinationDomain", - "type": "u32" - }, - { - "name": "mintRecipient", - "type": "pubkey" - }, - { - "name": "destinationCaller", - "type": "pubkey" - } - ] - } - }, - { - "name": "depositForBurnParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "destinationDomain", - "type": "u32" - }, - { - "name": "mintRecipient", - "type": "pubkey" - } - ] - } - }, - { - "name": "handleReceiveMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "sender", - "type": "pubkey" - }, - { - "name": "messageBody", - "type": "bytes" - }, - { - "name": "authorityBump", - "type": "u8" - } - ] - } - }, - { - "name": "initializeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "tokenController", - "type": "pubkey" - }, - { - "name": "localMessageTransmitter", - "type": "pubkey" - }, - { - "name": "messageBodyVersion", - "type": "u32" - } - ] - } - }, - { - "name": "removeRemoteTokenMessengerParams", - "type": { - "kind": "struct" - } - }, - { - "name": "replaceDepositForBurnParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "originalMessage", - "type": "bytes" - }, - { - "name": "originalAttestation", - "type": "bytes" - }, - { - "name": "newDestinationCaller", - "type": "pubkey" - }, - { - "name": "newMintRecipient", - "type": "pubkey" - } - ] - } - }, - { - "name": "transferOwnershipParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newOwner", - "type": "pubkey" - } - ] - } - }, - { - "name": "addLocalTokenParams", - "type": { - "kind": "struct" - } - }, - { - "name": "burnTokenCustodyParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "linkTokenPairParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "localToken", - "type": "pubkey" - }, - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "remoteToken", - "type": "pubkey" - } - ] - } - }, - { - "name": "pauseParams", - "type": { - "kind": "struct" - } - }, - { - "name": "removeLocalTokenParams", - "type": { - "kind": "struct" - } - }, - { - "name": "setMaxBurnAmountPerMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "burnLimitPerMessage", - "type": "u64" - } - ] - } - }, - { - "name": "setTokenControllerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "tokenController", - "type": "pubkey" - } - ] - } - }, - { - "name": "uninkTokenPairParams", - "type": { - "kind": "struct" - } - }, - { - "name": "unpauseParams", - "type": { - "kind": "struct" - } - }, - { - "name": "updatePauserParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newPauser", - "type": "pubkey" - } - ] - } - }, - { - "name": "tokenMinterError", - "type": { - "kind": "enum", - "variants": [ - { - "name": "invalidAuthority" - }, - { - "name": "invalidTokenMinterState" - }, - { - "name": "programPaused" - }, - { - "name": "invalidTokenPairState" - }, - { - "name": "invalidLocalTokenState" - }, - { - "name": "invalidPauser" - }, - { - "name": "invalidTokenController" - }, - { - "name": "burnAmountExceeded" - }, - { - "name": "invalidAmount" - } - ] - } - }, - { - "name": "tokenMessenger", - "type": { - "kind": "struct", - "fields": [ - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "pendingOwner", - "type": "pubkey" - }, - { - "name": "localMessageTransmitter", - "type": "pubkey" - }, - { - "name": "messageBodyVersion", - "type": "u32" - }, - { - "name": "authorityBump", - "type": "u8" - } - ] - } - }, - { - "name": "remoteTokenMessenger", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "tokenMessenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "tokenMinter", - "type": { - "kind": "struct", - "fields": [ - { - "name": "tokenController", - "type": "pubkey" - }, - { - "name": "pauser", - "type": "pubkey" - }, - { - "name": "paused", - "type": "bool" - }, - { - "name": "bump", - "type": "u8" - } - ] - } - }, - { - "name": "tokenPair", - "type": { - "kind": "struct", - "fields": [ - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "remoteToken", - "type": "pubkey" - }, - { - "name": "localToken", - "type": "pubkey" - }, - { - "name": "bump", - "type": "u8" - } - ] - } - }, - { - "name": "localToken", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "burnLimitPerMessage", - "type": "u64" - }, - { - "name": "messagesSent", - "type": "u64" - }, - { - "name": "messagesReceived", - "type": "u64" - }, - { - "name": "amountSent", - "type": "u128" - }, - { - "name": "amountReceived", - "type": "u128" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "custodyBump", - "type": "u8" - } - ] - } - }, - { - "name": "ownershipTransferStarted", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previousOwner", - "type": "pubkey" - }, - { - "name": "newOwner", - "type": "pubkey" - } - ] - } - }, - { - "name": "ownershipTransferred", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previousOwner", - "type": "pubkey" - }, - { - "name": "newOwner", - "type": "pubkey" - } - ] - } - }, - { - "name": "depositForBurn", - "type": { - "kind": "struct", - "fields": [ - { - "name": "nonce", - "type": "u64" - }, - { - "name": "burnToken", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "mintRecipient", - "type": "pubkey" - }, - { - "name": "destinationDomain", - "type": "u32" - }, - { - "name": "destinationTokenMessenger", - "type": "pubkey" - }, - { - "name": "destinationCaller", - "type": "pubkey" - } - ] - } - }, - { - "name": "mintAndWithdraw", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mintRecipient", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "mintToken", - "type": "pubkey" - } - ] - } - }, - { - "name": "remoteTokenMessengerAdded", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "tokenMessenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "remoteTokenMessengerRemoved", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "tokenMessenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "setTokenController", - "type": { - "kind": "struct", - "fields": [ - { - "name": "tokenController", - "type": "pubkey" - } - ] - } - }, - { - "name": "pauserChanged", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newAddress", - "type": "pubkey" - } - ] - } - }, - { - "name": "setBurnLimitPerMessage", - "type": { - "kind": "struct", - "fields": [ - { - "name": "token", - "type": "pubkey" - }, - { - "name": "burnLimitPerMessage", - "type": "u64" - } - ] - } - }, - { - "name": "localTokenAdded", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "localTokenRemoved", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "tokenPairLinked", - "type": { - "kind": "struct", - "fields": [ - { - "name": "localToken", - "type": "pubkey" - }, - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "remoteToken", - "type": "pubkey" - } - ] - } - }, - { - "name": "tokenPairUnlinked", - "type": { - "kind": "struct", - "fields": [ - { - "name": "localToken", - "type": "pubkey" - }, - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "remoteToken", - "type": "pubkey" - } - ] - } - }, - { - "name": "pause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "unpause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "tokenCustodyBurned", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custodyTokenAccount", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - } - ] - } - } - ] -}; diff --git a/src/svm/assets/token_messenger_minter_v2.ts b/src/svm/assets/token_messenger_minter_v2.ts deleted file mode 100644 index c447392f9..000000000 --- a/src/svm/assets/token_messenger_minter_v2.ts +++ /dev/null @@ -1,4447 +0,0 @@ -/** - * Program IDL in camelCase format in order to be used in JS/TS. - * - * Note that this is only a type helper and is not the actual IDL. The original - * IDL can be found at `target/idl/token_messenger_minter_v2.json`. - */ -export type TokenMessengerMinterV2 = { - "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe", - "metadata": { - "name": "tokenMessengerMinterV2", - "version": "0.2.0", - "spec": "0.1.0", - "description": "Token Messenger and Minter for Cross-Chain Transfer Protocol V2", - "repository": "https://github.com/circlefin/solana-cctp-contracts" - }, - "instructions": [ - { - "name": "acceptOwnership", - "discriminator": [ - 172, - 23, - 43, - 13, - 238, - 213, - 85, - 150 - ], - "accounts": [ - { - "name": "pendingOwner", - "signer": true, - "relations": [ - "tokenMessenger" - ] - }, - { - "name": "tokenMessenger", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "acceptOwnershipParams" - } - } - } - ] - }, - { - "name": "addLocalToken", - "discriminator": [ - 213, - 199, - 205, - 18, - 98, - 124, - 73, - 198 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "tokenController", - "signer": true, - "relations": [ - "tokenMinter" - ] - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "localTokenMint" - } - ] - } - }, - { - "name": "custodyTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "localTokenMint" - } - ] - } - }, - { - "name": "localTokenMint" - }, - { - "name": "tokenProgram", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "addLocalTokenParams" - } - } - } - ] - }, - { - "name": "addRemoteTokenMessenger", - "discriminator": [ - 12, - 149, - 172, - 165, - 111, - 202, - 24, - 33 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "owner", - "signer": true, - "relations": [ - "tokenMessenger" - ] - }, - { - "name": "tokenMessenger" - }, - { - "name": "remoteTokenMessenger", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 109, - 111, - 116, - 101, - 95, - 116, - 111, - 107, - 101, - 110, - 95, - 109, - 101, - 115, - 115, - 101, - 110, - 103, - 101, - 114 - ] - }, - { - "kind": "arg", - "path": "params.domain" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "addRemoteTokenMessengerParams" - } - } - } - ] - }, - { - "name": "burnTokenCustody", - "discriminator": [ - 233, - 136, - 180, - 175, - 112, - 41, - 62, - 71 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "tokenController", - "signer": true, - "relations": [ - "tokenMinter" - ] - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "localToken" - } - ] - } - }, - { - "name": "custodyTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "localToken" - } - ] - } - }, - { - "name": "custodyTokenMint", - "writable": true - }, - { - "name": "tokenProgram", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "burnTokenCustodyParams" - } - } - } - ] - }, - { - "name": "denylistAccount", - "discriminator": [ - 101, - 116, - 197, - 112, - 81, - 249, - 75, - 194 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "denylister", - "signer": true, - "relations": [ - "tokenMessenger" - ] - }, - { - "name": "tokenMessenger" - }, - { - "name": "denylistAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 100, - 101, - 110, - 121, - 108, - 105, - 115, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "arg", - "path": "params.account" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "denylistParams" - } - } - } - ] - }, - { - "name": "depositForBurn", - "discriminator": [ - 215, - 60, - 61, - 46, - 114, - 55, - 128, - 176 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "burnTokenAccount" - ] - }, - { - "name": "eventRentPayer", - "writable": true, - "signer": true - }, - { - "name": "senderAuthorityPda", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 101, - 110, - 100, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "burnTokenAccount", - "writable": true - }, - { - "name": "denylistAccount", - "docs": [ - "Account is denylisted if the account exists at the expected PDA." - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 100, - 101, - 110, - 121, - 108, - 105, - 115, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "owner" - } - ] - } - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "tokenMessenger" - }, - { - "name": "remoteTokenMessenger" - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "burnTokenMint" - } - ] - } - }, - { - "name": "burnTokenMint", - "writable": true - }, - { - "name": "messageSentEventData", - "writable": true, - "signer": true - }, - { - "name": "messageTransmitterProgram", - "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" - }, - { - "name": "tokenMessengerMinterProgram", - "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" - }, - { - "name": "tokenProgram", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "depositForBurnParams" - } - } - } - ] - }, - { - "name": "depositForBurnWithHook", - "discriminator": [ - 111, - 245, - 62, - 131, - 204, - 108, - 223, - 155 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "burnTokenAccount" - ] - }, - { - "name": "eventRentPayer", - "writable": true, - "signer": true - }, - { - "name": "senderAuthorityPda", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 101, - 110, - 100, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "burnTokenAccount", - "writable": true - }, - { - "name": "denylistAccount", - "docs": [ - "Account is denylisted if the account exists at the expected PDA." - ], - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 100, - 101, - 110, - 121, - 108, - 105, - 115, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "account", - "path": "owner" - } - ] - } - }, - { - "name": "messageTransmitter", - "writable": true - }, - { - "name": "tokenMessenger" - }, - { - "name": "remoteTokenMessenger" - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "burnTokenMint" - } - ] - } - }, - { - "name": "burnTokenMint", - "writable": true - }, - { - "name": "messageSentEventData", - "writable": true, - "signer": true - }, - { - "name": "messageTransmitterProgram", - "address": "CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC" - }, - { - "name": "tokenMessengerMinterProgram", - "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" - }, - { - "name": "tokenProgram", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "depositForBurnWithHookParams" - } - } - } - ] - }, - { - "name": "handleReceiveFinalizedMessage", - "discriminator": [ - 186, - 252, - 239, - 70, - 86, - 180, - 110, - 95 - ], - "accounts": [ - { - "name": "authorityPda", - "signer": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 115, - 115, - 97, - 103, - 101, - 95, - 116, - 114, - 97, - 110, - 115, - 109, - 105, - 116, - 116, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "const", - "value": [ - 166, - 95, - 200, - 29, - 15, - 239, - 168, - 134, - 12, - 179, - 184, - 63, - 8, - 155, - 2, - 36, - 190, - 138, - 102, - 135, - 183, - 174, - 73, - 245, - 148, - 192, - 185, - 180, - 215, - 233, - 56, - 147 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 166, - 95, - 200, - 28, - 225, - 158, - 220, - 210, - 210, - 195, - 64, - 176, - 47, - 166, - 27, - 225, - 213, - 186, - 221, - 225, - 89, - 40, - 51, - 221, - 249, - 32, - 9, - 216, - 207, - 104, - 84, - 85 - ] - } - } - }, - { - "name": "tokenMessenger" - }, - { - "name": "remoteTokenMessenger" - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "localToken" - } - ] - } - }, - { - "name": "tokenPair" - }, - { - "name": "feeRecipientTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "token_messenger.fee_recipient", - "account": "tokenMessenger" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "localToken" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "recipientTokenAccount", - "writable": true - }, - { - "name": "custodyTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "localToken" - } - ] - } - }, - { - "name": "tokenProgram", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "handleReceiveMessageParams" - } - } - } - ] - }, - { - "name": "handleReceiveUnfinalizedMessage", - "discriminator": [ - 200, - 169, - 175, - 20, - 200, - 58, - 182, - 61 - ], - "accounts": [ - { - "name": "authorityPda", - "signer": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 109, - 101, - 115, - 115, - 97, - 103, - 101, - 95, - 116, - 114, - 97, - 110, - 115, - 109, - 105, - 116, - 116, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - }, - { - "kind": "const", - "value": [ - 166, - 95, - 200, - 29, - 15, - 239, - 168, - 134, - 12, - 179, - 184, - 63, - 8, - 155, - 2, - 36, - 190, - 138, - 102, - 135, - 183, - 174, - 73, - 245, - 148, - 192, - 185, - 180, - 215, - 233, - 56, - 147 - ] - } - ], - "program": { - "kind": "const", - "value": [ - 166, - 95, - 200, - 28, - 225, - 158, - 220, - 210, - 210, - 195, - 64, - 176, - 47, - 166, - 27, - 225, - 213, - 186, - 221, - 225, - 89, - 40, - 51, - 221, - 249, - 32, - 9, - 216, - 207, - 104, - 84, - 85 - ] - } - } - }, - { - "name": "tokenMessenger" - }, - { - "name": "remoteTokenMessenger" - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "localToken" - } - ] - } - }, - { - "name": "tokenPair" - }, - { - "name": "feeRecipientTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "account", - "path": "token_messenger.fee_recipient", - "account": "tokenMessenger" - }, - { - "kind": "const", - "value": [ - 6, - 221, - 246, - 225, - 215, - 101, - 161, - 147, - 217, - 203, - 225, - 70, - 206, - 235, - 121, - 172, - 28, - 180, - 133, - 237, - 95, - 91, - 55, - 145, - 58, - 140, - 245, - 133, - 126, - 255, - 0, - 169 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "localToken" - } - ], - "program": { - "kind": "const", - "value": [ - 140, - 151, - 37, - 143, - 78, - 36, - 137, - 241, - 187, - 61, - 16, - 41, - 20, - 142, - 13, - 131, - 11, - 90, - 19, - 153, - 218, - 255, - 16, - 132, - 4, - 142, - 123, - 216, - 219, - 233, - 248, - 89 - ] - } - } - }, - { - "name": "recipientTokenAccount", - "writable": true - }, - { - "name": "custodyTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "localToken" - } - ] - } - }, - { - "name": "tokenProgram", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "handleReceiveMessageParams" - } - } - } - ] - }, - { - "name": "initialize", - "discriminator": [ - 175, - 175, - 109, - 31, - 13, - 152, - 155, - 237 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "upgradeAuthority", - "signer": true - }, - { - "name": "authorityPda", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 115, - 101, - 110, - 100, - 101, - 114, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "tokenMessenger", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 109, - 101, - 115, - 115, - 101, - 110, - 103, - 101, - 114 - ] - } - ] - } - }, - { - "name": "tokenMinter", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 109, - 105, - 110, - 116, - 101, - 114 - ] - } - ] - } - }, - { - "name": "tokenMessengerMinterProgramData" - }, - { - "name": "tokenMessengerMinterProgram", - "address": "CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe" - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "initializeParams" - } - } - } - ] - }, - { - "name": "linkTokenPair", - "discriminator": [ - 68, - 162, - 24, - 104, - 125, - 46, - 130, - 12 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "tokenController", - "signer": true, - "relations": [ - "tokenMinter" - ] - }, - { - "name": "tokenMinter" - }, - { - "name": "tokenPair", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 112, - 97, - 105, - 114 - ] - }, - { - "kind": "arg", - "path": "params.remote_domain" - }, - { - "kind": "arg", - "path": "params.remote_token" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "linkTokenPairParams" - } - } - } - ] - }, - { - "name": "pause", - "discriminator": [ - 211, - 22, - 221, - 251, - 74, - 121, - 193, - 47 - ], - "accounts": [ - { - "name": "pauser", - "signer": true, - "relations": [ - "tokenMinter" - ] - }, - { - "name": "tokenMinter", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "pauseParams" - } - } - } - ] - }, - { - "name": "removeLocalToken", - "discriminator": [ - 27, - 43, - 66, - 170, - 188, - 44, - 109, - 97 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "tokenController", - "signer": true, - "relations": [ - "tokenMinter" - ] - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "localToken" - } - ] - } - }, - { - "name": "custodyTokenAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 99, - 117, - 115, - 116, - 111, - 100, - 121 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "localToken" - } - ] - } - }, - { - "name": "custodyTokenMint", - "writable": true - }, - { - "name": "tokenProgram", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "removeLocalTokenParams" - } - } - } - ] - }, - { - "name": "removeRemoteTokenMessenger", - "discriminator": [ - 65, - 114, - 66, - 85, - 169, - 98, - 177, - 146 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "owner", - "signer": true, - "relations": [ - "tokenMessenger" - ] - }, - { - "name": "tokenMessenger" - }, - { - "name": "remoteTokenMessenger", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 114, - 101, - 109, - 111, - 116, - 101, - 95, - 116, - 111, - 107, - 101, - 110, - 95, - 109, - 101, - 115, - 115, - 101, - 110, - 103, - 101, - 114 - ] - }, - { - "kind": "account", - "path": "remote_token_messenger.domain", - "account": "remoteTokenMessenger" - } - ] - } - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "removeRemoteTokenMessengerParams" - } - } - } - ] - }, - { - "name": "setFeeRecipient", - "discriminator": [ - 227, - 18, - 215, - 42, - 237, - 246, - 151, - 66 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "tokenMessenger" - ] - }, - { - "name": "tokenMessenger", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setFeeRecipientParams" - } - } - } - ] - }, - { - "name": "setMaxBurnAmountPerMessage", - "discriminator": [ - 30, - 128, - 145, - 240, - 70, - 237, - 109, - 207 - ], - "accounts": [ - { - "name": "tokenController", - "signer": true, - "relations": [ - "tokenMinter" - ] - }, - { - "name": "tokenMinter" - }, - { - "name": "localToken", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 108, - 111, - 99, - 97, - 108, - 95, - 116, - 111, - 107, - 101, - 110 - ] - }, - { - "kind": "account", - "path": "local_token.mint", - "account": "localToken" - } - ] - } - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setMaxBurnAmountPerMessageParams" - } - } - } - ] - }, - { - "name": "setMinFee", - "discriminator": [ - 114, - 198, - 35, - 3, - 41, - 196, - 194, - 246 - ], - "accounts": [ - { - "name": "minFeeController", - "signer": true, - "relations": [ - "tokenMessenger" - ] - }, - { - "name": "tokenMessenger", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setMinFeeParams" - } - } - } - ] - }, - { - "name": "setMinFeeController", - "discriminator": [ - 195, - 142, - 74, - 84, - 234, - 94, - 180, - 113 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "tokenMessenger" - ] - }, - { - "name": "tokenMessenger", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setMinFeeControllerParams" - } - } - } - ] - }, - { - "name": "setTokenController", - "discriminator": [ - 88, - 6, - 98, - 10, - 79, - 59, - 15, - 24 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "tokenMessenger" - ] - }, - { - "name": "tokenMessenger" - }, - { - "name": "tokenMinter", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "setTokenControllerParams" - } - } - } - ] - }, - { - "name": "transferOwnership", - "discriminator": [ - 65, - 177, - 215, - 73, - 53, - 45, - 99, - 47 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "tokenMessenger" - ] - }, - { - "name": "tokenMessenger", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "transferOwnershipParams" - } - } - } - ] - }, - { - "name": "undenylistAccount", - "discriminator": [ - 57, - 36, - 43, - 168, - 62, - 172, - 33, - 39 - ], - "accounts": [ - { - "name": "payer", - "writable": true, - "signer": true - }, - { - "name": "denylister", - "signer": true, - "relations": [ - "tokenMessenger" - ] - }, - { - "name": "tokenMessenger" - }, - { - "name": "denylistAccount", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 100, - 101, - 110, - 121, - 108, - 105, - 115, - 116, - 95, - 97, - 99, - 99, - 111, - 117, - 110, - 116 - ] - }, - { - "kind": "arg", - "path": "params.account" - } - ] - } - }, - { - "name": "systemProgram", - "address": "11111111111111111111111111111111" - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "undenylistParams" - } - } - } - ] - }, - { - "name": "unlinkTokenPair", - "discriminator": [ - 52, - 198, - 100, - 114, - 104, - 174, - 85, - 58 - ], - "accounts": [ - { - "name": "payee", - "writable": true, - "signer": true - }, - { - "name": "tokenController", - "signer": true, - "relations": [ - "tokenMinter" - ] - }, - { - "name": "tokenMinter" - }, - { - "name": "tokenPair", - "writable": true, - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 116, - 111, - 107, - 101, - 110, - 95, - 112, - 97, - 105, - 114 - ] - }, - { - "kind": "account", - "path": "token_pair.remote_domain", - "account": "tokenPair" - }, - { - "kind": "account", - "path": "token_pair.remote_token", - "account": "tokenPair" - } - ] - } - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "uninkTokenPairParams" - } - } - } - ] - }, - { - "name": "unpause", - "discriminator": [ - 169, - 144, - 4, - 38, - 10, - 141, - 188, - 255 - ], - "accounts": [ - { - "name": "pauser", - "signer": true, - "relations": [ - "tokenMinter" - ] - }, - { - "name": "tokenMinter", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "unpauseParams" - } - } - } - ] - }, - { - "name": "updateDenylister", - "discriminator": [ - 193, - 66, - 198, - 201, - 84, - 57, - 14, - 222 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "tokenMessenger" - ] - }, - { - "name": "tokenMessenger", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "updateDenylisterParams" - } - } - } - ] - }, - { - "name": "updatePauser", - "discriminator": [ - 140, - 171, - 211, - 132, - 57, - 201, - 16, - 254 - ], - "accounts": [ - { - "name": "owner", - "signer": true, - "relations": [ - "tokenMessenger" - ] - }, - { - "name": "tokenMessenger" - }, - { - "name": "tokenMinter", - "writable": true - }, - { - "name": "eventAuthority", - "pda": { - "seeds": [ - { - "kind": "const", - "value": [ - 95, - 95, - 101, - 118, - 101, - 110, - 116, - 95, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ] - } - ] - } - }, - { - "name": "program" - } - ], - "args": [ - { - "name": "params", - "type": { - "defined": { - "name": "updatePauserParams" - } - } - } - ] - } - ], - "accounts": [ - { - "name": "denylistedAccount", - "discriminator": [ - 186, - 58, - 212, - 239, - 102, - 131, - 157, - 146 - ] - }, - { - "name": "localToken", - "discriminator": [ - 159, - 131, - 58, - 170, - 193, - 84, - 128, - 182 - ] - }, - { - "name": "messageTransmitter", - "discriminator": [ - 71, - 40, - 180, - 142, - 19, - 203, - 35, - 252 - ] - }, - { - "name": "remoteTokenMessenger", - "discriminator": [ - 105, - 115, - 174, - 34, - 95, - 233, - 138, - 252 - ] - }, - { - "name": "tokenMessenger", - "discriminator": [ - 162, - 4, - 242, - 52, - 147, - 243, - 221, - 96 - ] - }, - { - "name": "tokenMinter", - "discriminator": [ - 122, - 133, - 84, - 63, - 57, - 159, - 171, - 206 - ] - }, - { - "name": "tokenPair", - "discriminator": [ - 17, - 214, - 45, - 176, - 229, - 149, - 197, - 71 - ] - } - ], - "events": [ - { - "name": "denylisted", - "discriminator": [ - 20, - 145, - 173, - 200, - 182, - 17, - 234, - 154 - ] - }, - { - "name": "denylisterChanged", - "discriminator": [ - 249, - 170, - 81, - 180, - 185, - 175, - 138, - 72 - ] - }, - { - "name": "depositForBurn", - "discriminator": [ - 144, - 252, - 145, - 146, - 6, - 74, - 167, - 235 - ] - }, - { - "name": "feeRecipientSet", - "discriminator": [ - 99, - 140, - 80, - 35, - 245, - 176, - 179, - 110 - ] - }, - { - "name": "localTokenAdded", - "discriminator": [ - 146, - 8, - 224, - 150, - 122, - 173, - 23, - 39 - ] - }, - { - "name": "localTokenRemoved", - "discriminator": [ - 181, - 204, - 1, - 95, - 2, - 50, - 66, - 210 - ] - }, - { - "name": "minFeeControllerSet", - "discriminator": [ - 239, - 12, - 122, - 105, - 231, - 114, - 13, - 196 - ] - }, - { - "name": "minFeeSet", - "discriminator": [ - 60, - 127, - 101, - 230, - 216, - 129, - 188, - 98 - ] - }, - { - "name": "mintAndWithdraw", - "discriminator": [ - 75, - 67, - 229, - 70, - 162, - 126, - 0, - 71 - ] - }, - { - "name": "ownershipTransferStarted", - "discriminator": [ - 183, - 253, - 239, - 246, - 140, - 179, - 133, - 105 - ] - }, - { - "name": "ownershipTransferred", - "discriminator": [ - 172, - 61, - 205, - 183, - 250, - 50, - 38, - 98 - ] - }, - { - "name": "pause", - "discriminator": [ - 194, - 251, - 232, - 196, - 118, - 95, - 111, - 219 - ] - }, - { - "name": "pauserChanged", - "discriminator": [ - 142, - 157, - 158, - 87, - 127, - 8, - 119, - 55 - ] - }, - { - "name": "remoteTokenMessengerAdded", - "discriminator": [ - 251, - 29, - 63, - 244, - 48, - 114, - 210, - 175 - ] - }, - { - "name": "remoteTokenMessengerRemoved", - "discriminator": [ - 255, - 121, - 137, - 39, - 230, - 125, - 11, - 30 - ] - }, - { - "name": "setBurnLimitPerMessage", - "discriminator": [ - 98, - 152, - 88, - 191, - 245, - 30, - 27, - 209 - ] - }, - { - "name": "setTokenController", - "discriminator": [ - 193, - 44, - 243, - 83, - 230, - 72, - 120, - 216 - ] - }, - { - "name": "tokenCustodyBurned", - "discriminator": [ - 219, - 143, - 107, - 226, - 67, - 75, - 178, - 46 - ] - }, - { - "name": "tokenPairLinked", - "discriminator": [ - 2, - 14, - 177, - 64, - 155, - 93, - 196, - 141 - ] - }, - { - "name": "tokenPairUnlinked", - "discriminator": [ - 78, - 232, - 230, - 208, - 180, - 212, - 246, - 72 - ] - }, - { - "name": "unDenylisted", - "discriminator": [ - 150, - 39, - 227, - 20, - 162, - 180, - 5, - 242 - ] - }, - { - "name": "unpause", - "discriminator": [ - 241, - 149, - 104, - 90, - 199, - 136, - 219, - 146 - ] - } - ], - "errors": [ - { - "code": 6000, - "name": "invalidAuthority", - "msg": "Invalid authority" - }, - { - "code": 6001, - "name": "invalidTokenMinterState", - "msg": "Invalid token minter state" - }, - { - "code": 6002, - "name": "programPaused", - "msg": "Instruction is not allowed at this time" - }, - { - "code": 6003, - "name": "invalidTokenPairState", - "msg": "Invalid token pair state" - }, - { - "code": 6004, - "name": "invalidLocalTokenState", - "msg": "Invalid local token state" - }, - { - "code": 6005, - "name": "invalidPauser", - "msg": "Invalid pauser" - }, - { - "code": 6006, - "name": "invalidTokenController", - "msg": "Invalid token controller" - }, - { - "code": 6007, - "name": "burnAmountExceeded", - "msg": "Burn amount exceeded" - }, - { - "code": 6008, - "name": "invalidAmount", - "msg": "Invalid amount" - } - ], - "types": [ - { - "name": "acceptOwnershipParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "addLocalTokenParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "addRemoteTokenMessengerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "tokenMessenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "burnTokenCustodyParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "denylistParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "account", - "type": "pubkey" - } - ] - } - }, - { - "name": "denylisted", - "type": { - "kind": "struct", - "fields": [ - { - "name": "account", - "type": "pubkey" - } - ] - } - }, - { - "name": "denylistedAccount", - "type": { - "kind": "struct", - "fields": [ - { - "name": "account", - "type": "pubkey" - } - ] - } - }, - { - "name": "denylisterChanged", - "type": { - "kind": "struct", - "fields": [ - { - "name": "oldDenylister", - "type": "pubkey" - }, - { - "name": "newDenylister", - "type": "pubkey" - } - ] - } - }, - { - "name": "depositForBurn", - "type": { - "kind": "struct", - "fields": [ - { - "name": "burnToken", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "depositor", - "type": "pubkey" - }, - { - "name": "mintRecipient", - "type": "pubkey" - }, - { - "name": "destinationDomain", - "type": "u32" - }, - { - "name": "destinationTokenMessenger", - "type": "pubkey" - }, - { - "name": "destinationCaller", - "type": "pubkey" - }, - { - "name": "maxFee", - "type": "u64" - }, - { - "name": "minFinalityThreshold", - "type": "u32" - }, - { - "name": "hookData", - "type": "bytes" - } - ] - } - }, - { - "name": "depositForBurnParams", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "destinationDomain", - "type": "u32" - }, - { - "name": "mintRecipient", - "type": "pubkey" - }, - { - "name": "destinationCaller", - "type": "pubkey" - }, - { - "name": "maxFee", - "type": "u64" - }, - { - "name": "minFinalityThreshold", - "type": "u32" - } - ] - } - }, - { - "name": "depositForBurnWithHookParams", - "repr": { - "kind": "c" - }, - "type": { - "kind": "struct", - "fields": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "destinationDomain", - "type": "u32" - }, - { - "name": "mintRecipient", - "type": "pubkey" - }, - { - "name": "destinationCaller", - "type": "pubkey" - }, - { - "name": "maxFee", - "type": "u64" - }, - { - "name": "minFinalityThreshold", - "type": "u32" - }, - { - "name": "hookData", - "type": "bytes" - } - ] - } - }, - { - "name": "feeRecipientSet", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newFeeRecipient", - "type": "pubkey" - } - ] - } - }, - { - "name": "handleReceiveMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "sender", - "type": "pubkey" - }, - { - "name": "finalityThresholdExecuted", - "type": "u32" - }, - { - "name": "messageBody", - "type": "bytes" - }, - { - "name": "authorityBump", - "type": "u8" - } - ] - } - }, - { - "name": "initializeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "tokenController", - "type": "pubkey" - }, - { - "name": "denylister", - "type": "pubkey" - }, - { - "name": "feeRecipient", - "type": "pubkey" - }, - { - "name": "minFeeController", - "type": "pubkey" - }, - { - "name": "minFee", - "type": "u32" - }, - { - "name": "messageBodyVersion", - "type": "u32" - } - ] - } - }, - { - "name": "linkTokenPairParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "localToken", - "type": "pubkey" - }, - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "remoteToken", - "type": "pubkey" - } - ] - } - }, - { - "name": "localToken", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - }, - { - "name": "burnLimitPerMessage", - "type": "u64" - }, - { - "name": "messagesSent", - "type": "u64" - }, - { - "name": "messagesReceived", - "type": "u64" - }, - { - "name": "amountSent", - "type": "u128" - }, - { - "name": "amountReceived", - "type": "u128" - }, - { - "name": "bump", - "type": "u8" - }, - { - "name": "custodyBump", - "type": "u8" - } - ] - } - }, - { - "name": "localTokenAdded", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "localTokenRemoved", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custody", - "type": "pubkey" - }, - { - "name": "mint", - "type": "pubkey" - } - ] - } - }, - { - "name": "messageTransmitter", - "docs": [ - "Main state of the MessageTransmitter program" - ], - "type": { - "kind": "struct", - "fields": [ - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "pendingOwner", - "type": "pubkey" - }, - { - "name": "attesterManager", - "type": "pubkey" - }, - { - "name": "pauser", - "type": "pubkey" - }, - { - "name": "paused", - "type": "bool" - }, - { - "name": "localDomain", - "type": "u32" - }, - { - "name": "version", - "type": "u32" - }, - { - "name": "signatureThreshold", - "type": "u32" - }, - { - "name": "enabledAttesters", - "type": { - "vec": "pubkey" - } - }, - { - "name": "maxMessageBodySize", - "type": "u64" - } - ] - } - }, - { - "name": "minFeeControllerSet", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newMinFeeController", - "type": "pubkey" - } - ] - } - }, - { - "name": "minFeeSet", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newMinFee", - "type": "u32" - } - ] - } - }, - { - "name": "mintAndWithdraw", - "type": { - "kind": "struct", - "fields": [ - { - "name": "mintRecipient", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - }, - { - "name": "mintToken", - "type": "pubkey" - }, - { - "name": "feeCollected", - "type": "u64" - } - ] - } - }, - { - "name": "ownershipTransferStarted", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previousOwner", - "type": "pubkey" - }, - { - "name": "newOwner", - "type": "pubkey" - } - ] - } - }, - { - "name": "ownershipTransferred", - "type": { - "kind": "struct", - "fields": [ - { - "name": "previousOwner", - "type": "pubkey" - }, - { - "name": "newOwner", - "type": "pubkey" - } - ] - } - }, - { - "name": "pause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "pauseParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "pauserChanged", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newAddress", - "type": "pubkey" - } - ] - } - }, - { - "name": "remoteTokenMessenger", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "tokenMessenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "remoteTokenMessengerAdded", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "tokenMessenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "remoteTokenMessengerRemoved", - "type": { - "kind": "struct", - "fields": [ - { - "name": "domain", - "type": "u32" - }, - { - "name": "tokenMessenger", - "type": "pubkey" - } - ] - } - }, - { - "name": "removeLocalTokenParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "removeRemoteTokenMessengerParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "setBurnLimitPerMessage", - "type": { - "kind": "struct", - "fields": [ - { - "name": "token", - "type": "pubkey" - }, - { - "name": "burnLimitPerMessage", - "type": "u64" - } - ] - } - }, - { - "name": "setFeeRecipientParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newFeeRecipient", - "type": "pubkey" - } - ] - } - }, - { - "name": "setMaxBurnAmountPerMessageParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "burnLimitPerMessage", - "type": "u64" - } - ] - } - }, - { - "name": "setMinFeeControllerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newMinFeeController", - "type": "pubkey" - } - ] - } - }, - { - "name": "setMinFeeParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newMinFee", - "type": "u32" - } - ] - } - }, - { - "name": "setTokenController", - "type": { - "kind": "struct", - "fields": [ - { - "name": "tokenController", - "type": "pubkey" - } - ] - } - }, - { - "name": "setTokenControllerParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "tokenController", - "type": "pubkey" - } - ] - } - }, - { - "name": "tokenCustodyBurned", - "type": { - "kind": "struct", - "fields": [ - { - "name": "custodyTokenAccount", - "type": "pubkey" - }, - { - "name": "amount", - "type": "u64" - } - ] - } - }, - { - "name": "tokenMessenger", - "type": { - "kind": "struct", - "fields": [ - { - "name": "denylister", - "type": "pubkey" - }, - { - "name": "owner", - "type": "pubkey" - }, - { - "name": "pendingOwner", - "type": "pubkey" - }, - { - "name": "messageBodyVersion", - "type": "u32" - }, - { - "name": "authorityBump", - "type": "u8" - }, - { - "name": "feeRecipient", - "type": "pubkey" - }, - { - "name": "minFeeController", - "type": "pubkey" - }, - { - "name": "minFee", - "type": "u32" - } - ] - } - }, - { - "name": "tokenMinter", - "type": { - "kind": "struct", - "fields": [ - { - "name": "tokenController", - "type": "pubkey" - }, - { - "name": "pauser", - "type": "pubkey" - }, - { - "name": "paused", - "type": "bool" - }, - { - "name": "bump", - "type": "u8" - } - ] - } - }, - { - "name": "tokenPair", - "type": { - "kind": "struct", - "fields": [ - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "remoteToken", - "type": "pubkey" - }, - { - "name": "localToken", - "type": "pubkey" - }, - { - "name": "bump", - "type": "u8" - } - ] - } - }, - { - "name": "tokenPairLinked", - "type": { - "kind": "struct", - "fields": [ - { - "name": "localToken", - "type": "pubkey" - }, - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "remoteToken", - "type": "pubkey" - } - ] - } - }, - { - "name": "tokenPairUnlinked", - "type": { - "kind": "struct", - "fields": [ - { - "name": "localToken", - "type": "pubkey" - }, - { - "name": "remoteDomain", - "type": "u32" - }, - { - "name": "remoteToken", - "type": "pubkey" - } - ] - } - }, - { - "name": "transferOwnershipParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newOwner", - "type": "pubkey" - } - ] - } - }, - { - "name": "unDenylisted", - "type": { - "kind": "struct", - "fields": [ - { - "name": "account", - "type": "pubkey" - } - ] - } - }, - { - "name": "undenylistParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "account", - "type": "pubkey" - } - ] - } - }, - { - "name": "uninkTokenPairParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "unpause", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "unpauseParams", - "type": { - "kind": "struct", - "fields": [] - } - }, - { - "name": "updateDenylisterParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newDenylister", - "type": "pubkey" - } - ] - } - }, - { - "name": "updatePauserParams", - "type": { - "kind": "struct", - "fields": [ - { - "name": "newPauser", - "type": "pubkey" - } - ] - } - } - ] -}; diff --git a/src/svm/clients/MessageTransmitter/accounts/index.ts b/src/svm/clients/MessageTransmitter/accounts/index.ts deleted file mode 100644 index 2b409df43..000000000 --- a/src/svm/clients/MessageTransmitter/accounts/index.ts +++ /dev/null @@ -1,11 +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 - */ - -export * from './messageSent'; -export * from './messageTransmitter'; -export * from './usedNonces'; diff --git a/src/svm/clients/MessageTransmitter/accounts/messageSent.ts b/src/svm/clients/MessageTransmitter/accounts/messageSent.ts deleted file mode 100644 index 0accd2aa4..000000000 --- a/src/svm/clients/MessageTransmitter/accounts/messageSent.ts +++ /dev/null @@ -1,137 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const MESSAGE_SENT_DISCRIMINATOR = new Uint8Array([ - 131, 100, 133, 56, 166, 225, 151, 60, -]); - -export function getMessageSentDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - MESSAGE_SENT_DISCRIMINATOR - ); -} - -export type MessageSent = { - discriminator: ReadonlyUint8Array; - rentPayer: Address; - message: ReadonlyUint8Array; -}; - -export type MessageSentArgs = { - rentPayer: Address; - message: ReadonlyUint8Array; -}; - -export function getMessageSentEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['rentPayer', getAddressEncoder()], - ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ ...value, discriminator: MESSAGE_SENT_DISCRIMINATOR }) - ); -} - -export function getMessageSentDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['rentPayer', getAddressDecoder()], - ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getMessageSentCodec(): Codec { - return combineCodec(getMessageSentEncoder(), getMessageSentDecoder()); -} - -export function decodeMessageSent( - encodedAccount: EncodedAccount -): Account; -export function decodeMessageSent( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeMessageSent( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getMessageSentDecoder() - ); -} - -export async function fetchMessageSent( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeMessageSent(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeMessageSent( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeMessageSent(maybeAccount); -} - -export async function fetchAllMessageSent( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeMessageSent(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeMessageSent( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeMessageSent(maybeAccount)); -} diff --git a/src/svm/clients/MessageTransmitter/accounts/messageTransmitter.ts b/src/svm/clients/MessageTransmitter/accounts/messageTransmitter.ts deleted file mode 100644 index fc36cae2e..000000000 --- a/src/svm/clients/MessageTransmitter/accounts/messageTransmitter.ts +++ /dev/null @@ -1,193 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getArrayDecoder, - getArrayEncoder, - getBooleanDecoder, - getBooleanEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const MESSAGE_TRANSMITTER_DISCRIMINATOR = new Uint8Array([ - 71, 40, 180, 142, 19, 203, 35, 252, -]); - -export function getMessageTransmitterDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - MESSAGE_TRANSMITTER_DISCRIMINATOR - ); -} - -export type MessageTransmitter = { - discriminator: ReadonlyUint8Array; - owner: Address; - pendingOwner: Address; - attesterManager: Address; - pauser: Address; - paused: boolean; - localDomain: number; - version: number; - signatureThreshold: number; - enabledAttesters: Array
; - maxMessageBodySize: bigint; - nextAvailableNonce: bigint; -}; - -export type MessageTransmitterArgs = { - owner: Address; - pendingOwner: Address; - attesterManager: Address; - pauser: Address; - paused: boolean; - localDomain: number; - version: number; - signatureThreshold: number; - enabledAttesters: Array
; - maxMessageBodySize: number | bigint; - nextAvailableNonce: number | bigint; -}; - -export function getMessageTransmitterEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['owner', getAddressEncoder()], - ['pendingOwner', getAddressEncoder()], - ['attesterManager', getAddressEncoder()], - ['pauser', getAddressEncoder()], - ['paused', getBooleanEncoder()], - ['localDomain', getU32Encoder()], - ['version', getU32Encoder()], - ['signatureThreshold', getU32Encoder()], - ['enabledAttesters', getArrayEncoder(getAddressEncoder())], - ['maxMessageBodySize', getU64Encoder()], - ['nextAvailableNonce', getU64Encoder()], - ]), - (value) => ({ ...value, discriminator: MESSAGE_TRANSMITTER_DISCRIMINATOR }) - ); -} - -export function getMessageTransmitterDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['owner', getAddressDecoder()], - ['pendingOwner', getAddressDecoder()], - ['attesterManager', getAddressDecoder()], - ['pauser', getAddressDecoder()], - ['paused', getBooleanDecoder()], - ['localDomain', getU32Decoder()], - ['version', getU32Decoder()], - ['signatureThreshold', getU32Decoder()], - ['enabledAttesters', getArrayDecoder(getAddressDecoder())], - ['maxMessageBodySize', getU64Decoder()], - ['nextAvailableNonce', getU64Decoder()], - ]); -} - -export function getMessageTransmitterCodec(): Codec< - MessageTransmitterArgs, - MessageTransmitter -> { - return combineCodec( - getMessageTransmitterEncoder(), - getMessageTransmitterDecoder() - ); -} - -export function decodeMessageTransmitter( - encodedAccount: EncodedAccount -): Account; -export function decodeMessageTransmitter( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeMessageTransmitter( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): - | Account - | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getMessageTransmitterDecoder() - ); -} - -export async function fetchMessageTransmitter( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeMessageTransmitter(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeMessageTransmitter< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeMessageTransmitter(maybeAccount); -} - -export async function fetchAllMessageTransmitter( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeMessageTransmitter( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeMessageTransmitter( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeMessageTransmitter(maybeAccount) - ); -} diff --git a/src/svm/clients/MessageTransmitter/accounts/usedNonces.ts b/src/svm/clients/MessageTransmitter/accounts/usedNonces.ts deleted file mode 100644 index e872a957b..000000000 --- a/src/svm/clients/MessageTransmitter/accounts/usedNonces.ts +++ /dev/null @@ -1,143 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getArrayDecoder, - getArrayEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const USED_NONCES_DISCRIMINATOR = new Uint8Array([ - 60, 112, 18, 72, 138, 181, 100, 138, -]); - -export function getUsedNoncesDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(USED_NONCES_DISCRIMINATOR); -} - -export type UsedNonces = { - discriminator: ReadonlyUint8Array; - remoteDomain: number; - firstNonce: bigint; - usedNonces: Array; -}; - -export type UsedNoncesArgs = { - remoteDomain: number; - firstNonce: number | bigint; - usedNonces: Array; -}; - -export function getUsedNoncesEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['remoteDomain', getU32Encoder()], - ['firstNonce', getU64Encoder()], - ['usedNonces', getArrayEncoder(getU64Encoder(), { size: 100 })], - ]), - (value) => ({ ...value, discriminator: USED_NONCES_DISCRIMINATOR }) - ); -} - -export function getUsedNoncesDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['remoteDomain', getU32Decoder()], - ['firstNonce', getU64Decoder()], - ['usedNonces', getArrayDecoder(getU64Decoder(), { size: 100 })], - ]); -} - -export function getUsedNoncesCodec(): Codec { - return combineCodec(getUsedNoncesEncoder(), getUsedNoncesDecoder()); -} - -export function decodeUsedNonces( - encodedAccount: EncodedAccount -): Account; -export function decodeUsedNonces( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeUsedNonces( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getUsedNoncesDecoder() - ); -} - -export async function fetchUsedNonces( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeUsedNonces(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeUsedNonces( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeUsedNonces(maybeAccount); -} - -export async function fetchAllUsedNonces( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeUsedNonces(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeUsedNonces( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeUsedNonces(maybeAccount)); -} - -export function getUsedNoncesSize(): number { - return 820; -} diff --git a/src/svm/clients/MessageTransmitter/errors/index.ts b/src/svm/clients/MessageTransmitter/errors/index.ts deleted file mode 100644 index 35d6ae3df..000000000 --- a/src/svm/clients/MessageTransmitter/errors/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './messageTransmitter'; diff --git a/src/svm/clients/MessageTransmitter/errors/messageTransmitter.ts b/src/svm/clients/MessageTransmitter/errors/messageTransmitter.ts deleted file mode 100644 index eab5c97ed..000000000 --- a/src/svm/clients/MessageTransmitter/errors/messageTransmitter.ts +++ /dev/null @@ -1,184 +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 { - isProgramError, - type Address, - type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, - type SolanaError, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; - -/** InvalidAuthority: Invalid authority */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_AUTHORITY = 0x1770; // 6000 -/** ProgramPaused: Instruction is not allowed at this time */ -export const MESSAGE_TRANSMITTER_ERROR__PROGRAM_PAUSED = 0x1771; // 6001 -/** InvalidMessageTransmitterState: Invalid message transmitter state */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_TRANSMITTER_STATE = 0x1772; // 6002 -/** InvalidSignatureThreshold: Invalid signature threshold */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_THRESHOLD = 0x1773; // 6003 -/** SignatureThresholdAlreadySet: Signature threshold already set */ -export const MESSAGE_TRANSMITTER_ERROR__SIGNATURE_THRESHOLD_ALREADY_SET = 0x1774; // 6004 -/** InvalidOwner: Invalid owner */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_OWNER = 0x1775; // 6005 -/** InvalidPauser: Invalid pauser */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_PAUSER = 0x1776; // 6006 -/** InvalidAttesterManager: Invalid attester manager */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER_MANAGER = 0x1777; // 6007 -/** InvalidAttester: Invalid attester */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER = 0x1778; // 6008 -/** AttesterAlreadyEnabled: Attester already enabled */ -export const MESSAGE_TRANSMITTER_ERROR__ATTESTER_ALREADY_ENABLED = 0x1779; // 6009 -/** TooFewEnabledAttesters: Too few enabled attesters */ -export const MESSAGE_TRANSMITTER_ERROR__TOO_FEW_ENABLED_ATTESTERS = 0x177a; // 6010 -/** SignatureThresholdTooLow: Signature threshold is too low */ -export const MESSAGE_TRANSMITTER_ERROR__SIGNATURE_THRESHOLD_TOO_LOW = 0x177b; // 6011 -/** AttesterAlreadyDisabled: Attester already disabled */ -export const MESSAGE_TRANSMITTER_ERROR__ATTESTER_ALREADY_DISABLED = 0x177c; // 6012 -/** MessageBodyLimitExceeded: Message body exceeds max size */ -export const MESSAGE_TRANSMITTER_ERROR__MESSAGE_BODY_LIMIT_EXCEEDED = 0x177d; // 6013 -/** InvalidDestinationCaller: Invalid destination caller */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_DESTINATION_CALLER = 0x177e; // 6014 -/** InvalidRecipient: Invalid message recipient */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_RECIPIENT = 0x177f; // 6015 -/** SenderNotPermitted: Sender is not permitted */ -export const MESSAGE_TRANSMITTER_ERROR__SENDER_NOT_PERMITTED = 0x1780; // 6016 -/** InvalidSourceDomain: Invalid source domain */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_SOURCE_DOMAIN = 0x1781; // 6017 -/** InvalidDestinationDomain: Invalid destination domain */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_DESTINATION_DOMAIN = 0x1782; // 6018 -/** InvalidMessageVersion: Invalid message version */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_VERSION = 0x1783; // 6019 -/** InvalidUsedNoncesAccount: Invalid used nonces account */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_USED_NONCES_ACCOUNT = 0x1784; // 6020 -/** InvalidRecipientProgram: Invalid recipient program */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_RECIPIENT_PROGRAM = 0x1785; // 6021 -/** InvalidNonce: Invalid nonce */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_NONCE = 0x1786; // 6022 -/** NonceAlreadyUsed: Nonce already used */ -export const MESSAGE_TRANSMITTER_ERROR__NONCE_ALREADY_USED = 0x1787; // 6023 -/** MessageTooShort: Message is too short */ -export const MESSAGE_TRANSMITTER_ERROR__MESSAGE_TOO_SHORT = 0x1788; // 6024 -/** MalformedMessage: Malformed message */ -export const MESSAGE_TRANSMITTER_ERROR__MALFORMED_MESSAGE = 0x1789; // 6025 -/** InvalidSignatureOrderOrDupe: Invalid signature order or dupe */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_ORDER_OR_DUPE = 0x178a; // 6026 -/** InvalidAttesterSignature: Invalid attester signature */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER_SIGNATURE = 0x178b; // 6027 -/** InvalidAttestationLength: Invalid attestation length */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTATION_LENGTH = 0x178c; // 6028 -/** InvalidSignatureRecoveryId: Invalid signature recovery ID */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_RECOVERY_ID = 0x178d; // 6029 -/** InvalidSignatureSValue: Invalid signature S value */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_S_VALUE = 0x178e; // 6030 -/** InvalidMessageHash: Invalid message hash */ -export const MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_HASH = 0x178f; // 6031 - -export type MessageTransmitterError = - | typeof MESSAGE_TRANSMITTER_ERROR__ATTESTER_ALREADY_DISABLED - | typeof MESSAGE_TRANSMITTER_ERROR__ATTESTER_ALREADY_ENABLED - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTATION_LENGTH - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER_MANAGER - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER_SIGNATURE - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_AUTHORITY - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_DESTINATION_CALLER - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_DESTINATION_DOMAIN - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_HASH - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_TRANSMITTER_STATE - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_VERSION - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_NONCE - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_OWNER - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_PAUSER - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_RECIPIENT - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_RECIPIENT_PROGRAM - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_ORDER_OR_DUPE - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_RECOVERY_ID - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_S_VALUE - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_THRESHOLD - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_SOURCE_DOMAIN - | typeof MESSAGE_TRANSMITTER_ERROR__INVALID_USED_NONCES_ACCOUNT - | typeof MESSAGE_TRANSMITTER_ERROR__MALFORMED_MESSAGE - | typeof MESSAGE_TRANSMITTER_ERROR__MESSAGE_BODY_LIMIT_EXCEEDED - | typeof MESSAGE_TRANSMITTER_ERROR__MESSAGE_TOO_SHORT - | typeof MESSAGE_TRANSMITTER_ERROR__NONCE_ALREADY_USED - | typeof MESSAGE_TRANSMITTER_ERROR__PROGRAM_PAUSED - | typeof MESSAGE_TRANSMITTER_ERROR__SENDER_NOT_PERMITTED - | typeof MESSAGE_TRANSMITTER_ERROR__SIGNATURE_THRESHOLD_ALREADY_SET - | typeof MESSAGE_TRANSMITTER_ERROR__SIGNATURE_THRESHOLD_TOO_LOW - | typeof MESSAGE_TRANSMITTER_ERROR__TOO_FEW_ENABLED_ATTESTERS; - -let messageTransmitterErrorMessages: - | Record - | undefined; -if (process.env.NODE_ENV !== 'production') { - messageTransmitterErrorMessages = { - [MESSAGE_TRANSMITTER_ERROR__ATTESTER_ALREADY_DISABLED]: `Attester already disabled`, - [MESSAGE_TRANSMITTER_ERROR__ATTESTER_ALREADY_ENABLED]: `Attester already enabled`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTATION_LENGTH]: `Invalid attestation length`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER]: `Invalid attester`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER_MANAGER]: `Invalid attester manager`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_ATTESTER_SIGNATURE]: `Invalid attester signature`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_AUTHORITY]: `Invalid authority`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_DESTINATION_CALLER]: `Invalid destination caller`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_DESTINATION_DOMAIN]: `Invalid destination domain`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_HASH]: `Invalid message hash`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_TRANSMITTER_STATE]: `Invalid message transmitter state`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_MESSAGE_VERSION]: `Invalid message version`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_NONCE]: `Invalid nonce`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_OWNER]: `Invalid owner`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_PAUSER]: `Invalid pauser`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_RECIPIENT]: `Invalid message recipient`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_RECIPIENT_PROGRAM]: `Invalid recipient program`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_ORDER_OR_DUPE]: `Invalid signature order or dupe`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_RECOVERY_ID]: `Invalid signature recovery ID`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_S_VALUE]: `Invalid signature S value`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_SIGNATURE_THRESHOLD]: `Invalid signature threshold`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_SOURCE_DOMAIN]: `Invalid source domain`, - [MESSAGE_TRANSMITTER_ERROR__INVALID_USED_NONCES_ACCOUNT]: `Invalid used nonces account`, - [MESSAGE_TRANSMITTER_ERROR__MALFORMED_MESSAGE]: `Malformed message`, - [MESSAGE_TRANSMITTER_ERROR__MESSAGE_BODY_LIMIT_EXCEEDED]: `Message body exceeds max size`, - [MESSAGE_TRANSMITTER_ERROR__MESSAGE_TOO_SHORT]: `Message is too short`, - [MESSAGE_TRANSMITTER_ERROR__NONCE_ALREADY_USED]: `Nonce already used`, - [MESSAGE_TRANSMITTER_ERROR__PROGRAM_PAUSED]: `Instruction is not allowed at this time`, - [MESSAGE_TRANSMITTER_ERROR__SENDER_NOT_PERMITTED]: `Sender is not permitted`, - [MESSAGE_TRANSMITTER_ERROR__SIGNATURE_THRESHOLD_ALREADY_SET]: `Signature threshold already set`, - [MESSAGE_TRANSMITTER_ERROR__SIGNATURE_THRESHOLD_TOO_LOW]: `Signature threshold is too low`, - [MESSAGE_TRANSMITTER_ERROR__TOO_FEW_ENABLED_ATTESTERS]: `Too few enabled attesters`, - }; -} - -export function getMessageTransmitterErrorMessage( - code: MessageTransmitterError -): string { - if (process.env.NODE_ENV !== 'production') { - return ( - messageTransmitterErrorMessages as Record - )[code]; - } - - return 'Error message not available in production bundles.'; -} - -export function isMessageTransmitterError< - TProgramErrorCode extends MessageTransmitterError, ->( - error: unknown, - transactionMessage: { - instructions: Record; - }, - code?: TProgramErrorCode -): error is SolanaError & - Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { - return isProgramError( - error, - transactionMessage, - MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - code - ); -} diff --git a/src/svm/clients/MessageTransmitter/index.ts b/src/svm/clients/MessageTransmitter/index.ts deleted file mode 100644 index 02964a6ae..000000000 --- a/src/svm/clients/MessageTransmitter/index.ts +++ /dev/null @@ -1,13 +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 - */ - -export * from './accounts'; -export * from './errors'; -export * from './instructions'; -export * from './programs'; -export * from './types'; diff --git a/src/svm/clients/MessageTransmitter/instructions/acceptOwnership.ts b/src/svm/clients/MessageTransmitter/instructions/acceptOwnership.ts deleted file mode 100644 index ed851fa91..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/acceptOwnership.ts +++ /dev/null @@ -1,218 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const ACCEPT_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ - 172, 23, 43, 13, 238, 213, 85, 150, -]); - -export function getAcceptOwnershipDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - ACCEPT_OWNERSHIP_DISCRIMINATOR - ); -} - -export type AcceptOwnershipInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountPendingOwner extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPendingOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountPendingOwner, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type AcceptOwnershipInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type AcceptOwnershipInstructionDataArgs = {}; - -export function getAcceptOwnershipInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: ACCEPT_OWNERSHIP_DISCRIMINATOR }) - ); -} - -export function getAcceptOwnershipInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getAcceptOwnershipInstructionDataCodec(): Codec< - AcceptOwnershipInstructionDataArgs, - AcceptOwnershipInstructionData -> { - return combineCodec( - getAcceptOwnershipInstructionDataEncoder(), - getAcceptOwnershipInstructionDataDecoder() - ); -} - -export type AcceptOwnershipInput< - TAccountPendingOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pendingOwner: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; -}; - -export function getAcceptOwnershipInstruction< - TAccountPendingOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: AcceptOwnershipInput< - TAccountPendingOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): AcceptOwnershipInstruction< - TProgramAddress, - TAccountPendingOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pendingOwner: { value: input.pendingOwner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pendingOwner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getAcceptOwnershipInstructionDataEncoder().encode({}), - } as AcceptOwnershipInstruction< - TProgramAddress, - TAccountPendingOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedAcceptOwnershipInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - pendingOwner: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: AcceptOwnershipInstructionData; -}; - -export function parseAcceptOwnershipInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedAcceptOwnershipInstruction { - if (instruction.accounts.length < 4) { - // 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: { - pendingOwner: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getAcceptOwnershipInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/disableAttester.ts b/src/svm/clients/MessageTransmitter/instructions/disableAttester.ts deleted file mode 100644 index 0c14036af..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/disableAttester.ts +++ /dev/null @@ -1,271 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const DISABLE_ATTESTER_DISCRIMINATOR = new Uint8Array([ - 61, 171, 131, 95, 172, 15, 227, 229, -]); - -export function getDisableAttesterDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - DISABLE_ATTESTER_DISCRIMINATOR - ); -} - -export type DisableAttesterInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountAttesterManager extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountAttesterManager extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAttesterManager, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type DisableAttesterInstructionData = { - discriminator: ReadonlyUint8Array; - attester: Address; -}; - -export type DisableAttesterInstructionDataArgs = { attester: Address }; - -export function getDisableAttesterInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['attester', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: DISABLE_ATTESTER_DISCRIMINATOR }) - ); -} - -export function getDisableAttesterInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['attester', getAddressDecoder()], - ]); -} - -export function getDisableAttesterInstructionDataCodec(): Codec< - DisableAttesterInstructionDataArgs, - DisableAttesterInstructionData -> { - return combineCodec( - getDisableAttesterInstructionDataEncoder(), - getDisableAttesterInstructionDataDecoder() - ); -} - -export type DisableAttesterInput< - TAccountPayer extends string = string, - TAccountAttesterManager extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - attesterManager: TransactionSigner; - messageTransmitter: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - attester: DisableAttesterInstructionDataArgs['attester']; -}; - -export function getDisableAttesterInstruction< - TAccountPayer extends string, - TAccountAttesterManager extends string, - TAccountMessageTransmitter extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: DisableAttesterInput< - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): DisableAttesterInstruction< - TProgramAddress, - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - attesterManager: { - value: input.attesterManager ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.attesterManager), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDisableAttesterInstructionDataEncoder().encode( - args as DisableAttesterInstructionDataArgs - ), - } as DisableAttesterInstruction< - TProgramAddress, - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedDisableAttesterInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - attesterManager: TAccountMetas[1]; - messageTransmitter: TAccountMetas[2]; - systemProgram: TAccountMetas[3]; - eventAuthority: TAccountMetas[4]; - program: TAccountMetas[5]; - }; - data: DisableAttesterInstructionData; -}; - -export function parseDisableAttesterInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedDisableAttesterInstruction { - if (instruction.accounts.length < 6) { - // 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: { - payer: getNextAccount(), - attesterManager: getNextAccount(), - messageTransmitter: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getDisableAttesterInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/enableAttester.ts b/src/svm/clients/MessageTransmitter/instructions/enableAttester.ts deleted file mode 100644 index 68f9761dd..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/enableAttester.ts +++ /dev/null @@ -1,271 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const ENABLE_ATTESTER_DISCRIMINATOR = new Uint8Array([ - 2, 11, 193, 115, 5, 148, 4, 198, -]); - -export function getEnableAttesterDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - ENABLE_ATTESTER_DISCRIMINATOR - ); -} - -export type EnableAttesterInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountAttesterManager extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountAttesterManager extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAttesterManager, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type EnableAttesterInstructionData = { - discriminator: ReadonlyUint8Array; - newAttester: Address; -}; - -export type EnableAttesterInstructionDataArgs = { newAttester: Address }; - -export function getEnableAttesterInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newAttester', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: ENABLE_ATTESTER_DISCRIMINATOR }) - ); -} - -export function getEnableAttesterInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newAttester', getAddressDecoder()], - ]); -} - -export function getEnableAttesterInstructionDataCodec(): Codec< - EnableAttesterInstructionDataArgs, - EnableAttesterInstructionData -> { - return combineCodec( - getEnableAttesterInstructionDataEncoder(), - getEnableAttesterInstructionDataDecoder() - ); -} - -export type EnableAttesterInput< - TAccountPayer extends string = string, - TAccountAttesterManager extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - attesterManager: TransactionSigner; - messageTransmitter: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - newAttester: EnableAttesterInstructionDataArgs['newAttester']; -}; - -export function getEnableAttesterInstruction< - TAccountPayer extends string, - TAccountAttesterManager extends string, - TAccountMessageTransmitter extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: EnableAttesterInput< - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): EnableAttesterInstruction< - TProgramAddress, - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - attesterManager: { - value: input.attesterManager ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.attesterManager), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getEnableAttesterInstructionDataEncoder().encode( - args as EnableAttesterInstructionDataArgs - ), - } as EnableAttesterInstruction< - TProgramAddress, - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedEnableAttesterInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - attesterManager: TAccountMetas[1]; - messageTransmitter: TAccountMetas[2]; - systemProgram: TAccountMetas[3]; - eventAuthority: TAccountMetas[4]; - program: TAccountMetas[5]; - }; - data: EnableAttesterInstructionData; -}; - -export function parseEnableAttesterInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedEnableAttesterInstruction { - if (instruction.accounts.length < 6) { - // 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: { - payer: getNextAccount(), - attesterManager: getNextAccount(), - messageTransmitter: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getEnableAttesterInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/getNoncePda.ts b/src/svm/clients/MessageTransmitter/instructions/getNoncePda.ts deleted file mode 100644 index ea99487e8..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/getNoncePda.ts +++ /dev/null @@ -1,183 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const GET_NONCE_PDA_DISCRIMINATOR = new Uint8Array([ - 114, 70, 229, 212, 223, 50, 33, 39, -]); - -export function getGetNoncePdaDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - GET_NONCE_PDA_DISCRIMINATOR - ); -} - -export type GetNoncePdaInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMessageTransmitter extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountMessageTransmitter extends string - ? ReadonlyAccount - : TAccountMessageTransmitter, - ...TRemainingAccounts, - ] - >; - -export type GetNoncePdaInstructionData = { - discriminator: ReadonlyUint8Array; - nonce: bigint; - sourceDomain: number; -}; - -export type GetNoncePdaInstructionDataArgs = { - nonce: number | bigint; - sourceDomain: number; -}; - -export function getGetNoncePdaInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['nonce', getU64Encoder()], - ['sourceDomain', getU32Encoder()], - ]), - (value) => ({ ...value, discriminator: GET_NONCE_PDA_DISCRIMINATOR }) - ); -} - -export function getGetNoncePdaInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['nonce', getU64Decoder()], - ['sourceDomain', getU32Decoder()], - ]); -} - -export function getGetNoncePdaInstructionDataCodec(): Codec< - GetNoncePdaInstructionDataArgs, - GetNoncePdaInstructionData -> { - return combineCodec( - getGetNoncePdaInstructionDataEncoder(), - getGetNoncePdaInstructionDataDecoder() - ); -} - -export type GetNoncePdaInput< - TAccountMessageTransmitter extends string = string, -> = { - messageTransmitter: Address; - nonce: GetNoncePdaInstructionDataArgs['nonce']; - sourceDomain: GetNoncePdaInstructionDataArgs['sourceDomain']; -}; - -export function getGetNoncePdaInstruction< - TAccountMessageTransmitter extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: GetNoncePdaInput, - config?: { programAddress?: TProgramAddress } -): GetNoncePdaInstruction { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - messageTransmitter: { - value: input.messageTransmitter ?? 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.messageTransmitter)], - programAddress, - data: getGetNoncePdaInstructionDataEncoder().encode( - args as GetNoncePdaInstructionDataArgs - ), - } as GetNoncePdaInstruction; - - return instruction; -} - -export type ParsedGetNoncePdaInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - messageTransmitter: TAccountMetas[0]; - }; - data: GetNoncePdaInstructionData; -}; - -export function parseGetNoncePdaInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedGetNoncePdaInstruction { - if (instruction.accounts.length < 1) { - // 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: { - messageTransmitter: getNextAccount(), - }, - data: getGetNoncePdaInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/index.ts b/src/svm/clients/MessageTransmitter/instructions/index.ts deleted file mode 100644 index d285a7021..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/index.ts +++ /dev/null @@ -1,26 +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 - */ - -export * from './acceptOwnership'; -export * from './disableAttester'; -export * from './enableAttester'; -export * from './getNoncePda'; -export * from './initialize'; -export * from './isNonceUsed'; -export * from './pause'; -export * from './receiveMessage'; -export * from './reclaimEventAccount'; -export * from './replaceMessage'; -export * from './sendMessage'; -export * from './sendMessageWithCaller'; -export * from './setMaxMessageBodySize'; -export * from './setSignatureThreshold'; -export * from './transferOwnership'; -export * from './unpause'; -export * from './updateAttesterManager'; -export * from './updatePauser'; diff --git a/src/svm/clients/MessageTransmitter/instructions/initialize.ts b/src/svm/clients/MessageTransmitter/instructions/initialize.ts deleted file mode 100644 index d333f9169..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/initialize.ts +++ /dev/null @@ -1,326 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const INITIALIZE_DISCRIMINATOR = new Uint8Array([ - 175, 175, 109, 31, 13, 152, 155, 237, -]); - -export function getInitializeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_DISCRIMINATOR); -} - -export type InitializeInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountUpgradeAuthority extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountMessageTransmitterProgramData extends string | AccountMeta = - string, - TAccountMessageTransmitterProgram extends string | AccountMeta = - string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountUpgradeAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountUpgradeAuthority, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountMessageTransmitterProgramData extends string - ? ReadonlyAccount - : TAccountMessageTransmitterProgramData, - TAccountMessageTransmitterProgram extends string - ? ReadonlyAccount - : TAccountMessageTransmitterProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type InitializeInstructionData = { - discriminator: ReadonlyUint8Array; - localDomain: number; - attester: Address; - maxMessageBodySize: bigint; - version: number; -}; - -export type InitializeInstructionDataArgs = { - localDomain: number; - attester: Address; - maxMessageBodySize: number | bigint; - version: number; -}; - -export function getInitializeInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['localDomain', getU32Encoder()], - ['attester', getAddressEncoder()], - ['maxMessageBodySize', getU64Encoder()], - ['version', getU32Encoder()], - ]), - (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) - ); -} - -export function getInitializeInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['localDomain', getU32Decoder()], - ['attester', getAddressDecoder()], - ['maxMessageBodySize', getU64Decoder()], - ['version', getU32Decoder()], - ]); -} - -export function getInitializeInstructionDataCodec(): Codec< - InitializeInstructionDataArgs, - InitializeInstructionData -> { - return combineCodec( - getInitializeInstructionDataEncoder(), - getInitializeInstructionDataDecoder() - ); -} - -export type InitializeInput< - TAccountPayer extends string = string, - TAccountUpgradeAuthority extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountMessageTransmitterProgramData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - upgradeAuthority: TransactionSigner; - messageTransmitter: Address; - messageTransmitterProgramData: Address; - messageTransmitterProgram: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - localDomain: InitializeInstructionDataArgs['localDomain']; - attester: InitializeInstructionDataArgs['attester']; - maxMessageBodySize: InitializeInstructionDataArgs['maxMessageBodySize']; - version: InitializeInstructionDataArgs['version']; -}; - -export function getInitializeInstruction< - TAccountPayer extends string, - TAccountUpgradeAuthority extends string, - TAccountMessageTransmitter extends string, - TAccountMessageTransmitterProgramData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: InitializeInput< - TAccountPayer, - TAccountUpgradeAuthority, - TAccountMessageTransmitter, - TAccountMessageTransmitterProgramData, - TAccountMessageTransmitterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): InitializeInstruction< - TProgramAddress, - TAccountPayer, - TAccountUpgradeAuthority, - TAccountMessageTransmitter, - TAccountMessageTransmitterProgramData, - TAccountMessageTransmitterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - upgradeAuthority: { - value: input.upgradeAuthority ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - messageTransmitterProgramData: { - value: input.messageTransmitterProgramData ?? null, - isWritable: false, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.upgradeAuthority), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.messageTransmitterProgramData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getInitializeInstructionDataEncoder().encode( - args as InitializeInstructionDataArgs - ), - } as InitializeInstruction< - TProgramAddress, - TAccountPayer, - TAccountUpgradeAuthority, - TAccountMessageTransmitter, - TAccountMessageTransmitterProgramData, - TAccountMessageTransmitterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedInitializeInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - upgradeAuthority: TAccountMetas[1]; - messageTransmitter: TAccountMetas[2]; - messageTransmitterProgramData: TAccountMetas[3]; - messageTransmitterProgram: TAccountMetas[4]; - systemProgram: TAccountMetas[5]; - eventAuthority: TAccountMetas[6]; - program: TAccountMetas[7]; - }; - data: InitializeInstructionData; -}; - -export function parseInitializeInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedInitializeInstruction { - if (instruction.accounts.length < 8) { - // 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: { - payer: getNextAccount(), - upgradeAuthority: getNextAccount(), - messageTransmitter: getNextAccount(), - messageTransmitterProgramData: getNextAccount(), - messageTransmitterProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getInitializeInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/isNonceUsed.ts b/src/svm/clients/MessageTransmitter/instructions/isNonceUsed.ts deleted file mode 100644 index ef3466f72..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/isNonceUsed.ts +++ /dev/null @@ -1,171 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const IS_NONCE_USED_DISCRIMINATOR = new Uint8Array([ - 144, 72, 107, 148, 35, 218, 31, 187, -]); - -export function getIsNonceUsedDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - IS_NONCE_USED_DISCRIMINATOR - ); -} - -export type IsNonceUsedInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountUsedNonces extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountUsedNonces extends string - ? ReadonlyAccount - : TAccountUsedNonces, - ...TRemainingAccounts, - ] - >; - -export type IsNonceUsedInstructionData = { - discriminator: ReadonlyUint8Array; - nonce: bigint; -}; - -export type IsNonceUsedInstructionDataArgs = { nonce: number | bigint }; - -export function getIsNonceUsedInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['nonce', getU64Encoder()], - ]), - (value) => ({ ...value, discriminator: IS_NONCE_USED_DISCRIMINATOR }) - ); -} - -export function getIsNonceUsedInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['nonce', getU64Decoder()], - ]); -} - -export function getIsNonceUsedInstructionDataCodec(): Codec< - IsNonceUsedInstructionDataArgs, - IsNonceUsedInstructionData -> { - return combineCodec( - getIsNonceUsedInstructionDataEncoder(), - getIsNonceUsedInstructionDataDecoder() - ); -} - -export type IsNonceUsedInput = { - /** Account will be explicitly loaded to avoid error when it's not initialized */ - usedNonces: Address; - nonce: IsNonceUsedInstructionDataArgs['nonce']; -}; - -export function getIsNonceUsedInstruction< - TAccountUsedNonces extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: IsNonceUsedInput, - config?: { programAddress?: TProgramAddress } -): IsNonceUsedInstruction { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - usedNonces: { value: input.usedNonces ?? 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.usedNonces)], - programAddress, - data: getIsNonceUsedInstructionDataEncoder().encode( - args as IsNonceUsedInstructionDataArgs - ), - } as IsNonceUsedInstruction; - - return instruction; -} - -export type ParsedIsNonceUsedInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - /** Account will be explicitly loaded to avoid error when it's not initialized */ - usedNonces: TAccountMetas[0]; - }; - data: IsNonceUsedInstructionData; -}; - -export function parseIsNonceUsedInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedIsNonceUsedInstruction { - if (instruction.accounts.length < 1) { - // 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: { - usedNonces: getNextAccount(), - }, - data: getIsNonceUsedInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/pause.ts b/src/svm/clients/MessageTransmitter/instructions/pause.ts deleted file mode 100644 index d0caab341..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/pause.ts +++ /dev/null @@ -1,214 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const PAUSE_DISCRIMINATOR = new Uint8Array([ - 211, 22, 221, 251, 74, 121, 193, 47, -]); - -export function getPauseDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(PAUSE_DISCRIMINATOR); -} - -export type PauseInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountPauser extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPauser extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountPauser, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type PauseInstructionData = { discriminator: ReadonlyUint8Array }; - -export type PauseInstructionDataArgs = {}; - -export function getPauseInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: PAUSE_DISCRIMINATOR }) - ); -} - -export function getPauseInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getPauseInstructionDataCodec(): Codec< - PauseInstructionDataArgs, - PauseInstructionData -> { - return combineCodec( - getPauseInstructionDataEncoder(), - getPauseInstructionDataDecoder() - ); -} - -export type PauseInput< - TAccountPauser extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pauser: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; -}; - -export function getPauseInstruction< - TAccountPauser extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: PauseInput< - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): PauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pauser: { value: input.pauser ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pauser), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getPauseInstructionDataEncoder().encode({}), - } as PauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedPauseInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - pauser: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: PauseInstructionData; -}; - -export function parsePauseInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedPauseInstruction { - if (instruction.accounts.length < 4) { - // 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: { - pauser: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getPauseInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/receiveMessage.ts b/src/svm/clients/MessageTransmitter/instructions/receiveMessage.ts deleted file mode 100644 index 612dad4de..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/receiveMessage.ts +++ /dev/null @@ -1,319 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const RECEIVE_MESSAGE_DISCRIMINATOR = new Uint8Array([ - 38, 144, 127, 225, 31, 225, 238, 25, -]); - -export function getReceiveMessageDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - RECEIVE_MESSAGE_DISCRIMINATOR - ); -} - -export type ReceiveMessageInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountCaller extends string | AccountMeta = string, - TAccountAuthorityPda extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountUsedNonces extends string | AccountMeta = string, - TAccountReceiver extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountCaller extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountCaller, - TAccountAuthorityPda extends string - ? ReadonlyAccount - : TAccountAuthorityPda, - TAccountMessageTransmitter extends string - ? ReadonlyAccount - : TAccountMessageTransmitter, - TAccountUsedNonces extends string - ? WritableAccount - : TAccountUsedNonces, - TAccountReceiver extends string - ? ReadonlyAccount - : TAccountReceiver, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type ReceiveMessageInstructionData = { - discriminator: ReadonlyUint8Array; - message: ReadonlyUint8Array; - attestation: ReadonlyUint8Array; -}; - -export type ReceiveMessageInstructionDataArgs = { - message: ReadonlyUint8Array; - attestation: ReadonlyUint8Array; -}; - -export function getReceiveMessageInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ['attestation', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ ...value, discriminator: RECEIVE_MESSAGE_DISCRIMINATOR }) - ); -} - -export function getReceiveMessageInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ['attestation', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getReceiveMessageInstructionDataCodec(): Codec< - ReceiveMessageInstructionDataArgs, - ReceiveMessageInstructionData -> { - return combineCodec( - getReceiveMessageInstructionDataEncoder(), - getReceiveMessageInstructionDataDecoder() - ); -} - -export type ReceiveMessageInput< - TAccountPayer extends string = string, - TAccountCaller extends string = string, - TAccountAuthorityPda extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountUsedNonces extends string = string, - TAccountReceiver extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - caller: TransactionSigner; - authorityPda: Address; - messageTransmitter: Address; - usedNonces: Address; - receiver: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - message: ReceiveMessageInstructionDataArgs['message']; - attestation: ReceiveMessageInstructionDataArgs['attestation']; -}; - -export function getReceiveMessageInstruction< - TAccountPayer extends string, - TAccountCaller extends string, - TAccountAuthorityPda extends string, - TAccountMessageTransmitter extends string, - TAccountUsedNonces extends string, - TAccountReceiver extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: ReceiveMessageInput< - TAccountPayer, - TAccountCaller, - TAccountAuthorityPda, - TAccountMessageTransmitter, - TAccountUsedNonces, - TAccountReceiver, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): ReceiveMessageInstruction< - TProgramAddress, - TAccountPayer, - TAccountCaller, - TAccountAuthorityPda, - TAccountMessageTransmitter, - TAccountUsedNonces, - TAccountReceiver, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - caller: { value: input.caller ?? null, isWritable: false }, - authorityPda: { value: input.authorityPda ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: false, - }, - usedNonces: { value: input.usedNonces ?? null, isWritable: true }, - receiver: { value: input.receiver ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.caller), - getAccountMeta(accounts.authorityPda), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.usedNonces), - getAccountMeta(accounts.receiver), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getReceiveMessageInstructionDataEncoder().encode( - args as ReceiveMessageInstructionDataArgs - ), - } as ReceiveMessageInstruction< - TProgramAddress, - TAccountPayer, - TAccountCaller, - TAccountAuthorityPda, - TAccountMessageTransmitter, - TAccountUsedNonces, - TAccountReceiver, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedReceiveMessageInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - caller: TAccountMetas[1]; - authorityPda: TAccountMetas[2]; - messageTransmitter: TAccountMetas[3]; - usedNonces: TAccountMetas[4]; - receiver: TAccountMetas[5]; - systemProgram: TAccountMetas[6]; - eventAuthority: TAccountMetas[7]; - program: TAccountMetas[8]; - }; - data: ReceiveMessageInstructionData; -}; - -export function parseReceiveMessageInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedReceiveMessageInstruction { - if (instruction.accounts.length < 9) { - // 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: { - payer: getNextAccount(), - caller: getNextAccount(), - authorityPda: getNextAccount(), - messageTransmitter: getNextAccount(), - usedNonces: getNextAccount(), - receiver: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getReceiveMessageInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/reclaimEventAccount.ts b/src/svm/clients/MessageTransmitter/instructions/reclaimEventAccount.ts deleted file mode 100644 index 56c25c910..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/reclaimEventAccount.ts +++ /dev/null @@ -1,230 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR = new Uint8Array([ - 94, 198, 180, 159, 131, 236, 15, 174, -]); - -export function getReclaimEventAccountDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR - ); -} - -export type ReclaimEventAccountInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountPayee extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayee extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayee, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountMessageSentEventData extends string - ? WritableAccount - : TAccountMessageSentEventData, - ...TRemainingAccounts, - ] - >; - -export type ReclaimEventAccountInstructionData = { - discriminator: ReadonlyUint8Array; - attestation: ReadonlyUint8Array; -}; - -export type ReclaimEventAccountInstructionDataArgs = { - attestation: ReadonlyUint8Array; -}; - -export function getReclaimEventAccountInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['attestation', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ - ...value, - discriminator: RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR, - }) - ); -} - -export function getReclaimEventAccountInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['attestation', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getReclaimEventAccountInstructionDataCodec(): Codec< - ReclaimEventAccountInstructionDataArgs, - ReclaimEventAccountInstructionData -> { - return combineCodec( - getReclaimEventAccountInstructionDataEncoder(), - getReclaimEventAccountInstructionDataDecoder() - ); -} - -export type ReclaimEventAccountInput< - TAccountPayee extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountMessageSentEventData extends string = string, -> = { - /** rent SOL receiver, should match original rent payer */ - payee: TransactionSigner; - messageTransmitter: Address; - messageSentEventData: Address; - attestation: ReclaimEventAccountInstructionDataArgs['attestation']; -}; - -export function getReclaimEventAccountInstruction< - TAccountPayee extends string, - TAccountMessageTransmitter extends string, - TAccountMessageSentEventData extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: ReclaimEventAccountInput< - TAccountPayee, - TAccountMessageTransmitter, - TAccountMessageSentEventData - >, - config?: { programAddress?: TProgramAddress } -): ReclaimEventAccountInstruction< - TProgramAddress, - TAccountPayee, - TAccountMessageTransmitter, - TAccountMessageSentEventData -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.messageSentEventData), - ], - programAddress, - data: getReclaimEventAccountInstructionDataEncoder().encode( - args as ReclaimEventAccountInstructionDataArgs - ), - } as ReclaimEventAccountInstruction< - TProgramAddress, - TAccountPayee, - TAccountMessageTransmitter, - TAccountMessageSentEventData - >; - - return instruction; -} - -export type ParsedReclaimEventAccountInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - /** rent SOL receiver, should match original rent payer */ - payee: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - messageSentEventData: TAccountMetas[2]; - }; - data: ReclaimEventAccountInstructionData; -}; - -export function parseReclaimEventAccountInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedReclaimEventAccountInstruction { - 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: { - payee: getNextAccount(), - messageTransmitter: getNextAccount(), - messageSentEventData: getNextAccount(), - }, - data: getReclaimEventAccountInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/replaceMessage.ts b/src/svm/clients/MessageTransmitter/instructions/replaceMessage.ts deleted file mode 100644 index f0162de72..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/replaceMessage.ts +++ /dev/null @@ -1,314 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const REPLACE_MESSAGE_DISCRIMINATOR = new Uint8Array([ - 189, 189, 210, 163, 149, 205, 69, 229, -]); - -export function getReplaceMessageDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - REPLACE_MESSAGE_DISCRIMINATOR - ); -} - -export type ReplaceMessageInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountEventRentPayer extends string | AccountMeta = string, - TAccountSenderAuthorityPda extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TAccountSenderProgram extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountEventRentPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountEventRentPayer, - TAccountSenderAuthorityPda extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSenderAuthorityPda, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountMessageSentEventData extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountMessageSentEventData, - TAccountSenderProgram extends string - ? ReadonlyAccount - : TAccountSenderProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type ReplaceMessageInstructionData = { - discriminator: ReadonlyUint8Array; - originalMessage: ReadonlyUint8Array; - originalAttestation: ReadonlyUint8Array; - newMessageBody: ReadonlyUint8Array; - newDestinationCaller: Address; -}; - -export type ReplaceMessageInstructionDataArgs = { - originalMessage: ReadonlyUint8Array; - originalAttestation: ReadonlyUint8Array; - newMessageBody: ReadonlyUint8Array; - newDestinationCaller: Address; -}; - -export function getReplaceMessageInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - [ - 'originalMessage', - addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), - ], - [ - 'originalAttestation', - addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), - ], - [ - 'newMessageBody', - addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), - ], - ['newDestinationCaller', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: REPLACE_MESSAGE_DISCRIMINATOR }) - ); -} - -export function getReplaceMessageInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - [ - 'originalMessage', - addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()), - ], - [ - 'originalAttestation', - addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()), - ], - [ - 'newMessageBody', - addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()), - ], - ['newDestinationCaller', getAddressDecoder()], - ]); -} - -export function getReplaceMessageInstructionDataCodec(): Codec< - ReplaceMessageInstructionDataArgs, - ReplaceMessageInstructionData -> { - return combineCodec( - getReplaceMessageInstructionDataEncoder(), - getReplaceMessageInstructionDataDecoder() - ); -} - -export type ReplaceMessageInput< - TAccountEventRentPayer extends string = string, - TAccountSenderAuthorityPda extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountSenderProgram extends string = string, - TAccountSystemProgram extends string = string, -> = { - eventRentPayer: TransactionSigner; - senderAuthorityPda: TransactionSigner; - messageTransmitter: Address; - messageSentEventData: TransactionSigner; - senderProgram: Address; - systemProgram?: Address; - originalMessage: ReplaceMessageInstructionDataArgs['originalMessage']; - originalAttestation: ReplaceMessageInstructionDataArgs['originalAttestation']; - newMessageBody: ReplaceMessageInstructionDataArgs['newMessageBody']; - newDestinationCaller: ReplaceMessageInstructionDataArgs['newDestinationCaller']; -}; - -export function getReplaceMessageInstruction< - TAccountEventRentPayer extends string, - TAccountSenderAuthorityPda extends string, - TAccountMessageTransmitter extends string, - TAccountMessageSentEventData extends string, - TAccountSenderProgram extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: ReplaceMessageInput< - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountSenderProgram, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): ReplaceMessageInstruction< - TProgramAddress, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountSenderProgram, - TAccountSystemProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, - senderAuthorityPda: { - value: input.senderAuthorityPda ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - senderProgram: { value: input.senderProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.eventRentPayer), - getAccountMeta(accounts.senderAuthorityPda), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.senderProgram), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getReplaceMessageInstructionDataEncoder().encode( - args as ReplaceMessageInstructionDataArgs - ), - } as ReplaceMessageInstruction< - TProgramAddress, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountSenderProgram, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedReplaceMessageInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - eventRentPayer: TAccountMetas[0]; - senderAuthorityPda: TAccountMetas[1]; - messageTransmitter: TAccountMetas[2]; - messageSentEventData: TAccountMetas[3]; - senderProgram: TAccountMetas[4]; - systemProgram: TAccountMetas[5]; - }; - data: ReplaceMessageInstructionData; -}; - -export function parseReplaceMessageInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedReplaceMessageInstruction { - if (instruction.accounts.length < 6) { - // 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: { - eventRentPayer: getNextAccount(), - senderAuthorityPda: getNextAccount(), - messageTransmitter: getNextAccount(), - messageSentEventData: getNextAccount(), - senderProgram: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getReplaceMessageInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/sendMessage.ts b/src/svm/clients/MessageTransmitter/instructions/sendMessage.ts deleted file mode 100644 index d17392904..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/sendMessage.ts +++ /dev/null @@ -1,291 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SEND_MESSAGE_DISCRIMINATOR = new Uint8Array([ - 57, 40, 34, 178, 189, 10, 65, 26, -]); - -export function getSendMessageDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SEND_MESSAGE_DISCRIMINATOR - ); -} - -export type SendMessageInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountEventRentPayer extends string | AccountMeta = string, - TAccountSenderAuthorityPda extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TAccountSenderProgram extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountEventRentPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountEventRentPayer, - TAccountSenderAuthorityPda extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSenderAuthorityPda, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountMessageSentEventData extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountMessageSentEventData, - TAccountSenderProgram extends string - ? ReadonlyAccount - : TAccountSenderProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type SendMessageInstructionData = { - discriminator: ReadonlyUint8Array; - destinationDomain: number; - recipient: Address; - messageBody: ReadonlyUint8Array; -}; - -export type SendMessageInstructionDataArgs = { - destinationDomain: number; - recipient: Address; - messageBody: ReadonlyUint8Array; -}; - -export function getSendMessageInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['destinationDomain', getU32Encoder()], - ['recipient', getAddressEncoder()], - ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ ...value, discriminator: SEND_MESSAGE_DISCRIMINATOR }) - ); -} - -export function getSendMessageInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['destinationDomain', getU32Decoder()], - ['recipient', getAddressDecoder()], - ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getSendMessageInstructionDataCodec(): Codec< - SendMessageInstructionDataArgs, - SendMessageInstructionData -> { - return combineCodec( - getSendMessageInstructionDataEncoder(), - getSendMessageInstructionDataDecoder() - ); -} - -export type SendMessageInput< - TAccountEventRentPayer extends string = string, - TAccountSenderAuthorityPda extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountSenderProgram extends string = string, - TAccountSystemProgram extends string = string, -> = { - eventRentPayer: TransactionSigner; - senderAuthorityPda: TransactionSigner; - messageTransmitter: Address; - messageSentEventData: TransactionSigner; - senderProgram: Address; - systemProgram?: Address; - destinationDomain: SendMessageInstructionDataArgs['destinationDomain']; - recipient: SendMessageInstructionDataArgs['recipient']; - messageBody: SendMessageInstructionDataArgs['messageBody']; -}; - -export function getSendMessageInstruction< - TAccountEventRentPayer extends string, - TAccountSenderAuthorityPda extends string, - TAccountMessageTransmitter extends string, - TAccountMessageSentEventData extends string, - TAccountSenderProgram extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: SendMessageInput< - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountSenderProgram, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): SendMessageInstruction< - TProgramAddress, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountSenderProgram, - TAccountSystemProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, - senderAuthorityPda: { - value: input.senderAuthorityPda ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - senderProgram: { value: input.senderProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.eventRentPayer), - getAccountMeta(accounts.senderAuthorityPda), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.senderProgram), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getSendMessageInstructionDataEncoder().encode( - args as SendMessageInstructionDataArgs - ), - } as SendMessageInstruction< - TProgramAddress, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountSenderProgram, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedSendMessageInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - eventRentPayer: TAccountMetas[0]; - senderAuthorityPda: TAccountMetas[1]; - messageTransmitter: TAccountMetas[2]; - messageSentEventData: TAccountMetas[3]; - senderProgram: TAccountMetas[4]; - systemProgram: TAccountMetas[5]; - }; - data: SendMessageInstructionData; -}; - -export function parseSendMessageInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSendMessageInstruction { - if (instruction.accounts.length < 6) { - // 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: { - eventRentPayer: getNextAccount(), - senderAuthorityPda: getNextAccount(), - messageTransmitter: getNextAccount(), - messageSentEventData: getNextAccount(), - senderProgram: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getSendMessageInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/sendMessageWithCaller.ts b/src/svm/clients/MessageTransmitter/instructions/sendMessageWithCaller.ts deleted file mode 100644 index 07513e929..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/sendMessageWithCaller.ts +++ /dev/null @@ -1,301 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SEND_MESSAGE_WITH_CALLER_DISCRIMINATOR = new Uint8Array([ - 212, 47, 34, 52, 91, 32, 176, 204, -]); - -export function getSendMessageWithCallerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SEND_MESSAGE_WITH_CALLER_DISCRIMINATOR - ); -} - -export type SendMessageWithCallerInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountEventRentPayer extends string | AccountMeta = string, - TAccountSenderAuthorityPda extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TAccountSenderProgram extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountEventRentPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountEventRentPayer, - TAccountSenderAuthorityPda extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSenderAuthorityPda, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountMessageSentEventData extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountMessageSentEventData, - TAccountSenderProgram extends string - ? ReadonlyAccount - : TAccountSenderProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type SendMessageWithCallerInstructionData = { - discriminator: ReadonlyUint8Array; - destinationDomain: number; - recipient: Address; - messageBody: ReadonlyUint8Array; - destinationCaller: Address; -}; - -export type SendMessageWithCallerInstructionDataArgs = { - destinationDomain: number; - recipient: Address; - messageBody: ReadonlyUint8Array; - destinationCaller: Address; -}; - -export function getSendMessageWithCallerInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['destinationDomain', getU32Encoder()], - ['recipient', getAddressEncoder()], - ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ['destinationCaller', getAddressEncoder()], - ]), - (value) => ({ - ...value, - discriminator: SEND_MESSAGE_WITH_CALLER_DISCRIMINATOR, - }) - ); -} - -export function getSendMessageWithCallerInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['destinationDomain', getU32Decoder()], - ['recipient', getAddressDecoder()], - ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ['destinationCaller', getAddressDecoder()], - ]); -} - -export function getSendMessageWithCallerInstructionDataCodec(): Codec< - SendMessageWithCallerInstructionDataArgs, - SendMessageWithCallerInstructionData -> { - return combineCodec( - getSendMessageWithCallerInstructionDataEncoder(), - getSendMessageWithCallerInstructionDataDecoder() - ); -} - -export type SendMessageWithCallerInput< - TAccountEventRentPayer extends string = string, - TAccountSenderAuthorityPda extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountSenderProgram extends string = string, - TAccountSystemProgram extends string = string, -> = { - eventRentPayer: TransactionSigner; - senderAuthorityPda: TransactionSigner; - messageTransmitter: Address; - messageSentEventData: TransactionSigner; - senderProgram: Address; - systemProgram?: Address; - destinationDomain: SendMessageWithCallerInstructionDataArgs['destinationDomain']; - recipient: SendMessageWithCallerInstructionDataArgs['recipient']; - messageBody: SendMessageWithCallerInstructionDataArgs['messageBody']; - destinationCaller: SendMessageWithCallerInstructionDataArgs['destinationCaller']; -}; - -export function getSendMessageWithCallerInstruction< - TAccountEventRentPayer extends string, - TAccountSenderAuthorityPda extends string, - TAccountMessageTransmitter extends string, - TAccountMessageSentEventData extends string, - TAccountSenderProgram extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: SendMessageWithCallerInput< - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountSenderProgram, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): SendMessageWithCallerInstruction< - TProgramAddress, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountSenderProgram, - TAccountSystemProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, - senderAuthorityPda: { - value: input.senderAuthorityPda ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - senderProgram: { value: input.senderProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.eventRentPayer), - getAccountMeta(accounts.senderAuthorityPda), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.senderProgram), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getSendMessageWithCallerInstructionDataEncoder().encode( - args as SendMessageWithCallerInstructionDataArgs - ), - } as SendMessageWithCallerInstruction< - TProgramAddress, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountSenderProgram, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedSendMessageWithCallerInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - eventRentPayer: TAccountMetas[0]; - senderAuthorityPda: TAccountMetas[1]; - messageTransmitter: TAccountMetas[2]; - messageSentEventData: TAccountMetas[3]; - senderProgram: TAccountMetas[4]; - systemProgram: TAccountMetas[5]; - }; - data: SendMessageWithCallerInstructionData; -}; - -export function parseSendMessageWithCallerInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSendMessageWithCallerInstruction { - if (instruction.accounts.length < 6) { - // 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: { - eventRentPayer: getNextAccount(), - senderAuthorityPda: getNextAccount(), - messageTransmitter: getNextAccount(), - messageSentEventData: getNextAccount(), - senderProgram: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getSendMessageWithCallerInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/setMaxMessageBodySize.ts b/src/svm/clients/MessageTransmitter/instructions/setMaxMessageBodySize.ts deleted file mode 100644 index 522c023b7..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/setMaxMessageBodySize.ts +++ /dev/null @@ -1,238 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_MAX_MESSAGE_BODY_SIZE_DISCRIMINATOR = new Uint8Array([ - 168, 178, 8, 117, 217, 167, 219, 31, -]); - -export function getSetMaxMessageBodySizeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_MAX_MESSAGE_BODY_SIZE_DISCRIMINATOR - ); -} - -export type SetMaxMessageBodySizeInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type SetMaxMessageBodySizeInstructionData = { - discriminator: ReadonlyUint8Array; - newMaxMessageBodySize: bigint; -}; - -export type SetMaxMessageBodySizeInstructionDataArgs = { - newMaxMessageBodySize: number | bigint; -}; - -export function getSetMaxMessageBodySizeInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newMaxMessageBodySize', getU64Encoder()], - ]), - (value) => ({ - ...value, - discriminator: SET_MAX_MESSAGE_BODY_SIZE_DISCRIMINATOR, - }) - ); -} - -export function getSetMaxMessageBodySizeInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newMaxMessageBodySize', getU64Decoder()], - ]); -} - -export function getSetMaxMessageBodySizeInstructionDataCodec(): Codec< - SetMaxMessageBodySizeInstructionDataArgs, - SetMaxMessageBodySizeInstructionData -> { - return combineCodec( - getSetMaxMessageBodySizeInstructionDataEncoder(), - getSetMaxMessageBodySizeInstructionDataDecoder() - ); -} - -export type SetMaxMessageBodySizeInput< - TAccountOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; - newMaxMessageBodySize: SetMaxMessageBodySizeInstructionDataArgs['newMaxMessageBodySize']; -}; - -export function getSetMaxMessageBodySizeInstruction< - TAccountOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: SetMaxMessageBodySizeInput< - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): SetMaxMessageBodySizeInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetMaxMessageBodySizeInstructionDataEncoder().encode( - args as SetMaxMessageBodySizeInstructionDataArgs - ), - } as SetMaxMessageBodySizeInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedSetMaxMessageBodySizeInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: SetMaxMessageBodySizeInstructionData; -}; - -export function parseSetMaxMessageBodySizeInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetMaxMessageBodySizeInstruction { - if (instruction.accounts.length < 4) { - // 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: { - owner: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getSetMaxMessageBodySizeInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/setSignatureThreshold.ts b/src/svm/clients/MessageTransmitter/instructions/setSignatureThreshold.ts deleted file mode 100644 index 889ac78cb..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/setSignatureThreshold.ts +++ /dev/null @@ -1,241 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_SIGNATURE_THRESHOLD_DISCRIMINATOR = new Uint8Array([ - 163, 19, 154, 168, 82, 209, 214, 219, -]); - -export function getSetSignatureThresholdDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_SIGNATURE_THRESHOLD_DISCRIMINATOR - ); -} - -export type SetSignatureThresholdInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountAttesterManager extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountAttesterManager extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAttesterManager, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type SetSignatureThresholdInstructionData = { - discriminator: ReadonlyUint8Array; - newSignatureThreshold: number; -}; - -export type SetSignatureThresholdInstructionDataArgs = { - newSignatureThreshold: number; -}; - -export function getSetSignatureThresholdInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newSignatureThreshold', getU32Encoder()], - ]), - (value) => ({ - ...value, - discriminator: SET_SIGNATURE_THRESHOLD_DISCRIMINATOR, - }) - ); -} - -export function getSetSignatureThresholdInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newSignatureThreshold', getU32Decoder()], - ]); -} - -export function getSetSignatureThresholdInstructionDataCodec(): Codec< - SetSignatureThresholdInstructionDataArgs, - SetSignatureThresholdInstructionData -> { - return combineCodec( - getSetSignatureThresholdInstructionDataEncoder(), - getSetSignatureThresholdInstructionDataDecoder() - ); -} - -export type SetSignatureThresholdInput< - TAccountAttesterManager extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - attesterManager: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; - newSignatureThreshold: SetSignatureThresholdInstructionDataArgs['newSignatureThreshold']; -}; - -export function getSetSignatureThresholdInstruction< - TAccountAttesterManager extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: SetSignatureThresholdInput< - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): SetSignatureThresholdInstruction< - TProgramAddress, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - attesterManager: { - value: input.attesterManager ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.attesterManager), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetSignatureThresholdInstructionDataEncoder().encode( - args as SetSignatureThresholdInstructionDataArgs - ), - } as SetSignatureThresholdInstruction< - TProgramAddress, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedSetSignatureThresholdInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - attesterManager: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: SetSignatureThresholdInstructionData; -}; - -export function parseSetSignatureThresholdInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetSignatureThresholdInstruction { - if (instruction.accounts.length < 4) { - // 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: { - attesterManager: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getSetSignatureThresholdInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/transferOwnership.ts b/src/svm/clients/MessageTransmitter/instructions/transferOwnership.ts deleted file mode 100644 index 009a2aaab..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/transferOwnership.ts +++ /dev/null @@ -1,231 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const TRANSFER_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ - 65, 177, 215, 73, 53, 45, 99, 47, -]); - -export function getTransferOwnershipDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - TRANSFER_OWNERSHIP_DISCRIMINATOR - ); -} - -export type TransferOwnershipInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type TransferOwnershipInstructionData = { - discriminator: ReadonlyUint8Array; - newOwner: Address; -}; - -export type TransferOwnershipInstructionDataArgs = { newOwner: Address }; - -export function getTransferOwnershipInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newOwner', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: TRANSFER_OWNERSHIP_DISCRIMINATOR }) - ); -} - -export function getTransferOwnershipInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newOwner', getAddressDecoder()], - ]); -} - -export function getTransferOwnershipInstructionDataCodec(): Codec< - TransferOwnershipInstructionDataArgs, - TransferOwnershipInstructionData -> { - return combineCodec( - getTransferOwnershipInstructionDataEncoder(), - getTransferOwnershipInstructionDataDecoder() - ); -} - -export type TransferOwnershipInput< - TAccountOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; - newOwner: TransferOwnershipInstructionDataArgs['newOwner']; -}; - -export function getTransferOwnershipInstruction< - TAccountOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: TransferOwnershipInput< - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): TransferOwnershipInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getTransferOwnershipInstructionDataEncoder().encode( - args as TransferOwnershipInstructionDataArgs - ), - } as TransferOwnershipInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedTransferOwnershipInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: TransferOwnershipInstructionData; -}; - -export function parseTransferOwnershipInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedTransferOwnershipInstruction { - if (instruction.accounts.length < 4) { - // 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: { - owner: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getTransferOwnershipInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/unpause.ts b/src/svm/clients/MessageTransmitter/instructions/unpause.ts deleted file mode 100644 index f2bfff89f..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/unpause.ts +++ /dev/null @@ -1,214 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UNPAUSE_DISCRIMINATOR = new Uint8Array([ - 169, 144, 4, 38, 10, 141, 188, 255, -]); - -export function getUnpauseDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(UNPAUSE_DISCRIMINATOR); -} - -export type UnpauseInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountPauser extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPauser extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountPauser, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UnpauseInstructionData = { discriminator: ReadonlyUint8Array }; - -export type UnpauseInstructionDataArgs = {}; - -export function getUnpauseInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: UNPAUSE_DISCRIMINATOR }) - ); -} - -export function getUnpauseInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getUnpauseInstructionDataCodec(): Codec< - UnpauseInstructionDataArgs, - UnpauseInstructionData -> { - return combineCodec( - getUnpauseInstructionDataEncoder(), - getUnpauseInstructionDataDecoder() - ); -} - -export type UnpauseInput< - TAccountPauser extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pauser: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; -}; - -export function getUnpauseInstruction< - TAccountPauser extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: UnpauseInput< - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UnpauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pauser: { value: input.pauser ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pauser), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUnpauseInstructionDataEncoder().encode({}), - } as UnpauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUnpauseInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - pauser: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: UnpauseInstructionData; -}; - -export function parseUnpauseInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUnpauseInstruction { - if (instruction.accounts.length < 4) { - // 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: { - pauser: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUnpauseInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/updateAttesterManager.ts b/src/svm/clients/MessageTransmitter/instructions/updateAttesterManager.ts deleted file mode 100644 index 63c53f0ca..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/updateAttesterManager.ts +++ /dev/null @@ -1,238 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UPDATE_ATTESTER_MANAGER_DISCRIMINATOR = new Uint8Array([ - 175, 245, 178, 104, 85, 179, 71, 16, -]); - -export function getUpdateAttesterManagerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - UPDATE_ATTESTER_MANAGER_DISCRIMINATOR - ); -} - -export type UpdateAttesterManagerInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UpdateAttesterManagerInstructionData = { - discriminator: ReadonlyUint8Array; - newAttesterManager: Address; -}; - -export type UpdateAttesterManagerInstructionDataArgs = { - newAttesterManager: Address; -}; - -export function getUpdateAttesterManagerInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newAttesterManager', getAddressEncoder()], - ]), - (value) => ({ - ...value, - discriminator: UPDATE_ATTESTER_MANAGER_DISCRIMINATOR, - }) - ); -} - -export function getUpdateAttesterManagerInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newAttesterManager', getAddressDecoder()], - ]); -} - -export function getUpdateAttesterManagerInstructionDataCodec(): Codec< - UpdateAttesterManagerInstructionDataArgs, - UpdateAttesterManagerInstructionData -> { - return combineCodec( - getUpdateAttesterManagerInstructionDataEncoder(), - getUpdateAttesterManagerInstructionDataDecoder() - ); -} - -export type UpdateAttesterManagerInput< - TAccountOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; - newAttesterManager: UpdateAttesterManagerInstructionDataArgs['newAttesterManager']; -}; - -export function getUpdateAttesterManagerInstruction< - TAccountOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: UpdateAttesterManagerInput< - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UpdateAttesterManagerInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUpdateAttesterManagerInstructionDataEncoder().encode( - args as UpdateAttesterManagerInstructionDataArgs - ), - } as UpdateAttesterManagerInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUpdateAttesterManagerInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: UpdateAttesterManagerInstructionData; -}; - -export function parseUpdateAttesterManagerInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUpdateAttesterManagerInstruction { - if (instruction.accounts.length < 4) { - // 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: { - owner: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUpdateAttesterManagerInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/MessageTransmitter/instructions/updatePauser.ts b/src/svm/clients/MessageTransmitter/instructions/updatePauser.ts deleted file mode 100644 index 7736174e7..000000000 --- a/src/svm/clients/MessageTransmitter/instructions/updatePauser.ts +++ /dev/null @@ -1,231 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UPDATE_PAUSER_DISCRIMINATOR = new Uint8Array([ - 140, 171, 211, 132, 57, 201, 16, 254, -]); - -export function getUpdatePauserDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - UPDATE_PAUSER_DISCRIMINATOR - ); -} - -export type UpdatePauserInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UpdatePauserInstructionData = { - discriminator: ReadonlyUint8Array; - newPauser: Address; -}; - -export type UpdatePauserInstructionDataArgs = { newPauser: Address }; - -export function getUpdatePauserInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newPauser', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: UPDATE_PAUSER_DISCRIMINATOR }) - ); -} - -export function getUpdatePauserInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newPauser', getAddressDecoder()], - ]); -} - -export function getUpdatePauserInstructionDataCodec(): Codec< - UpdatePauserInstructionDataArgs, - UpdatePauserInstructionData -> { - return combineCodec( - getUpdatePauserInstructionDataEncoder(), - getUpdatePauserInstructionDataDecoder() - ); -} - -export type UpdatePauserInput< - TAccountOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; - newPauser: UpdatePauserInstructionDataArgs['newPauser']; -}; - -export function getUpdatePauserInstruction< - TAccountOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, ->( - input: UpdatePauserInput< - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UpdatePauserInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUpdatePauserInstructionDataEncoder().encode( - args as UpdatePauserInstructionDataArgs - ), - } as UpdatePauserInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUpdatePauserInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: UpdatePauserInstructionData; -}; - -export function parseUpdatePauserInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUpdatePauserInstruction { - if (instruction.accounts.length < 4) { - // 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: { - owner: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUpdatePauserInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitter/programs/index.ts b/src/svm/clients/MessageTransmitter/programs/index.ts deleted file mode 100644 index 35d6ae3df..000000000 --- a/src/svm/clients/MessageTransmitter/programs/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './messageTransmitter'; diff --git a/src/svm/clients/MessageTransmitter/programs/messageTransmitter.ts b/src/svm/clients/MessageTransmitter/programs/messageTransmitter.ts deleted file mode 100644 index 12dc139e7..000000000 --- a/src/svm/clients/MessageTransmitter/programs/messageTransmitter.ts +++ /dev/null @@ -1,372 +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/kit'; -import { - type ParsedAcceptOwnershipInstruction, - type ParsedDisableAttesterInstruction, - type ParsedEnableAttesterInstruction, - type ParsedGetNoncePdaInstruction, - type ParsedInitializeInstruction, - type ParsedIsNonceUsedInstruction, - type ParsedPauseInstruction, - type ParsedReceiveMessageInstruction, - type ParsedReclaimEventAccountInstruction, - type ParsedReplaceMessageInstruction, - type ParsedSendMessageInstruction, - type ParsedSendMessageWithCallerInstruction, - type ParsedSetMaxMessageBodySizeInstruction, - type ParsedSetSignatureThresholdInstruction, - type ParsedTransferOwnershipInstruction, - type ParsedUnpauseInstruction, - type ParsedUpdateAttesterManagerInstruction, - type ParsedUpdatePauserInstruction, -} from '../instructions'; - -export const MESSAGE_TRANSMITTER_PROGRAM_ADDRESS = - 'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd' as Address<'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd'>; - -export enum MessageTransmitterAccount { - MessageSent, - MessageTransmitter, - UsedNonces, -} - -export function identifyMessageTransmitterAccount( - account: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): MessageTransmitterAccount { - const data = 'data' in account ? account.data : account; - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([131, 100, 133, 56, 166, 225, 151, 60]) - ), - 0 - ) - ) { - return MessageTransmitterAccount.MessageSent; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([71, 40, 180, 142, 19, 203, 35, 252]) - ), - 0 - ) - ) { - return MessageTransmitterAccount.MessageTransmitter; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([60, 112, 18, 72, 138, 181, 100, 138]) - ), - 0 - ) - ) { - return MessageTransmitterAccount.UsedNonces; - } - throw new Error( - 'The provided account could not be identified as a messageTransmitter account.' - ); -} - -export enum MessageTransmitterInstruction { - Initialize, - TransferOwnership, - AcceptOwnership, - UpdatePauser, - UpdateAttesterManager, - Pause, - Unpause, - SetMaxMessageBodySize, - EnableAttester, - DisableAttester, - SetSignatureThreshold, - SendMessage, - SendMessageWithCaller, - ReplaceMessage, - ReceiveMessage, - ReclaimEventAccount, - GetNoncePda, - IsNonceUsed, -} - -export function identifyMessageTransmitterInstruction( - instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): MessageTransmitterInstruction { - 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 MessageTransmitterInstruction.Initialize; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.TransferOwnership; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([172, 23, 43, 13, 238, 213, 85, 150]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.AcceptOwnership; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([140, 171, 211, 132, 57, 201, 16, 254]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.UpdatePauser; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([175, 245, 178, 104, 85, 179, 71, 16]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.UpdateAttesterManager; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([211, 22, 221, 251, 74, 121, 193, 47]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.Pause; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([169, 144, 4, 38, 10, 141, 188, 255]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.Unpause; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([168, 178, 8, 117, 217, 167, 219, 31]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.SetMaxMessageBodySize; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([2, 11, 193, 115, 5, 148, 4, 198]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.EnableAttester; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([61, 171, 131, 95, 172, 15, 227, 229]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.DisableAttester; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([163, 19, 154, 168, 82, 209, 214, 219]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.SetSignatureThreshold; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([57, 40, 34, 178, 189, 10, 65, 26]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.SendMessage; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([212, 47, 34, 52, 91, 32, 176, 204]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.SendMessageWithCaller; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([189, 189, 210, 163, 149, 205, 69, 229]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.ReplaceMessage; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([38, 144, 127, 225, 31, 225, 238, 25]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.ReceiveMessage; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([94, 198, 180, 159, 131, 236, 15, 174]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.ReclaimEventAccount; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([114, 70, 229, 212, 223, 50, 33, 39]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.GetNoncePda; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([144, 72, 107, 148, 35, 218, 31, 187]) - ), - 0 - ) - ) { - return MessageTransmitterInstruction.IsNonceUsed; - } - throw new Error( - 'The provided instruction could not be identified as a messageTransmitter instruction.' - ); -} - -export type ParsedMessageTransmitterInstruction< - TProgram extends string = 'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd', -> = - | ({ - instructionType: MessageTransmitterInstruction.Initialize; - } & ParsedInitializeInstruction) - | ({ - instructionType: MessageTransmitterInstruction.TransferOwnership; - } & ParsedTransferOwnershipInstruction) - | ({ - instructionType: MessageTransmitterInstruction.AcceptOwnership; - } & ParsedAcceptOwnershipInstruction) - | ({ - instructionType: MessageTransmitterInstruction.UpdatePauser; - } & ParsedUpdatePauserInstruction) - | ({ - instructionType: MessageTransmitterInstruction.UpdateAttesterManager; - } & ParsedUpdateAttesterManagerInstruction) - | ({ - instructionType: MessageTransmitterInstruction.Pause; - } & ParsedPauseInstruction) - | ({ - instructionType: MessageTransmitterInstruction.Unpause; - } & ParsedUnpauseInstruction) - | ({ - instructionType: MessageTransmitterInstruction.SetMaxMessageBodySize; - } & ParsedSetMaxMessageBodySizeInstruction) - | ({ - instructionType: MessageTransmitterInstruction.EnableAttester; - } & ParsedEnableAttesterInstruction) - | ({ - instructionType: MessageTransmitterInstruction.DisableAttester; - } & ParsedDisableAttesterInstruction) - | ({ - instructionType: MessageTransmitterInstruction.SetSignatureThreshold; - } & ParsedSetSignatureThresholdInstruction) - | ({ - instructionType: MessageTransmitterInstruction.SendMessage; - } & ParsedSendMessageInstruction) - | ({ - instructionType: MessageTransmitterInstruction.SendMessageWithCaller; - } & ParsedSendMessageWithCallerInstruction) - | ({ - instructionType: MessageTransmitterInstruction.ReplaceMessage; - } & ParsedReplaceMessageInstruction) - | ({ - instructionType: MessageTransmitterInstruction.ReceiveMessage; - } & ParsedReceiveMessageInstruction) - | ({ - instructionType: MessageTransmitterInstruction.ReclaimEventAccount; - } & ParsedReclaimEventAccountInstruction) - | ({ - instructionType: MessageTransmitterInstruction.GetNoncePda; - } & ParsedGetNoncePdaInstruction) - | ({ - instructionType: MessageTransmitterInstruction.IsNonceUsed; - } & ParsedIsNonceUsedInstruction); diff --git a/src/svm/clients/MessageTransmitter/shared/index.ts b/src/svm/clients/MessageTransmitter/shared/index.ts deleted file mode 100644 index 7ebc26514..000000000 --- a/src/svm/clients/MessageTransmitter/shared/index.ts +++ /dev/null @@ -1,164 +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 { - AccountRole, - isProgramDerivedAddress, - isTransactionSigner as kitIsTransactionSigner, - type AccountMeta, - type AccountSignerMeta, - type Address, - type ProgramDerivedAddress, - type TransactionSigner, - upgradeRoleToSigner, -} from '@solana/kit'; - -/** - * Asserts that the given value is not null or undefined. - * @internal - */ -export function expectSome(value: T | null | undefined): T { - if (value == null) { - throw new Error('Expected a value but received null or undefined.'); - } - return value; -} - -/** - * Asserts that the given value is a PublicKey. - * @internal - */ -export function expectAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): Address { - if (!value) { - throw new Error('Expected a Address.'); - } - if (typeof value === 'object' && 'address' in value) { - return value.address; - } - if (Array.isArray(value)) { - return value[0]; - } - return value as Address; -} - -/** - * Asserts that the given value is a PDA. - * @internal - */ -export function expectProgramDerivedAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): ProgramDerivedAddress { - if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { - throw new Error('Expected a ProgramDerivedAddress.'); - } - return value; -} - -/** - * Asserts that the given value is a TransactionSigner. - * @internal - */ -export function expectTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): TransactionSigner { - if (!value || !isTransactionSigner(value)) { - throw new Error('Expected a TransactionSigner.'); - } - return value; -} - -/** - * Defines an instruction account to resolve. - * @internal - */ -export type ResolvedAccount< - T extends string = string, - U extends - | Address - | ProgramDerivedAddress - | TransactionSigner - | null = - | Address - | ProgramDerivedAddress - | TransactionSigner - | null, -> = { - isWritable: boolean; - value: U; -}; - -/** - * Defines an instruction that stores additional bytes on-chain. - * @internal - */ -export type InstructionWithByteDelta = { - byteDelta: number; -}; - -/** - * Get account metas and signers from resolved accounts. - * @internal - */ -export function getAccountMetaFactory( - programAddress: Address, - optionalAccountStrategy: 'omitted' | 'programId' -) { - return ( - account: ResolvedAccount - ): AccountMeta | AccountSignerMeta | undefined => { - if (!account.value) { - if (optionalAccountStrategy === 'omitted') return; - return Object.freeze({ - address: programAddress, - role: AccountRole.READONLY, - }); - } - - const writableRole = account.isWritable - ? AccountRole.WRITABLE - : AccountRole.READONLY; - return Object.freeze({ - address: expectAddress(account.value), - role: isTransactionSigner(account.value) - ? upgradeRoleToSigner(writableRole) - : writableRole, - ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), - }); - }; -} - -export function isTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner -): value is TransactionSigner { - return ( - !!value && - typeof value === 'object' && - 'address' in value && - kitIsTransactionSigner(value) - ); -} diff --git a/src/svm/clients/MessageTransmitter/types/attesterDisabled.ts b/src/svm/clients/MessageTransmitter/types/attesterDisabled.ts deleted file mode 100644 index b643a7a51..000000000 --- a/src/svm/clients/MessageTransmitter/types/attesterDisabled.ts +++ /dev/null @@ -1,41 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type AttesterDisabled = { attester: Address }; - -export type AttesterDisabledArgs = AttesterDisabled; - -export function getAttesterDisabledEncoder(): Encoder { - return getStructEncoder([['attester', getAddressEncoder()]]); -} - -export function getAttesterDisabledDecoder(): Decoder { - return getStructDecoder([['attester', getAddressDecoder()]]); -} - -export function getAttesterDisabledCodec(): Codec< - AttesterDisabledArgs, - AttesterDisabled -> { - return combineCodec( - getAttesterDisabledEncoder(), - getAttesterDisabledDecoder() - ); -} diff --git a/src/svm/clients/MessageTransmitter/types/attesterEnabled.ts b/src/svm/clients/MessageTransmitter/types/attesterEnabled.ts deleted file mode 100644 index ad2132a58..000000000 --- a/src/svm/clients/MessageTransmitter/types/attesterEnabled.ts +++ /dev/null @@ -1,38 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type AttesterEnabled = { attester: Address }; - -export type AttesterEnabledArgs = AttesterEnabled; - -export function getAttesterEnabledEncoder(): Encoder { - return getStructEncoder([['attester', getAddressEncoder()]]); -} - -export function getAttesterEnabledDecoder(): Decoder { - return getStructDecoder([['attester', getAddressDecoder()]]); -} - -export function getAttesterEnabledCodec(): Codec< - AttesterEnabledArgs, - AttesterEnabled -> { - return combineCodec(getAttesterEnabledEncoder(), getAttesterEnabledDecoder()); -} diff --git a/src/svm/clients/MessageTransmitter/types/attesterManagerUpdated.ts b/src/svm/clients/MessageTransmitter/types/attesterManagerUpdated.ts deleted file mode 100644 index f75c9f3ec..000000000 --- a/src/svm/clients/MessageTransmitter/types/attesterManagerUpdated.ts +++ /dev/null @@ -1,50 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type AttesterManagerUpdated = { - previousAttesterManager: Address; - newAttesterManager: Address; -}; - -export type AttesterManagerUpdatedArgs = AttesterManagerUpdated; - -export function getAttesterManagerUpdatedEncoder(): Encoder { - return getStructEncoder([ - ['previousAttesterManager', getAddressEncoder()], - ['newAttesterManager', getAddressEncoder()], - ]); -} - -export function getAttesterManagerUpdatedDecoder(): Decoder { - return getStructDecoder([ - ['previousAttesterManager', getAddressDecoder()], - ['newAttesterManager', getAddressDecoder()], - ]); -} - -export function getAttesterManagerUpdatedCodec(): Codec< - AttesterManagerUpdatedArgs, - AttesterManagerUpdated -> { - return combineCodec( - getAttesterManagerUpdatedEncoder(), - getAttesterManagerUpdatedDecoder() - ); -} diff --git a/src/svm/clients/MessageTransmitter/types/handleReceiveMessageParams.ts b/src/svm/clients/MessageTransmitter/types/handleReceiveMessageParams.ts deleted file mode 100644 index f0d1dde9b..000000000 --- a/src/svm/clients/MessageTransmitter/types/handleReceiveMessageParams.ts +++ /dev/null @@ -1,65 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU8Decoder, - getU8Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export type HandleReceiveMessageParams = { - remoteDomain: number; - sender: Address; - messageBody: ReadonlyUint8Array; - authorityBump: number; -}; - -export type HandleReceiveMessageParamsArgs = HandleReceiveMessageParams; - -export function getHandleReceiveMessageParamsEncoder(): Encoder { - return getStructEncoder([ - ['remoteDomain', getU32Encoder()], - ['sender', getAddressEncoder()], - ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ['authorityBump', getU8Encoder()], - ]); -} - -export function getHandleReceiveMessageParamsDecoder(): Decoder { - return getStructDecoder([ - ['remoteDomain', getU32Decoder()], - ['sender', getAddressDecoder()], - ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ['authorityBump', getU8Decoder()], - ]); -} - -export function getHandleReceiveMessageParamsCodec(): Codec< - HandleReceiveMessageParamsArgs, - HandleReceiveMessageParams -> { - return combineCodec( - getHandleReceiveMessageParamsEncoder(), - getHandleReceiveMessageParamsDecoder() - ); -} diff --git a/src/svm/clients/MessageTransmitter/types/index.ts b/src/svm/clients/MessageTransmitter/types/index.ts deleted file mode 100644 index 131ee2226..000000000 --- a/src/svm/clients/MessageTransmitter/types/index.ts +++ /dev/null @@ -1,21 +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 - */ - -export * from './attesterDisabled'; -export * from './attesterEnabled'; -export * from './attesterManagerUpdated'; -export * from './handleReceiveMessageParams'; -export * from './mathError'; -export * from './maxMessageBodySizeUpdated'; -export * from './messageReceived'; -export * from './ownershipTransferred'; -export * from './ownershipTransferStarted'; -export * from './pause'; -export * from './pauserChanged'; -export * from './signatureThresholdUpdated'; -export * from './unpause'; diff --git a/src/svm/clients/MessageTransmitter/types/mathError.ts b/src/svm/clients/MessageTransmitter/types/mathError.ts deleted file mode 100644 index 725835c2a..000000000 --- a/src/svm/clients/MessageTransmitter/types/mathError.ts +++ /dev/null @@ -1,36 +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 { - combineCodec, - getEnumDecoder, - getEnumEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export enum MathError { - MathOverflow, - MathUnderflow, - ErrorInDivision, -} - -export type MathErrorArgs = MathError; - -export function getMathErrorEncoder(): Encoder { - return getEnumEncoder(MathError); -} - -export function getMathErrorDecoder(): Decoder { - return getEnumDecoder(MathError); -} - -export function getMathErrorCodec(): Codec { - return combineCodec(getMathErrorEncoder(), getMathErrorDecoder()); -} diff --git a/src/svm/clients/MessageTransmitter/types/maxMessageBodySizeUpdated.ts b/src/svm/clients/MessageTransmitter/types/maxMessageBodySizeUpdated.ts deleted file mode 100644 index 8a0231c61..000000000 --- a/src/svm/clients/MessageTransmitter/types/maxMessageBodySizeUpdated.ts +++ /dev/null @@ -1,42 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type MaxMessageBodySizeUpdated = { newMaxMessageBodySize: bigint }; - -export type MaxMessageBodySizeUpdatedArgs = { - newMaxMessageBodySize: number | bigint; -}; - -export function getMaxMessageBodySizeUpdatedEncoder(): Encoder { - return getStructEncoder([['newMaxMessageBodySize', getU64Encoder()]]); -} - -export function getMaxMessageBodySizeUpdatedDecoder(): Decoder { - return getStructDecoder([['newMaxMessageBodySize', getU64Decoder()]]); -} - -export function getMaxMessageBodySizeUpdatedCodec(): Codec< - MaxMessageBodySizeUpdatedArgs, - MaxMessageBodySizeUpdated -> { - return combineCodec( - getMaxMessageBodySizeUpdatedEncoder(), - getMaxMessageBodySizeUpdatedDecoder() - ); -} diff --git a/src/svm/clients/MessageTransmitter/types/messageReceived.ts b/src/svm/clients/MessageTransmitter/types/messageReceived.ts deleted file mode 100644 index 3340a3c79..000000000 --- a/src/svm/clients/MessageTransmitter/types/messageReceived.ts +++ /dev/null @@ -1,71 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export type MessageReceived = { - caller: Address; - sourceDomain: number; - nonce: bigint; - sender: Address; - messageBody: ReadonlyUint8Array; -}; - -export type MessageReceivedArgs = { - caller: Address; - sourceDomain: number; - nonce: number | bigint; - sender: Address; - messageBody: ReadonlyUint8Array; -}; - -export function getMessageReceivedEncoder(): Encoder { - return getStructEncoder([ - ['caller', getAddressEncoder()], - ['sourceDomain', getU32Encoder()], - ['nonce', getU64Encoder()], - ['sender', getAddressEncoder()], - ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]); -} - -export function getMessageReceivedDecoder(): Decoder { - return getStructDecoder([ - ['caller', getAddressDecoder()], - ['sourceDomain', getU32Decoder()], - ['nonce', getU64Decoder()], - ['sender', getAddressDecoder()], - ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getMessageReceivedCodec(): Codec< - MessageReceivedArgs, - MessageReceived -> { - return combineCodec(getMessageReceivedEncoder(), getMessageReceivedDecoder()); -} diff --git a/src/svm/clients/MessageTransmitter/types/ownershipTransferStarted.ts b/src/svm/clients/MessageTransmitter/types/ownershipTransferStarted.ts deleted file mode 100644 index e170a569a..000000000 --- a/src/svm/clients/MessageTransmitter/types/ownershipTransferStarted.ts +++ /dev/null @@ -1,50 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type OwnershipTransferStarted = { - previousOwner: Address; - newOwner: Address; -}; - -export type OwnershipTransferStartedArgs = OwnershipTransferStarted; - -export function getOwnershipTransferStartedEncoder(): Encoder { - return getStructEncoder([ - ['previousOwner', getAddressEncoder()], - ['newOwner', getAddressEncoder()], - ]); -} - -export function getOwnershipTransferStartedDecoder(): Decoder { - return getStructDecoder([ - ['previousOwner', getAddressDecoder()], - ['newOwner', getAddressDecoder()], - ]); -} - -export function getOwnershipTransferStartedCodec(): Codec< - OwnershipTransferStartedArgs, - OwnershipTransferStarted -> { - return combineCodec( - getOwnershipTransferStartedEncoder(), - getOwnershipTransferStartedDecoder() - ); -} diff --git a/src/svm/clients/MessageTransmitter/types/ownershipTransferred.ts b/src/svm/clients/MessageTransmitter/types/ownershipTransferred.ts deleted file mode 100644 index 40f21c661..000000000 --- a/src/svm/clients/MessageTransmitter/types/ownershipTransferred.ts +++ /dev/null @@ -1,50 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type OwnershipTransferred = { - previousOwner: Address; - newOwner: Address; -}; - -export type OwnershipTransferredArgs = OwnershipTransferred; - -export function getOwnershipTransferredEncoder(): Encoder { - return getStructEncoder([ - ['previousOwner', getAddressEncoder()], - ['newOwner', getAddressEncoder()], - ]); -} - -export function getOwnershipTransferredDecoder(): Decoder { - return getStructDecoder([ - ['previousOwner', getAddressDecoder()], - ['newOwner', getAddressDecoder()], - ]); -} - -export function getOwnershipTransferredCodec(): Codec< - OwnershipTransferredArgs, - OwnershipTransferred -> { - return combineCodec( - getOwnershipTransferredEncoder(), - getOwnershipTransferredDecoder() - ); -} diff --git a/src/svm/clients/MessageTransmitter/types/pause.ts b/src/svm/clients/MessageTransmitter/types/pause.ts deleted file mode 100644 index f1f423325..000000000 --- a/src/svm/clients/MessageTransmitter/types/pause.ts +++ /dev/null @@ -1,32 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type Pause = {}; - -export type PauseArgs = Pause; - -export function getPauseEncoder(): Encoder { - return getStructEncoder([]); -} - -export function getPauseDecoder(): Decoder { - return getStructDecoder([]); -} - -export function getPauseCodec(): Codec { - return combineCodec(getPauseEncoder(), getPauseDecoder()); -} diff --git a/src/svm/clients/MessageTransmitter/types/pauserChanged.ts b/src/svm/clients/MessageTransmitter/types/pauserChanged.ts deleted file mode 100644 index 57d7433da..000000000 --- a/src/svm/clients/MessageTransmitter/types/pauserChanged.ts +++ /dev/null @@ -1,38 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type PauserChanged = { newAddress: Address }; - -export type PauserChangedArgs = PauserChanged; - -export function getPauserChangedEncoder(): Encoder { - return getStructEncoder([['newAddress', getAddressEncoder()]]); -} - -export function getPauserChangedDecoder(): Decoder { - return getStructDecoder([['newAddress', getAddressDecoder()]]); -} - -export function getPauserChangedCodec(): Codec< - PauserChangedArgs, - PauserChanged -> { - return combineCodec(getPauserChangedEncoder(), getPauserChangedDecoder()); -} diff --git a/src/svm/clients/MessageTransmitter/types/signatureThresholdUpdated.ts b/src/svm/clients/MessageTransmitter/types/signatureThresholdUpdated.ts deleted file mode 100644 index e8a729867..000000000 --- a/src/svm/clients/MessageTransmitter/types/signatureThresholdUpdated.ts +++ /dev/null @@ -1,49 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type SignatureThresholdUpdated = { - oldSignatureThreshold: number; - newSignatureThreshold: number; -}; - -export type SignatureThresholdUpdatedArgs = SignatureThresholdUpdated; - -export function getSignatureThresholdUpdatedEncoder(): Encoder { - return getStructEncoder([ - ['oldSignatureThreshold', getU32Encoder()], - ['newSignatureThreshold', getU32Encoder()], - ]); -} - -export function getSignatureThresholdUpdatedDecoder(): Decoder { - return getStructDecoder([ - ['oldSignatureThreshold', getU32Decoder()], - ['newSignatureThreshold', getU32Decoder()], - ]); -} - -export function getSignatureThresholdUpdatedCodec(): Codec< - SignatureThresholdUpdatedArgs, - SignatureThresholdUpdated -> { - return combineCodec( - getSignatureThresholdUpdatedEncoder(), - getSignatureThresholdUpdatedDecoder() - ); -} diff --git a/src/svm/clients/MessageTransmitter/types/unpause.ts b/src/svm/clients/MessageTransmitter/types/unpause.ts deleted file mode 100644 index 4fdc009ef..000000000 --- a/src/svm/clients/MessageTransmitter/types/unpause.ts +++ /dev/null @@ -1,32 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type Unpause = {}; - -export type UnpauseArgs = Unpause; - -export function getUnpauseEncoder(): Encoder { - return getStructEncoder([]); -} - -export function getUnpauseDecoder(): Decoder { - return getStructDecoder([]); -} - -export function getUnpauseCodec(): Codec { - return combineCodec(getUnpauseEncoder(), getUnpauseDecoder()); -} diff --git a/src/svm/clients/MessageTransmitterV2/accounts/index.ts b/src/svm/clients/MessageTransmitterV2/accounts/index.ts deleted file mode 100644 index 4475a820f..000000000 --- a/src/svm/clients/MessageTransmitterV2/accounts/index.ts +++ /dev/null @@ -1,11 +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 - */ - -export * from './messageSent'; -export * from './messageTransmitter'; -export * from './usedNonce'; diff --git a/src/svm/clients/MessageTransmitterV2/accounts/messageSent.ts b/src/svm/clients/MessageTransmitterV2/accounts/messageSent.ts deleted file mode 100644 index e401030f7..000000000 --- a/src/svm/clients/MessageTransmitterV2/accounts/messageSent.ts +++ /dev/null @@ -1,143 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getI64Decoder, - getI64Encoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const MESSAGE_SENT_DISCRIMINATOR = new Uint8Array([ - 131, 100, 133, 56, 166, 225, 151, 60, -]); - -export function getMessageSentDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - MESSAGE_SENT_DISCRIMINATOR - ); -} - -export type MessageSent = { - discriminator: ReadonlyUint8Array; - rentPayer: Address; - createdAt: bigint; - message: ReadonlyUint8Array; -}; - -export type MessageSentArgs = { - rentPayer: Address; - createdAt: number | bigint; - message: ReadonlyUint8Array; -}; - -export function getMessageSentEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['rentPayer', getAddressEncoder()], - ['createdAt', getI64Encoder()], - ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ ...value, discriminator: MESSAGE_SENT_DISCRIMINATOR }) - ); -} - -export function getMessageSentDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['rentPayer', getAddressDecoder()], - ['createdAt', getI64Decoder()], - ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getMessageSentCodec(): Codec { - return combineCodec(getMessageSentEncoder(), getMessageSentDecoder()); -} - -export function decodeMessageSent( - encodedAccount: EncodedAccount -): Account; -export function decodeMessageSent( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeMessageSent( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getMessageSentDecoder() - ); -} - -export async function fetchMessageSent( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeMessageSent(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeMessageSent( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeMessageSent(maybeAccount); -} - -export async function fetchAllMessageSent( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeMessageSent(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeMessageSent( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeMessageSent(maybeAccount)); -} diff --git a/src/svm/clients/MessageTransmitterV2/accounts/messageTransmitter.ts b/src/svm/clients/MessageTransmitterV2/accounts/messageTransmitter.ts deleted file mode 100644 index 7f6c300df..000000000 --- a/src/svm/clients/MessageTransmitterV2/accounts/messageTransmitter.ts +++ /dev/null @@ -1,189 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getArrayDecoder, - getArrayEncoder, - getBooleanDecoder, - getBooleanEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const MESSAGE_TRANSMITTER_DISCRIMINATOR = new Uint8Array([ - 71, 40, 180, 142, 19, 203, 35, 252, -]); - -export function getMessageTransmitterDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - MESSAGE_TRANSMITTER_DISCRIMINATOR - ); -} - -export type MessageTransmitter = { - discriminator: ReadonlyUint8Array; - owner: Address; - pendingOwner: Address; - attesterManager: Address; - pauser: Address; - paused: boolean; - localDomain: number; - version: number; - signatureThreshold: number; - enabledAttesters: Array
; - maxMessageBodySize: bigint; -}; - -export type MessageTransmitterArgs = { - owner: Address; - pendingOwner: Address; - attesterManager: Address; - pauser: Address; - paused: boolean; - localDomain: number; - version: number; - signatureThreshold: number; - enabledAttesters: Array
; - maxMessageBodySize: number | bigint; -}; - -export function getMessageTransmitterEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['owner', getAddressEncoder()], - ['pendingOwner', getAddressEncoder()], - ['attesterManager', getAddressEncoder()], - ['pauser', getAddressEncoder()], - ['paused', getBooleanEncoder()], - ['localDomain', getU32Encoder()], - ['version', getU32Encoder()], - ['signatureThreshold', getU32Encoder()], - ['enabledAttesters', getArrayEncoder(getAddressEncoder())], - ['maxMessageBodySize', getU64Encoder()], - ]), - (value) => ({ ...value, discriminator: MESSAGE_TRANSMITTER_DISCRIMINATOR }) - ); -} - -export function getMessageTransmitterDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['owner', getAddressDecoder()], - ['pendingOwner', getAddressDecoder()], - ['attesterManager', getAddressDecoder()], - ['pauser', getAddressDecoder()], - ['paused', getBooleanDecoder()], - ['localDomain', getU32Decoder()], - ['version', getU32Decoder()], - ['signatureThreshold', getU32Decoder()], - ['enabledAttesters', getArrayDecoder(getAddressDecoder())], - ['maxMessageBodySize', getU64Decoder()], - ]); -} - -export function getMessageTransmitterCodec(): Codec< - MessageTransmitterArgs, - MessageTransmitter -> { - return combineCodec( - getMessageTransmitterEncoder(), - getMessageTransmitterDecoder() - ); -} - -export function decodeMessageTransmitter( - encodedAccount: EncodedAccount -): Account; -export function decodeMessageTransmitter( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeMessageTransmitter( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): - | Account - | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getMessageTransmitterDecoder() - ); -} - -export async function fetchMessageTransmitter( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeMessageTransmitter(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeMessageTransmitter< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeMessageTransmitter(maybeAccount); -} - -export async function fetchAllMessageTransmitter( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeMessageTransmitter( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeMessageTransmitter( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeMessageTransmitter(maybeAccount) - ); -} diff --git a/src/svm/clients/MessageTransmitterV2/accounts/usedNonce.ts b/src/svm/clients/MessageTransmitterV2/accounts/usedNonce.ts deleted file mode 100644 index a39c6cbbd..000000000 --- a/src/svm/clients/MessageTransmitterV2/accounts/usedNonce.ts +++ /dev/null @@ -1,126 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getBooleanDecoder, - getBooleanEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const USED_NONCE_DISCRIMINATOR = new Uint8Array([ - 212, 222, 157, 252, 130, 71, 179, 238, -]); - -export function getUsedNonceDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(USED_NONCE_DISCRIMINATOR); -} - -export type UsedNonce = { discriminator: ReadonlyUint8Array; isUsed: boolean }; - -export type UsedNonceArgs = { isUsed: boolean }; - -export function getUsedNonceEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['isUsed', getBooleanEncoder()], - ]), - (value) => ({ ...value, discriminator: USED_NONCE_DISCRIMINATOR }) - ); -} - -export function getUsedNonceDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['isUsed', getBooleanDecoder()], - ]); -} - -export function getUsedNonceCodec(): Codec { - return combineCodec(getUsedNonceEncoder(), getUsedNonceDecoder()); -} - -export function decodeUsedNonce( - encodedAccount: EncodedAccount -): Account; -export function decodeUsedNonce( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeUsedNonce( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getUsedNonceDecoder() - ); -} - -export async function fetchUsedNonce( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeUsedNonce(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeUsedNonce( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeUsedNonce(maybeAccount); -} - -export async function fetchAllUsedNonce( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeUsedNonce(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeUsedNonce( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeUsedNonce(maybeAccount)); -} - -export function getUsedNonceSize(): number { - return 9; -} diff --git a/src/svm/clients/MessageTransmitterV2/errors/index.ts b/src/svm/clients/MessageTransmitterV2/errors/index.ts deleted file mode 100644 index eecc709dc..000000000 --- a/src/svm/clients/MessageTransmitterV2/errors/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './messageTransmitterV2'; diff --git a/src/svm/clients/MessageTransmitterV2/errors/messageTransmitterV2.ts b/src/svm/clients/MessageTransmitterV2/errors/messageTransmitterV2.ts deleted file mode 100644 index 1e8e1a679..000000000 --- a/src/svm/clients/MessageTransmitterV2/errors/messageTransmitterV2.ts +++ /dev/null @@ -1,199 +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 { - isProgramError, - type Address, - type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, - type SolanaError, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; - -/** InvalidAuthority: Invalid authority */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_AUTHORITY = 0x1770; // 6000 -/** ProgramPaused: Instruction is not allowed at this time */ -export const MESSAGE_TRANSMITTER_V2_ERROR__PROGRAM_PAUSED = 0x1771; // 6001 -/** InvalidMessageTransmitterState: Invalid message transmitter state */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_TRANSMITTER_STATE = 0x1772; // 6002 -/** InvalidSignatureThreshold: Invalid signature threshold */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_THRESHOLD = 0x1773; // 6003 -/** SignatureThresholdAlreadySet: Signature threshold already set */ -export const MESSAGE_TRANSMITTER_V2_ERROR__SIGNATURE_THRESHOLD_ALREADY_SET = 0x1774; // 6004 -/** InvalidOwner: Invalid owner */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_OWNER = 0x1775; // 6005 -/** InvalidPauser: Invalid pauser */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_PAUSER = 0x1776; // 6006 -/** InvalidAttesterManager: Invalid attester manager */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER_MANAGER = 0x1777; // 6007 -/** InvalidAttester: Invalid attester */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER = 0x1778; // 6008 -/** AttesterAlreadyEnabled: Attester already enabled */ -export const MESSAGE_TRANSMITTER_V2_ERROR__ATTESTER_ALREADY_ENABLED = 0x1779; // 6009 -/** TooFewEnabledAttesters: Too few enabled attesters */ -export const MESSAGE_TRANSMITTER_V2_ERROR__TOO_FEW_ENABLED_ATTESTERS = 0x177a; // 6010 -/** SignatureThresholdTooLow: Signature threshold is too low */ -export const MESSAGE_TRANSMITTER_V2_ERROR__SIGNATURE_THRESHOLD_TOO_LOW = 0x177b; // 6011 -/** AttesterAlreadyDisabled: Attester already disabled */ -export const MESSAGE_TRANSMITTER_V2_ERROR__ATTESTER_ALREADY_DISABLED = 0x177c; // 6012 -/** MessageBodyLimitExceeded: Message body exceeds max size */ -export const MESSAGE_TRANSMITTER_V2_ERROR__MESSAGE_BODY_LIMIT_EXCEEDED = 0x177d; // 6013 -/** InvalidDestinationCaller: Invalid destination caller */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_CALLER = 0x177e; // 6014 -/** InvalidRecipient: Invalid message recipient */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_RECIPIENT = 0x177f; // 6015 -/** SenderNotPermitted: Sender is not permitted */ -export const MESSAGE_TRANSMITTER_V2_ERROR__SENDER_NOT_PERMITTED = 0x1780; // 6016 -/** InvalidSourceDomain: Invalid source domain */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SOURCE_DOMAIN = 0x1781; // 6017 -/** InvalidDestinationDomain: Invalid destination domain */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_DOMAIN = 0x1782; // 6018 -/** InvalidMessageVersion: Invalid message version */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_VERSION = 0x1783; // 6019 -/** InvalidUsedNoncesAccount: Invalid used nonces account */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_USED_NONCES_ACCOUNT = 0x1784; // 6020 -/** InvalidRecipientProgram: Invalid recipient program */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_RECIPIENT_PROGRAM = 0x1785; // 6021 -/** InvalidNonce: Invalid nonce */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_NONCE = 0x1786; // 6022 -/** NonceAlreadyUsed: Nonce already used */ -export const MESSAGE_TRANSMITTER_V2_ERROR__NONCE_ALREADY_USED = 0x1787; // 6023 -/** MessageTooShort: Message is too short */ -export const MESSAGE_TRANSMITTER_V2_ERROR__MESSAGE_TOO_SHORT = 0x1788; // 6024 -/** MalformedMessage: Malformed message */ -export const MESSAGE_TRANSMITTER_V2_ERROR__MALFORMED_MESSAGE = 0x1789; // 6025 -/** InvalidSignatureOrderOrDupe: Invalid signature order or dupe */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_ORDER_OR_DUPE = 0x178a; // 6026 -/** InvalidAttesterSignature: Invalid attester signature */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER_SIGNATURE = 0x178b; // 6027 -/** InvalidAttestationLength: Invalid attestation length */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTATION_LENGTH = 0x178c; // 6028 -/** InvalidSignatureRecoveryId: Invalid signature recovery ID */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_RECOVERY_ID = 0x178d; // 6029 -/** InvalidSignatureSValue: Invalid signature S value */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_S_VALUE = 0x178e; // 6030 -/** InvalidMessageHash: Invalid message hash */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_HASH = 0x178f; // 6031 -/** InvalidDestinationMessage: Invalid destination message */ -export const MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_MESSAGE = 0x1790; // 6032 -/** EventAccountWindowNotExpired: Event account window not expired */ -export const MESSAGE_TRANSMITTER_V2_ERROR__EVENT_ACCOUNT_WINDOW_NOT_EXPIRED = 0x1791; // 6033 -/** DestinationDomainIsLocalDomain: Destination domain is local domain */ -export const MESSAGE_TRANSMITTER_V2_ERROR__DESTINATION_DOMAIN_IS_LOCAL_DOMAIN = 0x1792; // 6034 - -export type MessageTransmitterV2Error = - | typeof MESSAGE_TRANSMITTER_V2_ERROR__ATTESTER_ALREADY_DISABLED - | typeof MESSAGE_TRANSMITTER_V2_ERROR__ATTESTER_ALREADY_ENABLED - | typeof MESSAGE_TRANSMITTER_V2_ERROR__DESTINATION_DOMAIN_IS_LOCAL_DOMAIN - | typeof MESSAGE_TRANSMITTER_V2_ERROR__EVENT_ACCOUNT_WINDOW_NOT_EXPIRED - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTATION_LENGTH - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER_MANAGER - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER_SIGNATURE - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_AUTHORITY - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_CALLER - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_DOMAIN - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_MESSAGE - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_HASH - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_TRANSMITTER_STATE - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_VERSION - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_NONCE - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_OWNER - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_PAUSER - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_RECIPIENT - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_RECIPIENT_PROGRAM - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_ORDER_OR_DUPE - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_RECOVERY_ID - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_S_VALUE - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_THRESHOLD - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SOURCE_DOMAIN - | typeof MESSAGE_TRANSMITTER_V2_ERROR__INVALID_USED_NONCES_ACCOUNT - | typeof MESSAGE_TRANSMITTER_V2_ERROR__MALFORMED_MESSAGE - | typeof MESSAGE_TRANSMITTER_V2_ERROR__MESSAGE_BODY_LIMIT_EXCEEDED - | typeof MESSAGE_TRANSMITTER_V2_ERROR__MESSAGE_TOO_SHORT - | typeof MESSAGE_TRANSMITTER_V2_ERROR__NONCE_ALREADY_USED - | typeof MESSAGE_TRANSMITTER_V2_ERROR__PROGRAM_PAUSED - | typeof MESSAGE_TRANSMITTER_V2_ERROR__SENDER_NOT_PERMITTED - | typeof MESSAGE_TRANSMITTER_V2_ERROR__SIGNATURE_THRESHOLD_ALREADY_SET - | typeof MESSAGE_TRANSMITTER_V2_ERROR__SIGNATURE_THRESHOLD_TOO_LOW - | typeof MESSAGE_TRANSMITTER_V2_ERROR__TOO_FEW_ENABLED_ATTESTERS; - -let messageTransmitterV2ErrorMessages: - | Record - | undefined; -if (process.env.NODE_ENV !== 'production') { - messageTransmitterV2ErrorMessages = { - [MESSAGE_TRANSMITTER_V2_ERROR__ATTESTER_ALREADY_DISABLED]: `Attester already disabled`, - [MESSAGE_TRANSMITTER_V2_ERROR__ATTESTER_ALREADY_ENABLED]: `Attester already enabled`, - [MESSAGE_TRANSMITTER_V2_ERROR__DESTINATION_DOMAIN_IS_LOCAL_DOMAIN]: `Destination domain is local domain`, - [MESSAGE_TRANSMITTER_V2_ERROR__EVENT_ACCOUNT_WINDOW_NOT_EXPIRED]: `Event account window not expired`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTATION_LENGTH]: `Invalid attestation length`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER]: `Invalid attester`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER_MANAGER]: `Invalid attester manager`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_ATTESTER_SIGNATURE]: `Invalid attester signature`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_AUTHORITY]: `Invalid authority`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_CALLER]: `Invalid destination caller`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_DOMAIN]: `Invalid destination domain`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_DESTINATION_MESSAGE]: `Invalid destination message`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_HASH]: `Invalid message hash`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_TRANSMITTER_STATE]: `Invalid message transmitter state`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_MESSAGE_VERSION]: `Invalid message version`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_NONCE]: `Invalid nonce`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_OWNER]: `Invalid owner`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_PAUSER]: `Invalid pauser`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_RECIPIENT]: `Invalid message recipient`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_RECIPIENT_PROGRAM]: `Invalid recipient program`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_ORDER_OR_DUPE]: `Invalid signature order or dupe`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_RECOVERY_ID]: `Invalid signature recovery ID`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_S_VALUE]: `Invalid signature S value`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SIGNATURE_THRESHOLD]: `Invalid signature threshold`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_SOURCE_DOMAIN]: `Invalid source domain`, - [MESSAGE_TRANSMITTER_V2_ERROR__INVALID_USED_NONCES_ACCOUNT]: `Invalid used nonces account`, - [MESSAGE_TRANSMITTER_V2_ERROR__MALFORMED_MESSAGE]: `Malformed message`, - [MESSAGE_TRANSMITTER_V2_ERROR__MESSAGE_BODY_LIMIT_EXCEEDED]: `Message body exceeds max size`, - [MESSAGE_TRANSMITTER_V2_ERROR__MESSAGE_TOO_SHORT]: `Message is too short`, - [MESSAGE_TRANSMITTER_V2_ERROR__NONCE_ALREADY_USED]: `Nonce already used`, - [MESSAGE_TRANSMITTER_V2_ERROR__PROGRAM_PAUSED]: `Instruction is not allowed at this time`, - [MESSAGE_TRANSMITTER_V2_ERROR__SENDER_NOT_PERMITTED]: `Sender is not permitted`, - [MESSAGE_TRANSMITTER_V2_ERROR__SIGNATURE_THRESHOLD_ALREADY_SET]: `Signature threshold already set`, - [MESSAGE_TRANSMITTER_V2_ERROR__SIGNATURE_THRESHOLD_TOO_LOW]: `Signature threshold is too low`, - [MESSAGE_TRANSMITTER_V2_ERROR__TOO_FEW_ENABLED_ATTESTERS]: `Too few enabled attesters`, - }; -} - -export function getMessageTransmitterV2ErrorMessage( - code: MessageTransmitterV2Error -): string { - if (process.env.NODE_ENV !== 'production') { - return ( - messageTransmitterV2ErrorMessages as Record< - MessageTransmitterV2Error, - string - > - )[code]; - } - - return 'Error message not available in production bundles.'; -} - -export function isMessageTransmitterV2Error< - TProgramErrorCode extends MessageTransmitterV2Error, ->( - error: unknown, - transactionMessage: { - instructions: Record; - }, - code?: TProgramErrorCode -): error is SolanaError & - Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { - return isProgramError( - error, - transactionMessage, - MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - code - ); -} diff --git a/src/svm/clients/MessageTransmitterV2/index.ts b/src/svm/clients/MessageTransmitterV2/index.ts deleted file mode 100644 index 02964a6ae..000000000 --- a/src/svm/clients/MessageTransmitterV2/index.ts +++ /dev/null @@ -1,13 +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 - */ - -export * from './accounts'; -export * from './errors'; -export * from './instructions'; -export * from './programs'; -export * from './types'; diff --git a/src/svm/clients/MessageTransmitterV2/instructions/acceptOwnership.ts b/src/svm/clients/MessageTransmitterV2/instructions/acceptOwnership.ts deleted file mode 100644 index aa7ab864c..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/acceptOwnership.ts +++ /dev/null @@ -1,311 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const ACCEPT_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ - 172, 23, 43, 13, 238, 213, 85, 150, -]); - -export function getAcceptOwnershipDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - ACCEPT_OWNERSHIP_DISCRIMINATOR - ); -} - -export type AcceptOwnershipInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountPendingOwner extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPendingOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountPendingOwner, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type AcceptOwnershipInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type AcceptOwnershipInstructionDataArgs = {}; - -export function getAcceptOwnershipInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: ACCEPT_OWNERSHIP_DISCRIMINATOR }) - ); -} - -export function getAcceptOwnershipInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getAcceptOwnershipInstructionDataCodec(): Codec< - AcceptOwnershipInstructionDataArgs, - AcceptOwnershipInstructionData -> { - return combineCodec( - getAcceptOwnershipInstructionDataEncoder(), - getAcceptOwnershipInstructionDataDecoder() - ); -} - -export type AcceptOwnershipAsyncInput< - TAccountPendingOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pendingOwner: TransactionSigner; - messageTransmitter: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getAcceptOwnershipInstructionAsync< - TAccountPendingOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: AcceptOwnershipAsyncInput< - TAccountPendingOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - AcceptOwnershipInstruction< - TProgramAddress, - TAccountPendingOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pendingOwner: { value: input.pendingOwner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pendingOwner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getAcceptOwnershipInstructionDataEncoder().encode({}), - } as AcceptOwnershipInstruction< - TProgramAddress, - TAccountPendingOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type AcceptOwnershipInput< - TAccountPendingOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pendingOwner: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; -}; - -export function getAcceptOwnershipInstruction< - TAccountPendingOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: AcceptOwnershipInput< - TAccountPendingOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): AcceptOwnershipInstruction< - TProgramAddress, - TAccountPendingOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pendingOwner: { value: input.pendingOwner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pendingOwner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getAcceptOwnershipInstructionDataEncoder().encode({}), - } as AcceptOwnershipInstruction< - TProgramAddress, - TAccountPendingOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedAcceptOwnershipInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - pendingOwner: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: AcceptOwnershipInstructionData; -}; - -export function parseAcceptOwnershipInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedAcceptOwnershipInstruction { - if (instruction.accounts.length < 4) { - // 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: { - pendingOwner: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getAcceptOwnershipInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/disableAttester.ts b/src/svm/clients/MessageTransmitterV2/instructions/disableAttester.ts deleted file mode 100644 index 07eb78250..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/disableAttester.ts +++ /dev/null @@ -1,393 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const DISABLE_ATTESTER_DISCRIMINATOR = new Uint8Array([ - 61, 171, 131, 95, 172, 15, 227, 229, -]); - -export function getDisableAttesterDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - DISABLE_ATTESTER_DISCRIMINATOR - ); -} - -export type DisableAttesterInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountAttesterManager extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountAttesterManager extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAttesterManager, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type DisableAttesterInstructionData = { - discriminator: ReadonlyUint8Array; - attester: Address; -}; - -export type DisableAttesterInstructionDataArgs = { attester: Address }; - -export function getDisableAttesterInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['attester', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: DISABLE_ATTESTER_DISCRIMINATOR }) - ); -} - -export function getDisableAttesterInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['attester', getAddressDecoder()], - ]); -} - -export function getDisableAttesterInstructionDataCodec(): Codec< - DisableAttesterInstructionDataArgs, - DisableAttesterInstructionData -> { - return combineCodec( - getDisableAttesterInstructionDataEncoder(), - getDisableAttesterInstructionDataDecoder() - ); -} - -export type DisableAttesterAsyncInput< - TAccountPayer extends string = string, - TAccountAttesterManager extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - attesterManager: TransactionSigner; - messageTransmitter: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - attester: DisableAttesterInstructionDataArgs['attester']; -}; - -export async function getDisableAttesterInstructionAsync< - TAccountPayer extends string, - TAccountAttesterManager extends string, - TAccountMessageTransmitter extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: DisableAttesterAsyncInput< - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - DisableAttesterInstruction< - TProgramAddress, - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - attesterManager: { - value: input.attesterManager ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.attesterManager), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDisableAttesterInstructionDataEncoder().encode( - args as DisableAttesterInstructionDataArgs - ), - } as DisableAttesterInstruction< - TProgramAddress, - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type DisableAttesterInput< - TAccountPayer extends string = string, - TAccountAttesterManager extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - attesterManager: TransactionSigner; - messageTransmitter: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - attester: DisableAttesterInstructionDataArgs['attester']; -}; - -export function getDisableAttesterInstruction< - TAccountPayer extends string, - TAccountAttesterManager extends string, - TAccountMessageTransmitter extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: DisableAttesterInput< - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): DisableAttesterInstruction< - TProgramAddress, - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - attesterManager: { - value: input.attesterManager ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.attesterManager), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDisableAttesterInstructionDataEncoder().encode( - args as DisableAttesterInstructionDataArgs - ), - } as DisableAttesterInstruction< - TProgramAddress, - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedDisableAttesterInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - attesterManager: TAccountMetas[1]; - messageTransmitter: TAccountMetas[2]; - systemProgram: TAccountMetas[3]; - eventAuthority: TAccountMetas[4]; - program: TAccountMetas[5]; - }; - data: DisableAttesterInstructionData; -}; - -export function parseDisableAttesterInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedDisableAttesterInstruction { - if (instruction.accounts.length < 6) { - // 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: { - payer: getNextAccount(), - attesterManager: getNextAccount(), - messageTransmitter: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getDisableAttesterInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/enableAttester.ts b/src/svm/clients/MessageTransmitterV2/instructions/enableAttester.ts deleted file mode 100644 index 9f8ee2d60..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/enableAttester.ts +++ /dev/null @@ -1,393 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const ENABLE_ATTESTER_DISCRIMINATOR = new Uint8Array([ - 2, 11, 193, 115, 5, 148, 4, 198, -]); - -export function getEnableAttesterDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - ENABLE_ATTESTER_DISCRIMINATOR - ); -} - -export type EnableAttesterInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountAttesterManager extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountAttesterManager extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAttesterManager, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type EnableAttesterInstructionData = { - discriminator: ReadonlyUint8Array; - newAttester: Address; -}; - -export type EnableAttesterInstructionDataArgs = { newAttester: Address }; - -export function getEnableAttesterInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newAttester', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: ENABLE_ATTESTER_DISCRIMINATOR }) - ); -} - -export function getEnableAttesterInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newAttester', getAddressDecoder()], - ]); -} - -export function getEnableAttesterInstructionDataCodec(): Codec< - EnableAttesterInstructionDataArgs, - EnableAttesterInstructionData -> { - return combineCodec( - getEnableAttesterInstructionDataEncoder(), - getEnableAttesterInstructionDataDecoder() - ); -} - -export type EnableAttesterAsyncInput< - TAccountPayer extends string = string, - TAccountAttesterManager extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - attesterManager: TransactionSigner; - messageTransmitter: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - newAttester: EnableAttesterInstructionDataArgs['newAttester']; -}; - -export async function getEnableAttesterInstructionAsync< - TAccountPayer extends string, - TAccountAttesterManager extends string, - TAccountMessageTransmitter extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: EnableAttesterAsyncInput< - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - EnableAttesterInstruction< - TProgramAddress, - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - attesterManager: { - value: input.attesterManager ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.attesterManager), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getEnableAttesterInstructionDataEncoder().encode( - args as EnableAttesterInstructionDataArgs - ), - } as EnableAttesterInstruction< - TProgramAddress, - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type EnableAttesterInput< - TAccountPayer extends string = string, - TAccountAttesterManager extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - attesterManager: TransactionSigner; - messageTransmitter: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - newAttester: EnableAttesterInstructionDataArgs['newAttester']; -}; - -export function getEnableAttesterInstruction< - TAccountPayer extends string, - TAccountAttesterManager extends string, - TAccountMessageTransmitter extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: EnableAttesterInput< - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): EnableAttesterInstruction< - TProgramAddress, - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - attesterManager: { - value: input.attesterManager ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.attesterManager), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getEnableAttesterInstructionDataEncoder().encode( - args as EnableAttesterInstructionDataArgs - ), - } as EnableAttesterInstruction< - TProgramAddress, - TAccountPayer, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedEnableAttesterInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - attesterManager: TAccountMetas[1]; - messageTransmitter: TAccountMetas[2]; - systemProgram: TAccountMetas[3]; - eventAuthority: TAccountMetas[4]; - program: TAccountMetas[5]; - }; - data: EnableAttesterInstructionData; -}; - -export function parseEnableAttesterInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedEnableAttesterInstruction { - if (instruction.accounts.length < 6) { - // 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: { - payer: getNextAccount(), - attesterManager: getNextAccount(), - messageTransmitter: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getEnableAttesterInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/index.ts b/src/svm/clients/MessageTransmitterV2/instructions/index.ts deleted file mode 100644 index 9aa64f714..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/index.ts +++ /dev/null @@ -1,23 +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 - */ - -export * from './acceptOwnership'; -export * from './disableAttester'; -export * from './enableAttester'; -export * from './initialize'; -export * from './isNonceUsed'; -export * from './pause'; -export * from './receiveMessage'; -export * from './reclaimEventAccount'; -export * from './sendMessage'; -export * from './setMaxMessageBodySize'; -export * from './setSignatureThreshold'; -export * from './transferOwnership'; -export * from './unpause'; -export * from './updateAttesterManager'; -export * from './updatePauser'; diff --git a/src/svm/clients/MessageTransmitterV2/instructions/initialize.ts b/src/svm/clients/MessageTransmitterV2/instructions/initialize.ts deleted file mode 100644 index 95ab689b1..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/initialize.ts +++ /dev/null @@ -1,494 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const INITIALIZE_DISCRIMINATOR = new Uint8Array([ - 175, 175, 109, 31, 13, 152, 155, 237, -]); - -export function getInitializeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_DISCRIMINATOR); -} - -export type InitializeInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountUpgradeAuthority extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountMessageTransmitterProgramData extends string | AccountMeta = - string, - TAccountMessageTransmitterProgram extends string | AccountMeta = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountUpgradeAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountUpgradeAuthority, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountMessageTransmitterProgramData extends string - ? ReadonlyAccount - : TAccountMessageTransmitterProgramData, - TAccountMessageTransmitterProgram extends string - ? ReadonlyAccount - : TAccountMessageTransmitterProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type InitializeInstructionData = { - discriminator: ReadonlyUint8Array; - localDomain: number; - attester: Address; - maxMessageBodySize: bigint; - version: number; -}; - -export type InitializeInstructionDataArgs = { - localDomain: number; - attester: Address; - maxMessageBodySize: number | bigint; - version: number; -}; - -export function getInitializeInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['localDomain', getU32Encoder()], - ['attester', getAddressEncoder()], - ['maxMessageBodySize', getU64Encoder()], - ['version', getU32Encoder()], - ]), - (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) - ); -} - -export function getInitializeInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['localDomain', getU32Decoder()], - ['attester', getAddressDecoder()], - ['maxMessageBodySize', getU64Decoder()], - ['version', getU32Decoder()], - ]); -} - -export function getInitializeInstructionDataCodec(): Codec< - InitializeInstructionDataArgs, - InitializeInstructionData -> { - return combineCodec( - getInitializeInstructionDataEncoder(), - getInitializeInstructionDataDecoder() - ); -} - -export type InitializeAsyncInput< - TAccountPayer extends string = string, - TAccountUpgradeAuthority extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountMessageTransmitterProgramData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - upgradeAuthority: TransactionSigner; - messageTransmitter?: Address; - messageTransmitterProgramData: Address; - messageTransmitterProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - localDomain: InitializeInstructionDataArgs['localDomain']; - attester: InitializeInstructionDataArgs['attester']; - maxMessageBodySize: InitializeInstructionDataArgs['maxMessageBodySize']; - version: InitializeInstructionDataArgs['version']; -}; - -export async function getInitializeInstructionAsync< - TAccountPayer extends string, - TAccountUpgradeAuthority extends string, - TAccountMessageTransmitter extends string, - TAccountMessageTransmitterProgramData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: InitializeAsyncInput< - TAccountPayer, - TAccountUpgradeAuthority, - TAccountMessageTransmitter, - TAccountMessageTransmitterProgramData, - TAccountMessageTransmitterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - InitializeInstruction< - TProgramAddress, - TAccountPayer, - TAccountUpgradeAuthority, - TAccountMessageTransmitter, - TAccountMessageTransmitterProgramData, - TAccountMessageTransmitterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - upgradeAuthority: { - value: input.upgradeAuthority ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - messageTransmitterProgramData: { - value: input.messageTransmitterProgramData ?? null, - isWritable: false, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.messageTransmitter.value) { - accounts.messageTransmitter.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 109, 101, 115, 115, 97, 103, 101, 95, 116, 114, 97, 110, 115, 109, - 105, 116, 116, 101, 114, - ]) - ), - ], - }); - } - if (!accounts.messageTransmitterProgram.value) { - accounts.messageTransmitterProgram.value = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.upgradeAuthority), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.messageTransmitterProgramData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getInitializeInstructionDataEncoder().encode( - args as InitializeInstructionDataArgs - ), - } as InitializeInstruction< - TProgramAddress, - TAccountPayer, - TAccountUpgradeAuthority, - TAccountMessageTransmitter, - TAccountMessageTransmitterProgramData, - TAccountMessageTransmitterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type InitializeInput< - TAccountPayer extends string = string, - TAccountUpgradeAuthority extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountMessageTransmitterProgramData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - upgradeAuthority: TransactionSigner; - messageTransmitter: Address; - messageTransmitterProgramData: Address; - messageTransmitterProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - localDomain: InitializeInstructionDataArgs['localDomain']; - attester: InitializeInstructionDataArgs['attester']; - maxMessageBodySize: InitializeInstructionDataArgs['maxMessageBodySize']; - version: InitializeInstructionDataArgs['version']; -}; - -export function getInitializeInstruction< - TAccountPayer extends string, - TAccountUpgradeAuthority extends string, - TAccountMessageTransmitter extends string, - TAccountMessageTransmitterProgramData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: InitializeInput< - TAccountPayer, - TAccountUpgradeAuthority, - TAccountMessageTransmitter, - TAccountMessageTransmitterProgramData, - TAccountMessageTransmitterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): InitializeInstruction< - TProgramAddress, - TAccountPayer, - TAccountUpgradeAuthority, - TAccountMessageTransmitter, - TAccountMessageTransmitterProgramData, - TAccountMessageTransmitterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - upgradeAuthority: { - value: input.upgradeAuthority ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - messageTransmitterProgramData: { - value: input.messageTransmitterProgramData ?? null, - isWritable: false, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.messageTransmitterProgram.value) { - accounts.messageTransmitterProgram.value = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.upgradeAuthority), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.messageTransmitterProgramData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getInitializeInstructionDataEncoder().encode( - args as InitializeInstructionDataArgs - ), - } as InitializeInstruction< - TProgramAddress, - TAccountPayer, - TAccountUpgradeAuthority, - TAccountMessageTransmitter, - TAccountMessageTransmitterProgramData, - TAccountMessageTransmitterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedInitializeInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - upgradeAuthority: TAccountMetas[1]; - messageTransmitter: TAccountMetas[2]; - messageTransmitterProgramData: TAccountMetas[3]; - messageTransmitterProgram: TAccountMetas[4]; - systemProgram: TAccountMetas[5]; - eventAuthority: TAccountMetas[6]; - program: TAccountMetas[7]; - }; - data: InitializeInstructionData; -}; - -export function parseInitializeInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedInitializeInstruction { - if (instruction.accounts.length < 8) { - // 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: { - payer: getNextAccount(), - upgradeAuthority: getNextAccount(), - messageTransmitter: getNextAccount(), - messageTransmitterProgramData: getNextAccount(), - messageTransmitterProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getInitializeInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/isNonceUsed.ts b/src/svm/clients/MessageTransmitterV2/instructions/isNonceUsed.ts deleted file mode 100644 index 3d4f6ac42..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/isNonceUsed.ts +++ /dev/null @@ -1,157 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const IS_NONCE_USED_DISCRIMINATOR = new Uint8Array([ - 144, 72, 107, 148, 35, 218, 31, 187, -]); - -export function getIsNonceUsedDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - IS_NONCE_USED_DISCRIMINATOR - ); -} - -export type IsNonceUsedInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountUsedNonce extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountUsedNonce extends string - ? ReadonlyAccount - : TAccountUsedNonce, - ...TRemainingAccounts, - ] - >; - -export type IsNonceUsedInstructionData = { discriminator: ReadonlyUint8Array }; - -export type IsNonceUsedInstructionDataArgs = {}; - -export function getIsNonceUsedInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: IS_NONCE_USED_DISCRIMINATOR }) - ); -} - -export function getIsNonceUsedInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getIsNonceUsedInstructionDataCodec(): Codec< - IsNonceUsedInstructionDataArgs, - IsNonceUsedInstructionData -> { - return combineCodec( - getIsNonceUsedInstructionDataEncoder(), - getIsNonceUsedInstructionDataDecoder() - ); -} - -export type IsNonceUsedInput = { - /** Account will be explicitly loaded to avoid error when it's not initialized */ - usedNonce: Address; -}; - -export function getIsNonceUsedInstruction< - TAccountUsedNonce extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: IsNonceUsedInput, - config?: { programAddress?: TProgramAddress } -): IsNonceUsedInstruction { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - usedNonce: { value: input.usedNonce ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [getAccountMeta(accounts.usedNonce)], - programAddress, - data: getIsNonceUsedInstructionDataEncoder().encode({}), - } as IsNonceUsedInstruction; - - return instruction; -} - -export type ParsedIsNonceUsedInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - /** Account will be explicitly loaded to avoid error when it's not initialized */ - usedNonce: TAccountMetas[0]; - }; - data: IsNonceUsedInstructionData; -}; - -export function parseIsNonceUsedInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedIsNonceUsedInstruction { - if (instruction.accounts.length < 1) { - // 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: { - usedNonce: getNextAccount(), - }, - data: getIsNonceUsedInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/pause.ts b/src/svm/clients/MessageTransmitterV2/instructions/pause.ts deleted file mode 100644 index 2a43d3d20..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/pause.ts +++ /dev/null @@ -1,307 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const PAUSE_DISCRIMINATOR = new Uint8Array([ - 211, 22, 221, 251, 74, 121, 193, 47, -]); - -export function getPauseDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(PAUSE_DISCRIMINATOR); -} - -export type PauseInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountPauser extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPauser extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountPauser, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type PauseInstructionData = { discriminator: ReadonlyUint8Array }; - -export type PauseInstructionDataArgs = {}; - -export function getPauseInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: PAUSE_DISCRIMINATOR }) - ); -} - -export function getPauseInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getPauseInstructionDataCodec(): Codec< - PauseInstructionDataArgs, - PauseInstructionData -> { - return combineCodec( - getPauseInstructionDataEncoder(), - getPauseInstructionDataDecoder() - ); -} - -export type PauseAsyncInput< - TAccountPauser extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pauser: TransactionSigner; - messageTransmitter: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getPauseInstructionAsync< - TAccountPauser extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: PauseAsyncInput< - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - PauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pauser: { value: input.pauser ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pauser), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getPauseInstructionDataEncoder().encode({}), - } as PauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type PauseInput< - TAccountPauser extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pauser: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; -}; - -export function getPauseInstruction< - TAccountPauser extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: PauseInput< - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): PauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pauser: { value: input.pauser ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pauser), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getPauseInstructionDataEncoder().encode({}), - } as PauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedPauseInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - pauser: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: PauseInstructionData; -}; - -export function parsePauseInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedPauseInstruction { - if (instruction.accounts.length < 4) { - // 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: { - pauser: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getPauseInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/receiveMessage.ts b/src/svm/clients/MessageTransmitterV2/instructions/receiveMessage.ts deleted file mode 100644 index b471b4cf0..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/receiveMessage.ts +++ /dev/null @@ -1,486 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const RECEIVE_MESSAGE_DISCRIMINATOR = new Uint8Array([ - 38, 144, 127, 225, 31, 225, 238, 25, -]); - -export function getReceiveMessageDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - RECEIVE_MESSAGE_DISCRIMINATOR - ); -} - -export type ReceiveMessageInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountCaller extends string | AccountMeta = string, - TAccountAuthorityPda extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountUsedNonce extends string | AccountMeta = string, - TAccountReceiver extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountCaller extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountCaller, - TAccountAuthorityPda extends string - ? ReadonlyAccount - : TAccountAuthorityPda, - TAccountMessageTransmitter extends string - ? ReadonlyAccount - : TAccountMessageTransmitter, - TAccountUsedNonce extends string - ? WritableAccount - : TAccountUsedNonce, - TAccountReceiver extends string - ? ReadonlyAccount - : TAccountReceiver, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type ReceiveMessageInstructionData = { - discriminator: ReadonlyUint8Array; - message: ReadonlyUint8Array; - attestation: ReadonlyUint8Array; -}; - -export type ReceiveMessageInstructionDataArgs = { - message: ReadonlyUint8Array; - attestation: ReadonlyUint8Array; -}; - -export function getReceiveMessageInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ['attestation', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ ...value, discriminator: RECEIVE_MESSAGE_DISCRIMINATOR }) - ); -} - -export function getReceiveMessageInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ['attestation', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getReceiveMessageInstructionDataCodec(): Codec< - ReceiveMessageInstructionDataArgs, - ReceiveMessageInstructionData -> { - return combineCodec( - getReceiveMessageInstructionDataEncoder(), - getReceiveMessageInstructionDataDecoder() - ); -} - -export type ReceiveMessageAsyncInput< - TAccountPayer extends string = string, - TAccountCaller extends string = string, - TAccountAuthorityPda extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountUsedNonce extends string = string, - TAccountReceiver extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - caller: TransactionSigner; - authorityPda?: Address; - messageTransmitter: Address; - /** Each nonce is stored in a separate PDA */ - usedNonce: Address; - receiver: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - message: ReceiveMessageInstructionDataArgs['message']; - attestation: ReceiveMessageInstructionDataArgs['attestation']; -}; - -export async function getReceiveMessageInstructionAsync< - TAccountPayer extends string, - TAccountCaller extends string, - TAccountAuthorityPda extends string, - TAccountMessageTransmitter extends string, - TAccountUsedNonce extends string, - TAccountReceiver extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: ReceiveMessageAsyncInput< - TAccountPayer, - TAccountCaller, - TAccountAuthorityPda, - TAccountMessageTransmitter, - TAccountUsedNonce, - TAccountReceiver, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - ReceiveMessageInstruction< - TProgramAddress, - TAccountPayer, - TAccountCaller, - TAccountAuthorityPda, - TAccountMessageTransmitter, - TAccountUsedNonce, - TAccountReceiver, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - caller: { value: input.caller ?? null, isWritable: false }, - authorityPda: { value: input.authorityPda ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: false, - }, - usedNonce: { value: input.usedNonce ?? null, isWritable: true }, - receiver: { value: input.receiver ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.authorityPda.value) { - accounts.authorityPda.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 109, 101, 115, 115, 97, 103, 101, 95, 116, 114, 97, 110, 115, 109, - 105, 116, 116, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, 116, - 121, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.receiver.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.caller), - getAccountMeta(accounts.authorityPda), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.usedNonce), - getAccountMeta(accounts.receiver), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getReceiveMessageInstructionDataEncoder().encode( - args as ReceiveMessageInstructionDataArgs - ), - } as ReceiveMessageInstruction< - TProgramAddress, - TAccountPayer, - TAccountCaller, - TAccountAuthorityPda, - TAccountMessageTransmitter, - TAccountUsedNonce, - TAccountReceiver, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ReceiveMessageInput< - TAccountPayer extends string = string, - TAccountCaller extends string = string, - TAccountAuthorityPda extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountUsedNonce extends string = string, - TAccountReceiver extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - caller: TransactionSigner; - authorityPda: Address; - messageTransmitter: Address; - /** Each nonce is stored in a separate PDA */ - usedNonce: Address; - receiver: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - message: ReceiveMessageInstructionDataArgs['message']; - attestation: ReceiveMessageInstructionDataArgs['attestation']; -}; - -export function getReceiveMessageInstruction< - TAccountPayer extends string, - TAccountCaller extends string, - TAccountAuthorityPda extends string, - TAccountMessageTransmitter extends string, - TAccountUsedNonce extends string, - TAccountReceiver extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: ReceiveMessageInput< - TAccountPayer, - TAccountCaller, - TAccountAuthorityPda, - TAccountMessageTransmitter, - TAccountUsedNonce, - TAccountReceiver, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): ReceiveMessageInstruction< - TProgramAddress, - TAccountPayer, - TAccountCaller, - TAccountAuthorityPda, - TAccountMessageTransmitter, - TAccountUsedNonce, - TAccountReceiver, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - caller: { value: input.caller ?? null, isWritable: false }, - authorityPda: { value: input.authorityPda ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: false, - }, - usedNonce: { value: input.usedNonce ?? null, isWritable: true }, - receiver: { value: input.receiver ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.caller), - getAccountMeta(accounts.authorityPda), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.usedNonce), - getAccountMeta(accounts.receiver), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getReceiveMessageInstructionDataEncoder().encode( - args as ReceiveMessageInstructionDataArgs - ), - } as ReceiveMessageInstruction< - TProgramAddress, - TAccountPayer, - TAccountCaller, - TAccountAuthorityPda, - TAccountMessageTransmitter, - TAccountUsedNonce, - TAccountReceiver, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedReceiveMessageInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - caller: TAccountMetas[1]; - authorityPda: TAccountMetas[2]; - messageTransmitter: TAccountMetas[3]; - /** Each nonce is stored in a separate PDA */ - usedNonce: TAccountMetas[4]; - receiver: TAccountMetas[5]; - systemProgram: TAccountMetas[6]; - eventAuthority: TAccountMetas[7]; - program: TAccountMetas[8]; - }; - data: ReceiveMessageInstructionData; -}; - -export function parseReceiveMessageInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedReceiveMessageInstruction { - if (instruction.accounts.length < 9) { - // 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: { - payer: getNextAccount(), - caller: getNextAccount(), - authorityPda: getNextAccount(), - messageTransmitter: getNextAccount(), - usedNonce: getNextAccount(), - receiver: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getReceiveMessageInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/reclaimEventAccount.ts b/src/svm/clients/MessageTransmitterV2/instructions/reclaimEventAccount.ts deleted file mode 100644 index 72ecffb6b..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/reclaimEventAccount.ts +++ /dev/null @@ -1,242 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR = new Uint8Array([ - 94, 198, 180, 159, 131, 236, 15, 174, -]); - -export function getReclaimEventAccountDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR - ); -} - -export type ReclaimEventAccountInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountPayee extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayee extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayee, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountMessageSentEventData extends string - ? WritableAccount - : TAccountMessageSentEventData, - ...TRemainingAccounts, - ] - >; - -export type ReclaimEventAccountInstructionData = { - discriminator: ReadonlyUint8Array; - attestation: ReadonlyUint8Array; - destinationMessage: ReadonlyUint8Array; -}; - -export type ReclaimEventAccountInstructionDataArgs = { - attestation: ReadonlyUint8Array; - destinationMessage: ReadonlyUint8Array; -}; - -export function getReclaimEventAccountInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['attestation', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - [ - 'destinationMessage', - addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), - ], - ]), - (value) => ({ - ...value, - discriminator: RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR, - }) - ); -} - -export function getReclaimEventAccountInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['attestation', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - [ - 'destinationMessage', - addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()), - ], - ]); -} - -export function getReclaimEventAccountInstructionDataCodec(): Codec< - ReclaimEventAccountInstructionDataArgs, - ReclaimEventAccountInstructionData -> { - return combineCodec( - getReclaimEventAccountInstructionDataEncoder(), - getReclaimEventAccountInstructionDataDecoder() - ); -} - -export type ReclaimEventAccountInput< - TAccountPayee extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountMessageSentEventData extends string = string, -> = { - /** rent SOL receiver, should match original rent payer */ - payee: TransactionSigner; - messageTransmitter: Address; - messageSentEventData: Address; - attestation: ReclaimEventAccountInstructionDataArgs['attestation']; - destinationMessage: ReclaimEventAccountInstructionDataArgs['destinationMessage']; -}; - -export function getReclaimEventAccountInstruction< - TAccountPayee extends string, - TAccountMessageTransmitter extends string, - TAccountMessageSentEventData extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: ReclaimEventAccountInput< - TAccountPayee, - TAccountMessageTransmitter, - TAccountMessageSentEventData - >, - config?: { programAddress?: TProgramAddress } -): ReclaimEventAccountInstruction< - TProgramAddress, - TAccountPayee, - TAccountMessageTransmitter, - TAccountMessageSentEventData -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.messageSentEventData), - ], - programAddress, - data: getReclaimEventAccountInstructionDataEncoder().encode( - args as ReclaimEventAccountInstructionDataArgs - ), - } as ReclaimEventAccountInstruction< - TProgramAddress, - TAccountPayee, - TAccountMessageTransmitter, - TAccountMessageSentEventData - >; - - return instruction; -} - -export type ParsedReclaimEventAccountInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - /** rent SOL receiver, should match original rent payer */ - payee: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - messageSentEventData: TAccountMetas[2]; - }; - data: ReclaimEventAccountInstructionData; -}; - -export function parseReclaimEventAccountInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedReclaimEventAccountInstruction { - 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: { - payee: getNextAccount(), - messageTransmitter: getNextAccount(), - messageSentEventData: getNextAccount(), - }, - data: getReclaimEventAccountInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/sendMessage.ts b/src/svm/clients/MessageTransmitterV2/instructions/sendMessage.ts deleted file mode 100644 index c33eb00f1..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/sendMessage.ts +++ /dev/null @@ -1,302 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SEND_MESSAGE_DISCRIMINATOR = new Uint8Array([ - 57, 40, 34, 178, 189, 10, 65, 26, -]); - -export function getSendMessageDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SEND_MESSAGE_DISCRIMINATOR - ); -} - -export type SendMessageInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountEventRentPayer extends string | AccountMeta = string, - TAccountSenderAuthorityPda extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TAccountSenderProgram extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountEventRentPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountEventRentPayer, - TAccountSenderAuthorityPda extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSenderAuthorityPda, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountMessageSentEventData extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountMessageSentEventData, - TAccountSenderProgram extends string - ? ReadonlyAccount - : TAccountSenderProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type SendMessageInstructionData = { - discriminator: ReadonlyUint8Array; - destinationDomain: number; - recipient: Address; - destinationCaller: Address; - minFinalityThreshold: number; - messageBody: ReadonlyUint8Array; -}; - -export type SendMessageInstructionDataArgs = { - destinationDomain: number; - recipient: Address; - destinationCaller: Address; - minFinalityThreshold: number; - messageBody: ReadonlyUint8Array; -}; - -export function getSendMessageInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['destinationDomain', getU32Encoder()], - ['recipient', getAddressEncoder()], - ['destinationCaller', getAddressEncoder()], - ['minFinalityThreshold', getU32Encoder()], - ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ ...value, discriminator: SEND_MESSAGE_DISCRIMINATOR }) - ); -} - -export function getSendMessageInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['destinationDomain', getU32Decoder()], - ['recipient', getAddressDecoder()], - ['destinationCaller', getAddressDecoder()], - ['minFinalityThreshold', getU32Decoder()], - ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getSendMessageInstructionDataCodec(): Codec< - SendMessageInstructionDataArgs, - SendMessageInstructionData -> { - return combineCodec( - getSendMessageInstructionDataEncoder(), - getSendMessageInstructionDataDecoder() - ); -} - -export type SendMessageInput< - TAccountEventRentPayer extends string = string, - TAccountSenderAuthorityPda extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountSenderProgram extends string = string, - TAccountSystemProgram extends string = string, -> = { - eventRentPayer: TransactionSigner; - senderAuthorityPda: TransactionSigner; - messageTransmitter: Address; - messageSentEventData: TransactionSigner; - senderProgram: Address; - systemProgram?: Address; - destinationDomain: SendMessageInstructionDataArgs['destinationDomain']; - recipient: SendMessageInstructionDataArgs['recipient']; - destinationCaller: SendMessageInstructionDataArgs['destinationCaller']; - minFinalityThreshold: SendMessageInstructionDataArgs['minFinalityThreshold']; - messageBody: SendMessageInstructionDataArgs['messageBody']; -}; - -export function getSendMessageInstruction< - TAccountEventRentPayer extends string, - TAccountSenderAuthorityPda extends string, - TAccountMessageTransmitter extends string, - TAccountMessageSentEventData extends string, - TAccountSenderProgram extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: SendMessageInput< - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountSenderProgram, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): SendMessageInstruction< - TProgramAddress, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountSenderProgram, - TAccountSystemProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, - senderAuthorityPda: { - value: input.senderAuthorityPda ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - senderProgram: { value: input.senderProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.eventRentPayer), - getAccountMeta(accounts.senderAuthorityPda), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.senderProgram), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getSendMessageInstructionDataEncoder().encode( - args as SendMessageInstructionDataArgs - ), - } as SendMessageInstruction< - TProgramAddress, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountSenderProgram, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedSendMessageInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - eventRentPayer: TAccountMetas[0]; - senderAuthorityPda: TAccountMetas[1]; - messageTransmitter: TAccountMetas[2]; - messageSentEventData: TAccountMetas[3]; - senderProgram: TAccountMetas[4]; - systemProgram: TAccountMetas[5]; - }; - data: SendMessageInstructionData; -}; - -export function parseSendMessageInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSendMessageInstruction { - if (instruction.accounts.length < 6) { - // 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: { - eventRentPayer: getNextAccount(), - senderAuthorityPda: getNextAccount(), - messageTransmitter: getNextAccount(), - messageSentEventData: getNextAccount(), - senderProgram: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getSendMessageInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/setMaxMessageBodySize.ts b/src/svm/clients/MessageTransmitterV2/instructions/setMaxMessageBodySize.ts deleted file mode 100644 index f65656b00..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/setMaxMessageBodySize.ts +++ /dev/null @@ -1,337 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_MAX_MESSAGE_BODY_SIZE_DISCRIMINATOR = new Uint8Array([ - 168, 178, 8, 117, 217, 167, 219, 31, -]); - -export function getSetMaxMessageBodySizeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_MAX_MESSAGE_BODY_SIZE_DISCRIMINATOR - ); -} - -export type SetMaxMessageBodySizeInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type SetMaxMessageBodySizeInstructionData = { - discriminator: ReadonlyUint8Array; - newMaxMessageBodySize: bigint; -}; - -export type SetMaxMessageBodySizeInstructionDataArgs = { - newMaxMessageBodySize: number | bigint; -}; - -export function getSetMaxMessageBodySizeInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newMaxMessageBodySize', getU64Encoder()], - ]), - (value) => ({ - ...value, - discriminator: SET_MAX_MESSAGE_BODY_SIZE_DISCRIMINATOR, - }) - ); -} - -export function getSetMaxMessageBodySizeInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newMaxMessageBodySize', getU64Decoder()], - ]); -} - -export function getSetMaxMessageBodySizeInstructionDataCodec(): Codec< - SetMaxMessageBodySizeInstructionDataArgs, - SetMaxMessageBodySizeInstructionData -> { - return combineCodec( - getSetMaxMessageBodySizeInstructionDataEncoder(), - getSetMaxMessageBodySizeInstructionDataDecoder() - ); -} - -export type SetMaxMessageBodySizeAsyncInput< - TAccountOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - messageTransmitter: Address; - eventAuthority?: Address; - program: Address; - newMaxMessageBodySize: SetMaxMessageBodySizeInstructionDataArgs['newMaxMessageBodySize']; -}; - -export async function getSetMaxMessageBodySizeInstructionAsync< - TAccountOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: SetMaxMessageBodySizeAsyncInput< - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - SetMaxMessageBodySizeInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetMaxMessageBodySizeInstructionDataEncoder().encode( - args as SetMaxMessageBodySizeInstructionDataArgs - ), - } as SetMaxMessageBodySizeInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type SetMaxMessageBodySizeInput< - TAccountOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; - newMaxMessageBodySize: SetMaxMessageBodySizeInstructionDataArgs['newMaxMessageBodySize']; -}; - -export function getSetMaxMessageBodySizeInstruction< - TAccountOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: SetMaxMessageBodySizeInput< - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): SetMaxMessageBodySizeInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetMaxMessageBodySizeInstructionDataEncoder().encode( - args as SetMaxMessageBodySizeInstructionDataArgs - ), - } as SetMaxMessageBodySizeInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedSetMaxMessageBodySizeInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: SetMaxMessageBodySizeInstructionData; -}; - -export function parseSetMaxMessageBodySizeInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetMaxMessageBodySizeInstruction { - if (instruction.accounts.length < 4) { - // 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: { - owner: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getSetMaxMessageBodySizeInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/setSignatureThreshold.ts b/src/svm/clients/MessageTransmitterV2/instructions/setSignatureThreshold.ts deleted file mode 100644 index 3bee2ee85..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/setSignatureThreshold.ts +++ /dev/null @@ -1,343 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_SIGNATURE_THRESHOLD_DISCRIMINATOR = new Uint8Array([ - 163, 19, 154, 168, 82, 209, 214, 219, -]); - -export function getSetSignatureThresholdDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_SIGNATURE_THRESHOLD_DISCRIMINATOR - ); -} - -export type SetSignatureThresholdInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountAttesterManager extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountAttesterManager extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAttesterManager, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type SetSignatureThresholdInstructionData = { - discriminator: ReadonlyUint8Array; - newSignatureThreshold: number; -}; - -export type SetSignatureThresholdInstructionDataArgs = { - newSignatureThreshold: number; -}; - -export function getSetSignatureThresholdInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newSignatureThreshold', getU32Encoder()], - ]), - (value) => ({ - ...value, - discriminator: SET_SIGNATURE_THRESHOLD_DISCRIMINATOR, - }) - ); -} - -export function getSetSignatureThresholdInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newSignatureThreshold', getU32Decoder()], - ]); -} - -export function getSetSignatureThresholdInstructionDataCodec(): Codec< - SetSignatureThresholdInstructionDataArgs, - SetSignatureThresholdInstructionData -> { - return combineCodec( - getSetSignatureThresholdInstructionDataEncoder(), - getSetSignatureThresholdInstructionDataDecoder() - ); -} - -export type SetSignatureThresholdAsyncInput< - TAccountAttesterManager extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - attesterManager: TransactionSigner; - messageTransmitter: Address; - eventAuthority?: Address; - program: Address; - newSignatureThreshold: SetSignatureThresholdInstructionDataArgs['newSignatureThreshold']; -}; - -export async function getSetSignatureThresholdInstructionAsync< - TAccountAttesterManager extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: SetSignatureThresholdAsyncInput< - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - SetSignatureThresholdInstruction< - TProgramAddress, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - attesterManager: { - value: input.attesterManager ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.attesterManager), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetSignatureThresholdInstructionDataEncoder().encode( - args as SetSignatureThresholdInstructionDataArgs - ), - } as SetSignatureThresholdInstruction< - TProgramAddress, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type SetSignatureThresholdInput< - TAccountAttesterManager extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - attesterManager: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; - newSignatureThreshold: SetSignatureThresholdInstructionDataArgs['newSignatureThreshold']; -}; - -export function getSetSignatureThresholdInstruction< - TAccountAttesterManager extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: SetSignatureThresholdInput< - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): SetSignatureThresholdInstruction< - TProgramAddress, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - attesterManager: { - value: input.attesterManager ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.attesterManager), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetSignatureThresholdInstructionDataEncoder().encode( - args as SetSignatureThresholdInstructionDataArgs - ), - } as SetSignatureThresholdInstruction< - TProgramAddress, - TAccountAttesterManager, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedSetSignatureThresholdInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - attesterManager: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: SetSignatureThresholdInstructionData; -}; - -export function parseSetSignatureThresholdInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetSignatureThresholdInstruction { - if (instruction.accounts.length < 4) { - // 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: { - attesterManager: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getSetSignatureThresholdInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/transferOwnership.ts b/src/svm/clients/MessageTransmitterV2/instructions/transferOwnership.ts deleted file mode 100644 index 7fd509aa4..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/transferOwnership.ts +++ /dev/null @@ -1,330 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const TRANSFER_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ - 65, 177, 215, 73, 53, 45, 99, 47, -]); - -export function getTransferOwnershipDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - TRANSFER_OWNERSHIP_DISCRIMINATOR - ); -} - -export type TransferOwnershipInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type TransferOwnershipInstructionData = { - discriminator: ReadonlyUint8Array; - newOwner: Address; -}; - -export type TransferOwnershipInstructionDataArgs = { newOwner: Address }; - -export function getTransferOwnershipInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newOwner', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: TRANSFER_OWNERSHIP_DISCRIMINATOR }) - ); -} - -export function getTransferOwnershipInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newOwner', getAddressDecoder()], - ]); -} - -export function getTransferOwnershipInstructionDataCodec(): Codec< - TransferOwnershipInstructionDataArgs, - TransferOwnershipInstructionData -> { - return combineCodec( - getTransferOwnershipInstructionDataEncoder(), - getTransferOwnershipInstructionDataDecoder() - ); -} - -export type TransferOwnershipAsyncInput< - TAccountOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - messageTransmitter: Address; - eventAuthority?: Address; - program: Address; - newOwner: TransferOwnershipInstructionDataArgs['newOwner']; -}; - -export async function getTransferOwnershipInstructionAsync< - TAccountOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: TransferOwnershipAsyncInput< - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - TransferOwnershipInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getTransferOwnershipInstructionDataEncoder().encode( - args as TransferOwnershipInstructionDataArgs - ), - } as TransferOwnershipInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type TransferOwnershipInput< - TAccountOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; - newOwner: TransferOwnershipInstructionDataArgs['newOwner']; -}; - -export function getTransferOwnershipInstruction< - TAccountOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: TransferOwnershipInput< - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): TransferOwnershipInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getTransferOwnershipInstructionDataEncoder().encode( - args as TransferOwnershipInstructionDataArgs - ), - } as TransferOwnershipInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedTransferOwnershipInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: TransferOwnershipInstructionData; -}; - -export function parseTransferOwnershipInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedTransferOwnershipInstruction { - if (instruction.accounts.length < 4) { - // 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: { - owner: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getTransferOwnershipInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/unpause.ts b/src/svm/clients/MessageTransmitterV2/instructions/unpause.ts deleted file mode 100644 index 82e09eb08..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/unpause.ts +++ /dev/null @@ -1,307 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UNPAUSE_DISCRIMINATOR = new Uint8Array([ - 169, 144, 4, 38, 10, 141, 188, 255, -]); - -export function getUnpauseDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(UNPAUSE_DISCRIMINATOR); -} - -export type UnpauseInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountPauser extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPauser extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountPauser, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UnpauseInstructionData = { discriminator: ReadonlyUint8Array }; - -export type UnpauseInstructionDataArgs = {}; - -export function getUnpauseInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: UNPAUSE_DISCRIMINATOR }) - ); -} - -export function getUnpauseInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getUnpauseInstructionDataCodec(): Codec< - UnpauseInstructionDataArgs, - UnpauseInstructionData -> { - return combineCodec( - getUnpauseInstructionDataEncoder(), - getUnpauseInstructionDataDecoder() - ); -} - -export type UnpauseAsyncInput< - TAccountPauser extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pauser: TransactionSigner; - messageTransmitter: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getUnpauseInstructionAsync< - TAccountPauser extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: UnpauseAsyncInput< - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - UnpauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pauser: { value: input.pauser ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pauser), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUnpauseInstructionDataEncoder().encode({}), - } as UnpauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type UnpauseInput< - TAccountPauser extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pauser: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; -}; - -export function getUnpauseInstruction< - TAccountPauser extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: UnpauseInput< - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UnpauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pauser: { value: input.pauser ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pauser), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUnpauseInstructionDataEncoder().encode({}), - } as UnpauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUnpauseInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - pauser: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: UnpauseInstructionData; -}; - -export function parseUnpauseInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUnpauseInstruction { - if (instruction.accounts.length < 4) { - // 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: { - pauser: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUnpauseInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/updateAttesterManager.ts b/src/svm/clients/MessageTransmitterV2/instructions/updateAttesterManager.ts deleted file mode 100644 index 740fe3c72..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/updateAttesterManager.ts +++ /dev/null @@ -1,337 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UPDATE_ATTESTER_MANAGER_DISCRIMINATOR = new Uint8Array([ - 175, 245, 178, 104, 85, 179, 71, 16, -]); - -export function getUpdateAttesterManagerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - UPDATE_ATTESTER_MANAGER_DISCRIMINATOR - ); -} - -export type UpdateAttesterManagerInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UpdateAttesterManagerInstructionData = { - discriminator: ReadonlyUint8Array; - newAttesterManager: Address; -}; - -export type UpdateAttesterManagerInstructionDataArgs = { - newAttesterManager: Address; -}; - -export function getUpdateAttesterManagerInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newAttesterManager', getAddressEncoder()], - ]), - (value) => ({ - ...value, - discriminator: UPDATE_ATTESTER_MANAGER_DISCRIMINATOR, - }) - ); -} - -export function getUpdateAttesterManagerInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newAttesterManager', getAddressDecoder()], - ]); -} - -export function getUpdateAttesterManagerInstructionDataCodec(): Codec< - UpdateAttesterManagerInstructionDataArgs, - UpdateAttesterManagerInstructionData -> { - return combineCodec( - getUpdateAttesterManagerInstructionDataEncoder(), - getUpdateAttesterManagerInstructionDataDecoder() - ); -} - -export type UpdateAttesterManagerAsyncInput< - TAccountOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - messageTransmitter: Address; - eventAuthority?: Address; - program: Address; - newAttesterManager: UpdateAttesterManagerInstructionDataArgs['newAttesterManager']; -}; - -export async function getUpdateAttesterManagerInstructionAsync< - TAccountOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: UpdateAttesterManagerAsyncInput< - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - UpdateAttesterManagerInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUpdateAttesterManagerInstructionDataEncoder().encode( - args as UpdateAttesterManagerInstructionDataArgs - ), - } as UpdateAttesterManagerInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type UpdateAttesterManagerInput< - TAccountOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; - newAttesterManager: UpdateAttesterManagerInstructionDataArgs['newAttesterManager']; -}; - -export function getUpdateAttesterManagerInstruction< - TAccountOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: UpdateAttesterManagerInput< - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UpdateAttesterManagerInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUpdateAttesterManagerInstructionDataEncoder().encode( - args as UpdateAttesterManagerInstructionDataArgs - ), - } as UpdateAttesterManagerInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUpdateAttesterManagerInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: UpdateAttesterManagerInstructionData; -}; - -export function parseUpdateAttesterManagerInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUpdateAttesterManagerInstruction { - if (instruction.accounts.length < 4) { - // 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: { - owner: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUpdateAttesterManagerInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/instructions/updatePauser.ts b/src/svm/clients/MessageTransmitterV2/instructions/updatePauser.ts deleted file mode 100644 index dd37d75e7..000000000 --- a/src/svm/clients/MessageTransmitterV2/instructions/updatePauser.ts +++ /dev/null @@ -1,330 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UPDATE_PAUSER_DISCRIMINATOR = new Uint8Array([ - 140, 171, 211, 132, 57, 201, 16, 254, -]); - -export function getUpdatePauserDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - UPDATE_PAUSER_DISCRIMINATOR - ); -} - -export type UpdatePauserInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UpdatePauserInstructionData = { - discriminator: ReadonlyUint8Array; - newPauser: Address; -}; - -export type UpdatePauserInstructionDataArgs = { newPauser: Address }; - -export function getUpdatePauserInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newPauser', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: UPDATE_PAUSER_DISCRIMINATOR }) - ); -} - -export function getUpdatePauserInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newPauser', getAddressDecoder()], - ]); -} - -export function getUpdatePauserInstructionDataCodec(): Codec< - UpdatePauserInstructionDataArgs, - UpdatePauserInstructionData -> { - return combineCodec( - getUpdatePauserInstructionDataEncoder(), - getUpdatePauserInstructionDataDecoder() - ); -} - -export type UpdatePauserAsyncInput< - TAccountOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - messageTransmitter: Address; - eventAuthority?: Address; - program: Address; - newPauser: UpdatePauserInstructionDataArgs['newPauser']; -}; - -export async function getUpdatePauserInstructionAsync< - TAccountOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: UpdatePauserAsyncInput< - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - UpdatePauserInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUpdatePauserInstructionDataEncoder().encode( - args as UpdatePauserInstructionDataArgs - ), - } as UpdatePauserInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type UpdatePauserInput< - TAccountOwner extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - messageTransmitter: Address; - eventAuthority: Address; - program: Address; - newPauser: UpdatePauserInstructionDataArgs['newPauser']; -}; - -export function getUpdatePauserInstruction< - TAccountOwner extends string, - TAccountMessageTransmitter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, ->( - input: UpdatePauserInput< - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UpdatePauserInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUpdatePauserInstructionDataEncoder().encode( - args as UpdatePauserInstructionDataArgs - ), - } as UpdatePauserInstruction< - TProgramAddress, - TAccountOwner, - TAccountMessageTransmitter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUpdatePauserInstruction< - TProgram extends string = typeof MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: UpdatePauserInstructionData; -}; - -export function parseUpdatePauserInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUpdatePauserInstruction { - if (instruction.accounts.length < 4) { - // 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: { - owner: getNextAccount(), - messageTransmitter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUpdatePauserInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/MessageTransmitterV2/programs/index.ts b/src/svm/clients/MessageTransmitterV2/programs/index.ts deleted file mode 100644 index eecc709dc..000000000 --- a/src/svm/clients/MessageTransmitterV2/programs/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './messageTransmitterV2'; diff --git a/src/svm/clients/MessageTransmitterV2/programs/messageTransmitterV2.ts b/src/svm/clients/MessageTransmitterV2/programs/messageTransmitterV2.ts deleted file mode 100644 index 23ce64aed..000000000 --- a/src/svm/clients/MessageTransmitterV2/programs/messageTransmitterV2.ts +++ /dev/null @@ -1,324 +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/kit'; -import { - type ParsedAcceptOwnershipInstruction, - type ParsedDisableAttesterInstruction, - type ParsedEnableAttesterInstruction, - type ParsedInitializeInstruction, - type ParsedIsNonceUsedInstruction, - type ParsedPauseInstruction, - type ParsedReceiveMessageInstruction, - type ParsedReclaimEventAccountInstruction, - type ParsedSendMessageInstruction, - type ParsedSetMaxMessageBodySizeInstruction, - type ParsedSetSignatureThresholdInstruction, - type ParsedTransferOwnershipInstruction, - type ParsedUnpauseInstruction, - type ParsedUpdateAttesterManagerInstruction, - type ParsedUpdatePauserInstruction, -} from '../instructions'; - -export const MESSAGE_TRANSMITTER_V2_PROGRAM_ADDRESS = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; - -export enum MessageTransmitterV2Account { - MessageSent, - MessageTransmitter, - UsedNonce, -} - -export function identifyMessageTransmitterV2Account( - account: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): MessageTransmitterV2Account { - const data = 'data' in account ? account.data : account; - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([131, 100, 133, 56, 166, 225, 151, 60]) - ), - 0 - ) - ) { - return MessageTransmitterV2Account.MessageSent; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([71, 40, 180, 142, 19, 203, 35, 252]) - ), - 0 - ) - ) { - return MessageTransmitterV2Account.MessageTransmitter; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([212, 222, 157, 252, 130, 71, 179, 238]) - ), - 0 - ) - ) { - return MessageTransmitterV2Account.UsedNonce; - } - throw new Error( - 'The provided account could not be identified as a messageTransmitterV2 account.' - ); -} - -export enum MessageTransmitterV2Instruction { - AcceptOwnership, - DisableAttester, - EnableAttester, - Initialize, - IsNonceUsed, - Pause, - ReceiveMessage, - ReclaimEventAccount, - SendMessage, - SetMaxMessageBodySize, - SetSignatureThreshold, - TransferOwnership, - Unpause, - UpdateAttesterManager, - UpdatePauser, -} - -export function identifyMessageTransmitterV2Instruction( - instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): MessageTransmitterV2Instruction { - const data = 'data' in instruction ? instruction.data : instruction; - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([172, 23, 43, 13, 238, 213, 85, 150]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.AcceptOwnership; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([61, 171, 131, 95, 172, 15, 227, 229]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.DisableAttester; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([2, 11, 193, 115, 5, 148, 4, 198]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.EnableAttester; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.Initialize; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([144, 72, 107, 148, 35, 218, 31, 187]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.IsNonceUsed; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([211, 22, 221, 251, 74, 121, 193, 47]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.Pause; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([38, 144, 127, 225, 31, 225, 238, 25]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.ReceiveMessage; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([94, 198, 180, 159, 131, 236, 15, 174]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.ReclaimEventAccount; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([57, 40, 34, 178, 189, 10, 65, 26]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.SendMessage; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([168, 178, 8, 117, 217, 167, 219, 31]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.SetMaxMessageBodySize; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([163, 19, 154, 168, 82, 209, 214, 219]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.SetSignatureThreshold; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.TransferOwnership; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([169, 144, 4, 38, 10, 141, 188, 255]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.Unpause; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([175, 245, 178, 104, 85, 179, 71, 16]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.UpdateAttesterManager; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([140, 171, 211, 132, 57, 201, 16, 254]) - ), - 0 - ) - ) { - return MessageTransmitterV2Instruction.UpdatePauser; - } - throw new Error( - 'The provided instruction could not be identified as a messageTransmitterV2 instruction.' - ); -} - -export type ParsedMessageTransmitterV2Instruction< - TProgram extends string = 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC', -> = - | ({ - instructionType: MessageTransmitterV2Instruction.AcceptOwnership; - } & ParsedAcceptOwnershipInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.DisableAttester; - } & ParsedDisableAttesterInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.EnableAttester; - } & ParsedEnableAttesterInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.Initialize; - } & ParsedInitializeInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.IsNonceUsed; - } & ParsedIsNonceUsedInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.Pause; - } & ParsedPauseInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.ReceiveMessage; - } & ParsedReceiveMessageInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.ReclaimEventAccount; - } & ParsedReclaimEventAccountInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.SendMessage; - } & ParsedSendMessageInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.SetMaxMessageBodySize; - } & ParsedSetMaxMessageBodySizeInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.SetSignatureThreshold; - } & ParsedSetSignatureThresholdInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.TransferOwnership; - } & ParsedTransferOwnershipInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.Unpause; - } & ParsedUnpauseInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.UpdateAttesterManager; - } & ParsedUpdateAttesterManagerInstruction) - | ({ - instructionType: MessageTransmitterV2Instruction.UpdatePauser; - } & ParsedUpdatePauserInstruction); diff --git a/src/svm/clients/MessageTransmitterV2/shared/index.ts b/src/svm/clients/MessageTransmitterV2/shared/index.ts deleted file mode 100644 index 7ebc26514..000000000 --- a/src/svm/clients/MessageTransmitterV2/shared/index.ts +++ /dev/null @@ -1,164 +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 { - AccountRole, - isProgramDerivedAddress, - isTransactionSigner as kitIsTransactionSigner, - type AccountMeta, - type AccountSignerMeta, - type Address, - type ProgramDerivedAddress, - type TransactionSigner, - upgradeRoleToSigner, -} from '@solana/kit'; - -/** - * Asserts that the given value is not null or undefined. - * @internal - */ -export function expectSome(value: T | null | undefined): T { - if (value == null) { - throw new Error('Expected a value but received null or undefined.'); - } - return value; -} - -/** - * Asserts that the given value is a PublicKey. - * @internal - */ -export function expectAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): Address { - if (!value) { - throw new Error('Expected a Address.'); - } - if (typeof value === 'object' && 'address' in value) { - return value.address; - } - if (Array.isArray(value)) { - return value[0]; - } - return value as Address; -} - -/** - * Asserts that the given value is a PDA. - * @internal - */ -export function expectProgramDerivedAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): ProgramDerivedAddress { - if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { - throw new Error('Expected a ProgramDerivedAddress.'); - } - return value; -} - -/** - * Asserts that the given value is a TransactionSigner. - * @internal - */ -export function expectTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): TransactionSigner { - if (!value || !isTransactionSigner(value)) { - throw new Error('Expected a TransactionSigner.'); - } - return value; -} - -/** - * Defines an instruction account to resolve. - * @internal - */ -export type ResolvedAccount< - T extends string = string, - U extends - | Address - | ProgramDerivedAddress - | TransactionSigner - | null = - | Address - | ProgramDerivedAddress - | TransactionSigner - | null, -> = { - isWritable: boolean; - value: U; -}; - -/** - * Defines an instruction that stores additional bytes on-chain. - * @internal - */ -export type InstructionWithByteDelta = { - byteDelta: number; -}; - -/** - * Get account metas and signers from resolved accounts. - * @internal - */ -export function getAccountMetaFactory( - programAddress: Address, - optionalAccountStrategy: 'omitted' | 'programId' -) { - return ( - account: ResolvedAccount - ): AccountMeta | AccountSignerMeta | undefined => { - if (!account.value) { - if (optionalAccountStrategy === 'omitted') return; - return Object.freeze({ - address: programAddress, - role: AccountRole.READONLY, - }); - } - - const writableRole = account.isWritable - ? AccountRole.WRITABLE - : AccountRole.READONLY; - return Object.freeze({ - address: expectAddress(account.value), - role: isTransactionSigner(account.value) - ? upgradeRoleToSigner(writableRole) - : writableRole, - ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), - }); - }; -} - -export function isTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner -): value is TransactionSigner { - return ( - !!value && - typeof value === 'object' && - 'address' in value && - kitIsTransactionSigner(value) - ); -} diff --git a/src/svm/clients/MessageTransmitterV2/types/attesterDisabled.ts b/src/svm/clients/MessageTransmitterV2/types/attesterDisabled.ts deleted file mode 100644 index b643a7a51..000000000 --- a/src/svm/clients/MessageTransmitterV2/types/attesterDisabled.ts +++ /dev/null @@ -1,41 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type AttesterDisabled = { attester: Address }; - -export type AttesterDisabledArgs = AttesterDisabled; - -export function getAttesterDisabledEncoder(): Encoder { - return getStructEncoder([['attester', getAddressEncoder()]]); -} - -export function getAttesterDisabledDecoder(): Decoder { - return getStructDecoder([['attester', getAddressDecoder()]]); -} - -export function getAttesterDisabledCodec(): Codec< - AttesterDisabledArgs, - AttesterDisabled -> { - return combineCodec( - getAttesterDisabledEncoder(), - getAttesterDisabledDecoder() - ); -} diff --git a/src/svm/clients/MessageTransmitterV2/types/attesterEnabled.ts b/src/svm/clients/MessageTransmitterV2/types/attesterEnabled.ts deleted file mode 100644 index ad2132a58..000000000 --- a/src/svm/clients/MessageTransmitterV2/types/attesterEnabled.ts +++ /dev/null @@ -1,38 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type AttesterEnabled = { attester: Address }; - -export type AttesterEnabledArgs = AttesterEnabled; - -export function getAttesterEnabledEncoder(): Encoder { - return getStructEncoder([['attester', getAddressEncoder()]]); -} - -export function getAttesterEnabledDecoder(): Decoder { - return getStructDecoder([['attester', getAddressDecoder()]]); -} - -export function getAttesterEnabledCodec(): Codec< - AttesterEnabledArgs, - AttesterEnabled -> { - return combineCodec(getAttesterEnabledEncoder(), getAttesterEnabledDecoder()); -} diff --git a/src/svm/clients/MessageTransmitterV2/types/attesterManagerUpdated.ts b/src/svm/clients/MessageTransmitterV2/types/attesterManagerUpdated.ts deleted file mode 100644 index f75c9f3ec..000000000 --- a/src/svm/clients/MessageTransmitterV2/types/attesterManagerUpdated.ts +++ /dev/null @@ -1,50 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type AttesterManagerUpdated = { - previousAttesterManager: Address; - newAttesterManager: Address; -}; - -export type AttesterManagerUpdatedArgs = AttesterManagerUpdated; - -export function getAttesterManagerUpdatedEncoder(): Encoder { - return getStructEncoder([ - ['previousAttesterManager', getAddressEncoder()], - ['newAttesterManager', getAddressEncoder()], - ]); -} - -export function getAttesterManagerUpdatedDecoder(): Decoder { - return getStructDecoder([ - ['previousAttesterManager', getAddressDecoder()], - ['newAttesterManager', getAddressDecoder()], - ]); -} - -export function getAttesterManagerUpdatedCodec(): Codec< - AttesterManagerUpdatedArgs, - AttesterManagerUpdated -> { - return combineCodec( - getAttesterManagerUpdatedEncoder(), - getAttesterManagerUpdatedDecoder() - ); -} diff --git a/src/svm/clients/MessageTransmitterV2/types/index.ts b/src/svm/clients/MessageTransmitterV2/types/index.ts deleted file mode 100644 index df8590dc1..000000000 --- a/src/svm/clients/MessageTransmitterV2/types/index.ts +++ /dev/null @@ -1,19 +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 - */ - -export * from './attesterDisabled'; -export * from './attesterEnabled'; -export * from './attesterManagerUpdated'; -export * from './maxMessageBodySizeUpdated'; -export * from './messageReceived'; -export * from './ownershipTransferred'; -export * from './ownershipTransferStarted'; -export * from './pause'; -export * from './pauserChanged'; -export * from './signatureThresholdUpdated'; -export * from './unpause'; diff --git a/src/svm/clients/MessageTransmitterV2/types/maxMessageBodySizeUpdated.ts b/src/svm/clients/MessageTransmitterV2/types/maxMessageBodySizeUpdated.ts deleted file mode 100644 index 8a0231c61..000000000 --- a/src/svm/clients/MessageTransmitterV2/types/maxMessageBodySizeUpdated.ts +++ /dev/null @@ -1,42 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type MaxMessageBodySizeUpdated = { newMaxMessageBodySize: bigint }; - -export type MaxMessageBodySizeUpdatedArgs = { - newMaxMessageBodySize: number | bigint; -}; - -export function getMaxMessageBodySizeUpdatedEncoder(): Encoder { - return getStructEncoder([['newMaxMessageBodySize', getU64Encoder()]]); -} - -export function getMaxMessageBodySizeUpdatedDecoder(): Decoder { - return getStructDecoder([['newMaxMessageBodySize', getU64Decoder()]]); -} - -export function getMaxMessageBodySizeUpdatedCodec(): Codec< - MaxMessageBodySizeUpdatedArgs, - MaxMessageBodySizeUpdated -> { - return combineCodec( - getMaxMessageBodySizeUpdatedEncoder(), - getMaxMessageBodySizeUpdatedDecoder() - ); -} diff --git a/src/svm/clients/MessageTransmitterV2/types/messageReceived.ts b/src/svm/clients/MessageTransmitterV2/types/messageReceived.ts deleted file mode 100644 index f79286e6d..000000000 --- a/src/svm/clients/MessageTransmitterV2/types/messageReceived.ts +++ /dev/null @@ -1,68 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export type MessageReceived = { - caller: Address; - sourceDomain: number; - nonce: ReadonlyUint8Array; - sender: Address; - finalityThresholdExecuted: number; - messageBody: ReadonlyUint8Array; -}; - -export type MessageReceivedArgs = MessageReceived; - -export function getMessageReceivedEncoder(): Encoder { - return getStructEncoder([ - ['caller', getAddressEncoder()], - ['sourceDomain', getU32Encoder()], - ['nonce', fixEncoderSize(getBytesEncoder(), 32)], - ['sender', getAddressEncoder()], - ['finalityThresholdExecuted', getU32Encoder()], - ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]); -} - -export function getMessageReceivedDecoder(): Decoder { - return getStructDecoder([ - ['caller', getAddressDecoder()], - ['sourceDomain', getU32Decoder()], - ['nonce', fixDecoderSize(getBytesDecoder(), 32)], - ['sender', getAddressDecoder()], - ['finalityThresholdExecuted', getU32Decoder()], - ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getMessageReceivedCodec(): Codec< - MessageReceivedArgs, - MessageReceived -> { - return combineCodec(getMessageReceivedEncoder(), getMessageReceivedDecoder()); -} diff --git a/src/svm/clients/MessageTransmitterV2/types/ownershipTransferStarted.ts b/src/svm/clients/MessageTransmitterV2/types/ownershipTransferStarted.ts deleted file mode 100644 index e170a569a..000000000 --- a/src/svm/clients/MessageTransmitterV2/types/ownershipTransferStarted.ts +++ /dev/null @@ -1,50 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type OwnershipTransferStarted = { - previousOwner: Address; - newOwner: Address; -}; - -export type OwnershipTransferStartedArgs = OwnershipTransferStarted; - -export function getOwnershipTransferStartedEncoder(): Encoder { - return getStructEncoder([ - ['previousOwner', getAddressEncoder()], - ['newOwner', getAddressEncoder()], - ]); -} - -export function getOwnershipTransferStartedDecoder(): Decoder { - return getStructDecoder([ - ['previousOwner', getAddressDecoder()], - ['newOwner', getAddressDecoder()], - ]); -} - -export function getOwnershipTransferStartedCodec(): Codec< - OwnershipTransferStartedArgs, - OwnershipTransferStarted -> { - return combineCodec( - getOwnershipTransferStartedEncoder(), - getOwnershipTransferStartedDecoder() - ); -} diff --git a/src/svm/clients/MessageTransmitterV2/types/ownershipTransferred.ts b/src/svm/clients/MessageTransmitterV2/types/ownershipTransferred.ts deleted file mode 100644 index 40f21c661..000000000 --- a/src/svm/clients/MessageTransmitterV2/types/ownershipTransferred.ts +++ /dev/null @@ -1,50 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type OwnershipTransferred = { - previousOwner: Address; - newOwner: Address; -}; - -export type OwnershipTransferredArgs = OwnershipTransferred; - -export function getOwnershipTransferredEncoder(): Encoder { - return getStructEncoder([ - ['previousOwner', getAddressEncoder()], - ['newOwner', getAddressEncoder()], - ]); -} - -export function getOwnershipTransferredDecoder(): Decoder { - return getStructDecoder([ - ['previousOwner', getAddressDecoder()], - ['newOwner', getAddressDecoder()], - ]); -} - -export function getOwnershipTransferredCodec(): Codec< - OwnershipTransferredArgs, - OwnershipTransferred -> { - return combineCodec( - getOwnershipTransferredEncoder(), - getOwnershipTransferredDecoder() - ); -} diff --git a/src/svm/clients/MessageTransmitterV2/types/pause.ts b/src/svm/clients/MessageTransmitterV2/types/pause.ts deleted file mode 100644 index f1f423325..000000000 --- a/src/svm/clients/MessageTransmitterV2/types/pause.ts +++ /dev/null @@ -1,32 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type Pause = {}; - -export type PauseArgs = Pause; - -export function getPauseEncoder(): Encoder { - return getStructEncoder([]); -} - -export function getPauseDecoder(): Decoder { - return getStructDecoder([]); -} - -export function getPauseCodec(): Codec { - return combineCodec(getPauseEncoder(), getPauseDecoder()); -} diff --git a/src/svm/clients/MessageTransmitterV2/types/pauserChanged.ts b/src/svm/clients/MessageTransmitterV2/types/pauserChanged.ts deleted file mode 100644 index 57d7433da..000000000 --- a/src/svm/clients/MessageTransmitterV2/types/pauserChanged.ts +++ /dev/null @@ -1,38 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type PauserChanged = { newAddress: Address }; - -export type PauserChangedArgs = PauserChanged; - -export function getPauserChangedEncoder(): Encoder { - return getStructEncoder([['newAddress', getAddressEncoder()]]); -} - -export function getPauserChangedDecoder(): Decoder { - return getStructDecoder([['newAddress', getAddressDecoder()]]); -} - -export function getPauserChangedCodec(): Codec< - PauserChangedArgs, - PauserChanged -> { - return combineCodec(getPauserChangedEncoder(), getPauserChangedDecoder()); -} diff --git a/src/svm/clients/MessageTransmitterV2/types/signatureThresholdUpdated.ts b/src/svm/clients/MessageTransmitterV2/types/signatureThresholdUpdated.ts deleted file mode 100644 index e8a729867..000000000 --- a/src/svm/clients/MessageTransmitterV2/types/signatureThresholdUpdated.ts +++ /dev/null @@ -1,49 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type SignatureThresholdUpdated = { - oldSignatureThreshold: number; - newSignatureThreshold: number; -}; - -export type SignatureThresholdUpdatedArgs = SignatureThresholdUpdated; - -export function getSignatureThresholdUpdatedEncoder(): Encoder { - return getStructEncoder([ - ['oldSignatureThreshold', getU32Encoder()], - ['newSignatureThreshold', getU32Encoder()], - ]); -} - -export function getSignatureThresholdUpdatedDecoder(): Decoder { - return getStructDecoder([ - ['oldSignatureThreshold', getU32Decoder()], - ['newSignatureThreshold', getU32Decoder()], - ]); -} - -export function getSignatureThresholdUpdatedCodec(): Codec< - SignatureThresholdUpdatedArgs, - SignatureThresholdUpdated -> { - return combineCodec( - getSignatureThresholdUpdatedEncoder(), - getSignatureThresholdUpdatedDecoder() - ); -} diff --git a/src/svm/clients/MessageTransmitterV2/types/unpause.ts b/src/svm/clients/MessageTransmitterV2/types/unpause.ts deleted file mode 100644 index 4fdc009ef..000000000 --- a/src/svm/clients/MessageTransmitterV2/types/unpause.ts +++ /dev/null @@ -1,32 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type Unpause = {}; - -export type UnpauseArgs = Unpause; - -export function getUnpauseEncoder(): Encoder { - return getStructEncoder([]); -} - -export function getUnpauseDecoder(): Decoder { - return getStructDecoder([]); -} - -export function getUnpauseCodec(): Codec { - return combineCodec(getUnpauseEncoder(), getUnpauseDecoder()); -} diff --git a/src/svm/clients/MulticallHandler/index.ts b/src/svm/clients/MulticallHandler/index.ts deleted file mode 100644 index d69c576af..000000000 --- a/src/svm/clients/MulticallHandler/index.ts +++ /dev/null @@ -1,10 +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 - */ - -export * from './instructions'; -export * from './programs'; diff --git a/src/svm/clients/MulticallHandler/instructions/handleV3AcrossMessage.ts b/src/svm/clients/MulticallHandler/instructions/handleV3AcrossMessage.ts deleted file mode 100644 index 20d6b2591..000000000 --- a/src/svm/clients/MulticallHandler/instructions/handleV3AcrossMessage.ts +++ /dev/null @@ -1,133 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { MULTICALL_HANDLER_PROGRAM_ADDRESS } from '../programs'; - -export const HANDLE_V3_ACROSS_MESSAGE_DISCRIMINATOR = new Uint8Array([ - 131, 141, 52, 71, 16, 59, 196, 92, -]); - -export function getHandleV3AcrossMessageDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - HANDLE_V3_ACROSS_MESSAGE_DISCRIMINATOR - ); -} - -export type HandleV3AcrossMessageInstruction< - TProgram extends string = typeof MULTICALL_HANDLER_PROGRAM_ADDRESS, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts; - -export type HandleV3AcrossMessageInstructionData = { - discriminator: ReadonlyUint8Array; - message: ReadonlyUint8Array; -}; - -export type HandleV3AcrossMessageInstructionDataArgs = { - message: ReadonlyUint8Array; -}; - -export function getHandleV3AcrossMessageInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ - ...value, - discriminator: HANDLE_V3_ACROSS_MESSAGE_DISCRIMINATOR, - }) - ); -} - -export function getHandleV3AcrossMessageInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getHandleV3AcrossMessageInstructionDataCodec(): Codec< - HandleV3AcrossMessageInstructionDataArgs, - HandleV3AcrossMessageInstructionData -> { - return combineCodec( - getHandleV3AcrossMessageInstructionDataEncoder(), - getHandleV3AcrossMessageInstructionDataDecoder() - ); -} - -export type HandleV3AcrossMessageInput = { - message: HandleV3AcrossMessageInstructionDataArgs['message']; -}; - -export function getHandleV3AcrossMessageInstruction< - TProgramAddress extends Address = typeof MULTICALL_HANDLER_PROGRAM_ADDRESS, ->( - input: HandleV3AcrossMessageInput, - config?: { programAddress?: TProgramAddress } -): HandleV3AcrossMessageInstruction { - // Program address. - const programAddress = - config?.programAddress ?? MULTICALL_HANDLER_PROGRAM_ADDRESS; - - // Original args. - const args = { ...input }; - - const instruction = { - programAddress, - data: getHandleV3AcrossMessageInstructionDataEncoder().encode( - args as HandleV3AcrossMessageInstructionDataArgs - ), - } as HandleV3AcrossMessageInstruction; - - return instruction; -} - -export type ParsedHandleV3AcrossMessageInstruction< - TProgram extends string = typeof MULTICALL_HANDLER_PROGRAM_ADDRESS, -> = { - programAddress: Address; - data: HandleV3AcrossMessageInstructionData; -}; - -export function parseHandleV3AcrossMessageInstruction( - instruction: Instruction & InstructionWithData -): ParsedHandleV3AcrossMessageInstruction { - return { - programAddress: instruction.programAddress, - data: getHandleV3AcrossMessageInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/MulticallHandler/instructions/index.ts b/src/svm/clients/MulticallHandler/instructions/index.ts deleted file mode 100644 index 1dfed40c0..000000000 --- a/src/svm/clients/MulticallHandler/instructions/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './handleV3AcrossMessage'; diff --git a/src/svm/clients/MulticallHandler/programs/index.ts b/src/svm/clients/MulticallHandler/programs/index.ts deleted file mode 100644 index e8d227f30..000000000 --- a/src/svm/clients/MulticallHandler/programs/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './multicallHandler'; diff --git a/src/svm/clients/MulticallHandler/programs/multicallHandler.ts b/src/svm/clients/MulticallHandler/programs/multicallHandler.ts deleted file mode 100644 index d0f0fc93f..000000000 --- a/src/svm/clients/MulticallHandler/programs/multicallHandler.ts +++ /dev/null @@ -1,49 +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/kit'; -import { type ParsedHandleV3AcrossMessageInstruction } from '../instructions'; - -export const MULTICALL_HANDLER_PROGRAM_ADDRESS = - 'HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be' as Address<'HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be'>; - -export enum MulticallHandlerInstruction { - HandleV3AcrossMessage, -} - -export function identifyMulticallHandlerInstruction( - instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): MulticallHandlerInstruction { - const data = 'data' in instruction ? instruction.data : instruction; - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([131, 141, 52, 71, 16, 59, 196, 92]) - ), - 0 - ) - ) { - return MulticallHandlerInstruction.HandleV3AcrossMessage; - } - throw new Error( - 'The provided instruction could not be identified as a multicallHandler instruction.' - ); -} - -export type ParsedMulticallHandlerInstruction< - TProgram extends string = 'HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be', -> = { - instructionType: MulticallHandlerInstruction.HandleV3AcrossMessage; -} & ParsedHandleV3AcrossMessageInstruction; diff --git a/src/svm/clients/MulticallHandler/shared/index.ts b/src/svm/clients/MulticallHandler/shared/index.ts deleted file mode 100644 index 7ebc26514..000000000 --- a/src/svm/clients/MulticallHandler/shared/index.ts +++ /dev/null @@ -1,164 +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 { - AccountRole, - isProgramDerivedAddress, - isTransactionSigner as kitIsTransactionSigner, - type AccountMeta, - type AccountSignerMeta, - type Address, - type ProgramDerivedAddress, - type TransactionSigner, - upgradeRoleToSigner, -} from '@solana/kit'; - -/** - * Asserts that the given value is not null or undefined. - * @internal - */ -export function expectSome(value: T | null | undefined): T { - if (value == null) { - throw new Error('Expected a value but received null or undefined.'); - } - return value; -} - -/** - * Asserts that the given value is a PublicKey. - * @internal - */ -export function expectAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): Address { - if (!value) { - throw new Error('Expected a Address.'); - } - if (typeof value === 'object' && 'address' in value) { - return value.address; - } - if (Array.isArray(value)) { - return value[0]; - } - return value as Address; -} - -/** - * Asserts that the given value is a PDA. - * @internal - */ -export function expectProgramDerivedAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): ProgramDerivedAddress { - if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { - throw new Error('Expected a ProgramDerivedAddress.'); - } - return value; -} - -/** - * Asserts that the given value is a TransactionSigner. - * @internal - */ -export function expectTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): TransactionSigner { - if (!value || !isTransactionSigner(value)) { - throw new Error('Expected a TransactionSigner.'); - } - return value; -} - -/** - * Defines an instruction account to resolve. - * @internal - */ -export type ResolvedAccount< - T extends string = string, - U extends - | Address - | ProgramDerivedAddress - | TransactionSigner - | null = - | Address - | ProgramDerivedAddress - | TransactionSigner - | null, -> = { - isWritable: boolean; - value: U; -}; - -/** - * Defines an instruction that stores additional bytes on-chain. - * @internal - */ -export type InstructionWithByteDelta = { - byteDelta: number; -}; - -/** - * Get account metas and signers from resolved accounts. - * @internal - */ -export function getAccountMetaFactory( - programAddress: Address, - optionalAccountStrategy: 'omitted' | 'programId' -) { - return ( - account: ResolvedAccount - ): AccountMeta | AccountSignerMeta | undefined => { - if (!account.value) { - if (optionalAccountStrategy === 'omitted') return; - return Object.freeze({ - address: programAddress, - role: AccountRole.READONLY, - }); - } - - const writableRole = account.isWritable - ? AccountRole.WRITABLE - : AccountRole.READONLY; - return Object.freeze({ - address: expectAddress(account.value), - role: isTransactionSigner(account.value) - ? upgradeRoleToSigner(writableRole) - : writableRole, - ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), - }); - }; -} - -export function isTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner -): value is TransactionSigner { - return ( - !!value && - typeof value === 'object' && - 'address' in value && - kitIsTransactionSigner(value) - ); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/index.ts deleted file mode 100644 index 669123917..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/index.ts +++ /dev/null @@ -1,13 +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 - */ - -export * from './messageSent'; -export * from './minimumDeposit'; -export * from './rentClaim'; -export * from './state'; -export * from './usedNonce'; diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/messageSent.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/messageSent.ts deleted file mode 100644 index e401030f7..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/messageSent.ts +++ /dev/null @@ -1,143 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getI64Decoder, - getI64Encoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const MESSAGE_SENT_DISCRIMINATOR = new Uint8Array([ - 131, 100, 133, 56, 166, 225, 151, 60, -]); - -export function getMessageSentDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - MESSAGE_SENT_DISCRIMINATOR - ); -} - -export type MessageSent = { - discriminator: ReadonlyUint8Array; - rentPayer: Address; - createdAt: bigint; - message: ReadonlyUint8Array; -}; - -export type MessageSentArgs = { - rentPayer: Address; - createdAt: number | bigint; - message: ReadonlyUint8Array; -}; - -export function getMessageSentEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['rentPayer', getAddressEncoder()], - ['createdAt', getI64Encoder()], - ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ ...value, discriminator: MESSAGE_SENT_DISCRIMINATOR }) - ); -} - -export function getMessageSentDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['rentPayer', getAddressDecoder()], - ['createdAt', getI64Decoder()], - ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getMessageSentCodec(): Codec { - return combineCodec(getMessageSentEncoder(), getMessageSentDecoder()); -} - -export function decodeMessageSent( - encodedAccount: EncodedAccount -): Account; -export function decodeMessageSent( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeMessageSent( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getMessageSentDecoder() - ); -} - -export async function fetchMessageSent( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeMessageSent(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeMessageSent( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeMessageSent(maybeAccount); -} - -export async function fetchAllMessageSent( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeMessageSent(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeMessageSent( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeMessageSent(maybeAccount)); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/minimumDeposit.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/minimumDeposit.ts deleted file mode 100644 index 69afbefb0..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/minimumDeposit.ts +++ /dev/null @@ -1,147 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const MINIMUM_DEPOSIT_DISCRIMINATOR = new Uint8Array([ - 218, 139, 120, 202, 3, 12, 233, 65, -]); - -export function getMinimumDepositDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - MINIMUM_DEPOSIT_DISCRIMINATOR - ); -} - -export type MinimumDeposit = { - discriminator: ReadonlyUint8Array; - amount: bigint; - bump: number; -}; - -export type MinimumDepositArgs = { amount: number | bigint; bump: number }; - -export function getMinimumDepositEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['amount', getU64Encoder()], - ['bump', getU8Encoder()], - ]), - (value) => ({ ...value, discriminator: MINIMUM_DEPOSIT_DISCRIMINATOR }) - ); -} - -export function getMinimumDepositDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['amount', getU64Decoder()], - ['bump', getU8Decoder()], - ]); -} - -export function getMinimumDepositCodec(): Codec< - MinimumDepositArgs, - MinimumDeposit -> { - return combineCodec(getMinimumDepositEncoder(), getMinimumDepositDecoder()); -} - -export function decodeMinimumDeposit( - encodedAccount: EncodedAccount -): Account; -export function decodeMinimumDeposit( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeMinimumDeposit( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getMinimumDepositDecoder() - ); -} - -export async function fetchMinimumDeposit( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeMinimumDeposit(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeMinimumDeposit< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeMinimumDeposit(maybeAccount); -} - -export async function fetchAllMinimumDeposit( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeMinimumDeposit( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeMinimumDeposit( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeMinimumDeposit(maybeAccount) - ); -} - -export function getMinimumDepositSize(): number { - return 17; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/rentClaim.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/rentClaim.ts deleted file mode 100644 index 6631dac9b..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/rentClaim.ts +++ /dev/null @@ -1,126 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const RENT_CLAIM_DISCRIMINATOR = new Uint8Array([ - 13, 5, 183, 82, 60, 122, 72, 11, -]); - -export function getRentClaimDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(RENT_CLAIM_DISCRIMINATOR); -} - -export type RentClaim = { discriminator: ReadonlyUint8Array; amount: bigint }; - -export type RentClaimArgs = { amount: number | bigint }; - -export function getRentClaimEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['amount', getU64Encoder()], - ]), - (value) => ({ ...value, discriminator: RENT_CLAIM_DISCRIMINATOR }) - ); -} - -export function getRentClaimDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['amount', getU64Decoder()], - ]); -} - -export function getRentClaimCodec(): Codec { - return combineCodec(getRentClaimEncoder(), getRentClaimDecoder()); -} - -export function decodeRentClaim( - encodedAccount: EncodedAccount -): Account; -export function decodeRentClaim( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeRentClaim( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getRentClaimDecoder() - ); -} - -export async function fetchRentClaim( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeRentClaim(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeRentClaim( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeRentClaim(maybeAccount); -} - -export async function fetchAllRentClaim( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeRentClaim(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeRentClaim( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeRentClaim(maybeAccount)); -} - -export function getRentClaimSize(): number { - return 16; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/state.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/state.ts deleted file mode 100644 index 6d6399bb2..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/state.ts +++ /dev/null @@ -1,139 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const STATE_DISCRIMINATOR = new Uint8Array([ - 216, 146, 107, 94, 104, 75, 182, 177, -]); - -export function getStateDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(STATE_DISCRIMINATOR); -} - -export type State = { - discriminator: ReadonlyUint8Array; - sourceDomain: number; - signer: Address; - bump: number; -}; - -export type StateArgs = { sourceDomain: number; signer: Address; bump: number }; - -export function getStateEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['sourceDomain', getU32Encoder()], - ['signer', getAddressEncoder()], - ['bump', getU8Encoder()], - ]), - (value) => ({ ...value, discriminator: STATE_DISCRIMINATOR }) - ); -} - -export function getStateDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['sourceDomain', getU32Decoder()], - ['signer', getAddressDecoder()], - ['bump', getU8Decoder()], - ]); -} - -export function getStateCodec(): Codec { - return combineCodec(getStateEncoder(), getStateDecoder()); -} - -export function decodeState( - encodedAccount: EncodedAccount -): Account; -export function decodeState( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeState( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getStateDecoder() - ); -} - -export async function fetchState( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeState(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeState( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeState(maybeAccount); -} - -export async function fetchAllState( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeState(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeState( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeState(maybeAccount)); -} - -export function getStateSize(): number { - return 45; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/usedNonce.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/usedNonce.ts deleted file mode 100644 index 32d04d0b0..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/accounts/usedNonce.ts +++ /dev/null @@ -1,129 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const USED_NONCE_DISCRIMINATOR = new Uint8Array([ - 212, 222, 157, 252, 130, 71, 179, 238, -]); - -export function getUsedNonceDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(USED_NONCE_DISCRIMINATOR); -} - -export type UsedNonce = { - discriminator: ReadonlyUint8Array; - quoteDeadline: bigint; -}; - -export type UsedNonceArgs = { quoteDeadline: number | bigint }; - -export function getUsedNonceEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['quoteDeadline', getU64Encoder()], - ]), - (value) => ({ ...value, discriminator: USED_NONCE_DISCRIMINATOR }) - ); -} - -export function getUsedNonceDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['quoteDeadline', getU64Decoder()], - ]); -} - -export function getUsedNonceCodec(): Codec { - return combineCodec(getUsedNonceEncoder(), getUsedNonceDecoder()); -} - -export function decodeUsedNonce( - encodedAccount: EncodedAccount -): Account; -export function decodeUsedNonce( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeUsedNonce( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getUsedNonceDecoder() - ); -} - -export async function fetchUsedNonce( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeUsedNonce(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeUsedNonce( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeUsedNonce(maybeAccount); -} - -export async function fetchAllUsedNonce( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeUsedNonce(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeUsedNonce( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeUsedNonce(maybeAccount)); -} - -export function getUsedNonceSize(): number { - return 16; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/errors/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/errors/index.ts deleted file mode 100644 index b022681a8..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/errors/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './sponsoredCctpSrcPeriphery'; diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/errors/sponsoredCctpSrcPeriphery.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/errors/sponsoredCctpSrcPeriphery.ts deleted file mode 100644 index 818a08a00..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/errors/sponsoredCctpSrcPeriphery.ts +++ /dev/null @@ -1,103 +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 { - isProgramError, - type Address, - type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, - type SolanaError, -} from '@solana/kit'; -import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; - -/** NotUpgradeAuthority: Only the upgrade authority can call this instruction */ -export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__NOT_UPGRADE_AUTHORITY = 0x1770; // 6000 -/** InvalidProgramData: Invalid program data account */ -export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_PROGRAM_DATA = 0x1771; // 6001 -/** CannotSetCurrentTime: Cannot set time if not in test mode */ -export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__CANNOT_SET_CURRENT_TIME = 0x1772; // 6002 -/** InvalidBurnToken: Invalid burn_token key */ -export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_BURN_TOKEN = 0x1773; // 6003 -/** AmountNotPositive: Amount must be greater than 0 */ -export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__AMOUNT_NOT_POSITIVE = 0x1774; // 6004 -/** QuoteDeadlineNotPassed: The quote deadline has not passed! */ -export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__QUOTE_DEADLINE_NOT_PASSED = 0x1775; // 6005 -/** SignerUnchanged: New signer unchanged */ -export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__SIGNER_UNCHANGED = 0x1776; // 6006 -/** DepositAmountBelowMinimum: Deposit amount below minimum */ -export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__DEPOSIT_AMOUNT_BELOW_MINIMUM = 0x1777; // 6007 -/** MissingRentClaimAccount: Missing rent claim account */ -export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__MISSING_RENT_CLAIM_ACCOUNT = 0x1778; // 6008 -/** RentClaimOverflow: Rent claim amount overflow */ -export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__RENT_CLAIM_OVERFLOW = 0x1779; // 6009 -/** InvalidRecipientKey: Invalid recipient key */ -export const SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_RECIPIENT_KEY = 0x177a; // 6010 - -export type SponsoredCctpSrcPeripheryError = - | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__AMOUNT_NOT_POSITIVE - | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__CANNOT_SET_CURRENT_TIME - | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__DEPOSIT_AMOUNT_BELOW_MINIMUM - | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_BURN_TOKEN - | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_PROGRAM_DATA - | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_RECIPIENT_KEY - | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__MISSING_RENT_CLAIM_ACCOUNT - | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__NOT_UPGRADE_AUTHORITY - | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__QUOTE_DEADLINE_NOT_PASSED - | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__RENT_CLAIM_OVERFLOW - | typeof SPONSORED_CCTP_SRC_PERIPHERY_ERROR__SIGNER_UNCHANGED; - -let sponsoredCctpSrcPeripheryErrorMessages: - | Record - | undefined; -if (process.env.NODE_ENV !== 'production') { - sponsoredCctpSrcPeripheryErrorMessages = { - [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__AMOUNT_NOT_POSITIVE]: `Amount must be greater than 0`, - [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__CANNOT_SET_CURRENT_TIME]: `Cannot set time if not in test mode`, - [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__DEPOSIT_AMOUNT_BELOW_MINIMUM]: `Deposit amount below minimum`, - [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_BURN_TOKEN]: `Invalid burn_token key`, - [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_PROGRAM_DATA]: `Invalid program data account`, - [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__INVALID_RECIPIENT_KEY]: `Invalid recipient key`, - [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__MISSING_RENT_CLAIM_ACCOUNT]: `Missing rent claim account`, - [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__NOT_UPGRADE_AUTHORITY]: `Only the upgrade authority can call this instruction`, - [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__QUOTE_DEADLINE_NOT_PASSED]: `The quote deadline has not passed!`, - [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__RENT_CLAIM_OVERFLOW]: `Rent claim amount overflow`, - [SPONSORED_CCTP_SRC_PERIPHERY_ERROR__SIGNER_UNCHANGED]: `New signer unchanged`, - }; -} - -export function getSponsoredCctpSrcPeripheryErrorMessage( - code: SponsoredCctpSrcPeripheryError -): string { - if (process.env.NODE_ENV !== 'production') { - return ( - sponsoredCctpSrcPeripheryErrorMessages as Record< - SponsoredCctpSrcPeripheryError, - string - > - )[code]; - } - - return 'Error message not available in production bundles.'; -} - -export function isSponsoredCctpSrcPeripheryError< - TProgramErrorCode extends SponsoredCctpSrcPeripheryError, ->( - error: unknown, - transactionMessage: { - instructions: Record; - }, - code?: TProgramErrorCode -): error is SolanaError & - Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { - return isProgramError( - error, - transactionMessage, - SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - code - ); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/index.ts deleted file mode 100644 index 02964a6ae..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/index.ts +++ /dev/null @@ -1,13 +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 - */ - -export * from './accounts'; -export * from './errors'; -export * from './instructions'; -export * from './programs'; -export * from './types'; diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/depositForBurn.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/depositForBurn.ts deleted file mode 100644 index f4ed8234e..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/depositForBurn.ts +++ /dev/null @@ -1,914 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; -import { - getSponsoredCCTPQuoteDecoder, - getSponsoredCCTPQuoteEncoder, - type SponsoredCCTPQuote, - type SponsoredCCTPQuoteArgs, -} from '../types'; - -export const DEPOSIT_FOR_BURN_DISCRIMINATOR = new Uint8Array([ - 215, 60, 61, 46, 114, 55, 128, 176, -]); - -export function getDepositForBurnDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - DEPOSIT_FOR_BURN_DISCRIMINATOR - ); -} - -export type DepositForBurnInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountRentFund extends string | AccountMeta = string, - TAccountMinimumDeposit extends string | AccountMeta = string, - TAccountUsedNonce extends string | AccountMeta = string, - TAccountRentClaim extends string | AccountMeta = string, - TAccountDepositorTokenAccount extends string | AccountMeta = string, - TAccountBurnToken extends string | AccountMeta = string, - TAccountDenylistAccount extends string | AccountMeta = string, - TAccountTokenMessengerMinterSenderAuthority extends - | string - | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountRemoteTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountCctpEventAuthority extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TAccountMessageTransmitterProgram extends string | AccountMeta = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC', - TAccountTokenMessengerMinterProgram extends string | AccountMeta = - 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe', - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountState extends string - ? ReadonlyAccount - : TAccountState, - TAccountRentFund extends string - ? WritableAccount - : TAccountRentFund, - TAccountMinimumDeposit extends string - ? ReadonlyAccount - : TAccountMinimumDeposit, - TAccountUsedNonce extends string - ? WritableAccount - : TAccountUsedNonce, - TAccountRentClaim extends string - ? WritableAccount - : TAccountRentClaim, - TAccountDepositorTokenAccount extends string - ? WritableAccount - : TAccountDepositorTokenAccount, - TAccountBurnToken extends string - ? WritableAccount - : TAccountBurnToken, - TAccountDenylistAccount extends string - ? ReadonlyAccount - : TAccountDenylistAccount, - TAccountTokenMessengerMinterSenderAuthority extends string - ? ReadonlyAccount - : TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountRemoteTokenMessenger extends string - ? ReadonlyAccount - : TAccountRemoteTokenMessenger, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountCctpEventAuthority extends string - ? ReadonlyAccount - : TAccountCctpEventAuthority, - TAccountMessageSentEventData extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountMessageSentEventData, - TAccountMessageTransmitterProgram extends string - ? ReadonlyAccount - : TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram extends string - ? ReadonlyAccount - : TAccountTokenMessengerMinterProgram, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type DepositForBurnInstructionData = { - discriminator: ReadonlyUint8Array; - quote: SponsoredCCTPQuote; - signature: ReadonlyUint8Array; -}; - -export type DepositForBurnInstructionDataArgs = { - quote: SponsoredCCTPQuoteArgs; - signature: ReadonlyUint8Array; -}; - -export function getDepositForBurnInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['quote', getSponsoredCCTPQuoteEncoder()], - ['signature', fixEncoderSize(getBytesEncoder(), 65)], - ]), - (value) => ({ ...value, discriminator: DEPOSIT_FOR_BURN_DISCRIMINATOR }) - ); -} - -export function getDepositForBurnInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['quote', getSponsoredCCTPQuoteDecoder()], - ['signature', fixDecoderSize(getBytesDecoder(), 65)], - ]); -} - -export function getDepositForBurnInstructionDataCodec(): Codec< - DepositForBurnInstructionDataArgs, - DepositForBurnInstructionData -> { - return combineCodec( - getDepositForBurnInstructionDataEncoder(), - getDepositForBurnInstructionDataDecoder() - ); -} - -export type DepositForBurnAsyncInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountRentFund extends string = string, - TAccountMinimumDeposit extends string = string, - TAccountUsedNonce extends string = string, - TAccountRentClaim extends string = string, - TAccountDepositorTokenAccount extends string = string, - TAccountBurnToken extends string = string, - TAccountDenylistAccount extends string = string, - TAccountTokenMessengerMinterSenderAuthority extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountCctpEventAuthority extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state?: Address; - rentFund?: Address; - minimumDeposit?: Address; - usedNonce: Address; - rentClaim?: Address; - depositorTokenAccount?: Address; - burnToken: Address; - denylistAccount: Address; - tokenMessengerMinterSenderAuthority: Address; - messageTransmitter: Address; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken: Address; - cctpEventAuthority: Address; - messageSentEventData: TransactionSigner; - messageTransmitterProgram?: Address; - tokenMessengerMinterProgram?: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - quote: DepositForBurnInstructionDataArgs['quote']; - signature: DepositForBurnInstructionDataArgs['signature']; -}; - -export async function getDepositForBurnInstructionAsync< - TAccountSigner extends string, - TAccountState extends string, - TAccountRentFund extends string, - TAccountMinimumDeposit extends string, - TAccountUsedNonce extends string, - TAccountRentClaim extends string, - TAccountDepositorTokenAccount extends string, - TAccountBurnToken extends string, - TAccountDenylistAccount extends string, - TAccountTokenMessengerMinterSenderAuthority extends string, - TAccountMessageTransmitter extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountCctpEventAuthority extends string, - TAccountMessageSentEventData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: DepositForBurnAsyncInput< - TAccountSigner, - TAccountState, - TAccountRentFund, - TAccountMinimumDeposit, - TAccountUsedNonce, - TAccountRentClaim, - TAccountDepositorTokenAccount, - TAccountBurnToken, - TAccountDenylistAccount, - TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCctpEventAuthority, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - DepositForBurnInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountRentFund, - TAccountMinimumDeposit, - TAccountUsedNonce, - TAccountRentClaim, - TAccountDepositorTokenAccount, - TAccountBurnToken, - TAccountDenylistAccount, - TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCctpEventAuthority, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: false }, - rentFund: { value: input.rentFund ?? null, isWritable: true }, - minimumDeposit: { value: input.minimumDeposit ?? null, isWritable: false }, - usedNonce: { value: input.usedNonce ?? null, isWritable: true }, - rentClaim: { value: input.rentClaim ?? null, isWritable: true }, - depositorTokenAccount: { - value: input.depositorTokenAccount ?? null, - isWritable: true, - }, - burnToken: { value: input.burnToken ?? null, isWritable: true }, - denylistAccount: { - value: input.denylistAccount ?? null, - isWritable: false, - }, - tokenMessengerMinterSenderAuthority: { - value: input.tokenMessengerMinterSenderAuthority ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - cctpEventAuthority: { - value: input.cctpEventAuthority ?? null, - isWritable: false, - }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.state.value) { - accounts.state.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), - ], - }); - } - if (!accounts.rentFund.value) { - accounts.rentFund.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([114, 101, 110, 116, 95, 102, 117, 110, 100]) - ), - ], - }); - } - if (!accounts.minimumDeposit.value) { - accounts.minimumDeposit.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 109, 105, 110, 105, 109, 117, 109, 95, 100, 101, 112, 111, 115, 105, - 116, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.burnToken.value)), - ], - }); - } - if (!accounts.rentClaim.value) { - accounts.rentClaim.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([114, 101, 110, 116, 95, 99, 108, 97, 105, 109]) - ), - getAddressEncoder().encode(expectAddress(accounts.signer.value)), - ], - }); - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.depositorTokenAccount.value) { - accounts.depositorTokenAccount.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getAddressEncoder().encode(expectAddress(accounts.signer.value)), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.burnToken.value)), - ], - }); - } - if (!accounts.messageTransmitterProgram.value) { - accounts.messageTransmitterProgram.value = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; - } - if (!accounts.tokenMessengerMinterProgram.value) { - accounts.tokenMessengerMinterProgram.value = - 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.rentFund), - getAccountMeta(accounts.minimumDeposit), - getAccountMeta(accounts.usedNonce), - getAccountMeta(accounts.rentClaim), - getAccountMeta(accounts.depositorTokenAccount), - getAccountMeta(accounts.burnToken), - getAccountMeta(accounts.denylistAccount), - getAccountMeta(accounts.tokenMessengerMinterSenderAuthority), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.cctpEventAuthority), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDepositForBurnInstructionDataEncoder().encode( - args as DepositForBurnInstructionDataArgs - ), - } as DepositForBurnInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountRentFund, - TAccountMinimumDeposit, - TAccountUsedNonce, - TAccountRentClaim, - TAccountDepositorTokenAccount, - TAccountBurnToken, - TAccountDenylistAccount, - TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCctpEventAuthority, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type DepositForBurnInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountRentFund extends string = string, - TAccountMinimumDeposit extends string = string, - TAccountUsedNonce extends string = string, - TAccountRentClaim extends string = string, - TAccountDepositorTokenAccount extends string = string, - TAccountBurnToken extends string = string, - TAccountDenylistAccount extends string = string, - TAccountTokenMessengerMinterSenderAuthority extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountCctpEventAuthority extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - rentFund: Address; - minimumDeposit: Address; - usedNonce: Address; - rentClaim?: Address; - depositorTokenAccount: Address; - burnToken: Address; - denylistAccount: Address; - tokenMessengerMinterSenderAuthority: Address; - messageTransmitter: Address; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken: Address; - cctpEventAuthority: Address; - messageSentEventData: TransactionSigner; - messageTransmitterProgram?: Address; - tokenMessengerMinterProgram?: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - quote: DepositForBurnInstructionDataArgs['quote']; - signature: DepositForBurnInstructionDataArgs['signature']; -}; - -export function getDepositForBurnInstruction< - TAccountSigner extends string, - TAccountState extends string, - TAccountRentFund extends string, - TAccountMinimumDeposit extends string, - TAccountUsedNonce extends string, - TAccountRentClaim extends string, - TAccountDepositorTokenAccount extends string, - TAccountBurnToken extends string, - TAccountDenylistAccount extends string, - TAccountTokenMessengerMinterSenderAuthority extends string, - TAccountMessageTransmitter extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountCctpEventAuthority extends string, - TAccountMessageSentEventData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: DepositForBurnInput< - TAccountSigner, - TAccountState, - TAccountRentFund, - TAccountMinimumDeposit, - TAccountUsedNonce, - TAccountRentClaim, - TAccountDepositorTokenAccount, - TAccountBurnToken, - TAccountDenylistAccount, - TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCctpEventAuthority, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): DepositForBurnInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountRentFund, - TAccountMinimumDeposit, - TAccountUsedNonce, - TAccountRentClaim, - TAccountDepositorTokenAccount, - TAccountBurnToken, - TAccountDenylistAccount, - TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCctpEventAuthority, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: false }, - rentFund: { value: input.rentFund ?? null, isWritable: true }, - minimumDeposit: { value: input.minimumDeposit ?? null, isWritable: false }, - usedNonce: { value: input.usedNonce ?? null, isWritable: true }, - rentClaim: { value: input.rentClaim ?? null, isWritable: true }, - depositorTokenAccount: { - value: input.depositorTokenAccount ?? null, - isWritable: true, - }, - burnToken: { value: input.burnToken ?? null, isWritable: true }, - denylistAccount: { - value: input.denylistAccount ?? null, - isWritable: false, - }, - tokenMessengerMinterSenderAuthority: { - value: input.tokenMessengerMinterSenderAuthority ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - cctpEventAuthority: { - value: input.cctpEventAuthority ?? null, - isWritable: false, - }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.messageTransmitterProgram.value) { - accounts.messageTransmitterProgram.value = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; - } - if (!accounts.tokenMessengerMinterProgram.value) { - accounts.tokenMessengerMinterProgram.value = - 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.rentFund), - getAccountMeta(accounts.minimumDeposit), - getAccountMeta(accounts.usedNonce), - getAccountMeta(accounts.rentClaim), - getAccountMeta(accounts.depositorTokenAccount), - getAccountMeta(accounts.burnToken), - getAccountMeta(accounts.denylistAccount), - getAccountMeta(accounts.tokenMessengerMinterSenderAuthority), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.cctpEventAuthority), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDepositForBurnInstructionDataEncoder().encode( - args as DepositForBurnInstructionDataArgs - ), - } as DepositForBurnInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountRentFund, - TAccountMinimumDeposit, - TAccountUsedNonce, - TAccountRentClaim, - TAccountDepositorTokenAccount, - TAccountBurnToken, - TAccountDenylistAccount, - TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCctpEventAuthority, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedDepositForBurnInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - state: TAccountMetas[1]; - rentFund: TAccountMetas[2]; - minimumDeposit: TAccountMetas[3]; - usedNonce: TAccountMetas[4]; - rentClaim?: TAccountMetas[5] | undefined; - depositorTokenAccount: TAccountMetas[6]; - burnToken: TAccountMetas[7]; - denylistAccount: TAccountMetas[8]; - tokenMessengerMinterSenderAuthority: TAccountMetas[9]; - messageTransmitter: TAccountMetas[10]; - tokenMessenger: TAccountMetas[11]; - remoteTokenMessenger: TAccountMetas[12]; - tokenMinter: TAccountMetas[13]; - localToken: TAccountMetas[14]; - cctpEventAuthority: TAccountMetas[15]; - messageSentEventData: TAccountMetas[16]; - messageTransmitterProgram: TAccountMetas[17]; - tokenMessengerMinterProgram: TAccountMetas[18]; - tokenProgram: TAccountMetas[19]; - systemProgram: TAccountMetas[20]; - eventAuthority: TAccountMetas[21]; - program: TAccountMetas[22]; - }; - data: DepositForBurnInstructionData; -}; - -export function parseDepositForBurnInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedDepositForBurnInstruction { - if (instruction.accounts.length < 23) { - // TODO: Coded error. - throw new Error('Not enough accounts'); - } - let accountIndex = 0; - const getNextAccount = () => { - const accountMeta = instruction.accounts![accountIndex]!; - accountIndex += 1; - return accountMeta; - }; - const getNextOptionalAccount = () => { - const accountMeta = getNextAccount(); - return accountMeta.address === SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS - ? undefined - : accountMeta; - }; - return { - programAddress: instruction.programAddress, - accounts: { - signer: getNextAccount(), - state: getNextAccount(), - rentFund: getNextAccount(), - minimumDeposit: getNextAccount(), - usedNonce: getNextAccount(), - rentClaim: getNextOptionalAccount(), - depositorTokenAccount: getNextAccount(), - burnToken: getNextAccount(), - denylistAccount: getNextAccount(), - tokenMessengerMinterSenderAuthority: getNextAccount(), - messageTransmitter: getNextAccount(), - tokenMessenger: getNextAccount(), - remoteTokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - cctpEventAuthority: getNextAccount(), - messageSentEventData: getNextAccount(), - messageTransmitterProgram: getNextAccount(), - tokenMessengerMinterProgram: getNextAccount(), - tokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getDepositForBurnInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/getUsedNonceCloseInfo.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/getUsedNonceCloseInfo.ts deleted file mode 100644 index 96fec482f..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/getUsedNonceCloseInfo.ts +++ /dev/null @@ -1,275 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -import { - getUsedNonceAccountParamsDecoder, - getUsedNonceAccountParamsEncoder, - type UsedNonceAccountParams, - type UsedNonceAccountParamsArgs, -} from '../types'; - -export const GET_USED_NONCE_CLOSE_INFO_DISCRIMINATOR = new Uint8Array([ - 19, 183, 42, 151, 118, 234, 57, 92, -]); - -export function getGetUsedNonceCloseInfoDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - GET_USED_NONCE_CLOSE_INFO_DISCRIMINATOR - ); -} - -export type GetUsedNonceCloseInfoInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountState extends string | AccountMeta = string, - TAccountUsedNonce extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountState extends string - ? ReadonlyAccount - : TAccountState, - TAccountUsedNonce extends string - ? ReadonlyAccount - : TAccountUsedNonce, - ...TRemainingAccounts, - ] - >; - -export type GetUsedNonceCloseInfoInstructionData = { - discriminator: ReadonlyUint8Array; - params: UsedNonceAccountParams; -}; - -export type GetUsedNonceCloseInfoInstructionDataArgs = { - params: UsedNonceAccountParamsArgs; -}; - -export function getGetUsedNonceCloseInfoInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['params', getUsedNonceAccountParamsEncoder()], - ]), - (value) => ({ - ...value, - discriminator: GET_USED_NONCE_CLOSE_INFO_DISCRIMINATOR, - }) - ); -} - -export function getGetUsedNonceCloseInfoInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['params', getUsedNonceAccountParamsDecoder()], - ]); -} - -export function getGetUsedNonceCloseInfoInstructionDataCodec(): Codec< - GetUsedNonceCloseInfoInstructionDataArgs, - GetUsedNonceCloseInfoInstructionData -> { - return combineCodec( - getGetUsedNonceCloseInfoInstructionDataEncoder(), - getGetUsedNonceCloseInfoInstructionDataDecoder() - ); -} - -export type GetUsedNonceCloseInfoAsyncInput< - TAccountState extends string = string, - TAccountUsedNonce extends string = string, -> = { - state?: Address; - usedNonce: Address; - params: GetUsedNonceCloseInfoInstructionDataArgs['params']; -}; - -export async function getGetUsedNonceCloseInfoInstructionAsync< - TAccountState extends string, - TAccountUsedNonce extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: GetUsedNonceCloseInfoAsyncInput, - config?: { programAddress?: TProgramAddress } -): Promise< - GetUsedNonceCloseInfoInstruction< - TProgramAddress, - TAccountState, - TAccountUsedNonce - > -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - state: { value: input.state ?? null, isWritable: false }, - usedNonce: { value: input.usedNonce ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.state.value) { - accounts.state.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.state), - getAccountMeta(accounts.usedNonce), - ], - programAddress, - data: getGetUsedNonceCloseInfoInstructionDataEncoder().encode( - args as GetUsedNonceCloseInfoInstructionDataArgs - ), - } as GetUsedNonceCloseInfoInstruction< - TProgramAddress, - TAccountState, - TAccountUsedNonce - >; - - return instruction; -} - -export type GetUsedNonceCloseInfoInput< - TAccountState extends string = string, - TAccountUsedNonce extends string = string, -> = { - state: Address; - usedNonce: Address; - params: GetUsedNonceCloseInfoInstructionDataArgs['params']; -}; - -export function getGetUsedNonceCloseInfoInstruction< - TAccountState extends string, - TAccountUsedNonce extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: GetUsedNonceCloseInfoInput, - config?: { programAddress?: TProgramAddress } -): GetUsedNonceCloseInfoInstruction< - TProgramAddress, - TAccountState, - TAccountUsedNonce -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - state: { value: input.state ?? null, isWritable: false }, - usedNonce: { value: input.usedNonce ?? 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.state), - getAccountMeta(accounts.usedNonce), - ], - programAddress, - data: getGetUsedNonceCloseInfoInstructionDataEncoder().encode( - args as GetUsedNonceCloseInfoInstructionDataArgs - ), - } as GetUsedNonceCloseInfoInstruction< - TProgramAddress, - TAccountState, - TAccountUsedNonce - >; - - return instruction; -} - -export type ParsedGetUsedNonceCloseInfoInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - state: TAccountMetas[0]; - usedNonce: TAccountMetas[1]; - }; - data: GetUsedNonceCloseInfoInstructionData; -}; - -export function parseGetUsedNonceCloseInfoInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedGetUsedNonceCloseInfoInstruction { - if (instruction.accounts.length < 2) { - // 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: { - state: getNextAccount(), - usedNonce: getNextAccount(), - }, - data: getGetUsedNonceCloseInfoInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/index.ts deleted file mode 100644 index 706f7eee5..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/index.ts +++ /dev/null @@ -1,18 +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 - */ - -export * from './depositForBurn'; -export * from './getUsedNonceCloseInfo'; -export * from './initialize'; -export * from './reclaimEventAccount'; -export * from './reclaimUsedNonceAccount'; -export * from './repayRentFundDebt'; -export * from './setCurrentTime'; -export * from './setMinimumDepositAmount'; -export * from './setSigner'; -export * from './withdrawRentFund'; diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/initialize.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/initialize.ts deleted file mode 100644 index d40b3b2b1..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/initialize.ts +++ /dev/null @@ -1,369 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const INITIALIZE_DISCRIMINATOR = new Uint8Array([ - 175, 175, 109, 31, 13, 152, 155, 237, -]); - -export function getInitializeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_DISCRIMINATOR); -} - -export type InitializeInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountProgramData extends string | AccountMeta = string, - TAccountThisProgram extends string | AccountMeta = - 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountState extends string - ? WritableAccount - : TAccountState, - TAccountProgramData extends string - ? ReadonlyAccount - : TAccountProgramData, - TAccountThisProgram extends string - ? ReadonlyAccount - : TAccountThisProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type InitializeInstructionData = { - discriminator: ReadonlyUint8Array; - sourceDomain: number; - signer: Address; -}; - -export type InitializeInstructionDataArgs = { - sourceDomain: number; - signer: Address; -}; - -export function getInitializeInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['sourceDomain', getU32Encoder()], - ['signer', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) - ); -} - -export function getInitializeInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['sourceDomain', getU32Decoder()], - ['signer', getAddressDecoder()], - ]); -} - -export function getInitializeInstructionDataCodec(): Codec< - InitializeInstructionDataArgs, - InitializeInstructionData -> { - return combineCodec( - getInitializeInstructionDataEncoder(), - getInitializeInstructionDataDecoder() - ); -} - -export type InitializeAsyncInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountProgramData extends string = string, - TAccountThisProgram extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - state?: Address; - programData: Address; - thisProgram?: Address; - systemProgram?: Address; - sourceDomain: InitializeInstructionDataArgs['sourceDomain']; - signerArg: InitializeInstructionDataArgs['signer']; -}; - -export async function getInitializeInstructionAsync< - TAccountSigner extends string, - TAccountState extends string, - TAccountProgramData extends string, - TAccountThisProgram extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: InitializeAsyncInput< - TAccountSigner, - TAccountState, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - InitializeInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - programData: { value: input.programData ?? null, isWritable: false }, - thisProgram: { value: input.thisProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input, signer: input.signerArg }; - - // Resolve default values. - if (!accounts.state.value) { - accounts.state.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), - ], - }); - } - if (!accounts.thisProgram.value) { - accounts.thisProgram.value = - 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.programData), - getAccountMeta(accounts.thisProgram), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitializeInstructionDataEncoder().encode( - args as InitializeInstructionDataArgs - ), - } as InitializeInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - >; - - return instruction; -} - -export type InitializeInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountProgramData extends string = string, - TAccountThisProgram extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - programData: Address; - thisProgram?: Address; - systemProgram?: Address; - sourceDomain: InitializeInstructionDataArgs['sourceDomain']; - signerArg: InitializeInstructionDataArgs['signer']; -}; - -export function getInitializeInstruction< - TAccountSigner extends string, - TAccountState extends string, - TAccountProgramData extends string, - TAccountThisProgram extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: InitializeInput< - TAccountSigner, - TAccountState, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): InitializeInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - programData: { value: input.programData ?? null, isWritable: false }, - thisProgram: { value: input.thisProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input, signer: input.signerArg }; - - // Resolve default values. - if (!accounts.thisProgram.value) { - accounts.thisProgram.value = - 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.programData), - getAccountMeta(accounts.thisProgram), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitializeInstructionDataEncoder().encode( - args as InitializeInstructionDataArgs - ), - } as InitializeInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedInitializeInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - state: TAccountMetas[1]; - programData: TAccountMetas[2]; - thisProgram: TAccountMetas[3]; - systemProgram: TAccountMetas[4]; - }; - data: InitializeInstructionData; -}; - -export function parseInitializeInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedInitializeInstruction { - if (instruction.accounts.length < 5) { - // 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: { - signer: getNextAccount(), - state: getNextAccount(), - programData: getNextAccount(), - thisProgram: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getInitializeInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimEventAccount.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimEventAccount.ts deleted file mode 100644 index fb92b282b..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimEventAccount.ts +++ /dev/null @@ -1,436 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type WritableAccount, -} from '@solana/kit'; -import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR = new Uint8Array([ - 94, 198, 180, 159, 131, 236, 15, 174, -]); - -export function getReclaimEventAccountDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR - ); -} - -export type ReclaimEventAccountInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountRentFund extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TAccountMessageTransmitterProgram extends string | AccountMeta = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountRentFund extends string - ? WritableAccount - : TAccountRentFund, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountMessageSentEventData extends string - ? WritableAccount - : TAccountMessageSentEventData, - TAccountMessageTransmitterProgram extends string - ? ReadonlyAccount - : TAccountMessageTransmitterProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type ReclaimEventAccountInstructionData = { - discriminator: ReadonlyUint8Array; - attestation: ReadonlyUint8Array; - nonce: ReadonlyUint8Array; - finalityThresholdExecuted: ReadonlyUint8Array; - feeExecuted: ReadonlyUint8Array; - expirationBlock: ReadonlyUint8Array; -}; - -export type ReclaimEventAccountInstructionDataArgs = { - attestation: ReadonlyUint8Array; - nonce: ReadonlyUint8Array; - finalityThresholdExecuted: ReadonlyUint8Array; - feeExecuted: ReadonlyUint8Array; - expirationBlock: ReadonlyUint8Array; -}; - -export function getReclaimEventAccountInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['attestation', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ['nonce', fixEncoderSize(getBytesEncoder(), 32)], - ['finalityThresholdExecuted', fixEncoderSize(getBytesEncoder(), 4)], - ['feeExecuted', fixEncoderSize(getBytesEncoder(), 32)], - ['expirationBlock', fixEncoderSize(getBytesEncoder(), 32)], - ]), - (value) => ({ - ...value, - discriminator: RECLAIM_EVENT_ACCOUNT_DISCRIMINATOR, - }) - ); -} - -export function getReclaimEventAccountInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['attestation', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ['nonce', fixDecoderSize(getBytesDecoder(), 32)], - ['finalityThresholdExecuted', fixDecoderSize(getBytesDecoder(), 4)], - ['feeExecuted', fixDecoderSize(getBytesDecoder(), 32)], - ['expirationBlock', fixDecoderSize(getBytesDecoder(), 32)], - ]); -} - -export function getReclaimEventAccountInstructionDataCodec(): Codec< - ReclaimEventAccountInstructionDataArgs, - ReclaimEventAccountInstructionData -> { - return combineCodec( - getReclaimEventAccountInstructionDataEncoder(), - getReclaimEventAccountInstructionDataDecoder() - ); -} - -export type ReclaimEventAccountAsyncInput< - TAccountRentFund extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - rentFund?: Address; - messageTransmitter: Address; - messageSentEventData: Address; - messageTransmitterProgram?: Address; - eventAuthority?: Address; - program: Address; - attestation: ReclaimEventAccountInstructionDataArgs['attestation']; - nonce: ReclaimEventAccountInstructionDataArgs['nonce']; - finalityThresholdExecuted: ReclaimEventAccountInstructionDataArgs['finalityThresholdExecuted']; - feeExecuted: ReclaimEventAccountInstructionDataArgs['feeExecuted']; - expirationBlock: ReclaimEventAccountInstructionDataArgs['expirationBlock']; -}; - -export async function getReclaimEventAccountInstructionAsync< - TAccountRentFund extends string, - TAccountMessageTransmitter extends string, - TAccountMessageSentEventData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: ReclaimEventAccountAsyncInput< - TAccountRentFund, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - ReclaimEventAccountInstruction< - TProgramAddress, - TAccountRentFund, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - rentFund: { value: input.rentFund ?? null, isWritable: true }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.rentFund.value) { - accounts.rentFund.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([114, 101, 110, 116, 95, 102, 117, 110, 100]) - ), - ], - }); - } - if (!accounts.messageTransmitterProgram.value) { - accounts.messageTransmitterProgram.value = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.rentFund), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getReclaimEventAccountInstructionDataEncoder().encode( - args as ReclaimEventAccountInstructionDataArgs - ), - } as ReclaimEventAccountInstruction< - TProgramAddress, - TAccountRentFund, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ReclaimEventAccountInput< - TAccountRentFund extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - rentFund: Address; - messageTransmitter: Address; - messageSentEventData: Address; - messageTransmitterProgram?: Address; - eventAuthority: Address; - program: Address; - attestation: ReclaimEventAccountInstructionDataArgs['attestation']; - nonce: ReclaimEventAccountInstructionDataArgs['nonce']; - finalityThresholdExecuted: ReclaimEventAccountInstructionDataArgs['finalityThresholdExecuted']; - feeExecuted: ReclaimEventAccountInstructionDataArgs['feeExecuted']; - expirationBlock: ReclaimEventAccountInstructionDataArgs['expirationBlock']; -}; - -export function getReclaimEventAccountInstruction< - TAccountRentFund extends string, - TAccountMessageTransmitter extends string, - TAccountMessageSentEventData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: ReclaimEventAccountInput< - TAccountRentFund, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): ReclaimEventAccountInstruction< - TProgramAddress, - TAccountRentFund, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - rentFund: { value: input.rentFund ?? null, isWritable: true }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.messageTransmitterProgram.value) { - accounts.messageTransmitterProgram.value = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.rentFund), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getReclaimEventAccountInstructionDataEncoder().encode( - args as ReclaimEventAccountInstructionDataArgs - ), - } as ReclaimEventAccountInstruction< - TProgramAddress, - TAccountRentFund, - TAccountMessageTransmitter, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedReclaimEventAccountInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - rentFund: TAccountMetas[0]; - messageTransmitter: TAccountMetas[1]; - messageSentEventData: TAccountMetas[2]; - messageTransmitterProgram: TAccountMetas[3]; - eventAuthority: TAccountMetas[4]; - program: TAccountMetas[5]; - }; - data: ReclaimEventAccountInstructionData; -}; - -export function parseReclaimEventAccountInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedReclaimEventAccountInstruction { - if (instruction.accounts.length < 6) { - // 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: { - rentFund: getNextAccount(), - messageTransmitter: getNextAccount(), - messageSentEventData: getNextAccount(), - messageTransmitterProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getReclaimEventAccountInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimUsedNonceAccount.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimUsedNonceAccount.ts deleted file mode 100644 index ba6101715..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/reclaimUsedNonceAccount.ts +++ /dev/null @@ -1,371 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type WritableAccount, -} from '@solana/kit'; -import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -import { - getUsedNonceAccountParamsDecoder, - getUsedNonceAccountParamsEncoder, - type UsedNonceAccountParams, - type UsedNonceAccountParamsArgs, -} from '../types'; - -export const RECLAIM_USED_NONCE_ACCOUNT_DISCRIMINATOR = new Uint8Array([ - 153, 152, 111, 172, 156, 104, 116, 3, -]); - -export function getReclaimUsedNonceAccountDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - RECLAIM_USED_NONCE_ACCOUNT_DISCRIMINATOR - ); -} - -export type ReclaimUsedNonceAccountInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountState extends string | AccountMeta = string, - TAccountRentFund extends string | AccountMeta = string, - TAccountUsedNonce extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountState extends string - ? ReadonlyAccount - : TAccountState, - TAccountRentFund extends string - ? WritableAccount - : TAccountRentFund, - TAccountUsedNonce extends string - ? WritableAccount - : TAccountUsedNonce, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type ReclaimUsedNonceAccountInstructionData = { - discriminator: ReadonlyUint8Array; - params: UsedNonceAccountParams; -}; - -export type ReclaimUsedNonceAccountInstructionDataArgs = { - params: UsedNonceAccountParamsArgs; -}; - -export function getReclaimUsedNonceAccountInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['params', getUsedNonceAccountParamsEncoder()], - ]), - (value) => ({ - ...value, - discriminator: RECLAIM_USED_NONCE_ACCOUNT_DISCRIMINATOR, - }) - ); -} - -export function getReclaimUsedNonceAccountInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['params', getUsedNonceAccountParamsDecoder()], - ]); -} - -export function getReclaimUsedNonceAccountInstructionDataCodec(): Codec< - ReclaimUsedNonceAccountInstructionDataArgs, - ReclaimUsedNonceAccountInstructionData -> { - return combineCodec( - getReclaimUsedNonceAccountInstructionDataEncoder(), - getReclaimUsedNonceAccountInstructionDataDecoder() - ); -} - -export type ReclaimUsedNonceAccountAsyncInput< - TAccountState extends string = string, - TAccountRentFund extends string = string, - TAccountUsedNonce extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - state?: Address; - rentFund?: Address; - usedNonce: Address; - eventAuthority?: Address; - program: Address; - params: ReclaimUsedNonceAccountInstructionDataArgs['params']; -}; - -export async function getReclaimUsedNonceAccountInstructionAsync< - TAccountState extends string, - TAccountRentFund extends string, - TAccountUsedNonce extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: ReclaimUsedNonceAccountAsyncInput< - TAccountState, - TAccountRentFund, - TAccountUsedNonce, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - ReclaimUsedNonceAccountInstruction< - TProgramAddress, - TAccountState, - TAccountRentFund, - TAccountUsedNonce, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - state: { value: input.state ?? null, isWritable: false }, - rentFund: { value: input.rentFund ?? null, isWritable: true }, - usedNonce: { value: input.usedNonce ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.state.value) { - accounts.state.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), - ], - }); - } - if (!accounts.rentFund.value) { - accounts.rentFund.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([114, 101, 110, 116, 95, 102, 117, 110, 100]) - ), - ], - }); - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.state), - getAccountMeta(accounts.rentFund), - getAccountMeta(accounts.usedNonce), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getReclaimUsedNonceAccountInstructionDataEncoder().encode( - args as ReclaimUsedNonceAccountInstructionDataArgs - ), - } as ReclaimUsedNonceAccountInstruction< - TProgramAddress, - TAccountState, - TAccountRentFund, - TAccountUsedNonce, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ReclaimUsedNonceAccountInput< - TAccountState extends string = string, - TAccountRentFund extends string = string, - TAccountUsedNonce extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - state: Address; - rentFund: Address; - usedNonce: Address; - eventAuthority: Address; - program: Address; - params: ReclaimUsedNonceAccountInstructionDataArgs['params']; -}; - -export function getReclaimUsedNonceAccountInstruction< - TAccountState extends string, - TAccountRentFund extends string, - TAccountUsedNonce extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: ReclaimUsedNonceAccountInput< - TAccountState, - TAccountRentFund, - TAccountUsedNonce, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): ReclaimUsedNonceAccountInstruction< - TProgramAddress, - TAccountState, - TAccountRentFund, - TAccountUsedNonce, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - state: { value: input.state ?? null, isWritable: false }, - rentFund: { value: input.rentFund ?? null, isWritable: true }, - usedNonce: { value: input.usedNonce ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.state), - getAccountMeta(accounts.rentFund), - getAccountMeta(accounts.usedNonce), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getReclaimUsedNonceAccountInstructionDataEncoder().encode( - args as ReclaimUsedNonceAccountInstructionDataArgs - ), - } as ReclaimUsedNonceAccountInstruction< - TProgramAddress, - TAccountState, - TAccountRentFund, - TAccountUsedNonce, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedReclaimUsedNonceAccountInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - state: TAccountMetas[0]; - rentFund: TAccountMetas[1]; - usedNonce: TAccountMetas[2]; - eventAuthority: TAccountMetas[3]; - program: TAccountMetas[4]; - }; - data: ReclaimUsedNonceAccountInstructionData; -}; - -export function parseReclaimUsedNonceAccountInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedReclaimUsedNonceAccountInstruction { - if (instruction.accounts.length < 5) { - // 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: { - state: getNextAccount(), - rentFund: getNextAccount(), - usedNonce: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getReclaimUsedNonceAccountInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/repayRentFundDebt.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/repayRentFundDebt.ts deleted file mode 100644 index efb2eeeb4..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/repayRentFundDebt.ts +++ /dev/null @@ -1,382 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type WritableAccount, -} from '@solana/kit'; -import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const REPAY_RENT_FUND_DEBT_DISCRIMINATOR = new Uint8Array([ - 111, 95, 222, 174, 241, 41, 61, 78, -]); - -export function getRepayRentFundDebtDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - REPAY_RENT_FUND_DEBT_DISCRIMINATOR - ); -} - -export type RepayRentFundDebtInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountRentFund extends string | AccountMeta = string, - TAccountRecipient extends string | AccountMeta = string, - TAccountRentClaim extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountRentFund extends string - ? WritableAccount - : TAccountRentFund, - TAccountRecipient extends string - ? WritableAccount - : TAccountRecipient, - TAccountRentClaim extends string - ? WritableAccount - : TAccountRentClaim, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type RepayRentFundDebtInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type RepayRentFundDebtInstructionDataArgs = {}; - -export function getRepayRentFundDebtInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: REPAY_RENT_FUND_DEBT_DISCRIMINATOR }) - ); -} - -export function getRepayRentFundDebtInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getRepayRentFundDebtInstructionDataCodec(): Codec< - RepayRentFundDebtInstructionDataArgs, - RepayRentFundDebtInstructionData -> { - return combineCodec( - getRepayRentFundDebtInstructionDataEncoder(), - getRepayRentFundDebtInstructionDataDecoder() - ); -} - -export type RepayRentFundDebtAsyncInput< - TAccountRentFund extends string = string, - TAccountRecipient extends string = string, - TAccountRentClaim extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - rentFund?: Address; - recipient: Address; - rentClaim?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getRepayRentFundDebtInstructionAsync< - TAccountRentFund extends string, - TAccountRecipient extends string, - TAccountRentClaim extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: RepayRentFundDebtAsyncInput< - TAccountRentFund, - TAccountRecipient, - TAccountRentClaim, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - RepayRentFundDebtInstruction< - TProgramAddress, - TAccountRentFund, - TAccountRecipient, - TAccountRentClaim, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - rentFund: { value: input.rentFund ?? null, isWritable: true }, - recipient: { value: input.recipient ?? null, isWritable: true }, - rentClaim: { value: input.rentClaim ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.rentFund.value) { - accounts.rentFund.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([114, 101, 110, 116, 95, 102, 117, 110, 100]) - ), - ], - }); - } - if (!accounts.rentClaim.value) { - accounts.rentClaim.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([114, 101, 110, 116, 95, 99, 108, 97, 105, 109]) - ), - getAddressEncoder().encode(expectAddress(accounts.recipient.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.rentFund), - getAccountMeta(accounts.recipient), - getAccountMeta(accounts.rentClaim), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getRepayRentFundDebtInstructionDataEncoder().encode({}), - } as RepayRentFundDebtInstruction< - TProgramAddress, - TAccountRentFund, - TAccountRecipient, - TAccountRentClaim, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type RepayRentFundDebtInput< - TAccountRentFund extends string = string, - TAccountRecipient extends string = string, - TAccountRentClaim extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - rentFund: Address; - recipient: Address; - rentClaim: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; -}; - -export function getRepayRentFundDebtInstruction< - TAccountRentFund extends string, - TAccountRecipient extends string, - TAccountRentClaim extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: RepayRentFundDebtInput< - TAccountRentFund, - TAccountRecipient, - TAccountRentClaim, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): RepayRentFundDebtInstruction< - TProgramAddress, - TAccountRentFund, - TAccountRecipient, - TAccountRentClaim, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - rentFund: { value: input.rentFund ?? null, isWritable: true }, - recipient: { value: input.recipient ?? null, isWritable: true }, - rentClaim: { value: input.rentClaim ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.rentFund), - getAccountMeta(accounts.recipient), - getAccountMeta(accounts.rentClaim), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getRepayRentFundDebtInstructionDataEncoder().encode({}), - } as RepayRentFundDebtInstruction< - TProgramAddress, - TAccountRentFund, - TAccountRecipient, - TAccountRentClaim, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedRepayRentFundDebtInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - rentFund: TAccountMetas[0]; - recipient: TAccountMetas[1]; - rentClaim: TAccountMetas[2]; - systemProgram: TAccountMetas[3]; - eventAuthority: TAccountMetas[4]; - program: TAccountMetas[5]; - }; - data: RepayRentFundDebtInstructionData; -}; - -export function parseRepayRentFundDebtInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedRepayRentFundDebtInstruction { - if (instruction.accounts.length < 6) { - // 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: { - rentFund: getNextAccount(), - recipient: getNextAccount(), - rentClaim: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getRepayRentFundDebtInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setCurrentTime.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setCurrentTime.ts deleted file mode 100644 index 9619a1840..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setCurrentTime.ts +++ /dev/null @@ -1,254 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_CURRENT_TIME_DISCRIMINATOR = new Uint8Array([ - 69, 100, 169, 193, 125, 0, 150, 69, -]); - -export function getSetCurrentTimeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_CURRENT_TIME_DISCRIMINATOR - ); -} - -export type SetCurrentTimeInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountState extends string | AccountMeta = string, - TAccountSigner extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountState extends string - ? WritableAccount - : TAccountState, - TAccountSigner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSigner, - ...TRemainingAccounts, - ] - >; - -export type SetCurrentTimeInstructionData = { - discriminator: ReadonlyUint8Array; - newTime: bigint; -}; - -export type SetCurrentTimeInstructionDataArgs = { newTime: number | bigint }; - -export function getSetCurrentTimeInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newTime', getU64Encoder()], - ]), - (value) => ({ ...value, discriminator: SET_CURRENT_TIME_DISCRIMINATOR }) - ); -} - -export function getSetCurrentTimeInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newTime', getU64Decoder()], - ]); -} - -export function getSetCurrentTimeInstructionDataCodec(): Codec< - SetCurrentTimeInstructionDataArgs, - SetCurrentTimeInstructionData -> { - return combineCodec( - getSetCurrentTimeInstructionDataEncoder(), - getSetCurrentTimeInstructionDataDecoder() - ); -} - -export type SetCurrentTimeAsyncInput< - TAccountState extends string = string, - TAccountSigner extends string = string, -> = { - state?: Address; - signer: TransactionSigner; - newTime: SetCurrentTimeInstructionDataArgs['newTime']; -}; - -export async function getSetCurrentTimeInstructionAsync< - TAccountState extends string, - TAccountSigner extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: SetCurrentTimeAsyncInput, - config?: { programAddress?: TProgramAddress } -): Promise< - SetCurrentTimeInstruction -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - state: { value: input.state ?? null, isWritable: true }, - signer: { value: input.signer ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.state.value) { - accounts.state.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [getAccountMeta(accounts.state), getAccountMeta(accounts.signer)], - programAddress, - data: getSetCurrentTimeInstructionDataEncoder().encode( - args as SetCurrentTimeInstructionDataArgs - ), - } as SetCurrentTimeInstruction< - TProgramAddress, - TAccountState, - TAccountSigner - >; - - return instruction; -} - -export type SetCurrentTimeInput< - TAccountState extends string = string, - TAccountSigner extends string = string, -> = { - state: Address; - signer: TransactionSigner; - newTime: SetCurrentTimeInstructionDataArgs['newTime']; -}; - -export function getSetCurrentTimeInstruction< - TAccountState extends string, - TAccountSigner extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: SetCurrentTimeInput, - config?: { programAddress?: TProgramAddress } -): SetCurrentTimeInstruction { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - state: { value: input.state ?? null, isWritable: true }, - signer: { value: input.signer ?? 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.state), getAccountMeta(accounts.signer)], - programAddress, - data: getSetCurrentTimeInstructionDataEncoder().encode( - args as SetCurrentTimeInstructionDataArgs - ), - } as SetCurrentTimeInstruction< - TProgramAddress, - TAccountState, - TAccountSigner - >; - - return instruction; -} - -export type ParsedSetCurrentTimeInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - state: TAccountMetas[0]; - signer: TAccountMetas[1]; - }; - data: SetCurrentTimeInstructionData; -}; - -export function parseSetCurrentTimeInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetCurrentTimeInstruction { - if (instruction.accounts.length < 2) { - // 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: { - state: getNextAccount(), - signer: getNextAccount(), - }, - data: getSetCurrentTimeInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setMinimumDepositAmount.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setMinimumDepositAmount.ts deleted file mode 100644 index 12db886ec..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setMinimumDepositAmount.ts +++ /dev/null @@ -1,401 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const SET_MINIMUM_DEPOSIT_AMOUNT_DISCRIMINATOR = new Uint8Array([ - 176, 4, 74, 229, 206, 148, 151, 138, -]); - -export function getSetMinimumDepositAmountDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_MINIMUM_DEPOSIT_AMOUNT_DISCRIMINATOR - ); -} - -export type SetMinimumDepositAmountInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountMinimumDeposit extends string | AccountMeta = string, - TAccountBurnToken extends string | AccountMeta = string, - TAccountProgramData extends string | AccountMeta = string, - TAccountThisProgram extends string | AccountMeta = - 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountMinimumDeposit extends string - ? WritableAccount - : TAccountMinimumDeposit, - TAccountBurnToken extends string - ? ReadonlyAccount - : TAccountBurnToken, - TAccountProgramData extends string - ? ReadonlyAccount - : TAccountProgramData, - TAccountThisProgram extends string - ? ReadonlyAccount - : TAccountThisProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type SetMinimumDepositAmountInstructionData = { - discriminator: ReadonlyUint8Array; - amount: bigint; -}; - -export type SetMinimumDepositAmountInstructionDataArgs = { - amount: number | bigint; -}; - -export function getSetMinimumDepositAmountInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['amount', getU64Encoder()], - ]), - (value) => ({ - ...value, - discriminator: SET_MINIMUM_DEPOSIT_AMOUNT_DISCRIMINATOR, - }) - ); -} - -export function getSetMinimumDepositAmountInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['amount', getU64Decoder()], - ]); -} - -export function getSetMinimumDepositAmountInstructionDataCodec(): Codec< - SetMinimumDepositAmountInstructionDataArgs, - SetMinimumDepositAmountInstructionData -> { - return combineCodec( - getSetMinimumDepositAmountInstructionDataEncoder(), - getSetMinimumDepositAmountInstructionDataDecoder() - ); -} - -export type SetMinimumDepositAmountAsyncInput< - TAccountSigner extends string = string, - TAccountMinimumDeposit extends string = string, - TAccountBurnToken extends string = string, - TAccountProgramData extends string = string, - TAccountThisProgram extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - minimumDeposit?: Address; - burnToken: Address; - programData: Address; - thisProgram?: Address; - systemProgram?: Address; - amount: SetMinimumDepositAmountInstructionDataArgs['amount']; -}; - -export async function getSetMinimumDepositAmountInstructionAsync< - TAccountSigner extends string, - TAccountMinimumDeposit extends string, - TAccountBurnToken extends string, - TAccountProgramData extends string, - TAccountThisProgram extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: SetMinimumDepositAmountAsyncInput< - TAccountSigner, - TAccountMinimumDeposit, - TAccountBurnToken, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - SetMinimumDepositAmountInstruction< - TProgramAddress, - TAccountSigner, - TAccountMinimumDeposit, - TAccountBurnToken, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - minimumDeposit: { value: input.minimumDeposit ?? null, isWritable: true }, - burnToken: { value: input.burnToken ?? null, isWritable: false }, - programData: { value: input.programData ?? null, isWritable: false }, - thisProgram: { value: input.thisProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.minimumDeposit.value) { - accounts.minimumDeposit.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 109, 105, 110, 105, 109, 117, 109, 95, 100, 101, 112, 111, 115, 105, - 116, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.burnToken.value)), - ], - }); - } - if (!accounts.thisProgram.value) { - accounts.thisProgram.value = - 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.minimumDeposit), - getAccountMeta(accounts.burnToken), - getAccountMeta(accounts.programData), - getAccountMeta(accounts.thisProgram), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getSetMinimumDepositAmountInstructionDataEncoder().encode( - args as SetMinimumDepositAmountInstructionDataArgs - ), - } as SetMinimumDepositAmountInstruction< - TProgramAddress, - TAccountSigner, - TAccountMinimumDeposit, - TAccountBurnToken, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - >; - - return instruction; -} - -export type SetMinimumDepositAmountInput< - TAccountSigner extends string = string, - TAccountMinimumDeposit extends string = string, - TAccountBurnToken extends string = string, - TAccountProgramData extends string = string, - TAccountThisProgram extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - minimumDeposit: Address; - burnToken: Address; - programData: Address; - thisProgram?: Address; - systemProgram?: Address; - amount: SetMinimumDepositAmountInstructionDataArgs['amount']; -}; - -export function getSetMinimumDepositAmountInstruction< - TAccountSigner extends string, - TAccountMinimumDeposit extends string, - TAccountBurnToken extends string, - TAccountProgramData extends string, - TAccountThisProgram extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: SetMinimumDepositAmountInput< - TAccountSigner, - TAccountMinimumDeposit, - TAccountBurnToken, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): SetMinimumDepositAmountInstruction< - TProgramAddress, - TAccountSigner, - TAccountMinimumDeposit, - TAccountBurnToken, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - minimumDeposit: { value: input.minimumDeposit ?? null, isWritable: true }, - burnToken: { value: input.burnToken ?? null, isWritable: false }, - programData: { value: input.programData ?? null, isWritable: false }, - thisProgram: { value: input.thisProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.thisProgram.value) { - accounts.thisProgram.value = - 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.minimumDeposit), - getAccountMeta(accounts.burnToken), - getAccountMeta(accounts.programData), - getAccountMeta(accounts.thisProgram), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getSetMinimumDepositAmountInstructionDataEncoder().encode( - args as SetMinimumDepositAmountInstructionDataArgs - ), - } as SetMinimumDepositAmountInstruction< - TProgramAddress, - TAccountSigner, - TAccountMinimumDeposit, - TAccountBurnToken, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedSetMinimumDepositAmountInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - minimumDeposit: TAccountMetas[1]; - burnToken: TAccountMetas[2]; - programData: TAccountMetas[3]; - thisProgram: TAccountMetas[4]; - systemProgram: TAccountMetas[5]; - }; - data: SetMinimumDepositAmountInstructionData; -}; - -export function parseSetMinimumDepositAmountInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetMinimumDepositAmountInstruction { - if (instruction.accounts.length < 6) { - // 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: { - signer: getNextAccount(), - minimumDeposit: getNextAccount(), - burnToken: getNextAccount(), - programData: getNextAccount(), - thisProgram: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getSetMinimumDepositAmountInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setSigner.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setSigner.ts deleted file mode 100644 index 185ebfe5f..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/setSigner.ts +++ /dev/null @@ -1,328 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_SIGNER_DISCRIMINATOR = new Uint8Array([ - 127, 120, 252, 184, 97, 4, 88, 68, -]); - -export function getSetSignerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(SET_SIGNER_DISCRIMINATOR); -} - -export type SetSignerInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountProgramData extends string | AccountMeta = string, - TAccountThisProgram extends string | AccountMeta = - 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountState extends string - ? WritableAccount - : TAccountState, - TAccountProgramData extends string - ? ReadonlyAccount - : TAccountProgramData, - TAccountThisProgram extends string - ? ReadonlyAccount - : TAccountThisProgram, - ...TRemainingAccounts, - ] - >; - -export type SetSignerInstructionData = { - discriminator: ReadonlyUint8Array; - newSigner: Address; -}; - -export type SetSignerInstructionDataArgs = { newSigner: Address }; - -export function getSetSignerInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newSigner', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: SET_SIGNER_DISCRIMINATOR }) - ); -} - -export function getSetSignerInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newSigner', getAddressDecoder()], - ]); -} - -export function getSetSignerInstructionDataCodec(): Codec< - SetSignerInstructionDataArgs, - SetSignerInstructionData -> { - return combineCodec( - getSetSignerInstructionDataEncoder(), - getSetSignerInstructionDataDecoder() - ); -} - -export type SetSignerAsyncInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountProgramData extends string = string, - TAccountThisProgram extends string = string, -> = { - signer: TransactionSigner; - state?: Address; - programData: Address; - thisProgram?: Address; - newSigner: SetSignerInstructionDataArgs['newSigner']; -}; - -export async function getSetSignerInstructionAsync< - TAccountSigner extends string, - TAccountState extends string, - TAccountProgramData extends string, - TAccountThisProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: SetSignerAsyncInput< - TAccountSigner, - TAccountState, - TAccountProgramData, - TAccountThisProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - SetSignerInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountProgramData, - TAccountThisProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - programData: { value: input.programData ?? null, isWritable: false }, - thisProgram: { value: input.thisProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.state.value) { - accounts.state.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), - ], - }); - } - if (!accounts.thisProgram.value) { - accounts.thisProgram.value = - 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.programData), - getAccountMeta(accounts.thisProgram), - ], - programAddress, - data: getSetSignerInstructionDataEncoder().encode( - args as SetSignerInstructionDataArgs - ), - } as SetSignerInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountProgramData, - TAccountThisProgram - >; - - return instruction; -} - -export type SetSignerInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountProgramData extends string = string, - TAccountThisProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - programData: Address; - thisProgram?: Address; - newSigner: SetSignerInstructionDataArgs['newSigner']; -}; - -export function getSetSignerInstruction< - TAccountSigner extends string, - TAccountState extends string, - TAccountProgramData extends string, - TAccountThisProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: SetSignerInput< - TAccountSigner, - TAccountState, - TAccountProgramData, - TAccountThisProgram - >, - config?: { programAddress?: TProgramAddress } -): SetSignerInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountProgramData, - TAccountThisProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - programData: { value: input.programData ?? null, isWritable: false }, - thisProgram: { value: input.thisProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.thisProgram.value) { - accounts.thisProgram.value = - 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.programData), - getAccountMeta(accounts.thisProgram), - ], - programAddress, - data: getSetSignerInstructionDataEncoder().encode( - args as SetSignerInstructionDataArgs - ), - } as SetSignerInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountProgramData, - TAccountThisProgram - >; - - return instruction; -} - -export type ParsedSetSignerInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - state: TAccountMetas[1]; - programData: TAccountMetas[2]; - thisProgram: TAccountMetas[3]; - }; - data: SetSignerInstructionData; -}; - -export function parseSetSignerInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetSignerInstruction { - if (instruction.accounts.length < 4) { - // 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: { - signer: getNextAccount(), - state: getNextAccount(), - programData: getNextAccount(), - thisProgram: getNextAccount(), - }, - data: getSetSignerInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/withdrawRentFund.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/withdrawRentFund.ts deleted file mode 100644 index 1e07191ec..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/instructions/withdrawRentFund.ts +++ /dev/null @@ -1,385 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const WITHDRAW_RENT_FUND_DISCRIMINATOR = new Uint8Array([ - 153, 28, 108, 116, 132, 70, 161, 125, -]); - -export function getWithdrawRentFundDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - WITHDRAW_RENT_FUND_DISCRIMINATOR - ); -} - -export type WithdrawRentFundInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountRentFund extends string | AccountMeta = string, - TAccountRecipient extends string | AccountMeta = string, - TAccountProgramData extends string | AccountMeta = string, - TAccountThisProgram extends string | AccountMeta = - 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountRentFund extends string - ? WritableAccount - : TAccountRentFund, - TAccountRecipient extends string - ? WritableAccount - : TAccountRecipient, - TAccountProgramData extends string - ? ReadonlyAccount - : TAccountProgramData, - TAccountThisProgram extends string - ? ReadonlyAccount - : TAccountThisProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type WithdrawRentFundInstructionData = { - discriminator: ReadonlyUint8Array; - amount: bigint; -}; - -export type WithdrawRentFundInstructionDataArgs = { amount: number | bigint }; - -export function getWithdrawRentFundInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['amount', getU64Encoder()], - ]), - (value) => ({ ...value, discriminator: WITHDRAW_RENT_FUND_DISCRIMINATOR }) - ); -} - -export function getWithdrawRentFundInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['amount', getU64Decoder()], - ]); -} - -export function getWithdrawRentFundInstructionDataCodec(): Codec< - WithdrawRentFundInstructionDataArgs, - WithdrawRentFundInstructionData -> { - return combineCodec( - getWithdrawRentFundInstructionDataEncoder(), - getWithdrawRentFundInstructionDataDecoder() - ); -} - -export type WithdrawRentFundAsyncInput< - TAccountSigner extends string = string, - TAccountRentFund extends string = string, - TAccountRecipient extends string = string, - TAccountProgramData extends string = string, - TAccountThisProgram extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - rentFund?: Address; - recipient: Address; - programData: Address; - thisProgram?: Address; - systemProgram?: Address; - amount: WithdrawRentFundInstructionDataArgs['amount']; -}; - -export async function getWithdrawRentFundInstructionAsync< - TAccountSigner extends string, - TAccountRentFund extends string, - TAccountRecipient extends string, - TAccountProgramData extends string, - TAccountThisProgram extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: WithdrawRentFundAsyncInput< - TAccountSigner, - TAccountRentFund, - TAccountRecipient, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - WithdrawRentFundInstruction< - TProgramAddress, - TAccountSigner, - TAccountRentFund, - TAccountRecipient, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - rentFund: { value: input.rentFund ?? null, isWritable: true }, - recipient: { value: input.recipient ?? null, isWritable: true }, - programData: { value: input.programData ?? null, isWritable: false }, - thisProgram: { value: input.thisProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.rentFund.value) { - accounts.rentFund.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([114, 101, 110, 116, 95, 102, 117, 110, 100]) - ), - ], - }); - } - if (!accounts.thisProgram.value) { - accounts.thisProgram.value = - 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.rentFund), - getAccountMeta(accounts.recipient), - getAccountMeta(accounts.programData), - getAccountMeta(accounts.thisProgram), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getWithdrawRentFundInstructionDataEncoder().encode( - args as WithdrawRentFundInstructionDataArgs - ), - } as WithdrawRentFundInstruction< - TProgramAddress, - TAccountSigner, - TAccountRentFund, - TAccountRecipient, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - >; - - return instruction; -} - -export type WithdrawRentFundInput< - TAccountSigner extends string = string, - TAccountRentFund extends string = string, - TAccountRecipient extends string = string, - TAccountProgramData extends string = string, - TAccountThisProgram extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - rentFund: Address; - recipient: Address; - programData: Address; - thisProgram?: Address; - systemProgram?: Address; - amount: WithdrawRentFundInstructionDataArgs['amount']; -}; - -export function getWithdrawRentFundInstruction< - TAccountSigner extends string, - TAccountRentFund extends string, - TAccountRecipient extends string, - TAccountProgramData extends string, - TAccountThisProgram extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = - typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, ->( - input: WithdrawRentFundInput< - TAccountSigner, - TAccountRentFund, - TAccountRecipient, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): WithdrawRentFundInstruction< - TProgramAddress, - TAccountSigner, - TAccountRentFund, - TAccountRecipient, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - rentFund: { value: input.rentFund ?? null, isWritable: true }, - recipient: { value: input.recipient ?? null, isWritable: true }, - programData: { value: input.programData ?? null, isWritable: false }, - thisProgram: { value: input.thisProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.thisProgram.value) { - accounts.thisProgram.value = - 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.rentFund), - getAccountMeta(accounts.recipient), - getAccountMeta(accounts.programData), - getAccountMeta(accounts.thisProgram), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getWithdrawRentFundInstructionDataEncoder().encode( - args as WithdrawRentFundInstructionDataArgs - ), - } as WithdrawRentFundInstruction< - TProgramAddress, - TAccountSigner, - TAccountRentFund, - TAccountRecipient, - TAccountProgramData, - TAccountThisProgram, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedWithdrawRentFundInstruction< - TProgram extends string = typeof SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - rentFund: TAccountMetas[1]; - recipient: TAccountMetas[2]; - programData: TAccountMetas[3]; - thisProgram: TAccountMetas[4]; - systemProgram: TAccountMetas[5]; - }; - data: WithdrawRentFundInstructionData; -}; - -export function parseWithdrawRentFundInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedWithdrawRentFundInstruction { - if (instruction.accounts.length < 6) { - // 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: { - signer: getNextAccount(), - rentFund: getNextAccount(), - recipient: getNextAccount(), - programData: getNextAccount(), - thisProgram: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getWithdrawRentFundInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/programs/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/programs/index.ts deleted file mode 100644 index b022681a8..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/programs/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './sponsoredCctpSrcPeriphery'; diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/programs/sponsoredCctpSrcPeriphery.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/programs/sponsoredCctpSrcPeriphery.ts deleted file mode 100644 index 31734df44..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/programs/sponsoredCctpSrcPeriphery.ts +++ /dev/null @@ -1,268 +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/kit'; -import { - type ParsedDepositForBurnInstruction, - type ParsedGetUsedNonceCloseInfoInstruction, - type ParsedInitializeInstruction, - type ParsedReclaimEventAccountInstruction, - type ParsedReclaimUsedNonceAccountInstruction, - type ParsedRepayRentFundDebtInstruction, - type ParsedSetCurrentTimeInstruction, - type ParsedSetMinimumDepositAmountInstruction, - type ParsedSetSignerInstruction, - type ParsedWithdrawRentFundInstruction, -} from '../instructions'; - -export const SPONSORED_CCTP_SRC_PERIPHERY_PROGRAM_ADDRESS = - 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq' as Address<'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq'>; - -export enum SponsoredCctpSrcPeripheryAccount { - MessageSent, - MinimumDeposit, - RentClaim, - State, - UsedNonce, -} - -export function identifySponsoredCctpSrcPeripheryAccount( - account: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): SponsoredCctpSrcPeripheryAccount { - const data = 'data' in account ? account.data : account; - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([131, 100, 133, 56, 166, 225, 151, 60]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryAccount.MessageSent; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([218, 139, 120, 202, 3, 12, 233, 65]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryAccount.MinimumDeposit; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([13, 5, 183, 82, 60, 122, 72, 11]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryAccount.RentClaim; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([216, 146, 107, 94, 104, 75, 182, 177]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryAccount.State; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([212, 222, 157, 252, 130, 71, 179, 238]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryAccount.UsedNonce; - } - throw new Error( - 'The provided account could not be identified as a sponsoredCctpSrcPeriphery account.' - ); -} - -export enum SponsoredCctpSrcPeripheryInstruction { - DepositForBurn, - GetUsedNonceCloseInfo, - Initialize, - ReclaimEventAccount, - ReclaimUsedNonceAccount, - RepayRentFundDebt, - SetCurrentTime, - SetMinimumDepositAmount, - SetSigner, - WithdrawRentFund, -} - -export function identifySponsoredCctpSrcPeripheryInstruction( - instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): SponsoredCctpSrcPeripheryInstruction { - const data = 'data' in instruction ? instruction.data : instruction; - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([215, 60, 61, 46, 114, 55, 128, 176]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryInstruction.DepositForBurn; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([19, 183, 42, 151, 118, 234, 57, 92]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryInstruction.GetUsedNonceCloseInfo; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryInstruction.Initialize; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([94, 198, 180, 159, 131, 236, 15, 174]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryInstruction.ReclaimEventAccount; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([153, 152, 111, 172, 156, 104, 116, 3]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryInstruction.ReclaimUsedNonceAccount; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([111, 95, 222, 174, 241, 41, 61, 78]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryInstruction.RepayRentFundDebt; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([69, 100, 169, 193, 125, 0, 150, 69]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryInstruction.SetCurrentTime; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([176, 4, 74, 229, 206, 148, 151, 138]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryInstruction.SetMinimumDepositAmount; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([127, 120, 252, 184, 97, 4, 88, 68]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryInstruction.SetSigner; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([153, 28, 108, 116, 132, 70, 161, 125]) - ), - 0 - ) - ) { - return SponsoredCctpSrcPeripheryInstruction.WithdrawRentFund; - } - throw new Error( - 'The provided instruction could not be identified as a sponsoredCctpSrcPeriphery instruction.' - ); -} - -export type ParsedSponsoredCctpSrcPeripheryInstruction< - TProgram extends string = 'CPr4bRvkVKcSCLyrQpkZrRrwGzQeVAXutFU8WupuBLXq', -> = - | ({ - instructionType: SponsoredCctpSrcPeripheryInstruction.DepositForBurn; - } & ParsedDepositForBurnInstruction) - | ({ - instructionType: SponsoredCctpSrcPeripheryInstruction.GetUsedNonceCloseInfo; - } & ParsedGetUsedNonceCloseInfoInstruction) - | ({ - instructionType: SponsoredCctpSrcPeripheryInstruction.Initialize; - } & ParsedInitializeInstruction) - | ({ - instructionType: SponsoredCctpSrcPeripheryInstruction.ReclaimEventAccount; - } & ParsedReclaimEventAccountInstruction) - | ({ - instructionType: SponsoredCctpSrcPeripheryInstruction.ReclaimUsedNonceAccount; - } & ParsedReclaimUsedNonceAccountInstruction) - | ({ - instructionType: SponsoredCctpSrcPeripheryInstruction.RepayRentFundDebt; - } & ParsedRepayRentFundDebtInstruction) - | ({ - instructionType: SponsoredCctpSrcPeripheryInstruction.SetCurrentTime; - } & ParsedSetCurrentTimeInstruction) - | ({ - instructionType: SponsoredCctpSrcPeripheryInstruction.SetMinimumDepositAmount; - } & ParsedSetMinimumDepositAmountInstruction) - | ({ - instructionType: SponsoredCctpSrcPeripheryInstruction.SetSigner; - } & ParsedSetSignerInstruction) - | ({ - instructionType: SponsoredCctpSrcPeripheryInstruction.WithdrawRentFund; - } & ParsedWithdrawRentFundInstruction); diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/shared/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/shared/index.ts deleted file mode 100644 index 7ebc26514..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/shared/index.ts +++ /dev/null @@ -1,164 +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 { - AccountRole, - isProgramDerivedAddress, - isTransactionSigner as kitIsTransactionSigner, - type AccountMeta, - type AccountSignerMeta, - type Address, - type ProgramDerivedAddress, - type TransactionSigner, - upgradeRoleToSigner, -} from '@solana/kit'; - -/** - * Asserts that the given value is not null or undefined. - * @internal - */ -export function expectSome(value: T | null | undefined): T { - if (value == null) { - throw new Error('Expected a value but received null or undefined.'); - } - return value; -} - -/** - * Asserts that the given value is a PublicKey. - * @internal - */ -export function expectAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): Address { - if (!value) { - throw new Error('Expected a Address.'); - } - if (typeof value === 'object' && 'address' in value) { - return value.address; - } - if (Array.isArray(value)) { - return value[0]; - } - return value as Address; -} - -/** - * Asserts that the given value is a PDA. - * @internal - */ -export function expectProgramDerivedAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): ProgramDerivedAddress { - if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { - throw new Error('Expected a ProgramDerivedAddress.'); - } - return value; -} - -/** - * Asserts that the given value is a TransactionSigner. - * @internal - */ -export function expectTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): TransactionSigner { - if (!value || !isTransactionSigner(value)) { - throw new Error('Expected a TransactionSigner.'); - } - return value; -} - -/** - * Defines an instruction account to resolve. - * @internal - */ -export type ResolvedAccount< - T extends string = string, - U extends - | Address - | ProgramDerivedAddress - | TransactionSigner - | null = - | Address - | ProgramDerivedAddress - | TransactionSigner - | null, -> = { - isWritable: boolean; - value: U; -}; - -/** - * Defines an instruction that stores additional bytes on-chain. - * @internal - */ -export type InstructionWithByteDelta = { - byteDelta: number; -}; - -/** - * Get account metas and signers from resolved accounts. - * @internal - */ -export function getAccountMetaFactory( - programAddress: Address, - optionalAccountStrategy: 'omitted' | 'programId' -) { - return ( - account: ResolvedAccount - ): AccountMeta | AccountSignerMeta | undefined => { - if (!account.value) { - if (optionalAccountStrategy === 'omitted') return; - return Object.freeze({ - address: programAddress, - role: AccountRole.READONLY, - }); - } - - const writableRole = account.isWritable - ? AccountRole.WRITABLE - : AccountRole.READONLY; - return Object.freeze({ - address: expectAddress(account.value), - role: isTransactionSigner(account.value) - ? upgradeRoleToSigner(writableRole) - : writableRole, - ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), - }); - }; -} - -export function isTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner -): value is TransactionSigner { - return ( - !!value && - typeof value === 'object' && - 'address' in value && - kitIsTransactionSigner(value) - ); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/accruedRentFundLiability.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/accruedRentFundLiability.ts deleted file mode 100644 index ee41776c4..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/types/accruedRentFundLiability.ts +++ /dev/null @@ -1,59 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type AccruedRentFundLiability = { - user: Address; - amount: bigint; - totalUserClaim: bigint; -}; - -export type AccruedRentFundLiabilityArgs = { - user: Address; - amount: number | bigint; - totalUserClaim: number | bigint; -}; - -export function getAccruedRentFundLiabilityEncoder(): Encoder { - return getStructEncoder([ - ['user', getAddressEncoder()], - ['amount', getU64Encoder()], - ['totalUserClaim', getU64Encoder()], - ]); -} - -export function getAccruedRentFundLiabilityDecoder(): Decoder { - return getStructDecoder([ - ['user', getAddressDecoder()], - ['amount', getU64Decoder()], - ['totalUserClaim', getU64Decoder()], - ]); -} - -export function getAccruedRentFundLiabilityCodec(): Codec< - AccruedRentFundLiabilityArgs, - AccruedRentFundLiability -> { - return combineCodec( - getAccruedRentFundLiabilityEncoder(), - getAccruedRentFundLiabilityDecoder() - ); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/createdEventAccount.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/createdEventAccount.ts deleted file mode 100644 index bcc7959b4..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/types/createdEventAccount.ts +++ /dev/null @@ -1,41 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type CreatedEventAccount = { messageSentEventData: Address }; - -export type CreatedEventAccountArgs = CreatedEventAccount; - -export function getCreatedEventAccountEncoder(): Encoder { - return getStructEncoder([['messageSentEventData', getAddressEncoder()]]); -} - -export function getCreatedEventAccountDecoder(): Decoder { - return getStructDecoder([['messageSentEventData', getAddressDecoder()]]); -} - -export function getCreatedEventAccountCodec(): Codec< - CreatedEventAccountArgs, - CreatedEventAccount -> { - return combineCodec( - getCreatedEventAccountEncoder(), - getCreatedEventAccountDecoder() - ); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/index.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/index.ts deleted file mode 100644 index e130d5b74..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/types/index.ts +++ /dev/null @@ -1,20 +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 - */ - -export * from './accruedRentFundLiability'; -export * from './createdEventAccount'; -export * from './minimumDepositAmountSet'; -export * from './reclaimedEventAccount'; -export * from './reclaimedUsedNonceAccount'; -export * from './repaidRentFundDebt'; -export * from './signerSet'; -export * from './sponsoredCCTPQuote'; -export * from './sponsoredDepositForBurn'; -export * from './usedNonceAccountParams'; -export * from './usedNonceCloseInfo'; -export * from './withdrawnRentFund'; diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/minimumDepositAmountSet.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/minimumDepositAmountSet.ts deleted file mode 100644 index d19d6d04c..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/types/minimumDepositAmountSet.ts +++ /dev/null @@ -1,52 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type MinimumDepositAmountSet = { amount: bigint; burnToken: Address }; - -export type MinimumDepositAmountSetArgs = { - amount: number | bigint; - burnToken: Address; -}; - -export function getMinimumDepositAmountSetEncoder(): Encoder { - return getStructEncoder([ - ['amount', getU64Encoder()], - ['burnToken', getAddressEncoder()], - ]); -} - -export function getMinimumDepositAmountSetDecoder(): Decoder { - return getStructDecoder([ - ['amount', getU64Decoder()], - ['burnToken', getAddressDecoder()], - ]); -} - -export function getMinimumDepositAmountSetCodec(): Codec< - MinimumDepositAmountSetArgs, - MinimumDepositAmountSet -> { - return combineCodec( - getMinimumDepositAmountSetEncoder(), - getMinimumDepositAmountSetDecoder() - ); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedEventAccount.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedEventAccount.ts deleted file mode 100644 index 1acb1b219..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedEventAccount.ts +++ /dev/null @@ -1,41 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type ReclaimedEventAccount = { messageSentEventData: Address }; - -export type ReclaimedEventAccountArgs = ReclaimedEventAccount; - -export function getReclaimedEventAccountEncoder(): Encoder { - return getStructEncoder([['messageSentEventData', getAddressEncoder()]]); -} - -export function getReclaimedEventAccountDecoder(): Decoder { - return getStructDecoder([['messageSentEventData', getAddressDecoder()]]); -} - -export function getReclaimedEventAccountCodec(): Codec< - ReclaimedEventAccountArgs, - ReclaimedEventAccount -> { - return combineCodec( - getReclaimedEventAccountEncoder(), - getReclaimedEventAccountDecoder() - ); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedUsedNonceAccount.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedUsedNonceAccount.ts deleted file mode 100644 index 160ef570e..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/types/reclaimedUsedNonceAccount.ts +++ /dev/null @@ -1,57 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export type ReclaimedUsedNonceAccount = { - nonce: ReadonlyUint8Array; - usedNonce: Address; -}; - -export type ReclaimedUsedNonceAccountArgs = ReclaimedUsedNonceAccount; - -export function getReclaimedUsedNonceAccountEncoder(): Encoder { - return getStructEncoder([ - ['nonce', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ['usedNonce', getAddressEncoder()], - ]); -} - -export function getReclaimedUsedNonceAccountDecoder(): Decoder { - return getStructDecoder([ - ['nonce', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ['usedNonce', getAddressDecoder()], - ]); -} - -export function getReclaimedUsedNonceAccountCodec(): Codec< - ReclaimedUsedNonceAccountArgs, - ReclaimedUsedNonceAccount -> { - return combineCodec( - getReclaimedUsedNonceAccountEncoder(), - getReclaimedUsedNonceAccountDecoder() - ); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/repaidRentFundDebt.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/repaidRentFundDebt.ts deleted file mode 100644 index 1b4c6ae60..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/types/repaidRentFundDebt.ts +++ /dev/null @@ -1,59 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type RepaidRentFundDebt = { - user: Address; - amount: bigint; - remainingUserClaim: bigint; -}; - -export type RepaidRentFundDebtArgs = { - user: Address; - amount: number | bigint; - remainingUserClaim: number | bigint; -}; - -export function getRepaidRentFundDebtEncoder(): Encoder { - return getStructEncoder([ - ['user', getAddressEncoder()], - ['amount', getU64Encoder()], - ['remainingUserClaim', getU64Encoder()], - ]); -} - -export function getRepaidRentFundDebtDecoder(): Decoder { - return getStructDecoder([ - ['user', getAddressDecoder()], - ['amount', getU64Decoder()], - ['remainingUserClaim', getU64Decoder()], - ]); -} - -export function getRepaidRentFundDebtCodec(): Codec< - RepaidRentFundDebtArgs, - RepaidRentFundDebt -> { - return combineCodec( - getRepaidRentFundDebtEncoder(), - getRepaidRentFundDebtDecoder() - ); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/signerSet.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/signerSet.ts deleted file mode 100644 index 125210729..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/types/signerSet.ts +++ /dev/null @@ -1,41 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type SignerSet = { oldSigner: Address; newSigner: Address }; - -export type SignerSetArgs = SignerSet; - -export function getSignerSetEncoder(): Encoder { - return getStructEncoder([ - ['oldSigner', getAddressEncoder()], - ['newSigner', getAddressEncoder()], - ]); -} - -export function getSignerSetDecoder(): Decoder { - return getStructDecoder([ - ['oldSigner', getAddressDecoder()], - ['newSigner', getAddressDecoder()], - ]); -} - -export function getSignerSetCodec(): Codec { - return combineCodec(getSignerSetEncoder(), getSignerSetDecoder()); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredCCTPQuote.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredCCTPQuote.ts deleted file mode 100644 index 4dc544223..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredCCTPQuote.ts +++ /dev/null @@ -1,130 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - getU8Decoder, - getU8Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export type SponsoredCCTPQuote = { - sourceDomain: number; - destinationDomain: number; - mintRecipient: Address; - amount: bigint; - burnToken: Address; - destinationCaller: Address; - maxFee: bigint; - minFinalityThreshold: number; - nonce: ReadonlyUint8Array; - deadline: bigint; - maxBpsToSponsor: bigint; - maxUserSlippageBps: bigint; - finalRecipient: Address; - finalToken: Address; - destinationDex: number; - accountCreationMode: number; - executionMode: number; - actionData: ReadonlyUint8Array; -}; - -export type SponsoredCCTPQuoteArgs = { - sourceDomain: number; - destinationDomain: number; - mintRecipient: Address; - amount: number | bigint; - burnToken: Address; - destinationCaller: Address; - maxFee: number | bigint; - minFinalityThreshold: number; - nonce: ReadonlyUint8Array; - deadline: number | bigint; - maxBpsToSponsor: number | bigint; - maxUserSlippageBps: number | bigint; - finalRecipient: Address; - finalToken: Address; - destinationDex: number; - accountCreationMode: number; - executionMode: number; - actionData: ReadonlyUint8Array; -}; - -export function getSponsoredCCTPQuoteEncoder(): Encoder { - return getStructEncoder([ - ['sourceDomain', getU32Encoder()], - ['destinationDomain', getU32Encoder()], - ['mintRecipient', getAddressEncoder()], - ['amount', getU64Encoder()], - ['burnToken', getAddressEncoder()], - ['destinationCaller', getAddressEncoder()], - ['maxFee', getU64Encoder()], - ['minFinalityThreshold', getU32Encoder()], - ['nonce', fixEncoderSize(getBytesEncoder(), 32)], - ['deadline', getU64Encoder()], - ['maxBpsToSponsor', getU64Encoder()], - ['maxUserSlippageBps', getU64Encoder()], - ['finalRecipient', getAddressEncoder()], - ['finalToken', getAddressEncoder()], - ['destinationDex', getU32Encoder()], - ['accountCreationMode', getU8Encoder()], - ['executionMode', getU8Encoder()], - ['actionData', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]); -} - -export function getSponsoredCCTPQuoteDecoder(): Decoder { - return getStructDecoder([ - ['sourceDomain', getU32Decoder()], - ['destinationDomain', getU32Decoder()], - ['mintRecipient', getAddressDecoder()], - ['amount', getU64Decoder()], - ['burnToken', getAddressDecoder()], - ['destinationCaller', getAddressDecoder()], - ['maxFee', getU64Decoder()], - ['minFinalityThreshold', getU32Decoder()], - ['nonce', fixDecoderSize(getBytesDecoder(), 32)], - ['deadline', getU64Decoder()], - ['maxBpsToSponsor', getU64Decoder()], - ['maxUserSlippageBps', getU64Decoder()], - ['finalRecipient', getAddressDecoder()], - ['finalToken', getAddressDecoder()], - ['destinationDex', getU32Decoder()], - ['accountCreationMode', getU8Decoder()], - ['executionMode', getU8Decoder()], - ['actionData', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getSponsoredCCTPQuoteCodec(): Codec< - SponsoredCCTPQuoteArgs, - SponsoredCCTPQuote -> { - return combineCodec( - getSponsoredCCTPQuoteEncoder(), - getSponsoredCCTPQuoteDecoder() - ); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredDepositForBurn.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredDepositForBurn.ts deleted file mode 100644 index 0317ee5ea..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/types/sponsoredDepositForBurn.ts +++ /dev/null @@ -1,96 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - getU8Decoder, - getU8Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export type SponsoredDepositForBurn = { - quoteNonce: ReadonlyUint8Array; - originSender: Address; - finalRecipient: Address; - quoteDeadline: bigint; - maxBpsToSponsor: bigint; - maxUserSlippageBps: bigint; - finalToken: Address; - destinationDex: number; - accountCreationMode: number; - signature: ReadonlyUint8Array; -}; - -export type SponsoredDepositForBurnArgs = { - quoteNonce: ReadonlyUint8Array; - originSender: Address; - finalRecipient: Address; - quoteDeadline: number | bigint; - maxBpsToSponsor: number | bigint; - maxUserSlippageBps: number | bigint; - finalToken: Address; - destinationDex: number; - accountCreationMode: number; - signature: ReadonlyUint8Array; -}; - -export function getSponsoredDepositForBurnEncoder(): Encoder { - return getStructEncoder([ - ['quoteNonce', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ['originSender', getAddressEncoder()], - ['finalRecipient', getAddressEncoder()], - ['quoteDeadline', getU64Encoder()], - ['maxBpsToSponsor', getU64Encoder()], - ['maxUserSlippageBps', getU64Encoder()], - ['finalToken', getAddressEncoder()], - ['destinationDex', getU32Encoder()], - ['accountCreationMode', getU8Encoder()], - ['signature', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]); -} - -export function getSponsoredDepositForBurnDecoder(): Decoder { - return getStructDecoder([ - ['quoteNonce', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ['originSender', getAddressDecoder()], - ['finalRecipient', getAddressDecoder()], - ['quoteDeadline', getU64Decoder()], - ['maxBpsToSponsor', getU64Decoder()], - ['maxUserSlippageBps', getU64Decoder()], - ['finalToken', getAddressDecoder()], - ['destinationDex', getU32Decoder()], - ['accountCreationMode', getU8Decoder()], - ['signature', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getSponsoredDepositForBurnCodec(): Codec< - SponsoredDepositForBurnArgs, - SponsoredDepositForBurn -> { - return combineCodec( - getSponsoredDepositForBurnEncoder(), - getSponsoredDepositForBurnDecoder() - ); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceAccountParams.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceAccountParams.ts deleted file mode 100644 index b16705b55..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceAccountParams.ts +++ /dev/null @@ -1,43 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export type UsedNonceAccountParams = { nonce: ReadonlyUint8Array }; - -export type UsedNonceAccountParamsArgs = UsedNonceAccountParams; - -export function getUsedNonceAccountParamsEncoder(): Encoder { - return getStructEncoder([['nonce', fixEncoderSize(getBytesEncoder(), 32)]]); -} - -export function getUsedNonceAccountParamsDecoder(): Decoder { - return getStructDecoder([['nonce', fixDecoderSize(getBytesDecoder(), 32)]]); -} - -export function getUsedNonceAccountParamsCodec(): Codec< - UsedNonceAccountParamsArgs, - UsedNonceAccountParams -> { - return combineCodec( - getUsedNonceAccountParamsEncoder(), - getUsedNonceAccountParamsDecoder() - ); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceCloseInfo.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceCloseInfo.ts deleted file mode 100644 index ebc545fdf..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/types/usedNonceCloseInfo.ts +++ /dev/null @@ -1,54 +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 { - combineCodec, - getBooleanDecoder, - getBooleanEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type UsedNonceCloseInfo = { - canCloseAfter: bigint; - canCloseNow: boolean; -}; - -export type UsedNonceCloseInfoArgs = { - canCloseAfter: number | bigint; - canCloseNow: boolean; -}; - -export function getUsedNonceCloseInfoEncoder(): Encoder { - return getStructEncoder([ - ['canCloseAfter', getU64Encoder()], - ['canCloseNow', getBooleanEncoder()], - ]); -} - -export function getUsedNonceCloseInfoDecoder(): Decoder { - return getStructDecoder([ - ['canCloseAfter', getU64Decoder()], - ['canCloseNow', getBooleanDecoder()], - ]); -} - -export function getUsedNonceCloseInfoCodec(): Codec< - UsedNonceCloseInfoArgs, - UsedNonceCloseInfo -> { - return combineCodec( - getUsedNonceCloseInfoEncoder(), - getUsedNonceCloseInfoDecoder() - ); -} diff --git a/src/svm/clients/SponsoredCctpSrcPeriphery/types/withdrawnRentFund.ts b/src/svm/clients/SponsoredCctpSrcPeriphery/types/withdrawnRentFund.ts deleted file mode 100644 index a1837ff44..000000000 --- a/src/svm/clients/SponsoredCctpSrcPeriphery/types/withdrawnRentFund.ts +++ /dev/null @@ -1,52 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type WithdrawnRentFund = { amount: bigint; recipient: Address }; - -export type WithdrawnRentFundArgs = { - amount: number | bigint; - recipient: Address; -}; - -export function getWithdrawnRentFundEncoder(): Encoder { - return getStructEncoder([ - ['amount', getU64Encoder()], - ['recipient', getAddressEncoder()], - ]); -} - -export function getWithdrawnRentFundDecoder(): Decoder { - return getStructDecoder([ - ['amount', getU64Decoder()], - ['recipient', getAddressDecoder()], - ]); -} - -export function getWithdrawnRentFundCodec(): Codec< - WithdrawnRentFundArgs, - WithdrawnRentFund -> { - return combineCodec( - getWithdrawnRentFundEncoder(), - getWithdrawnRentFundDecoder() - ); -} diff --git a/src/svm/clients/SvmSpoke/accounts/claimAccount.ts b/src/svm/clients/SvmSpoke/accounts/claimAccount.ts deleted file mode 100644 index b0d78662b..000000000 --- a/src/svm/clients/SvmSpoke/accounts/claimAccount.ts +++ /dev/null @@ -1,139 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const CLAIM_ACCOUNT_DISCRIMINATOR = new Uint8Array([ - 113, 109, 47, 96, 242, 219, 61, 165, -]); - -export function getClaimAccountDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - CLAIM_ACCOUNT_DISCRIMINATOR - ); -} - -export type ClaimAccount = { - discriminator: ReadonlyUint8Array; - amount: bigint; - initializer: Address; -}; - -export type ClaimAccountArgs = { - amount: number | bigint; - initializer: Address; -}; - -export function getClaimAccountEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['amount', getU64Encoder()], - ['initializer', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: CLAIM_ACCOUNT_DISCRIMINATOR }) - ); -} - -export function getClaimAccountDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['amount', getU64Decoder()], - ['initializer', getAddressDecoder()], - ]); -} - -export function getClaimAccountCodec(): Codec { - return combineCodec(getClaimAccountEncoder(), getClaimAccountDecoder()); -} - -export function decodeClaimAccount( - encodedAccount: EncodedAccount -): Account; -export function decodeClaimAccount( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeClaimAccount( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getClaimAccountDecoder() - ); -} - -export async function fetchClaimAccount( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeClaimAccount(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeClaimAccount( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeClaimAccount(maybeAccount); -} - -export async function fetchAllClaimAccount( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeClaimAccount(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeClaimAccount( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeClaimAccount(maybeAccount)); -} - -export function getClaimAccountSize(): number { - return 48; -} diff --git a/src/svm/clients/SvmSpoke/accounts/executeRelayerRefundLeafParams.ts b/src/svm/clients/SvmSpoke/accounts/executeRelayerRefundLeafParams.ts deleted file mode 100644 index 98693aa19..000000000 --- a/src/svm/clients/SvmSpoke/accounts/executeRelayerRefundLeafParams.ts +++ /dev/null @@ -1,176 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getArrayDecoder, - getArrayEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { - getRelayerRefundLeafDecoder, - getRelayerRefundLeafEncoder, - type RelayerRefundLeaf, - type RelayerRefundLeafArgs, -} from '../types'; - -export const EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR = new Uint8Array([ - 192, 59, 93, 9, 171, 77, 28, 250, -]); - -export function getExecuteRelayerRefundLeafParamsDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR - ); -} - -export type ExecuteRelayerRefundLeafParams = { - discriminator: ReadonlyUint8Array; - rootBundleId: number; - relayerRefundLeaf: RelayerRefundLeaf; - proof: Array; -}; - -export type ExecuteRelayerRefundLeafParamsArgs = { - rootBundleId: number; - relayerRefundLeaf: RelayerRefundLeafArgs; - proof: Array; -}; - -export function getExecuteRelayerRefundLeafParamsEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['rootBundleId', getU32Encoder()], - ['relayerRefundLeaf', getRelayerRefundLeafEncoder()], - ['proof', getArrayEncoder(fixEncoderSize(getBytesEncoder(), 32))], - ]), - (value) => ({ - ...value, - discriminator: EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR, - }) - ); -} - -export function getExecuteRelayerRefundLeafParamsDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['rootBundleId', getU32Decoder()], - ['relayerRefundLeaf', getRelayerRefundLeafDecoder()], - ['proof', getArrayDecoder(fixDecoderSize(getBytesDecoder(), 32))], - ]); -} - -export function getExecuteRelayerRefundLeafParamsCodec(): Codec< - ExecuteRelayerRefundLeafParamsArgs, - ExecuteRelayerRefundLeafParams -> { - return combineCodec( - getExecuteRelayerRefundLeafParamsEncoder(), - getExecuteRelayerRefundLeafParamsDecoder() - ); -} - -export function decodeExecuteRelayerRefundLeafParams< - TAddress extends string = string, ->( - encodedAccount: EncodedAccount -): Account; -export function decodeExecuteRelayerRefundLeafParams< - TAddress extends string = string, ->( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeExecuteRelayerRefundLeafParams< - TAddress extends string = string, ->( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): - | Account - | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getExecuteRelayerRefundLeafParamsDecoder() - ); -} - -export async function fetchExecuteRelayerRefundLeafParams< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeExecuteRelayerRefundLeafParams( - rpc, - address, - config - ); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeExecuteRelayerRefundLeafParams< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeExecuteRelayerRefundLeafParams(maybeAccount); -} - -export async function fetchAllExecuteRelayerRefundLeafParams( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeExecuteRelayerRefundLeafParams( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeExecuteRelayerRefundLeafParams( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeExecuteRelayerRefundLeafParams(maybeAccount) - ); -} diff --git a/src/svm/clients/SvmSpoke/accounts/executeSlowRelayLeafParams.ts b/src/svm/clients/SvmSpoke/accounts/executeSlowRelayLeafParams.ts deleted file mode 100644 index e1d990ac0..000000000 --- a/src/svm/clients/SvmSpoke/accounts/executeSlowRelayLeafParams.ts +++ /dev/null @@ -1,176 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getArrayDecoder, - getArrayEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { - getSlowFillDecoder, - getSlowFillEncoder, - type SlowFill, - type SlowFillArgs, -} from '../types'; - -export const EXECUTE_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR = new Uint8Array([ - 135, 208, 119, 251, 14, 222, 66, 155, -]); - -export function getExecuteSlowRelayLeafParamsDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - EXECUTE_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR - ); -} - -export type ExecuteSlowRelayLeafParams = { - discriminator: ReadonlyUint8Array; - slowFillLeaf: SlowFill; - rootBundleId: number; - proof: Array; -}; - -export type ExecuteSlowRelayLeafParamsArgs = { - slowFillLeaf: SlowFillArgs; - rootBundleId: number; - proof: Array; -}; - -export function getExecuteSlowRelayLeafParamsEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['slowFillLeaf', getSlowFillEncoder()], - ['rootBundleId', getU32Encoder()], - ['proof', getArrayEncoder(fixEncoderSize(getBytesEncoder(), 32))], - ]), - (value) => ({ - ...value, - discriminator: EXECUTE_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR, - }) - ); -} - -export function getExecuteSlowRelayLeafParamsDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['slowFillLeaf', getSlowFillDecoder()], - ['rootBundleId', getU32Decoder()], - ['proof', getArrayDecoder(fixDecoderSize(getBytesDecoder(), 32))], - ]); -} - -export function getExecuteSlowRelayLeafParamsCodec(): Codec< - ExecuteSlowRelayLeafParamsArgs, - ExecuteSlowRelayLeafParams -> { - return combineCodec( - getExecuteSlowRelayLeafParamsEncoder(), - getExecuteSlowRelayLeafParamsDecoder() - ); -} - -export function decodeExecuteSlowRelayLeafParams< - TAddress extends string = string, ->( - encodedAccount: EncodedAccount -): Account; -export function decodeExecuteSlowRelayLeafParams< - TAddress extends string = string, ->( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeExecuteSlowRelayLeafParams< - TAddress extends string = string, ->( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): - | Account - | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getExecuteSlowRelayLeafParamsDecoder() - ); -} - -export async function fetchExecuteSlowRelayLeafParams< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeExecuteSlowRelayLeafParams( - rpc, - address, - config - ); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeExecuteSlowRelayLeafParams< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeExecuteSlowRelayLeafParams(maybeAccount); -} - -export async function fetchAllExecuteSlowRelayLeafParams( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeExecuteSlowRelayLeafParams( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeExecuteSlowRelayLeafParams( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeExecuteSlowRelayLeafParams(maybeAccount) - ); -} diff --git a/src/svm/clients/SvmSpoke/accounts/fillRelayParams.ts b/src/svm/clients/SvmSpoke/accounts/fillRelayParams.ts deleted file mode 100644 index 8f7361e3e..000000000 --- a/src/svm/clients/SvmSpoke/accounts/fillRelayParams.ts +++ /dev/null @@ -1,158 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { - getRelayDataDecoder, - getRelayDataEncoder, - type RelayData, - type RelayDataArgs, -} from '../types'; - -export const FILL_RELAY_PARAMS_DISCRIMINATOR = new Uint8Array([ - 50, 243, 51, 185, 89, 60, 43, 202, -]); - -export function getFillRelayParamsDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - FILL_RELAY_PARAMS_DISCRIMINATOR - ); -} - -export type FillRelayParams = { - discriminator: ReadonlyUint8Array; - relayData: RelayData; - repaymentChainId: bigint; - repaymentAddress: Address; -}; - -export type FillRelayParamsArgs = { - relayData: RelayDataArgs; - repaymentChainId: number | bigint; - repaymentAddress: Address; -}; - -export function getFillRelayParamsEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['relayData', getRelayDataEncoder()], - ['repaymentChainId', getU64Encoder()], - ['repaymentAddress', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: FILL_RELAY_PARAMS_DISCRIMINATOR }) - ); -} - -export function getFillRelayParamsDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['relayData', getRelayDataDecoder()], - ['repaymentChainId', getU64Decoder()], - ['repaymentAddress', getAddressDecoder()], - ]); -} - -export function getFillRelayParamsCodec(): Codec< - FillRelayParamsArgs, - FillRelayParams -> { - return combineCodec(getFillRelayParamsEncoder(), getFillRelayParamsDecoder()); -} - -export function decodeFillRelayParams( - encodedAccount: EncodedAccount -): Account; -export function decodeFillRelayParams( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeFillRelayParams( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): - | Account - | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getFillRelayParamsDecoder() - ); -} - -export async function fetchFillRelayParams( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeFillRelayParams(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeFillRelayParams< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeFillRelayParams(maybeAccount); -} - -export async function fetchAllFillRelayParams( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeFillRelayParams( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeFillRelayParams( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeFillRelayParams(maybeAccount) - ); -} diff --git a/src/svm/clients/SvmSpoke/accounts/fillStatusAccount.ts b/src/svm/clients/SvmSpoke/accounts/fillStatusAccount.ts deleted file mode 100644 index b6041d81e..000000000 --- a/src/svm/clients/SvmSpoke/accounts/fillStatusAccount.ts +++ /dev/null @@ -1,165 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { - getFillStatusDecoder, - getFillStatusEncoder, - type FillStatus, - type FillStatusArgs, -} from '../types'; - -export const FILL_STATUS_ACCOUNT_DISCRIMINATOR = new Uint8Array([ - 105, 89, 88, 35, 24, 147, 178, 137, -]); - -export function getFillStatusAccountDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - FILL_STATUS_ACCOUNT_DISCRIMINATOR - ); -} - -export type FillStatusAccount = { - discriminator: ReadonlyUint8Array; - status: FillStatus; - relayer: Address; - fillDeadline: number; -}; - -export type FillStatusAccountArgs = { - status: FillStatusArgs; - relayer: Address; - fillDeadline: number; -}; - -export function getFillStatusAccountEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['status', getFillStatusEncoder()], - ['relayer', getAddressEncoder()], - ['fillDeadline', getU32Encoder()], - ]), - (value) => ({ ...value, discriminator: FILL_STATUS_ACCOUNT_DISCRIMINATOR }) - ); -} - -export function getFillStatusAccountDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['status', getFillStatusDecoder()], - ['relayer', getAddressDecoder()], - ['fillDeadline', getU32Decoder()], - ]); -} - -export function getFillStatusAccountCodec(): Codec< - FillStatusAccountArgs, - FillStatusAccount -> { - return combineCodec( - getFillStatusAccountEncoder(), - getFillStatusAccountDecoder() - ); -} - -export function decodeFillStatusAccount( - encodedAccount: EncodedAccount -): Account; -export function decodeFillStatusAccount( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeFillStatusAccount( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): - | Account - | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getFillStatusAccountDecoder() - ); -} - -export async function fetchFillStatusAccount( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeFillStatusAccount(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeFillStatusAccount< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeFillStatusAccount(maybeAccount); -} - -export async function fetchAllFillStatusAccount( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeFillStatusAccount( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeFillStatusAccount( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeFillStatusAccount(maybeAccount) - ); -} - -export function getFillStatusAccountSize(): number { - return 45; -} diff --git a/src/svm/clients/SvmSpoke/accounts/index.ts b/src/svm/clients/SvmSpoke/accounts/index.ts deleted file mode 100644 index 4bfae2afd..000000000 --- a/src/svm/clients/SvmSpoke/accounts/index.ts +++ /dev/null @@ -1,17 +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 - */ - -export * from './claimAccount'; -export * from './executeRelayerRefundLeafParams'; -export * from './executeSlowRelayLeafParams'; -export * from './fillRelayParams'; -export * from './fillStatusAccount'; -export * from './requestSlowFillParams'; -export * from './rootBundle'; -export * from './state'; -export * from './transferLiability'; diff --git a/src/svm/clients/SvmSpoke/accounts/requestSlowFillParams.ts b/src/svm/clients/SvmSpoke/accounts/requestSlowFillParams.ts deleted file mode 100644 index 98cb2d075..000000000 --- a/src/svm/clients/SvmSpoke/accounts/requestSlowFillParams.ts +++ /dev/null @@ -1,156 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { - getRelayDataDecoder, - getRelayDataEncoder, - type RelayData, - type RelayDataArgs, -} from '../types'; - -export const REQUEST_SLOW_FILL_PARAMS_DISCRIMINATOR = new Uint8Array([ - 5, 54, 214, 89, 197, 37, 118, 28, -]); - -export function getRequestSlowFillParamsDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - REQUEST_SLOW_FILL_PARAMS_DISCRIMINATOR - ); -} - -export type RequestSlowFillParams = { - discriminator: ReadonlyUint8Array; - relayData: RelayData; -}; - -export type RequestSlowFillParamsArgs = { relayData: RelayDataArgs }; - -export function getRequestSlowFillParamsEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['relayData', getRelayDataEncoder()], - ]), - (value) => ({ - ...value, - discriminator: REQUEST_SLOW_FILL_PARAMS_DISCRIMINATOR, - }) - ); -} - -export function getRequestSlowFillParamsDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['relayData', getRelayDataDecoder()], - ]); -} - -export function getRequestSlowFillParamsCodec(): Codec< - RequestSlowFillParamsArgs, - RequestSlowFillParams -> { - return combineCodec( - getRequestSlowFillParamsEncoder(), - getRequestSlowFillParamsDecoder() - ); -} - -export function decodeRequestSlowFillParams( - encodedAccount: EncodedAccount -): Account; -export function decodeRequestSlowFillParams( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeRequestSlowFillParams( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): - | Account - | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getRequestSlowFillParamsDecoder() - ); -} - -export async function fetchRequestSlowFillParams< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeRequestSlowFillParams( - rpc, - address, - config - ); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeRequestSlowFillParams< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeRequestSlowFillParams(maybeAccount); -} - -export async function fetchAllRequestSlowFillParams( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeRequestSlowFillParams( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeRequestSlowFillParams( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeRequestSlowFillParams(maybeAccount) - ); -} diff --git a/src/svm/clients/SvmSpoke/accounts/rootBundle.ts b/src/svm/clients/SvmSpoke/accounts/rootBundle.ts deleted file mode 100644 index cdcf37171..000000000 --- a/src/svm/clients/SvmSpoke/accounts/rootBundle.ts +++ /dev/null @@ -1,140 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const ROOT_BUNDLE_DISCRIMINATOR = new Uint8Array([ - 66, 221, 214, 231, 25, 222, 184, 219, -]); - -export function getRootBundleDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(ROOT_BUNDLE_DISCRIMINATOR); -} - -export type RootBundle = { - discriminator: ReadonlyUint8Array; - relayerRefundRoot: ReadonlyUint8Array; - slowRelayRoot: ReadonlyUint8Array; - claimedBitmap: ReadonlyUint8Array; -}; - -export type RootBundleArgs = { - relayerRefundRoot: ReadonlyUint8Array; - slowRelayRoot: ReadonlyUint8Array; - claimedBitmap: ReadonlyUint8Array; -}; - -export function getRootBundleEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['relayerRefundRoot', fixEncoderSize(getBytesEncoder(), 32)], - ['slowRelayRoot', fixEncoderSize(getBytesEncoder(), 32)], - [ - 'claimedBitmap', - addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), - ], - ]), - (value) => ({ ...value, discriminator: ROOT_BUNDLE_DISCRIMINATOR }) - ); -} - -export function getRootBundleDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['relayerRefundRoot', fixDecoderSize(getBytesDecoder(), 32)], - ['slowRelayRoot', fixDecoderSize(getBytesDecoder(), 32)], - ['claimedBitmap', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getRootBundleCodec(): Codec { - return combineCodec(getRootBundleEncoder(), getRootBundleDecoder()); -} - -export function decodeRootBundle( - encodedAccount: EncodedAccount -): Account; -export function decodeRootBundle( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeRootBundle( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getRootBundleDecoder() - ); -} - -export async function fetchRootBundle( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeRootBundle(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeRootBundle( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeRootBundle(maybeAccount); -} - -export async function fetchAllRootBundle( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeRootBundle(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeRootBundle( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeRootBundle(maybeAccount)); -} diff --git a/src/svm/clients/SvmSpoke/accounts/state.ts b/src/svm/clients/SvmSpoke/accounts/state.ts deleted file mode 100644 index d25efa33d..000000000 --- a/src/svm/clients/SvmSpoke/accounts/state.ts +++ /dev/null @@ -1,181 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBooleanDecoder, - getBooleanEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const STATE_DISCRIMINATOR = new Uint8Array([ - 216, 146, 107, 94, 104, 75, 182, 177, -]); - -export function getStateDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(STATE_DISCRIMINATOR); -} - -export type State = { - discriminator: ReadonlyUint8Array; - pausedDeposits: boolean; - pausedFills: boolean; - owner: Address; - seed: bigint; - numberOfDeposits: number; - chainId: bigint; - currentTime: number; - remoteDomain: number; - crossDomainAdmin: Address; - rootBundleId: number; - depositQuoteTimeBuffer: number; - fillDeadlineBuffer: number; -}; - -export type StateArgs = { - pausedDeposits: boolean; - pausedFills: boolean; - owner: Address; - seed: number | bigint; - numberOfDeposits: number; - chainId: number | bigint; - currentTime: number; - remoteDomain: number; - crossDomainAdmin: Address; - rootBundleId: number; - depositQuoteTimeBuffer: number; - fillDeadlineBuffer: number; -}; - -export function getStateEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['pausedDeposits', getBooleanEncoder()], - ['pausedFills', getBooleanEncoder()], - ['owner', getAddressEncoder()], - ['seed', getU64Encoder()], - ['numberOfDeposits', getU32Encoder()], - ['chainId', getU64Encoder()], - ['currentTime', getU32Encoder()], - ['remoteDomain', getU32Encoder()], - ['crossDomainAdmin', getAddressEncoder()], - ['rootBundleId', getU32Encoder()], - ['depositQuoteTimeBuffer', getU32Encoder()], - ['fillDeadlineBuffer', getU32Encoder()], - ]), - (value) => ({ ...value, discriminator: STATE_DISCRIMINATOR }) - ); -} - -export function getStateDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['pausedDeposits', getBooleanDecoder()], - ['pausedFills', getBooleanDecoder()], - ['owner', getAddressDecoder()], - ['seed', getU64Decoder()], - ['numberOfDeposits', getU32Decoder()], - ['chainId', getU64Decoder()], - ['currentTime', getU32Decoder()], - ['remoteDomain', getU32Decoder()], - ['crossDomainAdmin', getAddressDecoder()], - ['rootBundleId', getU32Decoder()], - ['depositQuoteTimeBuffer', getU32Decoder()], - ['fillDeadlineBuffer', getU32Decoder()], - ]); -} - -export function getStateCodec(): Codec { - return combineCodec(getStateEncoder(), getStateDecoder()); -} - -export function decodeState( - encodedAccount: EncodedAccount -): Account; -export function decodeState( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeState( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getStateDecoder() - ); -} - -export async function fetchState( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeState(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeState( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeState(maybeAccount); -} - -export async function fetchAllState( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeState(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeState( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeState(maybeAccount)); -} - -export function getStateSize(): number { - return 114; -} diff --git a/src/svm/clients/SvmSpoke/accounts/transferLiability.ts b/src/svm/clients/SvmSpoke/accounts/transferLiability.ts deleted file mode 100644 index d604c5882..000000000 --- a/src/svm/clients/SvmSpoke/accounts/transferLiability.ts +++ /dev/null @@ -1,147 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const TRANSFER_LIABILITY_DISCRIMINATOR = new Uint8Array([ - 157, 137, 86, 109, 206, 241, 183, 79, -]); - -export function getTransferLiabilityDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - TRANSFER_LIABILITY_DISCRIMINATOR - ); -} - -export type TransferLiability = { - discriminator: ReadonlyUint8Array; - pendingToHubPool: bigint; -}; - -export type TransferLiabilityArgs = { pendingToHubPool: number | bigint }; - -export function getTransferLiabilityEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['pendingToHubPool', getU64Encoder()], - ]), - (value) => ({ ...value, discriminator: TRANSFER_LIABILITY_DISCRIMINATOR }) - ); -} - -export function getTransferLiabilityDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['pendingToHubPool', getU64Decoder()], - ]); -} - -export function getTransferLiabilityCodec(): Codec< - TransferLiabilityArgs, - TransferLiability -> { - return combineCodec( - getTransferLiabilityEncoder(), - getTransferLiabilityDecoder() - ); -} - -export function decodeTransferLiability( - encodedAccount: EncodedAccount -): Account; -export function decodeTransferLiability( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeTransferLiability( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): - | Account - | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getTransferLiabilityDecoder() - ); -} - -export async function fetchTransferLiability( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeTransferLiability(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeTransferLiability< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeTransferLiability(maybeAccount); -} - -export async function fetchAllTransferLiability( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeTransferLiability( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeTransferLiability( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeTransferLiability(maybeAccount) - ); -} - -export function getTransferLiabilitySize(): number { - return 16; -} diff --git a/src/svm/clients/SvmSpoke/errors/index.ts b/src/svm/clients/SvmSpoke/errors/index.ts deleted file mode 100644 index 90c874042..000000000 --- a/src/svm/clients/SvmSpoke/errors/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './svmSpoke'; diff --git a/src/svm/clients/SvmSpoke/errors/svmSpoke.ts b/src/svm/clients/SvmSpoke/errors/svmSpoke.ts deleted file mode 100644 index 0e7c48def..000000000 --- a/src/svm/clients/SvmSpoke/errors/svmSpoke.ts +++ /dev/null @@ -1,112 +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 { - isProgramError, - type Address, - type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, - type SolanaError, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; - -/** InvalidQuoteTimestamp: Invalid quote timestamp! */ -export const SVM_SPOKE_ERROR__INVALID_QUOTE_TIMESTAMP = 0x1770; // 6000 -/** InvalidFillDeadline: Invalid fill deadline! */ -export const SVM_SPOKE_ERROR__INVALID_FILL_DEADLINE = 0x1771; // 6001 -/** NotExclusiveRelayer: Caller is not the exclusive relayer and exclusivity deadline has not passed! */ -export const SVM_SPOKE_ERROR__NOT_EXCLUSIVE_RELAYER = 0x1772; // 6002 -/** NoSlowFillsInExclusivityWindow: The Deposit is still within the exclusivity window! */ -export const SVM_SPOKE_ERROR__NO_SLOW_FILLS_IN_EXCLUSIVITY_WINDOW = 0x1773; // 6003 -/** RelayFilled: The relay has already been filled! */ -export const SVM_SPOKE_ERROR__RELAY_FILLED = 0x1774; // 6004 -/** InvalidSlowFillRequest: Slow fill requires status of Unfilled! */ -export const SVM_SPOKE_ERROR__INVALID_SLOW_FILL_REQUEST = 0x1775; // 6005 -/** ExpiredFillDeadline: The fill deadline has passed! */ -export const SVM_SPOKE_ERROR__EXPIRED_FILL_DEADLINE = 0x1776; // 6006 -/** InvalidMerkleProof: Invalid Merkle proof! */ -export const SVM_SPOKE_ERROR__INVALID_MERKLE_PROOF = 0x1777; // 6007 -/** InvalidChainId: Invalid chain id! */ -export const SVM_SPOKE_ERROR__INVALID_CHAIN_ID = 0x1778; // 6008 -/** InvalidMerkleLeaf: Invalid Merkle leaf! */ -export const SVM_SPOKE_ERROR__INVALID_MERKLE_LEAF = 0x1779; // 6009 -/** ClaimedMerkleLeaf: Leaf already claimed! */ -export const SVM_SPOKE_ERROR__CLAIMED_MERKLE_LEAF = 0x177a; // 6010 -/** DepositsArePaused: Deposits are currently paused! */ -export const SVM_SPOKE_ERROR__DEPOSITS_ARE_PAUSED = 0x177b; // 6011 -/** FillsArePaused: Fills are currently paused! */ -export const SVM_SPOKE_ERROR__FILLS_ARE_PAUSED = 0x177c; // 6012 -/** InsufficientSpokePoolBalanceToExecuteLeaf: Insufficient spoke pool balance to execute leaf */ -export const SVM_SPOKE_ERROR__INSUFFICIENT_SPOKE_POOL_BALANCE_TO_EXECUTE_LEAF = 0x177d; // 6013 -/** InvalidExclusiveRelayer: Invalid exclusive relayer! */ -export const SVM_SPOKE_ERROR__INVALID_EXCLUSIVE_RELAYER = 0x177e; // 6014 -/** InvalidOutputToken: Invalid output token! */ -export const SVM_SPOKE_ERROR__INVALID_OUTPUT_TOKEN = 0x177f; // 6015 - -export type SvmSpokeError = - | typeof SVM_SPOKE_ERROR__CLAIMED_MERKLE_LEAF - | typeof SVM_SPOKE_ERROR__DEPOSITS_ARE_PAUSED - | typeof SVM_SPOKE_ERROR__EXPIRED_FILL_DEADLINE - | typeof SVM_SPOKE_ERROR__FILLS_ARE_PAUSED - | typeof SVM_SPOKE_ERROR__INSUFFICIENT_SPOKE_POOL_BALANCE_TO_EXECUTE_LEAF - | typeof SVM_SPOKE_ERROR__INVALID_CHAIN_ID - | typeof SVM_SPOKE_ERROR__INVALID_EXCLUSIVE_RELAYER - | typeof SVM_SPOKE_ERROR__INVALID_FILL_DEADLINE - | typeof SVM_SPOKE_ERROR__INVALID_MERKLE_LEAF - | typeof SVM_SPOKE_ERROR__INVALID_MERKLE_PROOF - | typeof SVM_SPOKE_ERROR__INVALID_OUTPUT_TOKEN - | typeof SVM_SPOKE_ERROR__INVALID_QUOTE_TIMESTAMP - | typeof SVM_SPOKE_ERROR__INVALID_SLOW_FILL_REQUEST - | typeof SVM_SPOKE_ERROR__NO_SLOW_FILLS_IN_EXCLUSIVITY_WINDOW - | typeof SVM_SPOKE_ERROR__NOT_EXCLUSIVE_RELAYER - | typeof SVM_SPOKE_ERROR__RELAY_FILLED; - -let svmSpokeErrorMessages: Record | undefined; -if (process.env.NODE_ENV !== 'production') { - svmSpokeErrorMessages = { - [SVM_SPOKE_ERROR__CLAIMED_MERKLE_LEAF]: `Leaf already claimed!`, - [SVM_SPOKE_ERROR__DEPOSITS_ARE_PAUSED]: `Deposits are currently paused!`, - [SVM_SPOKE_ERROR__EXPIRED_FILL_DEADLINE]: `The fill deadline has passed!`, - [SVM_SPOKE_ERROR__FILLS_ARE_PAUSED]: `Fills are currently paused!`, - [SVM_SPOKE_ERROR__INSUFFICIENT_SPOKE_POOL_BALANCE_TO_EXECUTE_LEAF]: `Insufficient spoke pool balance to execute leaf`, - [SVM_SPOKE_ERROR__INVALID_CHAIN_ID]: `Invalid chain id!`, - [SVM_SPOKE_ERROR__INVALID_EXCLUSIVE_RELAYER]: `Invalid exclusive relayer!`, - [SVM_SPOKE_ERROR__INVALID_FILL_DEADLINE]: `Invalid fill deadline!`, - [SVM_SPOKE_ERROR__INVALID_MERKLE_LEAF]: `Invalid Merkle leaf!`, - [SVM_SPOKE_ERROR__INVALID_MERKLE_PROOF]: `Invalid Merkle proof!`, - [SVM_SPOKE_ERROR__INVALID_OUTPUT_TOKEN]: `Invalid output token!`, - [SVM_SPOKE_ERROR__INVALID_QUOTE_TIMESTAMP]: `Invalid quote timestamp!`, - [SVM_SPOKE_ERROR__INVALID_SLOW_FILL_REQUEST]: `Slow fill requires status of Unfilled!`, - [SVM_SPOKE_ERROR__NO_SLOW_FILLS_IN_EXCLUSIVITY_WINDOW]: `The Deposit is still within the exclusivity window!`, - [SVM_SPOKE_ERROR__NOT_EXCLUSIVE_RELAYER]: `Caller is not the exclusive relayer and exclusivity deadline has not passed!`, - [SVM_SPOKE_ERROR__RELAY_FILLED]: `The relay has already been filled!`, - }; -} - -export function getSvmSpokeErrorMessage(code: SvmSpokeError): string { - if (process.env.NODE_ENV !== 'production') { - return (svmSpokeErrorMessages as Record)[code]; - } - - return 'Error message not available in production bundles.'; -} - -export function isSvmSpokeError( - error: unknown, - transactionMessage: { - instructions: Record; - }, - code?: TProgramErrorCode -): error is SolanaError & - Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { - return isProgramError( - error, - transactionMessage, - SVM_SPOKE_PROGRAM_ADDRESS, - code - ); -} diff --git a/src/svm/clients/SvmSpoke/index.ts b/src/svm/clients/SvmSpoke/index.ts deleted file mode 100644 index 02964a6ae..000000000 --- a/src/svm/clients/SvmSpoke/index.ts +++ /dev/null @@ -1,13 +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 - */ - -export * from './accounts'; -export * from './errors'; -export * from './instructions'; -export * from './programs'; -export * from './types'; diff --git a/src/svm/clients/SvmSpoke/instructions/bridgeTokensToHubPool.ts b/src/svm/clients/SvmSpoke/instructions/bridgeTokensToHubPool.ts deleted file mode 100644 index 57c023984..000000000 --- a/src/svm/clients/SvmSpoke/instructions/bridgeTokensToHubPool.ts +++ /dev/null @@ -1,800 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const BRIDGE_TOKENS_TO_HUB_POOL_DISCRIMINATOR = new Uint8Array([ - 1, 83, 255, 59, 232, 55, 64, 216, -]); - -export function getBridgeTokensToHubPoolDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - BRIDGE_TOKENS_TO_HUB_POOL_DISCRIMINATOR - ); -} - -export type BridgeTokensToHubPoolInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountPayer extends string | AccountMeta = string, - TAccountMint extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountTransferLiability extends string | AccountMeta = string, - TAccountVault extends string | AccountMeta = string, - TAccountTokenMessengerMinterSenderAuthority extends - | string - | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountRemoteTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountCctpEventAuthority extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TAccountMessageTransmitterProgram extends string | AccountMeta = - 'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd', - TAccountTokenMessengerMinterProgram extends string | AccountMeta = - 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3', - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountMint extends string - ? WritableAccount - : TAccountMint, - TAccountState extends string - ? ReadonlyAccount - : TAccountState, - TAccountTransferLiability extends string - ? WritableAccount - : TAccountTransferLiability, - TAccountVault extends string - ? WritableAccount - : TAccountVault, - TAccountTokenMessengerMinterSenderAuthority extends string - ? ReadonlyAccount - : TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountRemoteTokenMessenger extends string - ? ReadonlyAccount - : TAccountRemoteTokenMessenger, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountCctpEventAuthority extends string - ? ReadonlyAccount - : TAccountCctpEventAuthority, - TAccountMessageSentEventData extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountMessageSentEventData, - TAccountMessageTransmitterProgram extends string - ? ReadonlyAccount - : TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram extends string - ? ReadonlyAccount - : TAccountTokenMessengerMinterProgram, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type BridgeTokensToHubPoolInstructionData = { - discriminator: ReadonlyUint8Array; - amount: bigint; -}; - -export type BridgeTokensToHubPoolInstructionDataArgs = { - amount: number | bigint; -}; - -export function getBridgeTokensToHubPoolInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['amount', getU64Encoder()], - ]), - (value) => ({ - ...value, - discriminator: BRIDGE_TOKENS_TO_HUB_POOL_DISCRIMINATOR, - }) - ); -} - -export function getBridgeTokensToHubPoolInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['amount', getU64Decoder()], - ]); -} - -export function getBridgeTokensToHubPoolInstructionDataCodec(): Codec< - BridgeTokensToHubPoolInstructionDataArgs, - BridgeTokensToHubPoolInstructionData -> { - return combineCodec( - getBridgeTokensToHubPoolInstructionDataEncoder(), - getBridgeTokensToHubPoolInstructionDataDecoder() - ); -} - -export type BridgeTokensToHubPoolAsyncInput< - TAccountSigner extends string = string, - TAccountPayer extends string = string, - TAccountMint extends string = string, - TAccountState extends string = string, - TAccountTransferLiability extends string = string, - TAccountVault extends string = string, - TAccountTokenMessengerMinterSenderAuthority extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountCctpEventAuthority extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - payer: TransactionSigner; - mint: Address; - state: Address; - transferLiability?: Address; - vault?: Address; - tokenMessengerMinterSenderAuthority: Address; - messageTransmitter: Address; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken: Address; - cctpEventAuthority: Address; - messageSentEventData: TransactionSigner; - messageTransmitterProgram?: Address; - tokenMessengerMinterProgram?: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - amount: BridgeTokensToHubPoolInstructionDataArgs['amount']; -}; - -export async function getBridgeTokensToHubPoolInstructionAsync< - TAccountSigner extends string, - TAccountPayer extends string, - TAccountMint extends string, - TAccountState extends string, - TAccountTransferLiability extends string, - TAccountVault extends string, - TAccountTokenMessengerMinterSenderAuthority extends string, - TAccountMessageTransmitter extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountCctpEventAuthority extends string, - TAccountMessageSentEventData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: BridgeTokensToHubPoolAsyncInput< - TAccountSigner, - TAccountPayer, - TAccountMint, - TAccountState, - TAccountTransferLiability, - TAccountVault, - TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCctpEventAuthority, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - BridgeTokensToHubPoolInstruction< - TProgramAddress, - TAccountSigner, - TAccountPayer, - TAccountMint, - TAccountState, - TAccountTransferLiability, - TAccountVault, - TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCctpEventAuthority, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - payer: { value: input.payer ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: false }, - transferLiability: { - value: input.transferLiability ?? null, - isWritable: true, - }, - vault: { value: input.vault ?? null, isWritable: true }, - tokenMessengerMinterSenderAuthority: { - value: input.tokenMessengerMinterSenderAuthority ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - cctpEventAuthority: { - value: input.cctpEventAuthority ?? null, - isWritable: false, - }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.transferLiability.value) { - accounts.transferLiability.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 116, 114, 97, 110, 115, 102, 101, 114, 95, 108, 105, 97, 98, 105, - 108, 105, 116, 121, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.vault.value) { - accounts.vault.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getAddressEncoder().encode(expectAddress(accounts.state.value)), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.messageTransmitterProgram.value) { - accounts.messageTransmitterProgram.value = - 'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd' as Address<'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd'>; - } - if (!accounts.tokenMessengerMinterProgram.value) { - accounts.tokenMessengerMinterProgram.value = - 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3' as Address<'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.state), - getAccountMeta(accounts.transferLiability), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.tokenMessengerMinterSenderAuthority), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.cctpEventAuthority), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getBridgeTokensToHubPoolInstructionDataEncoder().encode( - args as BridgeTokensToHubPoolInstructionDataArgs - ), - } as BridgeTokensToHubPoolInstruction< - TProgramAddress, - TAccountSigner, - TAccountPayer, - TAccountMint, - TAccountState, - TAccountTransferLiability, - TAccountVault, - TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCctpEventAuthority, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type BridgeTokensToHubPoolInput< - TAccountSigner extends string = string, - TAccountPayer extends string = string, - TAccountMint extends string = string, - TAccountState extends string = string, - TAccountTransferLiability extends string = string, - TAccountVault extends string = string, - TAccountTokenMessengerMinterSenderAuthority extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountCctpEventAuthority extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - payer: TransactionSigner; - mint: Address; - state: Address; - transferLiability: Address; - vault: Address; - tokenMessengerMinterSenderAuthority: Address; - messageTransmitter: Address; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken: Address; - cctpEventAuthority: Address; - messageSentEventData: TransactionSigner; - messageTransmitterProgram?: Address; - tokenMessengerMinterProgram?: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - amount: BridgeTokensToHubPoolInstructionDataArgs['amount']; -}; - -export function getBridgeTokensToHubPoolInstruction< - TAccountSigner extends string, - TAccountPayer extends string, - TAccountMint extends string, - TAccountState extends string, - TAccountTransferLiability extends string, - TAccountVault extends string, - TAccountTokenMessengerMinterSenderAuthority extends string, - TAccountMessageTransmitter extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountCctpEventAuthority extends string, - TAccountMessageSentEventData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: BridgeTokensToHubPoolInput< - TAccountSigner, - TAccountPayer, - TAccountMint, - TAccountState, - TAccountTransferLiability, - TAccountVault, - TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCctpEventAuthority, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): BridgeTokensToHubPoolInstruction< - TProgramAddress, - TAccountSigner, - TAccountPayer, - TAccountMint, - TAccountState, - TAccountTransferLiability, - TAccountVault, - TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCctpEventAuthority, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - payer: { value: input.payer ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: false }, - transferLiability: { - value: input.transferLiability ?? null, - isWritable: true, - }, - vault: { value: input.vault ?? null, isWritable: true }, - tokenMessengerMinterSenderAuthority: { - value: input.tokenMessengerMinterSenderAuthority ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - cctpEventAuthority: { - value: input.cctpEventAuthority ?? null, - isWritable: false, - }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.messageTransmitterProgram.value) { - accounts.messageTransmitterProgram.value = - 'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd' as Address<'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd'>; - } - if (!accounts.tokenMessengerMinterProgram.value) { - accounts.tokenMessengerMinterProgram.value = - 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3' as Address<'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.state), - getAccountMeta(accounts.transferLiability), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.tokenMessengerMinterSenderAuthority), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.cctpEventAuthority), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getBridgeTokensToHubPoolInstructionDataEncoder().encode( - args as BridgeTokensToHubPoolInstructionDataArgs - ), - } as BridgeTokensToHubPoolInstruction< - TProgramAddress, - TAccountSigner, - TAccountPayer, - TAccountMint, - TAccountState, - TAccountTransferLiability, - TAccountVault, - TAccountTokenMessengerMinterSenderAuthority, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCctpEventAuthority, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedBridgeTokensToHubPoolInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - payer: TAccountMetas[1]; - mint: TAccountMetas[2]; - state: TAccountMetas[3]; - transferLiability: TAccountMetas[4]; - vault: TAccountMetas[5]; - tokenMessengerMinterSenderAuthority: TAccountMetas[6]; - messageTransmitter: TAccountMetas[7]; - tokenMessenger: TAccountMetas[8]; - remoteTokenMessenger: TAccountMetas[9]; - tokenMinter: TAccountMetas[10]; - localToken: TAccountMetas[11]; - cctpEventAuthority: TAccountMetas[12]; - messageSentEventData: TAccountMetas[13]; - messageTransmitterProgram: TAccountMetas[14]; - tokenMessengerMinterProgram: TAccountMetas[15]; - tokenProgram: TAccountMetas[16]; - systemProgram: TAccountMetas[17]; - eventAuthority: TAccountMetas[18]; - program: TAccountMetas[19]; - }; - data: BridgeTokensToHubPoolInstructionData; -}; - -export function parseBridgeTokensToHubPoolInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedBridgeTokensToHubPoolInstruction { - if (instruction.accounts.length < 20) { - // 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: { - signer: getNextAccount(), - payer: getNextAccount(), - mint: getNextAccount(), - state: getNextAccount(), - transferLiability: getNextAccount(), - vault: getNextAccount(), - tokenMessengerMinterSenderAuthority: getNextAccount(), - messageTransmitter: getNextAccount(), - tokenMessenger: getNextAccount(), - remoteTokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - cctpEventAuthority: getNextAccount(), - messageSentEventData: getNextAccount(), - messageTransmitterProgram: getNextAccount(), - tokenMessengerMinterProgram: getNextAccount(), - tokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getBridgeTokensToHubPoolInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/claimRelayerRefund.ts b/src/svm/clients/SvmSpoke/instructions/claimRelayerRefund.ts deleted file mode 100644 index 08e28458e..000000000 --- a/src/svm/clients/SvmSpoke/instructions/claimRelayerRefund.ts +++ /dev/null @@ -1,498 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const CLAIM_RELAYER_REFUND_DISCRIMINATOR = new Uint8Array([ - 205, 34, 34, 224, 204, 103, 81, 176, -]); - -export function getClaimRelayerRefundDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - CLAIM_RELAYER_REFUND_DISCRIMINATOR - ); -} - -export type ClaimRelayerRefundInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountInitializer extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountVault extends string | AccountMeta = string, - TAccountMint extends string | AccountMeta = string, - TAccountRefundAddress extends string | AccountMeta = string, - TAccountTokenAccount extends string | AccountMeta = string, - TAccountClaimAccount extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountInitializer extends string - ? WritableAccount - : TAccountInitializer, - TAccountState extends string - ? ReadonlyAccount - : TAccountState, - TAccountVault extends string - ? WritableAccount - : TAccountVault, - TAccountMint extends string - ? ReadonlyAccount - : TAccountMint, - TAccountRefundAddress extends string - ? ReadonlyAccount - : TAccountRefundAddress, - TAccountTokenAccount extends string - ? WritableAccount - : TAccountTokenAccount, - TAccountClaimAccount extends string - ? WritableAccount - : TAccountClaimAccount, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type ClaimRelayerRefundInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type ClaimRelayerRefundInstructionDataArgs = {}; - -export function getClaimRelayerRefundInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: CLAIM_RELAYER_REFUND_DISCRIMINATOR }) - ); -} - -export function getClaimRelayerRefundInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getClaimRelayerRefundInstructionDataCodec(): Codec< - ClaimRelayerRefundInstructionDataArgs, - ClaimRelayerRefundInstructionData -> { - return combineCodec( - getClaimRelayerRefundInstructionDataEncoder(), - getClaimRelayerRefundInstructionDataDecoder() - ); -} - -export type ClaimRelayerRefundAsyncInput< - TAccountSigner extends string = string, - TAccountInitializer extends string = string, - TAccountState extends string = string, - TAccountVault extends string = string, - TAccountMint extends string = string, - TAccountRefundAddress extends string = string, - TAccountTokenAccount extends string = string, - TAccountClaimAccount extends string = string, - TAccountTokenProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - initializer: Address; - state: Address; - vault?: Address; - mint: Address; - refundAddress: Address; - tokenAccount: Address; - claimAccount?: Address; - tokenProgram?: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getClaimRelayerRefundInstructionAsync< - TAccountSigner extends string, - TAccountInitializer extends string, - TAccountState extends string, - TAccountVault extends string, - TAccountMint extends string, - TAccountRefundAddress extends string, - TAccountTokenAccount extends string, - TAccountClaimAccount extends string, - TAccountTokenProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: ClaimRelayerRefundAsyncInput< - TAccountSigner, - TAccountInitializer, - TAccountState, - TAccountVault, - TAccountMint, - TAccountRefundAddress, - TAccountTokenAccount, - TAccountClaimAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - ClaimRelayerRefundInstruction< - TProgramAddress, - TAccountSigner, - TAccountInitializer, - TAccountState, - TAccountVault, - TAccountMint, - TAccountRefundAddress, - TAccountTokenAccount, - TAccountClaimAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - initializer: { value: input.initializer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: false }, - vault: { value: input.vault ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - refundAddress: { value: input.refundAddress ?? null, isWritable: false }, - tokenAccount: { value: input.tokenAccount ?? null, isWritable: true }, - claimAccount: { value: input.claimAccount ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.vault.value) { - accounts.vault.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getAddressEncoder().encode(expectAddress(accounts.state.value)), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.claimAccount.value) { - accounts.claimAccount.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 99, 108, 97, 105, 109, 95, 97, 99, 99, 111, 117, 110, 116, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - getAddressEncoder().encode(expectAddress(accounts.refundAddress.value)), - ], - }); - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.initializer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.refundAddress), - getAccountMeta(accounts.tokenAccount), - getAccountMeta(accounts.claimAccount), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getClaimRelayerRefundInstructionDataEncoder().encode({}), - } as ClaimRelayerRefundInstruction< - TProgramAddress, - TAccountSigner, - TAccountInitializer, - TAccountState, - TAccountVault, - TAccountMint, - TAccountRefundAddress, - TAccountTokenAccount, - TAccountClaimAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ClaimRelayerRefundInput< - TAccountSigner extends string = string, - TAccountInitializer extends string = string, - TAccountState extends string = string, - TAccountVault extends string = string, - TAccountMint extends string = string, - TAccountRefundAddress extends string = string, - TAccountTokenAccount extends string = string, - TAccountClaimAccount extends string = string, - TAccountTokenProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - initializer: Address; - state: Address; - vault: Address; - mint: Address; - refundAddress: Address; - tokenAccount: Address; - claimAccount: Address; - tokenProgram?: Address; - eventAuthority: Address; - program: Address; -}; - -export function getClaimRelayerRefundInstruction< - TAccountSigner extends string, - TAccountInitializer extends string, - TAccountState extends string, - TAccountVault extends string, - TAccountMint extends string, - TAccountRefundAddress extends string, - TAccountTokenAccount extends string, - TAccountClaimAccount extends string, - TAccountTokenProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: ClaimRelayerRefundInput< - TAccountSigner, - TAccountInitializer, - TAccountState, - TAccountVault, - TAccountMint, - TAccountRefundAddress, - TAccountTokenAccount, - TAccountClaimAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): ClaimRelayerRefundInstruction< - TProgramAddress, - TAccountSigner, - TAccountInitializer, - TAccountState, - TAccountVault, - TAccountMint, - TAccountRefundAddress, - TAccountTokenAccount, - TAccountClaimAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - initializer: { value: input.initializer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: false }, - vault: { value: input.vault ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - refundAddress: { value: input.refundAddress ?? null, isWritable: false }, - tokenAccount: { value: input.tokenAccount ?? null, isWritable: true }, - claimAccount: { value: input.claimAccount ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.initializer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.refundAddress), - getAccountMeta(accounts.tokenAccount), - getAccountMeta(accounts.claimAccount), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getClaimRelayerRefundInstructionDataEncoder().encode({}), - } as ClaimRelayerRefundInstruction< - TProgramAddress, - TAccountSigner, - TAccountInitializer, - TAccountState, - TAccountVault, - TAccountMint, - TAccountRefundAddress, - TAccountTokenAccount, - TAccountClaimAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedClaimRelayerRefundInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - initializer: TAccountMetas[1]; - state: TAccountMetas[2]; - vault: TAccountMetas[3]; - mint: TAccountMetas[4]; - refundAddress: TAccountMetas[5]; - tokenAccount: TAccountMetas[6]; - claimAccount: TAccountMetas[7]; - tokenProgram: TAccountMetas[8]; - eventAuthority: TAccountMetas[9]; - program: TAccountMetas[10]; - }; - data: ClaimRelayerRefundInstructionData; -}; - -export function parseClaimRelayerRefundInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedClaimRelayerRefundInstruction { - if (instruction.accounts.length < 11) { - // 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: { - signer: getNextAccount(), - initializer: getNextAccount(), - state: getNextAccount(), - vault: getNextAccount(), - mint: getNextAccount(), - refundAddress: getNextAccount(), - tokenAccount: getNextAccount(), - claimAccount: getNextAccount(), - tokenProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getClaimRelayerRefundInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/closeClaimAccount.ts b/src/svm/clients/SvmSpoke/instructions/closeClaimAccount.ts deleted file mode 100644 index bc6c88f85..000000000 --- a/src/svm/clients/SvmSpoke/instructions/closeClaimAccount.ts +++ /dev/null @@ -1,307 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const CLOSE_CLAIM_ACCOUNT_DISCRIMINATOR = new Uint8Array([ - 241, 146, 203, 216, 58, 222, 91, 118, -]); - -export function getCloseClaimAccountDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - CLOSE_CLAIM_ACCOUNT_DISCRIMINATOR - ); -} - -export type CloseClaimAccountInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountMint extends string | AccountMeta = string, - TAccountRefundAddress extends string | AccountMeta = string, - TAccountClaimAccount extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountMint extends string - ? ReadonlyAccount - : TAccountMint, - TAccountRefundAddress extends string - ? ReadonlyAccount - : TAccountRefundAddress, - TAccountClaimAccount extends string - ? WritableAccount - : TAccountClaimAccount, - ...TRemainingAccounts, - ] - >; - -export type CloseClaimAccountInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type CloseClaimAccountInstructionDataArgs = {}; - -export function getCloseClaimAccountInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: CLOSE_CLAIM_ACCOUNT_DISCRIMINATOR }) - ); -} - -export function getCloseClaimAccountInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getCloseClaimAccountInstructionDataCodec(): Codec< - CloseClaimAccountInstructionDataArgs, - CloseClaimAccountInstructionData -> { - return combineCodec( - getCloseClaimAccountInstructionDataEncoder(), - getCloseClaimAccountInstructionDataDecoder() - ); -} - -export type CloseClaimAccountAsyncInput< - TAccountSigner extends string = string, - TAccountMint extends string = string, - TAccountRefundAddress extends string = string, - TAccountClaimAccount extends string = string, -> = { - signer: TransactionSigner; - mint: Address; - refundAddress: Address; - claimAccount?: Address; -}; - -export async function getCloseClaimAccountInstructionAsync< - TAccountSigner extends string, - TAccountMint extends string, - TAccountRefundAddress extends string, - TAccountClaimAccount extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: CloseClaimAccountAsyncInput< - TAccountSigner, - TAccountMint, - TAccountRefundAddress, - TAccountClaimAccount - >, - config?: { programAddress?: TProgramAddress } -): Promise< - CloseClaimAccountInstruction< - TProgramAddress, - TAccountSigner, - TAccountMint, - TAccountRefundAddress, - TAccountClaimAccount - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - refundAddress: { value: input.refundAddress ?? null, isWritable: false }, - claimAccount: { value: input.claimAccount ?? null, isWritable: true }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.claimAccount.value) { - accounts.claimAccount.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 99, 108, 97, 105, 109, 95, 97, 99, 99, 111, 117, 110, 116, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - getAddressEncoder().encode(expectAddress(accounts.refundAddress.value)), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.refundAddress), - getAccountMeta(accounts.claimAccount), - ], - programAddress, - data: getCloseClaimAccountInstructionDataEncoder().encode({}), - } as CloseClaimAccountInstruction< - TProgramAddress, - TAccountSigner, - TAccountMint, - TAccountRefundAddress, - TAccountClaimAccount - >; - - return instruction; -} - -export type CloseClaimAccountInput< - TAccountSigner extends string = string, - TAccountMint extends string = string, - TAccountRefundAddress extends string = string, - TAccountClaimAccount extends string = string, -> = { - signer: TransactionSigner; - mint: Address; - refundAddress: Address; - claimAccount: Address; -}; - -export function getCloseClaimAccountInstruction< - TAccountSigner extends string, - TAccountMint extends string, - TAccountRefundAddress extends string, - TAccountClaimAccount extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: CloseClaimAccountInput< - TAccountSigner, - TAccountMint, - TAccountRefundAddress, - TAccountClaimAccount - >, - config?: { programAddress?: TProgramAddress } -): CloseClaimAccountInstruction< - TProgramAddress, - TAccountSigner, - TAccountMint, - TAccountRefundAddress, - TAccountClaimAccount -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - refundAddress: { value: input.refundAddress ?? null, isWritable: false }, - claimAccount: { value: input.claimAccount ?? null, isWritable: true }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.refundAddress), - getAccountMeta(accounts.claimAccount), - ], - programAddress, - data: getCloseClaimAccountInstructionDataEncoder().encode({}), - } as CloseClaimAccountInstruction< - TProgramAddress, - TAccountSigner, - TAccountMint, - TAccountRefundAddress, - TAccountClaimAccount - >; - - return instruction; -} - -export type ParsedCloseClaimAccountInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - mint: TAccountMetas[1]; - refundAddress: TAccountMetas[2]; - claimAccount: TAccountMetas[3]; - }; - data: CloseClaimAccountInstructionData; -}; - -export function parseCloseClaimAccountInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedCloseClaimAccountInstruction { - if (instruction.accounts.length < 4) { - // 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: { - signer: getNextAccount(), - mint: getNextAccount(), - refundAddress: getNextAccount(), - claimAccount: getNextAccount(), - }, - data: getCloseClaimAccountInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/closeFillPda.ts b/src/svm/clients/SvmSpoke/instructions/closeFillPda.ts deleted file mode 100644 index 868ab5109..000000000 --- a/src/svm/clients/SvmSpoke/instructions/closeFillPda.ts +++ /dev/null @@ -1,194 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const CLOSE_FILL_PDA_DISCRIMINATOR = new Uint8Array([ - 224, 39, 208, 68, 8, 226, 23, 214, -]); - -export function getCloseFillPdaDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - CLOSE_FILL_PDA_DISCRIMINATOR - ); -} - -export type CloseFillPdaInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountFillStatus extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountState extends string - ? ReadonlyAccount - : TAccountState, - TAccountFillStatus extends string - ? WritableAccount - : TAccountFillStatus, - ...TRemainingAccounts, - ] - >; - -export type CloseFillPdaInstructionData = { discriminator: ReadonlyUint8Array }; - -export type CloseFillPdaInstructionDataArgs = {}; - -export function getCloseFillPdaInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: CLOSE_FILL_PDA_DISCRIMINATOR }) - ); -} - -export function getCloseFillPdaInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getCloseFillPdaInstructionDataCodec(): Codec< - CloseFillPdaInstructionDataArgs, - CloseFillPdaInstructionData -> { - return combineCodec( - getCloseFillPdaInstructionDataEncoder(), - getCloseFillPdaInstructionDataDecoder() - ); -} - -export type CloseFillPdaInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountFillStatus extends string = string, -> = { - signer: TransactionSigner; - state: Address; - fillStatus: Address; -}; - -export function getCloseFillPdaInstruction< - TAccountSigner extends string, - TAccountState extends string, - TAccountFillStatus extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: CloseFillPdaInput, - config?: { programAddress?: TProgramAddress } -): CloseFillPdaInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountFillStatus -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: false }, - fillStatus: { value: input.fillStatus ?? null, isWritable: true }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.fillStatus), - ], - programAddress, - data: getCloseFillPdaInstructionDataEncoder().encode({}), - } as CloseFillPdaInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountFillStatus - >; - - return instruction; -} - -export type ParsedCloseFillPdaInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - state: TAccountMetas[1]; - fillStatus: TAccountMetas[2]; - }; - data: CloseFillPdaInstructionData; -}; - -export function parseCloseFillPdaInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedCloseFillPdaInstruction { - 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: { - signer: getNextAccount(), - state: getNextAccount(), - fillStatus: getNextAccount(), - }, - data: getCloseFillPdaInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/closeInstructionParams.ts b/src/svm/clients/SvmSpoke/instructions/closeInstructionParams.ts deleted file mode 100644 index 68b8e6537..000000000 --- a/src/svm/clients/SvmSpoke/instructions/closeInstructionParams.ts +++ /dev/null @@ -1,270 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const CLOSE_INSTRUCTION_PARAMS_DISCRIMINATOR = new Uint8Array([ - 224, 44, 254, 10, 216, 8, 172, 96, -]); - -export function getCloseInstructionParamsDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - CLOSE_INSTRUCTION_PARAMS_DISCRIMINATOR - ); -} - -export type CloseInstructionParamsInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountInstructionParams extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountInstructionParams extends string - ? WritableAccount - : TAccountInstructionParams, - ...TRemainingAccounts, - ] - >; - -export type CloseInstructionParamsInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type CloseInstructionParamsInstructionDataArgs = {}; - -export function getCloseInstructionParamsInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ - ...value, - discriminator: CLOSE_INSTRUCTION_PARAMS_DISCRIMINATOR, - }) - ); -} - -export function getCloseInstructionParamsInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getCloseInstructionParamsInstructionDataCodec(): Codec< - CloseInstructionParamsInstructionDataArgs, - CloseInstructionParamsInstructionData -> { - return combineCodec( - getCloseInstructionParamsInstructionDataEncoder(), - getCloseInstructionParamsInstructionDataDecoder() - ); -} - -export type CloseInstructionParamsAsyncInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, -> = { - signer: TransactionSigner; - instructionParams?: Address; -}; - -export async function getCloseInstructionParamsInstructionAsync< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: CloseInstructionParamsAsyncInput< - TAccountSigner, - TAccountInstructionParams - >, - config?: { programAddress?: TProgramAddress } -): Promise< - CloseInstructionParamsInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.instructionParams.value) { - accounts.instructionParams.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, - 114, 97, 109, 115, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.signer.value)), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - ], - programAddress, - data: getCloseInstructionParamsInstructionDataEncoder().encode({}), - } as CloseInstructionParamsInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams - >; - - return instruction; -} - -export type CloseInstructionParamsInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, -> = { - signer: TransactionSigner; - instructionParams: Address; -}; - -export function getCloseInstructionParamsInstruction< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: CloseInstructionParamsInput, - config?: { programAddress?: TProgramAddress } -): CloseInstructionParamsInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - ], - programAddress, - data: getCloseInstructionParamsInstructionDataEncoder().encode({}), - } as CloseInstructionParamsInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams - >; - - return instruction; -} - -export type ParsedCloseInstructionParamsInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - instructionParams: TAccountMetas[1]; - }; - data: CloseInstructionParamsInstructionData; -}; - -export function parseCloseInstructionParamsInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedCloseInstructionParamsInstruction { - if (instruction.accounts.length < 2) { - // 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: { - signer: getNextAccount(), - instructionParams: getNextAccount(), - }, - data: getCloseInstructionParamsInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/createTokenAccounts.ts b/src/svm/clients/SvmSpoke/instructions/createTokenAccounts.ts deleted file mode 100644 index aceebf3be..000000000 --- a/src/svm/clients/SvmSpoke/instructions/createTokenAccounts.ts +++ /dev/null @@ -1,252 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const CREATE_TOKEN_ACCOUNTS_DISCRIMINATOR = new Uint8Array([ - 163, 216, 49, 204, 97, 16, 80, 167, -]); - -export function getCreateTokenAccountsDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - CREATE_TOKEN_ACCOUNTS_DISCRIMINATOR - ); -} - -export type CreateTokenAccountsInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountMint extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountAssociatedTokenProgram extends string | AccountMeta = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountMint extends string - ? ReadonlyAccount - : TAccountMint, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountAssociatedTokenProgram extends string - ? ReadonlyAccount - : TAccountAssociatedTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type CreateTokenAccountsInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type CreateTokenAccountsInstructionDataArgs = {}; - -export function getCreateTokenAccountsInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ - ...value, - discriminator: CREATE_TOKEN_ACCOUNTS_DISCRIMINATOR, - }) - ); -} - -export function getCreateTokenAccountsInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getCreateTokenAccountsInstructionDataCodec(): Codec< - CreateTokenAccountsInstructionDataArgs, - CreateTokenAccountsInstructionData -> { - return combineCodec( - getCreateTokenAccountsInstructionDataEncoder(), - getCreateTokenAccountsInstructionDataDecoder() - ); -} - -export type CreateTokenAccountsInput< - TAccountSigner extends string = string, - TAccountMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountAssociatedTokenProgram extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - mint: Address; - tokenProgram?: Address; - associatedTokenProgram?: Address; - systemProgram?: Address; -}; - -export function getCreateTokenAccountsInstruction< - TAccountSigner extends string, - TAccountMint extends string, - TAccountTokenProgram extends string, - TAccountAssociatedTokenProgram extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: CreateTokenAccountsInput< - TAccountSigner, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): CreateTokenAccountsInstruction< - TProgramAddress, - TAccountSigner, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - associatedTokenProgram: { - value: input.associatedTokenProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.associatedTokenProgram.value) { - accounts.associatedTokenProgram.value = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.associatedTokenProgram), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getCreateTokenAccountsInstructionDataEncoder().encode({}), - } as CreateTokenAccountsInstruction< - TProgramAddress, - TAccountSigner, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedCreateTokenAccountsInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - mint: TAccountMetas[1]; - tokenProgram: TAccountMetas[2]; - associatedTokenProgram: TAccountMetas[3]; - systemProgram: TAccountMetas[4]; - }; - data: CreateTokenAccountsInstructionData; -}; - -export function parseCreateTokenAccountsInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedCreateTokenAccountsInstruction { - if (instruction.accounts.length < 5) { - // 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: { - signer: getNextAccount(), - mint: getNextAccount(), - tokenProgram: getNextAccount(), - associatedTokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getCreateTokenAccountsInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/deposit.ts b/src/svm/clients/SvmSpoke/instructions/deposit.ts deleted file mode 100644 index 13ff78c19..000000000 --- a/src/svm/clients/SvmSpoke/instructions/deposit.ts +++ /dev/null @@ -1,614 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - expectSome, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const DEPOSIT_DISCRIMINATOR = new Uint8Array([ - 242, 35, 198, 137, 82, 225, 242, 182, -]); - -export function getDepositDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(DEPOSIT_DISCRIMINATOR); -} - -export type DepositInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountDelegate extends string | AccountMeta = string, - TAccountDepositorTokenAccount extends string | AccountMeta = string, - TAccountVault extends string | AccountMeta = string, - TAccountMint extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountAssociatedTokenProgram extends string | AccountMeta = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountState extends string - ? WritableAccount - : TAccountState, - TAccountDelegate extends string - ? ReadonlyAccount - : TAccountDelegate, - TAccountDepositorTokenAccount extends string - ? WritableAccount - : TAccountDepositorTokenAccount, - TAccountVault extends string - ? WritableAccount - : TAccountVault, - TAccountMint extends string - ? ReadonlyAccount - : TAccountMint, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountAssociatedTokenProgram extends string - ? ReadonlyAccount - : TAccountAssociatedTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type DepositInstructionData = { - discriminator: ReadonlyUint8Array; - depositor: Address; - recipient: Address; - inputToken: Address; - outputToken: Address; - inputAmount: bigint; - outputAmount: ReadonlyUint8Array; - destinationChainId: bigint; - exclusiveRelayer: Address; - quoteTimestamp: number; - fillDeadline: number; - exclusivityParameter: number; - message: ReadonlyUint8Array; -}; - -export type DepositInstructionDataArgs = { - depositor: Address; - recipient: Address; - inputToken: Address; - outputToken: Address; - inputAmount: number | bigint; - outputAmount: ReadonlyUint8Array; - destinationChainId: number | bigint; - exclusiveRelayer: Address; - quoteTimestamp: number; - fillDeadline: number; - exclusivityParameter: number; - message: ReadonlyUint8Array; -}; - -export function getDepositInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['depositor', getAddressEncoder()], - ['recipient', getAddressEncoder()], - ['inputToken', getAddressEncoder()], - ['outputToken', getAddressEncoder()], - ['inputAmount', getU64Encoder()], - ['outputAmount', fixEncoderSize(getBytesEncoder(), 32)], - ['destinationChainId', getU64Encoder()], - ['exclusiveRelayer', getAddressEncoder()], - ['quoteTimestamp', getU32Encoder()], - ['fillDeadline', getU32Encoder()], - ['exclusivityParameter', getU32Encoder()], - ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ ...value, discriminator: DEPOSIT_DISCRIMINATOR }) - ); -} - -export function getDepositInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['depositor', getAddressDecoder()], - ['recipient', getAddressDecoder()], - ['inputToken', getAddressDecoder()], - ['outputToken', getAddressDecoder()], - ['inputAmount', getU64Decoder()], - ['outputAmount', fixDecoderSize(getBytesDecoder(), 32)], - ['destinationChainId', getU64Decoder()], - ['exclusiveRelayer', getAddressDecoder()], - ['quoteTimestamp', getU32Decoder()], - ['fillDeadline', getU32Decoder()], - ['exclusivityParameter', getU32Decoder()], - ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getDepositInstructionDataCodec(): Codec< - DepositInstructionDataArgs, - DepositInstructionData -> { - return combineCodec( - getDepositInstructionDataEncoder(), - getDepositInstructionDataDecoder() - ); -} - -export type DepositAsyncInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountDelegate extends string = string, - TAccountDepositorTokenAccount extends string = string, - TAccountVault extends string = string, - TAccountMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountAssociatedTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - delegate: Address; - depositorTokenAccount?: Address; - vault?: Address; - mint: Address; - tokenProgram?: Address; - associatedTokenProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - depositor: DepositInstructionDataArgs['depositor']; - recipient: DepositInstructionDataArgs['recipient']; - inputToken: DepositInstructionDataArgs['inputToken']; - outputToken: DepositInstructionDataArgs['outputToken']; - inputAmount: DepositInstructionDataArgs['inputAmount']; - outputAmount: DepositInstructionDataArgs['outputAmount']; - destinationChainId: DepositInstructionDataArgs['destinationChainId']; - exclusiveRelayer: DepositInstructionDataArgs['exclusiveRelayer']; - quoteTimestamp: DepositInstructionDataArgs['quoteTimestamp']; - fillDeadline: DepositInstructionDataArgs['fillDeadline']; - exclusivityParameter: DepositInstructionDataArgs['exclusivityParameter']; - message: DepositInstructionDataArgs['message']; -}; - -export async function getDepositInstructionAsync< - TAccountSigner extends string, - TAccountState extends string, - TAccountDelegate extends string, - TAccountDepositorTokenAccount extends string, - TAccountVault extends string, - TAccountMint extends string, - TAccountTokenProgram extends string, - TAccountAssociatedTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: DepositAsyncInput< - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - DepositInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - delegate: { value: input.delegate ?? null, isWritable: false }, - depositorTokenAccount: { - value: input.depositorTokenAccount ?? null, - isWritable: true, - }, - vault: { value: input.vault ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - associatedTokenProgram: { - value: input.associatedTokenProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.depositorTokenAccount.value) { - accounts.depositorTokenAccount.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getAddressEncoder().encode(expectSome(args.depositor)), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.vault.value) { - accounts.vault.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getAddressEncoder().encode(expectAddress(accounts.state.value)), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.associatedTokenProgram.value) { - accounts.associatedTokenProgram.value = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.delegate), - getAccountMeta(accounts.depositorTokenAccount), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.associatedTokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDepositInstructionDataEncoder().encode( - args as DepositInstructionDataArgs - ), - } as DepositInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type DepositInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountDelegate extends string = string, - TAccountDepositorTokenAccount extends string = string, - TAccountVault extends string = string, - TAccountMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountAssociatedTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - delegate: Address; - depositorTokenAccount: Address; - vault: Address; - mint: Address; - tokenProgram?: Address; - associatedTokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - depositor: DepositInstructionDataArgs['depositor']; - recipient: DepositInstructionDataArgs['recipient']; - inputToken: DepositInstructionDataArgs['inputToken']; - outputToken: DepositInstructionDataArgs['outputToken']; - inputAmount: DepositInstructionDataArgs['inputAmount']; - outputAmount: DepositInstructionDataArgs['outputAmount']; - destinationChainId: DepositInstructionDataArgs['destinationChainId']; - exclusiveRelayer: DepositInstructionDataArgs['exclusiveRelayer']; - quoteTimestamp: DepositInstructionDataArgs['quoteTimestamp']; - fillDeadline: DepositInstructionDataArgs['fillDeadline']; - exclusivityParameter: DepositInstructionDataArgs['exclusivityParameter']; - message: DepositInstructionDataArgs['message']; -}; - -export function getDepositInstruction< - TAccountSigner extends string, - TAccountState extends string, - TAccountDelegate extends string, - TAccountDepositorTokenAccount extends string, - TAccountVault extends string, - TAccountMint extends string, - TAccountTokenProgram extends string, - TAccountAssociatedTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: DepositInput< - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): DepositInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - delegate: { value: input.delegate ?? null, isWritable: false }, - depositorTokenAccount: { - value: input.depositorTokenAccount ?? null, - isWritable: true, - }, - vault: { value: input.vault ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - associatedTokenProgram: { - value: input.associatedTokenProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.associatedTokenProgram.value) { - accounts.associatedTokenProgram.value = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.delegate), - getAccountMeta(accounts.depositorTokenAccount), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.associatedTokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDepositInstructionDataEncoder().encode( - args as DepositInstructionDataArgs - ), - } as DepositInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedDepositInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - state: TAccountMetas[1]; - delegate: TAccountMetas[2]; - depositorTokenAccount: TAccountMetas[3]; - vault: TAccountMetas[4]; - mint: TAccountMetas[5]; - tokenProgram: TAccountMetas[6]; - associatedTokenProgram: TAccountMetas[7]; - systemProgram: TAccountMetas[8]; - eventAuthority: TAccountMetas[9]; - program: TAccountMetas[10]; - }; - data: DepositInstructionData; -}; - -export function parseDepositInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedDepositInstruction { - if (instruction.accounts.length < 11) { - // 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: { - signer: getNextAccount(), - state: getNextAccount(), - delegate: getNextAccount(), - depositorTokenAccount: getNextAccount(), - vault: getNextAccount(), - mint: getNextAccount(), - tokenProgram: getNextAccount(), - associatedTokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getDepositInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/depositNow.ts b/src/svm/clients/SvmSpoke/instructions/depositNow.ts deleted file mode 100644 index 1cae4240e..000000000 --- a/src/svm/clients/SvmSpoke/instructions/depositNow.ts +++ /dev/null @@ -1,608 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - expectSome, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const DEPOSIT_NOW_DISCRIMINATOR = new Uint8Array([ - 75, 228, 135, 221, 200, 25, 148, 26, -]); - -export function getDepositNowDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(DEPOSIT_NOW_DISCRIMINATOR); -} - -export type DepositNowInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountDelegate extends string | AccountMeta = string, - TAccountDepositorTokenAccount extends string | AccountMeta = string, - TAccountVault extends string | AccountMeta = string, - TAccountMint extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountAssociatedTokenProgram extends string | AccountMeta = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountState extends string - ? WritableAccount - : TAccountState, - TAccountDelegate extends string - ? ReadonlyAccount - : TAccountDelegate, - TAccountDepositorTokenAccount extends string - ? WritableAccount - : TAccountDepositorTokenAccount, - TAccountVault extends string - ? WritableAccount - : TAccountVault, - TAccountMint extends string - ? ReadonlyAccount - : TAccountMint, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountAssociatedTokenProgram extends string - ? ReadonlyAccount - : TAccountAssociatedTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type DepositNowInstructionData = { - discriminator: ReadonlyUint8Array; - depositor: Address; - recipient: Address; - inputToken: Address; - outputToken: Address; - inputAmount: bigint; - outputAmount: ReadonlyUint8Array; - destinationChainId: bigint; - exclusiveRelayer: Address; - fillDeadlineOffset: number; - exclusivityParameter: number; - message: ReadonlyUint8Array; -}; - -export type DepositNowInstructionDataArgs = { - depositor: Address; - recipient: Address; - inputToken: Address; - outputToken: Address; - inputAmount: number | bigint; - outputAmount: ReadonlyUint8Array; - destinationChainId: number | bigint; - exclusiveRelayer: Address; - fillDeadlineOffset: number; - exclusivityParameter: number; - message: ReadonlyUint8Array; -}; - -export function getDepositNowInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['depositor', getAddressEncoder()], - ['recipient', getAddressEncoder()], - ['inputToken', getAddressEncoder()], - ['outputToken', getAddressEncoder()], - ['inputAmount', getU64Encoder()], - ['outputAmount', fixEncoderSize(getBytesEncoder(), 32)], - ['destinationChainId', getU64Encoder()], - ['exclusiveRelayer', getAddressEncoder()], - ['fillDeadlineOffset', getU32Encoder()], - ['exclusivityParameter', getU32Encoder()], - ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ ...value, discriminator: DEPOSIT_NOW_DISCRIMINATOR }) - ); -} - -export function getDepositNowInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['depositor', getAddressDecoder()], - ['recipient', getAddressDecoder()], - ['inputToken', getAddressDecoder()], - ['outputToken', getAddressDecoder()], - ['inputAmount', getU64Decoder()], - ['outputAmount', fixDecoderSize(getBytesDecoder(), 32)], - ['destinationChainId', getU64Decoder()], - ['exclusiveRelayer', getAddressDecoder()], - ['fillDeadlineOffset', getU32Decoder()], - ['exclusivityParameter', getU32Decoder()], - ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getDepositNowInstructionDataCodec(): Codec< - DepositNowInstructionDataArgs, - DepositNowInstructionData -> { - return combineCodec( - getDepositNowInstructionDataEncoder(), - getDepositNowInstructionDataDecoder() - ); -} - -export type DepositNowAsyncInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountDelegate extends string = string, - TAccountDepositorTokenAccount extends string = string, - TAccountVault extends string = string, - TAccountMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountAssociatedTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - delegate: Address; - depositorTokenAccount?: Address; - vault?: Address; - mint: Address; - tokenProgram?: Address; - associatedTokenProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - depositor: DepositNowInstructionDataArgs['depositor']; - recipient: DepositNowInstructionDataArgs['recipient']; - inputToken: DepositNowInstructionDataArgs['inputToken']; - outputToken: DepositNowInstructionDataArgs['outputToken']; - inputAmount: DepositNowInstructionDataArgs['inputAmount']; - outputAmount: DepositNowInstructionDataArgs['outputAmount']; - destinationChainId: DepositNowInstructionDataArgs['destinationChainId']; - exclusiveRelayer: DepositNowInstructionDataArgs['exclusiveRelayer']; - fillDeadlineOffset: DepositNowInstructionDataArgs['fillDeadlineOffset']; - exclusivityParameter: DepositNowInstructionDataArgs['exclusivityParameter']; - message: DepositNowInstructionDataArgs['message']; -}; - -export async function getDepositNowInstructionAsync< - TAccountSigner extends string, - TAccountState extends string, - TAccountDelegate extends string, - TAccountDepositorTokenAccount extends string, - TAccountVault extends string, - TAccountMint extends string, - TAccountTokenProgram extends string, - TAccountAssociatedTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: DepositNowAsyncInput< - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - DepositNowInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - delegate: { value: input.delegate ?? null, isWritable: false }, - depositorTokenAccount: { - value: input.depositorTokenAccount ?? null, - isWritable: true, - }, - vault: { value: input.vault ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - associatedTokenProgram: { - value: input.associatedTokenProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.depositorTokenAccount.value) { - accounts.depositorTokenAccount.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getAddressEncoder().encode(expectSome(args.depositor)), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.vault.value) { - accounts.vault.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getAddressEncoder().encode(expectAddress(accounts.state.value)), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.associatedTokenProgram.value) { - accounts.associatedTokenProgram.value = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.delegate), - getAccountMeta(accounts.depositorTokenAccount), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.associatedTokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDepositNowInstructionDataEncoder().encode( - args as DepositNowInstructionDataArgs - ), - } as DepositNowInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type DepositNowInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountDelegate extends string = string, - TAccountDepositorTokenAccount extends string = string, - TAccountVault extends string = string, - TAccountMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountAssociatedTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - delegate: Address; - depositorTokenAccount: Address; - vault: Address; - mint: Address; - tokenProgram?: Address; - associatedTokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - depositor: DepositNowInstructionDataArgs['depositor']; - recipient: DepositNowInstructionDataArgs['recipient']; - inputToken: DepositNowInstructionDataArgs['inputToken']; - outputToken: DepositNowInstructionDataArgs['outputToken']; - inputAmount: DepositNowInstructionDataArgs['inputAmount']; - outputAmount: DepositNowInstructionDataArgs['outputAmount']; - destinationChainId: DepositNowInstructionDataArgs['destinationChainId']; - exclusiveRelayer: DepositNowInstructionDataArgs['exclusiveRelayer']; - fillDeadlineOffset: DepositNowInstructionDataArgs['fillDeadlineOffset']; - exclusivityParameter: DepositNowInstructionDataArgs['exclusivityParameter']; - message: DepositNowInstructionDataArgs['message']; -}; - -export function getDepositNowInstruction< - TAccountSigner extends string, - TAccountState extends string, - TAccountDelegate extends string, - TAccountDepositorTokenAccount extends string, - TAccountVault extends string, - TAccountMint extends string, - TAccountTokenProgram extends string, - TAccountAssociatedTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: DepositNowInput< - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): DepositNowInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - delegate: { value: input.delegate ?? null, isWritable: false }, - depositorTokenAccount: { - value: input.depositorTokenAccount ?? null, - isWritable: true, - }, - vault: { value: input.vault ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - associatedTokenProgram: { - value: input.associatedTokenProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.associatedTokenProgram.value) { - accounts.associatedTokenProgram.value = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.delegate), - getAccountMeta(accounts.depositorTokenAccount), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.associatedTokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDepositNowInstructionDataEncoder().encode( - args as DepositNowInstructionDataArgs - ), - } as DepositNowInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedDepositNowInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - state: TAccountMetas[1]; - delegate: TAccountMetas[2]; - depositorTokenAccount: TAccountMetas[3]; - vault: TAccountMetas[4]; - mint: TAccountMetas[5]; - tokenProgram: TAccountMetas[6]; - associatedTokenProgram: TAccountMetas[7]; - systemProgram: TAccountMetas[8]; - eventAuthority: TAccountMetas[9]; - program: TAccountMetas[10]; - }; - data: DepositNowInstructionData; -}; - -export function parseDepositNowInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedDepositNowInstruction { - if (instruction.accounts.length < 11) { - // 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: { - signer: getNextAccount(), - state: getNextAccount(), - delegate: getNextAccount(), - depositorTokenAccount: getNextAccount(), - vault: getNextAccount(), - mint: getNextAccount(), - tokenProgram: getNextAccount(), - associatedTokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getDepositNowInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/emergencyDeleteRootBundle.ts b/src/svm/clients/SvmSpoke/instructions/emergencyDeleteRootBundle.ts deleted file mode 100644 index 6dc0c7451..000000000 --- a/src/svm/clients/SvmSpoke/instructions/emergencyDeleteRootBundle.ts +++ /dev/null @@ -1,371 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const EMERGENCY_DELETE_ROOT_BUNDLE_DISCRIMINATOR = new Uint8Array([ - 226, 158, 1, 74, 84, 113, 24, 152, -]); - -export function getEmergencyDeleteRootBundleDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - EMERGENCY_DELETE_ROOT_BUNDLE_DISCRIMINATOR - ); -} - -export type EmergencyDeleteRootBundleInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountCloser extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountRootBundle extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountCloser extends string - ? WritableAccount - : TAccountCloser, - TAccountState extends string - ? ReadonlyAccount - : TAccountState, - TAccountRootBundle extends string - ? WritableAccount - : TAccountRootBundle, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type EmergencyDeleteRootBundleInstructionData = { - discriminator: ReadonlyUint8Array; - rootBundleId: number; -}; - -export type EmergencyDeleteRootBundleInstructionDataArgs = { - rootBundleId: number; -}; - -export function getEmergencyDeleteRootBundleInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['rootBundleId', getU32Encoder()], - ]), - (value) => ({ - ...value, - discriminator: EMERGENCY_DELETE_ROOT_BUNDLE_DISCRIMINATOR, - }) - ); -} - -export function getEmergencyDeleteRootBundleInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['rootBundleId', getU32Decoder()], - ]); -} - -export function getEmergencyDeleteRootBundleInstructionDataCodec(): Codec< - EmergencyDeleteRootBundleInstructionDataArgs, - EmergencyDeleteRootBundleInstructionData -> { - return combineCodec( - getEmergencyDeleteRootBundleInstructionDataEncoder(), - getEmergencyDeleteRootBundleInstructionDataDecoder() - ); -} - -export type EmergencyDeleteRootBundleAsyncInput< - TAccountSigner extends string = string, - TAccountCloser extends string = string, - TAccountState extends string = string, - TAccountRootBundle extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - closer: Address; - state: Address; - rootBundle: Address; - eventAuthority?: Address; - program: Address; - rootBundleId: EmergencyDeleteRootBundleInstructionDataArgs['rootBundleId']; -}; - -export async function getEmergencyDeleteRootBundleInstructionAsync< - TAccountSigner extends string, - TAccountCloser extends string, - TAccountState extends string, - TAccountRootBundle extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: EmergencyDeleteRootBundleAsyncInput< - TAccountSigner, - TAccountCloser, - TAccountState, - TAccountRootBundle, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - EmergencyDeleteRootBundleInstruction< - TProgramAddress, - TAccountSigner, - TAccountCloser, - TAccountState, - TAccountRootBundle, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - closer: { value: input.closer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: false }, - rootBundle: { value: input.rootBundle ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.closer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.rootBundle), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getEmergencyDeleteRootBundleInstructionDataEncoder().encode( - args as EmergencyDeleteRootBundleInstructionDataArgs - ), - } as EmergencyDeleteRootBundleInstruction< - TProgramAddress, - TAccountSigner, - TAccountCloser, - TAccountState, - TAccountRootBundle, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type EmergencyDeleteRootBundleInput< - TAccountSigner extends string = string, - TAccountCloser extends string = string, - TAccountState extends string = string, - TAccountRootBundle extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - closer: Address; - state: Address; - rootBundle: Address; - eventAuthority: Address; - program: Address; - rootBundleId: EmergencyDeleteRootBundleInstructionDataArgs['rootBundleId']; -}; - -export function getEmergencyDeleteRootBundleInstruction< - TAccountSigner extends string, - TAccountCloser extends string, - TAccountState extends string, - TAccountRootBundle extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: EmergencyDeleteRootBundleInput< - TAccountSigner, - TAccountCloser, - TAccountState, - TAccountRootBundle, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): EmergencyDeleteRootBundleInstruction< - TProgramAddress, - TAccountSigner, - TAccountCloser, - TAccountState, - TAccountRootBundle, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - closer: { value: input.closer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: false }, - rootBundle: { value: input.rootBundle ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.signer), - getAccountMeta(accounts.closer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.rootBundle), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getEmergencyDeleteRootBundleInstructionDataEncoder().encode( - args as EmergencyDeleteRootBundleInstructionDataArgs - ), - } as EmergencyDeleteRootBundleInstruction< - TProgramAddress, - TAccountSigner, - TAccountCloser, - TAccountState, - TAccountRootBundle, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedEmergencyDeleteRootBundleInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - closer: TAccountMetas[1]; - state: TAccountMetas[2]; - rootBundle: TAccountMetas[3]; - eventAuthority: TAccountMetas[4]; - program: TAccountMetas[5]; - }; - data: EmergencyDeleteRootBundleInstructionData; -}; - -export function parseEmergencyDeleteRootBundleInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedEmergencyDeleteRootBundleInstruction { - if (instruction.accounts.length < 6) { - // 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: { - signer: getNextAccount(), - closer: getNextAccount(), - state: getNextAccount(), - rootBundle: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getEmergencyDeleteRootBundleInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeaf.ts b/src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeaf.ts deleted file mode 100644 index 7cfed475f..000000000 --- a/src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeaf.ts +++ /dev/null @@ -1,536 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const EXECUTE_RELAYER_REFUND_LEAF_DISCRIMINATOR = new Uint8Array([ - 27, 136, 159, 240, 127, 68, 123, 164, -]); - -export function getExecuteRelayerRefundLeafDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - EXECUTE_RELAYER_REFUND_LEAF_DISCRIMINATOR - ); -} - -export type ExecuteRelayerRefundLeafInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountInstructionParams extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountRootBundle extends string | AccountMeta = string, - TAccountVault extends string | AccountMeta = string, - TAccountMint extends string | AccountMeta = string, - TAccountTransferLiability extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountInstructionParams extends string - ? WritableAccount - : TAccountInstructionParams, - TAccountState extends string - ? ReadonlyAccount - : TAccountState, - TAccountRootBundle extends string - ? WritableAccount - : TAccountRootBundle, - TAccountVault extends string - ? WritableAccount - : TAccountVault, - TAccountMint extends string - ? ReadonlyAccount - : TAccountMint, - TAccountTransferLiability extends string - ? WritableAccount - : TAccountTransferLiability, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type ExecuteRelayerRefundLeafInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type ExecuteRelayerRefundLeafInstructionDataArgs = {}; - -export function getExecuteRelayerRefundLeafInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ - ...value, - discriminator: EXECUTE_RELAYER_REFUND_LEAF_DISCRIMINATOR, - }) - ); -} - -export function getExecuteRelayerRefundLeafInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getExecuteRelayerRefundLeafInstructionDataCodec(): Codec< - ExecuteRelayerRefundLeafInstructionDataArgs, - ExecuteRelayerRefundLeafInstructionData -> { - return combineCodec( - getExecuteRelayerRefundLeafInstructionDataEncoder(), - getExecuteRelayerRefundLeafInstructionDataDecoder() - ); -} - -export type ExecuteRelayerRefundLeafAsyncInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountState extends string = string, - TAccountRootBundle extends string = string, - TAccountVault extends string = string, - TAccountMint extends string = string, - TAccountTransferLiability extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams?: Address; - state: Address; - rootBundle: Address; - vault?: Address; - mint: Address; - transferLiability?: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getExecuteRelayerRefundLeafInstructionAsync< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountState extends string, - TAccountRootBundle extends string, - TAccountVault extends string, - TAccountMint extends string, - TAccountTransferLiability extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: ExecuteRelayerRefundLeafAsyncInput< - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountVault, - TAccountMint, - TAccountTransferLiability, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - ExecuteRelayerRefundLeafInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountVault, - TAccountMint, - TAccountTransferLiability, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - state: { value: input.state ?? null, isWritable: false }, - rootBundle: { value: input.rootBundle ?? null, isWritable: true }, - vault: { value: input.vault ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - transferLiability: { - value: input.transferLiability ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.instructionParams.value) { - accounts.instructionParams.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, - 114, 97, 109, 115, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.signer.value)), - ], - }); - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.vault.value) { - accounts.vault.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getAddressEncoder().encode(expectAddress(accounts.state.value)), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.transferLiability.value) { - accounts.transferLiability.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 116, 114, 97, 110, 115, 102, 101, 114, 95, 108, 105, 97, 98, 105, - 108, 105, 116, 121, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.state), - getAccountMeta(accounts.rootBundle), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.transferLiability), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getExecuteRelayerRefundLeafInstructionDataEncoder().encode({}), - } as ExecuteRelayerRefundLeafInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountVault, - TAccountMint, - TAccountTransferLiability, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ExecuteRelayerRefundLeafInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountState extends string = string, - TAccountRootBundle extends string = string, - TAccountVault extends string = string, - TAccountMint extends string = string, - TAccountTransferLiability extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams: Address; - state: Address; - rootBundle: Address; - vault: Address; - mint: Address; - transferLiability: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; -}; - -export function getExecuteRelayerRefundLeafInstruction< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountState extends string, - TAccountRootBundle extends string, - TAccountVault extends string, - TAccountMint extends string, - TAccountTransferLiability extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: ExecuteRelayerRefundLeafInput< - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountVault, - TAccountMint, - TAccountTransferLiability, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): ExecuteRelayerRefundLeafInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountVault, - TAccountMint, - TAccountTransferLiability, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - state: { value: input.state ?? null, isWritable: false }, - rootBundle: { value: input.rootBundle ?? null, isWritable: true }, - vault: { value: input.vault ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - transferLiability: { - value: input.transferLiability ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.state), - getAccountMeta(accounts.rootBundle), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.transferLiability), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getExecuteRelayerRefundLeafInstructionDataEncoder().encode({}), - } as ExecuteRelayerRefundLeafInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountVault, - TAccountMint, - TAccountTransferLiability, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedExecuteRelayerRefundLeafInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - instructionParams: TAccountMetas[1]; - state: TAccountMetas[2]; - rootBundle: TAccountMetas[3]; - vault: TAccountMetas[4]; - mint: TAccountMetas[5]; - transferLiability: TAccountMetas[6]; - tokenProgram: TAccountMetas[7]; - systemProgram: TAccountMetas[8]; - eventAuthority: TAccountMetas[9]; - program: TAccountMetas[10]; - }; - data: ExecuteRelayerRefundLeafInstructionData; -}; - -export function parseExecuteRelayerRefundLeafInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedExecuteRelayerRefundLeafInstruction { - if (instruction.accounts.length < 11) { - // 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: { - signer: getNextAccount(), - instructionParams: getNextAccount(), - state: getNextAccount(), - rootBundle: getNextAccount(), - vault: getNextAccount(), - mint: getNextAccount(), - transferLiability: getNextAccount(), - tokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getExecuteRelayerRefundLeafInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeafDeferred.ts b/src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeafDeferred.ts deleted file mode 100644 index cfeb304f1..000000000 --- a/src/svm/clients/SvmSpoke/instructions/executeRelayerRefundLeafDeferred.ts +++ /dev/null @@ -1,539 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const EXECUTE_RELAYER_REFUND_LEAF_DEFERRED_DISCRIMINATOR = - new Uint8Array([110, 112, 89, 208, 38, 116, 93, 10]); - -export function getExecuteRelayerRefundLeafDeferredDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - EXECUTE_RELAYER_REFUND_LEAF_DEFERRED_DISCRIMINATOR - ); -} - -export type ExecuteRelayerRefundLeafDeferredInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountInstructionParams extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountRootBundle extends string | AccountMeta = string, - TAccountVault extends string | AccountMeta = string, - TAccountMint extends string | AccountMeta = string, - TAccountTransferLiability extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountInstructionParams extends string - ? WritableAccount - : TAccountInstructionParams, - TAccountState extends string - ? ReadonlyAccount - : TAccountState, - TAccountRootBundle extends string - ? WritableAccount - : TAccountRootBundle, - TAccountVault extends string - ? WritableAccount - : TAccountVault, - TAccountMint extends string - ? ReadonlyAccount - : TAccountMint, - TAccountTransferLiability extends string - ? WritableAccount - : TAccountTransferLiability, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type ExecuteRelayerRefundLeafDeferredInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type ExecuteRelayerRefundLeafDeferredInstructionDataArgs = {}; - -export function getExecuteRelayerRefundLeafDeferredInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ - ...value, - discriminator: EXECUTE_RELAYER_REFUND_LEAF_DEFERRED_DISCRIMINATOR, - }) - ); -} - -export function getExecuteRelayerRefundLeafDeferredInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getExecuteRelayerRefundLeafDeferredInstructionDataCodec(): Codec< - ExecuteRelayerRefundLeafDeferredInstructionDataArgs, - ExecuteRelayerRefundLeafDeferredInstructionData -> { - return combineCodec( - getExecuteRelayerRefundLeafDeferredInstructionDataEncoder(), - getExecuteRelayerRefundLeafDeferredInstructionDataDecoder() - ); -} - -export type ExecuteRelayerRefundLeafDeferredAsyncInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountState extends string = string, - TAccountRootBundle extends string = string, - TAccountVault extends string = string, - TAccountMint extends string = string, - TAccountTransferLiability extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams?: Address; - state: Address; - rootBundle: Address; - vault?: Address; - mint: Address; - transferLiability?: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getExecuteRelayerRefundLeafDeferredInstructionAsync< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountState extends string, - TAccountRootBundle extends string, - TAccountVault extends string, - TAccountMint extends string, - TAccountTransferLiability extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: ExecuteRelayerRefundLeafDeferredAsyncInput< - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountVault, - TAccountMint, - TAccountTransferLiability, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - ExecuteRelayerRefundLeafDeferredInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountVault, - TAccountMint, - TAccountTransferLiability, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - state: { value: input.state ?? null, isWritable: false }, - rootBundle: { value: input.rootBundle ?? null, isWritable: true }, - vault: { value: input.vault ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - transferLiability: { - value: input.transferLiability ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.instructionParams.value) { - accounts.instructionParams.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, - 114, 97, 109, 115, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.signer.value)), - ], - }); - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.vault.value) { - accounts.vault.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getAddressEncoder().encode(expectAddress(accounts.state.value)), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.transferLiability.value) { - accounts.transferLiability.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 116, 114, 97, 110, 115, 102, 101, 114, 95, 108, 105, 97, 98, 105, - 108, 105, 116, 121, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.state), - getAccountMeta(accounts.rootBundle), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.transferLiability), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getExecuteRelayerRefundLeafDeferredInstructionDataEncoder().encode( - {} - ), - } as ExecuteRelayerRefundLeafDeferredInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountVault, - TAccountMint, - TAccountTransferLiability, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ExecuteRelayerRefundLeafDeferredInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountState extends string = string, - TAccountRootBundle extends string = string, - TAccountVault extends string = string, - TAccountMint extends string = string, - TAccountTransferLiability extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams: Address; - state: Address; - rootBundle: Address; - vault: Address; - mint: Address; - transferLiability: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; -}; - -export function getExecuteRelayerRefundLeafDeferredInstruction< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountState extends string, - TAccountRootBundle extends string, - TAccountVault extends string, - TAccountMint extends string, - TAccountTransferLiability extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: ExecuteRelayerRefundLeafDeferredInput< - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountVault, - TAccountMint, - TAccountTransferLiability, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): ExecuteRelayerRefundLeafDeferredInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountVault, - TAccountMint, - TAccountTransferLiability, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - state: { value: input.state ?? null, isWritable: false }, - rootBundle: { value: input.rootBundle ?? null, isWritable: true }, - vault: { value: input.vault ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - transferLiability: { - value: input.transferLiability ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.state), - getAccountMeta(accounts.rootBundle), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.transferLiability), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getExecuteRelayerRefundLeafDeferredInstructionDataEncoder().encode( - {} - ), - } as ExecuteRelayerRefundLeafDeferredInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountVault, - TAccountMint, - TAccountTransferLiability, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedExecuteRelayerRefundLeafDeferredInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - instructionParams: TAccountMetas[1]; - state: TAccountMetas[2]; - rootBundle: TAccountMetas[3]; - vault: TAccountMetas[4]; - mint: TAccountMetas[5]; - transferLiability: TAccountMetas[6]; - tokenProgram: TAccountMetas[7]; - systemProgram: TAccountMetas[8]; - eventAuthority: TAccountMetas[9]; - program: TAccountMetas[10]; - }; - data: ExecuteRelayerRefundLeafDeferredInstructionData; -}; - -export function parseExecuteRelayerRefundLeafDeferredInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedExecuteRelayerRefundLeafDeferredInstruction { - if (instruction.accounts.length < 11) { - // 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: { - signer: getNextAccount(), - instructionParams: getNextAccount(), - state: getNextAccount(), - rootBundle: getNextAccount(), - vault: getNextAccount(), - mint: getNextAccount(), - transferLiability: getNextAccount(), - tokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getExecuteRelayerRefundLeafDeferredInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/executeSlowRelayLeaf.ts b/src/svm/clients/SvmSpoke/instructions/executeSlowRelayLeaf.ts deleted file mode 100644 index b9835f128..000000000 --- a/src/svm/clients/SvmSpoke/instructions/executeSlowRelayLeaf.ts +++ /dev/null @@ -1,634 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getArrayDecoder, - getArrayEncoder, - getBytesDecoder, - getBytesEncoder, - getOptionDecoder, - getOptionEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type Option, - type OptionOrNullable, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - expectSome, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; -import { - getSlowFillDecoder, - getSlowFillEncoder, - type SlowFill, - type SlowFillArgs, -} from '../types'; - -export const EXECUTE_SLOW_RELAY_LEAF_DISCRIMINATOR = new Uint8Array([ - 26, 207, 3, 168, 193, 252, 59, 127, -]); - -export function getExecuteSlowRelayLeafDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - EXECUTE_SLOW_RELAY_LEAF_DISCRIMINATOR - ); -} - -export type ExecuteSlowRelayLeafInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountInstructionParams extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountRootBundle extends string | AccountMeta = string, - TAccountFillStatus extends string | AccountMeta = string, - TAccountMint extends string | AccountMeta = string, - TAccountRecipientTokenAccount extends string | AccountMeta = string, - TAccountVault extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountInstructionParams extends string - ? WritableAccount - : TAccountInstructionParams, - TAccountState extends string - ? ReadonlyAccount - : TAccountState, - TAccountRootBundle extends string - ? ReadonlyAccount - : TAccountRootBundle, - TAccountFillStatus extends string - ? WritableAccount - : TAccountFillStatus, - TAccountMint extends string - ? ReadonlyAccount - : TAccountMint, - TAccountRecipientTokenAccount extends string - ? WritableAccount - : TAccountRecipientTokenAccount, - TAccountVault extends string - ? WritableAccount - : TAccountVault, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type ExecuteSlowRelayLeafInstructionData = { - discriminator: ReadonlyUint8Array; - relayHash: ReadonlyUint8Array; - slowFillLeaf: Option; - rootBundleId: Option; - proof: Option>; -}; - -export type ExecuteSlowRelayLeafInstructionDataArgs = { - relayHash: ReadonlyUint8Array; - slowFillLeaf: OptionOrNullable; - rootBundleId: OptionOrNullable; - proof: OptionOrNullable>; -}; - -export function getExecuteSlowRelayLeafInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['relayHash', fixEncoderSize(getBytesEncoder(), 32)], - ['slowFillLeaf', getOptionEncoder(getSlowFillEncoder())], - ['rootBundleId', getOptionEncoder(getU32Encoder())], - [ - 'proof', - getOptionEncoder( - getArrayEncoder(fixEncoderSize(getBytesEncoder(), 32)) - ), - ], - ]), - (value) => ({ - ...value, - discriminator: EXECUTE_SLOW_RELAY_LEAF_DISCRIMINATOR, - }) - ); -} - -export function getExecuteSlowRelayLeafInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['relayHash', fixDecoderSize(getBytesDecoder(), 32)], - ['slowFillLeaf', getOptionDecoder(getSlowFillDecoder())], - ['rootBundleId', getOptionDecoder(getU32Decoder())], - [ - 'proof', - getOptionDecoder(getArrayDecoder(fixDecoderSize(getBytesDecoder(), 32))), - ], - ]); -} - -export function getExecuteSlowRelayLeafInstructionDataCodec(): Codec< - ExecuteSlowRelayLeafInstructionDataArgs, - ExecuteSlowRelayLeafInstructionData -> { - return combineCodec( - getExecuteSlowRelayLeafInstructionDataEncoder(), - getExecuteSlowRelayLeafInstructionDataDecoder() - ); -} - -export type ExecuteSlowRelayLeafAsyncInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountState extends string = string, - TAccountRootBundle extends string = string, - TAccountFillStatus extends string = string, - TAccountMint extends string = string, - TAccountRecipientTokenAccount extends string = string, - TAccountVault extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams?: Address; - state: Address; - rootBundle: Address; - fillStatus?: Address; - mint: Address; - recipientTokenAccount?: Address; - vault?: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - relayHash: ExecuteSlowRelayLeafInstructionDataArgs['relayHash']; - slowFillLeaf: ExecuteSlowRelayLeafInstructionDataArgs['slowFillLeaf']; - rootBundleId: ExecuteSlowRelayLeafInstructionDataArgs['rootBundleId']; - proof: ExecuteSlowRelayLeafInstructionDataArgs['proof']; -}; - -export async function getExecuteSlowRelayLeafInstructionAsync< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountState extends string, - TAccountRootBundle extends string, - TAccountFillStatus extends string, - TAccountMint extends string, - TAccountRecipientTokenAccount extends string, - TAccountVault extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: ExecuteSlowRelayLeafAsyncInput< - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountFillStatus, - TAccountMint, - TAccountRecipientTokenAccount, - TAccountVault, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - ExecuteSlowRelayLeafInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountFillStatus, - TAccountMint, - TAccountRecipientTokenAccount, - TAccountVault, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - state: { value: input.state ?? null, isWritable: false }, - rootBundle: { value: input.rootBundle ?? null, isWritable: false }, - fillStatus: { value: input.fillStatus ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - recipientTokenAccount: { - value: input.recipientTokenAccount ?? null, - isWritable: true, - }, - vault: { value: input.vault ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.instructionParams.value) { - accounts.instructionParams.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, - 114, 97, 109, 115, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.signer.value)), - ], - }); - } - if (!accounts.fillStatus.value) { - accounts.fillStatus.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode(new Uint8Array([102, 105, 108, 108, 115])), - fixEncoderSize(getBytesEncoder(), 32).encode( - expectSome(args.relayHash) - ), - ], - }); - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.recipientTokenAccount.value) { - accounts.recipientTokenAccount.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getOptionEncoder(getSlowFillEncoder()).encode( - expectSome(args.slowFillLeaf) - ), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.vault.value) { - accounts.vault.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getAddressEncoder().encode(expectAddress(accounts.state.value)), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.state), - getAccountMeta(accounts.rootBundle), - getAccountMeta(accounts.fillStatus), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.recipientTokenAccount), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getExecuteSlowRelayLeafInstructionDataEncoder().encode( - args as ExecuteSlowRelayLeafInstructionDataArgs - ), - } as ExecuteSlowRelayLeafInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountFillStatus, - TAccountMint, - TAccountRecipientTokenAccount, - TAccountVault, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ExecuteSlowRelayLeafInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountState extends string = string, - TAccountRootBundle extends string = string, - TAccountFillStatus extends string = string, - TAccountMint extends string = string, - TAccountRecipientTokenAccount extends string = string, - TAccountVault extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams?: Address; - state: Address; - rootBundle: Address; - fillStatus: Address; - mint: Address; - recipientTokenAccount: Address; - vault: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - relayHash: ExecuteSlowRelayLeafInstructionDataArgs['relayHash']; - slowFillLeaf: ExecuteSlowRelayLeafInstructionDataArgs['slowFillLeaf']; - rootBundleId: ExecuteSlowRelayLeafInstructionDataArgs['rootBundleId']; - proof: ExecuteSlowRelayLeafInstructionDataArgs['proof']; -}; - -export function getExecuteSlowRelayLeafInstruction< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountState extends string, - TAccountRootBundle extends string, - TAccountFillStatus extends string, - TAccountMint extends string, - TAccountRecipientTokenAccount extends string, - TAccountVault extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: ExecuteSlowRelayLeafInput< - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountFillStatus, - TAccountMint, - TAccountRecipientTokenAccount, - TAccountVault, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): ExecuteSlowRelayLeafInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountFillStatus, - TAccountMint, - TAccountRecipientTokenAccount, - TAccountVault, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - state: { value: input.state ?? null, isWritable: false }, - rootBundle: { value: input.rootBundle ?? null, isWritable: false }, - fillStatus: { value: input.fillStatus ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - recipientTokenAccount: { - value: input.recipientTokenAccount ?? null, - isWritable: true, - }, - vault: { value: input.vault ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.state), - getAccountMeta(accounts.rootBundle), - getAccountMeta(accounts.fillStatus), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.recipientTokenAccount), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getExecuteSlowRelayLeafInstructionDataEncoder().encode( - args as ExecuteSlowRelayLeafInstructionDataArgs - ), - } as ExecuteSlowRelayLeafInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountRootBundle, - TAccountFillStatus, - TAccountMint, - TAccountRecipientTokenAccount, - TAccountVault, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedExecuteSlowRelayLeafInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - instructionParams?: TAccountMetas[1] | undefined; - state: TAccountMetas[2]; - rootBundle: TAccountMetas[3]; - fillStatus: TAccountMetas[4]; - mint: TAccountMetas[5]; - recipientTokenAccount: TAccountMetas[6]; - vault: TAccountMetas[7]; - tokenProgram: TAccountMetas[8]; - systemProgram: TAccountMetas[9]; - eventAuthority: TAccountMetas[10]; - program: TAccountMetas[11]; - }; - data: ExecuteSlowRelayLeafInstructionData; -}; - -export function parseExecuteSlowRelayLeafInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedExecuteSlowRelayLeafInstruction { - if (instruction.accounts.length < 12) { - // TODO: Coded error. - throw new Error('Not enough accounts'); - } - let accountIndex = 0; - const getNextAccount = () => { - const accountMeta = instruction.accounts![accountIndex]!; - accountIndex += 1; - return accountMeta; - }; - const getNextOptionalAccount = () => { - const accountMeta = getNextAccount(); - return accountMeta.address === SVM_SPOKE_PROGRAM_ADDRESS - ? undefined - : accountMeta; - }; - return { - programAddress: instruction.programAddress, - accounts: { - signer: getNextAccount(), - instructionParams: getNextOptionalAccount(), - state: getNextAccount(), - rootBundle: getNextAccount(), - fillStatus: getNextAccount(), - mint: getNextAccount(), - recipientTokenAccount: getNextAccount(), - vault: getNextAccount(), - tokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getExecuteSlowRelayLeafInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/fillRelay.ts b/src/svm/clients/SvmSpoke/instructions/fillRelay.ts deleted file mode 100644 index 47f307bca..000000000 --- a/src/svm/clients/SvmSpoke/instructions/fillRelay.ts +++ /dev/null @@ -1,650 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getOptionDecoder, - getOptionEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type Option, - type OptionOrNullable, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - expectSome, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; -import { - getRelayDataDecoder, - getRelayDataEncoder, - type RelayData, - type RelayDataArgs, -} from '../types'; - -export const FILL_RELAY_DISCRIMINATOR = new Uint8Array([ - 100, 84, 222, 90, 106, 209, 58, 222, -]); - -export function getFillRelayDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(FILL_RELAY_DISCRIMINATOR); -} - -export type FillRelayInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountInstructionParams extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountDelegate extends string | AccountMeta = string, - TAccountMint extends string | AccountMeta = string, - TAccountRelayerTokenAccount extends string | AccountMeta = string, - TAccountRecipientTokenAccount extends string | AccountMeta = string, - TAccountFillStatus extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountAssociatedTokenProgram extends string | AccountMeta = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountInstructionParams extends string - ? WritableAccount - : TAccountInstructionParams, - TAccountState extends string - ? ReadonlyAccount - : TAccountState, - TAccountDelegate extends string - ? ReadonlyAccount - : TAccountDelegate, - TAccountMint extends string - ? ReadonlyAccount - : TAccountMint, - TAccountRelayerTokenAccount extends string - ? WritableAccount - : TAccountRelayerTokenAccount, - TAccountRecipientTokenAccount extends string - ? WritableAccount - : TAccountRecipientTokenAccount, - TAccountFillStatus extends string - ? WritableAccount - : TAccountFillStatus, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountAssociatedTokenProgram extends string - ? ReadonlyAccount - : TAccountAssociatedTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type FillRelayInstructionData = { - discriminator: ReadonlyUint8Array; - relayHash: ReadonlyUint8Array; - relayData: Option; - repaymentChainId: Option; - repaymentAddress: Option
; -}; - -export type FillRelayInstructionDataArgs = { - relayHash: ReadonlyUint8Array; - relayData: OptionOrNullable; - repaymentChainId: OptionOrNullable; - repaymentAddress: OptionOrNullable
; -}; - -export function getFillRelayInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['relayHash', fixEncoderSize(getBytesEncoder(), 32)], - ['relayData', getOptionEncoder(getRelayDataEncoder())], - ['repaymentChainId', getOptionEncoder(getU64Encoder())], - ['repaymentAddress', getOptionEncoder(getAddressEncoder())], - ]), - (value) => ({ ...value, discriminator: FILL_RELAY_DISCRIMINATOR }) - ); -} - -export function getFillRelayInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['relayHash', fixDecoderSize(getBytesDecoder(), 32)], - ['relayData', getOptionDecoder(getRelayDataDecoder())], - ['repaymentChainId', getOptionDecoder(getU64Decoder())], - ['repaymentAddress', getOptionDecoder(getAddressDecoder())], - ]); -} - -export function getFillRelayInstructionDataCodec(): Codec< - FillRelayInstructionDataArgs, - FillRelayInstructionData -> { - return combineCodec( - getFillRelayInstructionDataEncoder(), - getFillRelayInstructionDataDecoder() - ); -} - -export type FillRelayAsyncInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountState extends string = string, - TAccountDelegate extends string = string, - TAccountMint extends string = string, - TAccountRelayerTokenAccount extends string = string, - TAccountRecipientTokenAccount extends string = string, - TAccountFillStatus extends string = string, - TAccountTokenProgram extends string = string, - TAccountAssociatedTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams?: Address; - state: Address; - delegate: Address; - mint: Address; - relayerTokenAccount: Address; - recipientTokenAccount?: Address; - fillStatus?: Address; - tokenProgram?: Address; - associatedTokenProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - relayHash: FillRelayInstructionDataArgs['relayHash']; - relayData: FillRelayInstructionDataArgs['relayData']; - repaymentChainId: FillRelayInstructionDataArgs['repaymentChainId']; - repaymentAddress: FillRelayInstructionDataArgs['repaymentAddress']; -}; - -export async function getFillRelayInstructionAsync< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountState extends string, - TAccountDelegate extends string, - TAccountMint extends string, - TAccountRelayerTokenAccount extends string, - TAccountRecipientTokenAccount extends string, - TAccountFillStatus extends string, - TAccountTokenProgram extends string, - TAccountAssociatedTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: FillRelayAsyncInput< - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountDelegate, - TAccountMint, - TAccountRelayerTokenAccount, - TAccountRecipientTokenAccount, - TAccountFillStatus, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - FillRelayInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountDelegate, - TAccountMint, - TAccountRelayerTokenAccount, - TAccountRecipientTokenAccount, - TAccountFillStatus, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - state: { value: input.state ?? null, isWritable: false }, - delegate: { value: input.delegate ?? null, isWritable: false }, - mint: { value: input.mint ?? null, isWritable: false }, - relayerTokenAccount: { - value: input.relayerTokenAccount ?? null, - isWritable: true, - }, - recipientTokenAccount: { - value: input.recipientTokenAccount ?? null, - isWritable: true, - }, - fillStatus: { value: input.fillStatus ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - associatedTokenProgram: { - value: input.associatedTokenProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.instructionParams.value) { - accounts.instructionParams.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, - 114, 97, 109, 115, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.signer.value)), - ], - }); - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.recipientTokenAccount.value) { - accounts.recipientTokenAccount.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getOptionEncoder(getRelayDataEncoder()).encode( - expectSome(args.relayData) - ), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.fillStatus.value) { - accounts.fillStatus.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode(new Uint8Array([102, 105, 108, 108, 115])), - fixEncoderSize(getBytesEncoder(), 32).encode( - expectSome(args.relayHash) - ), - ], - }); - } - if (!accounts.associatedTokenProgram.value) { - accounts.associatedTokenProgram.value = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.state), - getAccountMeta(accounts.delegate), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.relayerTokenAccount), - getAccountMeta(accounts.recipientTokenAccount), - getAccountMeta(accounts.fillStatus), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.associatedTokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getFillRelayInstructionDataEncoder().encode( - args as FillRelayInstructionDataArgs - ), - } as FillRelayInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountDelegate, - TAccountMint, - TAccountRelayerTokenAccount, - TAccountRecipientTokenAccount, - TAccountFillStatus, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type FillRelayInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountState extends string = string, - TAccountDelegate extends string = string, - TAccountMint extends string = string, - TAccountRelayerTokenAccount extends string = string, - TAccountRecipientTokenAccount extends string = string, - TAccountFillStatus extends string = string, - TAccountTokenProgram extends string = string, - TAccountAssociatedTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams?: Address; - state: Address; - delegate: Address; - mint: Address; - relayerTokenAccount: Address; - recipientTokenAccount: Address; - fillStatus: Address; - tokenProgram?: Address; - associatedTokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - relayHash: FillRelayInstructionDataArgs['relayHash']; - relayData: FillRelayInstructionDataArgs['relayData']; - repaymentChainId: FillRelayInstructionDataArgs['repaymentChainId']; - repaymentAddress: FillRelayInstructionDataArgs['repaymentAddress']; -}; - -export function getFillRelayInstruction< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountState extends string, - TAccountDelegate extends string, - TAccountMint extends string, - TAccountRelayerTokenAccount extends string, - TAccountRecipientTokenAccount extends string, - TAccountFillStatus extends string, - TAccountTokenProgram extends string, - TAccountAssociatedTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: FillRelayInput< - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountDelegate, - TAccountMint, - TAccountRelayerTokenAccount, - TAccountRecipientTokenAccount, - TAccountFillStatus, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): FillRelayInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountDelegate, - TAccountMint, - TAccountRelayerTokenAccount, - TAccountRecipientTokenAccount, - TAccountFillStatus, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - state: { value: input.state ?? null, isWritable: false }, - delegate: { value: input.delegate ?? null, isWritable: false }, - mint: { value: input.mint ?? null, isWritable: false }, - relayerTokenAccount: { - value: input.relayerTokenAccount ?? null, - isWritable: true, - }, - recipientTokenAccount: { - value: input.recipientTokenAccount ?? null, - isWritable: true, - }, - fillStatus: { value: input.fillStatus ?? null, isWritable: true }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - associatedTokenProgram: { - value: input.associatedTokenProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.associatedTokenProgram.value) { - accounts.associatedTokenProgram.value = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.state), - getAccountMeta(accounts.delegate), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.relayerTokenAccount), - getAccountMeta(accounts.recipientTokenAccount), - getAccountMeta(accounts.fillStatus), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.associatedTokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getFillRelayInstructionDataEncoder().encode( - args as FillRelayInstructionDataArgs - ), - } as FillRelayInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountDelegate, - TAccountMint, - TAccountRelayerTokenAccount, - TAccountRecipientTokenAccount, - TAccountFillStatus, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedFillRelayInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - instructionParams?: TAccountMetas[1] | undefined; - state: TAccountMetas[2]; - delegate: TAccountMetas[3]; - mint: TAccountMetas[4]; - relayerTokenAccount: TAccountMetas[5]; - recipientTokenAccount: TAccountMetas[6]; - fillStatus: TAccountMetas[7]; - tokenProgram: TAccountMetas[8]; - associatedTokenProgram: TAccountMetas[9]; - systemProgram: TAccountMetas[10]; - eventAuthority: TAccountMetas[11]; - program: TAccountMetas[12]; - }; - data: FillRelayInstructionData; -}; - -export function parseFillRelayInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedFillRelayInstruction { - if (instruction.accounts.length < 13) { - // TODO: Coded error. - throw new Error('Not enough accounts'); - } - let accountIndex = 0; - const getNextAccount = () => { - const accountMeta = instruction.accounts![accountIndex]!; - accountIndex += 1; - return accountMeta; - }; - const getNextOptionalAccount = () => { - const accountMeta = getNextAccount(); - return accountMeta.address === SVM_SPOKE_PROGRAM_ADDRESS - ? undefined - : accountMeta; - }; - return { - programAddress: instruction.programAddress, - accounts: { - signer: getNextAccount(), - instructionParams: getNextOptionalAccount(), - state: getNextAccount(), - delegate: getNextAccount(), - mint: getNextAccount(), - relayerTokenAccount: getNextAccount(), - recipientTokenAccount: getNextAccount(), - fillStatus: getNextAccount(), - tokenProgram: getNextAccount(), - associatedTokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getFillRelayInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/getUnsafeDepositId.ts b/src/svm/clients/SvmSpoke/instructions/getUnsafeDepositId.ts deleted file mode 100644 index 1efa25469..000000000 --- a/src/svm/clients/SvmSpoke/instructions/getUnsafeDepositId.ts +++ /dev/null @@ -1,142 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; - -export const GET_UNSAFE_DEPOSIT_ID_DISCRIMINATOR = new Uint8Array([ - 118, 10, 135, 0, 168, 243, 223, 117, -]); - -export function getGetUnsafeDepositIdDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - GET_UNSAFE_DEPOSIT_ID_DISCRIMINATOR - ); -} - -export type GetUnsafeDepositIdInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts; - -export type GetUnsafeDepositIdInstructionData = { - discriminator: ReadonlyUint8Array; - signer: Address; - depositor: Address; - depositNonce: bigint; -}; - -export type GetUnsafeDepositIdInstructionDataArgs = { - signer: Address; - depositor: Address; - depositNonce: number | bigint; -}; - -export function getGetUnsafeDepositIdInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['signer', getAddressEncoder()], - ['depositor', getAddressEncoder()], - ['depositNonce', getU64Encoder()], - ]), - (value) => ({ - ...value, - discriminator: GET_UNSAFE_DEPOSIT_ID_DISCRIMINATOR, - }) - ); -} - -export function getGetUnsafeDepositIdInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['signer', getAddressDecoder()], - ['depositor', getAddressDecoder()], - ['depositNonce', getU64Decoder()], - ]); -} - -export function getGetUnsafeDepositIdInstructionDataCodec(): Codec< - GetUnsafeDepositIdInstructionDataArgs, - GetUnsafeDepositIdInstructionData -> { - return combineCodec( - getGetUnsafeDepositIdInstructionDataEncoder(), - getGetUnsafeDepositIdInstructionDataDecoder() - ); -} - -export type GetUnsafeDepositIdInput = { - signer: GetUnsafeDepositIdInstructionDataArgs['signer']; - depositor: GetUnsafeDepositIdInstructionDataArgs['depositor']; - depositNonce: GetUnsafeDepositIdInstructionDataArgs['depositNonce']; -}; - -export function getGetUnsafeDepositIdInstruction< - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: GetUnsafeDepositIdInput, - config?: { programAddress?: TProgramAddress } -): GetUnsafeDepositIdInstruction { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original args. - const args = { ...input }; - - const instruction = { - programAddress, - data: getGetUnsafeDepositIdInstructionDataEncoder().encode( - args as GetUnsafeDepositIdInstructionDataArgs - ), - } as GetUnsafeDepositIdInstruction; - - return instruction; -} - -export type ParsedGetUnsafeDepositIdInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, -> = { - programAddress: Address; - data: GetUnsafeDepositIdInstructionData; -}; - -export function parseGetUnsafeDepositIdInstruction( - instruction: Instruction & InstructionWithData -): ParsedGetUnsafeDepositIdInstruction { - return { - programAddress: instruction.programAddress, - data: getGetUnsafeDepositIdInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/handleReceiveMessage.ts b/src/svm/clients/SvmSpoke/instructions/handleReceiveMessage.ts deleted file mode 100644 index b1124f722..000000000 --- a/src/svm/clients/SvmSpoke/instructions/handleReceiveMessage.ts +++ /dev/null @@ -1,382 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const HANDLE_RECEIVE_MESSAGE_DISCRIMINATOR = new Uint8Array([ - 133, 102, 1, 180, 145, 11, 138, 180, -]); - -export function getHandleReceiveMessageDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - HANDLE_RECEIVE_MESSAGE_DISCRIMINATOR - ); -} - -export type HandleReceiveMessageInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountAuthorityPda extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountSelfAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = - 'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountAuthorityPda extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthorityPda, - TAccountState extends string - ? ReadonlyAccount - : TAccountState, - TAccountSelfAuthority extends string - ? ReadonlyAccount - : TAccountSelfAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type HandleReceiveMessageInstructionData = { - discriminator: ReadonlyUint8Array; - remoteDomain: number; - sender: Address; - messageBody: ReadonlyUint8Array; - authorityBump: number; -}; - -export type HandleReceiveMessageInstructionDataArgs = { - remoteDomain: number; - sender: Address; - messageBody: ReadonlyUint8Array; - authorityBump: number; -}; - -export function getHandleReceiveMessageInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['remoteDomain', getU32Encoder()], - ['sender', getAddressEncoder()], - ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ['authorityBump', getU8Encoder()], - ]), - (value) => ({ - ...value, - discriminator: HANDLE_RECEIVE_MESSAGE_DISCRIMINATOR, - }) - ); -} - -export function getHandleReceiveMessageInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['remoteDomain', getU32Decoder()], - ['sender', getAddressDecoder()], - ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ['authorityBump', getU8Decoder()], - ]); -} - -export function getHandleReceiveMessageInstructionDataCodec(): Codec< - HandleReceiveMessageInstructionDataArgs, - HandleReceiveMessageInstructionData -> { - return combineCodec( - getHandleReceiveMessageInstructionDataEncoder(), - getHandleReceiveMessageInstructionDataDecoder() - ); -} - -export type HandleReceiveMessageAsyncInput< - TAccountAuthorityPda extends string = string, - TAccountState extends string = string, - TAccountSelfAuthority extends string = string, - TAccountProgram extends string = string, -> = { - authorityPda?: TransactionSigner; - state: Address; - selfAuthority?: Address; - program?: Address; - remoteDomain: HandleReceiveMessageInstructionDataArgs['remoteDomain']; - sender: HandleReceiveMessageInstructionDataArgs['sender']; - messageBody: HandleReceiveMessageInstructionDataArgs['messageBody']; - authorityBump: HandleReceiveMessageInstructionDataArgs['authorityBump']; -}; - -export async function getHandleReceiveMessageInstructionAsync< - TAccountAuthorityPda extends string, - TAccountState extends string, - TAccountSelfAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: HandleReceiveMessageAsyncInput< - TAccountAuthorityPda, - TAccountState, - TAccountSelfAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - HandleReceiveMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountState, - TAccountSelfAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - authorityPda: { value: input.authorityPda ?? null, isWritable: false }, - state: { value: input.state ?? null, isWritable: false }, - selfAuthority: { value: input.selfAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.authorityPda.value) { - accounts.authorityPda.value = await getProgramDerivedAddress({ - programAddress: - 'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd' as Address<'CCTPmbSD7gX1bxKPAmg77w8oFzNFpaQiQUWD43TKaecd'>, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 109, 101, 115, 115, 97, 103, 101, 95, 116, 114, 97, 110, 115, 109, - 105, 116, 116, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, 116, - 121, - ]) - ), - getBytesEncoder().encode( - new Uint8Array([ - 183, 102, 64, 134, 222, 55, 238, 112, 130, 28, 16, 68, 91, 22, 47, - 44, 126, 200, 121, 91, 208, 128, 12, 20, 98, 148, 158, 35, 40, 209, - 221, 90, - ]) - ), - ], - }); - } - if (!accounts.selfAuthority.value) { - accounts.selfAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 115, 101, 108, 102, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121, - ]) - ), - ], - }); - } - if (!accounts.program.value) { - accounts.program.value = - 'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru' as Address<'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.authorityPda), - getAccountMeta(accounts.state), - getAccountMeta(accounts.selfAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getHandleReceiveMessageInstructionDataEncoder().encode( - args as HandleReceiveMessageInstructionDataArgs - ), - } as HandleReceiveMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountState, - TAccountSelfAuthority, - TAccountProgram - >; - - return instruction; -} - -export type HandleReceiveMessageInput< - TAccountAuthorityPda extends string = string, - TAccountState extends string = string, - TAccountSelfAuthority extends string = string, - TAccountProgram extends string = string, -> = { - authorityPda: TransactionSigner; - state: Address; - selfAuthority: Address; - program?: Address; - remoteDomain: HandleReceiveMessageInstructionDataArgs['remoteDomain']; - sender: HandleReceiveMessageInstructionDataArgs['sender']; - messageBody: HandleReceiveMessageInstructionDataArgs['messageBody']; - authorityBump: HandleReceiveMessageInstructionDataArgs['authorityBump']; -}; - -export function getHandleReceiveMessageInstruction< - TAccountAuthorityPda extends string, - TAccountState extends string, - TAccountSelfAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: HandleReceiveMessageInput< - TAccountAuthorityPda, - TAccountState, - TAccountSelfAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): HandleReceiveMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountState, - TAccountSelfAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - authorityPda: { value: input.authorityPda ?? null, isWritable: false }, - state: { value: input.state ?? null, isWritable: false }, - selfAuthority: { value: input.selfAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.program.value) { - accounts.program.value = - 'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru' as Address<'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.authorityPda), - getAccountMeta(accounts.state), - getAccountMeta(accounts.selfAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getHandleReceiveMessageInstructionDataEncoder().encode( - args as HandleReceiveMessageInstructionDataArgs - ), - } as HandleReceiveMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountState, - TAccountSelfAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedHandleReceiveMessageInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - authorityPda: TAccountMetas[0]; - state: TAccountMetas[1]; - selfAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: HandleReceiveMessageInstructionData; -}; - -export function parseHandleReceiveMessageInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedHandleReceiveMessageInstruction { - if (instruction.accounts.length < 4) { - // 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: { - authorityPda: getNextAccount(), - state: getNextAccount(), - selfAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getHandleReceiveMessageInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/index.ts b/src/svm/clients/SvmSpoke/instructions/index.ts deleted file mode 100644 index 04e8a76be..000000000 --- a/src/svm/clients/SvmSpoke/instructions/index.ts +++ /dev/null @@ -1,35 +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 - */ - -export * from './bridgeTokensToHubPool'; -export * from './claimRelayerRefund'; -export * from './closeClaimAccount'; -export * from './closeFillPda'; -export * from './closeInstructionParams'; -export * from './createTokenAccounts'; -export * from './deposit'; -export * from './depositNow'; -export * from './emergencyDeleteRootBundle'; -export * from './executeRelayerRefundLeaf'; -export * from './executeRelayerRefundLeafDeferred'; -export * from './executeSlowRelayLeaf'; -export * from './fillRelay'; -export * from './getUnsafeDepositId'; -export * from './handleReceiveMessage'; -export * from './initialize'; -export * from './initializeClaimAccount'; -export * from './initializeInstructionParams'; -export * from './pauseDeposits'; -export * from './pauseFills'; -export * from './relayRootBundle'; -export * from './requestSlowFill'; -export * from './setCrossDomainAdmin'; -export * from './setCurrentTime'; -export * from './transferOwnership'; -export * from './unsafeDeposit'; -export * from './writeInstructionParamsFragment'; diff --git a/src/svm/clients/SvmSpoke/instructions/initialize.ts b/src/svm/clients/SvmSpoke/instructions/initialize.ts deleted file mode 100644 index d948e53dd..000000000 --- a/src/svm/clients/SvmSpoke/instructions/initialize.ts +++ /dev/null @@ -1,345 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectSome, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const INITIALIZE_DISCRIMINATOR = new Uint8Array([ - 175, 175, 109, 31, 13, 152, 155, 237, -]); - -export function getInitializeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_DISCRIMINATOR); -} - -export type InitializeInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountState extends string - ? WritableAccount - : TAccountState, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type InitializeInstructionData = { - discriminator: ReadonlyUint8Array; - seed: bigint; - initialNumberOfDeposits: number; - chainId: bigint; - remoteDomain: number; - crossDomainAdmin: Address; - depositQuoteTimeBuffer: number; - fillDeadlineBuffer: number; -}; - -export type InitializeInstructionDataArgs = { - seed: number | bigint; - initialNumberOfDeposits: number; - chainId: number | bigint; - remoteDomain: number; - crossDomainAdmin: Address; - depositQuoteTimeBuffer: number; - fillDeadlineBuffer: number; -}; - -export function getInitializeInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['seed', getU64Encoder()], - ['initialNumberOfDeposits', getU32Encoder()], - ['chainId', getU64Encoder()], - ['remoteDomain', getU32Encoder()], - ['crossDomainAdmin', getAddressEncoder()], - ['depositQuoteTimeBuffer', getU32Encoder()], - ['fillDeadlineBuffer', getU32Encoder()], - ]), - (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) - ); -} - -export function getInitializeInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['seed', getU64Decoder()], - ['initialNumberOfDeposits', getU32Decoder()], - ['chainId', getU64Decoder()], - ['remoteDomain', getU32Decoder()], - ['crossDomainAdmin', getAddressDecoder()], - ['depositQuoteTimeBuffer', getU32Decoder()], - ['fillDeadlineBuffer', getU32Decoder()], - ]); -} - -export function getInitializeInstructionDataCodec(): Codec< - InitializeInstructionDataArgs, - InitializeInstructionData -> { - return combineCodec( - getInitializeInstructionDataEncoder(), - getInitializeInstructionDataDecoder() - ); -} - -export type InitializeAsyncInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - state?: Address; - systemProgram?: Address; - seed: InitializeInstructionDataArgs['seed']; - initialNumberOfDeposits: InitializeInstructionDataArgs['initialNumberOfDeposits']; - chainId: InitializeInstructionDataArgs['chainId']; - remoteDomain: InitializeInstructionDataArgs['remoteDomain']; - crossDomainAdmin: InitializeInstructionDataArgs['crossDomainAdmin']; - depositQuoteTimeBuffer: InitializeInstructionDataArgs['depositQuoteTimeBuffer']; - fillDeadlineBuffer: InitializeInstructionDataArgs['fillDeadlineBuffer']; -}; - -export async function getInitializeInstructionAsync< - TAccountSigner extends string, - TAccountState extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: InitializeAsyncInput< - TAccountSigner, - TAccountState, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - InitializeInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.state.value) { - accounts.state.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode(new Uint8Array([115, 116, 97, 116, 101])), - getU64Encoder().encode(expectSome(args.seed)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitializeInstructionDataEncoder().encode( - args as InitializeInstructionDataArgs - ), - } as InitializeInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountSystemProgram - >; - - return instruction; -} - -export type InitializeInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - systemProgram?: Address; - seed: InitializeInstructionDataArgs['seed']; - initialNumberOfDeposits: InitializeInstructionDataArgs['initialNumberOfDeposits']; - chainId: InitializeInstructionDataArgs['chainId']; - remoteDomain: InitializeInstructionDataArgs['remoteDomain']; - crossDomainAdmin: InitializeInstructionDataArgs['crossDomainAdmin']; - depositQuoteTimeBuffer: InitializeInstructionDataArgs['depositQuoteTimeBuffer']; - fillDeadlineBuffer: InitializeInstructionDataArgs['fillDeadlineBuffer']; -}; - -export function getInitializeInstruction< - TAccountSigner extends string, - TAccountState extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: InitializeInput, - config?: { programAddress?: TProgramAddress } -): InitializeInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountSystemProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitializeInstructionDataEncoder().encode( - args as InitializeInstructionDataArgs - ), - } as InitializeInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedInitializeInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - state: TAccountMetas[1]; - systemProgram: TAccountMetas[2]; - }; - data: InitializeInstructionData; -}; - -export function parseInitializeInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedInitializeInstruction { - 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: { - signer: getNextAccount(), - state: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getInitializeInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/initializeClaimAccount.ts b/src/svm/clients/SvmSpoke/instructions/initializeClaimAccount.ts deleted file mode 100644 index c701674a4..000000000 --- a/src/svm/clients/SvmSpoke/instructions/initializeClaimAccount.ts +++ /dev/null @@ -1,345 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const INITIALIZE_CLAIM_ACCOUNT_DISCRIMINATOR = new Uint8Array([ - 22, 247, 214, 191, 90, 74, 87, 216, -]); - -export function getInitializeClaimAccountDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - INITIALIZE_CLAIM_ACCOUNT_DISCRIMINATOR - ); -} - -export type InitializeClaimAccountInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountMint extends string | AccountMeta = string, - TAccountRefundAddress extends string | AccountMeta = string, - TAccountClaimAccount extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountMint extends string - ? ReadonlyAccount - : TAccountMint, - TAccountRefundAddress extends string - ? ReadonlyAccount - : TAccountRefundAddress, - TAccountClaimAccount extends string - ? WritableAccount - : TAccountClaimAccount, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type InitializeClaimAccountInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type InitializeClaimAccountInstructionDataArgs = {}; - -export function getInitializeClaimAccountInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ - ...value, - discriminator: INITIALIZE_CLAIM_ACCOUNT_DISCRIMINATOR, - }) - ); -} - -export function getInitializeClaimAccountInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getInitializeClaimAccountInstructionDataCodec(): Codec< - InitializeClaimAccountInstructionDataArgs, - InitializeClaimAccountInstructionData -> { - return combineCodec( - getInitializeClaimAccountInstructionDataEncoder(), - getInitializeClaimAccountInstructionDataDecoder() - ); -} - -export type InitializeClaimAccountAsyncInput< - TAccountSigner extends string = string, - TAccountMint extends string = string, - TAccountRefundAddress extends string = string, - TAccountClaimAccount extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - mint: Address; - refundAddress: Address; - claimAccount?: Address; - systemProgram?: Address; -}; - -export async function getInitializeClaimAccountInstructionAsync< - TAccountSigner extends string, - TAccountMint extends string, - TAccountRefundAddress extends string, - TAccountClaimAccount extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: InitializeClaimAccountAsyncInput< - TAccountSigner, - TAccountMint, - TAccountRefundAddress, - TAccountClaimAccount, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - InitializeClaimAccountInstruction< - TProgramAddress, - TAccountSigner, - TAccountMint, - TAccountRefundAddress, - TAccountClaimAccount, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - refundAddress: { value: input.refundAddress ?? null, isWritable: false }, - claimAccount: { value: input.claimAccount ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.claimAccount.value) { - accounts.claimAccount.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 99, 108, 97, 105, 109, 95, 97, 99, 99, 111, 117, 110, 116, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - getAddressEncoder().encode(expectAddress(accounts.refundAddress.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.refundAddress), - getAccountMeta(accounts.claimAccount), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitializeClaimAccountInstructionDataEncoder().encode({}), - } as InitializeClaimAccountInstruction< - TProgramAddress, - TAccountSigner, - TAccountMint, - TAccountRefundAddress, - TAccountClaimAccount, - TAccountSystemProgram - >; - - return instruction; -} - -export type InitializeClaimAccountInput< - TAccountSigner extends string = string, - TAccountMint extends string = string, - TAccountRefundAddress extends string = string, - TAccountClaimAccount extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - mint: Address; - refundAddress: Address; - claimAccount: Address; - systemProgram?: Address; -}; - -export function getInitializeClaimAccountInstruction< - TAccountSigner extends string, - TAccountMint extends string, - TAccountRefundAddress extends string, - TAccountClaimAccount extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: InitializeClaimAccountInput< - TAccountSigner, - TAccountMint, - TAccountRefundAddress, - TAccountClaimAccount, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): InitializeClaimAccountInstruction< - TProgramAddress, - TAccountSigner, - TAccountMint, - TAccountRefundAddress, - TAccountClaimAccount, - TAccountSystemProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - refundAddress: { value: input.refundAddress ?? null, isWritable: false }, - claimAccount: { value: input.claimAccount ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.refundAddress), - getAccountMeta(accounts.claimAccount), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitializeClaimAccountInstructionDataEncoder().encode({}), - } as InitializeClaimAccountInstruction< - TProgramAddress, - TAccountSigner, - TAccountMint, - TAccountRefundAddress, - TAccountClaimAccount, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedInitializeClaimAccountInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - mint: TAccountMetas[1]; - refundAddress: TAccountMetas[2]; - claimAccount: TAccountMetas[3]; - systemProgram: TAccountMetas[4]; - }; - data: InitializeClaimAccountInstructionData; -}; - -export function parseInitializeClaimAccountInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedInitializeClaimAccountInstruction { - if (instruction.accounts.length < 5) { - // 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: { - signer: getNextAccount(), - mint: getNextAccount(), - refundAddress: getNextAccount(), - claimAccount: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getInitializeClaimAccountInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/initializeInstructionParams.ts b/src/svm/clients/SvmSpoke/instructions/initializeInstructionParams.ts deleted file mode 100644 index d140c328d..000000000 --- a/src/svm/clients/SvmSpoke/instructions/initializeInstructionParams.ts +++ /dev/null @@ -1,328 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const INITIALIZE_INSTRUCTION_PARAMS_DISCRIMINATOR = new Uint8Array([ - 94, 206, 190, 192, 127, 8, 186, 28, -]); - -export function getInitializeInstructionParamsDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - INITIALIZE_INSTRUCTION_PARAMS_DISCRIMINATOR - ); -} - -export type InitializeInstructionParamsInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountInstructionParams extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountInstructionParams extends string - ? WritableAccount - : TAccountInstructionParams, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type InitializeInstructionParamsInstructionData = { - discriminator: ReadonlyUint8Array; - totalSize: number; -}; - -export type InitializeInstructionParamsInstructionDataArgs = { - totalSize: number; -}; - -export function getInitializeInstructionParamsInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['totalSize', getU32Encoder()], - ]), - (value) => ({ - ...value, - discriminator: INITIALIZE_INSTRUCTION_PARAMS_DISCRIMINATOR, - }) - ); -} - -export function getInitializeInstructionParamsInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['totalSize', getU32Decoder()], - ]); -} - -export function getInitializeInstructionParamsInstructionDataCodec(): Codec< - InitializeInstructionParamsInstructionDataArgs, - InitializeInstructionParamsInstructionData -> { - return combineCodec( - getInitializeInstructionParamsInstructionDataEncoder(), - getInitializeInstructionParamsInstructionDataDecoder() - ); -} - -export type InitializeInstructionParamsAsyncInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams?: Address; - systemProgram?: Address; - totalSize: InitializeInstructionParamsInstructionDataArgs['totalSize']; -}; - -export async function getInitializeInstructionParamsInstructionAsync< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: InitializeInstructionParamsAsyncInput< - TAccountSigner, - TAccountInstructionParams, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - InitializeInstructionParamsInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.instructionParams.value) { - accounts.instructionParams.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, - 114, 97, 109, 115, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.signer.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitializeInstructionParamsInstructionDataEncoder().encode( - args as InitializeInstructionParamsInstructionDataArgs - ), - } as InitializeInstructionParamsInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountSystemProgram - >; - - return instruction; -} - -export type InitializeInstructionParamsInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams: Address; - systemProgram?: Address; - totalSize: InitializeInstructionParamsInstructionDataArgs['totalSize']; -}; - -export function getInitializeInstructionParamsInstruction< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: InitializeInstructionParamsInput< - TAccountSigner, - TAccountInstructionParams, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): InitializeInstructionParamsInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountSystemProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getInitializeInstructionParamsInstructionDataEncoder().encode( - args as InitializeInstructionParamsInstructionDataArgs - ), - } as InitializeInstructionParamsInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedInitializeInstructionParamsInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - instructionParams: TAccountMetas[1]; - systemProgram: TAccountMetas[2]; - }; - data: InitializeInstructionParamsInstructionData; -}; - -export function parseInitializeInstructionParamsInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedInitializeInstructionParamsInstruction { - 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: { - signer: getNextAccount(), - instructionParams: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getInitializeInstructionParamsInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/pauseDeposits.ts b/src/svm/clients/SvmSpoke/instructions/pauseDeposits.ts deleted file mode 100644 index 16661f397..000000000 --- a/src/svm/clients/SvmSpoke/instructions/pauseDeposits.ts +++ /dev/null @@ -1,320 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBooleanDecoder, - getBooleanEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const PAUSE_DEPOSITS_DISCRIMINATOR = new Uint8Array([ - 206, 186, 203, 153, 253, 61, 206, 122, -]); - -export function getPauseDepositsDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - PAUSE_DEPOSITS_DISCRIMINATOR - ); -} - -export type PauseDepositsInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountState extends string - ? WritableAccount - : TAccountState, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type PauseDepositsInstructionData = { - discriminator: ReadonlyUint8Array; - pause: boolean; -}; - -export type PauseDepositsInstructionDataArgs = { pause: boolean }; - -export function getPauseDepositsInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['pause', getBooleanEncoder()], - ]), - (value) => ({ ...value, discriminator: PAUSE_DEPOSITS_DISCRIMINATOR }) - ); -} - -export function getPauseDepositsInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['pause', getBooleanDecoder()], - ]); -} - -export function getPauseDepositsInstructionDataCodec(): Codec< - PauseDepositsInstructionDataArgs, - PauseDepositsInstructionData -> { - return combineCodec( - getPauseDepositsInstructionDataEncoder(), - getPauseDepositsInstructionDataDecoder() - ); -} - -export type PauseDepositsAsyncInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - eventAuthority?: Address; - program: Address; - pause: PauseDepositsInstructionDataArgs['pause']; -}; - -export async function getPauseDepositsInstructionAsync< - TAccountSigner extends string, - TAccountState extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: PauseDepositsAsyncInput< - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - PauseDepositsInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - state: { value: input.state ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getPauseDepositsInstructionDataEncoder().encode( - args as PauseDepositsInstructionDataArgs - ), - } as PauseDepositsInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type PauseDepositsInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - eventAuthority: Address; - program: Address; - pause: PauseDepositsInstructionDataArgs['pause']; -}; - -export function getPauseDepositsInstruction< - TAccountSigner extends string, - TAccountState extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: PauseDepositsInput< - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): PauseDepositsInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - state: { value: input.state ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getPauseDepositsInstructionDataEncoder().encode( - args as PauseDepositsInstructionDataArgs - ), - } as PauseDepositsInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedPauseDepositsInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - state: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: PauseDepositsInstructionData; -}; - -export function parsePauseDepositsInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedPauseDepositsInstruction { - if (instruction.accounts.length < 4) { - // 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: { - signer: getNextAccount(), - state: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getPauseDepositsInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/pauseFills.ts b/src/svm/clients/SvmSpoke/instructions/pauseFills.ts deleted file mode 100644 index 967019a70..000000000 --- a/src/svm/clients/SvmSpoke/instructions/pauseFills.ts +++ /dev/null @@ -1,318 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBooleanDecoder, - getBooleanEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const PAUSE_FILLS_DISCRIMINATOR = new Uint8Array([ - 92, 114, 214, 49, 13, 243, 73, 35, -]); - -export function getPauseFillsDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(PAUSE_FILLS_DISCRIMINATOR); -} - -export type PauseFillsInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountState extends string - ? WritableAccount - : TAccountState, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type PauseFillsInstructionData = { - discriminator: ReadonlyUint8Array; - pause: boolean; -}; - -export type PauseFillsInstructionDataArgs = { pause: boolean }; - -export function getPauseFillsInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['pause', getBooleanEncoder()], - ]), - (value) => ({ ...value, discriminator: PAUSE_FILLS_DISCRIMINATOR }) - ); -} - -export function getPauseFillsInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['pause', getBooleanDecoder()], - ]); -} - -export function getPauseFillsInstructionDataCodec(): Codec< - PauseFillsInstructionDataArgs, - PauseFillsInstructionData -> { - return combineCodec( - getPauseFillsInstructionDataEncoder(), - getPauseFillsInstructionDataDecoder() - ); -} - -export type PauseFillsAsyncInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - eventAuthority?: Address; - program: Address; - pause: PauseFillsInstructionDataArgs['pause']; -}; - -export async function getPauseFillsInstructionAsync< - TAccountSigner extends string, - TAccountState extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: PauseFillsAsyncInput< - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - PauseFillsInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - state: { value: input.state ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getPauseFillsInstructionDataEncoder().encode( - args as PauseFillsInstructionDataArgs - ), - } as PauseFillsInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type PauseFillsInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - eventAuthority: Address; - program: Address; - pause: PauseFillsInstructionDataArgs['pause']; -}; - -export function getPauseFillsInstruction< - TAccountSigner extends string, - TAccountState extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: PauseFillsInput< - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): PauseFillsInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - state: { value: input.state ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getPauseFillsInstructionDataEncoder().encode( - args as PauseFillsInstructionDataArgs - ), - } as PauseFillsInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedPauseFillsInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - state: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: PauseFillsInstructionData; -}; - -export function parsePauseFillsInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedPauseFillsInstruction { - if (instruction.accounts.length < 4) { - // 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: { - signer: getNextAccount(), - state: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getPauseFillsInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/relayRootBundle.ts b/src/svm/clients/SvmSpoke/instructions/relayRootBundle.ts deleted file mode 100644 index 52d9be8cb..000000000 --- a/src/svm/clients/SvmSpoke/instructions/relayRootBundle.ts +++ /dev/null @@ -1,405 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const RELAY_ROOT_BUNDLE_DISCRIMINATOR = new Uint8Array([ - 69, 13, 223, 204, 251, 61, 105, 6, -]); - -export function getRelayRootBundleDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - RELAY_ROOT_BUNDLE_DISCRIMINATOR - ); -} - -export type RelayRootBundleInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountPayer extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountRootBundle extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountState extends string - ? WritableAccount - : TAccountState, - TAccountRootBundle extends string - ? WritableAccount - : TAccountRootBundle, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type RelayRootBundleInstructionData = { - discriminator: ReadonlyUint8Array; - relayerRefundRoot: ReadonlyUint8Array; - slowRelayRoot: ReadonlyUint8Array; -}; - -export type RelayRootBundleInstructionDataArgs = { - relayerRefundRoot: ReadonlyUint8Array; - slowRelayRoot: ReadonlyUint8Array; -}; - -export function getRelayRootBundleInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['relayerRefundRoot', fixEncoderSize(getBytesEncoder(), 32)], - ['slowRelayRoot', fixEncoderSize(getBytesEncoder(), 32)], - ]), - (value) => ({ ...value, discriminator: RELAY_ROOT_BUNDLE_DISCRIMINATOR }) - ); -} - -export function getRelayRootBundleInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['relayerRefundRoot', fixDecoderSize(getBytesDecoder(), 32)], - ['slowRelayRoot', fixDecoderSize(getBytesDecoder(), 32)], - ]); -} - -export function getRelayRootBundleInstructionDataCodec(): Codec< - RelayRootBundleInstructionDataArgs, - RelayRootBundleInstructionData -> { - return combineCodec( - getRelayRootBundleInstructionDataEncoder(), - getRelayRootBundleInstructionDataDecoder() - ); -} - -export type RelayRootBundleAsyncInput< - TAccountSigner extends string = string, - TAccountPayer extends string = string, - TAccountState extends string = string, - TAccountRootBundle extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - payer: TransactionSigner; - state: Address; - rootBundle: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - relayerRefundRoot: RelayRootBundleInstructionDataArgs['relayerRefundRoot']; - slowRelayRoot: RelayRootBundleInstructionDataArgs['slowRelayRoot']; -}; - -export async function getRelayRootBundleInstructionAsync< - TAccountSigner extends string, - TAccountPayer extends string, - TAccountState extends string, - TAccountRootBundle extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: RelayRootBundleAsyncInput< - TAccountSigner, - TAccountPayer, - TAccountState, - TAccountRootBundle, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - RelayRootBundleInstruction< - TProgramAddress, - TAccountSigner, - TAccountPayer, - TAccountState, - TAccountRootBundle, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - payer: { value: input.payer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - rootBundle: { value: input.rootBundle ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.rootBundle), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getRelayRootBundleInstructionDataEncoder().encode( - args as RelayRootBundleInstructionDataArgs - ), - } as RelayRootBundleInstruction< - TProgramAddress, - TAccountSigner, - TAccountPayer, - TAccountState, - TAccountRootBundle, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type RelayRootBundleInput< - TAccountSigner extends string = string, - TAccountPayer extends string = string, - TAccountState extends string = string, - TAccountRootBundle extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - payer: TransactionSigner; - state: Address; - rootBundle: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - relayerRefundRoot: RelayRootBundleInstructionDataArgs['relayerRefundRoot']; - slowRelayRoot: RelayRootBundleInstructionDataArgs['slowRelayRoot']; -}; - -export function getRelayRootBundleInstruction< - TAccountSigner extends string, - TAccountPayer extends string, - TAccountState extends string, - TAccountRootBundle extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: RelayRootBundleInput< - TAccountSigner, - TAccountPayer, - TAccountState, - TAccountRootBundle, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): RelayRootBundleInstruction< - TProgramAddress, - TAccountSigner, - TAccountPayer, - TAccountState, - TAccountRootBundle, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - payer: { value: input.payer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - rootBundle: { value: input.rootBundle ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.payer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.rootBundle), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getRelayRootBundleInstructionDataEncoder().encode( - args as RelayRootBundleInstructionDataArgs - ), - } as RelayRootBundleInstruction< - TProgramAddress, - TAccountSigner, - TAccountPayer, - TAccountState, - TAccountRootBundle, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedRelayRootBundleInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - payer: TAccountMetas[1]; - state: TAccountMetas[2]; - rootBundle: TAccountMetas[3]; - systemProgram: TAccountMetas[4]; - eventAuthority: TAccountMetas[5]; - program: TAccountMetas[6]; - }; - data: RelayRootBundleInstructionData; -}; - -export function parseRelayRootBundleInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedRelayRootBundleInstruction { - if (instruction.accounts.length < 7) { - // 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: { - signer: getNextAccount(), - payer: getNextAccount(), - state: getNextAccount(), - rootBundle: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getRelayRootBundleInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/requestSlowFill.ts b/src/svm/clients/SvmSpoke/instructions/requestSlowFill.ts deleted file mode 100644 index 2c5b39d2d..000000000 --- a/src/svm/clients/SvmSpoke/instructions/requestSlowFill.ts +++ /dev/null @@ -1,456 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getOptionDecoder, - getOptionEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type Option, - type OptionOrNullable, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - expectSome, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; -import { - getRelayDataDecoder, - getRelayDataEncoder, - type RelayData, - type RelayDataArgs, -} from '../types'; - -export const REQUEST_SLOW_FILL_DISCRIMINATOR = new Uint8Array([ - 39, 157, 165, 187, 88, 217, 207, 98, -]); - -export function getRequestSlowFillDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - REQUEST_SLOW_FILL_DISCRIMINATOR - ); -} - -export type RequestSlowFillInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountInstructionParams extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountFillStatus extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountInstructionParams extends string - ? WritableAccount - : TAccountInstructionParams, - TAccountState extends string - ? ReadonlyAccount - : TAccountState, - TAccountFillStatus extends string - ? WritableAccount - : TAccountFillStatus, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type RequestSlowFillInstructionData = { - discriminator: ReadonlyUint8Array; - relayHash: ReadonlyUint8Array; - relayData: Option; -}; - -export type RequestSlowFillInstructionDataArgs = { - relayHash: ReadonlyUint8Array; - relayData: OptionOrNullable; -}; - -export function getRequestSlowFillInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['relayHash', fixEncoderSize(getBytesEncoder(), 32)], - ['relayData', getOptionEncoder(getRelayDataEncoder())], - ]), - (value) => ({ ...value, discriminator: REQUEST_SLOW_FILL_DISCRIMINATOR }) - ); -} - -export function getRequestSlowFillInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['relayHash', fixDecoderSize(getBytesDecoder(), 32)], - ['relayData', getOptionDecoder(getRelayDataDecoder())], - ]); -} - -export function getRequestSlowFillInstructionDataCodec(): Codec< - RequestSlowFillInstructionDataArgs, - RequestSlowFillInstructionData -> { - return combineCodec( - getRequestSlowFillInstructionDataEncoder(), - getRequestSlowFillInstructionDataDecoder() - ); -} - -export type RequestSlowFillAsyncInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountState extends string = string, - TAccountFillStatus extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams?: Address; - state: Address; - fillStatus?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - relayHash: RequestSlowFillInstructionDataArgs['relayHash']; - relayData: RequestSlowFillInstructionDataArgs['relayData']; -}; - -export async function getRequestSlowFillInstructionAsync< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountState extends string, - TAccountFillStatus extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: RequestSlowFillAsyncInput< - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountFillStatus, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - RequestSlowFillInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountFillStatus, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - state: { value: input.state ?? null, isWritable: false }, - fillStatus: { value: input.fillStatus ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.instructionParams.value) { - accounts.instructionParams.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, - 114, 97, 109, 115, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.signer.value)), - ], - }); - } - if (!accounts.fillStatus.value) { - accounts.fillStatus.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode(new Uint8Array([102, 105, 108, 108, 115])), - fixEncoderSize(getBytesEncoder(), 32).encode( - expectSome(args.relayHash) - ), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.state), - getAccountMeta(accounts.fillStatus), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getRequestSlowFillInstructionDataEncoder().encode( - args as RequestSlowFillInstructionDataArgs - ), - } as RequestSlowFillInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountFillStatus, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type RequestSlowFillInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountState extends string = string, - TAccountFillStatus extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams?: Address; - state: Address; - fillStatus: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - relayHash: RequestSlowFillInstructionDataArgs['relayHash']; - relayData: RequestSlowFillInstructionDataArgs['relayData']; -}; - -export function getRequestSlowFillInstruction< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountState extends string, - TAccountFillStatus extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: RequestSlowFillInput< - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountFillStatus, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): RequestSlowFillInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountFillStatus, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - state: { value: input.state ?? null, isWritable: false }, - fillStatus: { value: input.fillStatus ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.state), - getAccountMeta(accounts.fillStatus), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getRequestSlowFillInstructionDataEncoder().encode( - args as RequestSlowFillInstructionDataArgs - ), - } as RequestSlowFillInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountState, - TAccountFillStatus, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedRequestSlowFillInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - instructionParams?: TAccountMetas[1] | undefined; - state: TAccountMetas[2]; - fillStatus: TAccountMetas[3]; - systemProgram: TAccountMetas[4]; - eventAuthority: TAccountMetas[5]; - program: TAccountMetas[6]; - }; - data: RequestSlowFillInstructionData; -}; - -export function parseRequestSlowFillInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedRequestSlowFillInstruction { - if (instruction.accounts.length < 7) { - // TODO: Coded error. - throw new Error('Not enough accounts'); - } - let accountIndex = 0; - const getNextAccount = () => { - const accountMeta = instruction.accounts![accountIndex]!; - accountIndex += 1; - return accountMeta; - }; - const getNextOptionalAccount = () => { - const accountMeta = getNextAccount(); - return accountMeta.address === SVM_SPOKE_PROGRAM_ADDRESS - ? undefined - : accountMeta; - }; - return { - programAddress: instruction.programAddress, - accounts: { - signer: getNextAccount(), - instructionParams: getNextOptionalAccount(), - state: getNextAccount(), - fillStatus: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getRequestSlowFillInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/setCrossDomainAdmin.ts b/src/svm/clients/SvmSpoke/instructions/setCrossDomainAdmin.ts deleted file mode 100644 index 8484ffa00..000000000 --- a/src/svm/clients/SvmSpoke/instructions/setCrossDomainAdmin.ts +++ /dev/null @@ -1,327 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_CROSS_DOMAIN_ADMIN_DISCRIMINATOR = new Uint8Array([ - 102, 206, 237, 106, 63, 141, 42, 248, -]); - -export function getSetCrossDomainAdminDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_CROSS_DOMAIN_ADMIN_DISCRIMINATOR - ); -} - -export type SetCrossDomainAdminInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountState extends string - ? WritableAccount - : TAccountState, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type SetCrossDomainAdminInstructionData = { - discriminator: ReadonlyUint8Array; - crossDomainAdmin: Address; -}; - -export type SetCrossDomainAdminInstructionDataArgs = { - crossDomainAdmin: Address; -}; - -export function getSetCrossDomainAdminInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['crossDomainAdmin', getAddressEncoder()], - ]), - (value) => ({ - ...value, - discriminator: SET_CROSS_DOMAIN_ADMIN_DISCRIMINATOR, - }) - ); -} - -export function getSetCrossDomainAdminInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['crossDomainAdmin', getAddressDecoder()], - ]); -} - -export function getSetCrossDomainAdminInstructionDataCodec(): Codec< - SetCrossDomainAdminInstructionDataArgs, - SetCrossDomainAdminInstructionData -> { - return combineCodec( - getSetCrossDomainAdminInstructionDataEncoder(), - getSetCrossDomainAdminInstructionDataDecoder() - ); -} - -export type SetCrossDomainAdminAsyncInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - eventAuthority?: Address; - program: Address; - crossDomainAdmin: SetCrossDomainAdminInstructionDataArgs['crossDomainAdmin']; -}; - -export async function getSetCrossDomainAdminInstructionAsync< - TAccountSigner extends string, - TAccountState extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: SetCrossDomainAdminAsyncInput< - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - SetCrossDomainAdminInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - state: { value: input.state ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetCrossDomainAdminInstructionDataEncoder().encode( - args as SetCrossDomainAdminInstructionDataArgs - ), - } as SetCrossDomainAdminInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type SetCrossDomainAdminInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - eventAuthority: Address; - program: Address; - crossDomainAdmin: SetCrossDomainAdminInstructionDataArgs['crossDomainAdmin']; -}; - -export function getSetCrossDomainAdminInstruction< - TAccountSigner extends string, - TAccountState extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: SetCrossDomainAdminInput< - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): SetCrossDomainAdminInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - state: { value: input.state ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetCrossDomainAdminInstructionDataEncoder().encode( - args as SetCrossDomainAdminInstructionDataArgs - ), - } as SetCrossDomainAdminInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedSetCrossDomainAdminInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - state: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: SetCrossDomainAdminInstructionData; -}; - -export function parseSetCrossDomainAdminInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetCrossDomainAdminInstruction { - if (instruction.accounts.length < 4) { - // 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: { - signer: getNextAccount(), - state: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getSetCrossDomainAdminInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/setCurrentTime.ts b/src/svm/clients/SvmSpoke/instructions/setCurrentTime.ts deleted file mode 100644 index c557fa902..000000000 --- a/src/svm/clients/SvmSpoke/instructions/setCurrentTime.ts +++ /dev/null @@ -1,188 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_CURRENT_TIME_DISCRIMINATOR = new Uint8Array([ - 69, 100, 169, 193, 125, 0, 150, 69, -]); - -export function getSetCurrentTimeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_CURRENT_TIME_DISCRIMINATOR - ); -} - -export type SetCurrentTimeInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountState extends string | AccountMeta = string, - TAccountSigner extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountState extends string - ? WritableAccount - : TAccountState, - TAccountSigner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSigner, - ...TRemainingAccounts, - ] - >; - -export type SetCurrentTimeInstructionData = { - discriminator: ReadonlyUint8Array; - newTime: number; -}; - -export type SetCurrentTimeInstructionDataArgs = { newTime: number }; - -export function getSetCurrentTimeInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newTime', getU32Encoder()], - ]), - (value) => ({ ...value, discriminator: SET_CURRENT_TIME_DISCRIMINATOR }) - ); -} - -export function getSetCurrentTimeInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newTime', getU32Decoder()], - ]); -} - -export function getSetCurrentTimeInstructionDataCodec(): Codec< - SetCurrentTimeInstructionDataArgs, - SetCurrentTimeInstructionData -> { - return combineCodec( - getSetCurrentTimeInstructionDataEncoder(), - getSetCurrentTimeInstructionDataDecoder() - ); -} - -export type SetCurrentTimeInput< - TAccountState extends string = string, - TAccountSigner extends string = string, -> = { - state: Address; - signer: TransactionSigner; - newTime: SetCurrentTimeInstructionDataArgs['newTime']; -}; - -export function getSetCurrentTimeInstruction< - TAccountState extends string, - TAccountSigner extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: SetCurrentTimeInput, - config?: { programAddress?: TProgramAddress } -): SetCurrentTimeInstruction { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - state: { value: input.state ?? null, isWritable: true }, - signer: { value: input.signer ?? 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.state), getAccountMeta(accounts.signer)], - programAddress, - data: getSetCurrentTimeInstructionDataEncoder().encode( - args as SetCurrentTimeInstructionDataArgs - ), - } as SetCurrentTimeInstruction< - TProgramAddress, - TAccountState, - TAccountSigner - >; - - return instruction; -} - -export type ParsedSetCurrentTimeInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - state: TAccountMetas[0]; - signer: TAccountMetas[1]; - }; - data: SetCurrentTimeInstructionData; -}; - -export function parseSetCurrentTimeInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetCurrentTimeInstruction { - if (instruction.accounts.length < 2) { - // 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: { - state: getNextAccount(), - signer: getNextAccount(), - }, - data: getSetCurrentTimeInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/transferOwnership.ts b/src/svm/clients/SvmSpoke/instructions/transferOwnership.ts deleted file mode 100644 index c23021b57..000000000 --- a/src/svm/clients/SvmSpoke/instructions/transferOwnership.ts +++ /dev/null @@ -1,320 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const TRANSFER_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ - 65, 177, 215, 73, 53, 45, 99, 47, -]); - -export function getTransferOwnershipDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - TRANSFER_OWNERSHIP_DISCRIMINATOR - ); -} - -export type TransferOwnershipInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountState extends string - ? WritableAccount - : TAccountState, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type TransferOwnershipInstructionData = { - discriminator: ReadonlyUint8Array; - newOwner: Address; -}; - -export type TransferOwnershipInstructionDataArgs = { newOwner: Address }; - -export function getTransferOwnershipInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newOwner', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: TRANSFER_OWNERSHIP_DISCRIMINATOR }) - ); -} - -export function getTransferOwnershipInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newOwner', getAddressDecoder()], - ]); -} - -export function getTransferOwnershipInstructionDataCodec(): Codec< - TransferOwnershipInstructionDataArgs, - TransferOwnershipInstructionData -> { - return combineCodec( - getTransferOwnershipInstructionDataEncoder(), - getTransferOwnershipInstructionDataDecoder() - ); -} - -export type TransferOwnershipAsyncInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - eventAuthority?: Address; - program: Address; - newOwner: TransferOwnershipInstructionDataArgs['newOwner']; -}; - -export async function getTransferOwnershipInstructionAsync< - TAccountSigner extends string, - TAccountState extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: TransferOwnershipAsyncInput< - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - TransferOwnershipInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - state: { value: input.state ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getTransferOwnershipInstructionDataEncoder().encode( - args as TransferOwnershipInstructionDataArgs - ), - } as TransferOwnershipInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type TransferOwnershipInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - eventAuthority: Address; - program: Address; - newOwner: TransferOwnershipInstructionDataArgs['newOwner']; -}; - -export function getTransferOwnershipInstruction< - TAccountSigner extends string, - TAccountState extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: TransferOwnershipInput< - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): TransferOwnershipInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - state: { value: input.state ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getTransferOwnershipInstructionDataEncoder().encode( - args as TransferOwnershipInstructionDataArgs - ), - } as TransferOwnershipInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedTransferOwnershipInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - state: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: TransferOwnershipInstructionData; -}; - -export function parseTransferOwnershipInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedTransferOwnershipInstruction { - if (instruction.accounts.length < 4) { - // 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: { - signer: getNextAccount(), - state: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getTransferOwnershipInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/unsafeDeposit.ts b/src/svm/clients/SvmSpoke/instructions/unsafeDeposit.ts deleted file mode 100644 index d3d8eb447..000000000 --- a/src/svm/clients/SvmSpoke/instructions/unsafeDeposit.ts +++ /dev/null @@ -1,622 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - expectSome, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const UNSAFE_DEPOSIT_DISCRIMINATOR = new Uint8Array([ - 196, 187, 166, 179, 3, 146, 150, 246, -]); - -export function getUnsafeDepositDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - UNSAFE_DEPOSIT_DISCRIMINATOR - ); -} - -export type UnsafeDepositInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountState extends string | AccountMeta = string, - TAccountDelegate extends string | AccountMeta = string, - TAccountDepositorTokenAccount extends string | AccountMeta = string, - TAccountVault extends string | AccountMeta = string, - TAccountMint extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountAssociatedTokenProgram extends string | AccountMeta = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountState extends string - ? WritableAccount - : TAccountState, - TAccountDelegate extends string - ? ReadonlyAccount - : TAccountDelegate, - TAccountDepositorTokenAccount extends string - ? WritableAccount - : TAccountDepositorTokenAccount, - TAccountVault extends string - ? WritableAccount - : TAccountVault, - TAccountMint extends string - ? ReadonlyAccount - : TAccountMint, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountAssociatedTokenProgram extends string - ? ReadonlyAccount - : TAccountAssociatedTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UnsafeDepositInstructionData = { - discriminator: ReadonlyUint8Array; - depositor: Address; - recipient: Address; - inputToken: Address; - outputToken: Address; - inputAmount: bigint; - outputAmount: ReadonlyUint8Array; - destinationChainId: bigint; - exclusiveRelayer: Address; - depositNonce: bigint; - quoteTimestamp: number; - fillDeadline: number; - exclusivityParameter: number; - message: ReadonlyUint8Array; -}; - -export type UnsafeDepositInstructionDataArgs = { - depositor: Address; - recipient: Address; - inputToken: Address; - outputToken: Address; - inputAmount: number | bigint; - outputAmount: ReadonlyUint8Array; - destinationChainId: number | bigint; - exclusiveRelayer: Address; - depositNonce: number | bigint; - quoteTimestamp: number; - fillDeadline: number; - exclusivityParameter: number; - message: ReadonlyUint8Array; -}; - -export function getUnsafeDepositInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['depositor', getAddressEncoder()], - ['recipient', getAddressEncoder()], - ['inputToken', getAddressEncoder()], - ['outputToken', getAddressEncoder()], - ['inputAmount', getU64Encoder()], - ['outputAmount', fixEncoderSize(getBytesEncoder(), 32)], - ['destinationChainId', getU64Encoder()], - ['exclusiveRelayer', getAddressEncoder()], - ['depositNonce', getU64Encoder()], - ['quoteTimestamp', getU32Encoder()], - ['fillDeadline', getU32Encoder()], - ['exclusivityParameter', getU32Encoder()], - ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ ...value, discriminator: UNSAFE_DEPOSIT_DISCRIMINATOR }) - ); -} - -export function getUnsafeDepositInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['depositor', getAddressDecoder()], - ['recipient', getAddressDecoder()], - ['inputToken', getAddressDecoder()], - ['outputToken', getAddressDecoder()], - ['inputAmount', getU64Decoder()], - ['outputAmount', fixDecoderSize(getBytesDecoder(), 32)], - ['destinationChainId', getU64Decoder()], - ['exclusiveRelayer', getAddressDecoder()], - ['depositNonce', getU64Decoder()], - ['quoteTimestamp', getU32Decoder()], - ['fillDeadline', getU32Decoder()], - ['exclusivityParameter', getU32Decoder()], - ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getUnsafeDepositInstructionDataCodec(): Codec< - UnsafeDepositInstructionDataArgs, - UnsafeDepositInstructionData -> { - return combineCodec( - getUnsafeDepositInstructionDataEncoder(), - getUnsafeDepositInstructionDataDecoder() - ); -} - -export type UnsafeDepositAsyncInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountDelegate extends string = string, - TAccountDepositorTokenAccount extends string = string, - TAccountVault extends string = string, - TAccountMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountAssociatedTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - delegate: Address; - depositorTokenAccount?: Address; - vault?: Address; - mint: Address; - tokenProgram?: Address; - associatedTokenProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - depositor: UnsafeDepositInstructionDataArgs['depositor']; - recipient: UnsafeDepositInstructionDataArgs['recipient']; - inputToken: UnsafeDepositInstructionDataArgs['inputToken']; - outputToken: UnsafeDepositInstructionDataArgs['outputToken']; - inputAmount: UnsafeDepositInstructionDataArgs['inputAmount']; - outputAmount: UnsafeDepositInstructionDataArgs['outputAmount']; - destinationChainId: UnsafeDepositInstructionDataArgs['destinationChainId']; - exclusiveRelayer: UnsafeDepositInstructionDataArgs['exclusiveRelayer']; - depositNonce: UnsafeDepositInstructionDataArgs['depositNonce']; - quoteTimestamp: UnsafeDepositInstructionDataArgs['quoteTimestamp']; - fillDeadline: UnsafeDepositInstructionDataArgs['fillDeadline']; - exclusivityParameter: UnsafeDepositInstructionDataArgs['exclusivityParameter']; - message: UnsafeDepositInstructionDataArgs['message']; -}; - -export async function getUnsafeDepositInstructionAsync< - TAccountSigner extends string, - TAccountState extends string, - TAccountDelegate extends string, - TAccountDepositorTokenAccount extends string, - TAccountVault extends string, - TAccountMint extends string, - TAccountTokenProgram extends string, - TAccountAssociatedTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: UnsafeDepositAsyncInput< - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - UnsafeDepositInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - delegate: { value: input.delegate ?? null, isWritable: false }, - depositorTokenAccount: { - value: input.depositorTokenAccount ?? null, - isWritable: true, - }, - vault: { value: input.vault ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - associatedTokenProgram: { - value: input.associatedTokenProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.depositorTokenAccount.value) { - accounts.depositorTokenAccount.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getAddressEncoder().encode(expectSome(args.depositor)), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.vault.value) { - accounts.vault.value = await getProgramDerivedAddress({ - programAddress: - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>, - seeds: [ - getAddressEncoder().encode(expectAddress(accounts.state.value)), - getAddressEncoder().encode(expectAddress(accounts.tokenProgram.value)), - getAddressEncoder().encode(expectAddress(accounts.mint.value)), - ], - }); - } - if (!accounts.associatedTokenProgram.value) { - accounts.associatedTokenProgram.value = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.delegate), - getAccountMeta(accounts.depositorTokenAccount), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.associatedTokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUnsafeDepositInstructionDataEncoder().encode( - args as UnsafeDepositInstructionDataArgs - ), - } as UnsafeDepositInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type UnsafeDepositInput< - TAccountSigner extends string = string, - TAccountState extends string = string, - TAccountDelegate extends string = string, - TAccountDepositorTokenAccount extends string = string, - TAccountVault extends string = string, - TAccountMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountAssociatedTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - signer: TransactionSigner; - state: Address; - delegate: Address; - depositorTokenAccount: Address; - vault: Address; - mint: Address; - tokenProgram?: Address; - associatedTokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - depositor: UnsafeDepositInstructionDataArgs['depositor']; - recipient: UnsafeDepositInstructionDataArgs['recipient']; - inputToken: UnsafeDepositInstructionDataArgs['inputToken']; - outputToken: UnsafeDepositInstructionDataArgs['outputToken']; - inputAmount: UnsafeDepositInstructionDataArgs['inputAmount']; - outputAmount: UnsafeDepositInstructionDataArgs['outputAmount']; - destinationChainId: UnsafeDepositInstructionDataArgs['destinationChainId']; - exclusiveRelayer: UnsafeDepositInstructionDataArgs['exclusiveRelayer']; - depositNonce: UnsafeDepositInstructionDataArgs['depositNonce']; - quoteTimestamp: UnsafeDepositInstructionDataArgs['quoteTimestamp']; - fillDeadline: UnsafeDepositInstructionDataArgs['fillDeadline']; - exclusivityParameter: UnsafeDepositInstructionDataArgs['exclusivityParameter']; - message: UnsafeDepositInstructionDataArgs['message']; -}; - -export function getUnsafeDepositInstruction< - TAccountSigner extends string, - TAccountState extends string, - TAccountDelegate extends string, - TAccountDepositorTokenAccount extends string, - TAccountVault extends string, - TAccountMint extends string, - TAccountTokenProgram extends string, - TAccountAssociatedTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: UnsafeDepositInput< - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UnsafeDepositInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: true }, - state: { value: input.state ?? null, isWritable: true }, - delegate: { value: input.delegate ?? null, isWritable: false }, - depositorTokenAccount: { - value: input.depositorTokenAccount ?? null, - isWritable: true, - }, - vault: { value: input.vault ?? null, isWritable: true }, - mint: { value: input.mint ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - associatedTokenProgram: { - value: input.associatedTokenProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.associatedTokenProgram.value) { - accounts.associatedTokenProgram.value = - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.state), - getAccountMeta(accounts.delegate), - getAccountMeta(accounts.depositorTokenAccount), - getAccountMeta(accounts.vault), - getAccountMeta(accounts.mint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.associatedTokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUnsafeDepositInstructionDataEncoder().encode( - args as UnsafeDepositInstructionDataArgs - ), - } as UnsafeDepositInstruction< - TProgramAddress, - TAccountSigner, - TAccountState, - TAccountDelegate, - TAccountDepositorTokenAccount, - TAccountVault, - TAccountMint, - TAccountTokenProgram, - TAccountAssociatedTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUnsafeDepositInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - state: TAccountMetas[1]; - delegate: TAccountMetas[2]; - depositorTokenAccount: TAccountMetas[3]; - vault: TAccountMetas[4]; - mint: TAccountMetas[5]; - tokenProgram: TAccountMetas[6]; - associatedTokenProgram: TAccountMetas[7]; - systemProgram: TAccountMetas[8]; - eventAuthority: TAccountMetas[9]; - program: TAccountMetas[10]; - }; - data: UnsafeDepositInstructionData; -}; - -export function parseUnsafeDepositInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUnsafeDepositInstruction { - if (instruction.accounts.length < 11) { - // 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: { - signer: getNextAccount(), - state: getNextAccount(), - delegate: getNextAccount(), - depositorTokenAccount: getNextAccount(), - vault: getNextAccount(), - mint: getNextAccount(), - tokenProgram: getNextAccount(), - associatedTokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUnsafeDepositInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/SvmSpoke/instructions/writeInstructionParamsFragment.ts b/src/svm/clients/SvmSpoke/instructions/writeInstructionParamsFragment.ts deleted file mode 100644 index cf863c6b1..000000000 --- a/src/svm/clients/SvmSpoke/instructions/writeInstructionParamsFragment.ts +++ /dev/null @@ -1,336 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { SVM_SPOKE_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const WRITE_INSTRUCTION_PARAMS_FRAGMENT_DISCRIMINATOR = new Uint8Array([ - 238, 182, 109, 113, 124, 255, 72, 18, -]); - -export function getWriteInstructionParamsFragmentDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - WRITE_INSTRUCTION_PARAMS_FRAGMENT_DISCRIMINATOR - ); -} - -export type WriteInstructionParamsFragmentInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountSigner extends string | AccountMeta = string, - TAccountInstructionParams extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountSigner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountSigner, - TAccountInstructionParams extends string - ? WritableAccount - : TAccountInstructionParams, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - ...TRemainingAccounts, - ] - >; - -export type WriteInstructionParamsFragmentInstructionData = { - discriminator: ReadonlyUint8Array; - offset: number; - fragment: ReadonlyUint8Array; -}; - -export type WriteInstructionParamsFragmentInstructionDataArgs = { - offset: number; - fragment: ReadonlyUint8Array; -}; - -export function getWriteInstructionParamsFragmentInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['offset', getU32Encoder()], - ['fragment', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ - ...value, - discriminator: WRITE_INSTRUCTION_PARAMS_FRAGMENT_DISCRIMINATOR, - }) - ); -} - -export function getWriteInstructionParamsFragmentInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['offset', getU32Decoder()], - ['fragment', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getWriteInstructionParamsFragmentInstructionDataCodec(): Codec< - WriteInstructionParamsFragmentInstructionDataArgs, - WriteInstructionParamsFragmentInstructionData -> { - return combineCodec( - getWriteInstructionParamsFragmentInstructionDataEncoder(), - getWriteInstructionParamsFragmentInstructionDataDecoder() - ); -} - -export type WriteInstructionParamsFragmentAsyncInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams?: Address; - systemProgram?: Address; - offset: WriteInstructionParamsFragmentInstructionDataArgs['offset']; - fragment: WriteInstructionParamsFragmentInstructionDataArgs['fragment']; -}; - -export async function getWriteInstructionParamsFragmentInstructionAsync< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: WriteInstructionParamsFragmentAsyncInput< - TAccountSigner, - TAccountInstructionParams, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - WriteInstructionParamsFragmentInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountSystemProgram - > -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.instructionParams.value) { - accounts.instructionParams.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 105, 110, 115, 116, 114, 117, 99, 116, 105, 111, 110, 95, 112, 97, - 114, 97, 109, 115, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.signer.value)), - ], - }); - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getWriteInstructionParamsFragmentInstructionDataEncoder().encode( - args as WriteInstructionParamsFragmentInstructionDataArgs - ), - } as WriteInstructionParamsFragmentInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountSystemProgram - >; - - return instruction; -} - -export type WriteInstructionParamsFragmentInput< - TAccountSigner extends string = string, - TAccountInstructionParams extends string = string, - TAccountSystemProgram extends string = string, -> = { - signer: TransactionSigner; - instructionParams: Address; - systemProgram?: Address; - offset: WriteInstructionParamsFragmentInstructionDataArgs['offset']; - fragment: WriteInstructionParamsFragmentInstructionDataArgs['fragment']; -}; - -export function getWriteInstructionParamsFragmentInstruction< - TAccountSigner extends string, - TAccountInstructionParams extends string, - TAccountSystemProgram extends string, - TProgramAddress extends Address = typeof SVM_SPOKE_PROGRAM_ADDRESS, ->( - input: WriteInstructionParamsFragmentInput< - TAccountSigner, - TAccountInstructionParams, - TAccountSystemProgram - >, - config?: { programAddress?: TProgramAddress } -): WriteInstructionParamsFragmentInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountSystemProgram -> { - // Program address. - const programAddress = config?.programAddress ?? SVM_SPOKE_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - signer: { value: input.signer ?? null, isWritable: false }, - instructionParams: { - value: input.instructionParams ?? null, - isWritable: true, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.signer), - getAccountMeta(accounts.instructionParams), - getAccountMeta(accounts.systemProgram), - ], - programAddress, - data: getWriteInstructionParamsFragmentInstructionDataEncoder().encode( - args as WriteInstructionParamsFragmentInstructionDataArgs - ), - } as WriteInstructionParamsFragmentInstruction< - TProgramAddress, - TAccountSigner, - TAccountInstructionParams, - TAccountSystemProgram - >; - - return instruction; -} - -export type ParsedWriteInstructionParamsFragmentInstruction< - TProgram extends string = typeof SVM_SPOKE_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - signer: TAccountMetas[0]; - instructionParams: TAccountMetas[1]; - systemProgram: TAccountMetas[2]; - }; - data: WriteInstructionParamsFragmentInstructionData; -}; - -export function parseWriteInstructionParamsFragmentInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedWriteInstructionParamsFragmentInstruction { - 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: { - signer: getNextAccount(), - instructionParams: getNextAccount(), - systemProgram: getNextAccount(), - }, - data: getWriteInstructionParamsFragmentInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/SvmSpoke/programs/index.ts b/src/svm/clients/SvmSpoke/programs/index.ts deleted file mode 100644 index 90c874042..000000000 --- a/src/svm/clients/SvmSpoke/programs/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './svmSpoke'; diff --git a/src/svm/clients/SvmSpoke/programs/svmSpoke.ts b/src/svm/clients/SvmSpoke/programs/svmSpoke.ts deleted file mode 100644 index 39019c732..000000000 --- a/src/svm/clients/SvmSpoke/programs/svmSpoke.ts +++ /dev/null @@ -1,588 +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/kit'; -import { - type ParsedBridgeTokensToHubPoolInstruction, - type ParsedClaimRelayerRefundInstruction, - type ParsedCloseClaimAccountInstruction, - type ParsedCloseFillPdaInstruction, - type ParsedCloseInstructionParamsInstruction, - type ParsedCreateTokenAccountsInstruction, - type ParsedDepositInstruction, - type ParsedDepositNowInstruction, - type ParsedEmergencyDeleteRootBundleInstruction, - type ParsedExecuteRelayerRefundLeafDeferredInstruction, - type ParsedExecuteRelayerRefundLeafInstruction, - type ParsedExecuteSlowRelayLeafInstruction, - type ParsedFillRelayInstruction, - type ParsedGetUnsafeDepositIdInstruction, - type ParsedHandleReceiveMessageInstruction, - type ParsedInitializeClaimAccountInstruction, - type ParsedInitializeInstruction, - type ParsedInitializeInstructionParamsInstruction, - type ParsedPauseDepositsInstruction, - type ParsedPauseFillsInstruction, - type ParsedRelayRootBundleInstruction, - type ParsedRequestSlowFillInstruction, - type ParsedSetCrossDomainAdminInstruction, - type ParsedSetCurrentTimeInstruction, - type ParsedTransferOwnershipInstruction, - type ParsedUnsafeDepositInstruction, - type ParsedWriteInstructionParamsFragmentInstruction, -} from '../instructions'; - -export const SVM_SPOKE_PROGRAM_ADDRESS = - 'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru' as Address<'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru'>; - -export enum SvmSpokeAccount { - ClaimAccount, - ExecuteRelayerRefundLeafParams, - ExecuteSlowRelayLeafParams, - FillRelayParams, - FillStatusAccount, - RequestSlowFillParams, - RootBundle, - State, - TransferLiability, -} - -export function identifySvmSpokeAccount( - account: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): SvmSpokeAccount { - const data = 'data' in account ? account.data : account; - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([113, 109, 47, 96, 242, 219, 61, 165]) - ), - 0 - ) - ) { - return SvmSpokeAccount.ClaimAccount; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([192, 59, 93, 9, 171, 77, 28, 250]) - ), - 0 - ) - ) { - return SvmSpokeAccount.ExecuteRelayerRefundLeafParams; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([135, 208, 119, 251, 14, 222, 66, 155]) - ), - 0 - ) - ) { - return SvmSpokeAccount.ExecuteSlowRelayLeafParams; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([50, 243, 51, 185, 89, 60, 43, 202]) - ), - 0 - ) - ) { - return SvmSpokeAccount.FillRelayParams; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([105, 89, 88, 35, 24, 147, 178, 137]) - ), - 0 - ) - ) { - return SvmSpokeAccount.FillStatusAccount; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([5, 54, 214, 89, 197, 37, 118, 28]) - ), - 0 - ) - ) { - return SvmSpokeAccount.RequestSlowFillParams; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([66, 221, 214, 231, 25, 222, 184, 219]) - ), - 0 - ) - ) { - return SvmSpokeAccount.RootBundle; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([216, 146, 107, 94, 104, 75, 182, 177]) - ), - 0 - ) - ) { - return SvmSpokeAccount.State; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([157, 137, 86, 109, 206, 241, 183, 79]) - ), - 0 - ) - ) { - return SvmSpokeAccount.TransferLiability; - } - throw new Error( - 'The provided account could not be identified as a svmSpoke account.' - ); -} - -export enum SvmSpokeInstruction { - BridgeTokensToHubPool, - ClaimRelayerRefund, - CloseClaimAccount, - CloseFillPda, - CloseInstructionParams, - CreateTokenAccounts, - Deposit, - DepositNow, - EmergencyDeleteRootBundle, - ExecuteRelayerRefundLeaf, - ExecuteRelayerRefundLeafDeferred, - ExecuteSlowRelayLeaf, - FillRelay, - GetUnsafeDepositId, - HandleReceiveMessage, - Initialize, - InitializeClaimAccount, - InitializeInstructionParams, - PauseDeposits, - PauseFills, - RelayRootBundle, - RequestSlowFill, - SetCrossDomainAdmin, - SetCurrentTime, - TransferOwnership, - UnsafeDeposit, - WriteInstructionParamsFragment, -} - -export function identifySvmSpokeInstruction( - instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): SvmSpokeInstruction { - const data = 'data' in instruction ? instruction.data : instruction; - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([1, 83, 255, 59, 232, 55, 64, 216]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.BridgeTokensToHubPool; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([205, 34, 34, 224, 204, 103, 81, 176]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.ClaimRelayerRefund; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([241, 146, 203, 216, 58, 222, 91, 118]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.CloseClaimAccount; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([224, 39, 208, 68, 8, 226, 23, 214]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.CloseFillPda; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([224, 44, 254, 10, 216, 8, 172, 96]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.CloseInstructionParams; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([163, 216, 49, 204, 97, 16, 80, 167]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.CreateTokenAccounts; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([242, 35, 198, 137, 82, 225, 242, 182]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.Deposit; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([75, 228, 135, 221, 200, 25, 148, 26]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.DepositNow; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([226, 158, 1, 74, 84, 113, 24, 152]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.EmergencyDeleteRootBundle; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([27, 136, 159, 240, 127, 68, 123, 164]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.ExecuteRelayerRefundLeaf; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([110, 112, 89, 208, 38, 116, 93, 10]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.ExecuteRelayerRefundLeafDeferred; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([26, 207, 3, 168, 193, 252, 59, 127]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.ExecuteSlowRelayLeaf; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([100, 84, 222, 90, 106, 209, 58, 222]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.FillRelay; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([118, 10, 135, 0, 168, 243, 223, 117]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.GetUnsafeDepositId; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([133, 102, 1, 180, 145, 11, 138, 180]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.HandleReceiveMessage; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.Initialize; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([22, 247, 214, 191, 90, 74, 87, 216]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.InitializeClaimAccount; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([94, 206, 190, 192, 127, 8, 186, 28]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.InitializeInstructionParams; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([206, 186, 203, 153, 253, 61, 206, 122]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.PauseDeposits; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([92, 114, 214, 49, 13, 243, 73, 35]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.PauseFills; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([69, 13, 223, 204, 251, 61, 105, 6]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.RelayRootBundle; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([39, 157, 165, 187, 88, 217, 207, 98]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.RequestSlowFill; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([102, 206, 237, 106, 63, 141, 42, 248]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.SetCrossDomainAdmin; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([69, 100, 169, 193, 125, 0, 150, 69]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.SetCurrentTime; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.TransferOwnership; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([196, 187, 166, 179, 3, 146, 150, 246]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.UnsafeDeposit; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([238, 182, 109, 113, 124, 255, 72, 18]) - ), - 0 - ) - ) { - return SvmSpokeInstruction.WriteInstructionParamsFragment; - } - throw new Error( - 'The provided instruction could not be identified as a svmSpoke instruction.' - ); -} - -export type ParsedSvmSpokeInstruction< - TProgram extends string = 'DLv3NggMiSaef97YCkew5xKUHDh13tVGZ7tydt3ZeAru', -> = - | ({ - instructionType: SvmSpokeInstruction.BridgeTokensToHubPool; - } & ParsedBridgeTokensToHubPoolInstruction) - | ({ - instructionType: SvmSpokeInstruction.ClaimRelayerRefund; - } & ParsedClaimRelayerRefundInstruction) - | ({ - instructionType: SvmSpokeInstruction.CloseClaimAccount; - } & ParsedCloseClaimAccountInstruction) - | ({ - instructionType: SvmSpokeInstruction.CloseFillPda; - } & ParsedCloseFillPdaInstruction) - | ({ - instructionType: SvmSpokeInstruction.CloseInstructionParams; - } & ParsedCloseInstructionParamsInstruction) - | ({ - instructionType: SvmSpokeInstruction.CreateTokenAccounts; - } & ParsedCreateTokenAccountsInstruction) - | ({ - instructionType: SvmSpokeInstruction.Deposit; - } & ParsedDepositInstruction) - | ({ - instructionType: SvmSpokeInstruction.DepositNow; - } & ParsedDepositNowInstruction) - | ({ - instructionType: SvmSpokeInstruction.EmergencyDeleteRootBundle; - } & ParsedEmergencyDeleteRootBundleInstruction) - | ({ - instructionType: SvmSpokeInstruction.ExecuteRelayerRefundLeaf; - } & ParsedExecuteRelayerRefundLeafInstruction) - | ({ - instructionType: SvmSpokeInstruction.ExecuteRelayerRefundLeafDeferred; - } & ParsedExecuteRelayerRefundLeafDeferredInstruction) - | ({ - instructionType: SvmSpokeInstruction.ExecuteSlowRelayLeaf; - } & ParsedExecuteSlowRelayLeafInstruction) - | ({ - instructionType: SvmSpokeInstruction.FillRelay; - } & ParsedFillRelayInstruction) - | ({ - instructionType: SvmSpokeInstruction.GetUnsafeDepositId; - } & ParsedGetUnsafeDepositIdInstruction) - | ({ - instructionType: SvmSpokeInstruction.HandleReceiveMessage; - } & ParsedHandleReceiveMessageInstruction) - | ({ - instructionType: SvmSpokeInstruction.Initialize; - } & ParsedInitializeInstruction) - | ({ - instructionType: SvmSpokeInstruction.InitializeClaimAccount; - } & ParsedInitializeClaimAccountInstruction) - | ({ - instructionType: SvmSpokeInstruction.InitializeInstructionParams; - } & ParsedInitializeInstructionParamsInstruction) - | ({ - instructionType: SvmSpokeInstruction.PauseDeposits; - } & ParsedPauseDepositsInstruction) - | ({ - instructionType: SvmSpokeInstruction.PauseFills; - } & ParsedPauseFillsInstruction) - | ({ - instructionType: SvmSpokeInstruction.RelayRootBundle; - } & ParsedRelayRootBundleInstruction) - | ({ - instructionType: SvmSpokeInstruction.RequestSlowFill; - } & ParsedRequestSlowFillInstruction) - | ({ - instructionType: SvmSpokeInstruction.SetCrossDomainAdmin; - } & ParsedSetCrossDomainAdminInstruction) - | ({ - instructionType: SvmSpokeInstruction.SetCurrentTime; - } & ParsedSetCurrentTimeInstruction) - | ({ - instructionType: SvmSpokeInstruction.TransferOwnership; - } & ParsedTransferOwnershipInstruction) - | ({ - instructionType: SvmSpokeInstruction.UnsafeDeposit; - } & ParsedUnsafeDepositInstruction) - | ({ - instructionType: SvmSpokeInstruction.WriteInstructionParamsFragment; - } & ParsedWriteInstructionParamsFragmentInstruction); diff --git a/src/svm/clients/SvmSpoke/shared/index.ts b/src/svm/clients/SvmSpoke/shared/index.ts deleted file mode 100644 index 7ebc26514..000000000 --- a/src/svm/clients/SvmSpoke/shared/index.ts +++ /dev/null @@ -1,164 +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 { - AccountRole, - isProgramDerivedAddress, - isTransactionSigner as kitIsTransactionSigner, - type AccountMeta, - type AccountSignerMeta, - type Address, - type ProgramDerivedAddress, - type TransactionSigner, - upgradeRoleToSigner, -} from '@solana/kit'; - -/** - * Asserts that the given value is not null or undefined. - * @internal - */ -export function expectSome(value: T | null | undefined): T { - if (value == null) { - throw new Error('Expected a value but received null or undefined.'); - } - return value; -} - -/** - * Asserts that the given value is a PublicKey. - * @internal - */ -export function expectAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): Address { - if (!value) { - throw new Error('Expected a Address.'); - } - if (typeof value === 'object' && 'address' in value) { - return value.address; - } - if (Array.isArray(value)) { - return value[0]; - } - return value as Address; -} - -/** - * Asserts that the given value is a PDA. - * @internal - */ -export function expectProgramDerivedAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): ProgramDerivedAddress { - if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { - throw new Error('Expected a ProgramDerivedAddress.'); - } - return value; -} - -/** - * Asserts that the given value is a TransactionSigner. - * @internal - */ -export function expectTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): TransactionSigner { - if (!value || !isTransactionSigner(value)) { - throw new Error('Expected a TransactionSigner.'); - } - return value; -} - -/** - * Defines an instruction account to resolve. - * @internal - */ -export type ResolvedAccount< - T extends string = string, - U extends - | Address - | ProgramDerivedAddress - | TransactionSigner - | null = - | Address - | ProgramDerivedAddress - | TransactionSigner - | null, -> = { - isWritable: boolean; - value: U; -}; - -/** - * Defines an instruction that stores additional bytes on-chain. - * @internal - */ -export type InstructionWithByteDelta = { - byteDelta: number; -}; - -/** - * Get account metas and signers from resolved accounts. - * @internal - */ -export function getAccountMetaFactory( - programAddress: Address, - optionalAccountStrategy: 'omitted' | 'programId' -) { - return ( - account: ResolvedAccount - ): AccountMeta | AccountSignerMeta | undefined => { - if (!account.value) { - if (optionalAccountStrategy === 'omitted') return; - return Object.freeze({ - address: programAddress, - role: AccountRole.READONLY, - }); - } - - const writableRole = account.isWritable - ? AccountRole.WRITABLE - : AccountRole.READONLY; - return Object.freeze({ - address: expectAddress(account.value), - role: isTransactionSigner(account.value) - ? upgradeRoleToSigner(writableRole) - : writableRole, - ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), - }); - }; -} - -export function isTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner -): value is TransactionSigner { - return ( - !!value && - typeof value === 'object' && - 'address' in value && - kitIsTransactionSigner(value) - ); -} diff --git a/src/svm/clients/SvmSpoke/types/bridgedToHubPool.ts b/src/svm/clients/SvmSpoke/types/bridgedToHubPool.ts deleted file mode 100644 index 177836e64..000000000 --- a/src/svm/clients/SvmSpoke/types/bridgedToHubPool.ts +++ /dev/null @@ -1,49 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type BridgedToHubPool = { amount: bigint; mint: Address }; - -export type BridgedToHubPoolArgs = { amount: number | bigint; mint: Address }; - -export function getBridgedToHubPoolEncoder(): Encoder { - return getStructEncoder([ - ['amount', getU64Encoder()], - ['mint', getAddressEncoder()], - ]); -} - -export function getBridgedToHubPoolDecoder(): Decoder { - return getStructDecoder([ - ['amount', getU64Decoder()], - ['mint', getAddressDecoder()], - ]); -} - -export function getBridgedToHubPoolCodec(): Codec< - BridgedToHubPoolArgs, - BridgedToHubPool -> { - return combineCodec( - getBridgedToHubPoolEncoder(), - getBridgedToHubPoolDecoder() - ); -} diff --git a/src/svm/clients/SvmSpoke/types/claimedRelayerRefund.ts b/src/svm/clients/SvmSpoke/types/claimedRelayerRefund.ts deleted file mode 100644 index 72e1aa5e9..000000000 --- a/src/svm/clients/SvmSpoke/types/claimedRelayerRefund.ts +++ /dev/null @@ -1,59 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type ClaimedRelayerRefund = { - l2TokenAddress: Address; - claimAmount: bigint; - refundAddress: Address; -}; - -export type ClaimedRelayerRefundArgs = { - l2TokenAddress: Address; - claimAmount: number | bigint; - refundAddress: Address; -}; - -export function getClaimedRelayerRefundEncoder(): Encoder { - return getStructEncoder([ - ['l2TokenAddress', getAddressEncoder()], - ['claimAmount', getU64Encoder()], - ['refundAddress', getAddressEncoder()], - ]); -} - -export function getClaimedRelayerRefundDecoder(): Decoder { - return getStructDecoder([ - ['l2TokenAddress', getAddressDecoder()], - ['claimAmount', getU64Decoder()], - ['refundAddress', getAddressDecoder()], - ]); -} - -export function getClaimedRelayerRefundCodec(): Codec< - ClaimedRelayerRefundArgs, - ClaimedRelayerRefund -> { - return combineCodec( - getClaimedRelayerRefundEncoder(), - getClaimedRelayerRefundDecoder() - ); -} diff --git a/src/svm/clients/SvmSpoke/types/emergencyDeletedRootBundle.ts b/src/svm/clients/SvmSpoke/types/emergencyDeletedRootBundle.ts deleted file mode 100644 index 69272980b..000000000 --- a/src/svm/clients/SvmSpoke/types/emergencyDeletedRootBundle.ts +++ /dev/null @@ -1,40 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type EmergencyDeletedRootBundle = { rootBundleId: number }; - -export type EmergencyDeletedRootBundleArgs = EmergencyDeletedRootBundle; - -export function getEmergencyDeletedRootBundleEncoder(): Encoder { - return getStructEncoder([['rootBundleId', getU32Encoder()]]); -} - -export function getEmergencyDeletedRootBundleDecoder(): Decoder { - return getStructDecoder([['rootBundleId', getU32Decoder()]]); -} - -export function getEmergencyDeletedRootBundleCodec(): Codec< - EmergencyDeletedRootBundleArgs, - EmergencyDeletedRootBundle -> { - return combineCodec( - getEmergencyDeletedRootBundleEncoder(), - getEmergencyDeletedRootBundleDecoder() - ); -} diff --git a/src/svm/clients/SvmSpoke/types/executedRelayerRefundRoot.ts b/src/svm/clients/SvmSpoke/types/executedRelayerRefundRoot.ts deleted file mode 100644 index d6b724d94..000000000 --- a/src/svm/clients/SvmSpoke/types/executedRelayerRefundRoot.ts +++ /dev/null @@ -1,89 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getArrayDecoder, - getArrayEncoder, - getBooleanDecoder, - getBooleanEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type ExecutedRelayerRefundRoot = { - amountToReturn: bigint; - chainId: bigint; - refundAmounts: Array; - rootBundleId: number; - leafId: number; - l2TokenAddress: Address; - refundAddresses: Array
; - deferredRefunds: boolean; - caller: Address; -}; - -export type ExecutedRelayerRefundRootArgs = { - amountToReturn: number | bigint; - chainId: number | bigint; - refundAmounts: Array; - rootBundleId: number; - leafId: number; - l2TokenAddress: Address; - refundAddresses: Array
; - deferredRefunds: boolean; - caller: Address; -}; - -export function getExecutedRelayerRefundRootEncoder(): Encoder { - return getStructEncoder([ - ['amountToReturn', getU64Encoder()], - ['chainId', getU64Encoder()], - ['refundAmounts', getArrayEncoder(getU64Encoder())], - ['rootBundleId', getU32Encoder()], - ['leafId', getU32Encoder()], - ['l2TokenAddress', getAddressEncoder()], - ['refundAddresses', getArrayEncoder(getAddressEncoder())], - ['deferredRefunds', getBooleanEncoder()], - ['caller', getAddressEncoder()], - ]); -} - -export function getExecutedRelayerRefundRootDecoder(): Decoder { - return getStructDecoder([ - ['amountToReturn', getU64Decoder()], - ['chainId', getU64Decoder()], - ['refundAmounts', getArrayDecoder(getU64Decoder())], - ['rootBundleId', getU32Decoder()], - ['leafId', getU32Decoder()], - ['l2TokenAddress', getAddressDecoder()], - ['refundAddresses', getArrayDecoder(getAddressDecoder())], - ['deferredRefunds', getBooleanDecoder()], - ['caller', getAddressDecoder()], - ]); -} - -export function getExecutedRelayerRefundRootCodec(): Codec< - ExecutedRelayerRefundRootArgs, - ExecutedRelayerRefundRoot -> { - return combineCodec( - getExecutedRelayerRefundRootEncoder(), - getExecutedRelayerRefundRootDecoder() - ); -} diff --git a/src/svm/clients/SvmSpoke/types/fillStatus.ts b/src/svm/clients/SvmSpoke/types/fillStatus.ts deleted file mode 100644 index 578f49860..000000000 --- a/src/svm/clients/SvmSpoke/types/fillStatus.ts +++ /dev/null @@ -1,36 +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 { - combineCodec, - getEnumDecoder, - getEnumEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export enum FillStatus { - Unfilled, - RequestedSlowFill, - Filled, -} - -export type FillStatusArgs = FillStatus; - -export function getFillStatusEncoder(): Encoder { - return getEnumEncoder(FillStatus); -} - -export function getFillStatusDecoder(): Decoder { - return getEnumDecoder(FillStatus); -} - -export function getFillStatusCodec(): Codec { - return combineCodec(getFillStatusEncoder(), getFillStatusDecoder()); -} diff --git a/src/svm/clients/SvmSpoke/types/fillType.ts b/src/svm/clients/SvmSpoke/types/fillType.ts deleted file mode 100644 index 2ec225b26..000000000 --- a/src/svm/clients/SvmSpoke/types/fillType.ts +++ /dev/null @@ -1,36 +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 { - combineCodec, - getEnumDecoder, - getEnumEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export enum FillType { - FastFill, - ReplacedSlowFill, - SlowFill, -} - -export type FillTypeArgs = FillType; - -export function getFillTypeEncoder(): Encoder { - return getEnumEncoder(FillType); -} - -export function getFillTypeDecoder(): Decoder { - return getEnumDecoder(FillType); -} - -export function getFillTypeCodec(): Codec { - return combineCodec(getFillTypeEncoder(), getFillTypeDecoder()); -} diff --git a/src/svm/clients/SvmSpoke/types/filledRelay.ts b/src/svm/clients/SvmSpoke/types/filledRelay.ts deleted file mode 100644 index 5facf1648..000000000 --- a/src/svm/clients/SvmSpoke/types/filledRelay.ts +++ /dev/null @@ -1,114 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { - getRelayExecutionEventInfoDecoder, - getRelayExecutionEventInfoEncoder, - type RelayExecutionEventInfo, - type RelayExecutionEventInfoArgs, -} from '.'; - -export type FilledRelay = { - inputToken: Address; - outputToken: Address; - inputAmount: ReadonlyUint8Array; - outputAmount: bigint; - repaymentChainId: bigint; - originChainId: bigint; - depositId: ReadonlyUint8Array; - fillDeadline: number; - exclusivityDeadline: number; - exclusiveRelayer: Address; - relayer: Address; - depositor: Address; - recipient: Address; - messageHash: ReadonlyUint8Array; - relayExecutionInfo: RelayExecutionEventInfo; -}; - -export type FilledRelayArgs = { - inputToken: Address; - outputToken: Address; - inputAmount: ReadonlyUint8Array; - outputAmount: number | bigint; - repaymentChainId: number | bigint; - originChainId: number | bigint; - depositId: ReadonlyUint8Array; - fillDeadline: number; - exclusivityDeadline: number; - exclusiveRelayer: Address; - relayer: Address; - depositor: Address; - recipient: Address; - messageHash: ReadonlyUint8Array; - relayExecutionInfo: RelayExecutionEventInfoArgs; -}; - -export function getFilledRelayEncoder(): Encoder { - return getStructEncoder([ - ['inputToken', getAddressEncoder()], - ['outputToken', getAddressEncoder()], - ['inputAmount', fixEncoderSize(getBytesEncoder(), 32)], - ['outputAmount', getU64Encoder()], - ['repaymentChainId', getU64Encoder()], - ['originChainId', getU64Encoder()], - ['depositId', fixEncoderSize(getBytesEncoder(), 32)], - ['fillDeadline', getU32Encoder()], - ['exclusivityDeadline', getU32Encoder()], - ['exclusiveRelayer', getAddressEncoder()], - ['relayer', getAddressEncoder()], - ['depositor', getAddressEncoder()], - ['recipient', getAddressEncoder()], - ['messageHash', fixEncoderSize(getBytesEncoder(), 32)], - ['relayExecutionInfo', getRelayExecutionEventInfoEncoder()], - ]); -} - -export function getFilledRelayDecoder(): Decoder { - return getStructDecoder([ - ['inputToken', getAddressDecoder()], - ['outputToken', getAddressDecoder()], - ['inputAmount', fixDecoderSize(getBytesDecoder(), 32)], - ['outputAmount', getU64Decoder()], - ['repaymentChainId', getU64Decoder()], - ['originChainId', getU64Decoder()], - ['depositId', fixDecoderSize(getBytesDecoder(), 32)], - ['fillDeadline', getU32Decoder()], - ['exclusivityDeadline', getU32Decoder()], - ['exclusiveRelayer', getAddressDecoder()], - ['relayer', getAddressDecoder()], - ['depositor', getAddressDecoder()], - ['recipient', getAddressDecoder()], - ['messageHash', fixDecoderSize(getBytesDecoder(), 32)], - ['relayExecutionInfo', getRelayExecutionEventInfoDecoder()], - ]); -} - -export function getFilledRelayCodec(): Codec { - return combineCodec(getFilledRelayEncoder(), getFilledRelayDecoder()); -} diff --git a/src/svm/clients/SvmSpoke/types/fundsDeposited.ts b/src/svm/clients/SvmSpoke/types/fundsDeposited.ts deleted file mode 100644 index 8ff28c60e..000000000 --- a/src/svm/clients/SvmSpoke/types/fundsDeposited.ts +++ /dev/null @@ -1,105 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export type FundsDeposited = { - inputToken: Address; - outputToken: Address; - inputAmount: bigint; - outputAmount: ReadonlyUint8Array; - destinationChainId: bigint; - depositId: ReadonlyUint8Array; - quoteTimestamp: number; - fillDeadline: number; - exclusivityDeadline: number; - depositor: Address; - recipient: Address; - exclusiveRelayer: Address; - message: ReadonlyUint8Array; -}; - -export type FundsDepositedArgs = { - inputToken: Address; - outputToken: Address; - inputAmount: number | bigint; - outputAmount: ReadonlyUint8Array; - destinationChainId: number | bigint; - depositId: ReadonlyUint8Array; - quoteTimestamp: number; - fillDeadline: number; - exclusivityDeadline: number; - depositor: Address; - recipient: Address; - exclusiveRelayer: Address; - message: ReadonlyUint8Array; -}; - -export function getFundsDepositedEncoder(): Encoder { - return getStructEncoder([ - ['inputToken', getAddressEncoder()], - ['outputToken', getAddressEncoder()], - ['inputAmount', getU64Encoder()], - ['outputAmount', fixEncoderSize(getBytesEncoder(), 32)], - ['destinationChainId', getU64Encoder()], - ['depositId', fixEncoderSize(getBytesEncoder(), 32)], - ['quoteTimestamp', getU32Encoder()], - ['fillDeadline', getU32Encoder()], - ['exclusivityDeadline', getU32Encoder()], - ['depositor', getAddressEncoder()], - ['recipient', getAddressEncoder()], - ['exclusiveRelayer', getAddressEncoder()], - ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]); -} - -export function getFundsDepositedDecoder(): Decoder { - return getStructDecoder([ - ['inputToken', getAddressDecoder()], - ['outputToken', getAddressDecoder()], - ['inputAmount', getU64Decoder()], - ['outputAmount', fixDecoderSize(getBytesDecoder(), 32)], - ['destinationChainId', getU64Decoder()], - ['depositId', fixDecoderSize(getBytesDecoder(), 32)], - ['quoteTimestamp', getU32Decoder()], - ['fillDeadline', getU32Decoder()], - ['exclusivityDeadline', getU32Decoder()], - ['depositor', getAddressDecoder()], - ['recipient', getAddressDecoder()], - ['exclusiveRelayer', getAddressDecoder()], - ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getFundsDepositedCodec(): Codec< - FundsDepositedArgs, - FundsDeposited -> { - return combineCodec(getFundsDepositedEncoder(), getFundsDepositedDecoder()); -} diff --git a/src/svm/clients/SvmSpoke/types/index.ts b/src/svm/clients/SvmSpoke/types/index.ts deleted file mode 100644 index 33b8494ce..000000000 --- a/src/svm/clients/SvmSpoke/types/index.ts +++ /dev/null @@ -1,27 +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 - */ - -export * from './bridgedToHubPool'; -export * from './claimedRelayerRefund'; -export * from './emergencyDeletedRootBundle'; -export * from './executedRelayerRefundRoot'; -export * from './filledRelay'; -export * from './fillStatus'; -export * from './fillType'; -export * from './fundsDeposited'; -export * from './pausedDeposits'; -export * from './pausedFills'; -export * from './relayData'; -export * from './relayedRootBundle'; -export * from './relayerRefundLeaf'; -export * from './relayExecutionEventInfo'; -export * from './requestedSlowFill'; -export * from './setXDomainAdmin'; -export * from './slowFill'; -export * from './tokensBridged'; -export * from './transferredOwnership'; diff --git a/src/svm/clients/SvmSpoke/types/pausedDeposits.ts b/src/svm/clients/SvmSpoke/types/pausedDeposits.ts deleted file mode 100644 index 94ad8d991..000000000 --- a/src/svm/clients/SvmSpoke/types/pausedDeposits.ts +++ /dev/null @@ -1,37 +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 { - combineCodec, - getBooleanDecoder, - getBooleanEncoder, - getStructDecoder, - getStructEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type PausedDeposits = { isPaused: boolean }; - -export type PausedDepositsArgs = PausedDeposits; - -export function getPausedDepositsEncoder(): Encoder { - return getStructEncoder([['isPaused', getBooleanEncoder()]]); -} - -export function getPausedDepositsDecoder(): Decoder { - return getStructDecoder([['isPaused', getBooleanDecoder()]]); -} - -export function getPausedDepositsCodec(): Codec< - PausedDepositsArgs, - PausedDeposits -> { - return combineCodec(getPausedDepositsEncoder(), getPausedDepositsDecoder()); -} diff --git a/src/svm/clients/SvmSpoke/types/pausedFills.ts b/src/svm/clients/SvmSpoke/types/pausedFills.ts deleted file mode 100644 index 2bf8a0cea..000000000 --- a/src/svm/clients/SvmSpoke/types/pausedFills.ts +++ /dev/null @@ -1,34 +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 { - combineCodec, - getBooleanDecoder, - getBooleanEncoder, - getStructDecoder, - getStructEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type PausedFills = { isPaused: boolean }; - -export type PausedFillsArgs = PausedFills; - -export function getPausedFillsEncoder(): Encoder { - return getStructEncoder([['isPaused', getBooleanEncoder()]]); -} - -export function getPausedFillsDecoder(): Decoder { - return getStructDecoder([['isPaused', getBooleanDecoder()]]); -} - -export function getPausedFillsCodec(): Codec { - return combineCodec(getPausedFillsEncoder(), getPausedFillsDecoder()); -} diff --git a/src/svm/clients/SvmSpoke/types/relayData.ts b/src/svm/clients/SvmSpoke/types/relayData.ts deleted file mode 100644 index 7104dd7d8..000000000 --- a/src/svm/clients/SvmSpoke/types/relayData.ts +++ /dev/null @@ -1,98 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export type RelayData = { - depositor: Address; - recipient: Address; - exclusiveRelayer: Address; - inputToken: Address; - outputToken: Address; - inputAmount: ReadonlyUint8Array; - outputAmount: bigint; - originChainId: bigint; - depositId: ReadonlyUint8Array; - fillDeadline: number; - exclusivityDeadline: number; - message: ReadonlyUint8Array; -}; - -export type RelayDataArgs = { - depositor: Address; - recipient: Address; - exclusiveRelayer: Address; - inputToken: Address; - outputToken: Address; - inputAmount: ReadonlyUint8Array; - outputAmount: number | bigint; - originChainId: number | bigint; - depositId: ReadonlyUint8Array; - fillDeadline: number; - exclusivityDeadline: number; - message: ReadonlyUint8Array; -}; - -export function getRelayDataEncoder(): Encoder { - return getStructEncoder([ - ['depositor', getAddressEncoder()], - ['recipient', getAddressEncoder()], - ['exclusiveRelayer', getAddressEncoder()], - ['inputToken', getAddressEncoder()], - ['outputToken', getAddressEncoder()], - ['inputAmount', fixEncoderSize(getBytesEncoder(), 32)], - ['outputAmount', getU64Encoder()], - ['originChainId', getU64Encoder()], - ['depositId', fixEncoderSize(getBytesEncoder(), 32)], - ['fillDeadline', getU32Encoder()], - ['exclusivityDeadline', getU32Encoder()], - ['message', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]); -} - -export function getRelayDataDecoder(): Decoder { - return getStructDecoder([ - ['depositor', getAddressDecoder()], - ['recipient', getAddressDecoder()], - ['exclusiveRelayer', getAddressDecoder()], - ['inputToken', getAddressDecoder()], - ['outputToken', getAddressDecoder()], - ['inputAmount', fixDecoderSize(getBytesDecoder(), 32)], - ['outputAmount', getU64Decoder()], - ['originChainId', getU64Decoder()], - ['depositId', fixDecoderSize(getBytesDecoder(), 32)], - ['fillDeadline', getU32Decoder()], - ['exclusivityDeadline', getU32Decoder()], - ['message', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getRelayDataCodec(): Codec { - return combineCodec(getRelayDataEncoder(), getRelayDataDecoder()); -} diff --git a/src/svm/clients/SvmSpoke/types/relayExecutionEventInfo.ts b/src/svm/clients/SvmSpoke/types/relayExecutionEventInfo.ts deleted file mode 100644 index 3ead0d0aa..000000000 --- a/src/svm/clients/SvmSpoke/types/relayExecutionEventInfo.ts +++ /dev/null @@ -1,74 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; -import { - getFillTypeDecoder, - getFillTypeEncoder, - type FillType, - type FillTypeArgs, -} from '.'; - -export type RelayExecutionEventInfo = { - updatedRecipient: Address; - updatedMessageHash: ReadonlyUint8Array; - updatedOutputAmount: bigint; - fillType: FillType; -}; - -export type RelayExecutionEventInfoArgs = { - updatedRecipient: Address; - updatedMessageHash: ReadonlyUint8Array; - updatedOutputAmount: number | bigint; - fillType: FillTypeArgs; -}; - -export function getRelayExecutionEventInfoEncoder(): Encoder { - return getStructEncoder([ - ['updatedRecipient', getAddressEncoder()], - ['updatedMessageHash', fixEncoderSize(getBytesEncoder(), 32)], - ['updatedOutputAmount', getU64Encoder()], - ['fillType', getFillTypeEncoder()], - ]); -} - -export function getRelayExecutionEventInfoDecoder(): Decoder { - return getStructDecoder([ - ['updatedRecipient', getAddressDecoder()], - ['updatedMessageHash', fixDecoderSize(getBytesDecoder(), 32)], - ['updatedOutputAmount', getU64Decoder()], - ['fillType', getFillTypeDecoder()], - ]); -} - -export function getRelayExecutionEventInfoCodec(): Codec< - RelayExecutionEventInfoArgs, - RelayExecutionEventInfo -> { - return combineCodec( - getRelayExecutionEventInfoEncoder(), - getRelayExecutionEventInfoDecoder() - ); -} diff --git a/src/svm/clients/SvmSpoke/types/relayedRootBundle.ts b/src/svm/clients/SvmSpoke/types/relayedRootBundle.ts deleted file mode 100644 index 141ddb839..000000000 --- a/src/svm/clients/SvmSpoke/types/relayedRootBundle.ts +++ /dev/null @@ -1,57 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export type RelayedRootBundle = { - rootBundleId: number; - relayerRefundRoot: ReadonlyUint8Array; - slowRelayRoot: ReadonlyUint8Array; -}; - -export type RelayedRootBundleArgs = RelayedRootBundle; - -export function getRelayedRootBundleEncoder(): Encoder { - return getStructEncoder([ - ['rootBundleId', getU32Encoder()], - ['relayerRefundRoot', fixEncoderSize(getBytesEncoder(), 32)], - ['slowRelayRoot', fixEncoderSize(getBytesEncoder(), 32)], - ]); -} - -export function getRelayedRootBundleDecoder(): Decoder { - return getStructDecoder([ - ['rootBundleId', getU32Decoder()], - ['relayerRefundRoot', fixDecoderSize(getBytesDecoder(), 32)], - ['slowRelayRoot', fixDecoderSize(getBytesDecoder(), 32)], - ]); -} - -export function getRelayedRootBundleCodec(): Codec< - RelayedRootBundleArgs, - RelayedRootBundle -> { - return combineCodec( - getRelayedRootBundleEncoder(), - getRelayedRootBundleDecoder() - ); -} diff --git a/src/svm/clients/SvmSpoke/types/relayerRefundLeaf.ts b/src/svm/clients/SvmSpoke/types/relayerRefundLeaf.ts deleted file mode 100644 index 0683ad393..000000000 --- a/src/svm/clients/SvmSpoke/types/relayerRefundLeaf.ts +++ /dev/null @@ -1,75 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getArrayDecoder, - getArrayEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type RelayerRefundLeaf = { - amountToReturn: bigint; - chainId: bigint; - refundAmounts: Array; - leafId: number; - mintPublicKey: Address; - refundAddresses: Array
; -}; - -export type RelayerRefundLeafArgs = { - amountToReturn: number | bigint; - chainId: number | bigint; - refundAmounts: Array; - leafId: number; - mintPublicKey: Address; - refundAddresses: Array
; -}; - -export function getRelayerRefundLeafEncoder(): Encoder { - return getStructEncoder([ - ['amountToReturn', getU64Encoder()], - ['chainId', getU64Encoder()], - ['refundAmounts', getArrayEncoder(getU64Encoder())], - ['leafId', getU32Encoder()], - ['mintPublicKey', getAddressEncoder()], - ['refundAddresses', getArrayEncoder(getAddressEncoder())], - ]); -} - -export function getRelayerRefundLeafDecoder(): Decoder { - return getStructDecoder([ - ['amountToReturn', getU64Decoder()], - ['chainId', getU64Decoder()], - ['refundAmounts', getArrayDecoder(getU64Decoder())], - ['leafId', getU32Decoder()], - ['mintPublicKey', getAddressDecoder()], - ['refundAddresses', getArrayDecoder(getAddressDecoder())], - ]); -} - -export function getRelayerRefundLeafCodec(): Codec< - RelayerRefundLeafArgs, - RelayerRefundLeaf -> { - return combineCodec( - getRelayerRefundLeafEncoder(), - getRelayerRefundLeafDecoder() - ); -} diff --git a/src/svm/clients/SvmSpoke/types/requestedSlowFill.ts b/src/svm/clients/SvmSpoke/types/requestedSlowFill.ts deleted file mode 100644 index af02787ae..000000000 --- a/src/svm/clients/SvmSpoke/types/requestedSlowFill.ts +++ /dev/null @@ -1,102 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export type RequestedSlowFill = { - inputToken: Address; - outputToken: Address; - inputAmount: ReadonlyUint8Array; - outputAmount: bigint; - originChainId: bigint; - depositId: ReadonlyUint8Array; - fillDeadline: number; - exclusivityDeadline: number; - exclusiveRelayer: Address; - depositor: Address; - recipient: Address; - messageHash: ReadonlyUint8Array; -}; - -export type RequestedSlowFillArgs = { - inputToken: Address; - outputToken: Address; - inputAmount: ReadonlyUint8Array; - outputAmount: number | bigint; - originChainId: number | bigint; - depositId: ReadonlyUint8Array; - fillDeadline: number; - exclusivityDeadline: number; - exclusiveRelayer: Address; - depositor: Address; - recipient: Address; - messageHash: ReadonlyUint8Array; -}; - -export function getRequestedSlowFillEncoder(): Encoder { - return getStructEncoder([ - ['inputToken', getAddressEncoder()], - ['outputToken', getAddressEncoder()], - ['inputAmount', fixEncoderSize(getBytesEncoder(), 32)], - ['outputAmount', getU64Encoder()], - ['originChainId', getU64Encoder()], - ['depositId', fixEncoderSize(getBytesEncoder(), 32)], - ['fillDeadline', getU32Encoder()], - ['exclusivityDeadline', getU32Encoder()], - ['exclusiveRelayer', getAddressEncoder()], - ['depositor', getAddressEncoder()], - ['recipient', getAddressEncoder()], - ['messageHash', fixEncoderSize(getBytesEncoder(), 32)], - ]); -} - -export function getRequestedSlowFillDecoder(): Decoder { - return getStructDecoder([ - ['inputToken', getAddressDecoder()], - ['outputToken', getAddressDecoder()], - ['inputAmount', fixDecoderSize(getBytesDecoder(), 32)], - ['outputAmount', getU64Decoder()], - ['originChainId', getU64Decoder()], - ['depositId', fixDecoderSize(getBytesDecoder(), 32)], - ['fillDeadline', getU32Decoder()], - ['exclusivityDeadline', getU32Decoder()], - ['exclusiveRelayer', getAddressDecoder()], - ['depositor', getAddressDecoder()], - ['recipient', getAddressDecoder()], - ['messageHash', fixDecoderSize(getBytesDecoder(), 32)], - ]); -} - -export function getRequestedSlowFillCodec(): Codec< - RequestedSlowFillArgs, - RequestedSlowFill -> { - return combineCodec( - getRequestedSlowFillEncoder(), - getRequestedSlowFillDecoder() - ); -} diff --git a/src/svm/clients/SvmSpoke/types/setXDomainAdmin.ts b/src/svm/clients/SvmSpoke/types/setXDomainAdmin.ts deleted file mode 100644 index ee06f669f..000000000 --- a/src/svm/clients/SvmSpoke/types/setXDomainAdmin.ts +++ /dev/null @@ -1,38 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type SetXDomainAdmin = { newAdmin: Address }; - -export type SetXDomainAdminArgs = SetXDomainAdmin; - -export function getSetXDomainAdminEncoder(): Encoder { - return getStructEncoder([['newAdmin', getAddressEncoder()]]); -} - -export function getSetXDomainAdminDecoder(): Decoder { - return getStructDecoder([['newAdmin', getAddressDecoder()]]); -} - -export function getSetXDomainAdminCodec(): Codec< - SetXDomainAdminArgs, - SetXDomainAdmin -> { - return combineCodec(getSetXDomainAdminEncoder(), getSetXDomainAdminDecoder()); -} diff --git a/src/svm/clients/SvmSpoke/types/slowFill.ts b/src/svm/clients/SvmSpoke/types/slowFill.ts deleted file mode 100644 index 14de5e442..000000000 --- a/src/svm/clients/SvmSpoke/types/slowFill.ts +++ /dev/null @@ -1,56 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; -import { - getRelayDataDecoder, - getRelayDataEncoder, - type RelayData, - type RelayDataArgs, -} from '.'; - -export type SlowFill = { - relayData: RelayData; - chainId: bigint; - updatedOutputAmount: bigint; -}; - -export type SlowFillArgs = { - relayData: RelayDataArgs; - chainId: number | bigint; - updatedOutputAmount: number | bigint; -}; - -export function getSlowFillEncoder(): Encoder { - return getStructEncoder([ - ['relayData', getRelayDataEncoder()], - ['chainId', getU64Encoder()], - ['updatedOutputAmount', getU64Encoder()], - ]); -} - -export function getSlowFillDecoder(): Decoder { - return getStructDecoder([ - ['relayData', getRelayDataDecoder()], - ['chainId', getU64Decoder()], - ['updatedOutputAmount', getU64Decoder()], - ]); -} - -export function getSlowFillCodec(): Codec { - return combineCodec(getSlowFillEncoder(), getSlowFillDecoder()); -} diff --git a/src/svm/clients/SvmSpoke/types/tokensBridged.ts b/src/svm/clients/SvmSpoke/types/tokensBridged.ts deleted file mode 100644 index b22e3c20f..000000000 --- a/src/svm/clients/SvmSpoke/types/tokensBridged.ts +++ /dev/null @@ -1,66 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type TokensBridged = { - amountToReturn: bigint; - chainId: bigint; - leafId: number; - l2TokenAddress: Address; - caller: Address; -}; - -export type TokensBridgedArgs = { - amountToReturn: number | bigint; - chainId: number | bigint; - leafId: number; - l2TokenAddress: Address; - caller: Address; -}; - -export function getTokensBridgedEncoder(): Encoder { - return getStructEncoder([ - ['amountToReturn', getU64Encoder()], - ['chainId', getU64Encoder()], - ['leafId', getU32Encoder()], - ['l2TokenAddress', getAddressEncoder()], - ['caller', getAddressEncoder()], - ]); -} - -export function getTokensBridgedDecoder(): Decoder { - return getStructDecoder([ - ['amountToReturn', getU64Decoder()], - ['chainId', getU64Decoder()], - ['leafId', getU32Decoder()], - ['l2TokenAddress', getAddressDecoder()], - ['caller', getAddressDecoder()], - ]); -} - -export function getTokensBridgedCodec(): Codec< - TokensBridgedArgs, - TokensBridged -> { - return combineCodec(getTokensBridgedEncoder(), getTokensBridgedDecoder()); -} diff --git a/src/svm/clients/SvmSpoke/types/transferredOwnership.ts b/src/svm/clients/SvmSpoke/types/transferredOwnership.ts deleted file mode 100644 index 13ee0c614..000000000 --- a/src/svm/clients/SvmSpoke/types/transferredOwnership.ts +++ /dev/null @@ -1,41 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type TransferredOwnership = { newOwner: Address }; - -export type TransferredOwnershipArgs = TransferredOwnership; - -export function getTransferredOwnershipEncoder(): Encoder { - return getStructEncoder([['newOwner', getAddressEncoder()]]); -} - -export function getTransferredOwnershipDecoder(): Decoder { - return getStructDecoder([['newOwner', getAddressDecoder()]]); -} - -export function getTransferredOwnershipCodec(): Codec< - TransferredOwnershipArgs, - TransferredOwnership -> { - return combineCodec( - getTransferredOwnershipEncoder(), - getTransferredOwnershipDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinter/accounts/index.ts b/src/svm/clients/TokenMessengerMinter/accounts/index.ts deleted file mode 100644 index fd155b748..000000000 --- a/src/svm/clients/TokenMessengerMinter/accounts/index.ts +++ /dev/null @@ -1,13 +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 - */ - -export * from './localToken'; -export * from './remoteTokenMessenger'; -export * from './tokenMessenger'; -export * from './tokenMinter'; -export * from './tokenPair'; diff --git a/src/svm/clients/TokenMessengerMinter/accounts/localToken.ts b/src/svm/clients/TokenMessengerMinter/accounts/localToken.ts deleted file mode 100644 index 9db5966c7..000000000 --- a/src/svm/clients/TokenMessengerMinter/accounts/localToken.ts +++ /dev/null @@ -1,169 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU128Decoder, - getU128Encoder, - getU64Decoder, - getU64Encoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const LOCAL_TOKEN_DISCRIMINATOR = new Uint8Array([ - 159, 131, 58, 170, 193, 84, 128, 182, -]); - -export function getLocalTokenDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(LOCAL_TOKEN_DISCRIMINATOR); -} - -export type LocalToken = { - discriminator: ReadonlyUint8Array; - custody: Address; - mint: Address; - burnLimitPerMessage: bigint; - messagesSent: bigint; - messagesReceived: bigint; - amountSent: bigint; - amountReceived: bigint; - bump: number; - custodyBump: number; -}; - -export type LocalTokenArgs = { - custody: Address; - mint: Address; - burnLimitPerMessage: number | bigint; - messagesSent: number | bigint; - messagesReceived: number | bigint; - amountSent: number | bigint; - amountReceived: number | bigint; - bump: number; - custodyBump: number; -}; - -export function getLocalTokenEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['custody', getAddressEncoder()], - ['mint', getAddressEncoder()], - ['burnLimitPerMessage', getU64Encoder()], - ['messagesSent', getU64Encoder()], - ['messagesReceived', getU64Encoder()], - ['amountSent', getU128Encoder()], - ['amountReceived', getU128Encoder()], - ['bump', getU8Encoder()], - ['custodyBump', getU8Encoder()], - ]), - (value) => ({ ...value, discriminator: LOCAL_TOKEN_DISCRIMINATOR }) - ); -} - -export function getLocalTokenDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['custody', getAddressDecoder()], - ['mint', getAddressDecoder()], - ['burnLimitPerMessage', getU64Decoder()], - ['messagesSent', getU64Decoder()], - ['messagesReceived', getU64Decoder()], - ['amountSent', getU128Decoder()], - ['amountReceived', getU128Decoder()], - ['bump', getU8Decoder()], - ['custodyBump', getU8Decoder()], - ]); -} - -export function getLocalTokenCodec(): Codec { - return combineCodec(getLocalTokenEncoder(), getLocalTokenDecoder()); -} - -export function decodeLocalToken( - encodedAccount: EncodedAccount -): Account; -export function decodeLocalToken( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeLocalToken( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getLocalTokenDecoder() - ); -} - -export async function fetchLocalToken( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeLocalToken(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeLocalToken( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeLocalToken(maybeAccount); -} - -export async function fetchAllLocalToken( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeLocalToken(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeLocalToken( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeLocalToken(maybeAccount)); -} - -export function getLocalTokenSize(): number { - return 130; -} diff --git a/src/svm/clients/TokenMessengerMinter/accounts/remoteTokenMessenger.ts b/src/svm/clients/TokenMessengerMinter/accounts/remoteTokenMessenger.ts deleted file mode 100644 index a2bbc7ecf..000000000 --- a/src/svm/clients/TokenMessengerMinter/accounts/remoteTokenMessenger.ts +++ /dev/null @@ -1,164 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const REMOTE_TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ - 105, 115, 174, 34, 95, 233, 138, 252, -]); - -export function getRemoteTokenMessengerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - REMOTE_TOKEN_MESSENGER_DISCRIMINATOR - ); -} - -export type RemoteTokenMessenger = { - discriminator: ReadonlyUint8Array; - domain: number; - tokenMessenger: Address; -}; - -export type RemoteTokenMessengerArgs = { - domain: number; - tokenMessenger: Address; -}; - -export function getRemoteTokenMessengerEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['domain', getU32Encoder()], - ['tokenMessenger', getAddressEncoder()], - ]), - (value) => ({ - ...value, - discriminator: REMOTE_TOKEN_MESSENGER_DISCRIMINATOR, - }) - ); -} - -export function getRemoteTokenMessengerDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['domain', getU32Decoder()], - ['tokenMessenger', getAddressDecoder()], - ]); -} - -export function getRemoteTokenMessengerCodec(): Codec< - RemoteTokenMessengerArgs, - RemoteTokenMessenger -> { - return combineCodec( - getRemoteTokenMessengerEncoder(), - getRemoteTokenMessengerDecoder() - ); -} - -export function decodeRemoteTokenMessenger( - encodedAccount: EncodedAccount -): Account; -export function decodeRemoteTokenMessenger( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeRemoteTokenMessenger( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): - | Account - | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getRemoteTokenMessengerDecoder() - ); -} - -export async function fetchRemoteTokenMessenger< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeRemoteTokenMessenger( - rpc, - address, - config - ); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeRemoteTokenMessenger< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeRemoteTokenMessenger(maybeAccount); -} - -export async function fetchAllRemoteTokenMessenger( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeRemoteTokenMessenger( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeRemoteTokenMessenger( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeRemoteTokenMessenger(maybeAccount) - ); -} - -export function getRemoteTokenMessengerSize(): number { - return 44; -} diff --git a/src/svm/clients/TokenMessengerMinter/accounts/tokenMessenger.ts b/src/svm/clients/TokenMessengerMinter/accounts/tokenMessenger.ts deleted file mode 100644 index df5044649..000000000 --- a/src/svm/clients/TokenMessengerMinter/accounts/tokenMessenger.ts +++ /dev/null @@ -1,164 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ - 162, 4, 242, 52, 147, 243, 221, 96, -]); - -export function getTokenMessengerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - TOKEN_MESSENGER_DISCRIMINATOR - ); -} - -export type TokenMessenger = { - discriminator: ReadonlyUint8Array; - owner: Address; - pendingOwner: Address; - localMessageTransmitter: Address; - messageBodyVersion: number; - authorityBump: number; -}; - -export type TokenMessengerArgs = { - owner: Address; - pendingOwner: Address; - localMessageTransmitter: Address; - messageBodyVersion: number; - authorityBump: number; -}; - -export function getTokenMessengerEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['owner', getAddressEncoder()], - ['pendingOwner', getAddressEncoder()], - ['localMessageTransmitter', getAddressEncoder()], - ['messageBodyVersion', getU32Encoder()], - ['authorityBump', getU8Encoder()], - ]), - (value) => ({ ...value, discriminator: TOKEN_MESSENGER_DISCRIMINATOR }) - ); -} - -export function getTokenMessengerDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['owner', getAddressDecoder()], - ['pendingOwner', getAddressDecoder()], - ['localMessageTransmitter', getAddressDecoder()], - ['messageBodyVersion', getU32Decoder()], - ['authorityBump', getU8Decoder()], - ]); -} - -export function getTokenMessengerCodec(): Codec< - TokenMessengerArgs, - TokenMessenger -> { - return combineCodec(getTokenMessengerEncoder(), getTokenMessengerDecoder()); -} - -export function decodeTokenMessenger( - encodedAccount: EncodedAccount -): Account; -export function decodeTokenMessenger( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeTokenMessenger( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getTokenMessengerDecoder() - ); -} - -export async function fetchTokenMessenger( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeTokenMessenger(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeTokenMessenger< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeTokenMessenger(maybeAccount); -} - -export async function fetchAllTokenMessenger( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeTokenMessenger( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeTokenMessenger( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeTokenMessenger(maybeAccount) - ); -} - -export function getTokenMessengerSize(): number { - return 109; -} diff --git a/src/svm/clients/TokenMessengerMinter/accounts/tokenMinter.ts b/src/svm/clients/TokenMessengerMinter/accounts/tokenMinter.ts deleted file mode 100644 index e522ef79d..000000000 --- a/src/svm/clients/TokenMessengerMinter/accounts/tokenMinter.ts +++ /dev/null @@ -1,149 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBooleanDecoder, - getBooleanEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const TOKEN_MINTER_DISCRIMINATOR = new Uint8Array([ - 122, 133, 84, 63, 57, 159, 171, 206, -]); - -export function getTokenMinterDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - TOKEN_MINTER_DISCRIMINATOR - ); -} - -export type TokenMinter = { - discriminator: ReadonlyUint8Array; - tokenController: Address; - pauser: Address; - paused: boolean; - bump: number; -}; - -export type TokenMinterArgs = { - tokenController: Address; - pauser: Address; - paused: boolean; - bump: number; -}; - -export function getTokenMinterEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['tokenController', getAddressEncoder()], - ['pauser', getAddressEncoder()], - ['paused', getBooleanEncoder()], - ['bump', getU8Encoder()], - ]), - (value) => ({ ...value, discriminator: TOKEN_MINTER_DISCRIMINATOR }) - ); -} - -export function getTokenMinterDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['tokenController', getAddressDecoder()], - ['pauser', getAddressDecoder()], - ['paused', getBooleanDecoder()], - ['bump', getU8Decoder()], - ]); -} - -export function getTokenMinterCodec(): Codec { - return combineCodec(getTokenMinterEncoder(), getTokenMinterDecoder()); -} - -export function decodeTokenMinter( - encodedAccount: EncodedAccount -): Account; -export function decodeTokenMinter( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeTokenMinter( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getTokenMinterDecoder() - ); -} - -export async function fetchTokenMinter( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeTokenMinter(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeTokenMinter( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeTokenMinter(maybeAccount); -} - -export async function fetchAllTokenMinter( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeTokenMinter(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeTokenMinter( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeTokenMinter(maybeAccount)); -} - -export function getTokenMinterSize(): number { - return 74; -} diff --git a/src/svm/clients/TokenMessengerMinter/accounts/tokenPair.ts b/src/svm/clients/TokenMessengerMinter/accounts/tokenPair.ts deleted file mode 100644 index 40fee5627..000000000 --- a/src/svm/clients/TokenMessengerMinter/accounts/tokenPair.ts +++ /dev/null @@ -1,147 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const TOKEN_PAIR_DISCRIMINATOR = new Uint8Array([ - 17, 214, 45, 176, 229, 149, 197, 71, -]); - -export function getTokenPairDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(TOKEN_PAIR_DISCRIMINATOR); -} - -export type TokenPair = { - discriminator: ReadonlyUint8Array; - remoteDomain: number; - remoteToken: Address; - localToken: Address; - bump: number; -}; - -export type TokenPairArgs = { - remoteDomain: number; - remoteToken: Address; - localToken: Address; - bump: number; -}; - -export function getTokenPairEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['remoteDomain', getU32Encoder()], - ['remoteToken', getAddressEncoder()], - ['localToken', getAddressEncoder()], - ['bump', getU8Encoder()], - ]), - (value) => ({ ...value, discriminator: TOKEN_PAIR_DISCRIMINATOR }) - ); -} - -export function getTokenPairDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['remoteDomain', getU32Decoder()], - ['remoteToken', getAddressDecoder()], - ['localToken', getAddressDecoder()], - ['bump', getU8Decoder()], - ]); -} - -export function getTokenPairCodec(): Codec { - return combineCodec(getTokenPairEncoder(), getTokenPairDecoder()); -} - -export function decodeTokenPair( - encodedAccount: EncodedAccount -): Account; -export function decodeTokenPair( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeTokenPair( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getTokenPairDecoder() - ); -} - -export async function fetchTokenPair( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeTokenPair(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeTokenPair( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeTokenPair(maybeAccount); -} - -export async function fetchAllTokenPair( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeTokenPair(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeTokenPair( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeTokenPair(maybeAccount)); -} - -export function getTokenPairSize(): number { - return 77; -} diff --git a/src/svm/clients/TokenMessengerMinter/errors/index.ts b/src/svm/clients/TokenMessengerMinter/errors/index.ts deleted file mode 100644 index 1e005644b..000000000 --- a/src/svm/clients/TokenMessengerMinter/errors/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './tokenMessengerMinter'; diff --git a/src/svm/clients/TokenMessengerMinter/errors/tokenMessengerMinter.ts b/src/svm/clients/TokenMessengerMinter/errors/tokenMessengerMinter.ts deleted file mode 100644 index aa8f4398c..000000000 --- a/src/svm/clients/TokenMessengerMinter/errors/tokenMessengerMinter.ts +++ /dev/null @@ -1,111 +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 { - isProgramError, - type Address, - type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, - type SolanaError, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; - -/** InvalidAuthority: Invalid authority */ -export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_AUTHORITY = 0x1770; // 6000 -/** InvalidTokenMessengerState: Invalid token messenger state */ -export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MESSENGER_STATE = 0x1771; // 6001 -/** InvalidTokenMessenger: Invalid token messenger */ -export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MESSENGER = 0x1772; // 6002 -/** InvalidOwner: Invalid owner */ -export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_OWNER = 0x1773; // 6003 -/** MalformedMessage: Malformed message */ -export const TOKEN_MESSENGER_MINTER_ERROR__MALFORMED_MESSAGE = 0x1774; // 6004 -/** InvalidMessageBodyVersion: Invalid message body version */ -export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_MESSAGE_BODY_VERSION = 0x1775; // 6005 -/** InvalidAmount: Invalid amount */ -export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_AMOUNT = 0x1776; // 6006 -/** InvalidDestinationDomain: Invalid destination domain */ -export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_DESTINATION_DOMAIN = 0x1777; // 6007 -/** InvalidDestinationCaller: Invalid destination caller */ -export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_DESTINATION_CALLER = 0x1778; // 6008 -/** InvalidMintRecipient: Invalid mint recipient */ -export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_MINT_RECIPIENT = 0x1779; // 6009 -/** InvalidSender: Invalid sender */ -export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_SENDER = 0x177a; // 6010 -/** InvalidTokenPair: Invalid token pair */ -export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_PAIR = 0x177b; // 6011 -/** InvalidTokenMint: Invalid token mint */ -export const TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MINT = 0x177c; // 6012 - -export type TokenMessengerMinterError = - | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_AMOUNT - | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_AUTHORITY - | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_DESTINATION_CALLER - | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_DESTINATION_DOMAIN - | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_MESSAGE_BODY_VERSION - | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_MINT_RECIPIENT - | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_OWNER - | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_SENDER - | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MESSENGER - | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MESSENGER_STATE - | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MINT - | typeof TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_PAIR - | typeof TOKEN_MESSENGER_MINTER_ERROR__MALFORMED_MESSAGE; - -let tokenMessengerMinterErrorMessages: - | Record - | undefined; -if (process.env.NODE_ENV !== 'production') { - tokenMessengerMinterErrorMessages = { - [TOKEN_MESSENGER_MINTER_ERROR__INVALID_AMOUNT]: `Invalid amount`, - [TOKEN_MESSENGER_MINTER_ERROR__INVALID_AUTHORITY]: `Invalid authority`, - [TOKEN_MESSENGER_MINTER_ERROR__INVALID_DESTINATION_CALLER]: `Invalid destination caller`, - [TOKEN_MESSENGER_MINTER_ERROR__INVALID_DESTINATION_DOMAIN]: `Invalid destination domain`, - [TOKEN_MESSENGER_MINTER_ERROR__INVALID_MESSAGE_BODY_VERSION]: `Invalid message body version`, - [TOKEN_MESSENGER_MINTER_ERROR__INVALID_MINT_RECIPIENT]: `Invalid mint recipient`, - [TOKEN_MESSENGER_MINTER_ERROR__INVALID_OWNER]: `Invalid owner`, - [TOKEN_MESSENGER_MINTER_ERROR__INVALID_SENDER]: `Invalid sender`, - [TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MESSENGER]: `Invalid token messenger`, - [TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MESSENGER_STATE]: `Invalid token messenger state`, - [TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_MINT]: `Invalid token mint`, - [TOKEN_MESSENGER_MINTER_ERROR__INVALID_TOKEN_PAIR]: `Invalid token pair`, - [TOKEN_MESSENGER_MINTER_ERROR__MALFORMED_MESSAGE]: `Malformed message`, - }; -} - -export function getTokenMessengerMinterErrorMessage( - code: TokenMessengerMinterError -): string { - if (process.env.NODE_ENV !== 'production') { - return ( - tokenMessengerMinterErrorMessages as Record< - TokenMessengerMinterError, - string - > - )[code]; - } - - return 'Error message not available in production bundles.'; -} - -export function isTokenMessengerMinterError< - TProgramErrorCode extends TokenMessengerMinterError, ->( - error: unknown, - transactionMessage: { - instructions: Record; - }, - code?: TProgramErrorCode -): error is SolanaError & - Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { - return isProgramError( - error, - transactionMessage, - TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - code - ); -} diff --git a/src/svm/clients/TokenMessengerMinter/index.ts b/src/svm/clients/TokenMessengerMinter/index.ts deleted file mode 100644 index 02964a6ae..000000000 --- a/src/svm/clients/TokenMessengerMinter/index.ts +++ /dev/null @@ -1,13 +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 - */ - -export * from './accounts'; -export * from './errors'; -export * from './instructions'; -export * from './programs'; -export * from './types'; diff --git a/src/svm/clients/TokenMessengerMinter/instructions/acceptOwnership.ts b/src/svm/clients/TokenMessengerMinter/instructions/acceptOwnership.ts deleted file mode 100644 index 99146d8f4..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/acceptOwnership.ts +++ /dev/null @@ -1,216 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const ACCEPT_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ - 172, 23, 43, 13, 238, 213, 85, 150, -]); - -export function getAcceptOwnershipDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - ACCEPT_OWNERSHIP_DISCRIMINATOR - ); -} - -export type AcceptOwnershipInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountPendingOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPendingOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountPendingOwner, - TAccountTokenMessenger extends string - ? WritableAccount - : TAccountTokenMessenger, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type AcceptOwnershipInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type AcceptOwnershipInstructionDataArgs = {}; - -export function getAcceptOwnershipInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: ACCEPT_OWNERSHIP_DISCRIMINATOR }) - ); -} - -export function getAcceptOwnershipInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getAcceptOwnershipInstructionDataCodec(): Codec< - AcceptOwnershipInstructionDataArgs, - AcceptOwnershipInstructionData -> { - return combineCodec( - getAcceptOwnershipInstructionDataEncoder(), - getAcceptOwnershipInstructionDataDecoder() - ); -} - -export type AcceptOwnershipInput< - TAccountPendingOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pendingOwner: TransactionSigner; - tokenMessenger: Address; - eventAuthority: Address; - program: Address; -}; - -export function getAcceptOwnershipInstruction< - TAccountPendingOwner extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: AcceptOwnershipInput< - TAccountPendingOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): AcceptOwnershipInstruction< - TProgramAddress, - TAccountPendingOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pendingOwner: { value: input.pendingOwner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pendingOwner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getAcceptOwnershipInstructionDataEncoder().encode({}), - } as AcceptOwnershipInstruction< - TProgramAddress, - TAccountPendingOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedAcceptOwnershipInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - pendingOwner: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: AcceptOwnershipInstructionData; -}; - -export function parseAcceptOwnershipInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedAcceptOwnershipInstruction { - if (instruction.accounts.length < 4) { - // 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: { - pendingOwner: getNextAccount(), - tokenMessenger: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getAcceptOwnershipInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/addLocalToken.ts b/src/svm/clients/TokenMessengerMinter/instructions/addLocalToken.ts deleted file mode 100644 index 46bdf9dd1..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/addLocalToken.ts +++ /dev/null @@ -1,320 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const ADD_LOCAL_TOKEN_DISCRIMINATOR = new Uint8Array([ - 213, 199, 205, 18, 98, 124, 73, 198, -]); - -export function getAddLocalTokenDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - ADD_LOCAL_TOKEN_DISCRIMINATOR - ); -} - -export type AddLocalTokenInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountTokenController extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountCustodyTokenAccount extends string | AccountMeta = string, - TAccountLocalTokenMint extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountTokenController extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountTokenController, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountCustodyTokenAccount extends string - ? WritableAccount - : TAccountCustodyTokenAccount, - TAccountLocalTokenMint extends string - ? ReadonlyAccount - : TAccountLocalTokenMint, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type AddLocalTokenInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type AddLocalTokenInstructionDataArgs = {}; - -export function getAddLocalTokenInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: ADD_LOCAL_TOKEN_DISCRIMINATOR }) - ); -} - -export function getAddLocalTokenInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getAddLocalTokenInstructionDataCodec(): Codec< - AddLocalTokenInstructionDataArgs, - AddLocalTokenInstructionData -> { - return combineCodec( - getAddLocalTokenInstructionDataEncoder(), - getAddLocalTokenInstructionDataDecoder() - ); -} - -export type AddLocalTokenInput< - TAccountPayer extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountLocalTokenMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - localToken: Address; - custodyTokenAccount: Address; - localTokenMint: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; -}; - -export function getAddLocalTokenInstruction< - TAccountPayer extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountCustodyTokenAccount extends string, - TAccountLocalTokenMint extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: AddLocalTokenInput< - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountLocalTokenMint, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): AddLocalTokenInstruction< - TProgramAddress, - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountLocalTokenMint, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - localTokenMint: { value: input.localTokenMint ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.localTokenMint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getAddLocalTokenInstructionDataEncoder().encode({}), - } as AddLocalTokenInstruction< - TProgramAddress, - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountLocalTokenMint, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedAddLocalTokenInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - tokenController: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - localToken: TAccountMetas[3]; - custodyTokenAccount: TAccountMetas[4]; - localTokenMint: TAccountMetas[5]; - tokenProgram: TAccountMetas[6]; - systemProgram: TAccountMetas[7]; - eventAuthority: TAccountMetas[8]; - program: TAccountMetas[9]; - }; - data: AddLocalTokenInstructionData; -}; - -export function parseAddLocalTokenInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedAddLocalTokenInstruction { - if (instruction.accounts.length < 10) { - // 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: { - payer: getNextAccount(), - tokenController: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - custodyTokenAccount: getNextAccount(), - localTokenMint: getNextAccount(), - tokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getAddLocalTokenInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/addRemoteTokenMessenger.ts b/src/svm/clients/TokenMessengerMinter/instructions/addRemoteTokenMessenger.ts deleted file mode 100644 index f3686285f..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/addRemoteTokenMessenger.ts +++ /dev/null @@ -1,297 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const ADD_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ - 12, 149, 172, 165, 111, 202, 24, 33, -]); - -export function getAddRemoteTokenMessengerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - ADD_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR - ); -} - -export type AddRemoteTokenMessengerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountRemoteTokenMessenger extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountRemoteTokenMessenger extends string - ? WritableAccount - : TAccountRemoteTokenMessenger, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type AddRemoteTokenMessengerInstructionData = { - discriminator: ReadonlyUint8Array; - domain: number; - tokenMessenger: Address; -}; - -export type AddRemoteTokenMessengerInstructionDataArgs = { - domain: number; - tokenMessenger: Address; -}; - -export function getAddRemoteTokenMessengerInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['domain', getU32Encoder()], - ['tokenMessenger', getAddressEncoder()], - ]), - (value) => ({ - ...value, - discriminator: ADD_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR, - }) - ); -} - -export function getAddRemoteTokenMessengerInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['domain', getU32Decoder()], - ['tokenMessenger', getAddressDecoder()], - ]); -} - -export function getAddRemoteTokenMessengerInstructionDataCodec(): Codec< - AddRemoteTokenMessengerInstructionDataArgs, - AddRemoteTokenMessengerInstructionData -> { - return combineCodec( - getAddRemoteTokenMessengerInstructionDataEncoder(), - getAddRemoteTokenMessengerInstructionDataDecoder() - ); -} - -export type AddRemoteTokenMessengerInput< - TAccountPayer extends string = string, - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - owner: TransactionSigner; - tokenMessenger: Address; - remoteTokenMessenger: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - domain: AddRemoteTokenMessengerInstructionDataArgs['domain']; - tokenMessengerArg: AddRemoteTokenMessengerInstructionDataArgs['tokenMessenger']; -}; - -export function getAddRemoteTokenMessengerInstruction< - TAccountPayer extends string, - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: AddRemoteTokenMessengerInput< - TAccountPayer, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): AddRemoteTokenMessengerInstruction< - TProgramAddress, - TAccountPayer, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: true, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input, tokenMessenger: input.tokenMessengerArg }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getAddRemoteTokenMessengerInstructionDataEncoder().encode( - args as AddRemoteTokenMessengerInstructionDataArgs - ), - } as AddRemoteTokenMessengerInstruction< - TProgramAddress, - TAccountPayer, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedAddRemoteTokenMessengerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - owner: TAccountMetas[1]; - tokenMessenger: TAccountMetas[2]; - remoteTokenMessenger: TAccountMetas[3]; - systemProgram: TAccountMetas[4]; - eventAuthority: TAccountMetas[5]; - program: TAccountMetas[6]; - }; - data: AddRemoteTokenMessengerInstructionData; -}; - -export function parseAddRemoteTokenMessengerInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedAddRemoteTokenMessengerInstruction { - if (instruction.accounts.length < 7) { - // 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: { - payer: getNextAccount(), - owner: getNextAccount(), - tokenMessenger: getNextAccount(), - remoteTokenMessenger: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getAddRemoteTokenMessengerInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/burnTokenCustody.ts b/src/svm/clients/TokenMessengerMinter/instructions/burnTokenCustody.ts deleted file mode 100644 index 6b98c5544..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/burnTokenCustody.ts +++ /dev/null @@ -1,317 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const BURN_TOKEN_CUSTODY_DISCRIMINATOR = new Uint8Array([ - 233, 136, 180, 175, 112, 41, 62, 71, -]); - -export function getBurnTokenCustodyDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - BURN_TOKEN_CUSTODY_DISCRIMINATOR - ); -} - -export type BurnTokenCustodyInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountPayee extends string | AccountMeta = string, - TAccountTokenController extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountCustodyTokenAccount extends string | AccountMeta = string, - TAccountCustodyTokenMint extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayee extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayee, - TAccountTokenController extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountTokenController, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? ReadonlyAccount - : TAccountLocalToken, - TAccountCustodyTokenAccount extends string - ? WritableAccount - : TAccountCustodyTokenAccount, - TAccountCustodyTokenMint extends string - ? WritableAccount - : TAccountCustodyTokenMint, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type BurnTokenCustodyInstructionData = { - discriminator: ReadonlyUint8Array; - amount: bigint; -}; - -export type BurnTokenCustodyInstructionDataArgs = { amount: number | bigint }; - -export function getBurnTokenCustodyInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['amount', getU64Encoder()], - ]), - (value) => ({ ...value, discriminator: BURN_TOKEN_CUSTODY_DISCRIMINATOR }) - ); -} - -export function getBurnTokenCustodyInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['amount', getU64Decoder()], - ]); -} - -export function getBurnTokenCustodyInstructionDataCodec(): Codec< - BurnTokenCustodyInstructionDataArgs, - BurnTokenCustodyInstructionData -> { - return combineCodec( - getBurnTokenCustodyInstructionDataEncoder(), - getBurnTokenCustodyInstructionDataDecoder() - ); -} - -export type BurnTokenCustodyInput< - TAccountPayee extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountCustodyTokenMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payee: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - localToken: Address; - custodyTokenAccount: Address; - custodyTokenMint: Address; - tokenProgram?: Address; - eventAuthority: Address; - program: Address; - amount: BurnTokenCustodyInstructionDataArgs['amount']; -}; - -export function getBurnTokenCustodyInstruction< - TAccountPayee extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountCustodyTokenAccount extends string, - TAccountCustodyTokenMint extends string, - TAccountTokenProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: BurnTokenCustodyInput< - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): BurnTokenCustodyInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: false }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - custodyTokenMint: { - value: input.custodyTokenMint ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.custodyTokenMint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getBurnTokenCustodyInstructionDataEncoder().encode( - args as BurnTokenCustodyInstructionDataArgs - ), - } as BurnTokenCustodyInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedBurnTokenCustodyInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payee: TAccountMetas[0]; - tokenController: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - localToken: TAccountMetas[3]; - custodyTokenAccount: TAccountMetas[4]; - custodyTokenMint: TAccountMetas[5]; - tokenProgram: TAccountMetas[6]; - eventAuthority: TAccountMetas[7]; - program: TAccountMetas[8]; - }; - data: BurnTokenCustodyInstructionData; -}; - -export function parseBurnTokenCustodyInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedBurnTokenCustodyInstruction { - if (instruction.accounts.length < 9) { - // 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: { - payee: getNextAccount(), - tokenController: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - custodyTokenAccount: getNextAccount(), - custodyTokenMint: getNextAccount(), - tokenProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getBurnTokenCustodyInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/depositForBurn.ts b/src/svm/clients/TokenMessengerMinter/instructions/depositForBurn.ts deleted file mode 100644 index 1ccbd5a2b..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/depositForBurn.ts +++ /dev/null @@ -1,465 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const DEPOSIT_FOR_BURN_DISCRIMINATOR = new Uint8Array([ - 215, 60, 61, 46, 114, 55, 128, 176, -]); - -export function getDepositForBurnDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - DEPOSIT_FOR_BURN_DISCRIMINATOR - ); -} - -export type DepositForBurnInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountEventRentPayer extends string | AccountMeta = string, - TAccountSenderAuthorityPda extends string | AccountMeta = string, - TAccountBurnTokenAccount extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountRemoteTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountBurnTokenMint extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TAccountMessageTransmitterProgram extends string | AccountMeta = - string, - TAccountTokenMessengerMinterProgram extends string | AccountMeta = - string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountEventRentPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountEventRentPayer, - TAccountSenderAuthorityPda extends string - ? ReadonlyAccount - : TAccountSenderAuthorityPda, - TAccountBurnTokenAccount extends string - ? WritableAccount - : TAccountBurnTokenAccount, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountRemoteTokenMessenger extends string - ? ReadonlyAccount - : TAccountRemoteTokenMessenger, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountBurnTokenMint extends string - ? WritableAccount - : TAccountBurnTokenMint, - TAccountMessageSentEventData extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountMessageSentEventData, - TAccountMessageTransmitterProgram extends string - ? ReadonlyAccount - : TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram extends string - ? ReadonlyAccount - : TAccountTokenMessengerMinterProgram, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type DepositForBurnInstructionData = { - discriminator: ReadonlyUint8Array; - amount: bigint; - destinationDomain: number; - mintRecipient: Address; -}; - -export type DepositForBurnInstructionDataArgs = { - amount: number | bigint; - destinationDomain: number; - mintRecipient: Address; -}; - -export function getDepositForBurnInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['amount', getU64Encoder()], - ['destinationDomain', getU32Encoder()], - ['mintRecipient', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: DEPOSIT_FOR_BURN_DISCRIMINATOR }) - ); -} - -export function getDepositForBurnInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['amount', getU64Decoder()], - ['destinationDomain', getU32Decoder()], - ['mintRecipient', getAddressDecoder()], - ]); -} - -export function getDepositForBurnInstructionDataCodec(): Codec< - DepositForBurnInstructionDataArgs, - DepositForBurnInstructionData -> { - return combineCodec( - getDepositForBurnInstructionDataEncoder(), - getDepositForBurnInstructionDataDecoder() - ); -} - -export type DepositForBurnInput< - TAccountOwner extends string = string, - TAccountEventRentPayer extends string = string, - TAccountSenderAuthorityPda extends string = string, - TAccountBurnTokenAccount extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountBurnTokenMint extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - eventRentPayer: TransactionSigner; - senderAuthorityPda: Address; - burnTokenAccount: Address; - messageTransmitter: Address; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken: Address; - burnTokenMint: Address; - messageSentEventData: TransactionSigner; - messageTransmitterProgram: Address; - tokenMessengerMinterProgram: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - amount: DepositForBurnInstructionDataArgs['amount']; - destinationDomain: DepositForBurnInstructionDataArgs['destinationDomain']; - mintRecipient: DepositForBurnInstructionDataArgs['mintRecipient']; -}; - -export function getDepositForBurnInstruction< - TAccountOwner extends string, - TAccountEventRentPayer extends string, - TAccountSenderAuthorityPda extends string, - TAccountBurnTokenAccount extends string, - TAccountMessageTransmitter extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountBurnTokenMint extends string, - TAccountMessageSentEventData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: DepositForBurnInput< - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): DepositForBurnInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, - senderAuthorityPda: { - value: input.senderAuthorityPda ?? null, - isWritable: false, - }, - burnTokenAccount: { - value: input.burnTokenAccount ?? null, - isWritable: true, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - burnTokenMint: { value: input.burnTokenMint ?? null, isWritable: true }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.eventRentPayer), - getAccountMeta(accounts.senderAuthorityPda), - getAccountMeta(accounts.burnTokenAccount), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.burnTokenMint), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDepositForBurnInstructionDataEncoder().encode( - args as DepositForBurnInstructionDataArgs - ), - } as DepositForBurnInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedDepositForBurnInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - eventRentPayer: TAccountMetas[1]; - senderAuthorityPda: TAccountMetas[2]; - burnTokenAccount: TAccountMetas[3]; - messageTransmitter: TAccountMetas[4]; - tokenMessenger: TAccountMetas[5]; - remoteTokenMessenger: TAccountMetas[6]; - tokenMinter: TAccountMetas[7]; - localToken: TAccountMetas[8]; - burnTokenMint: TAccountMetas[9]; - messageSentEventData: TAccountMetas[10]; - messageTransmitterProgram: TAccountMetas[11]; - tokenMessengerMinterProgram: TAccountMetas[12]; - tokenProgram: TAccountMetas[13]; - systemProgram: TAccountMetas[14]; - eventAuthority: TAccountMetas[15]; - program: TAccountMetas[16]; - }; - data: DepositForBurnInstructionData; -}; - -export function parseDepositForBurnInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedDepositForBurnInstruction { - if (instruction.accounts.length < 17) { - // 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: { - owner: getNextAccount(), - eventRentPayer: getNextAccount(), - senderAuthorityPda: getNextAccount(), - burnTokenAccount: getNextAccount(), - messageTransmitter: getNextAccount(), - tokenMessenger: getNextAccount(), - remoteTokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - burnTokenMint: getNextAccount(), - messageSentEventData: getNextAccount(), - messageTransmitterProgram: getNextAccount(), - tokenMessengerMinterProgram: getNextAccount(), - tokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getDepositForBurnInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/depositForBurnWithCaller.ts b/src/svm/clients/TokenMessengerMinter/instructions/depositForBurnWithCaller.ts deleted file mode 100644 index d8d061f87..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/depositForBurnWithCaller.ts +++ /dev/null @@ -1,475 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const DEPOSIT_FOR_BURN_WITH_CALLER_DISCRIMINATOR = new Uint8Array([ - 167, 222, 19, 114, 85, 21, 14, 118, -]); - -export function getDepositForBurnWithCallerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - DEPOSIT_FOR_BURN_WITH_CALLER_DISCRIMINATOR - ); -} - -export type DepositForBurnWithCallerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountEventRentPayer extends string | AccountMeta = string, - TAccountSenderAuthorityPda extends string | AccountMeta = string, - TAccountBurnTokenAccount extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountRemoteTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountBurnTokenMint extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TAccountMessageTransmitterProgram extends string | AccountMeta = - string, - TAccountTokenMessengerMinterProgram extends string | AccountMeta = - string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountEventRentPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountEventRentPayer, - TAccountSenderAuthorityPda extends string - ? ReadonlyAccount - : TAccountSenderAuthorityPda, - TAccountBurnTokenAccount extends string - ? WritableAccount - : TAccountBurnTokenAccount, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountRemoteTokenMessenger extends string - ? ReadonlyAccount - : TAccountRemoteTokenMessenger, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountBurnTokenMint extends string - ? WritableAccount - : TAccountBurnTokenMint, - TAccountMessageSentEventData extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountMessageSentEventData, - TAccountMessageTransmitterProgram extends string - ? ReadonlyAccount - : TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram extends string - ? ReadonlyAccount - : TAccountTokenMessengerMinterProgram, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type DepositForBurnWithCallerInstructionData = { - discriminator: ReadonlyUint8Array; - amount: bigint; - destinationDomain: number; - mintRecipient: Address; - destinationCaller: Address; -}; - -export type DepositForBurnWithCallerInstructionDataArgs = { - amount: number | bigint; - destinationDomain: number; - mintRecipient: Address; - destinationCaller: Address; -}; - -export function getDepositForBurnWithCallerInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['amount', getU64Encoder()], - ['destinationDomain', getU32Encoder()], - ['mintRecipient', getAddressEncoder()], - ['destinationCaller', getAddressEncoder()], - ]), - (value) => ({ - ...value, - discriminator: DEPOSIT_FOR_BURN_WITH_CALLER_DISCRIMINATOR, - }) - ); -} - -export function getDepositForBurnWithCallerInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['amount', getU64Decoder()], - ['destinationDomain', getU32Decoder()], - ['mintRecipient', getAddressDecoder()], - ['destinationCaller', getAddressDecoder()], - ]); -} - -export function getDepositForBurnWithCallerInstructionDataCodec(): Codec< - DepositForBurnWithCallerInstructionDataArgs, - DepositForBurnWithCallerInstructionData -> { - return combineCodec( - getDepositForBurnWithCallerInstructionDataEncoder(), - getDepositForBurnWithCallerInstructionDataDecoder() - ); -} - -export type DepositForBurnWithCallerInput< - TAccountOwner extends string = string, - TAccountEventRentPayer extends string = string, - TAccountSenderAuthorityPda extends string = string, - TAccountBurnTokenAccount extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountBurnTokenMint extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - eventRentPayer: TransactionSigner; - senderAuthorityPda: Address; - burnTokenAccount: Address; - messageTransmitter: Address; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken: Address; - burnTokenMint: Address; - messageSentEventData: TransactionSigner; - messageTransmitterProgram: Address; - tokenMessengerMinterProgram: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - amount: DepositForBurnWithCallerInstructionDataArgs['amount']; - destinationDomain: DepositForBurnWithCallerInstructionDataArgs['destinationDomain']; - mintRecipient: DepositForBurnWithCallerInstructionDataArgs['mintRecipient']; - destinationCaller: DepositForBurnWithCallerInstructionDataArgs['destinationCaller']; -}; - -export function getDepositForBurnWithCallerInstruction< - TAccountOwner extends string, - TAccountEventRentPayer extends string, - TAccountSenderAuthorityPda extends string, - TAccountBurnTokenAccount extends string, - TAccountMessageTransmitter extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountBurnTokenMint extends string, - TAccountMessageSentEventData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: DepositForBurnWithCallerInput< - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): DepositForBurnWithCallerInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, - senderAuthorityPda: { - value: input.senderAuthorityPda ?? null, - isWritable: false, - }, - burnTokenAccount: { - value: input.burnTokenAccount ?? null, - isWritable: true, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - burnTokenMint: { value: input.burnTokenMint ?? null, isWritable: true }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.eventRentPayer), - getAccountMeta(accounts.senderAuthorityPda), - getAccountMeta(accounts.burnTokenAccount), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.burnTokenMint), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDepositForBurnWithCallerInstructionDataEncoder().encode( - args as DepositForBurnWithCallerInstructionDataArgs - ), - } as DepositForBurnWithCallerInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedDepositForBurnWithCallerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - eventRentPayer: TAccountMetas[1]; - senderAuthorityPda: TAccountMetas[2]; - burnTokenAccount: TAccountMetas[3]; - messageTransmitter: TAccountMetas[4]; - tokenMessenger: TAccountMetas[5]; - remoteTokenMessenger: TAccountMetas[6]; - tokenMinter: TAccountMetas[7]; - localToken: TAccountMetas[8]; - burnTokenMint: TAccountMetas[9]; - messageSentEventData: TAccountMetas[10]; - messageTransmitterProgram: TAccountMetas[11]; - tokenMessengerMinterProgram: TAccountMetas[12]; - tokenProgram: TAccountMetas[13]; - systemProgram: TAccountMetas[14]; - eventAuthority: TAccountMetas[15]; - program: TAccountMetas[16]; - }; - data: DepositForBurnWithCallerInstructionData; -}; - -export function parseDepositForBurnWithCallerInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedDepositForBurnWithCallerInstruction { - if (instruction.accounts.length < 17) { - // 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: { - owner: getNextAccount(), - eventRentPayer: getNextAccount(), - senderAuthorityPda: getNextAccount(), - burnTokenAccount: getNextAccount(), - messageTransmitter: getNextAccount(), - tokenMessenger: getNextAccount(), - remoteTokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - burnTokenMint: getNextAccount(), - messageSentEventData: getNextAccount(), - messageTransmitterProgram: getNextAccount(), - tokenMessengerMinterProgram: getNextAccount(), - tokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getDepositForBurnWithCallerInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/handleReceiveMessage.ts b/src/svm/clients/TokenMessengerMinter/instructions/handleReceiveMessage.ts deleted file mode 100644 index e1c7934ca..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/handleReceiveMessage.ts +++ /dev/null @@ -1,371 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const HANDLE_RECEIVE_MESSAGE_DISCRIMINATOR = new Uint8Array([ - 133, 102, 1, 180, 145, 11, 138, 180, -]); - -export function getHandleReceiveMessageDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - HANDLE_RECEIVE_MESSAGE_DISCRIMINATOR - ); -} - -export type HandleReceiveMessageInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountAuthorityPda extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountRemoteTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountTokenPair extends string | AccountMeta = string, - TAccountRecipientTokenAccount extends string | AccountMeta = string, - TAccountCustodyTokenAccount extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountAuthorityPda extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthorityPda, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountRemoteTokenMessenger extends string - ? ReadonlyAccount - : TAccountRemoteTokenMessenger, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountTokenPair extends string - ? ReadonlyAccount - : TAccountTokenPair, - TAccountRecipientTokenAccount extends string - ? WritableAccount - : TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount extends string - ? WritableAccount - : TAccountCustodyTokenAccount, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type HandleReceiveMessageInstructionData = { - discriminator: ReadonlyUint8Array; - remoteDomain: number; - sender: Address; - messageBody: ReadonlyUint8Array; - authorityBump: number; -}; - -export type HandleReceiveMessageInstructionDataArgs = { - remoteDomain: number; - sender: Address; - messageBody: ReadonlyUint8Array; - authorityBump: number; -}; - -export function getHandleReceiveMessageInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['remoteDomain', getU32Encoder()], - ['sender', getAddressEncoder()], - ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ['authorityBump', getU8Encoder()], - ]), - (value) => ({ - ...value, - discriminator: HANDLE_RECEIVE_MESSAGE_DISCRIMINATOR, - }) - ); -} - -export function getHandleReceiveMessageInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['remoteDomain', getU32Decoder()], - ['sender', getAddressDecoder()], - ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ['authorityBump', getU8Decoder()], - ]); -} - -export function getHandleReceiveMessageInstructionDataCodec(): Codec< - HandleReceiveMessageInstructionDataArgs, - HandleReceiveMessageInstructionData -> { - return combineCodec( - getHandleReceiveMessageInstructionDataEncoder(), - getHandleReceiveMessageInstructionDataDecoder() - ); -} - -export type HandleReceiveMessageInput< - TAccountAuthorityPda extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountTokenPair extends string = string, - TAccountRecipientTokenAccount extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountTokenProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - authorityPda: TransactionSigner; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken: Address; - tokenPair: Address; - recipientTokenAccount: Address; - custodyTokenAccount: Address; - tokenProgram?: Address; - eventAuthority: Address; - program: Address; - remoteDomain: HandleReceiveMessageInstructionDataArgs['remoteDomain']; - sender: HandleReceiveMessageInstructionDataArgs['sender']; - messageBody: HandleReceiveMessageInstructionDataArgs['messageBody']; - authorityBump: HandleReceiveMessageInstructionDataArgs['authorityBump']; -}; - -export function getHandleReceiveMessageInstruction< - TAccountAuthorityPda extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountTokenPair extends string, - TAccountRecipientTokenAccount extends string, - TAccountCustodyTokenAccount extends string, - TAccountTokenProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: HandleReceiveMessageInput< - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): HandleReceiveMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - authorityPda: { value: input.authorityPda ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - tokenPair: { value: input.tokenPair ?? null, isWritable: false }, - recipientTokenAccount: { - value: input.recipientTokenAccount ?? null, - isWritable: true, - }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.authorityPda), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.tokenPair), - getAccountMeta(accounts.recipientTokenAccount), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getHandleReceiveMessageInstructionDataEncoder().encode( - args as HandleReceiveMessageInstructionDataArgs - ), - } as HandleReceiveMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedHandleReceiveMessageInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - authorityPda: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - remoteTokenMessenger: TAccountMetas[2]; - tokenMinter: TAccountMetas[3]; - localToken: TAccountMetas[4]; - tokenPair: TAccountMetas[5]; - recipientTokenAccount: TAccountMetas[6]; - custodyTokenAccount: TAccountMetas[7]; - tokenProgram: TAccountMetas[8]; - eventAuthority: TAccountMetas[9]; - program: TAccountMetas[10]; - }; - data: HandleReceiveMessageInstructionData; -}; - -export function parseHandleReceiveMessageInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedHandleReceiveMessageInstruction { - if (instruction.accounts.length < 11) { - // 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: { - authorityPda: getNextAccount(), - tokenMessenger: getNextAccount(), - remoteTokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - tokenPair: getNextAccount(), - recipientTokenAccount: getNextAccount(), - custodyTokenAccount: getNextAccount(), - tokenProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getHandleReceiveMessageInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/index.ts b/src/svm/clients/TokenMessengerMinter/instructions/index.ts deleted file mode 100644 index 4f7879d35..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/index.ts +++ /dev/null @@ -1,27 +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 - */ - -export * from './acceptOwnership'; -export * from './addLocalToken'; -export * from './addRemoteTokenMessenger'; -export * from './burnTokenCustody'; -export * from './depositForBurn'; -export * from './depositForBurnWithCaller'; -export * from './handleReceiveMessage'; -export * from './initialize'; -export * from './linkTokenPair'; -export * from './pause'; -export * from './removeLocalToken'; -export * from './removeRemoteTokenMessenger'; -export * from './replaceDepositForBurn'; -export * from './setMaxBurnAmountPerMessage'; -export * from './setTokenController'; -export * from './transferOwnership'; -export * from './unlinkTokenPair'; -export * from './unpause'; -export * from './updatePauser'; diff --git a/src/svm/clients/TokenMessengerMinter/instructions/initialize.ts b/src/svm/clients/TokenMessengerMinter/instructions/initialize.ts deleted file mode 100644 index c41147b19..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/initialize.ts +++ /dev/null @@ -1,345 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const INITIALIZE_DISCRIMINATOR = new Uint8Array([ - 175, 175, 109, 31, 13, 152, 155, 237, -]); - -export function getInitializeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_DISCRIMINATOR); -} - -export type InitializeInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountUpgradeAuthority extends string | AccountMeta = string, - TAccountAuthorityPda extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountTokenMessengerMinterProgramData extends string | AccountMeta = - string, - TAccountTokenMessengerMinterProgram extends string | AccountMeta = - string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountUpgradeAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountUpgradeAuthority, - TAccountAuthorityPda extends string - ? ReadonlyAccount - : TAccountAuthorityPda, - TAccountTokenMessenger extends string - ? WritableAccount - : TAccountTokenMessenger, - TAccountTokenMinter extends string - ? WritableAccount - : TAccountTokenMinter, - TAccountTokenMessengerMinterProgramData extends string - ? ReadonlyAccount - : TAccountTokenMessengerMinterProgramData, - TAccountTokenMessengerMinterProgram extends string - ? ReadonlyAccount - : TAccountTokenMessengerMinterProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type InitializeInstructionData = { - discriminator: ReadonlyUint8Array; - tokenController: Address; - localMessageTransmitter: Address; - messageBodyVersion: number; -}; - -export type InitializeInstructionDataArgs = { - tokenController: Address; - localMessageTransmitter: Address; - messageBodyVersion: number; -}; - -export function getInitializeInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['tokenController', getAddressEncoder()], - ['localMessageTransmitter', getAddressEncoder()], - ['messageBodyVersion', getU32Encoder()], - ]), - (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) - ); -} - -export function getInitializeInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['tokenController', getAddressDecoder()], - ['localMessageTransmitter', getAddressDecoder()], - ['messageBodyVersion', getU32Decoder()], - ]); -} - -export function getInitializeInstructionDataCodec(): Codec< - InitializeInstructionDataArgs, - InitializeInstructionData -> { - return combineCodec( - getInitializeInstructionDataEncoder(), - getInitializeInstructionDataDecoder() - ); -} - -export type InitializeInput< - TAccountPayer extends string = string, - TAccountUpgradeAuthority extends string = string, - TAccountAuthorityPda extends string = string, - TAccountTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountTokenMessengerMinterProgramData extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - upgradeAuthority: TransactionSigner; - authorityPda: Address; - tokenMessenger: Address; - tokenMinter: Address; - tokenMessengerMinterProgramData: Address; - tokenMessengerMinterProgram: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - tokenController: InitializeInstructionDataArgs['tokenController']; - localMessageTransmitter: InitializeInstructionDataArgs['localMessageTransmitter']; - messageBodyVersion: InitializeInstructionDataArgs['messageBodyVersion']; -}; - -export function getInitializeInstruction< - TAccountPayer extends string, - TAccountUpgradeAuthority extends string, - TAccountAuthorityPda extends string, - TAccountTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountTokenMessengerMinterProgramData extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: InitializeInput< - TAccountPayer, - TAccountUpgradeAuthority, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountTokenMessengerMinterProgramData, - TAccountTokenMessengerMinterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): InitializeInstruction< - TProgramAddress, - TAccountPayer, - TAccountUpgradeAuthority, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountTokenMessengerMinterProgramData, - TAccountTokenMessengerMinterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - upgradeAuthority: { - value: input.upgradeAuthority ?? null, - isWritable: false, - }, - authorityPda: { value: input.authorityPda ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - tokenMessengerMinterProgramData: { - value: input.tokenMessengerMinterProgramData ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.upgradeAuthority), - getAccountMeta(accounts.authorityPda), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.tokenMessengerMinterProgramData), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getInitializeInstructionDataEncoder().encode( - args as InitializeInstructionDataArgs - ), - } as InitializeInstruction< - TProgramAddress, - TAccountPayer, - TAccountUpgradeAuthority, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountTokenMessengerMinterProgramData, - TAccountTokenMessengerMinterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedInitializeInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - upgradeAuthority: TAccountMetas[1]; - authorityPda: TAccountMetas[2]; - tokenMessenger: TAccountMetas[3]; - tokenMinter: TAccountMetas[4]; - tokenMessengerMinterProgramData: TAccountMetas[5]; - tokenMessengerMinterProgram: TAccountMetas[6]; - systemProgram: TAccountMetas[7]; - eventAuthority: TAccountMetas[8]; - program: TAccountMetas[9]; - }; - data: InitializeInstructionData; -}; - -export function parseInitializeInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedInitializeInstruction { - if (instruction.accounts.length < 10) { - // 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: { - payer: getNextAccount(), - upgradeAuthority: getNextAccount(), - authorityPda: getNextAccount(), - tokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - tokenMessengerMinterProgramData: getNextAccount(), - tokenMessengerMinterProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getInitializeInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/linkTokenPair.ts b/src/svm/clients/TokenMessengerMinter/instructions/linkTokenPair.ts deleted file mode 100644 index 5a514c309..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/linkTokenPair.ts +++ /dev/null @@ -1,297 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const LINK_TOKEN_PAIR_DISCRIMINATOR = new Uint8Array([ - 68, 162, 24, 104, 125, 46, 130, 12, -]); - -export function getLinkTokenPairDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - LINK_TOKEN_PAIR_DISCRIMINATOR - ); -} - -export type LinkTokenPairInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountTokenController extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountTokenPair extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountTokenController extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountTokenController, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountTokenPair extends string - ? WritableAccount - : TAccountTokenPair, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type LinkTokenPairInstructionData = { - discriminator: ReadonlyUint8Array; - localToken: Address; - remoteDomain: number; - remoteToken: Address; -}; - -export type LinkTokenPairInstructionDataArgs = { - localToken: Address; - remoteDomain: number; - remoteToken: Address; -}; - -export function getLinkTokenPairInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['localToken', getAddressEncoder()], - ['remoteDomain', getU32Encoder()], - ['remoteToken', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: LINK_TOKEN_PAIR_DISCRIMINATOR }) - ); -} - -export function getLinkTokenPairInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['localToken', getAddressDecoder()], - ['remoteDomain', getU32Decoder()], - ['remoteToken', getAddressDecoder()], - ]); -} - -export function getLinkTokenPairInstructionDataCodec(): Codec< - LinkTokenPairInstructionDataArgs, - LinkTokenPairInstructionData -> { - return combineCodec( - getLinkTokenPairInstructionDataEncoder(), - getLinkTokenPairInstructionDataDecoder() - ); -} - -export type LinkTokenPairInput< - TAccountPayer extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountTokenPair extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - tokenPair: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - localToken: LinkTokenPairInstructionDataArgs['localToken']; - remoteDomain: LinkTokenPairInstructionDataArgs['remoteDomain']; - remoteToken: LinkTokenPairInstructionDataArgs['remoteToken']; -}; - -export function getLinkTokenPairInstruction< - TAccountPayer extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountTokenPair extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: LinkTokenPairInput< - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): LinkTokenPairInstruction< - TProgramAddress, - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - tokenPair: { value: input.tokenPair ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.tokenPair), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getLinkTokenPairInstructionDataEncoder().encode( - args as LinkTokenPairInstructionDataArgs - ), - } as LinkTokenPairInstruction< - TProgramAddress, - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedLinkTokenPairInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - tokenController: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - tokenPair: TAccountMetas[3]; - systemProgram: TAccountMetas[4]; - eventAuthority: TAccountMetas[5]; - program: TAccountMetas[6]; - }; - data: LinkTokenPairInstructionData; -}; - -export function parseLinkTokenPairInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedLinkTokenPairInstruction { - if (instruction.accounts.length < 7) { - // 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: { - payer: getNextAccount(), - tokenController: getNextAccount(), - tokenMinter: getNextAccount(), - tokenPair: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getLinkTokenPairInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/pause.ts b/src/svm/clients/TokenMessengerMinter/instructions/pause.ts deleted file mode 100644 index 0dad6155e..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/pause.ts +++ /dev/null @@ -1,212 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const PAUSE_DISCRIMINATOR = new Uint8Array([ - 211, 22, 221, 251, 74, 121, 193, 47, -]); - -export function getPauseDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(PAUSE_DISCRIMINATOR); -} - -export type PauseInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountPauser extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPauser extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountPauser, - TAccountTokenMinter extends string - ? WritableAccount - : TAccountTokenMinter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type PauseInstructionData = { discriminator: ReadonlyUint8Array }; - -export type PauseInstructionDataArgs = {}; - -export function getPauseInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: PAUSE_DISCRIMINATOR }) - ); -} - -export function getPauseInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getPauseInstructionDataCodec(): Codec< - PauseInstructionDataArgs, - PauseInstructionData -> { - return combineCodec( - getPauseInstructionDataEncoder(), - getPauseInstructionDataDecoder() - ); -} - -export type PauseInput< - TAccountPauser extends string = string, - TAccountTokenMinter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pauser: TransactionSigner; - tokenMinter: Address; - eventAuthority: Address; - program: Address; -}; - -export function getPauseInstruction< - TAccountPauser extends string, - TAccountTokenMinter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: PauseInput< - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): PauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pauser: { value: input.pauser ?? null, isWritable: false }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pauser), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getPauseInstructionDataEncoder().encode({}), - } as PauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedPauseInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - pauser: TAccountMetas[0]; - tokenMinter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: PauseInstructionData; -}; - -export function parsePauseInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedPauseInstruction { - if (instruction.accounts.length < 4) { - // 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: { - pauser: getNextAccount(), - tokenMinter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getPauseInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/removeLocalToken.ts b/src/svm/clients/TokenMessengerMinter/instructions/removeLocalToken.ts deleted file mode 100644 index 4ad4e155e..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/removeLocalToken.ts +++ /dev/null @@ -1,287 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const REMOVE_LOCAL_TOKEN_DISCRIMINATOR = new Uint8Array([ - 27, 43, 66, 170, 188, 44, 109, 97, -]); - -export function getRemoveLocalTokenDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - REMOVE_LOCAL_TOKEN_DISCRIMINATOR - ); -} - -export type RemoveLocalTokenInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountPayee extends string | AccountMeta = string, - TAccountTokenController extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountCustodyTokenAccount extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayee extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayee, - TAccountTokenController extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountTokenController, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountCustodyTokenAccount extends string - ? WritableAccount - : TAccountCustodyTokenAccount, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type RemoveLocalTokenInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type RemoveLocalTokenInstructionDataArgs = {}; - -export function getRemoveLocalTokenInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: REMOVE_LOCAL_TOKEN_DISCRIMINATOR }) - ); -} - -export function getRemoveLocalTokenInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getRemoveLocalTokenInstructionDataCodec(): Codec< - RemoveLocalTokenInstructionDataArgs, - RemoveLocalTokenInstructionData -> { - return combineCodec( - getRemoveLocalTokenInstructionDataEncoder(), - getRemoveLocalTokenInstructionDataDecoder() - ); -} - -export type RemoveLocalTokenInput< - TAccountPayee extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountTokenProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payee: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - localToken: Address; - custodyTokenAccount: Address; - tokenProgram?: Address; - eventAuthority: Address; - program: Address; -}; - -export function getRemoveLocalTokenInstruction< - TAccountPayee extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountCustodyTokenAccount extends string, - TAccountTokenProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: RemoveLocalTokenInput< - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): RemoveLocalTokenInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getRemoveLocalTokenInstructionDataEncoder().encode({}), - } as RemoveLocalTokenInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedRemoveLocalTokenInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payee: TAccountMetas[0]; - tokenController: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - localToken: TAccountMetas[3]; - custodyTokenAccount: TAccountMetas[4]; - tokenProgram: TAccountMetas[5]; - eventAuthority: TAccountMetas[6]; - program: TAccountMetas[7]; - }; - data: RemoveLocalTokenInstructionData; -}; - -export function parseRemoveLocalTokenInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedRemoveLocalTokenInstruction { - if (instruction.accounts.length < 8) { - // 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: { - payee: getNextAccount(), - tokenController: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - custodyTokenAccount: getNextAccount(), - tokenProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getRemoveLocalTokenInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/removeRemoteTokenMessenger.ts b/src/svm/clients/TokenMessengerMinter/instructions/removeRemoteTokenMessenger.ts deleted file mode 100644 index 166b6ca45..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/removeRemoteTokenMessenger.ts +++ /dev/null @@ -1,254 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const REMOVE_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ - 65, 114, 66, 85, 169, 98, 177, 146, -]); - -export function getRemoveRemoteTokenMessengerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - REMOVE_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR - ); -} - -export type RemoveRemoteTokenMessengerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountPayee extends string | AccountMeta = string, - TAccountOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountRemoteTokenMessenger extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayee extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayee, - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountRemoteTokenMessenger extends string - ? WritableAccount - : TAccountRemoteTokenMessenger, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type RemoveRemoteTokenMessengerInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type RemoveRemoteTokenMessengerInstructionDataArgs = {}; - -export function getRemoveRemoteTokenMessengerInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ - ...value, - discriminator: REMOVE_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR, - }) - ); -} - -export function getRemoveRemoteTokenMessengerInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getRemoveRemoteTokenMessengerInstructionDataCodec(): Codec< - RemoveRemoteTokenMessengerInstructionDataArgs, - RemoveRemoteTokenMessengerInstructionData -> { - return combineCodec( - getRemoveRemoteTokenMessengerInstructionDataEncoder(), - getRemoveRemoteTokenMessengerInstructionDataDecoder() - ); -} - -export type RemoveRemoteTokenMessengerInput< - TAccountPayee extends string = string, - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payee: TransactionSigner; - owner: TransactionSigner; - tokenMessenger: Address; - remoteTokenMessenger: Address; - eventAuthority: Address; - program: Address; -}; - -export function getRemoveRemoteTokenMessengerInstruction< - TAccountPayee extends string, - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: RemoveRemoteTokenMessengerInput< - TAccountPayee, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): RemoveRemoteTokenMessengerInstruction< - TProgramAddress, - TAccountPayee, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getRemoveRemoteTokenMessengerInstructionDataEncoder().encode({}), - } as RemoveRemoteTokenMessengerInstruction< - TProgramAddress, - TAccountPayee, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedRemoveRemoteTokenMessengerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payee: TAccountMetas[0]; - owner: TAccountMetas[1]; - tokenMessenger: TAccountMetas[2]; - remoteTokenMessenger: TAccountMetas[3]; - eventAuthority: TAccountMetas[4]; - program: TAccountMetas[5]; - }; - data: RemoveRemoteTokenMessengerInstructionData; -}; - -export function parseRemoveRemoteTokenMessengerInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedRemoveRemoteTokenMessengerInstruction { - if (instruction.accounts.length < 6) { - // 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: { - payee: getNextAccount(), - owner: getNextAccount(), - tokenMessenger: getNextAccount(), - remoteTokenMessenger: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getRemoveRemoteTokenMessengerInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/replaceDepositForBurn.ts b/src/svm/clients/TokenMessengerMinter/instructions/replaceDepositForBurn.ts deleted file mode 100644 index 13228bfa4..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/replaceDepositForBurn.ts +++ /dev/null @@ -1,392 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const REPLACE_DEPOSIT_FOR_BURN_DISCRIMINATOR = new Uint8Array([ - 7, 27, 93, 132, 1, 80, 19, 163, -]); - -export function getReplaceDepositForBurnDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - REPLACE_DEPOSIT_FOR_BURN_DISCRIMINATOR - ); -} - -export type ReplaceDepositForBurnInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountEventRentPayer extends string | AccountMeta = string, - TAccountSenderAuthorityPda extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TAccountMessageTransmitterProgram extends string | AccountMeta = - string, - TAccountTokenMessengerMinterProgram extends string | AccountMeta = - string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountEventRentPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountEventRentPayer, - TAccountSenderAuthorityPda extends string - ? ReadonlyAccount - : TAccountSenderAuthorityPda, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountMessageSentEventData extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountMessageSentEventData, - TAccountMessageTransmitterProgram extends string - ? ReadonlyAccount - : TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram extends string - ? ReadonlyAccount - : TAccountTokenMessengerMinterProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type ReplaceDepositForBurnInstructionData = { - discriminator: ReadonlyUint8Array; - originalMessage: ReadonlyUint8Array; - originalAttestation: ReadonlyUint8Array; - newDestinationCaller: Address; - newMintRecipient: Address; -}; - -export type ReplaceDepositForBurnInstructionDataArgs = { - originalMessage: ReadonlyUint8Array; - originalAttestation: ReadonlyUint8Array; - newDestinationCaller: Address; - newMintRecipient: Address; -}; - -export function getReplaceDepositForBurnInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - [ - 'originalMessage', - addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), - ], - [ - 'originalAttestation', - addEncoderSizePrefix(getBytesEncoder(), getU32Encoder()), - ], - ['newDestinationCaller', getAddressEncoder()], - ['newMintRecipient', getAddressEncoder()], - ]), - (value) => ({ - ...value, - discriminator: REPLACE_DEPOSIT_FOR_BURN_DISCRIMINATOR, - }) - ); -} - -export function getReplaceDepositForBurnInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - [ - 'originalMessage', - addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()), - ], - [ - 'originalAttestation', - addDecoderSizePrefix(getBytesDecoder(), getU32Decoder()), - ], - ['newDestinationCaller', getAddressDecoder()], - ['newMintRecipient', getAddressDecoder()], - ]); -} - -export function getReplaceDepositForBurnInstructionDataCodec(): Codec< - ReplaceDepositForBurnInstructionDataArgs, - ReplaceDepositForBurnInstructionData -> { - return combineCodec( - getReplaceDepositForBurnInstructionDataEncoder(), - getReplaceDepositForBurnInstructionDataDecoder() - ); -} - -export type ReplaceDepositForBurnInput< - TAccountOwner extends string = string, - TAccountEventRentPayer extends string = string, - TAccountSenderAuthorityPda extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountTokenMessenger extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - eventRentPayer: TransactionSigner; - senderAuthorityPda: Address; - messageTransmitter: Address; - tokenMessenger: Address; - messageSentEventData: TransactionSigner; - messageTransmitterProgram: Address; - tokenMessengerMinterProgram: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - originalMessage: ReplaceDepositForBurnInstructionDataArgs['originalMessage']; - originalAttestation: ReplaceDepositForBurnInstructionDataArgs['originalAttestation']; - newDestinationCaller: ReplaceDepositForBurnInstructionDataArgs['newDestinationCaller']; - newMintRecipient: ReplaceDepositForBurnInstructionDataArgs['newMintRecipient']; -}; - -export function getReplaceDepositForBurnInstruction< - TAccountOwner extends string, - TAccountEventRentPayer extends string, - TAccountSenderAuthorityPda extends string, - TAccountMessageTransmitter extends string, - TAccountTokenMessenger extends string, - TAccountMessageSentEventData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: ReplaceDepositForBurnInput< - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): ReplaceDepositForBurnInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, - senderAuthorityPda: { - value: input.senderAuthorityPda ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.eventRentPayer), - getAccountMeta(accounts.senderAuthorityPda), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getReplaceDepositForBurnInstructionDataEncoder().encode( - args as ReplaceDepositForBurnInstructionDataArgs - ), - } as ReplaceDepositForBurnInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedReplaceDepositForBurnInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - eventRentPayer: TAccountMetas[1]; - senderAuthorityPda: TAccountMetas[2]; - messageTransmitter: TAccountMetas[3]; - tokenMessenger: TAccountMetas[4]; - messageSentEventData: TAccountMetas[5]; - messageTransmitterProgram: TAccountMetas[6]; - tokenMessengerMinterProgram: TAccountMetas[7]; - systemProgram: TAccountMetas[8]; - eventAuthority: TAccountMetas[9]; - program: TAccountMetas[10]; - }; - data: ReplaceDepositForBurnInstructionData; -}; - -export function parseReplaceDepositForBurnInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedReplaceDepositForBurnInstruction { - if (instruction.accounts.length < 11) { - // 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: { - owner: getNextAccount(), - eventRentPayer: getNextAccount(), - senderAuthorityPda: getNextAccount(), - messageTransmitter: getNextAccount(), - tokenMessenger: getNextAccount(), - messageSentEventData: getNextAccount(), - messageTransmitterProgram: getNextAccount(), - tokenMessengerMinterProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getReplaceDepositForBurnInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/setMaxBurnAmountPerMessage.ts b/src/svm/clients/TokenMessengerMinter/instructions/setMaxBurnAmountPerMessage.ts deleted file mode 100644 index da1d11b34..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/setMaxBurnAmountPerMessage.ts +++ /dev/null @@ -1,253 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_MAX_BURN_AMOUNT_PER_MESSAGE_DISCRIMINATOR = new Uint8Array([ - 30, 128, 145, 240, 70, 237, 109, 207, -]); - -export function getSetMaxBurnAmountPerMessageDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_MAX_BURN_AMOUNT_PER_MESSAGE_DISCRIMINATOR - ); -} - -export type SetMaxBurnAmountPerMessageInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountTokenController extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountTokenController extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountTokenController, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type SetMaxBurnAmountPerMessageInstructionData = { - discriminator: ReadonlyUint8Array; - burnLimitPerMessage: bigint; -}; - -export type SetMaxBurnAmountPerMessageInstructionDataArgs = { - burnLimitPerMessage: number | bigint; -}; - -export function getSetMaxBurnAmountPerMessageInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['burnLimitPerMessage', getU64Encoder()], - ]), - (value) => ({ - ...value, - discriminator: SET_MAX_BURN_AMOUNT_PER_MESSAGE_DISCRIMINATOR, - }) - ); -} - -export function getSetMaxBurnAmountPerMessageInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['burnLimitPerMessage', getU64Decoder()], - ]); -} - -export function getSetMaxBurnAmountPerMessageInstructionDataCodec(): Codec< - SetMaxBurnAmountPerMessageInstructionDataArgs, - SetMaxBurnAmountPerMessageInstructionData -> { - return combineCodec( - getSetMaxBurnAmountPerMessageInstructionDataEncoder(), - getSetMaxBurnAmountPerMessageInstructionDataDecoder() - ); -} - -export type SetMaxBurnAmountPerMessageInput< - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - tokenController: TransactionSigner; - tokenMinter: Address; - localToken: Address; - eventAuthority: Address; - program: Address; - burnLimitPerMessage: SetMaxBurnAmountPerMessageInstructionDataArgs['burnLimitPerMessage']; -}; - -export function getSetMaxBurnAmountPerMessageInstruction< - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: SetMaxBurnAmountPerMessageInput< - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): SetMaxBurnAmountPerMessageInstruction< - TProgramAddress, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetMaxBurnAmountPerMessageInstructionDataEncoder().encode( - args as SetMaxBurnAmountPerMessageInstructionDataArgs - ), - } as SetMaxBurnAmountPerMessageInstruction< - TProgramAddress, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedSetMaxBurnAmountPerMessageInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - tokenController: TAccountMetas[0]; - tokenMinter: TAccountMetas[1]; - localToken: TAccountMetas[2]; - eventAuthority: TAccountMetas[3]; - program: TAccountMetas[4]; - }; - data: SetMaxBurnAmountPerMessageInstructionData; -}; - -export function parseSetMaxBurnAmountPerMessageInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetMaxBurnAmountPerMessageInstruction { - if (instruction.accounts.length < 5) { - // 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: { - tokenController: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getSetMaxBurnAmountPerMessageInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/setTokenController.ts b/src/svm/clients/TokenMessengerMinter/instructions/setTokenController.ts deleted file mode 100644 index 96eb6c061..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/setTokenController.ts +++ /dev/null @@ -1,247 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_TOKEN_CONTROLLER_DISCRIMINATOR = new Uint8Array([ - 88, 6, 98, 10, 79, 59, 15, 24, -]); - -export function getSetTokenControllerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_TOKEN_CONTROLLER_DISCRIMINATOR - ); -} - -export type SetTokenControllerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountTokenMinter extends string - ? WritableAccount - : TAccountTokenMinter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type SetTokenControllerInstructionData = { - discriminator: ReadonlyUint8Array; - tokenController: Address; -}; - -export type SetTokenControllerInstructionDataArgs = { - tokenController: Address; -}; - -export function getSetTokenControllerInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['tokenController', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: SET_TOKEN_CONTROLLER_DISCRIMINATOR }) - ); -} - -export function getSetTokenControllerInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['tokenController', getAddressDecoder()], - ]); -} - -export function getSetTokenControllerInstructionDataCodec(): Codec< - SetTokenControllerInstructionDataArgs, - SetTokenControllerInstructionData -> { - return combineCodec( - getSetTokenControllerInstructionDataEncoder(), - getSetTokenControllerInstructionDataDecoder() - ); -} - -export type SetTokenControllerInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - tokenMinter: Address; - eventAuthority: Address; - program: Address; - tokenController: SetTokenControllerInstructionDataArgs['tokenController']; -}; - -export function getSetTokenControllerInstruction< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: SetTokenControllerInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): SetTokenControllerInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetTokenControllerInstructionDataEncoder().encode( - args as SetTokenControllerInstructionDataArgs - ), - } as SetTokenControllerInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedSetTokenControllerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - eventAuthority: TAccountMetas[3]; - program: TAccountMetas[4]; - }; - data: SetTokenControllerInstructionData; -}; - -export function parseSetTokenControllerInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetTokenControllerInstruction { - if (instruction.accounts.length < 5) { - // 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: { - owner: getNextAccount(), - tokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getSetTokenControllerInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/transferOwnership.ts b/src/svm/clients/TokenMessengerMinter/instructions/transferOwnership.ts deleted file mode 100644 index 3b405916c..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/transferOwnership.ts +++ /dev/null @@ -1,229 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const TRANSFER_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ - 65, 177, 215, 73, 53, 45, 99, 47, -]); - -export function getTransferOwnershipDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - TRANSFER_OWNERSHIP_DISCRIMINATOR - ); -} - -export type TransferOwnershipInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountTokenMessenger extends string - ? WritableAccount - : TAccountTokenMessenger, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type TransferOwnershipInstructionData = { - discriminator: ReadonlyUint8Array; - newOwner: Address; -}; - -export type TransferOwnershipInstructionDataArgs = { newOwner: Address }; - -export function getTransferOwnershipInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newOwner', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: TRANSFER_OWNERSHIP_DISCRIMINATOR }) - ); -} - -export function getTransferOwnershipInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newOwner', getAddressDecoder()], - ]); -} - -export function getTransferOwnershipInstructionDataCodec(): Codec< - TransferOwnershipInstructionDataArgs, - TransferOwnershipInstructionData -> { - return combineCodec( - getTransferOwnershipInstructionDataEncoder(), - getTransferOwnershipInstructionDataDecoder() - ); -} - -export type TransferOwnershipInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - eventAuthority: Address; - program: Address; - newOwner: TransferOwnershipInstructionDataArgs['newOwner']; -}; - -export function getTransferOwnershipInstruction< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: TransferOwnershipInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): TransferOwnershipInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getTransferOwnershipInstructionDataEncoder().encode( - args as TransferOwnershipInstructionDataArgs - ), - } as TransferOwnershipInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedTransferOwnershipInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: TransferOwnershipInstructionData; -}; - -export function parseTransferOwnershipInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedTransferOwnershipInstruction { - if (instruction.accounts.length < 4) { - // 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: { - owner: getNextAccount(), - tokenMessenger: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getTransferOwnershipInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/unlinkTokenPair.ts b/src/svm/clients/TokenMessengerMinter/instructions/unlinkTokenPair.ts deleted file mode 100644 index 09d89c457..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/unlinkTokenPair.ts +++ /dev/null @@ -1,249 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UNLINK_TOKEN_PAIR_DISCRIMINATOR = new Uint8Array([ - 52, 198, 100, 114, 104, 174, 85, 58, -]); - -export function getUnlinkTokenPairDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - UNLINK_TOKEN_PAIR_DISCRIMINATOR - ); -} - -export type UnlinkTokenPairInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountPayee extends string | AccountMeta = string, - TAccountTokenController extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountTokenPair extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayee extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayee, - TAccountTokenController extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountTokenController, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountTokenPair extends string - ? WritableAccount - : TAccountTokenPair, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UnlinkTokenPairInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type UnlinkTokenPairInstructionDataArgs = {}; - -export function getUnlinkTokenPairInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: UNLINK_TOKEN_PAIR_DISCRIMINATOR }) - ); -} - -export function getUnlinkTokenPairInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getUnlinkTokenPairInstructionDataCodec(): Codec< - UnlinkTokenPairInstructionDataArgs, - UnlinkTokenPairInstructionData -> { - return combineCodec( - getUnlinkTokenPairInstructionDataEncoder(), - getUnlinkTokenPairInstructionDataDecoder() - ); -} - -export type UnlinkTokenPairInput< - TAccountPayee extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountTokenPair extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payee: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - tokenPair: Address; - eventAuthority: Address; - program: Address; -}; - -export function getUnlinkTokenPairInstruction< - TAccountPayee extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountTokenPair extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: UnlinkTokenPairInput< - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UnlinkTokenPairInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - tokenPair: { value: input.tokenPair ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.tokenPair), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUnlinkTokenPairInstructionDataEncoder().encode({}), - } as UnlinkTokenPairInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUnlinkTokenPairInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payee: TAccountMetas[0]; - tokenController: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - tokenPair: TAccountMetas[3]; - eventAuthority: TAccountMetas[4]; - program: TAccountMetas[5]; - }; - data: UnlinkTokenPairInstructionData; -}; - -export function parseUnlinkTokenPairInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUnlinkTokenPairInstruction { - if (instruction.accounts.length < 6) { - // 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: { - payee: getNextAccount(), - tokenController: getNextAccount(), - tokenMinter: getNextAccount(), - tokenPair: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUnlinkTokenPairInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/unpause.ts b/src/svm/clients/TokenMessengerMinter/instructions/unpause.ts deleted file mode 100644 index 93d7696be..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/unpause.ts +++ /dev/null @@ -1,212 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UNPAUSE_DISCRIMINATOR = new Uint8Array([ - 169, 144, 4, 38, 10, 141, 188, 255, -]); - -export function getUnpauseDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(UNPAUSE_DISCRIMINATOR); -} - -export type UnpauseInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountPauser extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPauser extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountPauser, - TAccountTokenMinter extends string - ? WritableAccount - : TAccountTokenMinter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UnpauseInstructionData = { discriminator: ReadonlyUint8Array }; - -export type UnpauseInstructionDataArgs = {}; - -export function getUnpauseInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: UNPAUSE_DISCRIMINATOR }) - ); -} - -export function getUnpauseInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getUnpauseInstructionDataCodec(): Codec< - UnpauseInstructionDataArgs, - UnpauseInstructionData -> { - return combineCodec( - getUnpauseInstructionDataEncoder(), - getUnpauseInstructionDataDecoder() - ); -} - -export type UnpauseInput< - TAccountPauser extends string = string, - TAccountTokenMinter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pauser: TransactionSigner; - tokenMinter: Address; - eventAuthority: Address; - program: Address; -}; - -export function getUnpauseInstruction< - TAccountPauser extends string, - TAccountTokenMinter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: UnpauseInput< - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UnpauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pauser: { value: input.pauser ?? null, isWritable: false }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pauser), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUnpauseInstructionDataEncoder().encode({}), - } as UnpauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUnpauseInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - pauser: TAccountMetas[0]; - tokenMinter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: UnpauseInstructionData; -}; - -export function parseUnpauseInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUnpauseInstruction { - if (instruction.accounts.length < 4) { - // 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: { - pauser: getNextAccount(), - tokenMinter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUnpauseInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/instructions/updatePauser.ts b/src/svm/clients/TokenMessengerMinter/instructions/updatePauser.ts deleted file mode 100644 index 2c2cb713f..000000000 --- a/src/svm/clients/TokenMessengerMinter/instructions/updatePauser.ts +++ /dev/null @@ -1,243 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UPDATE_PAUSER_DISCRIMINATOR = new Uint8Array([ - 140, 171, 211, 132, 57, 201, 16, 254, -]); - -export function getUpdatePauserDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - UPDATE_PAUSER_DISCRIMINATOR - ); -} - -export type UpdatePauserInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountTokenMinter extends string - ? WritableAccount - : TAccountTokenMinter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UpdatePauserInstructionData = { - discriminator: ReadonlyUint8Array; - newPauser: Address; -}; - -export type UpdatePauserInstructionDataArgs = { newPauser: Address }; - -export function getUpdatePauserInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newPauser', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: UPDATE_PAUSER_DISCRIMINATOR }) - ); -} - -export function getUpdatePauserInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newPauser', getAddressDecoder()], - ]); -} - -export function getUpdatePauserInstructionDataCodec(): Codec< - UpdatePauserInstructionDataArgs, - UpdatePauserInstructionData -> { - return combineCodec( - getUpdatePauserInstructionDataEncoder(), - getUpdatePauserInstructionDataDecoder() - ); -} - -export type UpdatePauserInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - tokenMinter: Address; - eventAuthority: Address; - program: Address; - newPauser: UpdatePauserInstructionDataArgs['newPauser']; -}; - -export function getUpdatePauserInstruction< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, ->( - input: UpdatePauserInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UpdatePauserInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUpdatePauserInstructionDataEncoder().encode( - args as UpdatePauserInstructionDataArgs - ), - } as UpdatePauserInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUpdatePauserInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - eventAuthority: TAccountMetas[3]; - program: TAccountMetas[4]; - }; - data: UpdatePauserInstructionData; -}; - -export function parseUpdatePauserInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUpdatePauserInstruction { - if (instruction.accounts.length < 5) { - // 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: { - owner: getNextAccount(), - tokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUpdatePauserInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinter/programs/index.ts b/src/svm/clients/TokenMessengerMinter/programs/index.ts deleted file mode 100644 index 1e005644b..000000000 --- a/src/svm/clients/TokenMessengerMinter/programs/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './tokenMessengerMinter'; diff --git a/src/svm/clients/TokenMessengerMinter/programs/tokenMessengerMinter.ts b/src/svm/clients/TokenMessengerMinter/programs/tokenMessengerMinter.ts deleted file mode 100644 index 27e6dbad7..000000000 --- a/src/svm/clients/TokenMessengerMinter/programs/tokenMessengerMinter.ts +++ /dev/null @@ -1,412 +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/kit'; -import { - type ParsedAcceptOwnershipInstruction, - type ParsedAddLocalTokenInstruction, - type ParsedAddRemoteTokenMessengerInstruction, - type ParsedBurnTokenCustodyInstruction, - type ParsedDepositForBurnInstruction, - type ParsedDepositForBurnWithCallerInstruction, - type ParsedHandleReceiveMessageInstruction, - type ParsedInitializeInstruction, - type ParsedLinkTokenPairInstruction, - type ParsedPauseInstruction, - type ParsedRemoveLocalTokenInstruction, - type ParsedRemoveRemoteTokenMessengerInstruction, - type ParsedReplaceDepositForBurnInstruction, - type ParsedSetMaxBurnAmountPerMessageInstruction, - type ParsedSetTokenControllerInstruction, - type ParsedTransferOwnershipInstruction, - type ParsedUnlinkTokenPairInstruction, - type ParsedUnpauseInstruction, - type ParsedUpdatePauserInstruction, -} from '../instructions'; - -export const TOKEN_MESSENGER_MINTER_PROGRAM_ADDRESS = - 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3' as Address<'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3'>; - -export enum TokenMessengerMinterAccount { - TokenMessenger, - RemoteTokenMessenger, - TokenMinter, - TokenPair, - LocalToken, -} - -export function identifyTokenMessengerMinterAccount( - account: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): TokenMessengerMinterAccount { - const data = 'data' in account ? account.data : account; - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([162, 4, 242, 52, 147, 243, 221, 96]) - ), - 0 - ) - ) { - return TokenMessengerMinterAccount.TokenMessenger; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([105, 115, 174, 34, 95, 233, 138, 252]) - ), - 0 - ) - ) { - return TokenMessengerMinterAccount.RemoteTokenMessenger; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([122, 133, 84, 63, 57, 159, 171, 206]) - ), - 0 - ) - ) { - return TokenMessengerMinterAccount.TokenMinter; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([17, 214, 45, 176, 229, 149, 197, 71]) - ), - 0 - ) - ) { - return TokenMessengerMinterAccount.TokenPair; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([159, 131, 58, 170, 193, 84, 128, 182]) - ), - 0 - ) - ) { - return TokenMessengerMinterAccount.LocalToken; - } - throw new Error( - 'The provided account could not be identified as a tokenMessengerMinter account.' - ); -} - -export enum TokenMessengerMinterInstruction { - Initialize, - TransferOwnership, - AcceptOwnership, - AddRemoteTokenMessenger, - RemoveRemoteTokenMessenger, - DepositForBurn, - DepositForBurnWithCaller, - ReplaceDepositForBurn, - HandleReceiveMessage, - SetTokenController, - Pause, - Unpause, - UpdatePauser, - SetMaxBurnAmountPerMessage, - AddLocalToken, - RemoveLocalToken, - LinkTokenPair, - UnlinkTokenPair, - BurnTokenCustody, -} - -export function identifyTokenMessengerMinterInstruction( - instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): TokenMessengerMinterInstruction { - 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 TokenMessengerMinterInstruction.Initialize; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.TransferOwnership; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([172, 23, 43, 13, 238, 213, 85, 150]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.AcceptOwnership; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([12, 149, 172, 165, 111, 202, 24, 33]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.AddRemoteTokenMessenger; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([65, 114, 66, 85, 169, 98, 177, 146]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.RemoveRemoteTokenMessenger; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([215, 60, 61, 46, 114, 55, 128, 176]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.DepositForBurn; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([167, 222, 19, 114, 85, 21, 14, 118]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.DepositForBurnWithCaller; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([7, 27, 93, 132, 1, 80, 19, 163]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.ReplaceDepositForBurn; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([133, 102, 1, 180, 145, 11, 138, 180]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.HandleReceiveMessage; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([88, 6, 98, 10, 79, 59, 15, 24]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.SetTokenController; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([211, 22, 221, 251, 74, 121, 193, 47]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.Pause; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([169, 144, 4, 38, 10, 141, 188, 255]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.Unpause; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([140, 171, 211, 132, 57, 201, 16, 254]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.UpdatePauser; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([30, 128, 145, 240, 70, 237, 109, 207]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.SetMaxBurnAmountPerMessage; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([213, 199, 205, 18, 98, 124, 73, 198]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.AddLocalToken; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([27, 43, 66, 170, 188, 44, 109, 97]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.RemoveLocalToken; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([68, 162, 24, 104, 125, 46, 130, 12]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.LinkTokenPair; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([52, 198, 100, 114, 104, 174, 85, 58]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.UnlinkTokenPair; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([233, 136, 180, 175, 112, 41, 62, 71]) - ), - 0 - ) - ) { - return TokenMessengerMinterInstruction.BurnTokenCustody; - } - throw new Error( - 'The provided instruction could not be identified as a tokenMessengerMinter instruction.' - ); -} - -export type ParsedTokenMessengerMinterInstruction< - TProgram extends string = 'CCTPiPYPc6AsJuwueEnWgSgucamXDZwBd53dQ11YiKX3', -> = - | ({ - instructionType: TokenMessengerMinterInstruction.Initialize; - } & ParsedInitializeInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.TransferOwnership; - } & ParsedTransferOwnershipInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.AcceptOwnership; - } & ParsedAcceptOwnershipInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.AddRemoteTokenMessenger; - } & ParsedAddRemoteTokenMessengerInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.RemoveRemoteTokenMessenger; - } & ParsedRemoveRemoteTokenMessengerInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.DepositForBurn; - } & ParsedDepositForBurnInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.DepositForBurnWithCaller; - } & ParsedDepositForBurnWithCallerInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.ReplaceDepositForBurn; - } & ParsedReplaceDepositForBurnInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.HandleReceiveMessage; - } & ParsedHandleReceiveMessageInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.SetTokenController; - } & ParsedSetTokenControllerInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.Pause; - } & ParsedPauseInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.Unpause; - } & ParsedUnpauseInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.UpdatePauser; - } & ParsedUpdatePauserInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.SetMaxBurnAmountPerMessage; - } & ParsedSetMaxBurnAmountPerMessageInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.AddLocalToken; - } & ParsedAddLocalTokenInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.RemoveLocalToken; - } & ParsedRemoveLocalTokenInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.LinkTokenPair; - } & ParsedLinkTokenPairInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.UnlinkTokenPair; - } & ParsedUnlinkTokenPairInstruction) - | ({ - instructionType: TokenMessengerMinterInstruction.BurnTokenCustody; - } & ParsedBurnTokenCustodyInstruction); diff --git a/src/svm/clients/TokenMessengerMinter/shared/index.ts b/src/svm/clients/TokenMessengerMinter/shared/index.ts deleted file mode 100644 index 7ebc26514..000000000 --- a/src/svm/clients/TokenMessengerMinter/shared/index.ts +++ /dev/null @@ -1,164 +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 { - AccountRole, - isProgramDerivedAddress, - isTransactionSigner as kitIsTransactionSigner, - type AccountMeta, - type AccountSignerMeta, - type Address, - type ProgramDerivedAddress, - type TransactionSigner, - upgradeRoleToSigner, -} from '@solana/kit'; - -/** - * Asserts that the given value is not null or undefined. - * @internal - */ -export function expectSome(value: T | null | undefined): T { - if (value == null) { - throw new Error('Expected a value but received null or undefined.'); - } - return value; -} - -/** - * Asserts that the given value is a PublicKey. - * @internal - */ -export function expectAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): Address { - if (!value) { - throw new Error('Expected a Address.'); - } - if (typeof value === 'object' && 'address' in value) { - return value.address; - } - if (Array.isArray(value)) { - return value[0]; - } - return value as Address; -} - -/** - * Asserts that the given value is a PDA. - * @internal - */ -export function expectProgramDerivedAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): ProgramDerivedAddress { - if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { - throw new Error('Expected a ProgramDerivedAddress.'); - } - return value; -} - -/** - * Asserts that the given value is a TransactionSigner. - * @internal - */ -export function expectTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): TransactionSigner { - if (!value || !isTransactionSigner(value)) { - throw new Error('Expected a TransactionSigner.'); - } - return value; -} - -/** - * Defines an instruction account to resolve. - * @internal - */ -export type ResolvedAccount< - T extends string = string, - U extends - | Address - | ProgramDerivedAddress - | TransactionSigner - | null = - | Address - | ProgramDerivedAddress - | TransactionSigner - | null, -> = { - isWritable: boolean; - value: U; -}; - -/** - * Defines an instruction that stores additional bytes on-chain. - * @internal - */ -export type InstructionWithByteDelta = { - byteDelta: number; -}; - -/** - * Get account metas and signers from resolved accounts. - * @internal - */ -export function getAccountMetaFactory( - programAddress: Address, - optionalAccountStrategy: 'omitted' | 'programId' -) { - return ( - account: ResolvedAccount - ): AccountMeta | AccountSignerMeta | undefined => { - if (!account.value) { - if (optionalAccountStrategy === 'omitted') return; - return Object.freeze({ - address: programAddress, - role: AccountRole.READONLY, - }); - } - - const writableRole = account.isWritable - ? AccountRole.WRITABLE - : AccountRole.READONLY; - return Object.freeze({ - address: expectAddress(account.value), - role: isTransactionSigner(account.value) - ? upgradeRoleToSigner(writableRole) - : writableRole, - ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), - }); - }; -} - -export function isTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner -): value is TransactionSigner { - return ( - !!value && - typeof value === 'object' && - 'address' in value && - kitIsTransactionSigner(value) - ); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/depositForBurn.ts b/src/svm/clients/TokenMessengerMinter/types/depositForBurn.ts deleted file mode 100644 index 63ac39add..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/depositForBurn.ts +++ /dev/null @@ -1,78 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type DepositForBurn = { - nonce: bigint; - burnToken: Address; - amount: bigint; - depositor: Address; - mintRecipient: Address; - destinationDomain: number; - destinationTokenMessenger: Address; - destinationCaller: Address; -}; - -export type DepositForBurnArgs = { - nonce: number | bigint; - burnToken: Address; - amount: number | bigint; - depositor: Address; - mintRecipient: Address; - destinationDomain: number; - destinationTokenMessenger: Address; - destinationCaller: Address; -}; - -export function getDepositForBurnEncoder(): Encoder { - return getStructEncoder([ - ['nonce', getU64Encoder()], - ['burnToken', getAddressEncoder()], - ['amount', getU64Encoder()], - ['depositor', getAddressEncoder()], - ['mintRecipient', getAddressEncoder()], - ['destinationDomain', getU32Encoder()], - ['destinationTokenMessenger', getAddressEncoder()], - ['destinationCaller', getAddressEncoder()], - ]); -} - -export function getDepositForBurnDecoder(): Decoder { - return getStructDecoder([ - ['nonce', getU64Decoder()], - ['burnToken', getAddressDecoder()], - ['amount', getU64Decoder()], - ['depositor', getAddressDecoder()], - ['mintRecipient', getAddressDecoder()], - ['destinationDomain', getU32Decoder()], - ['destinationTokenMessenger', getAddressDecoder()], - ['destinationCaller', getAddressDecoder()], - ]); -} - -export function getDepositForBurnCodec(): Codec< - DepositForBurnArgs, - DepositForBurn -> { - return combineCodec(getDepositForBurnEncoder(), getDepositForBurnDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/index.ts b/src/svm/clients/TokenMessengerMinter/types/index.ts deleted file mode 100644 index 65e320f19..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/index.ts +++ /dev/null @@ -1,25 +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 - */ - -export * from './depositForBurn'; -export * from './localTokenAdded'; -export * from './localTokenRemoved'; -export * from './mintAndWithdraw'; -export * from './ownershipTransferred'; -export * from './ownershipTransferStarted'; -export * from './pause'; -export * from './pauserChanged'; -export * from './remoteTokenMessengerAdded'; -export * from './remoteTokenMessengerRemoved'; -export * from './setBurnLimitPerMessage'; -export * from './setTokenController'; -export * from './tokenCustodyBurned'; -export * from './tokenMinterError'; -export * from './tokenPairLinked'; -export * from './tokenPairUnlinked'; -export * from './unpause'; diff --git a/src/svm/clients/TokenMessengerMinter/types/localTokenAdded.ts b/src/svm/clients/TokenMessengerMinter/types/localTokenAdded.ts deleted file mode 100644 index f74e5a7e5..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/localTokenAdded.ts +++ /dev/null @@ -1,44 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type LocalTokenAdded = { custody: Address; mint: Address }; - -export type LocalTokenAddedArgs = LocalTokenAdded; - -export function getLocalTokenAddedEncoder(): Encoder { - return getStructEncoder([ - ['custody', getAddressEncoder()], - ['mint', getAddressEncoder()], - ]); -} - -export function getLocalTokenAddedDecoder(): Decoder { - return getStructDecoder([ - ['custody', getAddressDecoder()], - ['mint', getAddressDecoder()], - ]); -} - -export function getLocalTokenAddedCodec(): Codec< - LocalTokenAddedArgs, - LocalTokenAdded -> { - return combineCodec(getLocalTokenAddedEncoder(), getLocalTokenAddedDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/localTokenRemoved.ts b/src/svm/clients/TokenMessengerMinter/types/localTokenRemoved.ts deleted file mode 100644 index 813080526..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/localTokenRemoved.ts +++ /dev/null @@ -1,47 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type LocalTokenRemoved = { custody: Address; mint: Address }; - -export type LocalTokenRemovedArgs = LocalTokenRemoved; - -export function getLocalTokenRemovedEncoder(): Encoder { - return getStructEncoder([ - ['custody', getAddressEncoder()], - ['mint', getAddressEncoder()], - ]); -} - -export function getLocalTokenRemovedDecoder(): Decoder { - return getStructDecoder([ - ['custody', getAddressDecoder()], - ['mint', getAddressDecoder()], - ]); -} - -export function getLocalTokenRemovedCodec(): Codec< - LocalTokenRemovedArgs, - LocalTokenRemoved -> { - return combineCodec( - getLocalTokenRemovedEncoder(), - getLocalTokenRemovedDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/mintAndWithdraw.ts b/src/svm/clients/TokenMessengerMinter/types/mintAndWithdraw.ts deleted file mode 100644 index b98ae340d..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/mintAndWithdraw.ts +++ /dev/null @@ -1,56 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type MintAndWithdraw = { - mintRecipient: Address; - amount: bigint; - mintToken: Address; -}; - -export type MintAndWithdrawArgs = { - mintRecipient: Address; - amount: number | bigint; - mintToken: Address; -}; - -export function getMintAndWithdrawEncoder(): Encoder { - return getStructEncoder([ - ['mintRecipient', getAddressEncoder()], - ['amount', getU64Encoder()], - ['mintToken', getAddressEncoder()], - ]); -} - -export function getMintAndWithdrawDecoder(): Decoder { - return getStructDecoder([ - ['mintRecipient', getAddressDecoder()], - ['amount', getU64Decoder()], - ['mintToken', getAddressDecoder()], - ]); -} - -export function getMintAndWithdrawCodec(): Codec< - MintAndWithdrawArgs, - MintAndWithdraw -> { - return combineCodec(getMintAndWithdrawEncoder(), getMintAndWithdrawDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/ownershipTransferStarted.ts b/src/svm/clients/TokenMessengerMinter/types/ownershipTransferStarted.ts deleted file mode 100644 index e170a569a..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/ownershipTransferStarted.ts +++ /dev/null @@ -1,50 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type OwnershipTransferStarted = { - previousOwner: Address; - newOwner: Address; -}; - -export type OwnershipTransferStartedArgs = OwnershipTransferStarted; - -export function getOwnershipTransferStartedEncoder(): Encoder { - return getStructEncoder([ - ['previousOwner', getAddressEncoder()], - ['newOwner', getAddressEncoder()], - ]); -} - -export function getOwnershipTransferStartedDecoder(): Decoder { - return getStructDecoder([ - ['previousOwner', getAddressDecoder()], - ['newOwner', getAddressDecoder()], - ]); -} - -export function getOwnershipTransferStartedCodec(): Codec< - OwnershipTransferStartedArgs, - OwnershipTransferStarted -> { - return combineCodec( - getOwnershipTransferStartedEncoder(), - getOwnershipTransferStartedDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/ownershipTransferred.ts b/src/svm/clients/TokenMessengerMinter/types/ownershipTransferred.ts deleted file mode 100644 index 40f21c661..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/ownershipTransferred.ts +++ /dev/null @@ -1,50 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type OwnershipTransferred = { - previousOwner: Address; - newOwner: Address; -}; - -export type OwnershipTransferredArgs = OwnershipTransferred; - -export function getOwnershipTransferredEncoder(): Encoder { - return getStructEncoder([ - ['previousOwner', getAddressEncoder()], - ['newOwner', getAddressEncoder()], - ]); -} - -export function getOwnershipTransferredDecoder(): Decoder { - return getStructDecoder([ - ['previousOwner', getAddressDecoder()], - ['newOwner', getAddressDecoder()], - ]); -} - -export function getOwnershipTransferredCodec(): Codec< - OwnershipTransferredArgs, - OwnershipTransferred -> { - return combineCodec( - getOwnershipTransferredEncoder(), - getOwnershipTransferredDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/pause.ts b/src/svm/clients/TokenMessengerMinter/types/pause.ts deleted file mode 100644 index f1f423325..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/pause.ts +++ /dev/null @@ -1,32 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type Pause = {}; - -export type PauseArgs = Pause; - -export function getPauseEncoder(): Encoder { - return getStructEncoder([]); -} - -export function getPauseDecoder(): Decoder { - return getStructDecoder([]); -} - -export function getPauseCodec(): Codec { - return combineCodec(getPauseEncoder(), getPauseDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/pauserChanged.ts b/src/svm/clients/TokenMessengerMinter/types/pauserChanged.ts deleted file mode 100644 index 57d7433da..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/pauserChanged.ts +++ /dev/null @@ -1,38 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type PauserChanged = { newAddress: Address }; - -export type PauserChangedArgs = PauserChanged; - -export function getPauserChangedEncoder(): Encoder { - return getStructEncoder([['newAddress', getAddressEncoder()]]); -} - -export function getPauserChangedDecoder(): Decoder { - return getStructDecoder([['newAddress', getAddressDecoder()]]); -} - -export function getPauserChangedCodec(): Codec< - PauserChangedArgs, - PauserChanged -> { - return combineCodec(getPauserChangedEncoder(), getPauserChangedDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerAdded.ts b/src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerAdded.ts deleted file mode 100644 index f2586db0b..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerAdded.ts +++ /dev/null @@ -1,52 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type RemoteTokenMessengerAdded = { - domain: number; - tokenMessenger: Address; -}; - -export type RemoteTokenMessengerAddedArgs = RemoteTokenMessengerAdded; - -export function getRemoteTokenMessengerAddedEncoder(): Encoder { - return getStructEncoder([ - ['domain', getU32Encoder()], - ['tokenMessenger', getAddressEncoder()], - ]); -} - -export function getRemoteTokenMessengerAddedDecoder(): Decoder { - return getStructDecoder([ - ['domain', getU32Decoder()], - ['tokenMessenger', getAddressDecoder()], - ]); -} - -export function getRemoteTokenMessengerAddedCodec(): Codec< - RemoteTokenMessengerAddedArgs, - RemoteTokenMessengerAdded -> { - return combineCodec( - getRemoteTokenMessengerAddedEncoder(), - getRemoteTokenMessengerAddedDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerRemoved.ts b/src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerRemoved.ts deleted file mode 100644 index 290c643bc..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/remoteTokenMessengerRemoved.ts +++ /dev/null @@ -1,52 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type RemoteTokenMessengerRemoved = { - domain: number; - tokenMessenger: Address; -}; - -export type RemoteTokenMessengerRemovedArgs = RemoteTokenMessengerRemoved; - -export function getRemoteTokenMessengerRemovedEncoder(): Encoder { - return getStructEncoder([ - ['domain', getU32Encoder()], - ['tokenMessenger', getAddressEncoder()], - ]); -} - -export function getRemoteTokenMessengerRemovedDecoder(): Decoder { - return getStructDecoder([ - ['domain', getU32Decoder()], - ['tokenMessenger', getAddressDecoder()], - ]); -} - -export function getRemoteTokenMessengerRemovedCodec(): Codec< - RemoteTokenMessengerRemovedArgs, - RemoteTokenMessengerRemoved -> { - return combineCodec( - getRemoteTokenMessengerRemovedEncoder(), - getRemoteTokenMessengerRemovedDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/setBurnLimitPerMessage.ts b/src/svm/clients/TokenMessengerMinter/types/setBurnLimitPerMessage.ts deleted file mode 100644 index 8c28725c2..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/setBurnLimitPerMessage.ts +++ /dev/null @@ -1,55 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type SetBurnLimitPerMessage = { - token: Address; - burnLimitPerMessage: bigint; -}; - -export type SetBurnLimitPerMessageArgs = { - token: Address; - burnLimitPerMessage: number | bigint; -}; - -export function getSetBurnLimitPerMessageEncoder(): Encoder { - return getStructEncoder([ - ['token', getAddressEncoder()], - ['burnLimitPerMessage', getU64Encoder()], - ]); -} - -export function getSetBurnLimitPerMessageDecoder(): Decoder { - return getStructDecoder([ - ['token', getAddressDecoder()], - ['burnLimitPerMessage', getU64Decoder()], - ]); -} - -export function getSetBurnLimitPerMessageCodec(): Codec< - SetBurnLimitPerMessageArgs, - SetBurnLimitPerMessage -> { - return combineCodec( - getSetBurnLimitPerMessageEncoder(), - getSetBurnLimitPerMessageDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/setTokenController.ts b/src/svm/clients/TokenMessengerMinter/types/setTokenController.ts deleted file mode 100644 index 3b6c01571..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/setTokenController.ts +++ /dev/null @@ -1,41 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type SetTokenController = { tokenController: Address }; - -export type SetTokenControllerArgs = SetTokenController; - -export function getSetTokenControllerEncoder(): Encoder { - return getStructEncoder([['tokenController', getAddressEncoder()]]); -} - -export function getSetTokenControllerDecoder(): Decoder { - return getStructDecoder([['tokenController', getAddressDecoder()]]); -} - -export function getSetTokenControllerCodec(): Codec< - SetTokenControllerArgs, - SetTokenController -> { - return combineCodec( - getSetTokenControllerEncoder(), - getSetTokenControllerDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/tokenCustodyBurned.ts b/src/svm/clients/TokenMessengerMinter/types/tokenCustodyBurned.ts deleted file mode 100644 index 4b90fc0d7..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/tokenCustodyBurned.ts +++ /dev/null @@ -1,55 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type TokenCustodyBurned = { - custodyTokenAccount: Address; - amount: bigint; -}; - -export type TokenCustodyBurnedArgs = { - custodyTokenAccount: Address; - amount: number | bigint; -}; - -export function getTokenCustodyBurnedEncoder(): Encoder { - return getStructEncoder([ - ['custodyTokenAccount', getAddressEncoder()], - ['amount', getU64Encoder()], - ]); -} - -export function getTokenCustodyBurnedDecoder(): Decoder { - return getStructDecoder([ - ['custodyTokenAccount', getAddressDecoder()], - ['amount', getU64Decoder()], - ]); -} - -export function getTokenCustodyBurnedCodec(): Codec< - TokenCustodyBurnedArgs, - TokenCustodyBurned -> { - return combineCodec( - getTokenCustodyBurnedEncoder(), - getTokenCustodyBurnedDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/tokenMinterError.ts b/src/svm/clients/TokenMessengerMinter/types/tokenMinterError.ts deleted file mode 100644 index 298c968de..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/tokenMinterError.ts +++ /dev/null @@ -1,48 +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 { - combineCodec, - getEnumDecoder, - getEnumEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export enum TokenMinterError { - InvalidAuthority, - InvalidTokenMinterState, - ProgramPaused, - InvalidTokenPairState, - InvalidLocalTokenState, - InvalidPauser, - InvalidTokenController, - BurnAmountExceeded, - InvalidAmount, -} - -export type TokenMinterErrorArgs = TokenMinterError; - -export function getTokenMinterErrorEncoder(): Encoder { - return getEnumEncoder(TokenMinterError); -} - -export function getTokenMinterErrorDecoder(): Decoder { - return getEnumDecoder(TokenMinterError); -} - -export function getTokenMinterErrorCodec(): Codec< - TokenMinterErrorArgs, - TokenMinterError -> { - return combineCodec( - getTokenMinterErrorEncoder(), - getTokenMinterErrorDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/tokenPairLinked.ts b/src/svm/clients/TokenMessengerMinter/types/tokenPairLinked.ts deleted file mode 100644 index 3d4e2027d..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/tokenPairLinked.ts +++ /dev/null @@ -1,52 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type TokenPairLinked = { - localToken: Address; - remoteDomain: number; - remoteToken: Address; -}; - -export type TokenPairLinkedArgs = TokenPairLinked; - -export function getTokenPairLinkedEncoder(): Encoder { - return getStructEncoder([ - ['localToken', getAddressEncoder()], - ['remoteDomain', getU32Encoder()], - ['remoteToken', getAddressEncoder()], - ]); -} - -export function getTokenPairLinkedDecoder(): Decoder { - return getStructDecoder([ - ['localToken', getAddressDecoder()], - ['remoteDomain', getU32Decoder()], - ['remoteToken', getAddressDecoder()], - ]); -} - -export function getTokenPairLinkedCodec(): Codec< - TokenPairLinkedArgs, - TokenPairLinked -> { - return combineCodec(getTokenPairLinkedEncoder(), getTokenPairLinkedDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/tokenPairUnlinked.ts b/src/svm/clients/TokenMessengerMinter/types/tokenPairUnlinked.ts deleted file mode 100644 index 714376fdd..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/tokenPairUnlinked.ts +++ /dev/null @@ -1,55 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type TokenPairUnlinked = { - localToken: Address; - remoteDomain: number; - remoteToken: Address; -}; - -export type TokenPairUnlinkedArgs = TokenPairUnlinked; - -export function getTokenPairUnlinkedEncoder(): Encoder { - return getStructEncoder([ - ['localToken', getAddressEncoder()], - ['remoteDomain', getU32Encoder()], - ['remoteToken', getAddressEncoder()], - ]); -} - -export function getTokenPairUnlinkedDecoder(): Decoder { - return getStructDecoder([ - ['localToken', getAddressDecoder()], - ['remoteDomain', getU32Decoder()], - ['remoteToken', getAddressDecoder()], - ]); -} - -export function getTokenPairUnlinkedCodec(): Codec< - TokenPairUnlinkedArgs, - TokenPairUnlinked -> { - return combineCodec( - getTokenPairUnlinkedEncoder(), - getTokenPairUnlinkedDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinter/types/unpause.ts b/src/svm/clients/TokenMessengerMinter/types/unpause.ts deleted file mode 100644 index 4fdc009ef..000000000 --- a/src/svm/clients/TokenMessengerMinter/types/unpause.ts +++ /dev/null @@ -1,32 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type Unpause = {}; - -export type UnpauseArgs = Unpause; - -export function getUnpauseEncoder(): Encoder { - return getStructEncoder([]); -} - -export function getUnpauseDecoder(): Decoder { - return getStructDecoder([]); -} - -export function getUnpauseCodec(): Codec { - return combineCodec(getUnpauseEncoder(), getUnpauseDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/denylistedAccount.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/denylistedAccount.ts deleted file mode 100644 index 54b87bfa7..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/accounts/denylistedAccount.ts +++ /dev/null @@ -1,147 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const DENYLISTED_ACCOUNT_DISCRIMINATOR = new Uint8Array([ - 186, 58, 212, 239, 102, 131, 157, 146, -]); - -export function getDenylistedAccountDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - DENYLISTED_ACCOUNT_DISCRIMINATOR - ); -} - -export type DenylistedAccount = { - discriminator: ReadonlyUint8Array; - account: Address; -}; - -export type DenylistedAccountArgs = { account: Address }; - -export function getDenylistedAccountEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['account', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: DENYLISTED_ACCOUNT_DISCRIMINATOR }) - ); -} - -export function getDenylistedAccountDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['account', getAddressDecoder()], - ]); -} - -export function getDenylistedAccountCodec(): Codec< - DenylistedAccountArgs, - DenylistedAccount -> { - return combineCodec( - getDenylistedAccountEncoder(), - getDenylistedAccountDecoder() - ); -} - -export function decodeDenylistedAccount( - encodedAccount: EncodedAccount -): Account; -export function decodeDenylistedAccount( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeDenylistedAccount( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): - | Account - | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getDenylistedAccountDecoder() - ); -} - -export async function fetchDenylistedAccount( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeDenylistedAccount(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeDenylistedAccount< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeDenylistedAccount(maybeAccount); -} - -export async function fetchAllDenylistedAccount( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeDenylistedAccount( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeDenylistedAccount( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeDenylistedAccount(maybeAccount) - ); -} - -export function getDenylistedAccountSize(): number { - return 40; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/index.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/index.ts deleted file mode 100644 index 5fc20562f..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/accounts/index.ts +++ /dev/null @@ -1,15 +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 - */ - -export * from './denylistedAccount'; -export * from './localToken'; -export * from './messageTransmitter'; -export * from './remoteTokenMessenger'; -export * from './tokenMessenger'; -export * from './tokenMinter'; -export * from './tokenPair'; diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/localToken.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/localToken.ts deleted file mode 100644 index 9db5966c7..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/accounts/localToken.ts +++ /dev/null @@ -1,169 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU128Decoder, - getU128Encoder, - getU64Decoder, - getU64Encoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const LOCAL_TOKEN_DISCRIMINATOR = new Uint8Array([ - 159, 131, 58, 170, 193, 84, 128, 182, -]); - -export function getLocalTokenDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(LOCAL_TOKEN_DISCRIMINATOR); -} - -export type LocalToken = { - discriminator: ReadonlyUint8Array; - custody: Address; - mint: Address; - burnLimitPerMessage: bigint; - messagesSent: bigint; - messagesReceived: bigint; - amountSent: bigint; - amountReceived: bigint; - bump: number; - custodyBump: number; -}; - -export type LocalTokenArgs = { - custody: Address; - mint: Address; - burnLimitPerMessage: number | bigint; - messagesSent: number | bigint; - messagesReceived: number | bigint; - amountSent: number | bigint; - amountReceived: number | bigint; - bump: number; - custodyBump: number; -}; - -export function getLocalTokenEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['custody', getAddressEncoder()], - ['mint', getAddressEncoder()], - ['burnLimitPerMessage', getU64Encoder()], - ['messagesSent', getU64Encoder()], - ['messagesReceived', getU64Encoder()], - ['amountSent', getU128Encoder()], - ['amountReceived', getU128Encoder()], - ['bump', getU8Encoder()], - ['custodyBump', getU8Encoder()], - ]), - (value) => ({ ...value, discriminator: LOCAL_TOKEN_DISCRIMINATOR }) - ); -} - -export function getLocalTokenDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['custody', getAddressDecoder()], - ['mint', getAddressDecoder()], - ['burnLimitPerMessage', getU64Decoder()], - ['messagesSent', getU64Decoder()], - ['messagesReceived', getU64Decoder()], - ['amountSent', getU128Decoder()], - ['amountReceived', getU128Decoder()], - ['bump', getU8Decoder()], - ['custodyBump', getU8Decoder()], - ]); -} - -export function getLocalTokenCodec(): Codec { - return combineCodec(getLocalTokenEncoder(), getLocalTokenDecoder()); -} - -export function decodeLocalToken( - encodedAccount: EncodedAccount -): Account; -export function decodeLocalToken( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeLocalToken( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getLocalTokenDecoder() - ); -} - -export async function fetchLocalToken( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeLocalToken(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeLocalToken( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeLocalToken(maybeAccount); -} - -export async function fetchAllLocalToken( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeLocalToken(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeLocalToken( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeLocalToken(maybeAccount)); -} - -export function getLocalTokenSize(): number { - return 130; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/messageTransmitter.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/messageTransmitter.ts deleted file mode 100644 index 7f6c300df..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/accounts/messageTransmitter.ts +++ /dev/null @@ -1,189 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getArrayDecoder, - getArrayEncoder, - getBooleanDecoder, - getBooleanEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const MESSAGE_TRANSMITTER_DISCRIMINATOR = new Uint8Array([ - 71, 40, 180, 142, 19, 203, 35, 252, -]); - -export function getMessageTransmitterDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - MESSAGE_TRANSMITTER_DISCRIMINATOR - ); -} - -export type MessageTransmitter = { - discriminator: ReadonlyUint8Array; - owner: Address; - pendingOwner: Address; - attesterManager: Address; - pauser: Address; - paused: boolean; - localDomain: number; - version: number; - signatureThreshold: number; - enabledAttesters: Array
; - maxMessageBodySize: bigint; -}; - -export type MessageTransmitterArgs = { - owner: Address; - pendingOwner: Address; - attesterManager: Address; - pauser: Address; - paused: boolean; - localDomain: number; - version: number; - signatureThreshold: number; - enabledAttesters: Array
; - maxMessageBodySize: number | bigint; -}; - -export function getMessageTransmitterEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['owner', getAddressEncoder()], - ['pendingOwner', getAddressEncoder()], - ['attesterManager', getAddressEncoder()], - ['pauser', getAddressEncoder()], - ['paused', getBooleanEncoder()], - ['localDomain', getU32Encoder()], - ['version', getU32Encoder()], - ['signatureThreshold', getU32Encoder()], - ['enabledAttesters', getArrayEncoder(getAddressEncoder())], - ['maxMessageBodySize', getU64Encoder()], - ]), - (value) => ({ ...value, discriminator: MESSAGE_TRANSMITTER_DISCRIMINATOR }) - ); -} - -export function getMessageTransmitterDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['owner', getAddressDecoder()], - ['pendingOwner', getAddressDecoder()], - ['attesterManager', getAddressDecoder()], - ['pauser', getAddressDecoder()], - ['paused', getBooleanDecoder()], - ['localDomain', getU32Decoder()], - ['version', getU32Decoder()], - ['signatureThreshold', getU32Decoder()], - ['enabledAttesters', getArrayDecoder(getAddressDecoder())], - ['maxMessageBodySize', getU64Decoder()], - ]); -} - -export function getMessageTransmitterCodec(): Codec< - MessageTransmitterArgs, - MessageTransmitter -> { - return combineCodec( - getMessageTransmitterEncoder(), - getMessageTransmitterDecoder() - ); -} - -export function decodeMessageTransmitter( - encodedAccount: EncodedAccount -): Account; -export function decodeMessageTransmitter( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeMessageTransmitter( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): - | Account - | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getMessageTransmitterDecoder() - ); -} - -export async function fetchMessageTransmitter( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeMessageTransmitter(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeMessageTransmitter< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeMessageTransmitter(maybeAccount); -} - -export async function fetchAllMessageTransmitter( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeMessageTransmitter( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeMessageTransmitter( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeMessageTransmitter(maybeAccount) - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/remoteTokenMessenger.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/remoteTokenMessenger.ts deleted file mode 100644 index a2bbc7ecf..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/accounts/remoteTokenMessenger.ts +++ /dev/null @@ -1,164 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const REMOTE_TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ - 105, 115, 174, 34, 95, 233, 138, 252, -]); - -export function getRemoteTokenMessengerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - REMOTE_TOKEN_MESSENGER_DISCRIMINATOR - ); -} - -export type RemoteTokenMessenger = { - discriminator: ReadonlyUint8Array; - domain: number; - tokenMessenger: Address; -}; - -export type RemoteTokenMessengerArgs = { - domain: number; - tokenMessenger: Address; -}; - -export function getRemoteTokenMessengerEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['domain', getU32Encoder()], - ['tokenMessenger', getAddressEncoder()], - ]), - (value) => ({ - ...value, - discriminator: REMOTE_TOKEN_MESSENGER_DISCRIMINATOR, - }) - ); -} - -export function getRemoteTokenMessengerDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['domain', getU32Decoder()], - ['tokenMessenger', getAddressDecoder()], - ]); -} - -export function getRemoteTokenMessengerCodec(): Codec< - RemoteTokenMessengerArgs, - RemoteTokenMessenger -> { - return combineCodec( - getRemoteTokenMessengerEncoder(), - getRemoteTokenMessengerDecoder() - ); -} - -export function decodeRemoteTokenMessenger( - encodedAccount: EncodedAccount -): Account; -export function decodeRemoteTokenMessenger( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeRemoteTokenMessenger( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): - | Account - | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getRemoteTokenMessengerDecoder() - ); -} - -export async function fetchRemoteTokenMessenger< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeRemoteTokenMessenger( - rpc, - address, - config - ); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeRemoteTokenMessenger< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeRemoteTokenMessenger(maybeAccount); -} - -export async function fetchAllRemoteTokenMessenger( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeRemoteTokenMessenger( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeRemoteTokenMessenger( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeRemoteTokenMessenger(maybeAccount) - ); -} - -export function getRemoteTokenMessengerSize(): number { - return 44; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/tokenMessenger.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/tokenMessenger.ts deleted file mode 100644 index 72bbc9716..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/accounts/tokenMessenger.ts +++ /dev/null @@ -1,176 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ - 162, 4, 242, 52, 147, 243, 221, 96, -]); - -export function getTokenMessengerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - TOKEN_MESSENGER_DISCRIMINATOR - ); -} - -export type TokenMessenger = { - discriminator: ReadonlyUint8Array; - denylister: Address; - owner: Address; - pendingOwner: Address; - messageBodyVersion: number; - authorityBump: number; - feeRecipient: Address; - minFeeController: Address; - minFee: number; -}; - -export type TokenMessengerArgs = { - denylister: Address; - owner: Address; - pendingOwner: Address; - messageBodyVersion: number; - authorityBump: number; - feeRecipient: Address; - minFeeController: Address; - minFee: number; -}; - -export function getTokenMessengerEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['denylister', getAddressEncoder()], - ['owner', getAddressEncoder()], - ['pendingOwner', getAddressEncoder()], - ['messageBodyVersion', getU32Encoder()], - ['authorityBump', getU8Encoder()], - ['feeRecipient', getAddressEncoder()], - ['minFeeController', getAddressEncoder()], - ['minFee', getU32Encoder()], - ]), - (value) => ({ ...value, discriminator: TOKEN_MESSENGER_DISCRIMINATOR }) - ); -} - -export function getTokenMessengerDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['denylister', getAddressDecoder()], - ['owner', getAddressDecoder()], - ['pendingOwner', getAddressDecoder()], - ['messageBodyVersion', getU32Decoder()], - ['authorityBump', getU8Decoder()], - ['feeRecipient', getAddressDecoder()], - ['minFeeController', getAddressDecoder()], - ['minFee', getU32Decoder()], - ]); -} - -export function getTokenMessengerCodec(): Codec< - TokenMessengerArgs, - TokenMessenger -> { - return combineCodec(getTokenMessengerEncoder(), getTokenMessengerDecoder()); -} - -export function decodeTokenMessenger( - encodedAccount: EncodedAccount -): Account; -export function decodeTokenMessenger( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeTokenMessenger( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getTokenMessengerDecoder() - ); -} - -export async function fetchTokenMessenger( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeTokenMessenger(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeTokenMessenger< - TAddress extends string = string, ->( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeTokenMessenger(maybeAccount); -} - -export async function fetchAllTokenMessenger( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeTokenMessenger( - rpc, - addresses, - config - ); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeTokenMessenger( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => - decodeTokenMessenger(maybeAccount) - ); -} - -export function getTokenMessengerSize(): number { - return 177; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/tokenMinter.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/tokenMinter.ts deleted file mode 100644 index e522ef79d..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/accounts/tokenMinter.ts +++ /dev/null @@ -1,149 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBooleanDecoder, - getBooleanEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const TOKEN_MINTER_DISCRIMINATOR = new Uint8Array([ - 122, 133, 84, 63, 57, 159, 171, 206, -]); - -export function getTokenMinterDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - TOKEN_MINTER_DISCRIMINATOR - ); -} - -export type TokenMinter = { - discriminator: ReadonlyUint8Array; - tokenController: Address; - pauser: Address; - paused: boolean; - bump: number; -}; - -export type TokenMinterArgs = { - tokenController: Address; - pauser: Address; - paused: boolean; - bump: number; -}; - -export function getTokenMinterEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['tokenController', getAddressEncoder()], - ['pauser', getAddressEncoder()], - ['paused', getBooleanEncoder()], - ['bump', getU8Encoder()], - ]), - (value) => ({ ...value, discriminator: TOKEN_MINTER_DISCRIMINATOR }) - ); -} - -export function getTokenMinterDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['tokenController', getAddressDecoder()], - ['pauser', getAddressDecoder()], - ['paused', getBooleanDecoder()], - ['bump', getU8Decoder()], - ]); -} - -export function getTokenMinterCodec(): Codec { - return combineCodec(getTokenMinterEncoder(), getTokenMinterDecoder()); -} - -export function decodeTokenMinter( - encodedAccount: EncodedAccount -): Account; -export function decodeTokenMinter( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeTokenMinter( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getTokenMinterDecoder() - ); -} - -export async function fetchTokenMinter( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeTokenMinter(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeTokenMinter( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeTokenMinter(maybeAccount); -} - -export async function fetchAllTokenMinter( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeTokenMinter(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeTokenMinter( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeTokenMinter(maybeAccount)); -} - -export function getTokenMinterSize(): number { - return 74; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/accounts/tokenPair.ts b/src/svm/clients/TokenMessengerMinterV2/accounts/tokenPair.ts deleted file mode 100644 index 40fee5627..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/accounts/tokenPair.ts +++ /dev/null @@ -1,147 +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 { - assertAccountExists, - assertAccountsExist, - combineCodec, - decodeAccount, - fetchEncodedAccount, - fetchEncodedAccounts, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU8Decoder, - getU8Encoder, - transformEncoder, - type Account, - type Address, - type Codec, - type Decoder, - type EncodedAccount, - type Encoder, - type FetchAccountConfig, - type FetchAccountsConfig, - type MaybeAccount, - type MaybeEncodedAccount, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export const TOKEN_PAIR_DISCRIMINATOR = new Uint8Array([ - 17, 214, 45, 176, 229, 149, 197, 71, -]); - -export function getTokenPairDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(TOKEN_PAIR_DISCRIMINATOR); -} - -export type TokenPair = { - discriminator: ReadonlyUint8Array; - remoteDomain: number; - remoteToken: Address; - localToken: Address; - bump: number; -}; - -export type TokenPairArgs = { - remoteDomain: number; - remoteToken: Address; - localToken: Address; - bump: number; -}; - -export function getTokenPairEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['remoteDomain', getU32Encoder()], - ['remoteToken', getAddressEncoder()], - ['localToken', getAddressEncoder()], - ['bump', getU8Encoder()], - ]), - (value) => ({ ...value, discriminator: TOKEN_PAIR_DISCRIMINATOR }) - ); -} - -export function getTokenPairDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['remoteDomain', getU32Decoder()], - ['remoteToken', getAddressDecoder()], - ['localToken', getAddressDecoder()], - ['bump', getU8Decoder()], - ]); -} - -export function getTokenPairCodec(): Codec { - return combineCodec(getTokenPairEncoder(), getTokenPairDecoder()); -} - -export function decodeTokenPair( - encodedAccount: EncodedAccount -): Account; -export function decodeTokenPair( - encodedAccount: MaybeEncodedAccount -): MaybeAccount; -export function decodeTokenPair( - encodedAccount: EncodedAccount | MaybeEncodedAccount -): Account | MaybeAccount { - return decodeAccount( - encodedAccount as MaybeEncodedAccount, - getTokenPairDecoder() - ); -} - -export async function fetchTokenPair( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchMaybeTokenPair(rpc, address, config); - assertAccountExists(maybeAccount); - return maybeAccount; -} - -export async function fetchMaybeTokenPair( - rpc: Parameters[0], - address: Address, - config?: FetchAccountConfig -): Promise> { - const maybeAccount = await fetchEncodedAccount(rpc, address, config); - return decodeTokenPair(maybeAccount); -} - -export async function fetchAllTokenPair( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchAllMaybeTokenPair(rpc, addresses, config); - assertAccountsExist(maybeAccounts); - return maybeAccounts; -} - -export async function fetchAllMaybeTokenPair( - rpc: Parameters[0], - addresses: Array
, - config?: FetchAccountsConfig -): Promise[]> { - const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config); - return maybeAccounts.map((maybeAccount) => decodeTokenPair(maybeAccount)); -} - -export function getTokenPairSize(): number { - return 77; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/errors/index.ts b/src/svm/clients/TokenMessengerMinterV2/errors/index.ts deleted file mode 100644 index f2cacc30e..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/errors/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './tokenMessengerMinterV2'; diff --git a/src/svm/clients/TokenMessengerMinterV2/errors/tokenMessengerMinterV2.ts b/src/svm/clients/TokenMessengerMinterV2/errors/tokenMessengerMinterV2.ts deleted file mode 100644 index 7d01d6fce..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/errors/tokenMessengerMinterV2.ts +++ /dev/null @@ -1,95 +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 { - isProgramError, - type Address, - type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, - type SolanaError, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; - -/** InvalidAuthority: Invalid authority */ -export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_AUTHORITY = 0x1770; // 6000 -/** InvalidTokenMinterState: Invalid token minter state */ -export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_MINTER_STATE = 0x1771; // 6001 -/** ProgramPaused: Instruction is not allowed at this time */ -export const TOKEN_MESSENGER_MINTER_V2_ERROR__PROGRAM_PAUSED = 0x1772; // 6002 -/** InvalidTokenPairState: Invalid token pair state */ -export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_PAIR_STATE = 0x1773; // 6003 -/** InvalidLocalTokenState: Invalid local token state */ -export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_LOCAL_TOKEN_STATE = 0x1774; // 6004 -/** InvalidPauser: Invalid pauser */ -export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_PAUSER = 0x1775; // 6005 -/** InvalidTokenController: Invalid token controller */ -export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_CONTROLLER = 0x1776; // 6006 -/** BurnAmountExceeded: Burn amount exceeded */ -export const TOKEN_MESSENGER_MINTER_V2_ERROR__BURN_AMOUNT_EXCEEDED = 0x1777; // 6007 -/** InvalidAmount: Invalid amount */ -export const TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_AMOUNT = 0x1778; // 6008 - -export type TokenMessengerMinterV2Error = - | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__BURN_AMOUNT_EXCEEDED - | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_AMOUNT - | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_AUTHORITY - | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_LOCAL_TOKEN_STATE - | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_PAUSER - | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_CONTROLLER - | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_MINTER_STATE - | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_PAIR_STATE - | typeof TOKEN_MESSENGER_MINTER_V2_ERROR__PROGRAM_PAUSED; - -let tokenMessengerMinterV2ErrorMessages: - | Record - | undefined; -if (process.env.NODE_ENV !== 'production') { - tokenMessengerMinterV2ErrorMessages = { - [TOKEN_MESSENGER_MINTER_V2_ERROR__BURN_AMOUNT_EXCEEDED]: `Burn amount exceeded`, - [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_AMOUNT]: `Invalid amount`, - [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_AUTHORITY]: `Invalid authority`, - [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_LOCAL_TOKEN_STATE]: `Invalid local token state`, - [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_PAUSER]: `Invalid pauser`, - [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_CONTROLLER]: `Invalid token controller`, - [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_MINTER_STATE]: `Invalid token minter state`, - [TOKEN_MESSENGER_MINTER_V2_ERROR__INVALID_TOKEN_PAIR_STATE]: `Invalid token pair state`, - [TOKEN_MESSENGER_MINTER_V2_ERROR__PROGRAM_PAUSED]: `Instruction is not allowed at this time`, - }; -} - -export function getTokenMessengerMinterV2ErrorMessage( - code: TokenMessengerMinterV2Error -): string { - if (process.env.NODE_ENV !== 'production') { - return ( - tokenMessengerMinterV2ErrorMessages as Record< - TokenMessengerMinterV2Error, - string - > - )[code]; - } - - return 'Error message not available in production bundles.'; -} - -export function isTokenMessengerMinterV2Error< - TProgramErrorCode extends TokenMessengerMinterV2Error, ->( - error: unknown, - transactionMessage: { - instructions: Record; - }, - code?: TProgramErrorCode -): error is SolanaError & - Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { - return isProgramError( - error, - transactionMessage, - TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - code - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/index.ts b/src/svm/clients/TokenMessengerMinterV2/index.ts deleted file mode 100644 index 02964a6ae..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/index.ts +++ /dev/null @@ -1,13 +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 - */ - -export * from './accounts'; -export * from './errors'; -export * from './instructions'; -export * from './programs'; -export * from './types'; diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/acceptOwnership.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/acceptOwnership.ts deleted file mode 100644 index f0dca6def..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/acceptOwnership.ts +++ /dev/null @@ -1,305 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const ACCEPT_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ - 172, 23, 43, 13, 238, 213, 85, 150, -]); - -export function getAcceptOwnershipDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - ACCEPT_OWNERSHIP_DISCRIMINATOR - ); -} - -export type AcceptOwnershipInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountPendingOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPendingOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountPendingOwner, - TAccountTokenMessenger extends string - ? WritableAccount - : TAccountTokenMessenger, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type AcceptOwnershipInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type AcceptOwnershipInstructionDataArgs = {}; - -export function getAcceptOwnershipInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: ACCEPT_OWNERSHIP_DISCRIMINATOR }) - ); -} - -export function getAcceptOwnershipInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getAcceptOwnershipInstructionDataCodec(): Codec< - AcceptOwnershipInstructionDataArgs, - AcceptOwnershipInstructionData -> { - return combineCodec( - getAcceptOwnershipInstructionDataEncoder(), - getAcceptOwnershipInstructionDataDecoder() - ); -} - -export type AcceptOwnershipAsyncInput< - TAccountPendingOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pendingOwner: TransactionSigner; - tokenMessenger: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getAcceptOwnershipInstructionAsync< - TAccountPendingOwner extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: AcceptOwnershipAsyncInput< - TAccountPendingOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - AcceptOwnershipInstruction< - TProgramAddress, - TAccountPendingOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pendingOwner: { value: input.pendingOwner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pendingOwner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getAcceptOwnershipInstructionDataEncoder().encode({}), - } as AcceptOwnershipInstruction< - TProgramAddress, - TAccountPendingOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type AcceptOwnershipInput< - TAccountPendingOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pendingOwner: TransactionSigner; - tokenMessenger: Address; - eventAuthority: Address; - program: Address; -}; - -export function getAcceptOwnershipInstruction< - TAccountPendingOwner extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: AcceptOwnershipInput< - TAccountPendingOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): AcceptOwnershipInstruction< - TProgramAddress, - TAccountPendingOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pendingOwner: { value: input.pendingOwner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pendingOwner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getAcceptOwnershipInstructionDataEncoder().encode({}), - } as AcceptOwnershipInstruction< - TProgramAddress, - TAccountPendingOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedAcceptOwnershipInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - pendingOwner: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: AcceptOwnershipInstructionData; -}; - -export function parseAcceptOwnershipInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedAcceptOwnershipInstruction { - if (instruction.accounts.length < 4) { - // 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: { - pendingOwner: getNextAccount(), - tokenMessenger: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getAcceptOwnershipInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/addLocalToken.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/addLocalToken.ts deleted file mode 100644 index f54136d91..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/addLocalToken.ts +++ /dev/null @@ -1,502 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const ADD_LOCAL_TOKEN_DISCRIMINATOR = new Uint8Array([ - 213, 199, 205, 18, 98, 124, 73, 198, -]); - -export function getAddLocalTokenDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - ADD_LOCAL_TOKEN_DISCRIMINATOR - ); -} - -export type AddLocalTokenInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountTokenController extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountCustodyTokenAccount extends string | AccountMeta = string, - TAccountLocalTokenMint extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountTokenController extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountTokenController, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountCustodyTokenAccount extends string - ? WritableAccount - : TAccountCustodyTokenAccount, - TAccountLocalTokenMint extends string - ? ReadonlyAccount - : TAccountLocalTokenMint, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type AddLocalTokenInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type AddLocalTokenInstructionDataArgs = {}; - -export function getAddLocalTokenInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: ADD_LOCAL_TOKEN_DISCRIMINATOR }) - ); -} - -export function getAddLocalTokenInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getAddLocalTokenInstructionDataCodec(): Codec< - AddLocalTokenInstructionDataArgs, - AddLocalTokenInstructionData -> { - return combineCodec( - getAddLocalTokenInstructionDataEncoder(), - getAddLocalTokenInstructionDataDecoder() - ); -} - -export type AddLocalTokenAsyncInput< - TAccountPayer extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountLocalTokenMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - localToken?: Address; - custodyTokenAccount?: Address; - localTokenMint: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getAddLocalTokenInstructionAsync< - TAccountPayer extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountCustodyTokenAccount extends string, - TAccountLocalTokenMint extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: AddLocalTokenAsyncInput< - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountLocalTokenMint, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - AddLocalTokenInstruction< - TProgramAddress, - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountLocalTokenMint, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - localTokenMint: { value: input.localTokenMint ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.localToken.value) { - accounts.localToken.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([108, 111, 99, 97, 108, 95, 116, 111, 107, 101, 110]) - ), - getAddressEncoder().encode( - expectAddress(accounts.localTokenMint.value) - ), - ], - }); - } - if (!accounts.custodyTokenAccount.value) { - accounts.custodyTokenAccount.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([99, 117, 115, 116, 111, 100, 121]) - ), - getAddressEncoder().encode( - expectAddress(accounts.localTokenMint.value) - ), - ], - }); - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.localTokenMint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getAddLocalTokenInstructionDataEncoder().encode({}), - } as AddLocalTokenInstruction< - TProgramAddress, - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountLocalTokenMint, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type AddLocalTokenInput< - TAccountPayer extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountLocalTokenMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - localToken: Address; - custodyTokenAccount: Address; - localTokenMint: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; -}; - -export function getAddLocalTokenInstruction< - TAccountPayer extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountCustodyTokenAccount extends string, - TAccountLocalTokenMint extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: AddLocalTokenInput< - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountLocalTokenMint, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): AddLocalTokenInstruction< - TProgramAddress, - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountLocalTokenMint, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - localTokenMint: { value: input.localTokenMint ?? null, isWritable: false }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.localTokenMint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getAddLocalTokenInstructionDataEncoder().encode({}), - } as AddLocalTokenInstruction< - TProgramAddress, - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountLocalTokenMint, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedAddLocalTokenInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - tokenController: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - localToken: TAccountMetas[3]; - custodyTokenAccount: TAccountMetas[4]; - localTokenMint: TAccountMetas[5]; - tokenProgram: TAccountMetas[6]; - systemProgram: TAccountMetas[7]; - eventAuthority: TAccountMetas[8]; - program: TAccountMetas[9]; - }; - data: AddLocalTokenInstructionData; -}; - -export function parseAddLocalTokenInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedAddLocalTokenInstruction { - if (instruction.accounts.length < 10) { - // 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: { - payer: getNextAccount(), - tokenController: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - custodyTokenAccount: getNextAccount(), - localTokenMint: getNextAccount(), - tokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getAddLocalTokenInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/addRemoteTokenMessenger.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/addRemoteTokenMessenger.ts deleted file mode 100644 index 0fab7dfd5..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/addRemoteTokenMessenger.ts +++ /dev/null @@ -1,424 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const ADD_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ - 12, 149, 172, 165, 111, 202, 24, 33, -]); - -export function getAddRemoteTokenMessengerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - ADD_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR - ); -} - -export type AddRemoteTokenMessengerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountRemoteTokenMessenger extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountRemoteTokenMessenger extends string - ? WritableAccount - : TAccountRemoteTokenMessenger, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type AddRemoteTokenMessengerInstructionData = { - discriminator: ReadonlyUint8Array; - domain: number; - tokenMessenger: Address; -}; - -export type AddRemoteTokenMessengerInstructionDataArgs = { - domain: number; - tokenMessenger: Address; -}; - -export function getAddRemoteTokenMessengerInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['domain', getU32Encoder()], - ['tokenMessenger', getAddressEncoder()], - ]), - (value) => ({ - ...value, - discriminator: ADD_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR, - }) - ); -} - -export function getAddRemoteTokenMessengerInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['domain', getU32Decoder()], - ['tokenMessenger', getAddressDecoder()], - ]); -} - -export function getAddRemoteTokenMessengerInstructionDataCodec(): Codec< - AddRemoteTokenMessengerInstructionDataArgs, - AddRemoteTokenMessengerInstructionData -> { - return combineCodec( - getAddRemoteTokenMessengerInstructionDataEncoder(), - getAddRemoteTokenMessengerInstructionDataDecoder() - ); -} - -export type AddRemoteTokenMessengerAsyncInput< - TAccountPayer extends string = string, - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - owner: TransactionSigner; - tokenMessenger: Address; - remoteTokenMessenger: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - domain: AddRemoteTokenMessengerInstructionDataArgs['domain']; - tokenMessengerArg: AddRemoteTokenMessengerInstructionDataArgs['tokenMessenger']; -}; - -export async function getAddRemoteTokenMessengerInstructionAsync< - TAccountPayer extends string, - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: AddRemoteTokenMessengerAsyncInput< - TAccountPayer, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - AddRemoteTokenMessengerInstruction< - TProgramAddress, - TAccountPayer, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: true, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input, tokenMessenger: input.tokenMessengerArg }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getAddRemoteTokenMessengerInstructionDataEncoder().encode( - args as AddRemoteTokenMessengerInstructionDataArgs - ), - } as AddRemoteTokenMessengerInstruction< - TProgramAddress, - TAccountPayer, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type AddRemoteTokenMessengerInput< - TAccountPayer extends string = string, - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - owner: TransactionSigner; - tokenMessenger: Address; - remoteTokenMessenger: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - domain: AddRemoteTokenMessengerInstructionDataArgs['domain']; - tokenMessengerArg: AddRemoteTokenMessengerInstructionDataArgs['tokenMessenger']; -}; - -export function getAddRemoteTokenMessengerInstruction< - TAccountPayer extends string, - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: AddRemoteTokenMessengerInput< - TAccountPayer, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): AddRemoteTokenMessengerInstruction< - TProgramAddress, - TAccountPayer, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: true, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input, tokenMessenger: input.tokenMessengerArg }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getAddRemoteTokenMessengerInstructionDataEncoder().encode( - args as AddRemoteTokenMessengerInstructionDataArgs - ), - } as AddRemoteTokenMessengerInstruction< - TProgramAddress, - TAccountPayer, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedAddRemoteTokenMessengerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - owner: TAccountMetas[1]; - tokenMessenger: TAccountMetas[2]; - remoteTokenMessenger: TAccountMetas[3]; - systemProgram: TAccountMetas[4]; - eventAuthority: TAccountMetas[5]; - program: TAccountMetas[6]; - }; - data: AddRemoteTokenMessengerInstructionData; -}; - -export function parseAddRemoteTokenMessengerInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedAddRemoteTokenMessengerInstruction { - if (instruction.accounts.length < 7) { - // 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: { - payer: getNextAccount(), - owner: getNextAccount(), - tokenMessenger: getNextAccount(), - remoteTokenMessenger: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getAddRemoteTokenMessengerInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/burnTokenCustody.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/burnTokenCustody.ts deleted file mode 100644 index bec1d8a82..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/burnTokenCustody.ts +++ /dev/null @@ -1,465 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const BURN_TOKEN_CUSTODY_DISCRIMINATOR = new Uint8Array([ - 233, 136, 180, 175, 112, 41, 62, 71, -]); - -export function getBurnTokenCustodyDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - BURN_TOKEN_CUSTODY_DISCRIMINATOR - ); -} - -export type BurnTokenCustodyInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountPayee extends string | AccountMeta = string, - TAccountTokenController extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountCustodyTokenAccount extends string | AccountMeta = string, - TAccountCustodyTokenMint extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayee extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayee, - TAccountTokenController extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountTokenController, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? ReadonlyAccount - : TAccountLocalToken, - TAccountCustodyTokenAccount extends string - ? WritableAccount - : TAccountCustodyTokenAccount, - TAccountCustodyTokenMint extends string - ? WritableAccount - : TAccountCustodyTokenMint, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type BurnTokenCustodyInstructionData = { - discriminator: ReadonlyUint8Array; - amount: bigint; -}; - -export type BurnTokenCustodyInstructionDataArgs = { amount: number | bigint }; - -export function getBurnTokenCustodyInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['amount', getU64Encoder()], - ]), - (value) => ({ ...value, discriminator: BURN_TOKEN_CUSTODY_DISCRIMINATOR }) - ); -} - -export function getBurnTokenCustodyInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['amount', getU64Decoder()], - ]); -} - -export function getBurnTokenCustodyInstructionDataCodec(): Codec< - BurnTokenCustodyInstructionDataArgs, - BurnTokenCustodyInstructionData -> { - return combineCodec( - getBurnTokenCustodyInstructionDataEncoder(), - getBurnTokenCustodyInstructionDataDecoder() - ); -} - -export type BurnTokenCustodyAsyncInput< - TAccountPayee extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountCustodyTokenMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payee: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - localToken: Address; - custodyTokenAccount: Address; - custodyTokenMint: Address; - tokenProgram?: Address; - eventAuthority?: Address; - program: Address; - amount: BurnTokenCustodyInstructionDataArgs['amount']; -}; - -export async function getBurnTokenCustodyInstructionAsync< - TAccountPayee extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountCustodyTokenAccount extends string, - TAccountCustodyTokenMint extends string, - TAccountTokenProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: BurnTokenCustodyAsyncInput< - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - BurnTokenCustodyInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: false }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - custodyTokenMint: { - value: input.custodyTokenMint ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.custodyTokenMint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getBurnTokenCustodyInstructionDataEncoder().encode( - args as BurnTokenCustodyInstructionDataArgs - ), - } as BurnTokenCustodyInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type BurnTokenCustodyInput< - TAccountPayee extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountCustodyTokenMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payee: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - localToken: Address; - custodyTokenAccount: Address; - custodyTokenMint: Address; - tokenProgram?: Address; - eventAuthority: Address; - program: Address; - amount: BurnTokenCustodyInstructionDataArgs['amount']; -}; - -export function getBurnTokenCustodyInstruction< - TAccountPayee extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountCustodyTokenAccount extends string, - TAccountCustodyTokenMint extends string, - TAccountTokenProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: BurnTokenCustodyInput< - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): BurnTokenCustodyInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: false }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - custodyTokenMint: { - value: input.custodyTokenMint ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.custodyTokenMint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getBurnTokenCustodyInstructionDataEncoder().encode( - args as BurnTokenCustodyInstructionDataArgs - ), - } as BurnTokenCustodyInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedBurnTokenCustodyInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payee: TAccountMetas[0]; - tokenController: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - localToken: TAccountMetas[3]; - custodyTokenAccount: TAccountMetas[4]; - custodyTokenMint: TAccountMetas[5]; - tokenProgram: TAccountMetas[6]; - eventAuthority: TAccountMetas[7]; - program: TAccountMetas[8]; - }; - data: BurnTokenCustodyInstructionData; -}; - -export function parseBurnTokenCustodyInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedBurnTokenCustodyInstruction { - if (instruction.accounts.length < 9) { - // 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: { - payee: getNextAccount(), - tokenController: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - custodyTokenAccount: getNextAccount(), - custodyTokenMint: getNextAccount(), - tokenProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getBurnTokenCustodyInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/denylistAccount.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/denylistAccount.ts deleted file mode 100644 index 52fcc61c7..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/denylistAccount.ts +++ /dev/null @@ -1,403 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const DENYLIST_ACCOUNT_DISCRIMINATOR = new Uint8Array([ - 101, 116, 197, 112, 81, 249, 75, 194, -]); - -export function getDenylistAccountDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - DENYLIST_ACCOUNT_DISCRIMINATOR - ); -} - -export type DenylistAccountInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountDenylister extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountDenylistAccount extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountDenylister extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountDenylister, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountDenylistAccount extends string - ? WritableAccount - : TAccountDenylistAccount, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type DenylistAccountInstructionData = { - discriminator: ReadonlyUint8Array; - account: Address; -}; - -export type DenylistAccountInstructionDataArgs = { account: Address }; - -export function getDenylistAccountInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['account', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: DENYLIST_ACCOUNT_DISCRIMINATOR }) - ); -} - -export function getDenylistAccountInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['account', getAddressDecoder()], - ]); -} - -export function getDenylistAccountInstructionDataCodec(): Codec< - DenylistAccountInstructionDataArgs, - DenylistAccountInstructionData -> { - return combineCodec( - getDenylistAccountInstructionDataEncoder(), - getDenylistAccountInstructionDataDecoder() - ); -} - -export type DenylistAccountAsyncInput< - TAccountPayer extends string = string, - TAccountDenylister extends string = string, - TAccountTokenMessenger extends string = string, - TAccountDenylistAccount extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - denylister: TransactionSigner; - tokenMessenger: Address; - denylistAccount: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - account: DenylistAccountInstructionDataArgs['account']; -}; - -export async function getDenylistAccountInstructionAsync< - TAccountPayer extends string, - TAccountDenylister extends string, - TAccountTokenMessenger extends string, - TAccountDenylistAccount extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: DenylistAccountAsyncInput< - TAccountPayer, - TAccountDenylister, - TAccountTokenMessenger, - TAccountDenylistAccount, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - DenylistAccountInstruction< - TProgramAddress, - TAccountPayer, - TAccountDenylister, - TAccountTokenMessenger, - TAccountDenylistAccount, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - denylister: { value: input.denylister ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - denylistAccount: { value: input.denylistAccount ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.denylister), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.denylistAccount), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDenylistAccountInstructionDataEncoder().encode( - args as DenylistAccountInstructionDataArgs - ), - } as DenylistAccountInstruction< - TProgramAddress, - TAccountPayer, - TAccountDenylister, - TAccountTokenMessenger, - TAccountDenylistAccount, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type DenylistAccountInput< - TAccountPayer extends string = string, - TAccountDenylister extends string = string, - TAccountTokenMessenger extends string = string, - TAccountDenylistAccount extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - denylister: TransactionSigner; - tokenMessenger: Address; - denylistAccount: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - account: DenylistAccountInstructionDataArgs['account']; -}; - -export function getDenylistAccountInstruction< - TAccountPayer extends string, - TAccountDenylister extends string, - TAccountTokenMessenger extends string, - TAccountDenylistAccount extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: DenylistAccountInput< - TAccountPayer, - TAccountDenylister, - TAccountTokenMessenger, - TAccountDenylistAccount, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): DenylistAccountInstruction< - TProgramAddress, - TAccountPayer, - TAccountDenylister, - TAccountTokenMessenger, - TAccountDenylistAccount, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - denylister: { value: input.denylister ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - denylistAccount: { value: input.denylistAccount ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.denylister), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.denylistAccount), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDenylistAccountInstructionDataEncoder().encode( - args as DenylistAccountInstructionDataArgs - ), - } as DenylistAccountInstruction< - TProgramAddress, - TAccountPayer, - TAccountDenylister, - TAccountTokenMessenger, - TAccountDenylistAccount, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedDenylistAccountInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - denylister: TAccountMetas[1]; - tokenMessenger: TAccountMetas[2]; - denylistAccount: TAccountMetas[3]; - systemProgram: TAccountMetas[4]; - eventAuthority: TAccountMetas[5]; - program: TAccountMetas[6]; - }; - data: DenylistAccountInstructionData; -}; - -export function parseDenylistAccountInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedDenylistAccountInstruction { - if (instruction.accounts.length < 7) { - // 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: { - payer: getNextAccount(), - denylister: getNextAccount(), - tokenMessenger: getNextAccount(), - denylistAccount: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getDenylistAccountInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurn.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurn.ts deleted file mode 100644 index 89ae3ab3a..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurn.ts +++ /dev/null @@ -1,802 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const DEPOSIT_FOR_BURN_DISCRIMINATOR = new Uint8Array([ - 215, 60, 61, 46, 114, 55, 128, 176, -]); - -export function getDepositForBurnDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - DEPOSIT_FOR_BURN_DISCRIMINATOR - ); -} - -export type DepositForBurnInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountEventRentPayer extends string | AccountMeta = string, - TAccountSenderAuthorityPda extends string | AccountMeta = string, - TAccountBurnTokenAccount extends string | AccountMeta = string, - TAccountDenylistAccount extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountRemoteTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountBurnTokenMint extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TAccountMessageTransmitterProgram extends string | AccountMeta = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC', - TAccountTokenMessengerMinterProgram extends string | AccountMeta = - 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe', - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountEventRentPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountEventRentPayer, - TAccountSenderAuthorityPda extends string - ? ReadonlyAccount - : TAccountSenderAuthorityPda, - TAccountBurnTokenAccount extends string - ? WritableAccount - : TAccountBurnTokenAccount, - TAccountDenylistAccount extends string - ? ReadonlyAccount - : TAccountDenylistAccount, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountRemoteTokenMessenger extends string - ? ReadonlyAccount - : TAccountRemoteTokenMessenger, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountBurnTokenMint extends string - ? WritableAccount - : TAccountBurnTokenMint, - TAccountMessageSentEventData extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountMessageSentEventData, - TAccountMessageTransmitterProgram extends string - ? ReadonlyAccount - : TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram extends string - ? ReadonlyAccount - : TAccountTokenMessengerMinterProgram, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type DepositForBurnInstructionData = { - discriminator: ReadonlyUint8Array; - amount: bigint; - destinationDomain: number; - mintRecipient: Address; - destinationCaller: Address; - maxFee: bigint; - minFinalityThreshold: number; -}; - -export type DepositForBurnInstructionDataArgs = { - amount: number | bigint; - destinationDomain: number; - mintRecipient: Address; - destinationCaller: Address; - maxFee: number | bigint; - minFinalityThreshold: number; -}; - -export function getDepositForBurnInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['amount', getU64Encoder()], - ['destinationDomain', getU32Encoder()], - ['mintRecipient', getAddressEncoder()], - ['destinationCaller', getAddressEncoder()], - ['maxFee', getU64Encoder()], - ['minFinalityThreshold', getU32Encoder()], - ]), - (value) => ({ ...value, discriminator: DEPOSIT_FOR_BURN_DISCRIMINATOR }) - ); -} - -export function getDepositForBurnInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['amount', getU64Decoder()], - ['destinationDomain', getU32Decoder()], - ['mintRecipient', getAddressDecoder()], - ['destinationCaller', getAddressDecoder()], - ['maxFee', getU64Decoder()], - ['minFinalityThreshold', getU32Decoder()], - ]); -} - -export function getDepositForBurnInstructionDataCodec(): Codec< - DepositForBurnInstructionDataArgs, - DepositForBurnInstructionData -> { - return combineCodec( - getDepositForBurnInstructionDataEncoder(), - getDepositForBurnInstructionDataDecoder() - ); -} - -export type DepositForBurnAsyncInput< - TAccountOwner extends string = string, - TAccountEventRentPayer extends string = string, - TAccountSenderAuthorityPda extends string = string, - TAccountBurnTokenAccount extends string = string, - TAccountDenylistAccount extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountBurnTokenMint extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - eventRentPayer: TransactionSigner; - senderAuthorityPda?: Address; - burnTokenAccount: Address; - /** Account is denylisted if the account exists at the expected PDA. */ - denylistAccount?: Address; - messageTransmitter: Address; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken?: Address; - burnTokenMint: Address; - messageSentEventData: TransactionSigner; - messageTransmitterProgram?: Address; - tokenMessengerMinterProgram?: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - amount: DepositForBurnInstructionDataArgs['amount']; - destinationDomain: DepositForBurnInstructionDataArgs['destinationDomain']; - mintRecipient: DepositForBurnInstructionDataArgs['mintRecipient']; - destinationCaller: DepositForBurnInstructionDataArgs['destinationCaller']; - maxFee: DepositForBurnInstructionDataArgs['maxFee']; - minFinalityThreshold: DepositForBurnInstructionDataArgs['minFinalityThreshold']; -}; - -export async function getDepositForBurnInstructionAsync< - TAccountOwner extends string, - TAccountEventRentPayer extends string, - TAccountSenderAuthorityPda extends string, - TAccountBurnTokenAccount extends string, - TAccountDenylistAccount extends string, - TAccountMessageTransmitter extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountBurnTokenMint extends string, - TAccountMessageSentEventData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: DepositForBurnAsyncInput< - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountDenylistAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - DepositForBurnInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountDenylistAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, - senderAuthorityPda: { - value: input.senderAuthorityPda ?? null, - isWritable: false, - }, - burnTokenAccount: { - value: input.burnTokenAccount ?? null, - isWritable: true, - }, - denylistAccount: { - value: input.denylistAccount ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - burnTokenMint: { value: input.burnTokenMint ?? null, isWritable: true }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.senderAuthorityPda.value) { - accounts.senderAuthorityPda.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 115, 101, 110, 100, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, - 116, 121, - ]) - ), - ], - }); - } - if (!accounts.denylistAccount.value) { - accounts.denylistAccount.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 100, 101, 110, 121, 108, 105, 115, 116, 95, 97, 99, 99, 111, 117, - 110, 116, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.owner.value)), - ], - }); - } - if (!accounts.localToken.value) { - accounts.localToken.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([108, 111, 99, 97, 108, 95, 116, 111, 107, 101, 110]) - ), - getAddressEncoder().encode(expectAddress(accounts.burnTokenMint.value)), - ], - }); - } - if (!accounts.messageTransmitterProgram.value) { - accounts.messageTransmitterProgram.value = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; - } - if (!accounts.tokenMessengerMinterProgram.value) { - accounts.tokenMessengerMinterProgram.value = - 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.eventRentPayer), - getAccountMeta(accounts.senderAuthorityPda), - getAccountMeta(accounts.burnTokenAccount), - getAccountMeta(accounts.denylistAccount), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.burnTokenMint), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDepositForBurnInstructionDataEncoder().encode( - args as DepositForBurnInstructionDataArgs - ), - } as DepositForBurnInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountDenylistAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type DepositForBurnInput< - TAccountOwner extends string = string, - TAccountEventRentPayer extends string = string, - TAccountSenderAuthorityPda extends string = string, - TAccountBurnTokenAccount extends string = string, - TAccountDenylistAccount extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountBurnTokenMint extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - eventRentPayer: TransactionSigner; - senderAuthorityPda: Address; - burnTokenAccount: Address; - /** Account is denylisted if the account exists at the expected PDA. */ - denylistAccount: Address; - messageTransmitter: Address; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken: Address; - burnTokenMint: Address; - messageSentEventData: TransactionSigner; - messageTransmitterProgram?: Address; - tokenMessengerMinterProgram?: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - amount: DepositForBurnInstructionDataArgs['amount']; - destinationDomain: DepositForBurnInstructionDataArgs['destinationDomain']; - mintRecipient: DepositForBurnInstructionDataArgs['mintRecipient']; - destinationCaller: DepositForBurnInstructionDataArgs['destinationCaller']; - maxFee: DepositForBurnInstructionDataArgs['maxFee']; - minFinalityThreshold: DepositForBurnInstructionDataArgs['minFinalityThreshold']; -}; - -export function getDepositForBurnInstruction< - TAccountOwner extends string, - TAccountEventRentPayer extends string, - TAccountSenderAuthorityPda extends string, - TAccountBurnTokenAccount extends string, - TAccountDenylistAccount extends string, - TAccountMessageTransmitter extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountBurnTokenMint extends string, - TAccountMessageSentEventData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: DepositForBurnInput< - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountDenylistAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): DepositForBurnInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountDenylistAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, - senderAuthorityPda: { - value: input.senderAuthorityPda ?? null, - isWritable: false, - }, - burnTokenAccount: { - value: input.burnTokenAccount ?? null, - isWritable: true, - }, - denylistAccount: { - value: input.denylistAccount ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - burnTokenMint: { value: input.burnTokenMint ?? null, isWritable: true }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.messageTransmitterProgram.value) { - accounts.messageTransmitterProgram.value = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; - } - if (!accounts.tokenMessengerMinterProgram.value) { - accounts.tokenMessengerMinterProgram.value = - 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.eventRentPayer), - getAccountMeta(accounts.senderAuthorityPda), - getAccountMeta(accounts.burnTokenAccount), - getAccountMeta(accounts.denylistAccount), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.burnTokenMint), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDepositForBurnInstructionDataEncoder().encode( - args as DepositForBurnInstructionDataArgs - ), - } as DepositForBurnInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountDenylistAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedDepositForBurnInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - eventRentPayer: TAccountMetas[1]; - senderAuthorityPda: TAccountMetas[2]; - burnTokenAccount: TAccountMetas[3]; - /** Account is denylisted if the account exists at the expected PDA. */ - denylistAccount: TAccountMetas[4]; - messageTransmitter: TAccountMetas[5]; - tokenMessenger: TAccountMetas[6]; - remoteTokenMessenger: TAccountMetas[7]; - tokenMinter: TAccountMetas[8]; - localToken: TAccountMetas[9]; - burnTokenMint: TAccountMetas[10]; - messageSentEventData: TAccountMetas[11]; - messageTransmitterProgram: TAccountMetas[12]; - tokenMessengerMinterProgram: TAccountMetas[13]; - tokenProgram: TAccountMetas[14]; - systemProgram: TAccountMetas[15]; - eventAuthority: TAccountMetas[16]; - program: TAccountMetas[17]; - }; - data: DepositForBurnInstructionData; -}; - -export function parseDepositForBurnInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedDepositForBurnInstruction { - if (instruction.accounts.length < 18) { - // 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: { - owner: getNextAccount(), - eventRentPayer: getNextAccount(), - senderAuthorityPda: getNextAccount(), - burnTokenAccount: getNextAccount(), - denylistAccount: getNextAccount(), - messageTransmitter: getNextAccount(), - tokenMessenger: getNextAccount(), - remoteTokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - burnTokenMint: getNextAccount(), - messageSentEventData: getNextAccount(), - messageTransmitterProgram: getNextAccount(), - tokenMessengerMinterProgram: getNextAccount(), - tokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getDepositForBurnInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurnWithHook.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurnWithHook.ts deleted file mode 100644 index 321409ad2..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/depositForBurnWithHook.ts +++ /dev/null @@ -1,815 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { - expectAddress, - getAccountMetaFactory, - type ResolvedAccount, -} from '../shared'; - -export const DEPOSIT_FOR_BURN_WITH_HOOK_DISCRIMINATOR = new Uint8Array([ - 111, 245, 62, 131, 204, 108, 223, 155, -]); - -export function getDepositForBurnWithHookDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - DEPOSIT_FOR_BURN_WITH_HOOK_DISCRIMINATOR - ); -} - -export type DepositForBurnWithHookInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountEventRentPayer extends string | AccountMeta = string, - TAccountSenderAuthorityPda extends string | AccountMeta = string, - TAccountBurnTokenAccount extends string | AccountMeta = string, - TAccountDenylistAccount extends string | AccountMeta = string, - TAccountMessageTransmitter extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountRemoteTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountBurnTokenMint extends string | AccountMeta = string, - TAccountMessageSentEventData extends string | AccountMeta = string, - TAccountMessageTransmitterProgram extends string | AccountMeta = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC', - TAccountTokenMessengerMinterProgram extends string | AccountMeta = - 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe', - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountEventRentPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountEventRentPayer, - TAccountSenderAuthorityPda extends string - ? ReadonlyAccount - : TAccountSenderAuthorityPda, - TAccountBurnTokenAccount extends string - ? WritableAccount - : TAccountBurnTokenAccount, - TAccountDenylistAccount extends string - ? ReadonlyAccount - : TAccountDenylistAccount, - TAccountMessageTransmitter extends string - ? WritableAccount - : TAccountMessageTransmitter, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountRemoteTokenMessenger extends string - ? ReadonlyAccount - : TAccountRemoteTokenMessenger, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountBurnTokenMint extends string - ? WritableAccount - : TAccountBurnTokenMint, - TAccountMessageSentEventData extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountMessageSentEventData, - TAccountMessageTransmitterProgram extends string - ? ReadonlyAccount - : TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram extends string - ? ReadonlyAccount - : TAccountTokenMessengerMinterProgram, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type DepositForBurnWithHookInstructionData = { - discriminator: ReadonlyUint8Array; - amount: bigint; - destinationDomain: number; - mintRecipient: Address; - destinationCaller: Address; - maxFee: bigint; - minFinalityThreshold: number; - hookData: ReadonlyUint8Array; -}; - -export type DepositForBurnWithHookInstructionDataArgs = { - amount: number | bigint; - destinationDomain: number; - mintRecipient: Address; - destinationCaller: Address; - maxFee: number | bigint; - minFinalityThreshold: number; - hookData: ReadonlyUint8Array; -}; - -export function getDepositForBurnWithHookInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['amount', getU64Encoder()], - ['destinationDomain', getU32Encoder()], - ['mintRecipient', getAddressEncoder()], - ['destinationCaller', getAddressEncoder()], - ['maxFee', getU64Encoder()], - ['minFinalityThreshold', getU32Encoder()], - ['hookData', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]), - (value) => ({ - ...value, - discriminator: DEPOSIT_FOR_BURN_WITH_HOOK_DISCRIMINATOR, - }) - ); -} - -export function getDepositForBurnWithHookInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['amount', getU64Decoder()], - ['destinationDomain', getU32Decoder()], - ['mintRecipient', getAddressDecoder()], - ['destinationCaller', getAddressDecoder()], - ['maxFee', getU64Decoder()], - ['minFinalityThreshold', getU32Decoder()], - ['hookData', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getDepositForBurnWithHookInstructionDataCodec(): Codec< - DepositForBurnWithHookInstructionDataArgs, - DepositForBurnWithHookInstructionData -> { - return combineCodec( - getDepositForBurnWithHookInstructionDataEncoder(), - getDepositForBurnWithHookInstructionDataDecoder() - ); -} - -export type DepositForBurnWithHookAsyncInput< - TAccountOwner extends string = string, - TAccountEventRentPayer extends string = string, - TAccountSenderAuthorityPda extends string = string, - TAccountBurnTokenAccount extends string = string, - TAccountDenylistAccount extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountBurnTokenMint extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - eventRentPayer: TransactionSigner; - senderAuthorityPda?: Address; - burnTokenAccount: Address; - /** Account is denylisted if the account exists at the expected PDA. */ - denylistAccount?: Address; - messageTransmitter: Address; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken?: Address; - burnTokenMint: Address; - messageSentEventData: TransactionSigner; - messageTransmitterProgram?: Address; - tokenMessengerMinterProgram?: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - amount: DepositForBurnWithHookInstructionDataArgs['amount']; - destinationDomain: DepositForBurnWithHookInstructionDataArgs['destinationDomain']; - mintRecipient: DepositForBurnWithHookInstructionDataArgs['mintRecipient']; - destinationCaller: DepositForBurnWithHookInstructionDataArgs['destinationCaller']; - maxFee: DepositForBurnWithHookInstructionDataArgs['maxFee']; - minFinalityThreshold: DepositForBurnWithHookInstructionDataArgs['minFinalityThreshold']; - hookData: DepositForBurnWithHookInstructionDataArgs['hookData']; -}; - -export async function getDepositForBurnWithHookInstructionAsync< - TAccountOwner extends string, - TAccountEventRentPayer extends string, - TAccountSenderAuthorityPda extends string, - TAccountBurnTokenAccount extends string, - TAccountDenylistAccount extends string, - TAccountMessageTransmitter extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountBurnTokenMint extends string, - TAccountMessageSentEventData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: DepositForBurnWithHookAsyncInput< - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountDenylistAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - DepositForBurnWithHookInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountDenylistAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, - senderAuthorityPda: { - value: input.senderAuthorityPda ?? null, - isWritable: false, - }, - burnTokenAccount: { - value: input.burnTokenAccount ?? null, - isWritable: true, - }, - denylistAccount: { - value: input.denylistAccount ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - burnTokenMint: { value: input.burnTokenMint ?? null, isWritable: true }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.senderAuthorityPda.value) { - accounts.senderAuthorityPda.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 115, 101, 110, 100, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, - 116, 121, - ]) - ), - ], - }); - } - if (!accounts.denylistAccount.value) { - accounts.denylistAccount.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 100, 101, 110, 121, 108, 105, 115, 116, 95, 97, 99, 99, 111, 117, - 110, 116, - ]) - ), - getAddressEncoder().encode(expectAddress(accounts.owner.value)), - ], - }); - } - if (!accounts.localToken.value) { - accounts.localToken.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([108, 111, 99, 97, 108, 95, 116, 111, 107, 101, 110]) - ), - getAddressEncoder().encode(expectAddress(accounts.burnTokenMint.value)), - ], - }); - } - if (!accounts.messageTransmitterProgram.value) { - accounts.messageTransmitterProgram.value = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; - } - if (!accounts.tokenMessengerMinterProgram.value) { - accounts.tokenMessengerMinterProgram.value = - 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.eventRentPayer), - getAccountMeta(accounts.senderAuthorityPda), - getAccountMeta(accounts.burnTokenAccount), - getAccountMeta(accounts.denylistAccount), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.burnTokenMint), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDepositForBurnWithHookInstructionDataEncoder().encode( - args as DepositForBurnWithHookInstructionDataArgs - ), - } as DepositForBurnWithHookInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountDenylistAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type DepositForBurnWithHookInput< - TAccountOwner extends string = string, - TAccountEventRentPayer extends string = string, - TAccountSenderAuthorityPda extends string = string, - TAccountBurnTokenAccount extends string = string, - TAccountDenylistAccount extends string = string, - TAccountMessageTransmitter extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountBurnTokenMint extends string = string, - TAccountMessageSentEventData extends string = string, - TAccountMessageTransmitterProgram extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountTokenProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - eventRentPayer: TransactionSigner; - senderAuthorityPda: Address; - burnTokenAccount: Address; - /** Account is denylisted if the account exists at the expected PDA. */ - denylistAccount: Address; - messageTransmitter: Address; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken: Address; - burnTokenMint: Address; - messageSentEventData: TransactionSigner; - messageTransmitterProgram?: Address; - tokenMessengerMinterProgram?: Address; - tokenProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - amount: DepositForBurnWithHookInstructionDataArgs['amount']; - destinationDomain: DepositForBurnWithHookInstructionDataArgs['destinationDomain']; - mintRecipient: DepositForBurnWithHookInstructionDataArgs['mintRecipient']; - destinationCaller: DepositForBurnWithHookInstructionDataArgs['destinationCaller']; - maxFee: DepositForBurnWithHookInstructionDataArgs['maxFee']; - minFinalityThreshold: DepositForBurnWithHookInstructionDataArgs['minFinalityThreshold']; - hookData: DepositForBurnWithHookInstructionDataArgs['hookData']; -}; - -export function getDepositForBurnWithHookInstruction< - TAccountOwner extends string, - TAccountEventRentPayer extends string, - TAccountSenderAuthorityPda extends string, - TAccountBurnTokenAccount extends string, - TAccountDenylistAccount extends string, - TAccountMessageTransmitter extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountBurnTokenMint extends string, - TAccountMessageSentEventData extends string, - TAccountMessageTransmitterProgram extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountTokenProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: DepositForBurnWithHookInput< - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountDenylistAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): DepositForBurnWithHookInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountDenylistAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - eventRentPayer: { value: input.eventRentPayer ?? null, isWritable: true }, - senderAuthorityPda: { - value: input.senderAuthorityPda ?? null, - isWritable: false, - }, - burnTokenAccount: { - value: input.burnTokenAccount ?? null, - isWritable: true, - }, - denylistAccount: { - value: input.denylistAccount ?? null, - isWritable: false, - }, - messageTransmitter: { - value: input.messageTransmitter ?? null, - isWritable: true, - }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - burnTokenMint: { value: input.burnTokenMint ?? null, isWritable: true }, - messageSentEventData: { - value: input.messageSentEventData ?? null, - isWritable: true, - }, - messageTransmitterProgram: { - value: input.messageTransmitterProgram ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.messageTransmitterProgram.value) { - accounts.messageTransmitterProgram.value = - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>; - } - if (!accounts.tokenMessengerMinterProgram.value) { - accounts.tokenMessengerMinterProgram.value = - 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.eventRentPayer), - getAccountMeta(accounts.senderAuthorityPda), - getAccountMeta(accounts.burnTokenAccount), - getAccountMeta(accounts.denylistAccount), - getAccountMeta(accounts.messageTransmitter), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.burnTokenMint), - getAccountMeta(accounts.messageSentEventData), - getAccountMeta(accounts.messageTransmitterProgram), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getDepositForBurnWithHookInstructionDataEncoder().encode( - args as DepositForBurnWithHookInstructionDataArgs - ), - } as DepositForBurnWithHookInstruction< - TProgramAddress, - TAccountOwner, - TAccountEventRentPayer, - TAccountSenderAuthorityPda, - TAccountBurnTokenAccount, - TAccountDenylistAccount, - TAccountMessageTransmitter, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountBurnTokenMint, - TAccountMessageSentEventData, - TAccountMessageTransmitterProgram, - TAccountTokenMessengerMinterProgram, - TAccountTokenProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedDepositForBurnWithHookInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - eventRentPayer: TAccountMetas[1]; - senderAuthorityPda: TAccountMetas[2]; - burnTokenAccount: TAccountMetas[3]; - /** Account is denylisted if the account exists at the expected PDA. */ - denylistAccount: TAccountMetas[4]; - messageTransmitter: TAccountMetas[5]; - tokenMessenger: TAccountMetas[6]; - remoteTokenMessenger: TAccountMetas[7]; - tokenMinter: TAccountMetas[8]; - localToken: TAccountMetas[9]; - burnTokenMint: TAccountMetas[10]; - messageSentEventData: TAccountMetas[11]; - messageTransmitterProgram: TAccountMetas[12]; - tokenMessengerMinterProgram: TAccountMetas[13]; - tokenProgram: TAccountMetas[14]; - systemProgram: TAccountMetas[15]; - eventAuthority: TAccountMetas[16]; - program: TAccountMetas[17]; - }; - data: DepositForBurnWithHookInstructionData; -}; - -export function parseDepositForBurnWithHookInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedDepositForBurnWithHookInstruction { - if (instruction.accounts.length < 18) { - // 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: { - owner: getNextAccount(), - eventRentPayer: getNextAccount(), - senderAuthorityPda: getNextAccount(), - burnTokenAccount: getNextAccount(), - denylistAccount: getNextAccount(), - messageTransmitter: getNextAccount(), - tokenMessenger: getNextAccount(), - remoteTokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - burnTokenMint: getNextAccount(), - messageSentEventData: getNextAccount(), - messageTransmitterProgram: getNextAccount(), - tokenMessengerMinterProgram: getNextAccount(), - tokenProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getDepositForBurnWithHookInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveFinalizedMessage.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveFinalizedMessage.ts deleted file mode 100644 index 96630cc35..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveFinalizedMessage.ts +++ /dev/null @@ -1,569 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -import { - getHandleReceiveMessageParamsDecoder, - getHandleReceiveMessageParamsEncoder, - type HandleReceiveMessageParams, - type HandleReceiveMessageParamsArgs, -} from '../types'; - -export const HANDLE_RECEIVE_FINALIZED_MESSAGE_DISCRIMINATOR = new Uint8Array([ - 186, 252, 239, 70, 86, 180, 110, 95, -]); - -export function getHandleReceiveFinalizedMessageDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - HANDLE_RECEIVE_FINALIZED_MESSAGE_DISCRIMINATOR - ); -} - -export type HandleReceiveFinalizedMessageInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountAuthorityPda extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountRemoteTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountTokenPair extends string | AccountMeta = string, - TAccountFeeRecipientTokenAccount extends string | AccountMeta = - string, - TAccountRecipientTokenAccount extends string | AccountMeta = string, - TAccountCustodyTokenAccount extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountAuthorityPda extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthorityPda, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountRemoteTokenMessenger extends string - ? ReadonlyAccount - : TAccountRemoteTokenMessenger, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountTokenPair extends string - ? ReadonlyAccount - : TAccountTokenPair, - TAccountFeeRecipientTokenAccount extends string - ? WritableAccount - : TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount extends string - ? WritableAccount - : TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount extends string - ? WritableAccount - : TAccountCustodyTokenAccount, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type HandleReceiveFinalizedMessageInstructionData = { - discriminator: ReadonlyUint8Array; - params: HandleReceiveMessageParams; -}; - -export type HandleReceiveFinalizedMessageInstructionDataArgs = { - params: HandleReceiveMessageParamsArgs; -}; - -export function getHandleReceiveFinalizedMessageInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['params', getHandleReceiveMessageParamsEncoder()], - ]), - (value) => ({ - ...value, - discriminator: HANDLE_RECEIVE_FINALIZED_MESSAGE_DISCRIMINATOR, - }) - ); -} - -export function getHandleReceiveFinalizedMessageInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['params', getHandleReceiveMessageParamsDecoder()], - ]); -} - -export function getHandleReceiveFinalizedMessageInstructionDataCodec(): Codec< - HandleReceiveFinalizedMessageInstructionDataArgs, - HandleReceiveFinalizedMessageInstructionData -> { - return combineCodec( - getHandleReceiveFinalizedMessageInstructionDataEncoder(), - getHandleReceiveFinalizedMessageInstructionDataDecoder() - ); -} - -export type HandleReceiveFinalizedMessageAsyncInput< - TAccountAuthorityPda extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountTokenPair extends string = string, - TAccountFeeRecipientTokenAccount extends string = string, - TAccountRecipientTokenAccount extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountTokenProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - authorityPda?: TransactionSigner; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken: Address; - tokenPair: Address; - feeRecipientTokenAccount: Address; - recipientTokenAccount: Address; - custodyTokenAccount: Address; - tokenProgram?: Address; - eventAuthority?: Address; - program: Address; - params: HandleReceiveFinalizedMessageInstructionDataArgs['params']; -}; - -export async function getHandleReceiveFinalizedMessageInstructionAsync< - TAccountAuthorityPda extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountTokenPair extends string, - TAccountFeeRecipientTokenAccount extends string, - TAccountRecipientTokenAccount extends string, - TAccountCustodyTokenAccount extends string, - TAccountTokenProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: HandleReceiveFinalizedMessageAsyncInput< - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - HandleReceiveFinalizedMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - authorityPda: { value: input.authorityPda ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - tokenPair: { value: input.tokenPair ?? null, isWritable: false }, - feeRecipientTokenAccount: { - value: input.feeRecipientTokenAccount ?? null, - isWritable: true, - }, - recipientTokenAccount: { - value: input.recipientTokenAccount ?? null, - isWritable: true, - }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.authorityPda.value) { - accounts.authorityPda.value = await getProgramDerivedAddress({ - programAddress: - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 109, 101, 115, 115, 97, 103, 101, 95, 116, 114, 97, 110, 115, 109, - 105, 116, 116, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, 116, - 121, - ]) - ), - getBytesEncoder().encode( - new Uint8Array([ - 166, 95, 200, 29, 15, 239, 168, 134, 12, 179, 184, 63, 8, 155, 2, - 36, 190, 138, 102, 135, 183, 174, 73, 245, 148, 192, 185, 180, 215, - 233, 56, 147, - ]) - ), - ], - }); - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.authorityPda), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.tokenPair), - getAccountMeta(accounts.feeRecipientTokenAccount), - getAccountMeta(accounts.recipientTokenAccount), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getHandleReceiveFinalizedMessageInstructionDataEncoder().encode( - args as HandleReceiveFinalizedMessageInstructionDataArgs - ), - } as HandleReceiveFinalizedMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type HandleReceiveFinalizedMessageInput< - TAccountAuthorityPda extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountTokenPair extends string = string, - TAccountFeeRecipientTokenAccount extends string = string, - TAccountRecipientTokenAccount extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountTokenProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - authorityPda: TransactionSigner; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken: Address; - tokenPair: Address; - feeRecipientTokenAccount: Address; - recipientTokenAccount: Address; - custodyTokenAccount: Address; - tokenProgram?: Address; - eventAuthority: Address; - program: Address; - params: HandleReceiveFinalizedMessageInstructionDataArgs['params']; -}; - -export function getHandleReceiveFinalizedMessageInstruction< - TAccountAuthorityPda extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountTokenPair extends string, - TAccountFeeRecipientTokenAccount extends string, - TAccountRecipientTokenAccount extends string, - TAccountCustodyTokenAccount extends string, - TAccountTokenProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: HandleReceiveFinalizedMessageInput< - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): HandleReceiveFinalizedMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - authorityPda: { value: input.authorityPda ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - tokenPair: { value: input.tokenPair ?? null, isWritable: false }, - feeRecipientTokenAccount: { - value: input.feeRecipientTokenAccount ?? null, - isWritable: true, - }, - recipientTokenAccount: { - value: input.recipientTokenAccount ?? null, - isWritable: true, - }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.authorityPda), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.tokenPair), - getAccountMeta(accounts.feeRecipientTokenAccount), - getAccountMeta(accounts.recipientTokenAccount), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getHandleReceiveFinalizedMessageInstructionDataEncoder().encode( - args as HandleReceiveFinalizedMessageInstructionDataArgs - ), - } as HandleReceiveFinalizedMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedHandleReceiveFinalizedMessageInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - authorityPda: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - remoteTokenMessenger: TAccountMetas[2]; - tokenMinter: TAccountMetas[3]; - localToken: TAccountMetas[4]; - tokenPair: TAccountMetas[5]; - feeRecipientTokenAccount: TAccountMetas[6]; - recipientTokenAccount: TAccountMetas[7]; - custodyTokenAccount: TAccountMetas[8]; - tokenProgram: TAccountMetas[9]; - eventAuthority: TAccountMetas[10]; - program: TAccountMetas[11]; - }; - data: HandleReceiveFinalizedMessageInstructionData; -}; - -export function parseHandleReceiveFinalizedMessageInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedHandleReceiveFinalizedMessageInstruction { - if (instruction.accounts.length < 12) { - // 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: { - authorityPda: getNextAccount(), - tokenMessenger: getNextAccount(), - remoteTokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - tokenPair: getNextAccount(), - feeRecipientTokenAccount: getNextAccount(), - recipientTokenAccount: getNextAccount(), - custodyTokenAccount: getNextAccount(), - tokenProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getHandleReceiveFinalizedMessageInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveUnfinalizedMessage.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveUnfinalizedMessage.ts deleted file mode 100644 index 5a18b9f6a..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/handleReceiveUnfinalizedMessage.ts +++ /dev/null @@ -1,569 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; -import { - getHandleReceiveMessageParamsDecoder, - getHandleReceiveMessageParamsEncoder, - type HandleReceiveMessageParams, - type HandleReceiveMessageParamsArgs, -} from '../types'; - -export const HANDLE_RECEIVE_UNFINALIZED_MESSAGE_DISCRIMINATOR = new Uint8Array([ - 200, 169, 175, 20, 200, 58, 182, 61, -]); - -export function getHandleReceiveUnfinalizedMessageDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - HANDLE_RECEIVE_UNFINALIZED_MESSAGE_DISCRIMINATOR - ); -} - -export type HandleReceiveUnfinalizedMessageInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountAuthorityPda extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountRemoteTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountTokenPair extends string | AccountMeta = string, - TAccountFeeRecipientTokenAccount extends string | AccountMeta = - string, - TAccountRecipientTokenAccount extends string | AccountMeta = string, - TAccountCustodyTokenAccount extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountAuthorityPda extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountAuthorityPda, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountRemoteTokenMessenger extends string - ? ReadonlyAccount - : TAccountRemoteTokenMessenger, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountTokenPair extends string - ? ReadonlyAccount - : TAccountTokenPair, - TAccountFeeRecipientTokenAccount extends string - ? WritableAccount - : TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount extends string - ? WritableAccount - : TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount extends string - ? WritableAccount - : TAccountCustodyTokenAccount, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type HandleReceiveUnfinalizedMessageInstructionData = { - discriminator: ReadonlyUint8Array; - params: HandleReceiveMessageParams; -}; - -export type HandleReceiveUnfinalizedMessageInstructionDataArgs = { - params: HandleReceiveMessageParamsArgs; -}; - -export function getHandleReceiveUnfinalizedMessageInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['params', getHandleReceiveMessageParamsEncoder()], - ]), - (value) => ({ - ...value, - discriminator: HANDLE_RECEIVE_UNFINALIZED_MESSAGE_DISCRIMINATOR, - }) - ); -} - -export function getHandleReceiveUnfinalizedMessageInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['params', getHandleReceiveMessageParamsDecoder()], - ]); -} - -export function getHandleReceiveUnfinalizedMessageInstructionDataCodec(): Codec< - HandleReceiveUnfinalizedMessageInstructionDataArgs, - HandleReceiveUnfinalizedMessageInstructionData -> { - return combineCodec( - getHandleReceiveUnfinalizedMessageInstructionDataEncoder(), - getHandleReceiveUnfinalizedMessageInstructionDataDecoder() - ); -} - -export type HandleReceiveUnfinalizedMessageAsyncInput< - TAccountAuthorityPda extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountTokenPair extends string = string, - TAccountFeeRecipientTokenAccount extends string = string, - TAccountRecipientTokenAccount extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountTokenProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - authorityPda?: TransactionSigner; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken: Address; - tokenPair: Address; - feeRecipientTokenAccount: Address; - recipientTokenAccount: Address; - custodyTokenAccount: Address; - tokenProgram?: Address; - eventAuthority?: Address; - program: Address; - params: HandleReceiveUnfinalizedMessageInstructionDataArgs['params']; -}; - -export async function getHandleReceiveUnfinalizedMessageInstructionAsync< - TAccountAuthorityPda extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountTokenPair extends string, - TAccountFeeRecipientTokenAccount extends string, - TAccountRecipientTokenAccount extends string, - TAccountCustodyTokenAccount extends string, - TAccountTokenProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: HandleReceiveUnfinalizedMessageAsyncInput< - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - HandleReceiveUnfinalizedMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - authorityPda: { value: input.authorityPda ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - tokenPair: { value: input.tokenPair ?? null, isWritable: false }, - feeRecipientTokenAccount: { - value: input.feeRecipientTokenAccount ?? null, - isWritable: true, - }, - recipientTokenAccount: { - value: input.recipientTokenAccount ?? null, - isWritable: true, - }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.authorityPda.value) { - accounts.authorityPda.value = await getProgramDerivedAddress({ - programAddress: - 'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC' as Address<'CCTPV2Sm4AdWt5296sk4P66VBZ7bEhcARwFaaS9YPbeC'>, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 109, 101, 115, 115, 97, 103, 101, 95, 116, 114, 97, 110, 115, 109, - 105, 116, 116, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, 116, - 121, - ]) - ), - getBytesEncoder().encode( - new Uint8Array([ - 166, 95, 200, 29, 15, 239, 168, 134, 12, 179, 184, 63, 8, 155, 2, - 36, 190, 138, 102, 135, 183, 174, 73, 245, 148, 192, 185, 180, 215, - 233, 56, 147, - ]) - ), - ], - }); - } - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.authorityPda), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.tokenPair), - getAccountMeta(accounts.feeRecipientTokenAccount), - getAccountMeta(accounts.recipientTokenAccount), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getHandleReceiveUnfinalizedMessageInstructionDataEncoder().encode( - args as HandleReceiveUnfinalizedMessageInstructionDataArgs - ), - } as HandleReceiveUnfinalizedMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type HandleReceiveUnfinalizedMessageInput< - TAccountAuthorityPda extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountTokenPair extends string = string, - TAccountFeeRecipientTokenAccount extends string = string, - TAccountRecipientTokenAccount extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountTokenProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - authorityPda: TransactionSigner; - tokenMessenger: Address; - remoteTokenMessenger: Address; - tokenMinter: Address; - localToken: Address; - tokenPair: Address; - feeRecipientTokenAccount: Address; - recipientTokenAccount: Address; - custodyTokenAccount: Address; - tokenProgram?: Address; - eventAuthority: Address; - program: Address; - params: HandleReceiveUnfinalizedMessageInstructionDataArgs['params']; -}; - -export function getHandleReceiveUnfinalizedMessageInstruction< - TAccountAuthorityPda extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountTokenPair extends string, - TAccountFeeRecipientTokenAccount extends string, - TAccountRecipientTokenAccount extends string, - TAccountCustodyTokenAccount extends string, - TAccountTokenProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: HandleReceiveUnfinalizedMessageInput< - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): HandleReceiveUnfinalizedMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - authorityPda: { value: input.authorityPda ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - tokenPair: { value: input.tokenPair ?? null, isWritable: false }, - feeRecipientTokenAccount: { - value: input.feeRecipientTokenAccount ?? null, - isWritable: true, - }, - recipientTokenAccount: { - value: input.recipientTokenAccount ?? null, - isWritable: true, - }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.authorityPda), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.tokenPair), - getAccountMeta(accounts.feeRecipientTokenAccount), - getAccountMeta(accounts.recipientTokenAccount), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getHandleReceiveUnfinalizedMessageInstructionDataEncoder().encode( - args as HandleReceiveUnfinalizedMessageInstructionDataArgs - ), - } as HandleReceiveUnfinalizedMessageInstruction< - TProgramAddress, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountTokenMinter, - TAccountLocalToken, - TAccountTokenPair, - TAccountFeeRecipientTokenAccount, - TAccountRecipientTokenAccount, - TAccountCustodyTokenAccount, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedHandleReceiveUnfinalizedMessageInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - authorityPda: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - remoteTokenMessenger: TAccountMetas[2]; - tokenMinter: TAccountMetas[3]; - localToken: TAccountMetas[4]; - tokenPair: TAccountMetas[5]; - feeRecipientTokenAccount: TAccountMetas[6]; - recipientTokenAccount: TAccountMetas[7]; - custodyTokenAccount: TAccountMetas[8]; - tokenProgram: TAccountMetas[9]; - eventAuthority: TAccountMetas[10]; - program: TAccountMetas[11]; - }; - data: HandleReceiveUnfinalizedMessageInstructionData; -}; - -export function parseHandleReceiveUnfinalizedMessageInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedHandleReceiveUnfinalizedMessageInstruction { - if (instruction.accounts.length < 12) { - // 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: { - authorityPda: getNextAccount(), - tokenMessenger: getNextAccount(), - remoteTokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - tokenPair: getNextAccount(), - feeRecipientTokenAccount: getNextAccount(), - recipientTokenAccount: getNextAccount(), - custodyTokenAccount: getNextAccount(), - tokenProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getHandleReceiveUnfinalizedMessageInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/index.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/index.ts deleted file mode 100644 index c62b1d984..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/index.ts +++ /dev/null @@ -1,33 +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 - */ - -export * from './acceptOwnership'; -export * from './addLocalToken'; -export * from './addRemoteTokenMessenger'; -export * from './burnTokenCustody'; -export * from './denylistAccount'; -export * from './depositForBurn'; -export * from './depositForBurnWithHook'; -export * from './handleReceiveFinalizedMessage'; -export * from './handleReceiveUnfinalizedMessage'; -export * from './initialize'; -export * from './linkTokenPair'; -export * from './pause'; -export * from './removeLocalToken'; -export * from './removeRemoteTokenMessenger'; -export * from './setFeeRecipient'; -export * from './setMaxBurnAmountPerMessage'; -export * from './setMinFee'; -export * from './setMinFeeController'; -export * from './setTokenController'; -export * from './transferOwnership'; -export * from './undenylistAccount'; -export * from './unlinkTokenPair'; -export * from './unpause'; -export * from './updateDenylister'; -export * from './updatePauser'; diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/initialize.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/initialize.ts deleted file mode 100644 index 64e38ddfb..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/initialize.ts +++ /dev/null @@ -1,567 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const INITIALIZE_DISCRIMINATOR = new Uint8Array([ - 175, 175, 109, 31, 13, 152, 155, 237, -]); - -export function getInitializeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(INITIALIZE_DISCRIMINATOR); -} - -export type InitializeInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountUpgradeAuthority extends string | AccountMeta = string, - TAccountAuthorityPda extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountTokenMessengerMinterProgramData extends string | AccountMeta = - string, - TAccountTokenMessengerMinterProgram extends string | AccountMeta = - 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe', - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountUpgradeAuthority extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountUpgradeAuthority, - TAccountAuthorityPda extends string - ? ReadonlyAccount - : TAccountAuthorityPda, - TAccountTokenMessenger extends string - ? WritableAccount - : TAccountTokenMessenger, - TAccountTokenMinter extends string - ? WritableAccount - : TAccountTokenMinter, - TAccountTokenMessengerMinterProgramData extends string - ? ReadonlyAccount - : TAccountTokenMessengerMinterProgramData, - TAccountTokenMessengerMinterProgram extends string - ? ReadonlyAccount - : TAccountTokenMessengerMinterProgram, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type InitializeInstructionData = { - discriminator: ReadonlyUint8Array; - tokenController: Address; - denylister: Address; - feeRecipient: Address; - minFeeController: Address; - minFee: number; - messageBodyVersion: number; -}; - -export type InitializeInstructionDataArgs = { - tokenController: Address; - denylister: Address; - feeRecipient: Address; - minFeeController: Address; - minFee: number; - messageBodyVersion: number; -}; - -export function getInitializeInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['tokenController', getAddressEncoder()], - ['denylister', getAddressEncoder()], - ['feeRecipient', getAddressEncoder()], - ['minFeeController', getAddressEncoder()], - ['minFee', getU32Encoder()], - ['messageBodyVersion', getU32Encoder()], - ]), - (value) => ({ ...value, discriminator: INITIALIZE_DISCRIMINATOR }) - ); -} - -export function getInitializeInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['tokenController', getAddressDecoder()], - ['denylister', getAddressDecoder()], - ['feeRecipient', getAddressDecoder()], - ['minFeeController', getAddressDecoder()], - ['minFee', getU32Decoder()], - ['messageBodyVersion', getU32Decoder()], - ]); -} - -export function getInitializeInstructionDataCodec(): Codec< - InitializeInstructionDataArgs, - InitializeInstructionData -> { - return combineCodec( - getInitializeInstructionDataEncoder(), - getInitializeInstructionDataDecoder() - ); -} - -export type InitializeAsyncInput< - TAccountPayer extends string = string, - TAccountUpgradeAuthority extends string = string, - TAccountAuthorityPda extends string = string, - TAccountTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountTokenMessengerMinterProgramData extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - upgradeAuthority: TransactionSigner; - authorityPda?: Address; - tokenMessenger?: Address; - tokenMinter?: Address; - tokenMessengerMinterProgramData: Address; - tokenMessengerMinterProgram?: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - tokenController: InitializeInstructionDataArgs['tokenController']; - denylister: InitializeInstructionDataArgs['denylister']; - feeRecipient: InitializeInstructionDataArgs['feeRecipient']; - minFeeController: InitializeInstructionDataArgs['minFeeController']; - minFee: InitializeInstructionDataArgs['minFee']; - messageBodyVersion: InitializeInstructionDataArgs['messageBodyVersion']; -}; - -export async function getInitializeInstructionAsync< - TAccountPayer extends string, - TAccountUpgradeAuthority extends string, - TAccountAuthorityPda extends string, - TAccountTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountTokenMessengerMinterProgramData extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: InitializeAsyncInput< - TAccountPayer, - TAccountUpgradeAuthority, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountTokenMessengerMinterProgramData, - TAccountTokenMessengerMinterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - InitializeInstruction< - TProgramAddress, - TAccountPayer, - TAccountUpgradeAuthority, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountTokenMessengerMinterProgramData, - TAccountTokenMessengerMinterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - upgradeAuthority: { - value: input.upgradeAuthority ?? null, - isWritable: false, - }, - authorityPda: { value: input.authorityPda ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - tokenMessengerMinterProgramData: { - value: input.tokenMessengerMinterProgramData ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.authorityPda.value) { - accounts.authorityPda.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 115, 101, 110, 100, 101, 114, 95, 97, 117, 116, 104, 111, 114, 105, - 116, 121, - ]) - ), - ], - }); - } - if (!accounts.tokenMessenger.value) { - accounts.tokenMessenger.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 116, 111, 107, 101, 110, 95, 109, 101, 115, 115, 101, 110, 103, 101, - 114, - ]) - ), - ], - }); - } - if (!accounts.tokenMinter.value) { - accounts.tokenMinter.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 116, 111, 107, 101, 110, 95, 109, 105, 110, 116, 101, 114, - ]) - ), - ], - }); - } - if (!accounts.tokenMessengerMinterProgram.value) { - accounts.tokenMessengerMinterProgram.value = - 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.upgradeAuthority), - getAccountMeta(accounts.authorityPda), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.tokenMessengerMinterProgramData), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getInitializeInstructionDataEncoder().encode( - args as InitializeInstructionDataArgs - ), - } as InitializeInstruction< - TProgramAddress, - TAccountPayer, - TAccountUpgradeAuthority, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountTokenMessengerMinterProgramData, - TAccountTokenMessengerMinterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type InitializeInput< - TAccountPayer extends string = string, - TAccountUpgradeAuthority extends string = string, - TAccountAuthorityPda extends string = string, - TAccountTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountTokenMessengerMinterProgramData extends string = string, - TAccountTokenMessengerMinterProgram extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - upgradeAuthority: TransactionSigner; - authorityPda: Address; - tokenMessenger: Address; - tokenMinter: Address; - tokenMessengerMinterProgramData: Address; - tokenMessengerMinterProgram?: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - tokenController: InitializeInstructionDataArgs['tokenController']; - denylister: InitializeInstructionDataArgs['denylister']; - feeRecipient: InitializeInstructionDataArgs['feeRecipient']; - minFeeController: InitializeInstructionDataArgs['minFeeController']; - minFee: InitializeInstructionDataArgs['minFee']; - messageBodyVersion: InitializeInstructionDataArgs['messageBodyVersion']; -}; - -export function getInitializeInstruction< - TAccountPayer extends string, - TAccountUpgradeAuthority extends string, - TAccountAuthorityPda extends string, - TAccountTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountTokenMessengerMinterProgramData extends string, - TAccountTokenMessengerMinterProgram extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: InitializeInput< - TAccountPayer, - TAccountUpgradeAuthority, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountTokenMessengerMinterProgramData, - TAccountTokenMessengerMinterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): InitializeInstruction< - TProgramAddress, - TAccountPayer, - TAccountUpgradeAuthority, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountTokenMessengerMinterProgramData, - TAccountTokenMessengerMinterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - upgradeAuthority: { - value: input.upgradeAuthority ?? null, - isWritable: false, - }, - authorityPda: { value: input.authorityPda ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - tokenMessengerMinterProgramData: { - value: input.tokenMessengerMinterProgramData ?? null, - isWritable: false, - }, - tokenMessengerMinterProgram: { - value: input.tokenMessengerMinterProgram ?? null, - isWritable: false, - }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.tokenMessengerMinterProgram.value) { - accounts.tokenMessengerMinterProgram.value = - 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; - } - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.upgradeAuthority), - getAccountMeta(accounts.authorityPda), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.tokenMessengerMinterProgramData), - getAccountMeta(accounts.tokenMessengerMinterProgram), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getInitializeInstructionDataEncoder().encode( - args as InitializeInstructionDataArgs - ), - } as InitializeInstruction< - TProgramAddress, - TAccountPayer, - TAccountUpgradeAuthority, - TAccountAuthorityPda, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountTokenMessengerMinterProgramData, - TAccountTokenMessengerMinterProgram, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedInitializeInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - upgradeAuthority: TAccountMetas[1]; - authorityPda: TAccountMetas[2]; - tokenMessenger: TAccountMetas[3]; - tokenMinter: TAccountMetas[4]; - tokenMessengerMinterProgramData: TAccountMetas[5]; - tokenMessengerMinterProgram: TAccountMetas[6]; - systemProgram: TAccountMetas[7]; - eventAuthority: TAccountMetas[8]; - program: TAccountMetas[9]; - }; - data: InitializeInstructionData; -}; - -export function parseInitializeInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedInitializeInstruction { - if (instruction.accounts.length < 10) { - // 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: { - payer: getNextAccount(), - upgradeAuthority: getNextAccount(), - authorityPda: getNextAccount(), - tokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - tokenMessengerMinterProgramData: getNextAccount(), - tokenMessengerMinterProgram: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getInitializeInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/linkTokenPair.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/linkTokenPair.ts deleted file mode 100644 index b71c69dc0..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/linkTokenPair.ts +++ /dev/null @@ -1,425 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const LINK_TOKEN_PAIR_DISCRIMINATOR = new Uint8Array([ - 68, 162, 24, 104, 125, 46, 130, 12, -]); - -export function getLinkTokenPairDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - LINK_TOKEN_PAIR_DISCRIMINATOR - ); -} - -export type LinkTokenPairInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountTokenController extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountTokenPair extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountTokenController extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountTokenController, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountTokenPair extends string - ? WritableAccount - : TAccountTokenPair, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type LinkTokenPairInstructionData = { - discriminator: ReadonlyUint8Array; - localToken: Address; - remoteDomain: number; - remoteToken: Address; -}; - -export type LinkTokenPairInstructionDataArgs = { - localToken: Address; - remoteDomain: number; - remoteToken: Address; -}; - -export function getLinkTokenPairInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['localToken', getAddressEncoder()], - ['remoteDomain', getU32Encoder()], - ['remoteToken', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: LINK_TOKEN_PAIR_DISCRIMINATOR }) - ); -} - -export function getLinkTokenPairInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['localToken', getAddressDecoder()], - ['remoteDomain', getU32Decoder()], - ['remoteToken', getAddressDecoder()], - ]); -} - -export function getLinkTokenPairInstructionDataCodec(): Codec< - LinkTokenPairInstructionDataArgs, - LinkTokenPairInstructionData -> { - return combineCodec( - getLinkTokenPairInstructionDataEncoder(), - getLinkTokenPairInstructionDataDecoder() - ); -} - -export type LinkTokenPairAsyncInput< - TAccountPayer extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountTokenPair extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - tokenPair: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - localToken: LinkTokenPairInstructionDataArgs['localToken']; - remoteDomain: LinkTokenPairInstructionDataArgs['remoteDomain']; - remoteToken: LinkTokenPairInstructionDataArgs['remoteToken']; -}; - -export async function getLinkTokenPairInstructionAsync< - TAccountPayer extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountTokenPair extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: LinkTokenPairAsyncInput< - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - LinkTokenPairInstruction< - TProgramAddress, - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - tokenPair: { value: input.tokenPair ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.tokenPair), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getLinkTokenPairInstructionDataEncoder().encode( - args as LinkTokenPairInstructionDataArgs - ), - } as LinkTokenPairInstruction< - TProgramAddress, - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type LinkTokenPairInput< - TAccountPayer extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountTokenPair extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - tokenPair: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - localToken: LinkTokenPairInstructionDataArgs['localToken']; - remoteDomain: LinkTokenPairInstructionDataArgs['remoteDomain']; - remoteToken: LinkTokenPairInstructionDataArgs['remoteToken']; -}; - -export function getLinkTokenPairInstruction< - TAccountPayer extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountTokenPair extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: LinkTokenPairInput< - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): LinkTokenPairInstruction< - TProgramAddress, - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - tokenPair: { value: input.tokenPair ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.tokenPair), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getLinkTokenPairInstructionDataEncoder().encode( - args as LinkTokenPairInstructionDataArgs - ), - } as LinkTokenPairInstruction< - TProgramAddress, - TAccountPayer, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedLinkTokenPairInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - tokenController: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - tokenPair: TAccountMetas[3]; - systemProgram: TAccountMetas[4]; - eventAuthority: TAccountMetas[5]; - program: TAccountMetas[6]; - }; - data: LinkTokenPairInstructionData; -}; - -export function parseLinkTokenPairInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedLinkTokenPairInstruction { - if (instruction.accounts.length < 7) { - // 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: { - payer: getNextAccount(), - tokenController: getNextAccount(), - tokenMinter: getNextAccount(), - tokenPair: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getLinkTokenPairInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/pause.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/pause.ts deleted file mode 100644 index c74faf922..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/pause.ts +++ /dev/null @@ -1,301 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const PAUSE_DISCRIMINATOR = new Uint8Array([ - 211, 22, 221, 251, 74, 121, 193, 47, -]); - -export function getPauseDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(PAUSE_DISCRIMINATOR); -} - -export type PauseInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountPauser extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPauser extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountPauser, - TAccountTokenMinter extends string - ? WritableAccount - : TAccountTokenMinter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type PauseInstructionData = { discriminator: ReadonlyUint8Array }; - -export type PauseInstructionDataArgs = {}; - -export function getPauseInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: PAUSE_DISCRIMINATOR }) - ); -} - -export function getPauseInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getPauseInstructionDataCodec(): Codec< - PauseInstructionDataArgs, - PauseInstructionData -> { - return combineCodec( - getPauseInstructionDataEncoder(), - getPauseInstructionDataDecoder() - ); -} - -export type PauseAsyncInput< - TAccountPauser extends string = string, - TAccountTokenMinter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pauser: TransactionSigner; - tokenMinter: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getPauseInstructionAsync< - TAccountPauser extends string, - TAccountTokenMinter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: PauseAsyncInput< - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - PauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pauser: { value: input.pauser ?? null, isWritable: false }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pauser), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getPauseInstructionDataEncoder().encode({}), - } as PauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type PauseInput< - TAccountPauser extends string = string, - TAccountTokenMinter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pauser: TransactionSigner; - tokenMinter: Address; - eventAuthority: Address; - program: Address; -}; - -export function getPauseInstruction< - TAccountPauser extends string, - TAccountTokenMinter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: PauseInput< - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): PauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pauser: { value: input.pauser ?? null, isWritable: false }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pauser), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getPauseInstructionDataEncoder().encode({}), - } as PauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedPauseInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - pauser: TAccountMetas[0]; - tokenMinter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: PauseInstructionData; -}; - -export function parsePauseInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedPauseInstruction { - if (instruction.accounts.length < 4) { - // 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: { - pauser: getNextAccount(), - tokenMinter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getPauseInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/removeLocalToken.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/removeLocalToken.ts deleted file mode 100644 index 7977fc73f..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/removeLocalToken.ts +++ /dev/null @@ -1,446 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const REMOVE_LOCAL_TOKEN_DISCRIMINATOR = new Uint8Array([ - 27, 43, 66, 170, 188, 44, 109, 97, -]); - -export function getRemoveLocalTokenDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - REMOVE_LOCAL_TOKEN_DISCRIMINATOR - ); -} - -export type RemoveLocalTokenInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountPayee extends string | AccountMeta = string, - TAccountTokenController extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountCustodyTokenAccount extends string | AccountMeta = string, - TAccountCustodyTokenMint extends string | AccountMeta = string, - TAccountTokenProgram extends string | AccountMeta = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayee extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayee, - TAccountTokenController extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountTokenController, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountCustodyTokenAccount extends string - ? WritableAccount - : TAccountCustodyTokenAccount, - TAccountCustodyTokenMint extends string - ? WritableAccount - : TAccountCustodyTokenMint, - TAccountTokenProgram extends string - ? ReadonlyAccount - : TAccountTokenProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type RemoveLocalTokenInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type RemoveLocalTokenInstructionDataArgs = {}; - -export function getRemoveLocalTokenInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: REMOVE_LOCAL_TOKEN_DISCRIMINATOR }) - ); -} - -export function getRemoveLocalTokenInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getRemoveLocalTokenInstructionDataCodec(): Codec< - RemoveLocalTokenInstructionDataArgs, - RemoveLocalTokenInstructionData -> { - return combineCodec( - getRemoveLocalTokenInstructionDataEncoder(), - getRemoveLocalTokenInstructionDataDecoder() - ); -} - -export type RemoveLocalTokenAsyncInput< - TAccountPayee extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountCustodyTokenMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payee: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - localToken: Address; - custodyTokenAccount: Address; - custodyTokenMint: Address; - tokenProgram?: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getRemoveLocalTokenInstructionAsync< - TAccountPayee extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountCustodyTokenAccount extends string, - TAccountCustodyTokenMint extends string, - TAccountTokenProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: RemoveLocalTokenAsyncInput< - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - RemoveLocalTokenInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - custodyTokenMint: { - value: input.custodyTokenMint ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.custodyTokenMint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getRemoveLocalTokenInstructionDataEncoder().encode({}), - } as RemoveLocalTokenInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type RemoveLocalTokenInput< - TAccountPayee extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountCustodyTokenAccount extends string = string, - TAccountCustodyTokenMint extends string = string, - TAccountTokenProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payee: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - localToken: Address; - custodyTokenAccount: Address; - custodyTokenMint: Address; - tokenProgram?: Address; - eventAuthority: Address; - program: Address; -}; - -export function getRemoveLocalTokenInstruction< - TAccountPayee extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountCustodyTokenAccount extends string, - TAccountCustodyTokenMint extends string, - TAccountTokenProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: RemoveLocalTokenInput< - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): RemoveLocalTokenInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - custodyTokenAccount: { - value: input.custodyTokenAccount ?? null, - isWritable: true, - }, - custodyTokenMint: { - value: input.custodyTokenMint ?? null, - isWritable: true, - }, - tokenProgram: { value: input.tokenProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.tokenProgram.value) { - accounts.tokenProgram.value = - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' as Address<'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.custodyTokenAccount), - getAccountMeta(accounts.custodyTokenMint), - getAccountMeta(accounts.tokenProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getRemoveLocalTokenInstructionDataEncoder().encode({}), - } as RemoveLocalTokenInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountCustodyTokenAccount, - TAccountCustodyTokenMint, - TAccountTokenProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedRemoveLocalTokenInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payee: TAccountMetas[0]; - tokenController: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - localToken: TAccountMetas[3]; - custodyTokenAccount: TAccountMetas[4]; - custodyTokenMint: TAccountMetas[5]; - tokenProgram: TAccountMetas[6]; - eventAuthority: TAccountMetas[7]; - program: TAccountMetas[8]; - }; - data: RemoveLocalTokenInstructionData; -}; - -export function parseRemoveLocalTokenInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedRemoveLocalTokenInstruction { - if (instruction.accounts.length < 9) { - // 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: { - payee: getNextAccount(), - tokenController: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - custodyTokenAccount: getNextAccount(), - custodyTokenMint: getNextAccount(), - tokenProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getRemoveLocalTokenInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/removeRemoteTokenMessenger.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/removeRemoteTokenMessenger.ts deleted file mode 100644 index c62e19a40..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/removeRemoteTokenMessenger.ts +++ /dev/null @@ -1,362 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const REMOVE_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([ - 65, 114, 66, 85, 169, 98, 177, 146, -]); - -export function getRemoveRemoteTokenMessengerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - REMOVE_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR - ); -} - -export type RemoveRemoteTokenMessengerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountPayee extends string | AccountMeta = string, - TAccountOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountRemoteTokenMessenger extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayee extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayee, - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountRemoteTokenMessenger extends string - ? WritableAccount - : TAccountRemoteTokenMessenger, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type RemoveRemoteTokenMessengerInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type RemoveRemoteTokenMessengerInstructionDataArgs = {}; - -export function getRemoveRemoteTokenMessengerInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ - ...value, - discriminator: REMOVE_REMOTE_TOKEN_MESSENGER_DISCRIMINATOR, - }) - ); -} - -export function getRemoveRemoteTokenMessengerInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getRemoveRemoteTokenMessengerInstructionDataCodec(): Codec< - RemoveRemoteTokenMessengerInstructionDataArgs, - RemoveRemoteTokenMessengerInstructionData -> { - return combineCodec( - getRemoveRemoteTokenMessengerInstructionDataEncoder(), - getRemoveRemoteTokenMessengerInstructionDataDecoder() - ); -} - -export type RemoveRemoteTokenMessengerAsyncInput< - TAccountPayee extends string = string, - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payee: TransactionSigner; - owner: TransactionSigner; - tokenMessenger: Address; - remoteTokenMessenger: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getRemoveRemoteTokenMessengerInstructionAsync< - TAccountPayee extends string, - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: RemoveRemoteTokenMessengerAsyncInput< - TAccountPayee, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - RemoveRemoteTokenMessengerInstruction< - TProgramAddress, - TAccountPayee, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getRemoveRemoteTokenMessengerInstructionDataEncoder().encode({}), - } as RemoveRemoteTokenMessengerInstruction< - TProgramAddress, - TAccountPayee, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type RemoveRemoteTokenMessengerInput< - TAccountPayee extends string = string, - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountRemoteTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payee: TransactionSigner; - owner: TransactionSigner; - tokenMessenger: Address; - remoteTokenMessenger: Address; - eventAuthority: Address; - program: Address; -}; - -export function getRemoveRemoteTokenMessengerInstruction< - TAccountPayee extends string, - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountRemoteTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: RemoveRemoteTokenMessengerInput< - TAccountPayee, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): RemoveRemoteTokenMessengerInstruction< - TProgramAddress, - TAccountPayee, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - remoteTokenMessenger: { - value: input.remoteTokenMessenger ?? null, - isWritable: true, - }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.remoteTokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getRemoveRemoteTokenMessengerInstructionDataEncoder().encode({}), - } as RemoveRemoteTokenMessengerInstruction< - TProgramAddress, - TAccountPayee, - TAccountOwner, - TAccountTokenMessenger, - TAccountRemoteTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedRemoveRemoteTokenMessengerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payee: TAccountMetas[0]; - owner: TAccountMetas[1]; - tokenMessenger: TAccountMetas[2]; - remoteTokenMessenger: TAccountMetas[3]; - eventAuthority: TAccountMetas[4]; - program: TAccountMetas[5]; - }; - data: RemoveRemoteTokenMessengerInstructionData; -}; - -export function parseRemoveRemoteTokenMessengerInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedRemoveRemoteTokenMessengerInstruction { - if (instruction.accounts.length < 6) { - // 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: { - payee: getNextAccount(), - owner: getNextAccount(), - tokenMessenger: getNextAccount(), - remoteTokenMessenger: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getRemoveRemoteTokenMessengerInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/setFeeRecipient.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/setFeeRecipient.ts deleted file mode 100644 index 1249199fc..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/setFeeRecipient.ts +++ /dev/null @@ -1,324 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_FEE_RECIPIENT_DISCRIMINATOR = new Uint8Array([ - 227, 18, 215, 42, 237, 246, 151, 66, -]); - -export function getSetFeeRecipientDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_FEE_RECIPIENT_DISCRIMINATOR - ); -} - -export type SetFeeRecipientInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountTokenMessenger extends string - ? WritableAccount - : TAccountTokenMessenger, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type SetFeeRecipientInstructionData = { - discriminator: ReadonlyUint8Array; - newFeeRecipient: Address; -}; - -export type SetFeeRecipientInstructionDataArgs = { newFeeRecipient: Address }; - -export function getSetFeeRecipientInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newFeeRecipient', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: SET_FEE_RECIPIENT_DISCRIMINATOR }) - ); -} - -export function getSetFeeRecipientInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newFeeRecipient', getAddressDecoder()], - ]); -} - -export function getSetFeeRecipientInstructionDataCodec(): Codec< - SetFeeRecipientInstructionDataArgs, - SetFeeRecipientInstructionData -> { - return combineCodec( - getSetFeeRecipientInstructionDataEncoder(), - getSetFeeRecipientInstructionDataDecoder() - ); -} - -export type SetFeeRecipientAsyncInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - eventAuthority?: Address; - program: Address; - newFeeRecipient: SetFeeRecipientInstructionDataArgs['newFeeRecipient']; -}; - -export async function getSetFeeRecipientInstructionAsync< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: SetFeeRecipientAsyncInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - SetFeeRecipientInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetFeeRecipientInstructionDataEncoder().encode( - args as SetFeeRecipientInstructionDataArgs - ), - } as SetFeeRecipientInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type SetFeeRecipientInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - eventAuthority: Address; - program: Address; - newFeeRecipient: SetFeeRecipientInstructionDataArgs['newFeeRecipient']; -}; - -export function getSetFeeRecipientInstruction< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: SetFeeRecipientInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): SetFeeRecipientInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetFeeRecipientInstructionDataEncoder().encode( - args as SetFeeRecipientInstructionDataArgs - ), - } as SetFeeRecipientInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedSetFeeRecipientInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: SetFeeRecipientInstructionData; -}; - -export function parseSetFeeRecipientInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetFeeRecipientInstruction { - if (instruction.accounts.length < 4) { - // 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: { - owner: getNextAccount(), - tokenMessenger: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getSetFeeRecipientInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/setMaxBurnAmountPerMessage.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/setMaxBurnAmountPerMessage.ts deleted file mode 100644 index 136e7a2f9..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/setMaxBurnAmountPerMessage.ts +++ /dev/null @@ -1,359 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_MAX_BURN_AMOUNT_PER_MESSAGE_DISCRIMINATOR = new Uint8Array([ - 30, 128, 145, 240, 70, 237, 109, 207, -]); - -export function getSetMaxBurnAmountPerMessageDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_MAX_BURN_AMOUNT_PER_MESSAGE_DISCRIMINATOR - ); -} - -export type SetMaxBurnAmountPerMessageInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountTokenController extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountLocalToken extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountTokenController extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountTokenController, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountLocalToken extends string - ? WritableAccount - : TAccountLocalToken, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type SetMaxBurnAmountPerMessageInstructionData = { - discriminator: ReadonlyUint8Array; - burnLimitPerMessage: bigint; -}; - -export type SetMaxBurnAmountPerMessageInstructionDataArgs = { - burnLimitPerMessage: number | bigint; -}; - -export function getSetMaxBurnAmountPerMessageInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['burnLimitPerMessage', getU64Encoder()], - ]), - (value) => ({ - ...value, - discriminator: SET_MAX_BURN_AMOUNT_PER_MESSAGE_DISCRIMINATOR, - }) - ); -} - -export function getSetMaxBurnAmountPerMessageInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['burnLimitPerMessage', getU64Decoder()], - ]); -} - -export function getSetMaxBurnAmountPerMessageInstructionDataCodec(): Codec< - SetMaxBurnAmountPerMessageInstructionDataArgs, - SetMaxBurnAmountPerMessageInstructionData -> { - return combineCodec( - getSetMaxBurnAmountPerMessageInstructionDataEncoder(), - getSetMaxBurnAmountPerMessageInstructionDataDecoder() - ); -} - -export type SetMaxBurnAmountPerMessageAsyncInput< - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - tokenController: TransactionSigner; - tokenMinter: Address; - localToken: Address; - eventAuthority?: Address; - program: Address; - burnLimitPerMessage: SetMaxBurnAmountPerMessageInstructionDataArgs['burnLimitPerMessage']; -}; - -export async function getSetMaxBurnAmountPerMessageInstructionAsync< - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: SetMaxBurnAmountPerMessageAsyncInput< - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - SetMaxBurnAmountPerMessageInstruction< - TProgramAddress, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetMaxBurnAmountPerMessageInstructionDataEncoder().encode( - args as SetMaxBurnAmountPerMessageInstructionDataArgs - ), - } as SetMaxBurnAmountPerMessageInstruction< - TProgramAddress, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type SetMaxBurnAmountPerMessageInput< - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountLocalToken extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - tokenController: TransactionSigner; - tokenMinter: Address; - localToken: Address; - eventAuthority: Address; - program: Address; - burnLimitPerMessage: SetMaxBurnAmountPerMessageInstructionDataArgs['burnLimitPerMessage']; -}; - -export function getSetMaxBurnAmountPerMessageInstruction< - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountLocalToken extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: SetMaxBurnAmountPerMessageInput< - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): SetMaxBurnAmountPerMessageInstruction< - TProgramAddress, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - localToken: { value: input.localToken ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.localToken), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetMaxBurnAmountPerMessageInstructionDataEncoder().encode( - args as SetMaxBurnAmountPerMessageInstructionDataArgs - ), - } as SetMaxBurnAmountPerMessageInstruction< - TProgramAddress, - TAccountTokenController, - TAccountTokenMinter, - TAccountLocalToken, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedSetMaxBurnAmountPerMessageInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - tokenController: TAccountMetas[0]; - tokenMinter: TAccountMetas[1]; - localToken: TAccountMetas[2]; - eventAuthority: TAccountMetas[3]; - program: TAccountMetas[4]; - }; - data: SetMaxBurnAmountPerMessageInstructionData; -}; - -export function parseSetMaxBurnAmountPerMessageInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetMaxBurnAmountPerMessageInstruction { - if (instruction.accounts.length < 5) { - // 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: { - tokenController: getNextAccount(), - tokenMinter: getNextAccount(), - localToken: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getSetMaxBurnAmountPerMessageInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/setMinFee.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/setMinFee.ts deleted file mode 100644 index 410b8ec6a..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/setMinFee.ts +++ /dev/null @@ -1,328 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_MIN_FEE_DISCRIMINATOR = new Uint8Array([ - 114, 198, 35, 3, 41, 196, 194, 246, -]); - -export function getSetMinFeeDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(SET_MIN_FEE_DISCRIMINATOR); -} - -export type SetMinFeeInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMinFeeController extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountMinFeeController extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountMinFeeController, - TAccountTokenMessenger extends string - ? WritableAccount - : TAccountTokenMessenger, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type SetMinFeeInstructionData = { - discriminator: ReadonlyUint8Array; - newMinFee: number; -}; - -export type SetMinFeeInstructionDataArgs = { newMinFee: number }; - -export function getSetMinFeeInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newMinFee', getU32Encoder()], - ]), - (value) => ({ ...value, discriminator: SET_MIN_FEE_DISCRIMINATOR }) - ); -} - -export function getSetMinFeeInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newMinFee', getU32Decoder()], - ]); -} - -export function getSetMinFeeInstructionDataCodec(): Codec< - SetMinFeeInstructionDataArgs, - SetMinFeeInstructionData -> { - return combineCodec( - getSetMinFeeInstructionDataEncoder(), - getSetMinFeeInstructionDataDecoder() - ); -} - -export type SetMinFeeAsyncInput< - TAccountMinFeeController extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - minFeeController: TransactionSigner; - tokenMessenger: Address; - eventAuthority?: Address; - program: Address; - newMinFee: SetMinFeeInstructionDataArgs['newMinFee']; -}; - -export async function getSetMinFeeInstructionAsync< - TAccountMinFeeController extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: SetMinFeeAsyncInput< - TAccountMinFeeController, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - SetMinFeeInstruction< - TProgramAddress, - TAccountMinFeeController, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - minFeeController: { - value: input.minFeeController ?? null, - isWritable: false, - }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.minFeeController), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetMinFeeInstructionDataEncoder().encode( - args as SetMinFeeInstructionDataArgs - ), - } as SetMinFeeInstruction< - TProgramAddress, - TAccountMinFeeController, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type SetMinFeeInput< - TAccountMinFeeController extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - minFeeController: TransactionSigner; - tokenMessenger: Address; - eventAuthority: Address; - program: Address; - newMinFee: SetMinFeeInstructionDataArgs['newMinFee']; -}; - -export function getSetMinFeeInstruction< - TAccountMinFeeController extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: SetMinFeeInput< - TAccountMinFeeController, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): SetMinFeeInstruction< - TProgramAddress, - TAccountMinFeeController, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - minFeeController: { - value: input.minFeeController ?? null, - isWritable: false, - }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.minFeeController), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetMinFeeInstructionDataEncoder().encode( - args as SetMinFeeInstructionDataArgs - ), - } as SetMinFeeInstruction< - TProgramAddress, - TAccountMinFeeController, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedSetMinFeeInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - minFeeController: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: SetMinFeeInstructionData; -}; - -export function parseSetMinFeeInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetMinFeeInstruction { - if (instruction.accounts.length < 4) { - // 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: { - minFeeController: getNextAccount(), - tokenMessenger: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getSetMinFeeInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/setMinFeeController.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/setMinFeeController.ts deleted file mode 100644 index ee003d2a5..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/setMinFeeController.ts +++ /dev/null @@ -1,331 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_MIN_FEE_CONTROLLER_DISCRIMINATOR = new Uint8Array([ - 195, 142, 74, 84, 234, 94, 180, 113, -]); - -export function getSetMinFeeControllerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_MIN_FEE_CONTROLLER_DISCRIMINATOR - ); -} - -export type SetMinFeeControllerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountTokenMessenger extends string - ? WritableAccount - : TAccountTokenMessenger, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type SetMinFeeControllerInstructionData = { - discriminator: ReadonlyUint8Array; - newMinFeeController: Address; -}; - -export type SetMinFeeControllerInstructionDataArgs = { - newMinFeeController: Address; -}; - -export function getSetMinFeeControllerInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newMinFeeController', getAddressEncoder()], - ]), - (value) => ({ - ...value, - discriminator: SET_MIN_FEE_CONTROLLER_DISCRIMINATOR, - }) - ); -} - -export function getSetMinFeeControllerInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newMinFeeController', getAddressDecoder()], - ]); -} - -export function getSetMinFeeControllerInstructionDataCodec(): Codec< - SetMinFeeControllerInstructionDataArgs, - SetMinFeeControllerInstructionData -> { - return combineCodec( - getSetMinFeeControllerInstructionDataEncoder(), - getSetMinFeeControllerInstructionDataDecoder() - ); -} - -export type SetMinFeeControllerAsyncInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - eventAuthority?: Address; - program: Address; - newMinFeeController: SetMinFeeControllerInstructionDataArgs['newMinFeeController']; -}; - -export async function getSetMinFeeControllerInstructionAsync< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: SetMinFeeControllerAsyncInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - SetMinFeeControllerInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetMinFeeControllerInstructionDataEncoder().encode( - args as SetMinFeeControllerInstructionDataArgs - ), - } as SetMinFeeControllerInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type SetMinFeeControllerInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - eventAuthority: Address; - program: Address; - newMinFeeController: SetMinFeeControllerInstructionDataArgs['newMinFeeController']; -}; - -export function getSetMinFeeControllerInstruction< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: SetMinFeeControllerInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): SetMinFeeControllerInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetMinFeeControllerInstructionDataEncoder().encode( - args as SetMinFeeControllerInstructionDataArgs - ), - } as SetMinFeeControllerInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedSetMinFeeControllerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: SetMinFeeControllerInstructionData; -}; - -export function parseSetMinFeeControllerInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetMinFeeControllerInstruction { - if (instruction.accounts.length < 4) { - // 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: { - owner: getNextAccount(), - tokenMessenger: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getSetMinFeeControllerInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/setTokenController.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/setTokenController.ts deleted file mode 100644 index d3c7fdbbd..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/setTokenController.ts +++ /dev/null @@ -1,350 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const SET_TOKEN_CONTROLLER_DISCRIMINATOR = new Uint8Array([ - 88, 6, 98, 10, 79, 59, 15, 24, -]); - -export function getSetTokenControllerDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - SET_TOKEN_CONTROLLER_DISCRIMINATOR - ); -} - -export type SetTokenControllerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountTokenMinter extends string - ? WritableAccount - : TAccountTokenMinter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type SetTokenControllerInstructionData = { - discriminator: ReadonlyUint8Array; - tokenController: Address; -}; - -export type SetTokenControllerInstructionDataArgs = { - tokenController: Address; -}; - -export function getSetTokenControllerInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['tokenController', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: SET_TOKEN_CONTROLLER_DISCRIMINATOR }) - ); -} - -export function getSetTokenControllerInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['tokenController', getAddressDecoder()], - ]); -} - -export function getSetTokenControllerInstructionDataCodec(): Codec< - SetTokenControllerInstructionDataArgs, - SetTokenControllerInstructionData -> { - return combineCodec( - getSetTokenControllerInstructionDataEncoder(), - getSetTokenControllerInstructionDataDecoder() - ); -} - -export type SetTokenControllerAsyncInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - tokenMinter: Address; - eventAuthority?: Address; - program: Address; - tokenController: SetTokenControllerInstructionDataArgs['tokenController']; -}; - -export async function getSetTokenControllerInstructionAsync< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: SetTokenControllerAsyncInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - SetTokenControllerInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetTokenControllerInstructionDataEncoder().encode( - args as SetTokenControllerInstructionDataArgs - ), - } as SetTokenControllerInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type SetTokenControllerInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - tokenMinter: Address; - eventAuthority: Address; - program: Address; - tokenController: SetTokenControllerInstructionDataArgs['tokenController']; -}; - -export function getSetTokenControllerInstruction< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: SetTokenControllerInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): SetTokenControllerInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getSetTokenControllerInstructionDataEncoder().encode( - args as SetTokenControllerInstructionDataArgs - ), - } as SetTokenControllerInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedSetTokenControllerInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - eventAuthority: TAccountMetas[3]; - program: TAccountMetas[4]; - }; - data: SetTokenControllerInstructionData; -}; - -export function parseSetTokenControllerInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedSetTokenControllerInstruction { - if (instruction.accounts.length < 5) { - // 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: { - owner: getNextAccount(), - tokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getSetTokenControllerInstructionDataDecoder().decode( - instruction.data - ), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/transferOwnership.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/transferOwnership.ts deleted file mode 100644 index 1e01e6da2..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/transferOwnership.ts +++ /dev/null @@ -1,324 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const TRANSFER_OWNERSHIP_DISCRIMINATOR = new Uint8Array([ - 65, 177, 215, 73, 53, 45, 99, 47, -]); - -export function getTransferOwnershipDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - TRANSFER_OWNERSHIP_DISCRIMINATOR - ); -} - -export type TransferOwnershipInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountTokenMessenger extends string - ? WritableAccount - : TAccountTokenMessenger, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type TransferOwnershipInstructionData = { - discriminator: ReadonlyUint8Array; - newOwner: Address; -}; - -export type TransferOwnershipInstructionDataArgs = { newOwner: Address }; - -export function getTransferOwnershipInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newOwner', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: TRANSFER_OWNERSHIP_DISCRIMINATOR }) - ); -} - -export function getTransferOwnershipInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newOwner', getAddressDecoder()], - ]); -} - -export function getTransferOwnershipInstructionDataCodec(): Codec< - TransferOwnershipInstructionDataArgs, - TransferOwnershipInstructionData -> { - return combineCodec( - getTransferOwnershipInstructionDataEncoder(), - getTransferOwnershipInstructionDataDecoder() - ); -} - -export type TransferOwnershipAsyncInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - eventAuthority?: Address; - program: Address; - newOwner: TransferOwnershipInstructionDataArgs['newOwner']; -}; - -export async function getTransferOwnershipInstructionAsync< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: TransferOwnershipAsyncInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - TransferOwnershipInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getTransferOwnershipInstructionDataEncoder().encode( - args as TransferOwnershipInstructionDataArgs - ), - } as TransferOwnershipInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type TransferOwnershipInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - eventAuthority: Address; - program: Address; - newOwner: TransferOwnershipInstructionDataArgs['newOwner']; -}; - -export function getTransferOwnershipInstruction< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: TransferOwnershipInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): TransferOwnershipInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getTransferOwnershipInstructionDataEncoder().encode( - args as TransferOwnershipInstructionDataArgs - ), - } as TransferOwnershipInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedTransferOwnershipInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: TransferOwnershipInstructionData; -}; - -export function parseTransferOwnershipInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedTransferOwnershipInstruction { - if (instruction.accounts.length < 4) { - // 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: { - owner: getNextAccount(), - tokenMessenger: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getTransferOwnershipInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/undenylistAccount.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/undenylistAccount.ts deleted file mode 100644 index a80c7e9d6..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/undenylistAccount.ts +++ /dev/null @@ -1,403 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UNDENYLIST_ACCOUNT_DISCRIMINATOR = new Uint8Array([ - 57, 36, 43, 168, 62, 172, 33, 39, -]); - -export function getUndenylistAccountDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - UNDENYLIST_ACCOUNT_DISCRIMINATOR - ); -} - -export type UndenylistAccountInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountPayer extends string | AccountMeta = string, - TAccountDenylister extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountDenylistAccount extends string | AccountMeta = string, - TAccountSystemProgram extends string | AccountMeta = - '11111111111111111111111111111111', - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayer extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayer, - TAccountDenylister extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountDenylister, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountDenylistAccount extends string - ? WritableAccount - : TAccountDenylistAccount, - TAccountSystemProgram extends string - ? ReadonlyAccount - : TAccountSystemProgram, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UndenylistAccountInstructionData = { - discriminator: ReadonlyUint8Array; - account: Address; -}; - -export type UndenylistAccountInstructionDataArgs = { account: Address }; - -export function getUndenylistAccountInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['account', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: UNDENYLIST_ACCOUNT_DISCRIMINATOR }) - ); -} - -export function getUndenylistAccountInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['account', getAddressDecoder()], - ]); -} - -export function getUndenylistAccountInstructionDataCodec(): Codec< - UndenylistAccountInstructionDataArgs, - UndenylistAccountInstructionData -> { - return combineCodec( - getUndenylistAccountInstructionDataEncoder(), - getUndenylistAccountInstructionDataDecoder() - ); -} - -export type UndenylistAccountAsyncInput< - TAccountPayer extends string = string, - TAccountDenylister extends string = string, - TAccountTokenMessenger extends string = string, - TAccountDenylistAccount extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - denylister: TransactionSigner; - tokenMessenger: Address; - denylistAccount: Address; - systemProgram?: Address; - eventAuthority?: Address; - program: Address; - account: UndenylistAccountInstructionDataArgs['account']; -}; - -export async function getUndenylistAccountInstructionAsync< - TAccountPayer extends string, - TAccountDenylister extends string, - TAccountTokenMessenger extends string, - TAccountDenylistAccount extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: UndenylistAccountAsyncInput< - TAccountPayer, - TAccountDenylister, - TAccountTokenMessenger, - TAccountDenylistAccount, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - UndenylistAccountInstruction< - TProgramAddress, - TAccountPayer, - TAccountDenylister, - TAccountTokenMessenger, - TAccountDenylistAccount, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - denylister: { value: input.denylister ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - denylistAccount: { value: input.denylistAccount ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.denylister), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.denylistAccount), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUndenylistAccountInstructionDataEncoder().encode( - args as UndenylistAccountInstructionDataArgs - ), - } as UndenylistAccountInstruction< - TProgramAddress, - TAccountPayer, - TAccountDenylister, - TAccountTokenMessenger, - TAccountDenylistAccount, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type UndenylistAccountInput< - TAccountPayer extends string = string, - TAccountDenylister extends string = string, - TAccountTokenMessenger extends string = string, - TAccountDenylistAccount extends string = string, - TAccountSystemProgram extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payer: TransactionSigner; - denylister: TransactionSigner; - tokenMessenger: Address; - denylistAccount: Address; - systemProgram?: Address; - eventAuthority: Address; - program: Address; - account: UndenylistAccountInstructionDataArgs['account']; -}; - -export function getUndenylistAccountInstruction< - TAccountPayer extends string, - TAccountDenylister extends string, - TAccountTokenMessenger extends string, - TAccountDenylistAccount extends string, - TAccountSystemProgram extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: UndenylistAccountInput< - TAccountPayer, - TAccountDenylister, - TAccountTokenMessenger, - TAccountDenylistAccount, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UndenylistAccountInstruction< - TProgramAddress, - TAccountPayer, - TAccountDenylister, - TAccountTokenMessenger, - TAccountDenylistAccount, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payer: { value: input.payer ?? null, isWritable: true }, - denylister: { value: input.denylister ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - denylistAccount: { value: input.denylistAccount ?? null, isWritable: true }, - systemProgram: { value: input.systemProgram ?? null, isWritable: false }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.systemProgram.value) { - accounts.systemProgram.value = - '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>; - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payer), - getAccountMeta(accounts.denylister), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.denylistAccount), - getAccountMeta(accounts.systemProgram), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUndenylistAccountInstructionDataEncoder().encode( - args as UndenylistAccountInstructionDataArgs - ), - } as UndenylistAccountInstruction< - TProgramAddress, - TAccountPayer, - TAccountDenylister, - TAccountTokenMessenger, - TAccountDenylistAccount, - TAccountSystemProgram, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUndenylistAccountInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payer: TAccountMetas[0]; - denylister: TAccountMetas[1]; - tokenMessenger: TAccountMetas[2]; - denylistAccount: TAccountMetas[3]; - systemProgram: TAccountMetas[4]; - eventAuthority: TAccountMetas[5]; - program: TAccountMetas[6]; - }; - data: UndenylistAccountInstructionData; -}; - -export function parseUndenylistAccountInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUndenylistAccountInstruction { - if (instruction.accounts.length < 7) { - // 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: { - payer: getNextAccount(), - denylister: getNextAccount(), - tokenMessenger: getNextAccount(), - denylistAccount: getNextAccount(), - systemProgram: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUndenylistAccountInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/unlinkTokenPair.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/unlinkTokenPair.ts deleted file mode 100644 index aa29b3ec3..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/unlinkTokenPair.ts +++ /dev/null @@ -1,357 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, - type WritableSignerAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UNLINK_TOKEN_PAIR_DISCRIMINATOR = new Uint8Array([ - 52, 198, 100, 114, 104, 174, 85, 58, -]); - -export function getUnlinkTokenPairDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - UNLINK_TOKEN_PAIR_DISCRIMINATOR - ); -} - -export type UnlinkTokenPairInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountPayee extends string | AccountMeta = string, - TAccountTokenController extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountTokenPair extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPayee extends string - ? WritableSignerAccount & - AccountSignerMeta - : TAccountPayee, - TAccountTokenController extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountTokenController, - TAccountTokenMinter extends string - ? ReadonlyAccount - : TAccountTokenMinter, - TAccountTokenPair extends string - ? WritableAccount - : TAccountTokenPair, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UnlinkTokenPairInstructionData = { - discriminator: ReadonlyUint8Array; -}; - -export type UnlinkTokenPairInstructionDataArgs = {}; - -export function getUnlinkTokenPairInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: UNLINK_TOKEN_PAIR_DISCRIMINATOR }) - ); -} - -export function getUnlinkTokenPairInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getUnlinkTokenPairInstructionDataCodec(): Codec< - UnlinkTokenPairInstructionDataArgs, - UnlinkTokenPairInstructionData -> { - return combineCodec( - getUnlinkTokenPairInstructionDataEncoder(), - getUnlinkTokenPairInstructionDataDecoder() - ); -} - -export type UnlinkTokenPairAsyncInput< - TAccountPayee extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountTokenPair extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payee: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - tokenPair: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getUnlinkTokenPairInstructionAsync< - TAccountPayee extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountTokenPair extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: UnlinkTokenPairAsyncInput< - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - UnlinkTokenPairInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - tokenPair: { value: input.tokenPair ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.tokenPair), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUnlinkTokenPairInstructionDataEncoder().encode({}), - } as UnlinkTokenPairInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type UnlinkTokenPairInput< - TAccountPayee extends string = string, - TAccountTokenController extends string = string, - TAccountTokenMinter extends string = string, - TAccountTokenPair extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - payee: TransactionSigner; - tokenController: TransactionSigner; - tokenMinter: Address; - tokenPair: Address; - eventAuthority: Address; - program: Address; -}; - -export function getUnlinkTokenPairInstruction< - TAccountPayee extends string, - TAccountTokenController extends string, - TAccountTokenMinter extends string, - TAccountTokenPair extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: UnlinkTokenPairInput< - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UnlinkTokenPairInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - payee: { value: input.payee ?? null, isWritable: true }, - tokenController: { - value: input.tokenController ?? null, - isWritable: false, - }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: false }, - tokenPair: { value: input.tokenPair ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.payee), - getAccountMeta(accounts.tokenController), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.tokenPair), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUnlinkTokenPairInstructionDataEncoder().encode({}), - } as UnlinkTokenPairInstruction< - TProgramAddress, - TAccountPayee, - TAccountTokenController, - TAccountTokenMinter, - TAccountTokenPair, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUnlinkTokenPairInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - payee: TAccountMetas[0]; - tokenController: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - tokenPair: TAccountMetas[3]; - eventAuthority: TAccountMetas[4]; - program: TAccountMetas[5]; - }; - data: UnlinkTokenPairInstructionData; -}; - -export function parseUnlinkTokenPairInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUnlinkTokenPairInstruction { - if (instruction.accounts.length < 6) { - // 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: { - payee: getNextAccount(), - tokenController: getNextAccount(), - tokenMinter: getNextAccount(), - tokenPair: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUnlinkTokenPairInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/unpause.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/unpause.ts deleted file mode 100644 index 10bd0d65a..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/unpause.ts +++ /dev/null @@ -1,301 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UNPAUSE_DISCRIMINATOR = new Uint8Array([ - 169, 144, 4, 38, 10, 141, 188, 255, -]); - -export function getUnpauseDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode(UNPAUSE_DISCRIMINATOR); -} - -export type UnpauseInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountPauser extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountPauser extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountPauser, - TAccountTokenMinter extends string - ? WritableAccount - : TAccountTokenMinter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UnpauseInstructionData = { discriminator: ReadonlyUint8Array }; - -export type UnpauseInstructionDataArgs = {}; - -export function getUnpauseInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), - (value) => ({ ...value, discriminator: UNPAUSE_DISCRIMINATOR }) - ); -} - -export function getUnpauseInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ]); -} - -export function getUnpauseInstructionDataCodec(): Codec< - UnpauseInstructionDataArgs, - UnpauseInstructionData -> { - return combineCodec( - getUnpauseInstructionDataEncoder(), - getUnpauseInstructionDataDecoder() - ); -} - -export type UnpauseAsyncInput< - TAccountPauser extends string = string, - TAccountTokenMinter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pauser: TransactionSigner; - tokenMinter: Address; - eventAuthority?: Address; - program: Address; -}; - -export async function getUnpauseInstructionAsync< - TAccountPauser extends string, - TAccountTokenMinter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: UnpauseAsyncInput< - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - UnpauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pauser: { value: input.pauser ?? null, isWritable: false }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pauser), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUnpauseInstructionDataEncoder().encode({}), - } as UnpauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type UnpauseInput< - TAccountPauser extends string = string, - TAccountTokenMinter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - pauser: TransactionSigner; - tokenMinter: Address; - eventAuthority: Address; - program: Address; -}; - -export function getUnpauseInstruction< - TAccountPauser extends string, - TAccountTokenMinter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: UnpauseInput< - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UnpauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - pauser: { value: input.pauser ?? null, isWritable: false }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.pauser), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUnpauseInstructionDataEncoder().encode({}), - } as UnpauseInstruction< - TProgramAddress, - TAccountPauser, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUnpauseInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - pauser: TAccountMetas[0]; - tokenMinter: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: UnpauseInstructionData; -}; - -export function parseUnpauseInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUnpauseInstruction { - if (instruction.accounts.length < 4) { - // 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: { - pauser: getNextAccount(), - tokenMinter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUnpauseInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/updateDenylister.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/updateDenylister.ts deleted file mode 100644 index 31645028b..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/updateDenylister.ts +++ /dev/null @@ -1,324 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UPDATE_DENYLISTER_DISCRIMINATOR = new Uint8Array([ - 193, 66, 198, 201, 84, 57, 14, 222, -]); - -export function getUpdateDenylisterDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - UPDATE_DENYLISTER_DISCRIMINATOR - ); -} - -export type UpdateDenylisterInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountTokenMessenger extends string - ? WritableAccount - : TAccountTokenMessenger, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UpdateDenylisterInstructionData = { - discriminator: ReadonlyUint8Array; - newDenylister: Address; -}; - -export type UpdateDenylisterInstructionDataArgs = { newDenylister: Address }; - -export function getUpdateDenylisterInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newDenylister', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: UPDATE_DENYLISTER_DISCRIMINATOR }) - ); -} - -export function getUpdateDenylisterInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newDenylister', getAddressDecoder()], - ]); -} - -export function getUpdateDenylisterInstructionDataCodec(): Codec< - UpdateDenylisterInstructionDataArgs, - UpdateDenylisterInstructionData -> { - return combineCodec( - getUpdateDenylisterInstructionDataEncoder(), - getUpdateDenylisterInstructionDataDecoder() - ); -} - -export type UpdateDenylisterAsyncInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - eventAuthority?: Address; - program: Address; - newDenylister: UpdateDenylisterInstructionDataArgs['newDenylister']; -}; - -export async function getUpdateDenylisterInstructionAsync< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: UpdateDenylisterAsyncInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - UpdateDenylisterInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUpdateDenylisterInstructionDataEncoder().encode( - args as UpdateDenylisterInstructionDataArgs - ), - } as UpdateDenylisterInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type UpdateDenylisterInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - eventAuthority: Address; - program: Address; - newDenylister: UpdateDenylisterInstructionDataArgs['newDenylister']; -}; - -export function getUpdateDenylisterInstruction< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: UpdateDenylisterInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UpdateDenylisterInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUpdateDenylisterInstructionDataEncoder().encode( - args as UpdateDenylisterInstructionDataArgs - ), - } as UpdateDenylisterInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUpdateDenylisterInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - eventAuthority: TAccountMetas[2]; - program: TAccountMetas[3]; - }; - data: UpdateDenylisterInstructionData; -}; - -export function parseUpdateDenylisterInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUpdateDenylisterInstruction { - if (instruction.accounts.length < 4) { - // 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: { - owner: getNextAccount(), - tokenMessenger: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUpdateDenylisterInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/instructions/updatePauser.ts b/src/svm/clients/TokenMessengerMinterV2/instructions/updatePauser.ts deleted file mode 100644 index 6b65e6855..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/instructions/updatePauser.ts +++ /dev/null @@ -1,346 +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 { - combineCodec, - fixDecoderSize, - fixEncoderSize, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getProgramDerivedAddress, - getStructDecoder, - getStructEncoder, - transformEncoder, - type AccountMeta, - type AccountSignerMeta, - type Address, - type Codec, - type Decoder, - type Encoder, - type Instruction, - type InstructionWithAccounts, - type InstructionWithData, - type ReadonlyAccount, - type ReadonlySignerAccount, - type ReadonlyUint8Array, - type TransactionSigner, - type WritableAccount, -} from '@solana/kit'; -import { TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS } from '../programs'; -import { getAccountMetaFactory, type ResolvedAccount } from '../shared'; - -export const UPDATE_PAUSER_DISCRIMINATOR = new Uint8Array([ - 140, 171, 211, 132, 57, 201, 16, 254, -]); - -export function getUpdatePauserDiscriminatorBytes() { - return fixEncoderSize(getBytesEncoder(), 8).encode( - UPDATE_PAUSER_DISCRIMINATOR - ); -} - -export type UpdatePauserInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountOwner extends string | AccountMeta = string, - TAccountTokenMessenger extends string | AccountMeta = string, - TAccountTokenMinter extends string | AccountMeta = string, - TAccountEventAuthority extends string | AccountMeta = string, - TAccountProgram extends string | AccountMeta = string, - TRemainingAccounts extends readonly AccountMeta[] = [], -> = Instruction & - InstructionWithData & - InstructionWithAccounts< - [ - TAccountOwner extends string - ? ReadonlySignerAccount & - AccountSignerMeta - : TAccountOwner, - TAccountTokenMessenger extends string - ? ReadonlyAccount - : TAccountTokenMessenger, - TAccountTokenMinter extends string - ? WritableAccount - : TAccountTokenMinter, - TAccountEventAuthority extends string - ? ReadonlyAccount - : TAccountEventAuthority, - TAccountProgram extends string - ? ReadonlyAccount - : TAccountProgram, - ...TRemainingAccounts, - ] - >; - -export type UpdatePauserInstructionData = { - discriminator: ReadonlyUint8Array; - newPauser: Address; -}; - -export type UpdatePauserInstructionDataArgs = { newPauser: Address }; - -export function getUpdatePauserInstructionDataEncoder(): Encoder { - return transformEncoder( - getStructEncoder([ - ['discriminator', fixEncoderSize(getBytesEncoder(), 8)], - ['newPauser', getAddressEncoder()], - ]), - (value) => ({ ...value, discriminator: UPDATE_PAUSER_DISCRIMINATOR }) - ); -} - -export function getUpdatePauserInstructionDataDecoder(): Decoder { - return getStructDecoder([ - ['discriminator', fixDecoderSize(getBytesDecoder(), 8)], - ['newPauser', getAddressDecoder()], - ]); -} - -export function getUpdatePauserInstructionDataCodec(): Codec< - UpdatePauserInstructionDataArgs, - UpdatePauserInstructionData -> { - return combineCodec( - getUpdatePauserInstructionDataEncoder(), - getUpdatePauserInstructionDataDecoder() - ); -} - -export type UpdatePauserAsyncInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - tokenMinter: Address; - eventAuthority?: Address; - program: Address; - newPauser: UpdatePauserInstructionDataArgs['newPauser']; -}; - -export async function getUpdatePauserInstructionAsync< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: UpdatePauserAsyncInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): Promise< - UpdatePauserInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - > -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? null, isWritable: false }, - }; - const accounts = originalAccounts as Record< - keyof typeof originalAccounts, - ResolvedAccount - >; - - // Original args. - const args = { ...input }; - - // Resolve default values. - if (!accounts.eventAuthority.value) { - accounts.eventAuthority.value = await getProgramDerivedAddress({ - programAddress, - seeds: [ - getBytesEncoder().encode( - new Uint8Array([ - 95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, - 105, 116, 121, - ]) - ), - ], - }); - } - - const getAccountMeta = getAccountMetaFactory(programAddress, 'programId'); - const instruction = { - accounts: [ - getAccountMeta(accounts.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUpdatePauserInstructionDataEncoder().encode( - args as UpdatePauserInstructionDataArgs - ), - } as UpdatePauserInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type UpdatePauserInput< - TAccountOwner extends string = string, - TAccountTokenMessenger extends string = string, - TAccountTokenMinter extends string = string, - TAccountEventAuthority extends string = string, - TAccountProgram extends string = string, -> = { - owner: TransactionSigner; - tokenMessenger: Address; - tokenMinter: Address; - eventAuthority: Address; - program: Address; - newPauser: UpdatePauserInstructionDataArgs['newPauser']; -}; - -export function getUpdatePauserInstruction< - TAccountOwner extends string, - TAccountTokenMessenger extends string, - TAccountTokenMinter extends string, - TAccountEventAuthority extends string, - TAccountProgram extends string, - TProgramAddress extends Address = - typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, ->( - input: UpdatePauserInput< - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >, - config?: { programAddress?: TProgramAddress } -): UpdatePauserInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram -> { - // Program address. - const programAddress = - config?.programAddress ?? TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS; - - // Original accounts. - const originalAccounts = { - owner: { value: input.owner ?? null, isWritable: false }, - tokenMessenger: { value: input.tokenMessenger ?? null, isWritable: false }, - tokenMinter: { value: input.tokenMinter ?? null, isWritable: true }, - eventAuthority: { value: input.eventAuthority ?? null, isWritable: false }, - program: { value: input.program ?? 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.owner), - getAccountMeta(accounts.tokenMessenger), - getAccountMeta(accounts.tokenMinter), - getAccountMeta(accounts.eventAuthority), - getAccountMeta(accounts.program), - ], - programAddress, - data: getUpdatePauserInstructionDataEncoder().encode( - args as UpdatePauserInstructionDataArgs - ), - } as UpdatePauserInstruction< - TProgramAddress, - TAccountOwner, - TAccountTokenMessenger, - TAccountTokenMinter, - TAccountEventAuthority, - TAccountProgram - >; - - return instruction; -} - -export type ParsedUpdatePauserInstruction< - TProgram extends string = typeof TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS, - TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[], -> = { - programAddress: Address; - accounts: { - owner: TAccountMetas[0]; - tokenMessenger: TAccountMetas[1]; - tokenMinter: TAccountMetas[2]; - eventAuthority: TAccountMetas[3]; - program: TAccountMetas[4]; - }; - data: UpdatePauserInstructionData; -}; - -export function parseUpdatePauserInstruction< - TProgram extends string, - TAccountMetas extends readonly AccountMeta[], ->( - instruction: Instruction & - InstructionWithAccounts & - InstructionWithData -): ParsedUpdatePauserInstruction { - if (instruction.accounts.length < 5) { - // 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: { - owner: getNextAccount(), - tokenMessenger: getNextAccount(), - tokenMinter: getNextAccount(), - eventAuthority: getNextAccount(), - program: getNextAccount(), - }, - data: getUpdatePauserInstructionDataDecoder().decode(instruction.data), - }; -} diff --git a/src/svm/clients/TokenMessengerMinterV2/programs/index.ts b/src/svm/clients/TokenMessengerMinterV2/programs/index.ts deleted file mode 100644 index f2cacc30e..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/programs/index.ts +++ /dev/null @@ -1,9 +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 - */ - -export * from './tokenMessengerMinterV2'; diff --git a/src/svm/clients/TokenMessengerMinterV2/programs/tokenMessengerMinterV2.ts b/src/svm/clients/TokenMessengerMinterV2/programs/tokenMessengerMinterV2.ts deleted file mode 100644 index 04a3fc6de..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/programs/tokenMessengerMinterV2.ts +++ /dev/null @@ -1,532 +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/kit'; -import { - type ParsedAcceptOwnershipInstruction, - type ParsedAddLocalTokenInstruction, - type ParsedAddRemoteTokenMessengerInstruction, - type ParsedBurnTokenCustodyInstruction, - type ParsedDenylistAccountInstruction, - type ParsedDepositForBurnInstruction, - type ParsedDepositForBurnWithHookInstruction, - type ParsedHandleReceiveFinalizedMessageInstruction, - type ParsedHandleReceiveUnfinalizedMessageInstruction, - type ParsedInitializeInstruction, - type ParsedLinkTokenPairInstruction, - type ParsedPauseInstruction, - type ParsedRemoveLocalTokenInstruction, - type ParsedRemoveRemoteTokenMessengerInstruction, - type ParsedSetFeeRecipientInstruction, - type ParsedSetMaxBurnAmountPerMessageInstruction, - type ParsedSetMinFeeControllerInstruction, - type ParsedSetMinFeeInstruction, - type ParsedSetTokenControllerInstruction, - type ParsedTransferOwnershipInstruction, - type ParsedUndenylistAccountInstruction, - type ParsedUnlinkTokenPairInstruction, - type ParsedUnpauseInstruction, - type ParsedUpdateDenylisterInstruction, - type ParsedUpdatePauserInstruction, -} from '../instructions'; - -export const TOKEN_MESSENGER_MINTER_V2_PROGRAM_ADDRESS = - 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe' as Address<'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe'>; - -export enum TokenMessengerMinterV2Account { - DenylistedAccount, - LocalToken, - MessageTransmitter, - RemoteTokenMessenger, - TokenMessenger, - TokenMinter, - TokenPair, -} - -export function identifyTokenMessengerMinterV2Account( - account: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): TokenMessengerMinterV2Account { - const data = 'data' in account ? account.data : account; - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([186, 58, 212, 239, 102, 131, 157, 146]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Account.DenylistedAccount; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([159, 131, 58, 170, 193, 84, 128, 182]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Account.LocalToken; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([71, 40, 180, 142, 19, 203, 35, 252]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Account.MessageTransmitter; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([105, 115, 174, 34, 95, 233, 138, 252]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Account.RemoteTokenMessenger; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([162, 4, 242, 52, 147, 243, 221, 96]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Account.TokenMessenger; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([122, 133, 84, 63, 57, 159, 171, 206]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Account.TokenMinter; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([17, 214, 45, 176, 229, 149, 197, 71]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Account.TokenPair; - } - throw new Error( - 'The provided account could not be identified as a tokenMessengerMinterV2 account.' - ); -} - -export enum TokenMessengerMinterV2Instruction { - AcceptOwnership, - AddLocalToken, - AddRemoteTokenMessenger, - BurnTokenCustody, - DenylistAccount, - DepositForBurn, - DepositForBurnWithHook, - HandleReceiveFinalizedMessage, - HandleReceiveUnfinalizedMessage, - Initialize, - LinkTokenPair, - Pause, - RemoveLocalToken, - RemoveRemoteTokenMessenger, - SetFeeRecipient, - SetMaxBurnAmountPerMessage, - SetMinFee, - SetMinFeeController, - SetTokenController, - TransferOwnership, - UndenylistAccount, - UnlinkTokenPair, - Unpause, - UpdateDenylister, - UpdatePauser, -} - -export function identifyTokenMessengerMinterV2Instruction( - instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array -): TokenMessengerMinterV2Instruction { - const data = 'data' in instruction ? instruction.data : instruction; - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([172, 23, 43, 13, 238, 213, 85, 150]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.AcceptOwnership; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([213, 199, 205, 18, 98, 124, 73, 198]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.AddLocalToken; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([12, 149, 172, 165, 111, 202, 24, 33]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.AddRemoteTokenMessenger; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([233, 136, 180, 175, 112, 41, 62, 71]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.BurnTokenCustody; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([101, 116, 197, 112, 81, 249, 75, 194]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.DenylistAccount; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([215, 60, 61, 46, 114, 55, 128, 176]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.DepositForBurn; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([111, 245, 62, 131, 204, 108, 223, 155]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.DepositForBurnWithHook; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([186, 252, 239, 70, 86, 180, 110, 95]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.HandleReceiveFinalizedMessage; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([200, 169, 175, 20, 200, 58, 182, 61]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.HandleReceiveUnfinalizedMessage; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([175, 175, 109, 31, 13, 152, 155, 237]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.Initialize; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([68, 162, 24, 104, 125, 46, 130, 12]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.LinkTokenPair; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([211, 22, 221, 251, 74, 121, 193, 47]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.Pause; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([27, 43, 66, 170, 188, 44, 109, 97]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.RemoveLocalToken; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([65, 114, 66, 85, 169, 98, 177, 146]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.RemoveRemoteTokenMessenger; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([227, 18, 215, 42, 237, 246, 151, 66]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.SetFeeRecipient; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([30, 128, 145, 240, 70, 237, 109, 207]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.SetMaxBurnAmountPerMessage; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([114, 198, 35, 3, 41, 196, 194, 246]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.SetMinFee; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([195, 142, 74, 84, 234, 94, 180, 113]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.SetMinFeeController; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([88, 6, 98, 10, 79, 59, 15, 24]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.SetTokenController; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([65, 177, 215, 73, 53, 45, 99, 47]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.TransferOwnership; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([57, 36, 43, 168, 62, 172, 33, 39]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.UndenylistAccount; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([52, 198, 100, 114, 104, 174, 85, 58]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.UnlinkTokenPair; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([169, 144, 4, 38, 10, 141, 188, 255]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.Unpause; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([193, 66, 198, 201, 84, 57, 14, 222]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.UpdateDenylister; - } - if ( - containsBytes( - data, - fixEncoderSize(getBytesEncoder(), 8).encode( - new Uint8Array([140, 171, 211, 132, 57, 201, 16, 254]) - ), - 0 - ) - ) { - return TokenMessengerMinterV2Instruction.UpdatePauser; - } - throw new Error( - 'The provided instruction could not be identified as a tokenMessengerMinterV2 instruction.' - ); -} - -export type ParsedTokenMessengerMinterV2Instruction< - TProgram extends string = 'CCTPV2vPZJS2u2BBsUoscuikbYjnpFmbFsvVuJdgUMQe', -> = - | ({ - instructionType: TokenMessengerMinterV2Instruction.AcceptOwnership; - } & ParsedAcceptOwnershipInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.AddLocalToken; - } & ParsedAddLocalTokenInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.AddRemoteTokenMessenger; - } & ParsedAddRemoteTokenMessengerInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.BurnTokenCustody; - } & ParsedBurnTokenCustodyInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.DenylistAccount; - } & ParsedDenylistAccountInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.DepositForBurn; - } & ParsedDepositForBurnInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.DepositForBurnWithHook; - } & ParsedDepositForBurnWithHookInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.HandleReceiveFinalizedMessage; - } & ParsedHandleReceiveFinalizedMessageInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.HandleReceiveUnfinalizedMessage; - } & ParsedHandleReceiveUnfinalizedMessageInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.Initialize; - } & ParsedInitializeInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.LinkTokenPair; - } & ParsedLinkTokenPairInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.Pause; - } & ParsedPauseInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.RemoveLocalToken; - } & ParsedRemoveLocalTokenInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.RemoveRemoteTokenMessenger; - } & ParsedRemoveRemoteTokenMessengerInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.SetFeeRecipient; - } & ParsedSetFeeRecipientInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.SetMaxBurnAmountPerMessage; - } & ParsedSetMaxBurnAmountPerMessageInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.SetMinFee; - } & ParsedSetMinFeeInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.SetMinFeeController; - } & ParsedSetMinFeeControllerInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.SetTokenController; - } & ParsedSetTokenControllerInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.TransferOwnership; - } & ParsedTransferOwnershipInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.UndenylistAccount; - } & ParsedUndenylistAccountInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.UnlinkTokenPair; - } & ParsedUnlinkTokenPairInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.Unpause; - } & ParsedUnpauseInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.UpdateDenylister; - } & ParsedUpdateDenylisterInstruction) - | ({ - instructionType: TokenMessengerMinterV2Instruction.UpdatePauser; - } & ParsedUpdatePauserInstruction); diff --git a/src/svm/clients/TokenMessengerMinterV2/shared/index.ts b/src/svm/clients/TokenMessengerMinterV2/shared/index.ts deleted file mode 100644 index 7ebc26514..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/shared/index.ts +++ /dev/null @@ -1,164 +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 { - AccountRole, - isProgramDerivedAddress, - isTransactionSigner as kitIsTransactionSigner, - type AccountMeta, - type AccountSignerMeta, - type Address, - type ProgramDerivedAddress, - type TransactionSigner, - upgradeRoleToSigner, -} from '@solana/kit'; - -/** - * Asserts that the given value is not null or undefined. - * @internal - */ -export function expectSome(value: T | null | undefined): T { - if (value == null) { - throw new Error('Expected a value but received null or undefined.'); - } - return value; -} - -/** - * Asserts that the given value is a PublicKey. - * @internal - */ -export function expectAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): Address { - if (!value) { - throw new Error('Expected a Address.'); - } - if (typeof value === 'object' && 'address' in value) { - return value.address; - } - if (Array.isArray(value)) { - return value[0]; - } - return value as Address; -} - -/** - * Asserts that the given value is a PDA. - * @internal - */ -export function expectProgramDerivedAddress( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): ProgramDerivedAddress { - if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) { - throw new Error('Expected a ProgramDerivedAddress.'); - } - return value; -} - -/** - * Asserts that the given value is a TransactionSigner. - * @internal - */ -export function expectTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner - | null - | undefined -): TransactionSigner { - if (!value || !isTransactionSigner(value)) { - throw new Error('Expected a TransactionSigner.'); - } - return value; -} - -/** - * Defines an instruction account to resolve. - * @internal - */ -export type ResolvedAccount< - T extends string = string, - U extends - | Address - | ProgramDerivedAddress - | TransactionSigner - | null = - | Address - | ProgramDerivedAddress - | TransactionSigner - | null, -> = { - isWritable: boolean; - value: U; -}; - -/** - * Defines an instruction that stores additional bytes on-chain. - * @internal - */ -export type InstructionWithByteDelta = { - byteDelta: number; -}; - -/** - * Get account metas and signers from resolved accounts. - * @internal - */ -export function getAccountMetaFactory( - programAddress: Address, - optionalAccountStrategy: 'omitted' | 'programId' -) { - return ( - account: ResolvedAccount - ): AccountMeta | AccountSignerMeta | undefined => { - if (!account.value) { - if (optionalAccountStrategy === 'omitted') return; - return Object.freeze({ - address: programAddress, - role: AccountRole.READONLY, - }); - } - - const writableRole = account.isWritable - ? AccountRole.WRITABLE - : AccountRole.READONLY; - return Object.freeze({ - address: expectAddress(account.value), - role: isTransactionSigner(account.value) - ? upgradeRoleToSigner(writableRole) - : writableRole, - ...(isTransactionSigner(account.value) ? { signer: account.value } : {}), - }); - }; -} - -export function isTransactionSigner( - value: - | Address - | ProgramDerivedAddress - | TransactionSigner -): value is TransactionSigner { - return ( - !!value && - typeof value === 'object' && - 'address' in value && - kitIsTransactionSigner(value) - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/denylisted.ts b/src/svm/clients/TokenMessengerMinterV2/types/denylisted.ts deleted file mode 100644 index 04f33c71c..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/denylisted.ts +++ /dev/null @@ -1,35 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type Denylisted = { account: Address }; - -export type DenylistedArgs = Denylisted; - -export function getDenylistedEncoder(): Encoder { - return getStructEncoder([['account', getAddressEncoder()]]); -} - -export function getDenylistedDecoder(): Decoder { - return getStructDecoder([['account', getAddressDecoder()]]); -} - -export function getDenylistedCodec(): Codec { - return combineCodec(getDenylistedEncoder(), getDenylistedDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/denylisterChanged.ts b/src/svm/clients/TokenMessengerMinterV2/types/denylisterChanged.ts deleted file mode 100644 index 1a6433281..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/denylisterChanged.ts +++ /dev/null @@ -1,50 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type DenylisterChanged = { - oldDenylister: Address; - newDenylister: Address; -}; - -export type DenylisterChangedArgs = DenylisterChanged; - -export function getDenylisterChangedEncoder(): Encoder { - return getStructEncoder([ - ['oldDenylister', getAddressEncoder()], - ['newDenylister', getAddressEncoder()], - ]); -} - -export function getDenylisterChangedDecoder(): Decoder { - return getStructDecoder([ - ['oldDenylister', getAddressDecoder()], - ['newDenylister', getAddressDecoder()], - ]); -} - -export function getDenylisterChangedCodec(): Codec< - DenylisterChangedArgs, - DenylisterChanged -> { - return combineCodec( - getDenylisterChangedEncoder(), - getDenylisterChangedDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/depositForBurn.ts b/src/svm/clients/TokenMessengerMinterV2/types/depositForBurn.ts deleted file mode 100644 index e8e7478fe..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/depositForBurn.ts +++ /dev/null @@ -1,91 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export type DepositForBurn = { - burnToken: Address; - amount: bigint; - depositor: Address; - mintRecipient: Address; - destinationDomain: number; - destinationTokenMessenger: Address; - destinationCaller: Address; - maxFee: bigint; - minFinalityThreshold: number; - hookData: ReadonlyUint8Array; -}; - -export type DepositForBurnArgs = { - burnToken: Address; - amount: number | bigint; - depositor: Address; - mintRecipient: Address; - destinationDomain: number; - destinationTokenMessenger: Address; - destinationCaller: Address; - maxFee: number | bigint; - minFinalityThreshold: number; - hookData: ReadonlyUint8Array; -}; - -export function getDepositForBurnEncoder(): Encoder { - return getStructEncoder([ - ['burnToken', getAddressEncoder()], - ['amount', getU64Encoder()], - ['depositor', getAddressEncoder()], - ['mintRecipient', getAddressEncoder()], - ['destinationDomain', getU32Encoder()], - ['destinationTokenMessenger', getAddressEncoder()], - ['destinationCaller', getAddressEncoder()], - ['maxFee', getU64Encoder()], - ['minFinalityThreshold', getU32Encoder()], - ['hookData', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ]); -} - -export function getDepositForBurnDecoder(): Decoder { - return getStructDecoder([ - ['burnToken', getAddressDecoder()], - ['amount', getU64Decoder()], - ['depositor', getAddressDecoder()], - ['mintRecipient', getAddressDecoder()], - ['destinationDomain', getU32Decoder()], - ['destinationTokenMessenger', getAddressDecoder()], - ['destinationCaller', getAddressDecoder()], - ['maxFee', getU64Decoder()], - ['minFinalityThreshold', getU32Decoder()], - ['hookData', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ]); -} - -export function getDepositForBurnCodec(): Codec< - DepositForBurnArgs, - DepositForBurn -> { - return combineCodec(getDepositForBurnEncoder(), getDepositForBurnDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/feeRecipientSet.ts b/src/svm/clients/TokenMessengerMinterV2/types/feeRecipientSet.ts deleted file mode 100644 index 299a364c9..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/feeRecipientSet.ts +++ /dev/null @@ -1,38 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type FeeRecipientSet = { newFeeRecipient: Address }; - -export type FeeRecipientSetArgs = FeeRecipientSet; - -export function getFeeRecipientSetEncoder(): Encoder { - return getStructEncoder([['newFeeRecipient', getAddressEncoder()]]); -} - -export function getFeeRecipientSetDecoder(): Decoder { - return getStructDecoder([['newFeeRecipient', getAddressDecoder()]]); -} - -export function getFeeRecipientSetCodec(): Codec< - FeeRecipientSetArgs, - FeeRecipientSet -> { - return combineCodec(getFeeRecipientSetEncoder(), getFeeRecipientSetDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/handleReceiveMessageParams.ts b/src/svm/clients/TokenMessengerMinterV2/types/handleReceiveMessageParams.ts deleted file mode 100644 index f99a66b9f..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/handleReceiveMessageParams.ts +++ /dev/null @@ -1,68 +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 { - addDecoderSizePrefix, - addEncoderSizePrefix, - combineCodec, - getAddressDecoder, - getAddressEncoder, - getBytesDecoder, - getBytesEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - getU8Decoder, - getU8Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, - type ReadonlyUint8Array, -} from '@solana/kit'; - -export type HandleReceiveMessageParams = { - remoteDomain: number; - sender: Address; - finalityThresholdExecuted: number; - messageBody: ReadonlyUint8Array; - authorityBump: number; -}; - -export type HandleReceiveMessageParamsArgs = HandleReceiveMessageParams; - -export function getHandleReceiveMessageParamsEncoder(): Encoder { - return getStructEncoder([ - ['remoteDomain', getU32Encoder()], - ['sender', getAddressEncoder()], - ['finalityThresholdExecuted', getU32Encoder()], - ['messageBody', addEncoderSizePrefix(getBytesEncoder(), getU32Encoder())], - ['authorityBump', getU8Encoder()], - ]); -} - -export function getHandleReceiveMessageParamsDecoder(): Decoder { - return getStructDecoder([ - ['remoteDomain', getU32Decoder()], - ['sender', getAddressDecoder()], - ['finalityThresholdExecuted', getU32Decoder()], - ['messageBody', addDecoderSizePrefix(getBytesDecoder(), getU32Decoder())], - ['authorityBump', getU8Decoder()], - ]); -} - -export function getHandleReceiveMessageParamsCodec(): Codec< - HandleReceiveMessageParamsArgs, - HandleReceiveMessageParams -> { - return combineCodec( - getHandleReceiveMessageParamsEncoder(), - getHandleReceiveMessageParamsDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/index.ts b/src/svm/clients/TokenMessengerMinterV2/types/index.ts deleted file mode 100644 index d7b73048e..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/index.ts +++ /dev/null @@ -1,31 +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 - */ - -export * from './denylisted'; -export * from './denylisterChanged'; -export * from './depositForBurn'; -export * from './feeRecipientSet'; -export * from './handleReceiveMessageParams'; -export * from './localTokenAdded'; -export * from './localTokenRemoved'; -export * from './minFeeControllerSet'; -export * from './minFeeSet'; -export * from './mintAndWithdraw'; -export * from './ownershipTransferred'; -export * from './ownershipTransferStarted'; -export * from './pause'; -export * from './pauserChanged'; -export * from './remoteTokenMessengerAdded'; -export * from './remoteTokenMessengerRemoved'; -export * from './setBurnLimitPerMessage'; -export * from './setTokenController'; -export * from './tokenCustodyBurned'; -export * from './tokenPairLinked'; -export * from './tokenPairUnlinked'; -export * from './unDenylisted'; -export * from './unpause'; diff --git a/src/svm/clients/TokenMessengerMinterV2/types/localTokenAdded.ts b/src/svm/clients/TokenMessengerMinterV2/types/localTokenAdded.ts deleted file mode 100644 index f74e5a7e5..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/localTokenAdded.ts +++ /dev/null @@ -1,44 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type LocalTokenAdded = { custody: Address; mint: Address }; - -export type LocalTokenAddedArgs = LocalTokenAdded; - -export function getLocalTokenAddedEncoder(): Encoder { - return getStructEncoder([ - ['custody', getAddressEncoder()], - ['mint', getAddressEncoder()], - ]); -} - -export function getLocalTokenAddedDecoder(): Decoder { - return getStructDecoder([ - ['custody', getAddressDecoder()], - ['mint', getAddressDecoder()], - ]); -} - -export function getLocalTokenAddedCodec(): Codec< - LocalTokenAddedArgs, - LocalTokenAdded -> { - return combineCodec(getLocalTokenAddedEncoder(), getLocalTokenAddedDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/localTokenRemoved.ts b/src/svm/clients/TokenMessengerMinterV2/types/localTokenRemoved.ts deleted file mode 100644 index 813080526..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/localTokenRemoved.ts +++ /dev/null @@ -1,47 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type LocalTokenRemoved = { custody: Address; mint: Address }; - -export type LocalTokenRemovedArgs = LocalTokenRemoved; - -export function getLocalTokenRemovedEncoder(): Encoder { - return getStructEncoder([ - ['custody', getAddressEncoder()], - ['mint', getAddressEncoder()], - ]); -} - -export function getLocalTokenRemovedDecoder(): Decoder { - return getStructDecoder([ - ['custody', getAddressDecoder()], - ['mint', getAddressDecoder()], - ]); -} - -export function getLocalTokenRemovedCodec(): Codec< - LocalTokenRemovedArgs, - LocalTokenRemoved -> { - return combineCodec( - getLocalTokenRemovedEncoder(), - getLocalTokenRemovedDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/minFeeControllerSet.ts b/src/svm/clients/TokenMessengerMinterV2/types/minFeeControllerSet.ts deleted file mode 100644 index 459cd7b5c..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/minFeeControllerSet.ts +++ /dev/null @@ -1,41 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type MinFeeControllerSet = { newMinFeeController: Address }; - -export type MinFeeControllerSetArgs = MinFeeControllerSet; - -export function getMinFeeControllerSetEncoder(): Encoder { - return getStructEncoder([['newMinFeeController', getAddressEncoder()]]); -} - -export function getMinFeeControllerSetDecoder(): Decoder { - return getStructDecoder([['newMinFeeController', getAddressDecoder()]]); -} - -export function getMinFeeControllerSetCodec(): Codec< - MinFeeControllerSetArgs, - MinFeeControllerSet -> { - return combineCodec( - getMinFeeControllerSetEncoder(), - getMinFeeControllerSetDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/minFeeSet.ts b/src/svm/clients/TokenMessengerMinterV2/types/minFeeSet.ts deleted file mode 100644 index 2a7cad1cb..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/minFeeSet.ts +++ /dev/null @@ -1,34 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type MinFeeSet = { newMinFee: number }; - -export type MinFeeSetArgs = MinFeeSet; - -export function getMinFeeSetEncoder(): Encoder { - return getStructEncoder([['newMinFee', getU32Encoder()]]); -} - -export function getMinFeeSetDecoder(): Decoder { - return getStructDecoder([['newMinFee', getU32Decoder()]]); -} - -export function getMinFeeSetCodec(): Codec { - return combineCodec(getMinFeeSetEncoder(), getMinFeeSetDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/mintAndWithdraw.ts b/src/svm/clients/TokenMessengerMinterV2/types/mintAndWithdraw.ts deleted file mode 100644 index 8d73db814..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/mintAndWithdraw.ts +++ /dev/null @@ -1,60 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type MintAndWithdraw = { - mintRecipient: Address; - amount: bigint; - mintToken: Address; - feeCollected: bigint; -}; - -export type MintAndWithdrawArgs = { - mintRecipient: Address; - amount: number | bigint; - mintToken: Address; - feeCollected: number | bigint; -}; - -export function getMintAndWithdrawEncoder(): Encoder { - return getStructEncoder([ - ['mintRecipient', getAddressEncoder()], - ['amount', getU64Encoder()], - ['mintToken', getAddressEncoder()], - ['feeCollected', getU64Encoder()], - ]); -} - -export function getMintAndWithdrawDecoder(): Decoder { - return getStructDecoder([ - ['mintRecipient', getAddressDecoder()], - ['amount', getU64Decoder()], - ['mintToken', getAddressDecoder()], - ['feeCollected', getU64Decoder()], - ]); -} - -export function getMintAndWithdrawCodec(): Codec< - MintAndWithdrawArgs, - MintAndWithdraw -> { - return combineCodec(getMintAndWithdrawEncoder(), getMintAndWithdrawDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferStarted.ts b/src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferStarted.ts deleted file mode 100644 index e170a569a..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferStarted.ts +++ /dev/null @@ -1,50 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type OwnershipTransferStarted = { - previousOwner: Address; - newOwner: Address; -}; - -export type OwnershipTransferStartedArgs = OwnershipTransferStarted; - -export function getOwnershipTransferStartedEncoder(): Encoder { - return getStructEncoder([ - ['previousOwner', getAddressEncoder()], - ['newOwner', getAddressEncoder()], - ]); -} - -export function getOwnershipTransferStartedDecoder(): Decoder { - return getStructDecoder([ - ['previousOwner', getAddressDecoder()], - ['newOwner', getAddressDecoder()], - ]); -} - -export function getOwnershipTransferStartedCodec(): Codec< - OwnershipTransferStartedArgs, - OwnershipTransferStarted -> { - return combineCodec( - getOwnershipTransferStartedEncoder(), - getOwnershipTransferStartedDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferred.ts b/src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferred.ts deleted file mode 100644 index 40f21c661..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/ownershipTransferred.ts +++ /dev/null @@ -1,50 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type OwnershipTransferred = { - previousOwner: Address; - newOwner: Address; -}; - -export type OwnershipTransferredArgs = OwnershipTransferred; - -export function getOwnershipTransferredEncoder(): Encoder { - return getStructEncoder([ - ['previousOwner', getAddressEncoder()], - ['newOwner', getAddressEncoder()], - ]); -} - -export function getOwnershipTransferredDecoder(): Decoder { - return getStructDecoder([ - ['previousOwner', getAddressDecoder()], - ['newOwner', getAddressDecoder()], - ]); -} - -export function getOwnershipTransferredCodec(): Codec< - OwnershipTransferredArgs, - OwnershipTransferred -> { - return combineCodec( - getOwnershipTransferredEncoder(), - getOwnershipTransferredDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/pause.ts b/src/svm/clients/TokenMessengerMinterV2/types/pause.ts deleted file mode 100644 index f1f423325..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/pause.ts +++ /dev/null @@ -1,32 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type Pause = {}; - -export type PauseArgs = Pause; - -export function getPauseEncoder(): Encoder { - return getStructEncoder([]); -} - -export function getPauseDecoder(): Decoder { - return getStructDecoder([]); -} - -export function getPauseCodec(): Codec { - return combineCodec(getPauseEncoder(), getPauseDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/pauserChanged.ts b/src/svm/clients/TokenMessengerMinterV2/types/pauserChanged.ts deleted file mode 100644 index 57d7433da..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/pauserChanged.ts +++ /dev/null @@ -1,38 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type PauserChanged = { newAddress: Address }; - -export type PauserChangedArgs = PauserChanged; - -export function getPauserChangedEncoder(): Encoder { - return getStructEncoder([['newAddress', getAddressEncoder()]]); -} - -export function getPauserChangedDecoder(): Decoder { - return getStructDecoder([['newAddress', getAddressDecoder()]]); -} - -export function getPauserChangedCodec(): Codec< - PauserChangedArgs, - PauserChanged -> { - return combineCodec(getPauserChangedEncoder(), getPauserChangedDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerAdded.ts b/src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerAdded.ts deleted file mode 100644 index f2586db0b..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerAdded.ts +++ /dev/null @@ -1,52 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type RemoteTokenMessengerAdded = { - domain: number; - tokenMessenger: Address; -}; - -export type RemoteTokenMessengerAddedArgs = RemoteTokenMessengerAdded; - -export function getRemoteTokenMessengerAddedEncoder(): Encoder { - return getStructEncoder([ - ['domain', getU32Encoder()], - ['tokenMessenger', getAddressEncoder()], - ]); -} - -export function getRemoteTokenMessengerAddedDecoder(): Decoder { - return getStructDecoder([ - ['domain', getU32Decoder()], - ['tokenMessenger', getAddressDecoder()], - ]); -} - -export function getRemoteTokenMessengerAddedCodec(): Codec< - RemoteTokenMessengerAddedArgs, - RemoteTokenMessengerAdded -> { - return combineCodec( - getRemoteTokenMessengerAddedEncoder(), - getRemoteTokenMessengerAddedDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerRemoved.ts b/src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerRemoved.ts deleted file mode 100644 index 290c643bc..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/remoteTokenMessengerRemoved.ts +++ /dev/null @@ -1,52 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type RemoteTokenMessengerRemoved = { - domain: number; - tokenMessenger: Address; -}; - -export type RemoteTokenMessengerRemovedArgs = RemoteTokenMessengerRemoved; - -export function getRemoteTokenMessengerRemovedEncoder(): Encoder { - return getStructEncoder([ - ['domain', getU32Encoder()], - ['tokenMessenger', getAddressEncoder()], - ]); -} - -export function getRemoteTokenMessengerRemovedDecoder(): Decoder { - return getStructDecoder([ - ['domain', getU32Decoder()], - ['tokenMessenger', getAddressDecoder()], - ]); -} - -export function getRemoteTokenMessengerRemovedCodec(): Codec< - RemoteTokenMessengerRemovedArgs, - RemoteTokenMessengerRemoved -> { - return combineCodec( - getRemoteTokenMessengerRemovedEncoder(), - getRemoteTokenMessengerRemovedDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/setBurnLimitPerMessage.ts b/src/svm/clients/TokenMessengerMinterV2/types/setBurnLimitPerMessage.ts deleted file mode 100644 index 8c28725c2..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/setBurnLimitPerMessage.ts +++ /dev/null @@ -1,55 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type SetBurnLimitPerMessage = { - token: Address; - burnLimitPerMessage: bigint; -}; - -export type SetBurnLimitPerMessageArgs = { - token: Address; - burnLimitPerMessage: number | bigint; -}; - -export function getSetBurnLimitPerMessageEncoder(): Encoder { - return getStructEncoder([ - ['token', getAddressEncoder()], - ['burnLimitPerMessage', getU64Encoder()], - ]); -} - -export function getSetBurnLimitPerMessageDecoder(): Decoder { - return getStructDecoder([ - ['token', getAddressDecoder()], - ['burnLimitPerMessage', getU64Decoder()], - ]); -} - -export function getSetBurnLimitPerMessageCodec(): Codec< - SetBurnLimitPerMessageArgs, - SetBurnLimitPerMessage -> { - return combineCodec( - getSetBurnLimitPerMessageEncoder(), - getSetBurnLimitPerMessageDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/setTokenController.ts b/src/svm/clients/TokenMessengerMinterV2/types/setTokenController.ts deleted file mode 100644 index 3b6c01571..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/setTokenController.ts +++ /dev/null @@ -1,41 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type SetTokenController = { tokenController: Address }; - -export type SetTokenControllerArgs = SetTokenController; - -export function getSetTokenControllerEncoder(): Encoder { - return getStructEncoder([['tokenController', getAddressEncoder()]]); -} - -export function getSetTokenControllerDecoder(): Decoder { - return getStructDecoder([['tokenController', getAddressDecoder()]]); -} - -export function getSetTokenControllerCodec(): Codec< - SetTokenControllerArgs, - SetTokenController -> { - return combineCodec( - getSetTokenControllerEncoder(), - getSetTokenControllerDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/tokenCustodyBurned.ts b/src/svm/clients/TokenMessengerMinterV2/types/tokenCustodyBurned.ts deleted file mode 100644 index 4b90fc0d7..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/tokenCustodyBurned.ts +++ /dev/null @@ -1,55 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU64Decoder, - getU64Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type TokenCustodyBurned = { - custodyTokenAccount: Address; - amount: bigint; -}; - -export type TokenCustodyBurnedArgs = { - custodyTokenAccount: Address; - amount: number | bigint; -}; - -export function getTokenCustodyBurnedEncoder(): Encoder { - return getStructEncoder([ - ['custodyTokenAccount', getAddressEncoder()], - ['amount', getU64Encoder()], - ]); -} - -export function getTokenCustodyBurnedDecoder(): Decoder { - return getStructDecoder([ - ['custodyTokenAccount', getAddressDecoder()], - ['amount', getU64Decoder()], - ]); -} - -export function getTokenCustodyBurnedCodec(): Codec< - TokenCustodyBurnedArgs, - TokenCustodyBurned -> { - return combineCodec( - getTokenCustodyBurnedEncoder(), - getTokenCustodyBurnedDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/tokenPairLinked.ts b/src/svm/clients/TokenMessengerMinterV2/types/tokenPairLinked.ts deleted file mode 100644 index 3d4e2027d..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/tokenPairLinked.ts +++ /dev/null @@ -1,52 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type TokenPairLinked = { - localToken: Address; - remoteDomain: number; - remoteToken: Address; -}; - -export type TokenPairLinkedArgs = TokenPairLinked; - -export function getTokenPairLinkedEncoder(): Encoder { - return getStructEncoder([ - ['localToken', getAddressEncoder()], - ['remoteDomain', getU32Encoder()], - ['remoteToken', getAddressEncoder()], - ]); -} - -export function getTokenPairLinkedDecoder(): Decoder { - return getStructDecoder([ - ['localToken', getAddressDecoder()], - ['remoteDomain', getU32Decoder()], - ['remoteToken', getAddressDecoder()], - ]); -} - -export function getTokenPairLinkedCodec(): Codec< - TokenPairLinkedArgs, - TokenPairLinked -> { - return combineCodec(getTokenPairLinkedEncoder(), getTokenPairLinkedDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/tokenPairUnlinked.ts b/src/svm/clients/TokenMessengerMinterV2/types/tokenPairUnlinked.ts deleted file mode 100644 index 714376fdd..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/tokenPairUnlinked.ts +++ /dev/null @@ -1,55 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - getU32Decoder, - getU32Encoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type TokenPairUnlinked = { - localToken: Address; - remoteDomain: number; - remoteToken: Address; -}; - -export type TokenPairUnlinkedArgs = TokenPairUnlinked; - -export function getTokenPairUnlinkedEncoder(): Encoder { - return getStructEncoder([ - ['localToken', getAddressEncoder()], - ['remoteDomain', getU32Encoder()], - ['remoteToken', getAddressEncoder()], - ]); -} - -export function getTokenPairUnlinkedDecoder(): Decoder { - return getStructDecoder([ - ['localToken', getAddressDecoder()], - ['remoteDomain', getU32Decoder()], - ['remoteToken', getAddressDecoder()], - ]); -} - -export function getTokenPairUnlinkedCodec(): Codec< - TokenPairUnlinkedArgs, - TokenPairUnlinked -> { - return combineCodec( - getTokenPairUnlinkedEncoder(), - getTokenPairUnlinkedDecoder() - ); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/unDenylisted.ts b/src/svm/clients/TokenMessengerMinterV2/types/unDenylisted.ts deleted file mode 100644 index e60f24876..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/unDenylisted.ts +++ /dev/null @@ -1,35 +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 { - combineCodec, - getAddressDecoder, - getAddressEncoder, - getStructDecoder, - getStructEncoder, - type Address, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type UnDenylisted = { account: Address }; - -export type UnDenylistedArgs = UnDenylisted; - -export function getUnDenylistedEncoder(): Encoder { - return getStructEncoder([['account', getAddressEncoder()]]); -} - -export function getUnDenylistedDecoder(): Decoder { - return getStructDecoder([['account', getAddressDecoder()]]); -} - -export function getUnDenylistedCodec(): Codec { - return combineCodec(getUnDenylistedEncoder(), getUnDenylistedDecoder()); -} diff --git a/src/svm/clients/TokenMessengerMinterV2/types/unpause.ts b/src/svm/clients/TokenMessengerMinterV2/types/unpause.ts deleted file mode 100644 index 4fdc009ef..000000000 --- a/src/svm/clients/TokenMessengerMinterV2/types/unpause.ts +++ /dev/null @@ -1,32 +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 { - combineCodec, - getStructDecoder, - getStructEncoder, - type Codec, - type Decoder, - type Encoder, -} from '@solana/kit'; - -export type Unpause = {}; - -export type UnpauseArgs = Unpause; - -export function getUnpauseEncoder(): Encoder { - return getStructEncoder([]); -} - -export function getUnpauseDecoder(): Decoder { - return getStructDecoder([]); -} - -export function getUnpauseCodec(): Codec { - return combineCodec(getUnpauseEncoder(), getUnpauseDecoder()); -} From 960771de7ce4b678cc653ca81da74942b9cd4f82 Mon Sep 17 00:00:00 2001 From: Faisal Usmani Date: Wed, 1 Apr 2026 11:53:41 -0700 Subject: [PATCH 03/12] feat: generate SVM artifacts from contracts package instead of syncing Replace the sync-from-contracts approach with self-contained generation: - Add generateSvmAssets.sh: copies IDL JSONs and generates type re-exports from the installed @across-protocol/contracts package - Add generateSvmClients.ts: runs Codama to produce TypeScript clients - Add renameClientsImports.ts: post-processes @solana/web3.js -> @solana/kit - Add codama, @codama/nodes-from-anchor, @codama/renderers-js as devDeps - Wire into build: yarn generate-svm-artifacts runs before TypeScript compile - Remove sync-svm-clients.sh (no longer needed) - Bump @across-protocol/contracts to 5.0.4 - Export all web3-v1 utils at top level of svm barrel (needed by consumers) Co-Authored-By: Claude Opus 4.6 (1M context) --- package.json | 10 +- scripts/svm/generateSvmAssets.sh | 106 ++++++++++++ scripts/svm/generateSvmClients.ts | 47 ++++++ scripts/svm/renameClientsImports.ts | 27 +++ scripts/sync-svm-clients.sh | 28 ---- yarn.lock | 249 +++++++++++++++++++++------- 6 files changed, 375 insertions(+), 92 deletions(-) create mode 100755 scripts/svm/generateSvmAssets.sh create mode 100644 scripts/svm/generateSvmClients.ts create mode 100644 scripts/svm/renameClientsImports.ts delete mode 100755 scripts/sync-svm-clients.sh diff --git a/package.json b/package.json index 6001cdc65..e2e0e178f 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,9 @@ "build-bigint-buffer": "node scripts/build-bigint-buffer.js", "postinstall": "node scripts/build-bigint-buffer.js", "start": "yarn typechain && nodemon -e ts,tsx,json,js,jsx --watch ./src --ignore ./dist --exec 'yarn dev'", - "build": "yarn run clean && yarn typechain && yarn dev", + "build": "yarn run clean && yarn typechain && yarn generate-svm-artifacts && yarn dev", + "generate-svm-artifacts": "bash scripts/svm/generateSvmAssets.sh && yarn generate-svm-clients", + "generate-svm-clients": "ts-node scripts/svm/generateSvmClients.ts && ts-node scripts/svm/renameClientsImports.ts", "dev": "concurrently --kill-others-on-fail --names 'cjs,esm,types' --prefix-colors 'blue,magenta,green' 'yarn run build:cjs' 'yarn run build:esm' 'yarn run build:types'", "build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir ./dist/cjs --removeComments --verbatimModuleSyntax false && echo > ./dist/cjs/package.json '{\"type\":\"commonjs\"}' && yarn export-svm-idl:cjs", "build:esm": "tsc --project tsconfig.build.json --module es2015 --outDir ./dist/esm && echo > ./dist/esm/package.json '{\"type\":\"module\",\"sideEffects\":false}' && yarn export-svm-idl:esm", @@ -42,7 +44,6 @@ "bump-version:minor": "yarn version --minor --no-git-tag-version --no-commit-hooks && git commit -m 'chore: bump version' ./package.json --no-verify", "bump-version:patch": "yarn version --patch --no-git-tag-version --no-commit-hooks && git commit -m 'chore: bump version' ./package.json --no-verify", "stage-artifacts": "node scripts/stage-typechain-artifacts.js", - "sync-svm-clients": "bash scripts/sync-svm-clients.sh", "typechain": "yarn stage-artifacts && typechain --target ethers-v5 --out-dir src/utils/abi/typechain 'src/utils/abi/contracts/*.json'", "yalc:watch": "nodemon --watch src --ext ts,tsx,json,js,jsx --ignore src/utils/abi/ --exec 'yalc publish --push --changed'" }, @@ -62,6 +63,9 @@ } ], "devDependencies": { + "@codama/nodes-from-anchor": "^1.2.2", + "@codama/renderers-js": "^1.3.0", + "codama": "^1.3.0", "@defi-wonderland/smock": "^2.4.0", "@nomicfoundation/hardhat-chai-matchers": "^1.0.6", "@nomiclabs/hardhat-ethers": "^2.2.1", @@ -115,7 +119,7 @@ "dependencies": { "@across-protocol/across-token": "^1.0.0", "@across-protocol/constants": "^3.1.100", - "@across-protocol/contracts": "4.1.24", + "@across-protocol/contracts": "5.0.4", "@coral-xyz/anchor": "^0.30.1", "@coral-xyz/borsh": "^0.30.1", "@eth-optimism/sdk": "^3.3.1", diff --git a/scripts/svm/generateSvmAssets.sh b/scripts/svm/generateSvmAssets.sh new file mode 100755 index 000000000..de0f85b28 --- /dev/null +++ b/scripts/svm/generateSvmAssets.sh @@ -0,0 +1,106 @@ +#!/bin/bash +# Generates SVM assets (IDL index + Anchor type re-exports) from @across-protocol/contracts. +# The SDK generates its own artifacts from the installed contracts package. + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SDK_ROOT="$(dirname "$(dirname "$SCRIPT_DIR")")" +CONTRACTS_PKG="$SDK_ROOT/node_modules/@across-protocol/contracts" + +SVM_ASSETS="$SDK_ROOT/src/svm/assets" +SVM_IDL="$SVM_ASSETS/idl" +IDL_OUTPUT_FILE="$SVM_IDL/index.ts" +TYPES_OUTPUT_FILE="$SVM_ASSETS/index.ts" + +# Source IDL and types from installed contracts package +SOURCE_IDL="$CONTRACTS_PKG/dist/src/svm/assets/idl" +# Anchor types live in dist/src/svm/assets/ (v5+) or dist/target/types/ (v4) +SOURCE_TYPES="$CONTRACTS_PKG/dist/src/svm/assets" +if [ ! -d "$SOURCE_TYPES" ] || [ "$(ls "$SOURCE_TYPES"/*.d.ts 2>/dev/null | grep -v index | wc -l)" -eq 0 ]; then + SOURCE_TYPES="$CONTRACTS_PKG/dist/target/types" +fi + +if [ ! -d "$SOURCE_IDL" ]; then + echo "Error: IDL files not found at $SOURCE_IDL" + echo "Make sure @across-protocol/contracts is installed." + exit 1 +fi + +# Ensure destination directories exist +mkdir -p "$SVM_IDL" +mkdir -p "$SVM_ASSETS" + +# --- Copy IDL JSON files --- +echo "Copying IDL JSON files from contracts package..." +cp "$SOURCE_IDL"/*.json "$SVM_IDL/" + +# --- Generate IDL index.ts --- +echo "Generating IDL index.ts..." +> "$IDL_OUTPUT_FILE" + +{ + echo "// This file has been autogenerated. Do not edit manually." + echo "// Generated by scripts/svm/generateSvmAssets.sh" + echo +} >> "$IDL_OUTPUT_FILE" + +IMPORTS="" +EXPORTS="" + +for file in "$SVM_IDL"/*.json; do + filename=$(basename -- "$file") + name="${filename%.json}" + camelCaseName=$(echo "$name" | awk -F'_' '{ + for (i=1; i<=NF; i++) { + printf toupper(substr($i,1,1)) tolower(substr($i,2)); + } + }') + IMPORTS="${IMPORTS}const ${camelCaseName}Idl = require(\"./${filename}\");\n" + EXPORTS="${EXPORTS} ${camelCaseName}Idl,\n" +done + +printf "$IMPORTS" >> "$IDL_OUTPUT_FILE" + +{ + echo "export {" + printf "$EXPORTS" | sed '$ s/,$//' + echo "};" +} >> "$IDL_OUTPUT_FILE" + +echo "IDL index.ts generated at $IDL_OUTPUT_FILE" + +# --- Generate assets index.ts (Anchor type re-exports) --- +echo "Generating assets index.ts..." +> "$TYPES_OUTPUT_FILE" + +{ + echo "// This file has been autogenerated. Do not edit manually." + echo "// Generated by scripts/svm/generateSvmAssets.sh" + echo + echo "export * from \"./idl\";" +} >> "$TYPES_OUTPUT_FILE" + +# Determine the import path prefix based on which source directory we're using +if echo "$SOURCE_TYPES" | grep -q "dist/src/svm/assets"; then + IMPORT_PREFIX="@across-protocol/contracts/dist/src/svm/assets" +else + IMPORT_PREFIX="@across-protocol/contracts/dist/target/types" +fi + +# Re-export Anchor types from the contracts package +for file in "$SOURCE_TYPES"/*.d.ts; do + filename=$(basename -- "$file") + [ "$filename" = "index.d.ts" ] && continue + name="${filename%.d.ts}" + camelCaseName=$(echo "$name" | awk -F'_' '{ + for (i=1; i<=NF; i++) { + printf toupper(substr($i,1,1)) tolower(substr($i,2)); + } + }') + newName="${camelCaseName}Anchor" + echo "export {${camelCaseName} as ${newName}} from \"${IMPORT_PREFIX}/${name}\";" >> "$TYPES_OUTPUT_FILE" +done + +echo "Assets index.ts generated at $TYPES_OUTPUT_FILE" +echo "Done generating SVM assets." diff --git a/scripts/svm/generateSvmClients.ts b/scripts/svm/generateSvmClients.ts new file mode 100644 index 000000000..ae5bf8df8 --- /dev/null +++ b/scripts/svm/generateSvmClients.ts @@ -0,0 +1,47 @@ +/** + * Generates Codama TypeScript clients from IDL files. + * Reads IDL assets from the locally generated src/svm/assets/idl/ directory + * (populated by generateSvmAssets.sh). + * + * This is the SDK's own generation script, equivalent to the one in the contracts repo. + */ +import { createFromRoot } from "codama"; +import { rootNodeFromAnchor, AnchorIdl } from "@codama/nodes-from-anchor"; +import { renderVisitor as renderJavaScriptVisitor } from "@codama/renderers-js"; +import path from "path"; + +// Read IDL files directly from the generated assets +const idlPath = path.join(__dirname, "..", "..", "src", "svm", "assets", "idl"); +const clientsPath = path.join(__dirname, "..", "..", "src", "svm", "clients"); + +const SvmSpokeIdl = require(path.join(idlPath, "svm_spoke.json")); +const MulticallHandlerIdl = require(path.join(idlPath, "multicall_handler.json")); +const MessageTransmitterIdl = require(path.join(idlPath, "message_transmitter.json")); +const TokenMessengerMinterIdl = require(path.join(idlPath, "token_messenger_minter.json")); +const MessageTransmitterV2Idl = require(path.join(idlPath, "message_transmitter_v2.json")); +const TokenMessengerMinterV2Idl = require(path.join(idlPath, "token_messenger_minter_v2.json")); +const SponsoredCctpSrcPeripheryIdl = require(path.join(idlPath, "sponsored_cctp_src_periphery.json")); + +// Generate clients for each program +let codama = createFromRoot(rootNodeFromAnchor(SvmSpokeIdl as AnchorIdl)); +codama.accept(renderJavaScriptVisitor(path.join(clientsPath, "SvmSpoke"))); + +codama = createFromRoot(rootNodeFromAnchor(MulticallHandlerIdl as AnchorIdl)); +codama.accept(renderJavaScriptVisitor(path.join(clientsPath, "MulticallHandler"))); + +codama = createFromRoot(rootNodeFromAnchor(MessageTransmitterIdl as AnchorIdl)); +codama.accept(renderJavaScriptVisitor(path.join(clientsPath, "MessageTransmitter"))); + +codama = createFromRoot(rootNodeFromAnchor(TokenMessengerMinterIdl as AnchorIdl)); +codama.accept(renderJavaScriptVisitor(path.join(clientsPath, "TokenMessengerMinter"))); + +codama = createFromRoot(rootNodeFromAnchor(MessageTransmitterV2Idl as AnchorIdl)); +codama.accept(renderJavaScriptVisitor(path.join(clientsPath, "MessageTransmitterV2"))); + +codama = createFromRoot(rootNodeFromAnchor(TokenMessengerMinterV2Idl as AnchorIdl)); +codama.accept(renderJavaScriptVisitor(path.join(clientsPath, "TokenMessengerMinterV2"))); + +codama = createFromRoot(rootNodeFromAnchor(SponsoredCctpSrcPeripheryIdl as AnchorIdl)); +codama.accept(renderJavaScriptVisitor(path.join(clientsPath, "SponsoredCctpSrcPeriphery"))); + +console.log("Codama clients generated at", clientsPath); diff --git a/scripts/svm/renameClientsImports.ts b/scripts/svm/renameClientsImports.ts new file mode 100644 index 000000000..0b415682f --- /dev/null +++ b/scripts/svm/renameClientsImports.ts @@ -0,0 +1,27 @@ +/** + * Post-processes generated Codama clients to replace @solana/web3.js imports with @solana/kit. + * This is needed because Codama generates imports for @solana/web3.js by default. + */ +const fs = require("fs"); +const path = require("path"); + +const clientsPath = path.join(__dirname, "..", "..", "src", "svm", "clients"); + +function replaceInFiles(dir: string): void { + const files = fs.readdirSync(dir); + files.forEach((file: string) => { + const filePath = path.join(dir, file); + const stat = fs.statSync(filePath); + + if (stat.isDirectory()) { + replaceInFiles(filePath); + } else if (file.endsWith(".ts")) { + const fileContent = fs.readFileSync(filePath, "utf8"); + const updatedContent = fileContent.replace("@solana/web3.js", "@solana/kit"); + fs.writeFileSync(filePath, updatedContent); + } + }); +} + +replaceInFiles(clientsPath); +console.log("Client imports renamed (@solana/web3.js -> @solana/kit)"); diff --git a/scripts/sync-svm-clients.sh b/scripts/sync-svm-clients.sh deleted file mode 100755 index 0848fc35e..000000000 --- a/scripts/sync-svm-clients.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -# Syncs auto-generated Codama clients and IDL assets from the contracts repo. -# Run this after `yarn generate-svm-artifacts` in the contracts repo. -# See ACP-56 for context. - -set -euo pipefail - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -SDK_ROOT="$(dirname "$SCRIPT_DIR")" -CONTRACTS_ROOT="${CONTRACTS_ROOT:-$(dirname "$SDK_ROOT")/contracts}" - -if [ ! -d "$CONTRACTS_ROOT/src/svm" ]; then - echo "Error: contracts repo not found at $CONTRACTS_ROOT" - echo "Set CONTRACTS_ROOT env var to the contracts repo path." - exit 1 -fi - -echo "Syncing SVM clients from $CONTRACTS_ROOT..." - -# Sync Codama-generated clients -rm -rf "$SDK_ROOT/src/svm/clients" -cp -r "$CONTRACTS_ROOT/src/svm/clients" "$SDK_ROOT/src/svm/clients" - -# Sync auto-generated assets (IDLs + Anchor types) -rm -rf "$SDK_ROOT/src/svm/assets" -cp -r "$CONTRACTS_ROOT/src/svm/assets" "$SDK_ROOT/src/svm/assets" - -echo "Done. Synced clients/ and assets/ to sdk/src/svm/" diff --git a/yarn.lock b/yarn.lock index 4ed6efb32..4ceec1c17 100644 --- a/yarn.lock +++ b/yarn.lock @@ -21,20 +21,17 @@ resolved "https://registry.yarnpkg.com/@across-protocol/constants/-/constants-3.1.100.tgz#ac7f7910340e62abb66dceea451e96f590742211" integrity sha512-HWALdgQHY7Q0IQFMCThi/bcUp1CTgb/sdVmRvj5sLkjz2tFZfCcPA0nKzKK+5pXD3hdd2W44uqQA58Z19XhSSw== -"@across-protocol/constants@^3.1.98": - version "3.1.98" - resolved "https://registry.yarnpkg.com/@across-protocol/constants/-/constants-3.1.98.tgz#58fef78e455799ee0bf83abe9bc7232058833c3a" - integrity sha512-YHvKF42b351YCVoN/8AMURNj/m6uQONWCB+o4i9OhLc9x0nbICK17cwYcFoVgYIyL7PWU++ZDgttFoL0GqbMmQ== - -"@across-protocol/contracts@4.1.24": - version "4.1.24" - resolved "https://registry.yarnpkg.com/@across-protocol/contracts/-/contracts-4.1.24.tgz#8d21b38abd7c33bcf43e189c8646488325632aa5" - integrity sha512-vkMY3lCFmD8LskLlEXZ/KK+FlXpA9xk5BTSBXNR8qmsmA7WGaDvY1wZRLwToXVht1UbzDF/4P5sGA5x+JmQfUA== +"@across-protocol/contracts@5.0.4": + version "5.0.4" + resolved "https://registry.yarnpkg.com/@across-protocol/contracts/-/contracts-5.0.4.tgz#1cb63c81538a75f67f8df8421a088b96d51b7c06" + integrity sha512-6XADW4ntJZYAH0vYjTazL0lfakwp1uOWHtcrELSdSir4TRSMf9ieaXAHt/oDHkSFQaNSiyJ+xU63cNsdX05CgQ== dependencies: - "@across-protocol/constants" "^3.1.98" + "@across-protocol/constants" "^3.1.100" "@coral-xyz/anchor" "^0.31.1" "@eth-optimism/contracts" "^0.5.40" "@ethersproject/bignumber" "5.7.0" + "@ethersproject/bytes" "5.7.0" + "@ethersproject/keccak256" "5.7.0" "@openzeppelin/contracts" "5.5.0" "@openzeppelin/contracts-upgradeable" "5.5.0" "@openzeppelin/contracts-upgradeable-v4" "npm:@openzeppelin/contracts-upgradeable@4.9.6" @@ -48,8 +45,6 @@ "@solana/spl-token" "0.4.14" "@solana/web3.js" "1.98.2" "@types/yargs" "^17.0.33" - "@uma/common" "^2.37.3" - "@uma/contracts-node" "^0.4.17" bs58 "^6.0.0" yargs "^17.7.2" zksync-web3 "^0.14.3" @@ -390,6 +385,100 @@ "@babel/helper-validator-identifier" "^7.22.20" to-fast-properties "^2.0.0" +"@codama/cli@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@codama/cli/-/cli-1.5.0.tgz#074866ba3e2cfbc009185a6dc0ec307583bc59e4" + integrity sha512-+q62IvEA6o7ji/mcnGgAvyPWyiFx3cojVGrFNG8NSm0zFXrBk1lT3n/qg+2Ag8C8aHwno9boXgDTxV+P5VCDYw== + dependencies: + "@codama/nodes" "1.5.1" + "@codama/visitors" "1.5.1" + "@codama/visitors-core" "1.5.1" + commander "^14.0.2" + picocolors "^1.1.1" + prompts "^2.4.2" + +"@codama/errors@1.5.1", "@codama/errors@^1.4.4": + version "1.5.1" + resolved "https://registry.yarnpkg.com/@codama/errors/-/errors-1.5.1.tgz#66c93ea8a9d81c1f13debb19cc2f1af63c2a8c81" + integrity sha512-kdLk/OSLBt03DoViRU1Xr0M7NZ7J/CSqaXV8fooF9qMRGPRJdgUeW2VkCGlLXDQSaIALrls3HkHmKRKbqqjSOA== + dependencies: + "@codama/node-types" "1.5.1" + commander "^14.0.2" + picocolors "^1.1.1" + +"@codama/node-types@1.5.1": + version "1.5.1" + resolved "https://registry.yarnpkg.com/@codama/node-types/-/node-types-1.5.1.tgz#f44208f04e1a588f023829cd8b67e01a353cb1ae" + integrity sha512-jMGz93MSszb1iXAAyWWa0i7RQbLxGihLKRZ+zr9aBsjaFFmhXhONfTFeSXzbEfc05cajpd/gW2QI7xmQHlUDKQ== + +"@codama/nodes-from-anchor@^1.2.2": + version "1.4.0" + resolved "https://registry.yarnpkg.com/@codama/nodes-from-anchor/-/nodes-from-anchor-1.4.0.tgz#513360f47b5d956198e8f4469be9ec2a261c0ea1" + integrity sha512-RAn2I1SI8LPvFOFFOeG5AK4wtXc/olcGa7tebHH30zeY3t0cYbi2Y86hDck4pFC57KQWmKQFAOwvdCj5zAVaEA== + dependencies: + "@codama/errors" "1.5.1" + "@codama/nodes" "1.5.1" + "@codama/visitors" "1.5.1" + "@noble/hashes" "^2.0.1" + "@solana/codecs" "^5.3.0" + +"@codama/nodes@1.5.1", "@codama/nodes@^1.4.4": + version "1.5.1" + resolved "https://registry.yarnpkg.com/@codama/nodes/-/nodes-1.5.1.tgz#b7dc48c49182905999e8f9249e9813dcc05f05ba" + integrity sha512-6fIoH5Cfa5dFUE1fRxymZloeNg02klOT4fHsWwQavkkRWkoySgiti//w0j1itiZj6j5O+usujrwsZUJqSFjnhQ== + dependencies: + "@codama/errors" "1.5.1" + "@codama/node-types" "1.5.1" + +"@codama/renderers-core@^1.3.4": + version "1.3.6" + resolved "https://registry.yarnpkg.com/@codama/renderers-core/-/renderers-core-1.3.6.tgz#2f48905423e5f5445b3f661e30189a44753ee073" + integrity sha512-m3yAmhrObnagyC7d8g9bZxyLC5YMpttLagRE0aAKD4zlDDh23o3zV7TxSYCh2nRCg5ObceflgvXdauIHUm/6Xg== + dependencies: + "@codama/errors" "1.5.1" + "@codama/nodes" "1.5.1" + "@codama/visitors-core" "1.5.1" + +"@codama/renderers-js@^1.3.0": + version "1.7.0" + resolved "https://registry.yarnpkg.com/@codama/renderers-js/-/renderers-js-1.7.0.tgz#508037700767732d370c535995e0ccb13f3f2010" + integrity sha512-WwKkSkNPdUBVWjGmkG+RNXyZ5K/4ji8UZQGzowDNTrqktUrqPsBThOkc7Zpmv+TpCapxrfjj0Txpo+0q5FjKGw== + dependencies: + "@codama/errors" "^1.4.4" + "@codama/nodes" "^1.4.4" + "@codama/renderers-core" "^1.3.4" + "@codama/visitors-core" "^1.4.4" + "@solana/codecs-strings" "^6.0.0" + prettier "^3.8.1" + semver "^7.7.3" + +"@codama/validators@1.5.1": + version "1.5.1" + resolved "https://registry.yarnpkg.com/@codama/validators/-/validators-1.5.1.tgz#ec952b78c9b32d787f34d7fe8bed9ec2361ebcd1" + integrity sha512-aUXl39AMa091CBWpYiK2XCXP/uyKOOtAT399TzRld3z8dIH9E0fGyu4ocP+IhQKXWXDPsh7V3qPmqsdyevOPcQ== + dependencies: + "@codama/errors" "1.5.1" + "@codama/nodes" "1.5.1" + "@codama/visitors-core" "1.5.1" + +"@codama/visitors-core@1.5.1", "@codama/visitors-core@^1.4.4": + version "1.5.1" + resolved "https://registry.yarnpkg.com/@codama/visitors-core/-/visitors-core-1.5.1.tgz#179a31bc632095b46ca70db84106732bf05671ab" + integrity sha512-JotrDJLI7OfPNHulu4KtPfUDF/FYMC3RgEnv9lu47Fiiy0upbGAw1NorgBuoreyJ9Uj0GZyHt7Q5rjrCoa1U0g== + dependencies: + "@codama/errors" "1.5.1" + "@codama/nodes" "1.5.1" + json-stable-stringify "^1.3.0" + +"@codama/visitors@1.5.1": + version "1.5.1" + resolved "https://registry.yarnpkg.com/@codama/visitors/-/visitors-1.5.1.tgz#fc9739ef3fcc924ae5cd15252e6fd8f471d10f5f" + integrity sha512-8WcGP1tJKtqBfZ4mJsBRPjZ/H6+SPLWmiUoDTXRrVePQE4X4Yb04o6BoX2Uc3heZbfEc0rXdM1w8HTFvXBX4/A== + dependencies: + "@codama/errors" "1.5.1" + "@codama/nodes" "1.5.1" + "@codama/visitors-core" "1.5.1" + "@colors/colors@1.5.0": version "1.5.0" resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" @@ -2350,6 +2439,13 @@ dependencies: "@solana/errors" "5.4.0" +"@solana/codecs-core@6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@solana/codecs-core/-/codecs-core-6.6.0.tgz#9c043eb35df626ccfeaeb5aac7dabdeebdce410e" + integrity sha512-sjVgIDnOp5ZTnrv7p1bq6UXm1uOTa8vVvm+tHdHiaBkYcCrcUx9XwAlODfpEW8GBXihdq7dYs6xwj+80jzjmeA== + dependencies: + "@solana/errors" "6.6.0" + "@solana/codecs-data-structures@5.4.0": version "5.4.0" resolved "https://registry.yarnpkg.com/@solana/codecs-data-structures/-/codecs-data-structures-5.4.0.tgz#014e30fee700a001bae2fbbb97339d48b1840d0b" @@ -2359,7 +2455,7 @@ "@solana/codecs-numbers" "5.4.0" "@solana/errors" "5.4.0" -"@solana/codecs-numbers@5.4.0", "@solana/codecs-numbers@^2.1.0": +"@solana/codecs-numbers@5.4.0", "@solana/codecs-numbers@6.6.0", "@solana/codecs-numbers@^2.1.0": version "5.4.0" resolved "https://registry.yarnpkg.com/@solana/codecs-numbers/-/codecs-numbers-5.4.0.tgz#c4b841e26b2b81e4d293cf6758dcf5c2c64d0de0" integrity sha512-z6LMkY+kXWx1alrvIDSAxexY5QLhsso638CjM7XI1u6dB7drTLWKhifyjnm1vOQc1VPVFmbYxTgKKpds8TY8tg== @@ -2376,7 +2472,16 @@ "@solana/codecs-numbers" "5.4.0" "@solana/errors" "5.4.0" -"@solana/codecs@2.0.0-rc.1", "@solana/codecs@5.4.0": +"@solana/codecs-strings@^6.0.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@solana/codecs-strings/-/codecs-strings-6.6.0.tgz#f1b0c30794a6df052d3e4a5c0984e1e6fd8dd9b1" + integrity sha512-YK1IzJyymuiKsEdYXqswt+CaZMJ8YcTwsQrUd4KfdUKUo1o1Bz3HxzTeuFfMqn0K+Yv+U5V7JVhO90gzJIMB2g== + dependencies: + "@solana/codecs-core" "6.6.0" + "@solana/codecs-numbers" "6.6.0" + "@solana/errors" "6.6.0" + +"@solana/codecs@2.0.0-rc.1", "@solana/codecs@5.4.0", "@solana/codecs@^5.3.0": version "5.4.0" resolved "https://registry.yarnpkg.com/@solana/codecs/-/codecs-5.4.0.tgz#57a42e9f07505a84d59a35c6ff2409af114f2e50" integrity sha512-IbDCUvNX0MrkQahxiXj9rHzkd/fYfp1F2nTJkHGH8v+vPfD+YPjl007ZBM38EnCeXj/Xn+hxqBBivPvIHP29dA== @@ -2395,6 +2500,14 @@ chalk "5.6.2" commander "14.0.2" +"@solana/errors@6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@solana/errors/-/errors-6.6.0.tgz#86118fed6bc27f20b7a00069d80aeb6379044e9d" + integrity sha512-8MlqxF3NWWT+nzvq08/7uPyx3u7zOGBR7ZmYvczWxM37pPcBmGEgsruWqw120Zk2Z1spzqOzXd/uTbXBxanH4Q== + dependencies: + chalk "5.6.2" + commander "14.0.3" + "@solana/fast-stable-stringify@5.4.0": version "5.4.0" resolved "https://registry.yarnpkg.com/@solana/fast-stable-stringify/-/fast-stable-stringify-5.4.0.tgz#a57c4d7dacd8c3906f569aceb6ec10c3843fd4fb" @@ -3770,57 +3883,11 @@ web3 "^1.6.0" winston "^3.2.1" -"@uma/common@^2.37.3": - version "2.37.3" - resolved "https://registry.yarnpkg.com/@uma/common/-/common-2.37.3.tgz#0d7fda1227e3a05563544bb36f418a790c81129d" - integrity sha512-DLcM2xtiFWDbty21r2gsL6AJbOc8G/CMqg0iMxssvkKbz8varsWS44zJF85XGxMlY8fE40w0ZS8MR92xpbsu4g== - dependencies: - "@across-protocol/contracts" "^0.1.4" - "@ethersproject/address" "^5.7.0" - "@ethersproject/bignumber" "^5.0.5" - "@ethersproject/bytes" "^5.7.0" - "@ethersproject/constants" "^5.7.0" - "@google-cloud/kms" "^3.0.1" - "@google-cloud/storage" "^6.4.2" - "@nomicfoundation/hardhat-verify" "^1.0.4" - "@nomiclabs/hardhat-ethers" "^2.2.1" - "@nomiclabs/hardhat-web3" "^2.0.0" - "@truffle/contract" "4.6.17" - "@truffle/hdwallet-provider" eip1559-beta - "@types/ethereum-protocol" "^1.0.0" - "@uniswap/v3-core" "^1.0.0-rc.2" - abi-decoder "github:UMAprotocol/abi-decoder" - async-retry "^1.3.3" - axios "^1.6.1" - bignumber.js "^8.0.1" - chalk-pipe "^3.0.0" - decimal.js "^10.2.1" - dotenv "^9.0.0" - eth-crypto "^2.4.0" - hardhat-deploy "0.9.1" - hardhat-gas-reporter "^1.0.4" - hardhat-typechain "^0.3.5" - lodash.uniqby "^4.7.0" - minimist "^1.2.0" - moment "^2.24.0" - node-fetch "^2.6.0" - node-metamask "github:UMAprotocol/node-metamask" - require-context "^1.1.0" - solidity-coverage "^0.7.13" - truffle-deploy-registry "^0.5.1" - web3 "^1.6.0" - winston "^3.2.1" - "@uma/contracts-node@^0.4.0": version "0.4.17" resolved "https://registry.yarnpkg.com/@uma/contracts-node/-/contracts-node-0.4.17.tgz#6abd815723c8344017eb5c302f6a5b0b690eeb4e" integrity sha512-e7cVJr3yhKrPZn1TAo/CCOt+QacJON6Mj71lcwHq/rnx+tgjujK2MsOhihytmb79ejPTKg1b5+2GIDL02ttrrQ== -"@uma/contracts-node@^0.4.17": - version "0.4.25" - resolved "https://registry.yarnpkg.com/@uma/contracts-node/-/contracts-node-0.4.25.tgz#d5c82f1f2c7e0dc2dec26fe876db73ba3f0689d7" - integrity sha512-WaFojX4qyMmXpy5MBS7g0M0KnWESGusdSfTmlkZpCh65TksGaJwAyOM1YBRLL3xm3xSgxPoG+n6tTilSomUmOw== - "@uma/core@^2.18.0": version "2.56.0" resolved "https://registry.yarnpkg.com/@uma/core/-/core-2.56.0.tgz#c19aa427f08691a85e99ec523d23abf359a6b0c3" @@ -5797,6 +5864,17 @@ co@^4.6.0: resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ== +codama@^1.3.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/codama/-/codama-1.5.1.tgz#bcfd0e65d4368e77d8ec58493e1d86e5eef0c1c2" + integrity sha512-kZbYgesIxwGNZ1JsYIWFzAsLtBuLZy/S1pCxJZgYaE13NJwDzi+bsEYqRSOUQ9ISN7FJR3SCyAE+vgzvcJpg2A== + dependencies: + "@codama/cli" "1.5.0" + "@codama/errors" "1.5.1" + "@codama/nodes" "1.5.1" + "@codama/validators" "1.5.1" + "@codama/visitors" "1.5.1" + code-point-at@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" @@ -5929,6 +6007,11 @@ commander@14.0.2: resolved "https://registry.yarnpkg.com/commander/-/commander-14.0.2.tgz#b71fd37fe4069e4c3c7c13925252ada4eba14e8e" integrity sha512-TywoWNNRbhoD0BXs1P3ZEScW8W5iKrnbithIl0YH+uCmBd0QpPOA8yc82DS3BIE5Ma6FnBVUsJ7wVUDz4dvOWQ== +commander@14.0.3, commander@^14.0.2: + version "14.0.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-14.0.3.tgz#425d79b48f9af82fcd9e4fc1ea8af6c5ec07bbc2" + integrity sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw== + commander@^14.0.0: version "14.0.0" resolved "https://registry.yarnpkg.com/commander/-/commander-14.0.0.tgz#f244fc74a92343514e56229f16ef5c5e22ced5e9" @@ -10366,6 +10449,17 @@ json-stable-stringify@^1.0.1: dependencies: jsonify "~0.0.0" +json-stable-stringify@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.3.0.tgz#8903cfac42ea1a0f97f35d63a4ce0518f0cc6a70" + integrity sha512-qtYiSSFlwot9XHtF9bD9c7rwKjr+RecWT//ZnPvSmEjpV5mmPOCN4j8UjY5hbjNkOwZ/jQv3J6R1/pL7RwgMsg== + dependencies: + call-bind "^1.0.8" + call-bound "^1.0.4" + isarray "^2.0.5" + jsonify "^0.0.1" + object-keys "^1.1.1" + json-stream-stringify@^3.1.4: version "3.1.6" resolved "https://registry.yarnpkg.com/json-stream-stringify/-/json-stream-stringify-3.1.6.tgz#ebe32193876fb99d4ec9f612389a8d8e2b5d54d4" @@ -10418,6 +10512,11 @@ jsonfile@^6.0.1: optionalDependencies: graceful-fs "^4.1.6" +jsonify@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.1.tgz#2aa3111dae3d34a0f151c63f3a45d995d9420978" + integrity sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg== + jsonify@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73" @@ -10529,6 +10628,11 @@ klaw@^3.0.0: dependencies: graceful-fs "^4.1.9" +kleur@^3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.3.tgz#a79c9ecc86ee1ce3fa6206d1216c501f147fc07e" + integrity sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w== + knex@^0.95.6: version "0.95.15" resolved "https://registry.yarnpkg.com/knex/-/knex-0.95.15.tgz#39d7e7110a6e2ad7de5d673d2dea94143015e0e7" @@ -12727,7 +12831,7 @@ picocolors@^1.0.0: resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== -picocolors@^1.1.0: +picocolors@^1.1.0, picocolors@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.1.tgz#3d321af3eab939b083c8f929a1d12cda81c26b6b" integrity sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA== @@ -12839,6 +12943,11 @@ prettier@^3.0.3: resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.3.tgz#432a51f7ba422d1469096c0fdc28e235db8f9643" integrity sha512-L/4pUDMxcNa8R/EthV08Zt42WBO4h1rarVtK0K+QJG0X187OLo7l699jWw0GKuwzkPQ//jMFA/8Xm6Fh3J/DAg== +prettier@^3.8.1: + version "3.8.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.8.1.tgz#edf48977cf991558f4fcbd8a3ba6015ba2a3a173" + integrity sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg== + printj@~1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/printj/-/printj-1.3.1.tgz#9af6b1d55647a1587ac44f4c1654a4b95b8e12cb" @@ -12892,6 +13001,14 @@ promise@^8.0.0: dependencies: asap "~2.0.6" +prompts@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.4.2.tgz#7b57e73b3a48029ad10ebd44f74b01722a4cb069" + integrity sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q== + dependencies: + kleur "^3.0.3" + sisteransi "^1.0.5" + proper-lockfile@^4.1.1: version "4.1.2" resolved "https://registry.yarnpkg.com/proper-lockfile/-/proper-lockfile-4.1.2.tgz#c8b9de2af6b2f1601067f98e01ac66baa223141f" @@ -13773,6 +13890,11 @@ semver@^7.6.0, semver@^7.6.2, semver@^7.7.2: resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.3.tgz#4b5f4143d007633a8dc671cd0a6ef9147b8bb946" integrity sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q== +semver@^7.7.3: + version "7.7.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.4.tgz#28464e36060e991fa7a11d0279d2d3f3b57a7e8a" + integrity sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA== + semver@~5.4.1: version "5.4.1" resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e" @@ -14012,6 +14134,11 @@ sinon@^16.0.0: nise "^5.1.4" supports-color "^7.2.0" +sisteransi@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" + integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg== + size-limit@^7.0.8: version "7.0.8" resolved "https://registry.yarnpkg.com/size-limit/-/size-limit-7.0.8.tgz#bf0c656da9e6bc3b8eb5b8a5a634df4634309811" From 97c29d33dd78f4fc19b42498e8982207f3a9ff82 Mon Sep 17 00:00:00 2001 From: Faisal Usmani Date: Wed, 1 Apr 2026 12:25:31 -0700 Subject: [PATCH 04/12] fix: resolve all lint errors in migrated SVM utils - Fix no-explicit-any with eslint-disable-next-line comments - Merge duplicate superstruct imports in cctpV2Helpers - Replace restricted @ethersproject/bignumber import with ethers - Change while(true) to for(;;) for no-constant-condition - Remove async from subscribeToCpiEventsForProgram (no await) - Add eslint-disable for require-await on encode() (base class requires async) - Exclude auto-generated src/svm/assets and src/svm/clients from eslint Co-Authored-By: Claude Opus 4.6 (1M context) --- .eslintignore | 4 ++++ src/svm/types.svm.ts | 1 + src/svm/web3-v1/buffer-layout.d.ts | 1 + src/svm/web3-v1/cctpHelpers.ts | 4 +++- src/svm/web3-v1/cctpV2Helpers.ts | 13 ++++++------- src/svm/web3-v1/coders.ts | 2 ++ src/svm/web3-v1/conversionUtils.ts | 2 ++ src/svm/web3-v1/helpers.ts | 4 ++-- src/svm/web3-v1/instructionParamsUtils.ts | 4 +++- src/svm/web3-v1/relayHashUtils.ts | 6 +++++- src/svm/web3-v1/solanaProgramUtils.ts | 12 ++++++++++-- src/svm/web3-v1/transactionUtils.ts | 19 ++++++++++++------- src/svm/web3-v2/solanaProgramUtils.ts | 7 +++++-- 13 files changed, 56 insertions(+), 23 deletions(-) diff --git a/.eslintignore b/.eslintignore index f319ba238..82dc1645d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,5 @@ scripts/build-bigint-buffer.js + +# Auto-generated SVM artifacts +src/svm/assets +src/svm/clients diff --git a/src/svm/types.svm.ts b/src/svm/types.svm.ts index b3fd17ee7..4d2610e0b 100644 --- a/src/svm/types.svm.ts +++ b/src/svm/types.svm.ts @@ -124,6 +124,7 @@ export type AcrossPlusMessage = { */ export interface EventType { program: PublicKey; + // eslint-disable-next-line @typescript-eslint/no-explicit-any data: any; name: string; slot: number; diff --git a/src/svm/web3-v1/buffer-layout.d.ts b/src/svm/web3-v1/buffer-layout.d.ts index a319c3fb6..6774143e0 100644 --- a/src/svm/web3-v1/buffer-layout.d.ts +++ b/src/svm/web3-v1/buffer-layout.d.ts @@ -1,4 +1,5 @@ declare module "buffer-layout" { + // eslint-disable-next-line @typescript-eslint/no-explicit-any export class Layout { span: number; property?: string; diff --git a/src/svm/web3-v1/cctpHelpers.ts b/src/svm/web3-v1/cctpHelpers.ts index 520f43fdd..d99d14b87 100644 --- a/src/svm/web3-v1/cctpHelpers.ts +++ b/src/svm/web3-v1/cctpHelpers.ts @@ -28,7 +28,7 @@ export type TokenMessengerMessageBody = { version: number; burnToken: anchor.web3.PublicKey; mintRecipient: anchor.web3.PublicKey; - amount: BigInt; + amount: bigint; messageSender: anchor.web3.PublicKey; }; @@ -130,6 +130,7 @@ type AttestationResponse = { /** * Structure for the attestation response from the attestation service. */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any const AttestationResponseStruct: Struct = object({ error: optional(string()), messages: array( @@ -150,6 +151,7 @@ export const getMessages = async ( irisApiUrl: string ): Promise => { console.log("Fetching attestations and messages for tx...", txHash); + // eslint-disable-next-line @typescript-eslint/no-explicit-any let attestationResponse: any = {}; while ( attestationResponse.error || diff --git a/src/svm/web3-v1/cctpV2Helpers.ts b/src/svm/web3-v1/cctpV2Helpers.ts index b34b3ab96..72823ccec 100644 --- a/src/svm/web3-v1/cctpV2Helpers.ts +++ b/src/svm/web3-v1/cctpV2Helpers.ts @@ -1,7 +1,6 @@ import * as anchor from "@coral-xyz/anchor"; -import { array, enums, object, optional, string, union, nullable, Infer, coerce } from "superstruct"; +import { array, enums, object, optional, string, union, nullable, Infer, coerce, assert } from "superstruct"; import { ethers } from "ethers"; -import { assert } from "superstruct"; import { readUInt256BE } from "./relayHashUtils"; import { addressOrBase58ToBytes32 } from "./conversionUtils"; @@ -39,11 +38,11 @@ export type TokenMessengerV2MessageBody = { version: number; burnToken: anchor.web3.PublicKey; mintRecipient: anchor.web3.PublicKey; - amount: BigInt; + amount: bigint; messageSender: anchor.web3.PublicKey; - maxFee: BigInt; - feeExecuted: BigInt; - expirationBlock: BigInt; + maxFee: bigint; + feeExecuted: bigint; + expirationBlock: bigint; hookData: Buffer; }; @@ -54,7 +53,7 @@ export type MessageHeaderV2 = { version: number; sourceDomain: number; destinationDomain: number; - nonce: BigInt; + nonce: bigint; sender: anchor.web3.PublicKey; recipient: anchor.web3.PublicKey; destinationCaller: anchor.web3.PublicKey; diff --git a/src/svm/web3-v1/coders.ts b/src/svm/web3-v1/coders.ts index 1694daf9a..c1d118b2b 100644 --- a/src/svm/web3-v1/coders.ts +++ b/src/svm/web3-v1/coders.ts @@ -22,9 +22,11 @@ export class LargeAccountsCoder extends BorshAccounts // Getter to access the private accountLayouts property from base class. private getAccountLayouts() { // Base class has `Map; } + // eslint-disable-next-line @typescript-eslint/no-explicit-any, require-await public async encode(accountName: A, account: T): Promise { const buffer = Buffer.alloc(10240); // We don't currently need anything above instruction data account reallocation limit. const layout = this.getAccountLayouts().get(accountName); diff --git a/src/svm/web3-v1/conversionUtils.ts b/src/svm/web3-v1/conversionUtils.ts index 64b5152ee..c8e185197 100644 --- a/src/svm/web3-v1/conversionUtils.ts +++ b/src/svm/web3-v1/conversionUtils.ts @@ -19,6 +19,7 @@ export function intToU8Array32(num: number | BN): number[] { * Converts a 32-byte Uint8Array to a bigint. */ export function u8Array32ToInt(u8Array: Uint8Array | number[]): bigint { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const isValidArray = (arr: any): arr is number[] => Array.isArray(arr) && arr.every(Number.isInteger); if ((u8Array instanceof Uint8Array || isValidArray(u8Array)) && u8Array.length === 32) { @@ -32,6 +33,7 @@ export function u8Array32ToInt(u8Array: Uint8Array | number[]): bigint { * Converts a 32-byte Uint8Array to a BigNumber. */ export function u8Array32ToBigNumber(u8Array: Uint8Array | number[]): BigNumber { + // eslint-disable-next-line @typescript-eslint/no-explicit-any const isValidArray = (arr: any): arr is number[] => Array.isArray(arr) && arr.every(Number.isInteger); if ((u8Array instanceof Uint8Array || isValidArray(u8Array)) && u8Array.length === 32) { const hexString = "0x" + Buffer.from(u8Array).toString("hex"); diff --git a/src/svm/web3-v1/helpers.ts b/src/svm/web3-v1/helpers.ts index d589e59cc..dc8a6b593 100644 --- a/src/svm/web3-v1/helpers.ts +++ b/src/svm/web3-v1/helpers.ts @@ -1,6 +1,5 @@ import { AnchorProvider, BN } from "@coral-xyz/anchor"; -import { BigNumber } from "@ethersproject/bignumber"; -import { ethers } from "ethers"; +import { BigNumber, ethers } from "ethers"; import { PublicKey } from "@solana/web3.js"; import { serialize } from "borsh"; import { keccak256 } from "ethers/lib/utils"; @@ -255,6 +254,7 @@ class FillDelegateSeedData { /** * Borsh schema for FillDelegateSeedData */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any const fillDelegateSeedSchema = new Map([ [ FillDelegateSeedData, diff --git a/src/svm/web3-v1/instructionParamsUtils.ts b/src/svm/web3-v1/instructionParamsUtils.ts index 1ecbcf2ea..240a91f02 100644 --- a/src/svm/web3-v1/instructionParamsUtils.ts +++ b/src/svm/web3-v1/instructionParamsUtils.ts @@ -115,7 +115,9 @@ export async function loadFillRelayParams( ); for (let i = 0; i < loadInstructions.length; i += 1) { // eslint-disable-next-line @typescript-eslint/no-explicit-any - await sendAndConfirmTransaction(program.provider.connection as any, new Transaction().add(loadInstructions[i]), [signer]); + await sendAndConfirmTransaction(program.provider.connection as any, new Transaction().add(loadInstructions[i]), [ + signer, + ]); } } diff --git a/src/svm/web3-v1/relayHashUtils.ts b/src/svm/web3-v1/relayHashUtils.ts index 7cfd73825..f2d016886 100644 --- a/src/svm/web3-v1/relayHashUtils.ts +++ b/src/svm/web3-v1/relayHashUtils.ts @@ -6,6 +6,7 @@ import { serialize } from "borsh"; /** * Calculates the relay hash from relay data and chain ID. */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function calculateRelayHashUint8Array(relayData: any, chainId: BN): Uint8Array { const contentToHash = Buffer.concat([ relayData.depositor.toBuffer(), @@ -31,6 +32,7 @@ export function calculateRelayHashUint8Array(relayData: any, chainId: BN): Uint8 /** * Calculates the relay event hash from relay event data and chain ID. */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function calculateRelayEventHashUint8Array(relayEventData: any, chainId: BN): Uint8Array { const contentToHash = Buffer.concat([ relayEventData.depositor.toBuffer(), @@ -56,7 +58,7 @@ export function calculateRelayEventHashUint8Array(relayEventData: any, chainId: /** * Reads a 256-bit unsigned integer from a buffer. */ -export const readUInt256BE = (buffer: Buffer): BigInt => { +export const readUInt256BE = (buffer: Buffer): bigint => { let result = BigInt(0); for (let i = 0; i < buffer.length; i++) { result = (result << BigInt(8)) + BigInt(buffer[i]); @@ -80,6 +82,7 @@ export function hashNonEmptyMessage(message: Buffer) { * Class for relay data. */ class RelayData { + // eslint-disable-next-line @typescript-eslint/no-explicit-any constructor(properties: any) { Object.assign(this, properties); } @@ -160,6 +163,7 @@ export const relayerRefundHashFn = (input: RelayerRefundLeaf | RelayerRefundLeaf * Class for slow fill data. */ class SlowFillData { + // eslint-disable-next-line @typescript-eslint/no-explicit-any constructor(properties: any) { Object.assign(this, properties); } diff --git a/src/svm/web3-v1/solanaProgramUtils.ts b/src/svm/web3-v1/solanaProgramUtils.ts index c9313bddc..40619c825 100644 --- a/src/svm/web3-v1/solanaProgramUtils.ts +++ b/src/svm/web3-v1/solanaProgramUtils.ts @@ -25,6 +25,7 @@ export function findProgramAddress(label: string, program: PublicKey, extraSeeds } else if (Buffer.isBuffer(extraSeed)) { seeds.push(extraSeed); } else { + // eslint-disable-next-line @typescript-eslint/no-explicit-any seeds.push((extraSeed as any).toBuffer()); } } @@ -53,6 +54,7 @@ export async function readEvents( /** * Processes events from a transaction. */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function processEventFromTx(txResult: web3.VersionedTransactionResponse, programs: Program[]) { const eventAuthorities: Map = new Map(); for (const program of programs) { @@ -124,6 +126,7 @@ export async function readEventsUntilFound( /** * Retrieves a specific event by name from a list of events. */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function getEvent(events: any[], program: PublicKey, eventName: string) { for (const event of events) { if (event.name === eventName && program.toString() === event.program.toString()) { @@ -138,6 +141,7 @@ export function getEvent(events: any[], program: PublicKey, eventName: string) { */ export async function readProgramEvents( connection: Connection, + // eslint-disable-next-line @typescript-eslint/no-explicit-any program: Program, finality: Finality = "confirmed", options: SignaturesForAddressOptions = { limit: 1000 } @@ -145,7 +149,7 @@ export async function readProgramEvents( const allSignatures: ConfirmedSignatureInfo[] = []; // Fetch all signatures in sequential batches - while (true) { + for (;;) { const signatures = await connection.getSignaturesForAddress(program.programId, options, finality); allSignatures.push(...signatures); @@ -178,9 +182,11 @@ export async function readProgramEvents( /** * Subscribes to CPI events for a program. */ -export async function subscribeToCpiEventsForProgram( +export function subscribeToCpiEventsForProgram( connection: Connection, + // eslint-disable-next-line @typescript-eslint/no-explicit-any program: Program, + // eslint-disable-next-line @typescript-eslint/no-explicit-any callback: (events: any[]) => void ) { const subscriptionId = connection.onLogs( @@ -227,6 +233,7 @@ function parseDepositId(value: Uint8Array): string { // Deserialize the full depositId using the Borsh schema // eslint-disable-next-line @typescript-eslint/no-explicit-any + // eslint-disable-next-line @typescript-eslint/no-explicit-any const depositId = (deserialize as any)(depositIdSchema, DepositId, Buffer.from(value)) as DepositId; return new BN(depositId.value).toString(); } @@ -234,6 +241,7 @@ function parseDepositId(value: Uint8Array): string { /** * Stringifies a CPI event. */ +// eslint-disable-next-line @typescript-eslint/no-explicit-any export function stringifyCpiEvent(obj: any, eventName: string): any { if (obj?.constructor?.toString()?.includes("PublicKey")) { if (obj.toString().startsWith("111111111111")) { diff --git a/src/svm/web3-v1/transactionUtils.ts b/src/svm/web3-v1/transactionUtils.ts index 568abb6c8..aaa1bfdff 100644 --- a/src/svm/web3-v1/transactionUtils.ts +++ b/src/svm/web3-v1/transactionUtils.ts @@ -40,11 +40,16 @@ export async function sendTransactionWithLookupTable( }); // Submit the ALT creation transaction - // eslint-disable-next-line @typescript-eslint/no-explicit-any - await web3.sendAndConfirmTransaction(connection as any, new web3.Transaction().add(lookupTableInstruction), [sender], { - commitment: "confirmed", - skipPreflight: true, - }); + await web3.sendAndConfirmTransaction( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + connection as any, + new web3.Transaction().add(lookupTableInstruction), + [sender], + { + commitment: "confirmed", + skipPreflight: true, + } + ); // Extend the ALT with all accounts making sure not to exceed the maximum number of accounts per transaction. for (let i = 0; i < lookupAddresses.length; i += maxExtendedAccounts) { @@ -86,7 +91,7 @@ export async function sendTransactionWithLookupTable( const txSignature = await connection.sendTransaction(versionedTx); // Confirm the versioned transaction - let block = await connection.getLatestBlockhash(); + const block = await connection.getLatestBlockhash(); await connection.confirmTransaction( { signature: txSignature, blockhash: block.blockhash, lastValidBlockHeight: block.lastValidBlockHeight }, "confirmed" @@ -119,7 +124,7 @@ export async function sendTransactionWithExistingLookupTable( const txSignature = await connection.sendTransaction(versionedTx); // Confirm the versioned transaction - let block = await connection.getLatestBlockhash(); + const block = await connection.getLatestBlockhash(); await connection.confirmTransaction( { signature: txSignature, blockhash: block.blockhash, lastValidBlockHeight: block.lastValidBlockHeight }, "confirmed" diff --git a/src/svm/web3-v2/solanaProgramUtils.ts b/src/svm/web3-v2/solanaProgramUtils.ts index 51bf899bd..d728f6bf4 100644 --- a/src/svm/web3-v2/solanaProgramUtils.ts +++ b/src/svm/web3-v2/solanaProgramUtils.ts @@ -45,7 +45,7 @@ async function searchSignaturesUntilLimit( ): Promise { const allSignatures: GetSignaturesForAddressTransaction[] = []; // Fetch all signatures in sequential batches - while (true) { + for (;;) { const signatures = await client.rpc.getSignaturesForAddress(program, options).send(); allSignatures.push(...signatures); @@ -87,9 +87,11 @@ async function processEventFromTx( txResult: GetTransactionReturnType, programId: Address, programIdl: Idl + // eslint-disable-next-line @typescript-eslint/no-explicit-any ): Promise<{ program: Address; data: any; name: string | undefined }[]> { if (!txResult) return []; const eventAuthorities: Map = new Map(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any const events: { program: Address; data: any; name: string | undefined }[] = []; const [pda] = await web3.getProgramDerivedAddress({ programAddress: programId, seeds: ["__event_authority"] }); eventAuthorities.set(programId, pda); @@ -113,7 +115,7 @@ async function processEventFromTx( ) { const ixData = utils.bytes.bs58.decode(ix.data); const eventData = utils.bytes.base64.encode(Buffer.from(new Uint8Array(ixData).slice(8))); - let event = new BorshEventCoder(programIdl).decode(eventData); + const event = new BorshEventCoder(programIdl).decode(eventData); events.push({ program: programId, data: event?.data, @@ -134,6 +136,7 @@ export async function readFillEventFromFillStatusPda( fillStatusPda: Address, programId: Address, programIdl: Idl + // eslint-disable-next-line @typescript-eslint/no-explicit-any ): Promise<{ event: any; slot: number }> { const signatures = await searchSignaturesUntilLimit(client, fillStatusPda); if (signatures.length === 0) return { event: null, slot: 0 }; From 8efd9ee20e3c27630b05581ef08cd4893a98e7cb Mon Sep 17 00:00:00 2001 From: Faisal Usmani Date: Wed, 1 Apr 2026 12:36:31 -0700 Subject: [PATCH 05/12] version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d80295d45..05c13e46e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@across-protocol/sdk", "author": "UMA Team", - "version": "4.3.136", + "version": "4.4.0-alpha.1", "license": "AGPL-3.0", "homepage": "https://docs.across.to/reference/sdk", "repository": { From 96047c36fbb20edccb45e7088d31722b917e488e Mon Sep 17 00:00:00 2001 From: Faisal Usmani Date: Wed, 1 Apr 2026 13:39:40 -0700 Subject: [PATCH 06/12] fix: export all web3-v1 utils from svm barrel The selective exports (only 5 functions) caused downstream consumers to get "not a function" errors for utils like encodeMessageHeader, intToU8Array32, getSpokePoolProgram, etc. Export everything from web3-v1 at the top level, with web3-v2 conflicting names aliased with V2 suffix. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/svm/index.ts | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/svm/index.ts b/src/svm/index.ts index b9851e1b0..3a0c89849 100644 --- a/src/svm/index.ts +++ b/src/svm/index.ts @@ -4,20 +4,24 @@ // Re-export SVM types export * from "./types.svm"; -// web3-v1 (Anchor/web3.js v1) — selective top-level exports -// (matches the original @across-protocol/contracts public API) -// Additional web3-v1 utils are accessible via deep imports: -// import { ... } from "@across-protocol/sdk/dist/cjs/src/svm/web3-v1" -export { - AcrossPlusMessageCoder, - calculateRelayHashUint8Array, - findProgramAddress, - MulticallHandlerCoder, - relayerRefundHashFn, -} from "./web3-v1"; +// web3-v1 (Anchor/web3.js v1) — all utils +export * from "./web3-v1"; -// web3-v2 (Solana Kit) — all exports -export * from "./web3-v2"; +// web3-v2 (Solana Kit) — re-export non-conflicting names directly, +// alias conflicting ones with V2 suffix to avoid name collision with web3-v1. +export { + readFillEventFromFillStatusPda, + signAndSendTransaction, + createDefaultTransaction, + createLookupTable, + extendLookupTable, +} from "./web3-v2"; +export type { RpcClient } from "./web3-v2"; +export { + readProgramEvents as readProgramEventsV2, + readEvents as readEventsV2, + sendTransactionWithLookupTable as sendTransactionWithLookupTableV2, +} from "./web3-v2"; // Auto-generated assets (IDL definitions and Anchor types) export * from "./assets"; From 2631c8baeb1bbd478b588e2a4f295e42dceb2ea5 Mon Sep 17 00:00:00 2001 From: Faisal Usmani Date: Wed, 1 Apr 2026 13:40:43 -0700 Subject: [PATCH 07/12] version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 05c13e46e..ad5dd770b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@across-protocol/sdk", "author": "UMA Team", - "version": "4.4.0-alpha.1", + "version": "4.4.0-alpha.2", "license": "AGPL-3.0", "homepage": "https://docs.across.to/reference/sdk", "repository": { From a0b4647499dbfc9849bb6160dbda4588b4b280e2 Mon Sep 17 00:00:00 2001 From: Faisal Usmani Date: Wed, 1 Apr 2026 17:20:41 -0700 Subject: [PATCH 08/12] fix: pin borsh to 0.7.0 and bump target to ES2020 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Pin borsh to 0.7.0 (was ^2.0.0 which resolves to 2.x in CI, breaking the old-style Map schema API used by relayHashUtils and helpers) - Bump TypeScript target from ES5 to ES2020 to fix "Class constructor BorshAccountsCoder cannot be invoked without 'new'" — ES5 __extends can't extend native ES6 classes from @coral-xyz/anchor Co-Authored-By: Claude Opus 4.6 (1M context) --- package.json | 2 +- tsconfig.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ad5dd770b..340cd272a 100644 --- a/package.json +++ b/package.json @@ -136,7 +136,7 @@ "@solana-program/address-lookup-table": "^0.10.0", "@uma/contracts-node": "^0.4.0", "arweave": "^1.14.4", - "borsh": "^2.0.0", + "borsh": "0.7.0", "buffer-layout": "^1.2.2", "async": "^3.2.5", "axios": "^0.27.2", diff --git a/tsconfig.json b/tsconfig.json index be2c8fb6a..f47ab44b1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "include": ["src", "types", "./test-utils.ts",], "compilerOptions": { "module": "CommonJS", - "target": "ES5", + "target": "ES2020", "lib": ["dom", "esnext"], // allow bundling of json files "resolveJsonModule": true, From fe1d419f99a6f9baa1ec8c5b374a931ab13955a0 Mon Sep 17 00:00:00 2001 From: Faisal Usmani Date: Wed, 1 Apr 2026 17:21:46 -0700 Subject: [PATCH 09/12] version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 340cd272a..a226a6d8f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@across-protocol/sdk", "author": "UMA Team", - "version": "4.4.0-alpha.2", + "version": "4.4.0-alpha.3", "license": "AGPL-3.0", "homepage": "https://docs.across.to/reference/sdk", "repository": { From 17188809ba34fdd0f564b93b3fcde619b30c41ab Mon Sep 17 00:00:00 2001 From: Faisal Usmani Date: Wed, 1 Apr 2026 17:25:29 -0700 Subject: [PATCH 10/12] yarn.lock --- package.json | 2 +- yarn.lock | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index a226a6d8f..54dc07070 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@across-protocol/sdk", "author": "UMA Team", - "version": "4.4.0-alpha.3", + "version": "4.4.0-alpha.4", "license": "AGPL-3.0", "homepage": "https://docs.across.to/reference/sdk", "repository": { diff --git a/yarn.lock b/yarn.lock index 1b8bc14e5..ee0b022f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3849,7 +3849,7 @@ bn.js@^5.1.2, bn.js@^5.2.0, bn.js@^5.2.1: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70" integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ== -borsh@^0.7.0: +borsh@0.7.0, borsh@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/borsh/-/borsh-0.7.0.tgz#6e9560d719d86d90dc589bca60ffc8a6c51fec2a" integrity sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA== @@ -3858,11 +3858,6 @@ borsh@^0.7.0: bs58 "^4.0.0" text-encoding-utf-8 "^1.0.2" -borsh@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/borsh/-/borsh-2.0.0.tgz#042a9f109565caac3c6a21297cd8c0ae8db3149d" - integrity sha512-kc9+BgR3zz9+cjbwM8ODoUB4fs3X3I5A/HtX7LZKxCLaMrEeDFoBpnhZY//DTS1VZBSs6S5v46RZRbZjRFspEg== - boxen@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/boxen/-/boxen-5.1.2.tgz#788cb686fc83c1f486dfa8a40c68fc2b831d2b50" From fb776e74aa4b8c41ca653b4490e3563db9eba7ca Mon Sep 17 00:00:00 2001 From: Faisal Usmani Date: Wed, 1 Apr 2026 18:19:35 -0700 Subject: [PATCH 11/12] fix: bump anchor to ^0.31.1 to match contracts repo The SDK had @coral-xyz/anchor ^0.30.1 while contracts uses ^0.31.1. When ts-mocha loads SDK source files, the BorshAccountsCoder from 0.30 receives an IDL formatted for 0.31, causing accountLayouts to be empty/undefined. Bumping to ^0.31.1 aligns the versions. Co-Authored-By: Claude Opus 4.6 (1M context) --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 54dc07070..03bdb56e2 100644 --- a/package.json +++ b/package.json @@ -119,8 +119,8 @@ "dependencies": { "@across-protocol/constants": "^3.1.100", "@across-protocol/contracts": "5.0.4", - "@coral-xyz/anchor": "^0.30.1", - "@coral-xyz/borsh": "^0.30.1", + "@coral-xyz/anchor": "^0.31.1", + "@coral-xyz/borsh": "^0.31.1", "@eth-optimism/sdk": "^3.3.1", "@ethersproject/bignumber": "^5.7.0", "@nktkas/hyperliquid": "^0.25.9", From 053d6ae72b8d0fb0230f63b5f90b0ae5ceebb685 Mon Sep 17 00:00:00 2001 From: Faisal Usmani Date: Wed, 1 Apr 2026 18:22:43 -0700 Subject: [PATCH 12/12] version --- package.json | 2 +- yarn.lock | 101 +++------------------------------------------------ 2 files changed, 6 insertions(+), 97 deletions(-) diff --git a/package.json b/package.json index 03bdb56e2..84674b363 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@across-protocol/sdk", "author": "UMA Team", - "version": "4.4.0-alpha.4", + "version": "4.4.0-alpha.5", "license": "AGPL-3.0", "homepage": "https://docs.across.to/reference/sdk", "repository": { diff --git a/yarn.lock b/yarn.lock index ee0b022f2..c1c82da3f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -297,37 +297,11 @@ resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.6.0.tgz#ec6cd237440700bc23ca23087f513c75508958b0" integrity sha512-Ir+AOibqzrIsL6ajt3Rz3LskB7OiMVHqltZmspbW/TJuTVuyOMirVqAkjfY6JISiLHgyNqicAC8AyHHGzNd/dA== -"@coral-xyz/anchor-errors@^0.30.1": - version "0.30.1" - resolved "https://registry.yarnpkg.com/@coral-xyz/anchor-errors/-/anchor-errors-0.30.1.tgz#bdfd3a353131345244546876eb4afc0e125bec30" - integrity sha512-9Mkradf5yS5xiLWrl9WrpjqOrAV+/W2RQHDlbnAZBivoGpOs1ECjoDCkVk4aRG8ZdiFiB8zQEVlxf+8fKkmSfQ== - "@coral-xyz/anchor-errors@^0.31.1": version "0.31.1" resolved "https://registry.yarnpkg.com/@coral-xyz/anchor-errors/-/anchor-errors-0.31.1.tgz#d635cbac2533973ae6bfb5d3ba1de89ce5aece2d" integrity sha512-NhNEku4F3zzUSBtrYz84FzYWm48+9OvmT1Hhnwr6GnPQry2dsEqH/ti/7ASjjpoFTWRnPXrjAIT1qM6Isop+LQ== -"@coral-xyz/anchor@^0.30.1": - version "0.30.1" - resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.30.1.tgz#17f3e9134c28cd0ea83574c6bab4e410bcecec5d" - integrity sha512-gDXFoF5oHgpriXAaLpxyWBHdCs8Awgf/gLHIo6crv7Aqm937CNdY+x+6hoj7QR5vaJV7MxWSQ0NGFzL3kPbWEQ== - dependencies: - "@coral-xyz/anchor-errors" "^0.30.1" - "@coral-xyz/borsh" "^0.30.1" - "@noble/hashes" "^1.3.1" - "@solana/web3.js" "^1.68.0" - bn.js "^5.1.2" - bs58 "^4.0.1" - buffer-layout "^1.2.2" - camelcase "^6.3.0" - cross-fetch "^3.1.5" - crypto-hash "^1.3.0" - eventemitter3 "^4.0.7" - pako "^2.0.3" - snake-case "^3.0.4" - superstruct "^0.15.4" - toml "^3.0.0" - "@coral-xyz/anchor@^0.31.1": version "0.31.1" resolved "https://registry.yarnpkg.com/@coral-xyz/anchor/-/anchor-0.31.1.tgz#0fdeebf45a3cb2e47e8ebbb815ca98542152962c" @@ -347,14 +321,6 @@ superstruct "^0.15.4" toml "^3.0.0" -"@coral-xyz/borsh@^0.30.1": - version "0.30.1" - resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.30.1.tgz#869d8833abe65685c72e9199b8688477a4f6b0e3" - integrity sha512-aaxswpPrCFKl8vZTbxLssA2RvwX2zmKLlRCIktJOwW+VpVwYtXRtlWiIP+c2pPRKneiTiWCN2GEMSH9j1zTlWQ== - dependencies: - bn.js "^5.1.2" - buffer-layout "^1.2.0" - "@coral-xyz/borsh@^0.31.1": version "0.31.1" resolved "https://registry.yarnpkg.com/@coral-xyz/borsh/-/borsh-0.31.1.tgz#5328e1e0921b75d7f4a62dd3f61885a938bc7241" @@ -2433,27 +2399,6 @@ rpc-websockets "^9.0.2" superstruct "^2.0.2" -"@solana/web3.js@^1.68.0": - version "1.95.4" - resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.95.4.tgz#771603f60d75cf7556ad867e1fd2efae32f9ad09" - integrity sha512-sdewnNEA42ZSMxqkzdwEWi6fDgzwtJHaQa5ndUGEJYtoOnM6X5cvPmjoTUp7/k7bRrVAxfBgDnvQQHD6yhlLYw== - dependencies: - "@babel/runtime" "^7.25.0" - "@noble/curves" "^1.4.2" - "@noble/hashes" "^1.4.0" - "@solana/buffer-layout" "^4.0.1" - agentkeepalive "^4.5.0" - bigint-buffer "^1.1.5" - bn.js "^5.2.1" - borsh "^0.7.0" - bs58 "^4.0.1" - buffer "6.0.3" - fast-stable-stringify "^1.0.0" - jayson "^4.1.1" - node-fetch "^2.7.0" - rpc-websockets "^9.0.2" - superstruct "^2.0.2" - "@solana/web3.js@^1.98.2": version "1.98.4" resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.98.4.tgz#df51d78be9d865181ec5138b4e699d48e6895bbe" @@ -4726,11 +4671,6 @@ cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" integrity sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs= -crypto-hash@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/crypto-hash/-/crypto-hash-1.3.0.tgz#b402cb08f4529e9f4f09346c3e275942f845e247" - integrity sha512-lyAZ0EMyjDkVvz8WOeVnuCPvKVBXcMv1l5SVqO1yC7PzTwrD/pPje/BIRbWhMoPe436U+Y2nD7f5bFx0kt+Sbg== - crypto-js@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.2.0.tgz#4d931639ecdfd12ff80e8186dba6af2c2e856631" @@ -4992,14 +4932,6 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -dot-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-3.0.4.tgz#9b2b670d00a431667a8a75ba29cd1b98809ce751" - integrity sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w== - dependencies: - no-case "^3.0.4" - tslib "^2.0.3" - dotenv@*, dotenv@^16.0.0: version "16.0.0" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.0.tgz#c619001253be89ebb638d027b609c75c26e47411" @@ -7957,13 +7889,6 @@ loupe@^2.3.6: dependencies: get-func-name "^2.0.1" -lower-case@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28" - integrity sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg== - dependencies: - tslib "^2.0.3" - "lru-cache@7.10.1 - 7.13.1": version "7.13.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.13.1.tgz#267a81fbd0881327c46a81c5922606a2cfe336c4" @@ -8595,14 +8520,6 @@ nise@^5.1.4: just-extend "^4.0.2" path-to-regexp "^1.7.0" -no-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d" - integrity sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg== - dependencies: - lower-case "^2.0.2" - tslib "^2.0.3" - node-abi@^3.3.0: version "3.54.0" resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-3.54.0.tgz#f6386f7548817acac6434c6cba02999c9aebcc69" @@ -10050,14 +9967,6 @@ smartweave@^0.4.46: sentencer "^0.2.1" yargs "^17.5.1" -snake-case@^3.0.4: - version "3.0.4" - resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-3.0.4.tgz#4f2bbd568e9935abdfd593f34c691dadb49c452c" - integrity sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg== - dependencies: - dot-case "^3.0.4" - tslib "^2.0.3" - socks-proxy-agent@^6.0.0: version "6.2.1" resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-6.2.1.tgz#2687a31f9d7185e38d530bef1944fe1f1496d6ce" @@ -10804,16 +10713,16 @@ tslib@^1.11.1, tslib@^1.9.3: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== -tslib@^2.0.3, tslib@^2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" - integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== - tslib@^2.1.0, tslib@^2.3.1, tslib@^2.4.0, tslib@^2.5.0, tslib@^2.6.0, tslib@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== +tslib@^2.8.1: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== + tsort@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/tsort/-/tsort-0.0.1.tgz#e2280f5e817f8bf4275657fd0f9aebd44f5a2786"