@layerzerolabs/lz-solana-sdk-v2 3.0.47 → 3.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/package.json +11 -10
- package/src/base-oapp.ts +159 -0
- package/src/config.ts +32 -0
- package/src/deployment.test.ts +11 -0
- package/src/deployment.ts +128 -0
- package/src/dvn.ts +606 -0
- package/src/endpoint.ts +1518 -0
- package/src/executor.ts +577 -0
- package/src/generated/blocked_messagelib/index.ts +18 -0
- package/src/generated/blocked_messagelib/instructions/index.ts +1 -0
- package/src/generated/blocked_messagelib/instructions/version.ts +59 -0
- package/src/generated/dvn/accounts/DvnConfig.ts +217 -0
- package/src/generated/dvn/accounts/ExecuteHash.ts +179 -0
- package/src/generated/dvn/accounts/ReceiveConfig.ts +169 -0
- package/src/generated/dvn/accounts/index.ts +9 -0
- package/src/generated/dvn/errors/index.ts +396 -0
- package/src/generated/dvn/events/AdminConfigSetEvent.ts +22 -0
- package/src/generated/dvn/events/FeeWithdrawnEvent.ts +26 -0
- package/src/generated/dvn/events/MultisigConfigSetEvent.ts +22 -0
- package/src/generated/dvn/events/index.ts +3 -0
- package/src/generated/dvn/index.ts +21 -0
- package/src/generated/dvn/instructions/closeExecute.ts +148 -0
- package/src/generated/dvn/instructions/index.ts +7 -0
- package/src/generated/dvn/instructions/initDvn.ts +144 -0
- package/src/generated/dvn/instructions/invoke.ts +178 -0
- package/src/generated/dvn/instructions/quoteDvn.ts +145 -0
- package/src/generated/dvn/instructions/setConfig.ts +157 -0
- package/src/generated/dvn/instructions/verifiable.ts +160 -0
- package/src/generated/dvn/instructions/withdrawFee.ts +172 -0
- package/src/generated/dvn/types/Acl.ts +26 -0
- package/src/generated/dvn/types/AdminConfig.ts +100 -0
- package/src/generated/dvn/types/CloseExecuteParams.ts +21 -0
- package/src/generated/dvn/types/DstConfig.ts +28 -0
- package/src/generated/dvn/types/ExecuteTransactionDigest.ts +37 -0
- package/src/generated/dvn/types/InitDvnParams.ts +34 -0
- package/src/generated/dvn/types/InvokeParams.ts +28 -0
- package/src/generated/dvn/types/LzOption.ts +24 -0
- package/src/generated/dvn/types/Multisig.ts +24 -0
- package/src/generated/dvn/types/MultisigConfig.ts +124 -0
- package/src/generated/dvn/types/QuoteDvnParams.ts +38 -0
- package/src/generated/dvn/types/SetConfigParams.ts +22 -0
- package/src/generated/dvn/types/TransactionAccount.ts +29 -0
- package/src/generated/dvn/types/UlnConfig.ts +34 -0
- package/src/generated/dvn/types/VerifiableParams.ts +24 -0
- package/src/generated/dvn/types/VerificationState.ts +27 -0
- package/src/generated/dvn/types/WithdrawFeeParams.ts +20 -0
- package/src/generated/dvn/types/index.ts +17 -0
- package/src/generated/endpoint/accounts/ComposeMessageState.ts +170 -0
- package/src/generated/endpoint/accounts/EndpointSettings.ts +184 -0
- package/src/generated/endpoint/accounts/MessageLibInfo.ts +178 -0
- package/src/generated/endpoint/accounts/Nonce.ts +193 -0
- package/src/generated/endpoint/accounts/OAppRegistry.ts +169 -0
- package/src/generated/endpoint/accounts/PayloadHash.ts +169 -0
- package/src/generated/endpoint/accounts/PendingInboundNonce.ts +172 -0
- package/src/generated/endpoint/accounts/ReceiveLibraryConfig.ts +183 -0
- package/src/generated/endpoint/accounts/SendLibraryConfig.ts +171 -0
- package/src/generated/endpoint/accounts/index.ts +31 -0
- package/src/generated/endpoint/errors/index.ts +428 -0
- package/src/generated/endpoint/events/AdminTransferredEvent.ts +23 -0
- package/src/generated/endpoint/events/ComposeDeliveredEvent.ts +31 -0
- package/src/generated/endpoint/events/ComposeSentEvent.ts +33 -0
- package/src/generated/endpoint/events/DefaultReceiveLibrarySetEvent.ts +27 -0
- package/src/generated/endpoint/events/DefaultReceiveLibraryTimeoutSetEvent.ts +29 -0
- package/src/generated/endpoint/events/DefaultSendLibrarySetEvent.ts +27 -0
- package/src/generated/endpoint/events/DelegateSetEvent.ts +22 -0
- package/src/generated/endpoint/events/InboundNonceSkippedEvent.ts +31 -0
- package/src/generated/endpoint/events/LibraryRegisteredEvent.ts +27 -0
- package/src/generated/endpoint/events/LzComposeAlertEvent.ts +43 -0
- package/src/generated/endpoint/events/LzReceiveAlertEvent.ts +45 -0
- package/src/generated/endpoint/events/LzTokenSetEvent.ts +23 -0
- package/src/generated/endpoint/events/OAppRegisteredEvent.ts +27 -0
- package/src/generated/endpoint/events/PacketBurntEvent.ts +32 -0
- package/src/generated/endpoint/events/PacketDeliveredEvent.ts +31 -0
- package/src/generated/endpoint/events/PacketNilifiedEvent.ts +33 -0
- package/src/generated/endpoint/events/PacketSentEvent.ts +29 -0
- package/src/generated/endpoint/events/PacketVerifiedEvent.ts +33 -0
- package/src/generated/endpoint/events/ReceiveLibrarySetEvent.ts +29 -0
- package/src/generated/endpoint/events/ReceiveLibraryTimeoutSetEvent.ts +33 -0
- package/src/generated/endpoint/events/RentWithdrawnEvent.ts +27 -0
- package/src/generated/endpoint/events/SendLibrarySetEvent.ts +29 -0
- package/src/generated/endpoint/events/index.ts +22 -0
- package/src/generated/endpoint/index.ts +21 -0
- package/src/generated/endpoint/instructions/burn.ts +191 -0
- package/src/generated/endpoint/instructions/clear.ts +193 -0
- package/src/generated/endpoint/instructions/clearCompose.ts +160 -0
- package/src/generated/endpoint/instructions/index.ts +32 -0
- package/src/generated/endpoint/instructions/initConfig.ts +172 -0
- package/src/generated/endpoint/instructions/initDefaultReceiveLibrary.ts +195 -0
- package/src/generated/endpoint/instructions/initDefaultSendLibrary.ts +195 -0
- package/src/generated/endpoint/instructions/initEndpoint.ts +147 -0
- package/src/generated/endpoint/instructions/initNonce.ts +168 -0
- package/src/generated/endpoint/instructions/initReceiveLibrary.ts +159 -0
- package/src/generated/endpoint/instructions/initSendLibrary.ts +159 -0
- package/src/generated/endpoint/instructions/initVerify.ts +159 -0
- package/src/generated/endpoint/instructions/lzComposeAlert.ts +148 -0
- package/src/generated/endpoint/instructions/lzReceiveAlert.ts +148 -0
- package/src/generated/endpoint/instructions/nilify.ts +193 -0
- package/src/generated/endpoint/instructions/quote.ts +181 -0
- package/src/generated/endpoint/instructions/registerLibrary.ts +183 -0
- package/src/generated/endpoint/instructions/registerOapp.ts +183 -0
- package/src/generated/endpoint/instructions/send.ts +215 -0
- package/src/generated/endpoint/instructions/sendCompose.ts +183 -0
- package/src/generated/endpoint/instructions/setConfig.ts +169 -0
- package/src/generated/endpoint/instructions/setDefaultReceiveLibrary.ts +184 -0
- package/src/generated/endpoint/instructions/setDefaultReceiveLibraryTimeout.ts +185 -0
- package/src/generated/endpoint/instructions/setDefaultSendLibrary.ts +184 -0
- package/src/generated/endpoint/instructions/setDelegate.ts +160 -0
- package/src/generated/endpoint/instructions/setLzToken.ts +160 -0
- package/src/generated/endpoint/instructions/setReceiveLibrary.ts +190 -0
- package/src/generated/endpoint/instructions/setReceiveLibraryTimeout.ts +184 -0
- package/src/generated/endpoint/instructions/setSendLibrary.ts +190 -0
- package/src/generated/endpoint/instructions/skip.ts +203 -0
- package/src/generated/endpoint/instructions/transferAdmin.ts +160 -0
- package/src/generated/endpoint/instructions/verify.ts +205 -0
- package/src/generated/endpoint/instructions/withdrawRent.ts +172 -0
- package/src/generated/endpoint/types/BurnParams.ts +32 -0
- package/src/generated/endpoint/types/ClearComposeParams.ts +31 -0
- package/src/generated/endpoint/types/ClearParams.ts +34 -0
- package/src/generated/endpoint/types/InitConfigParams.ts +26 -0
- package/src/generated/endpoint/types/InitDefaultReceiveLibraryParams.ts +27 -0
- package/src/generated/endpoint/types/InitDefaultSendLibraryParams.ts +27 -0
- package/src/generated/endpoint/types/InitEndpointParams.ts +27 -0
- package/src/generated/endpoint/types/InitNonceParams.ts +28 -0
- package/src/generated/endpoint/types/InitReceiveLibraryParams.ts +27 -0
- package/src/generated/endpoint/types/InitSendLibraryParams.ts +27 -0
- package/src/generated/endpoint/types/InitVerifyParams.ts +30 -0
- package/src/generated/endpoint/types/LzComposeAlertParams.ts +41 -0
- package/src/generated/endpoint/types/LzReceiveAlertParams.ts +43 -0
- package/src/generated/endpoint/types/MessageLibType.ts +25 -0
- package/src/generated/endpoint/types/MessagingFee.ts +24 -0
- package/src/generated/endpoint/types/MessagingReceipt.ts +27 -0
- package/src/generated/endpoint/types/NilifyParams.ts +32 -0
- package/src/generated/endpoint/types/QuoteParams.ts +34 -0
- package/src/generated/endpoint/types/ReceiveLibraryTimeout.ts +27 -0
- package/src/generated/endpoint/types/RegisterLibraryParams.ts +28 -0
- package/src/generated/endpoint/types/RegisterOAppParams.ts +23 -0
- package/src/generated/endpoint/types/SendComposeParams.ts +31 -0
- package/src/generated/endpoint/types/SendParams.ts +32 -0
- package/src/generated/endpoint/types/SetConfigParams.ts +31 -0
- package/src/generated/endpoint/types/SetDefaultReceiveLibraryParams.ts +29 -0
- package/src/generated/endpoint/types/SetDefaultReceiveLibraryTimeoutParams.ts +29 -0
- package/src/generated/endpoint/types/SetDefaultSendLibraryParams.ts +27 -0
- package/src/generated/endpoint/types/SetDelegateParams.ts +22 -0
- package/src/generated/endpoint/types/SetLzTokenParams.ts +23 -0
- package/src/generated/endpoint/types/SetReceiveLibraryParams.ts +31 -0
- package/src/generated/endpoint/types/SetReceiveLibraryTimeoutParams.ts +31 -0
- package/src/generated/endpoint/types/SetSendLibraryParams.ts +29 -0
- package/src/generated/endpoint/types/SkipParams.ts +30 -0
- package/src/generated/endpoint/types/TransferAdminParams.ts +23 -0
- package/src/generated/endpoint/types/VerifyParams.ts +32 -0
- package/src/generated/endpoint/types/WithdrawRentParams.ts +21 -0
- package/src/generated/endpoint/types/index.ts +36 -0
- package/src/generated/executor/accounts/ExecutorConfig.ts +216 -0
- package/src/generated/executor/accounts/Nonce.ts +193 -0
- package/src/generated/executor/accounts/index.ts +7 -0
- package/src/generated/executor/errors/index.ts +434 -0
- package/src/generated/executor/events/NativeDropAppliedEvent.ts +38 -0
- package/src/generated/executor/events/index.ts +1 -0
- package/src/generated/executor/index.ts +21 -0
- package/src/generated/executor/instructions/adminSetConfig.ts +136 -0
- package/src/generated/executor/instructions/compose.ts +181 -0
- package/src/generated/executor/instructions/executable.ts +136 -0
- package/src/generated/executor/instructions/execute.ts +181 -0
- package/src/generated/executor/instructions/index.ts +8 -0
- package/src/generated/executor/instructions/initExecutor.ts +147 -0
- package/src/generated/executor/instructions/nativeDrop.ts +171 -0
- package/src/generated/executor/instructions/ownerSetConfig.ts +136 -0
- package/src/generated/executor/instructions/quoteExecutor.ts +148 -0
- package/src/generated/executor/types/Acl.ts +26 -0
- package/src/generated/executor/types/AdminSetConfigParams.ts +83 -0
- package/src/generated/executor/types/ComposeParams.ts +27 -0
- package/src/generated/executor/types/DstConfig.ts +32 -0
- package/src/generated/executor/types/ExecutableParams.ts +30 -0
- package/src/generated/executor/types/ExecuteParams.ts +31 -0
- package/src/generated/executor/types/ExecutionState.ts +26 -0
- package/src/generated/executor/types/InitExecutorParams.ts +33 -0
- package/src/generated/executor/types/LzComposeParams.ts +35 -0
- package/src/generated/executor/types/LzOption.ts +24 -0
- package/src/generated/executor/types/LzReceiveParams.ts +33 -0
- package/src/generated/executor/types/NativeDropParams.ts +36 -0
- package/src/generated/executor/types/NativeDropRequest.ts +26 -0
- package/src/generated/executor/types/OwnerSetConfigParams.ts +123 -0
- package/src/generated/executor/types/QuoteExecutorParams.ts +34 -0
- package/src/generated/executor/types/index.ts +15 -0
- package/src/generated/pricefeed/accounts/PriceFeed.ts +220 -0
- package/src/generated/pricefeed/accounts/index.ts +5 -0
- package/src/generated/pricefeed/errors/index.ts +115 -0
- package/src/generated/pricefeed/index.ts +21 -0
- package/src/generated/pricefeed/instructions/getFee.ts +121 -0
- package/src/generated/pricefeed/instructions/index.ts +6 -0
- package/src/generated/pricefeed/instructions/initPriceFeed.ts +147 -0
- package/src/generated/pricefeed/instructions/setPrice.ts +133 -0
- package/src/generated/pricefeed/instructions/setPriceFeed.ts +136 -0
- package/src/generated/pricefeed/instructions/setSolPrice.ts +136 -0
- package/src/generated/pricefeed/instructions/transferAdmin.ts +136 -0
- package/src/generated/pricefeed/types/GetFeeParams.ts +26 -0
- package/src/generated/pricefeed/types/InitPriceFeedParams.ts +27 -0
- package/src/generated/pricefeed/types/ModelType.ts +66 -0
- package/src/generated/pricefeed/types/Price.ts +31 -0
- package/src/generated/pricefeed/types/PriceParams.ts +29 -0
- package/src/generated/pricefeed/types/SetPriceFeedParams.ts +29 -0
- package/src/generated/pricefeed/types/SetPriceParams.ts +26 -0
- package/src/generated/pricefeed/types/SetSolPriceParams.ts +21 -0
- package/src/generated/pricefeed/types/TransferAdminParams.ts +23 -0
- package/src/generated/pricefeed/types/index.ts +9 -0
- package/src/generated/simple_messagelib/accounts/MessageLib.ts +222 -0
- package/src/generated/simple_messagelib/accounts/ReceiveConfigStore.ts +168 -0
- package/src/generated/simple_messagelib/accounts/SendConfigStore.ts +170 -0
- package/src/generated/simple_messagelib/accounts/index.ts +13 -0
- package/src/generated/simple_messagelib/errors/index.ts +207 -0
- package/src/generated/simple_messagelib/index.ts +21 -0
- package/src/generated/simple_messagelib/instructions/index.ts +15 -0
- package/src/generated/simple_messagelib/instructions/initConfig.ts +183 -0
- package/src/generated/simple_messagelib/instructions/initDefaultConfig.ts +171 -0
- package/src/generated/simple_messagelib/instructions/initMessageLib.ts +147 -0
- package/src/generated/simple_messagelib/instructions/quote.ts +133 -0
- package/src/generated/simple_messagelib/instructions/revertCall.ts +59 -0
- package/src/generated/simple_messagelib/instructions/send.ts +154 -0
- package/src/generated/simple_messagelib/instructions/sendWithLzToken.ts +207 -0
- package/src/generated/simple_messagelib/instructions/setConfig.ts +157 -0
- package/src/generated/simple_messagelib/instructions/setDefaultConfig.ts +171 -0
- package/src/generated/simple_messagelib/instructions/setFee.ts +133 -0
- package/src/generated/simple_messagelib/instructions/setWlCaller.ts +136 -0
- package/src/generated/simple_messagelib/instructions/transferAdmin.ts +136 -0
- package/src/generated/simple_messagelib/instructions/validatePacket.ts +136 -0
- package/src/generated/simple_messagelib/instructions/version.ts +59 -0
- package/src/generated/simple_messagelib/instructions/withdrawFees.ts +148 -0
- package/src/generated/simple_messagelib/types/InitConfigParams.ts +26 -0
- package/src/generated/simple_messagelib/types/InitDefaultConfigParams.ts +27 -0
- package/src/generated/simple_messagelib/types/InitMessageLibParams.ts +35 -0
- package/src/generated/simple_messagelib/types/MessagingFee.ts +24 -0
- package/src/generated/simple_messagelib/types/Packet.ts +36 -0
- package/src/generated/simple_messagelib/types/QuoteParams.ts +27 -0
- package/src/generated/simple_messagelib/types/SendParams.ts +27 -0
- package/src/generated/simple_messagelib/types/SendWithLzTokenParams.ts +34 -0
- package/src/generated/simple_messagelib/types/SetConfigParams.ts +31 -0
- package/src/generated/simple_messagelib/types/SetDefaultConfigParams.ts +27 -0
- package/src/generated/simple_messagelib/types/SetFeeParams.ts +24 -0
- package/src/generated/simple_messagelib/types/SetWlCallerParams.ts +22 -0
- package/src/generated/simple_messagelib/types/TransferAdminParams.ts +23 -0
- package/src/generated/simple_messagelib/types/ValidatePacketParams.ts +21 -0
- package/src/generated/simple_messagelib/types/Version.ts +26 -0
- package/src/generated/simple_messagelib/types/WithdrawFeesParams.ts +21 -0
- package/src/generated/simple_messagelib/types/index.ts +16 -0
- package/src/generated/uln/accounts/Confirmations.ts +171 -0
- package/src/generated/uln/accounts/ReceiveConfig.ts +169 -0
- package/src/generated/uln/accounts/SendConfig.ts +177 -0
- package/src/generated/uln/accounts/UlnSettings.ts +195 -0
- package/src/generated/uln/accounts/index.ts +16 -0
- package/src/generated/uln/errors/index.ts +761 -0
- package/src/generated/uln/events/AdminTransferredEvent.ts +23 -0
- package/src/generated/uln/events/ConfigSetEvent.ts +30 -0
- package/src/generated/uln/events/DefaultConfigSetEvent.ts +31 -0
- package/src/generated/uln/events/FeesPaidEvent.ts +28 -0
- package/src/generated/uln/events/LzTokenSetEvent.ts +23 -0
- package/src/generated/uln/events/PayloadVerifiedEvent.ts +31 -0
- package/src/generated/uln/events/RentWithdrawnEvent.ts +27 -0
- package/src/generated/uln/events/TreasuryFeeCapSetEvent.ts +21 -0
- package/src/generated/uln/events/TreasurySetEvent.ts +22 -0
- package/src/generated/uln/events/index.ts +7 -0
- package/src/generated/uln/index.ts +21 -0
- package/src/generated/uln/instructions/closeVerify.ts +148 -0
- package/src/generated/uln/instructions/commitVerification.ts +148 -0
- package/src/generated/uln/instructions/index.ts +16 -0
- package/src/generated/uln/instructions/initConfig.ts +183 -0
- package/src/generated/uln/instructions/initDefaultConfig.ts +195 -0
- package/src/generated/uln/instructions/initUln.ts +144 -0
- package/src/generated/uln/instructions/initVerify.ts +147 -0
- package/src/generated/uln/instructions/quote.ts +157 -0
- package/src/generated/uln/instructions/send.ts +220 -0
- package/src/generated/uln/instructions/sendWithLzToken.ts +255 -0
- package/src/generated/uln/instructions/setConfig.ts +205 -0
- package/src/generated/uln/instructions/setDefaultConfig.ts +184 -0
- package/src/generated/uln/instructions/setTreasury.ts +160 -0
- package/src/generated/uln/instructions/transferAdmin.ts +160 -0
- package/src/generated/uln/instructions/verify.ts +157 -0
- package/src/generated/uln/instructions/version.ts +59 -0
- package/src/generated/uln/instructions/withdrawRent.ts +172 -0
- package/src/generated/uln/types/CloseVerifyParams.ts +24 -0
- package/src/generated/uln/types/CommitVerificationParams.ts +25 -0
- package/src/generated/uln/types/Config.ts +75 -0
- package/src/generated/uln/types/ExecutorConfig.ts +26 -0
- package/src/generated/uln/types/InitConfigParams.ts +26 -0
- package/src/generated/uln/types/InitDefaultConfigParams.ts +31 -0
- package/src/generated/uln/types/InitUlnParams.ts +30 -0
- package/src/generated/uln/types/InitVerifyParams.ts +28 -0
- package/src/generated/uln/types/LzTokenTreasury.ts +26 -0
- package/src/generated/uln/types/MessagingFee.ts +24 -0
- package/src/generated/uln/types/Packet.ts +36 -0
- package/src/generated/uln/types/QuoteParams.ts +27 -0
- package/src/generated/uln/types/SendParams.ts +27 -0
- package/src/generated/uln/types/SendWithLzTokenParams.ts +34 -0
- package/src/generated/uln/types/SetConfigParams.ts +31 -0
- package/src/generated/uln/types/SetDefaultConfigParams.ts +31 -0
- package/src/generated/uln/types/SetTreasuryParams.ts +22 -0
- package/src/generated/uln/types/TransferAdminParams.ts +23 -0
- package/src/generated/uln/types/Treasury.ts +31 -0
- package/src/generated/uln/types/TreasuryFee.ts +28 -0
- package/src/generated/uln/types/UlnConfig.ts +34 -0
- package/src/generated/uln/types/VerifyParams.ts +26 -0
- package/src/generated/uln/types/Version.ts +26 -0
- package/src/generated/uln/types/WithdrawRentParams.ts +21 -0
- package/src/generated/uln/types/WorkerFee.ts +26 -0
- package/src/generated/uln/types/index.ts +25 -0
- package/src/generated/worker_interface/errors/index.ts +75 -0
- package/src/generated/worker_interface/index.ts +20 -0
- package/src/generated/worker_interface/instructions/index.ts +2 -0
- package/src/generated/worker_interface/instructions/quoteDvn.ts +145 -0
- package/src/generated/worker_interface/instructions/quoteExecutor.ts +148 -0
- package/src/generated/worker_interface/types/LzOption.ts +24 -0
- package/src/generated/worker_interface/types/QuoteDvnParams.ts +38 -0
- package/src/generated/worker_interface/types/QuoteExecutorParams.ts +34 -0
- package/src/generated/worker_interface/types/index.ts +3 -0
- package/src/index.ts +120 -0
- package/src/pda-deriver.ts +658 -0
- package/src/pricefeed.ts +208 -0
- package/src/recevie.ts +269 -0
- package/src/send-helper.ts +504 -0
- package/src/simple-message-lib.ts +303 -0
- package/src/types.ts +222 -0
- package/src/uln.ts +1045 -0
- package/src/utility.ts +592 -0
package/src/executor.ts
ADDED
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountInfo,
|
|
3
|
+
AccountMeta,
|
|
4
|
+
Commitment,
|
|
5
|
+
Connection,
|
|
6
|
+
GetAccountInfoConfig,
|
|
7
|
+
PublicKey,
|
|
8
|
+
TransactionInstruction,
|
|
9
|
+
} from '@solana/web3.js'
|
|
10
|
+
import BN from 'bn.js'
|
|
11
|
+
|
|
12
|
+
import { arrayify } from '@layerzerolabs/lz-utilities'
|
|
13
|
+
import { Packet, addressToBytes32 } from '@layerzerolabs/lz-v2-utilities'
|
|
14
|
+
|
|
15
|
+
import { ComposeSentEvent } from './generated/endpoint/events'
|
|
16
|
+
import * as accounts from './generated/executor/accounts'
|
|
17
|
+
import * as events from './generated/executor/events'
|
|
18
|
+
import * as instructions from './generated/executor/instructions'
|
|
19
|
+
import * as types from './generated/executor/types'
|
|
20
|
+
import { EventPDADeriver, ExecutorPDADeriver, MessageLibPDADeriver, PriceFeedPDADeriver } from './pda-deriver'
|
|
21
|
+
import { getLzComposeAccountMeta, getLzReceiveAccounts } from './recevie'
|
|
22
|
+
|
|
23
|
+
export * from './generated/executor'
|
|
24
|
+
export { accounts, instructions, types, events }
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Class representing the Executor.
|
|
28
|
+
*/
|
|
29
|
+
export class Executor {
|
|
30
|
+
deriver: ExecutorPDADeriver
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Creates an instance of the Executor class.
|
|
34
|
+
*
|
|
35
|
+
* @param {PublicKey} program - The program public key.
|
|
36
|
+
*/
|
|
37
|
+
constructor(public program: PublicKey) {
|
|
38
|
+
this.deriver = new ExecutorPDADeriver(this.program)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// owner methods
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Initializes the executor.
|
|
45
|
+
*
|
|
46
|
+
* @param {PublicKey} payer - The payer public key.
|
|
47
|
+
* @param {PublicKey} owner - The owner public key.
|
|
48
|
+
* @param {PublicKey[]} admins - The admin public keys.
|
|
49
|
+
* @param {PublicKey[]} executors - The executor public keys.
|
|
50
|
+
* @param {PublicKey[]} msglibs - The message library public keys.
|
|
51
|
+
* @param {PublicKey} priceFeed - The price feed public key.
|
|
52
|
+
*
|
|
53
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
54
|
+
*/
|
|
55
|
+
initExecutor(
|
|
56
|
+
payer: PublicKey,
|
|
57
|
+
owner: PublicKey,
|
|
58
|
+
admins: PublicKey[],
|
|
59
|
+
executors: PublicKey[],
|
|
60
|
+
msglibs: PublicKey[],
|
|
61
|
+
priceFeed: PublicKey
|
|
62
|
+
): TransactionInstruction {
|
|
63
|
+
const [configAccount] = this.deriver.config()
|
|
64
|
+
return instructions.createInitExecutorInstruction(
|
|
65
|
+
{
|
|
66
|
+
payer,
|
|
67
|
+
config: configAccount,
|
|
68
|
+
} satisfies instructions.InitExecutorInstructionAccounts,
|
|
69
|
+
{
|
|
70
|
+
params: {
|
|
71
|
+
owner,
|
|
72
|
+
admins,
|
|
73
|
+
executors,
|
|
74
|
+
msglibs,
|
|
75
|
+
priceFeed,
|
|
76
|
+
} satisfies types.InitExecutorParams,
|
|
77
|
+
} satisfies instructions.InitExecutorInstructionArgs,
|
|
78
|
+
this.program
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Sets the owner.
|
|
84
|
+
*
|
|
85
|
+
* @param {PublicKey} owner - The current owner public key.
|
|
86
|
+
* @param {PublicKey} newOwner - The new owner public key.
|
|
87
|
+
*
|
|
88
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
89
|
+
*/
|
|
90
|
+
setOwner(owner: PublicKey, newOwner: PublicKey): TransactionInstruction {
|
|
91
|
+
const [configAccount] = this.deriver.config()
|
|
92
|
+
return instructions.createOwnerSetConfigInstruction(
|
|
93
|
+
{
|
|
94
|
+
owner,
|
|
95
|
+
config: configAccount,
|
|
96
|
+
} satisfies instructions.OwnerSetConfigInstructionAccounts,
|
|
97
|
+
{
|
|
98
|
+
params: {
|
|
99
|
+
fields: [newOwner],
|
|
100
|
+
__kind: 'Owner',
|
|
101
|
+
} satisfies types.OwnerSetConfigParams,
|
|
102
|
+
} satisfies instructions.OwnerSetConfigInstructionArgs,
|
|
103
|
+
this.program
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Sets the admins.
|
|
109
|
+
*
|
|
110
|
+
* @param {PublicKey} owner - The owner public key.
|
|
111
|
+
* @param {PublicKey[]} admins - The admin public keys.
|
|
112
|
+
*
|
|
113
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
114
|
+
*/
|
|
115
|
+
setAdmins(owner: PublicKey, admins: PublicKey[]): TransactionInstruction {
|
|
116
|
+
const [configAccount] = this.deriver.config()
|
|
117
|
+
return instructions.createOwnerSetConfigInstruction(
|
|
118
|
+
{
|
|
119
|
+
owner,
|
|
120
|
+
config: configAccount,
|
|
121
|
+
} satisfies instructions.OwnerSetConfigInstructionAccounts,
|
|
122
|
+
{
|
|
123
|
+
params: {
|
|
124
|
+
fields: [admins],
|
|
125
|
+
__kind: 'Admins',
|
|
126
|
+
} satisfies types.OwnerSetConfigParams,
|
|
127
|
+
} satisfies instructions.OwnerSetConfigInstructionArgs,
|
|
128
|
+
this.program
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Sets the allow list.
|
|
134
|
+
*
|
|
135
|
+
* @param {PublicKey} owner - The owner public key.
|
|
136
|
+
* @param {PublicKey[]} allowlist - The allow list public keys.
|
|
137
|
+
*
|
|
138
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
139
|
+
*/
|
|
140
|
+
setAllowList(owner: PublicKey, allowlist: PublicKey[]): TransactionInstruction {
|
|
141
|
+
const [configAccount] = this.deriver.config()
|
|
142
|
+
return instructions.createOwnerSetConfigInstruction(
|
|
143
|
+
{
|
|
144
|
+
owner,
|
|
145
|
+
config: configAccount,
|
|
146
|
+
} satisfies instructions.OwnerSetConfigInstructionAccounts,
|
|
147
|
+
{
|
|
148
|
+
params: {
|
|
149
|
+
fields: [allowlist],
|
|
150
|
+
__kind: 'Allowlist',
|
|
151
|
+
} satisfies types.OwnerSetConfigParams,
|
|
152
|
+
} satisfies instructions.OwnerSetConfigInstructionArgs,
|
|
153
|
+
this.program
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Sets the deny list.
|
|
159
|
+
*
|
|
160
|
+
* @param {PublicKey} owner - The owner public key.
|
|
161
|
+
* @param {PublicKey[]} denylist - The deny list public keys.
|
|
162
|
+
*
|
|
163
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
164
|
+
*/
|
|
165
|
+
setDenyList(owner: PublicKey, denylist: PublicKey[]): TransactionInstruction {
|
|
166
|
+
const [configAccount] = this.deriver.config()
|
|
167
|
+
return instructions.createOwnerSetConfigInstruction(
|
|
168
|
+
{
|
|
169
|
+
owner,
|
|
170
|
+
config: configAccount,
|
|
171
|
+
} satisfies instructions.OwnerSetConfigInstructionAccounts,
|
|
172
|
+
{
|
|
173
|
+
params: {
|
|
174
|
+
fields: [denylist],
|
|
175
|
+
__kind: 'Denylist',
|
|
176
|
+
} satisfies types.OwnerSetConfigParams,
|
|
177
|
+
} satisfies instructions.OwnerSetConfigInstructionArgs,
|
|
178
|
+
this.program
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Sets the paused state.
|
|
184
|
+
*
|
|
185
|
+
* @param {PublicKey} owner - The owner public key.
|
|
186
|
+
* @param {boolean} paused - The paused state.
|
|
187
|
+
*
|
|
188
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
189
|
+
*/
|
|
190
|
+
setPaused(owner: PublicKey, paused: boolean): TransactionInstruction {
|
|
191
|
+
const [configAccount] = this.deriver.config()
|
|
192
|
+
return instructions.createOwnerSetConfigInstruction(
|
|
193
|
+
{
|
|
194
|
+
owner,
|
|
195
|
+
config: configAccount,
|
|
196
|
+
} satisfies instructions.OwnerSetConfigInstructionAccounts,
|
|
197
|
+
{
|
|
198
|
+
params: {
|
|
199
|
+
fields: [paused],
|
|
200
|
+
__kind: 'Paused',
|
|
201
|
+
} satisfies types.OwnerSetConfigParams,
|
|
202
|
+
} satisfies instructions.OwnerSetConfigInstructionArgs,
|
|
203
|
+
this.program
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Sets the executors.
|
|
209
|
+
*
|
|
210
|
+
* @param {PublicKey} owner - The owner public key.
|
|
211
|
+
* @param {PublicKey[]} executors - The executor public keys.
|
|
212
|
+
*
|
|
213
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
214
|
+
*/
|
|
215
|
+
setExecutors(owner: PublicKey, executors: PublicKey[]): TransactionInstruction {
|
|
216
|
+
const [configAccount] = this.deriver.config()
|
|
217
|
+
return instructions.createOwnerSetConfigInstruction(
|
|
218
|
+
{
|
|
219
|
+
owner,
|
|
220
|
+
config: configAccount,
|
|
221
|
+
} satisfies instructions.OwnerSetConfigInstructionAccounts,
|
|
222
|
+
{
|
|
223
|
+
params: {
|
|
224
|
+
fields: [executors],
|
|
225
|
+
__kind: 'Executors',
|
|
226
|
+
} satisfies types.OwnerSetConfigParams,
|
|
227
|
+
} satisfies instructions.OwnerSetConfigInstructionArgs,
|
|
228
|
+
this.program
|
|
229
|
+
)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Sets the message libraries by programs.
|
|
234
|
+
*
|
|
235
|
+
* @param {PublicKey} owner - The owner public key.
|
|
236
|
+
* @param {PublicKey[]} msglibPrograms - The message library program public keys.
|
|
237
|
+
*
|
|
238
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
239
|
+
*/
|
|
240
|
+
setMsglibByPrograms(owner: PublicKey, msglibPrograms: PublicKey[]): TransactionInstruction {
|
|
241
|
+
const [configAccount] = this.deriver.config()
|
|
242
|
+
const msglibPdas = msglibPrograms.map((program) => {
|
|
243
|
+
return new MessageLibPDADeriver(program).messageLib()[0]
|
|
244
|
+
})
|
|
245
|
+
return this.setMsglibByPDAs(owner, msglibPdas)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Sets the message libraries by PDAs.
|
|
250
|
+
*
|
|
251
|
+
* @param {PublicKey} owner - The owner public key.
|
|
252
|
+
* @param {PublicKey[]} msglibPDAs - The message library PDA public keys.
|
|
253
|
+
*
|
|
254
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
255
|
+
*/
|
|
256
|
+
setMsglibByPDAs(owner: PublicKey, msglibPDAs: PublicKey[]): TransactionInstruction {
|
|
257
|
+
const [configAccount] = this.deriver.config()
|
|
258
|
+
return instructions.createOwnerSetConfigInstruction(
|
|
259
|
+
{
|
|
260
|
+
owner,
|
|
261
|
+
config: configAccount,
|
|
262
|
+
} satisfies instructions.OwnerSetConfigInstructionAccounts,
|
|
263
|
+
{
|
|
264
|
+
params: {
|
|
265
|
+
fields: [msglibPDAs],
|
|
266
|
+
__kind: 'Msglibs',
|
|
267
|
+
} satisfies types.OwnerSetConfigParams,
|
|
268
|
+
} satisfies instructions.OwnerSetConfigInstructionArgs,
|
|
269
|
+
this.program
|
|
270
|
+
)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// admin methods
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Sets the default multiplier BPS.
|
|
277
|
+
*
|
|
278
|
+
* @param {PublicKey} admin - The admin public key.
|
|
279
|
+
* @param {number} defaultMultiplierBps - The default multiplier BPS.
|
|
280
|
+
*
|
|
281
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
282
|
+
*/
|
|
283
|
+
setDefaultMultiplierBps(admin: PublicKey, defaultMultiplierBps: number): TransactionInstruction {
|
|
284
|
+
const [configAccount] = this.deriver.config()
|
|
285
|
+
return instructions.createAdminSetConfigInstruction(
|
|
286
|
+
{
|
|
287
|
+
admin,
|
|
288
|
+
config: configAccount,
|
|
289
|
+
} satisfies instructions.AdminSetConfigInstructionAccounts,
|
|
290
|
+
{
|
|
291
|
+
params: {
|
|
292
|
+
fields: [defaultMultiplierBps],
|
|
293
|
+
__kind: 'DefaultMultiplierBps',
|
|
294
|
+
} satisfies types.AdminSetConfigParams,
|
|
295
|
+
} satisfies instructions.AdminSetConfigInstructionArgs,
|
|
296
|
+
this.program
|
|
297
|
+
)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Sets the destination configurations.
|
|
302
|
+
*
|
|
303
|
+
* @param {PublicKey} admin - The admin public key.
|
|
304
|
+
* @param {types.DstConfig[]} dstConfigs - The destination configurations.
|
|
305
|
+
*
|
|
306
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
307
|
+
*/
|
|
308
|
+
setDstConfig(admin: PublicKey, dstConfigs: types.DstConfig[]): TransactionInstruction {
|
|
309
|
+
const [configAccount] = this.deriver.config()
|
|
310
|
+
return instructions.createAdminSetConfigInstruction(
|
|
311
|
+
{
|
|
312
|
+
admin,
|
|
313
|
+
config: configAccount,
|
|
314
|
+
} satisfies instructions.AdminSetConfigInstructionAccounts,
|
|
315
|
+
{
|
|
316
|
+
params: {
|
|
317
|
+
fields: [dstConfigs],
|
|
318
|
+
__kind: 'DstConfigs',
|
|
319
|
+
} satisfies types.AdminSetConfigParams,
|
|
320
|
+
} satisfies instructions.AdminSetConfigInstructionArgs,
|
|
321
|
+
this.program
|
|
322
|
+
)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Sets the price feed.
|
|
327
|
+
*
|
|
328
|
+
* @param {PublicKey} admin - The admin public key.
|
|
329
|
+
* @param {PublicKey} priceFeedProgram - The price feed program public key.
|
|
330
|
+
*
|
|
331
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
332
|
+
*/
|
|
333
|
+
setPriceFeed(admin: PublicKey, priceFeedProgram: PublicKey): TransactionInstruction {
|
|
334
|
+
const [configAccount] = this.deriver.config()
|
|
335
|
+
const [priceFeed] = new PriceFeedPDADeriver(priceFeedProgram).priceFeed()
|
|
336
|
+
return instructions.createAdminSetConfigInstruction(
|
|
337
|
+
{
|
|
338
|
+
admin,
|
|
339
|
+
config: configAccount,
|
|
340
|
+
} satisfies instructions.AdminSetConfigInstructionAccounts,
|
|
341
|
+
{
|
|
342
|
+
params: {
|
|
343
|
+
fields: [priceFeed],
|
|
344
|
+
__kind: 'PriceFeed',
|
|
345
|
+
} satisfies types.AdminSetConfigParams,
|
|
346
|
+
} satisfies instructions.AdminSetConfigInstructionArgs,
|
|
347
|
+
this.program
|
|
348
|
+
)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Gets the executor configuration.
|
|
353
|
+
*
|
|
354
|
+
* @param {Connection} connection - The connection.
|
|
355
|
+
* @param {Commitment | GetAccountInfoConfig} [commitmentOrConfig] - The commitment or configuration.
|
|
356
|
+
*
|
|
357
|
+
* @returns {Promise<accounts.ExecutorConfig | null>} A promise that resolves to the executor configuration or null.
|
|
358
|
+
*/
|
|
359
|
+
async getExecutorConfig(
|
|
360
|
+
connection: Connection,
|
|
361
|
+
commitmentOrConfig?: Commitment | GetAccountInfoConfig
|
|
362
|
+
): Promise<accounts.ExecutorConfig | null> {
|
|
363
|
+
const [configAccount] = this.deriver.config()
|
|
364
|
+
try {
|
|
365
|
+
const config = await accounts.ExecutorConfig.fromAccountAddress(
|
|
366
|
+
connection,
|
|
367
|
+
configAccount,
|
|
368
|
+
commitmentOrConfig
|
|
369
|
+
)
|
|
370
|
+
return config
|
|
371
|
+
} catch (error) {
|
|
372
|
+
return null
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Gets the quote instruction account meta for CPI.
|
|
378
|
+
*
|
|
379
|
+
* @param {PublicKey} priceFeedConfig - The price feed configuration public key.
|
|
380
|
+
* @param {PublicKey} priceFeedProgram - The price feed program public key.
|
|
381
|
+
* @param {boolean} payment - Whether payment is required.
|
|
382
|
+
*
|
|
383
|
+
* @returns {AccountMeta[]} The account meta array.
|
|
384
|
+
*/
|
|
385
|
+
getQuoteIXAccountMetaForCPI(
|
|
386
|
+
priceFeedConfig: PublicKey,
|
|
387
|
+
priceFeedProgram: PublicKey,
|
|
388
|
+
payment: boolean
|
|
389
|
+
): AccountMeta[] {
|
|
390
|
+
const [config] = this.deriver.config()
|
|
391
|
+
const ixAccounts = instructions.createQuoteExecutorInstructionAccounts(
|
|
392
|
+
{
|
|
393
|
+
executorConfig: config,
|
|
394
|
+
priceFeedConfig,
|
|
395
|
+
priceFeedProgram: priceFeedProgram,
|
|
396
|
+
} satisfies instructions.QuoteExecutorInstructionAccounts,
|
|
397
|
+
this.program
|
|
398
|
+
)
|
|
399
|
+
if (payment) {
|
|
400
|
+
// if payment is required, the first account is required to be writable to receive the payment
|
|
401
|
+
ixAccounts[0].isWritable = true
|
|
402
|
+
}
|
|
403
|
+
return [
|
|
404
|
+
{
|
|
405
|
+
pubkey: this.program,
|
|
406
|
+
isWritable: false,
|
|
407
|
+
isSigner: false,
|
|
408
|
+
},
|
|
409
|
+
].concat(ixAccounts)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Executes a transaction.
|
|
414
|
+
*
|
|
415
|
+
* @param {Connection} connection - The connection.
|
|
416
|
+
* @param {PublicKey} executor - The executor public key.
|
|
417
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
418
|
+
* @param {Packet} packet - The packet.
|
|
419
|
+
* @param {Uint8Array} extraData - The extra data.
|
|
420
|
+
* @param {BN} [value] - The value.
|
|
421
|
+
* @param {number} [computeUnits] - The compute units.
|
|
422
|
+
* @param {Commitment} [commitmentOrConfig] - The commitment or configuration.
|
|
423
|
+
*
|
|
424
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
425
|
+
*/
|
|
426
|
+
async execute(
|
|
427
|
+
connection: Connection,
|
|
428
|
+
executor: PublicKey,
|
|
429
|
+
endpointProgram: PublicKey,
|
|
430
|
+
packet: Packet,
|
|
431
|
+
extraData: Uint8Array,
|
|
432
|
+
value: BN = new BN(0),
|
|
433
|
+
computeUnits = 200000,
|
|
434
|
+
commitmentOrConfig?: Commitment
|
|
435
|
+
): Promise<TransactionInstruction> {
|
|
436
|
+
const [config] = this.deriver.config()
|
|
437
|
+
const endpointEventDeriver = new EventPDADeriver(endpointProgram)
|
|
438
|
+
const executorEventDeriver = new EventPDADeriver(this.program)
|
|
439
|
+
const { message: message_, sender: sender, srcEid, guid, receiver: receiver_, nonce } = packet
|
|
440
|
+
const receiver = new PublicKey(addressToBytes32(receiver_))
|
|
441
|
+
const receiverInfo = await connection.getParsedAccountInfo(receiver, commitmentOrConfig)
|
|
442
|
+
const receiverProgram = new PublicKey((receiverInfo.value as AccountInfo<Buffer>).owner)
|
|
443
|
+
const message = arrayify(message_)
|
|
444
|
+
const accounts = await getLzReceiveAccounts(
|
|
445
|
+
connection,
|
|
446
|
+
executor,
|
|
447
|
+
receiver,
|
|
448
|
+
receiverProgram,
|
|
449
|
+
{
|
|
450
|
+
srcEid: srcEid,
|
|
451
|
+
sender: Array.from(arrayify(sender)),
|
|
452
|
+
guid: Array.from(arrayify(guid)),
|
|
453
|
+
message,
|
|
454
|
+
callerParams: extraData,
|
|
455
|
+
nonce: parseInt(packet.nonce),
|
|
456
|
+
},
|
|
457
|
+
commitmentOrConfig
|
|
458
|
+
)
|
|
459
|
+
|
|
460
|
+
return instructions.createExecuteInstruction(
|
|
461
|
+
{
|
|
462
|
+
executor,
|
|
463
|
+
config,
|
|
464
|
+
endpointProgram,
|
|
465
|
+
endpointEventAuthority: endpointEventDeriver.eventAuthority()[0],
|
|
466
|
+
program: this.program,
|
|
467
|
+
eventAuthority: executorEventDeriver.eventAuthority()[0],
|
|
468
|
+
anchorRemainingAccounts: [
|
|
469
|
+
{
|
|
470
|
+
pubkey: receiverProgram,
|
|
471
|
+
isWritable: false,
|
|
472
|
+
isSigner: false,
|
|
473
|
+
},
|
|
474
|
+
...accounts,
|
|
475
|
+
],
|
|
476
|
+
} satisfies instructions.ExecuteInstructionAccounts,
|
|
477
|
+
{
|
|
478
|
+
params: {
|
|
479
|
+
receiver,
|
|
480
|
+
lzReceive: {
|
|
481
|
+
srcEid,
|
|
482
|
+
sender: Array.from(arrayify(sender)),
|
|
483
|
+
nonce: parseInt(nonce),
|
|
484
|
+
guid: Array.from(arrayify(guid)),
|
|
485
|
+
message,
|
|
486
|
+
extraData,
|
|
487
|
+
},
|
|
488
|
+
value,
|
|
489
|
+
computeUnits,
|
|
490
|
+
} satisfies types.ExecuteParams,
|
|
491
|
+
} satisfies instructions.ExecuteInstructionArgs,
|
|
492
|
+
this.program
|
|
493
|
+
)
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Composes a transaction.
|
|
498
|
+
*
|
|
499
|
+
* @param {Connection} connection - The connection.
|
|
500
|
+
* @param {PublicKey} executor - The executor public key.
|
|
501
|
+
* @param {PublicKey} endpointProgram - The endpoint program public key.
|
|
502
|
+
* @param {ComposeSentEvent} event - The compose sent event.
|
|
503
|
+
* @param {Uint8Array} extraData - The extra data.
|
|
504
|
+
* @param {BN} [value] - The value.
|
|
505
|
+
* @param {number} [computeUnits] - The compute units.
|
|
506
|
+
* @param {Commitment} [commitmentOrConfig] - The commitment or configuration.
|
|
507
|
+
*
|
|
508
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
509
|
+
*/
|
|
510
|
+
async compose(
|
|
511
|
+
connection: Connection,
|
|
512
|
+
executor: PublicKey,
|
|
513
|
+
endpointProgram: PublicKey,
|
|
514
|
+
event: ComposeSentEvent,
|
|
515
|
+
extraData: Uint8Array,
|
|
516
|
+
value: BN = new BN(0),
|
|
517
|
+
computeUnits = 400000,
|
|
518
|
+
commitmentOrConfig?: Commitment
|
|
519
|
+
): Promise<TransactionInstruction> {
|
|
520
|
+
const [config] = this.deriver.config()
|
|
521
|
+
const endpointEventDeriver = new EventPDADeriver(endpointProgram)
|
|
522
|
+
const executorEventDeriver = new EventPDADeriver(this.program)
|
|
523
|
+
const { to, from, guid, index, message } = event
|
|
524
|
+
const receiverInfo = await connection.getParsedAccountInfo(to, commitmentOrConfig)
|
|
525
|
+
const receiverProgram = new PublicKey((receiverInfo.value as AccountInfo<Buffer>).owner)
|
|
526
|
+
|
|
527
|
+
const accounts = await getLzComposeAccountMeta(
|
|
528
|
+
connection,
|
|
529
|
+
executor,
|
|
530
|
+
to,
|
|
531
|
+
receiverProgram,
|
|
532
|
+
{
|
|
533
|
+
from,
|
|
534
|
+
to,
|
|
535
|
+
guid,
|
|
536
|
+
index,
|
|
537
|
+
message,
|
|
538
|
+
extraData,
|
|
539
|
+
},
|
|
540
|
+
commitmentOrConfig
|
|
541
|
+
)
|
|
542
|
+
|
|
543
|
+
return instructions.createComposeInstruction(
|
|
544
|
+
{
|
|
545
|
+
executor,
|
|
546
|
+
config,
|
|
547
|
+
endpointProgram,
|
|
548
|
+
endpointEventAuthority: endpointEventDeriver.eventAuthority()[0],
|
|
549
|
+
program: this.program,
|
|
550
|
+
eventAuthority: executorEventDeriver.eventAuthority()[0],
|
|
551
|
+
anchorRemainingAccounts: [
|
|
552
|
+
{
|
|
553
|
+
pubkey: receiverProgram,
|
|
554
|
+
isWritable: false,
|
|
555
|
+
isSigner: false,
|
|
556
|
+
},
|
|
557
|
+
...accounts,
|
|
558
|
+
],
|
|
559
|
+
} satisfies instructions.ComposeInstructionAccounts,
|
|
560
|
+
{
|
|
561
|
+
params: {
|
|
562
|
+
lzCompose: {
|
|
563
|
+
to,
|
|
564
|
+
from,
|
|
565
|
+
guid,
|
|
566
|
+
index,
|
|
567
|
+
message,
|
|
568
|
+
extraData,
|
|
569
|
+
},
|
|
570
|
+
computeUnits,
|
|
571
|
+
value,
|
|
572
|
+
} satisfies types.ComposeParams,
|
|
573
|
+
} satisfies instructions.ComposeInstructionArgs,
|
|
574
|
+
this.program
|
|
575
|
+
)
|
|
576
|
+
}
|
|
577
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PublicKey } from '@solana/web3.js'
|
|
2
|
+
export * from './instructions'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Program address
|
|
6
|
+
*
|
|
7
|
+
* @category constants
|
|
8
|
+
* @category generated
|
|
9
|
+
*/
|
|
10
|
+
export const PROGRAM_ADDRESS = '2XrYqmhBMPJgDsb4SVbjV1PnJBprurd5bzRCkHwiFCJB'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Program public key
|
|
14
|
+
*
|
|
15
|
+
* @category constants
|
|
16
|
+
* @category generated
|
|
17
|
+
*/
|
|
18
|
+
export const PROGRAM_ID = new PublicKey(PROGRAM_ADDRESS)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './version'
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was GENERATED using the solita package.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality.
|
|
4
|
+
*
|
|
5
|
+
* See: https://github.com/metaplex-foundation/solita
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as beet from '@metaplex-foundation/beet'
|
|
9
|
+
import * as web3 from '@solana/web3.js'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @category Instructions
|
|
13
|
+
* @category Version
|
|
14
|
+
* @category generated
|
|
15
|
+
*/
|
|
16
|
+
export const versionStruct = new beet.BeetArgsStruct<{
|
|
17
|
+
instructionDiscriminator: number[] /* size: 8 */
|
|
18
|
+
}>(
|
|
19
|
+
[['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)]],
|
|
20
|
+
'VersionInstructionArgs'
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
export const versionInstructionDiscriminator = [
|
|
24
|
+
118, 65, 195, 198, 129, 216, 252, 192,
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Creates a _Version_ instruction.
|
|
29
|
+
*
|
|
30
|
+
* @category Instructions
|
|
31
|
+
* @category Version
|
|
32
|
+
* @category generated
|
|
33
|
+
*/
|
|
34
|
+
export function createVersionInstruction(programId: web3.PublicKey) {
|
|
35
|
+
const [data] = versionStruct.serialize({
|
|
36
|
+
instructionDiscriminator: versionInstructionDiscriminator,
|
|
37
|
+
})
|
|
38
|
+
const keys: web3.AccountMeta[] = []
|
|
39
|
+
|
|
40
|
+
const ix = new web3.TransactionInstruction({
|
|
41
|
+
programId,
|
|
42
|
+
keys,
|
|
43
|
+
data,
|
|
44
|
+
})
|
|
45
|
+
return ix
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Creates a _Version_ instructionAccounts.
|
|
50
|
+
*
|
|
51
|
+
* @category Instructions
|
|
52
|
+
* @category Version
|
|
53
|
+
* @category generated
|
|
54
|
+
*/
|
|
55
|
+
export function createVersionInstructionAccounts(programId: web3.PublicKey) {
|
|
56
|
+
const keys: web3.AccountMeta[] = []
|
|
57
|
+
|
|
58
|
+
return keys
|
|
59
|
+
}
|