@layerzerolabs/lz-solana-sdk-v2 3.0.47 → 3.0.48
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 +13 -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/dvn.ts
ADDED
|
@@ -0,0 +1,606 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountMeta,
|
|
3
|
+
Commitment,
|
|
4
|
+
Connection,
|
|
5
|
+
GetAccountInfoConfig,
|
|
6
|
+
PublicKey,
|
|
7
|
+
TransactionInstruction,
|
|
8
|
+
} from '@solana/web3.js'
|
|
9
|
+
|
|
10
|
+
import { EndpointId } from '@layerzerolabs/lz-definitions'
|
|
11
|
+
import { HashSigner, keccak_256 } from '@layerzerolabs/lz-foundation'
|
|
12
|
+
|
|
13
|
+
import { InitDvnParams, MultisigConfig, multisigConfigBeet } from './generated/dvn'
|
|
14
|
+
import * as accounts from './generated/dvn/accounts'
|
|
15
|
+
import * as errors from './generated/dvn/errors'
|
|
16
|
+
import * as events from './generated/dvn/events'
|
|
17
|
+
import * as instructions from './generated/dvn/instructions'
|
|
18
|
+
import * as types from './generated/dvn/types'
|
|
19
|
+
import { DVNDeriver, EventPDADeriver, PriceFeedPDADeriver } from './pda-deriver'
|
|
20
|
+
|
|
21
|
+
export { accounts, errors, instructions, types, events }
|
|
22
|
+
export { PROGRAM_ID } from './generated/dvn'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Interface representing a sign function.
|
|
26
|
+
*/
|
|
27
|
+
export interface SignFunc {
|
|
28
|
+
/**
|
|
29
|
+
* Signs a message.
|
|
30
|
+
*
|
|
31
|
+
* @param {Buffer} message - The message to sign.
|
|
32
|
+
* @returns {Promise<{ signature: Uint8Array; recoveryId: number }[]>} A promise that resolves to an array of signature objects.
|
|
33
|
+
*/
|
|
34
|
+
sign(message: Buffer): Promise<
|
|
35
|
+
{
|
|
36
|
+
signature: Uint8Array
|
|
37
|
+
recoveryId: number
|
|
38
|
+
}[]
|
|
39
|
+
>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Class representing a Solana signer extension.
|
|
44
|
+
*/
|
|
45
|
+
export class SolanaSignerExt implements SignFunc {
|
|
46
|
+
private readonly signers: HashSigner[]
|
|
47
|
+
|
|
48
|
+
private constructor(signers: HashSigner[]) {
|
|
49
|
+
this.signers = signers
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Creates an instance of the SolanaSignerExt class.
|
|
54
|
+
*
|
|
55
|
+
* @param {HashSigner[]} signers - The signers.
|
|
56
|
+
* @returns {SolanaSignerExt} The SolanaSignerExt instance.
|
|
57
|
+
*/
|
|
58
|
+
static from(signers: HashSigner[]): SolanaSignerExt {
|
|
59
|
+
return new SolanaSignerExt(signers)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Signs a message.
|
|
64
|
+
*
|
|
65
|
+
* @param {Buffer} message - The message to sign.
|
|
66
|
+
* @returns {Promise<{ signature: Uint8Array; recoveryId: number }[]>} A promise that resolves to an array of signature objects.
|
|
67
|
+
*/
|
|
68
|
+
async sign(message: Buffer): Promise<{ signature: Uint8Array; recoveryId: number }[]> {
|
|
69
|
+
return Promise.all(
|
|
70
|
+
this.signers.map(async (s) => {
|
|
71
|
+
const rv = await s.signHash(message)
|
|
72
|
+
return { signature: rv.slice(0, 64), recoveryId: rv[64] }
|
|
73
|
+
})
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Class representing a DVN (Decentralized Validator Network).
|
|
80
|
+
*/
|
|
81
|
+
export class DVN {
|
|
82
|
+
dvnDeriver: DVNDeriver
|
|
83
|
+
vid: number
|
|
84
|
+
eventAuthority: PublicKey
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Creates an instance of the DVN class.
|
|
88
|
+
*
|
|
89
|
+
* @param {PublicKey} programId - The program ID.
|
|
90
|
+
* @param {EndpointId} [endpointId=EndpointId.SOLANA_V2_SANDBOX] - The endpoint ID.
|
|
91
|
+
*/
|
|
92
|
+
constructor(
|
|
93
|
+
readonly programId: PublicKey,
|
|
94
|
+
endpointId: EndpointId = EndpointId.SOLANA_V2_SANDBOX
|
|
95
|
+
) {
|
|
96
|
+
this.dvnDeriver = new DVNDeriver(programId)
|
|
97
|
+
this.vid = endpointId % 30000
|
|
98
|
+
this.eventAuthority = new EventPDADeriver(programId).eventAuthority()[0]
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Initializes the DVN.
|
|
103
|
+
*
|
|
104
|
+
* @param {Connection} connection - The connection.
|
|
105
|
+
* @param {PublicKey} payer - The payer.
|
|
106
|
+
* @param {InitDvnParams} params - The initialization parameters.
|
|
107
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
108
|
+
* @throws {Error} If the DVN is already initialized.
|
|
109
|
+
*/
|
|
110
|
+
async initDVN(connection: Connection, payer: PublicKey, params: InitDvnParams): Promise<TransactionInstruction> {
|
|
111
|
+
const [config] = this.dvnDeriver.config()
|
|
112
|
+
const info = await connection.getAccountInfo(config)
|
|
113
|
+
if (info) {
|
|
114
|
+
throw new Error('DVN already initialized')
|
|
115
|
+
}
|
|
116
|
+
return instructions.createInitDvnInstruction(
|
|
117
|
+
{
|
|
118
|
+
payer,
|
|
119
|
+
config,
|
|
120
|
+
} satisfies instructions.InitDvnInstructionAccounts,
|
|
121
|
+
{
|
|
122
|
+
params,
|
|
123
|
+
} satisfies instructions.InitDvnInstructionArgs,
|
|
124
|
+
this.programId
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Gets the digest for a transaction.
|
|
130
|
+
*
|
|
131
|
+
* @param {number} vid - The validator ID.
|
|
132
|
+
* @param {TransactionInstruction} instruction - The transaction instruction.
|
|
133
|
+
* @param {number} expiration - The expiration time.
|
|
134
|
+
* @returns {types.ExecuteTransactionDigest} The transaction digest.
|
|
135
|
+
*/
|
|
136
|
+
getDigest(vid: number, instruction: TransactionInstruction, expiration: number): types.ExecuteTransactionDigest {
|
|
137
|
+
return {
|
|
138
|
+
vid,
|
|
139
|
+
programId: instruction.programId,
|
|
140
|
+
accounts: instruction.keys.map((key) => {
|
|
141
|
+
return {
|
|
142
|
+
pubkey: key.pubkey,
|
|
143
|
+
isSigner: key.isSigner,
|
|
144
|
+
isWritable: key.isWritable,
|
|
145
|
+
}
|
|
146
|
+
}),
|
|
147
|
+
data: instruction.data,
|
|
148
|
+
expiration,
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Gets the execute hash for a given hash bytes.
|
|
154
|
+
*
|
|
155
|
+
* @param {Buffer} hashBytes - The hash bytes.
|
|
156
|
+
* @returns {PublicKey} The execute hash.
|
|
157
|
+
*/
|
|
158
|
+
getExecuteHash(hashBytes: Buffer): PublicKey {
|
|
159
|
+
const [executeHash] = this.dvnDeriver.executeHash(hashBytes)
|
|
160
|
+
return executeHash
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Gets the hash bytes for a given digest.
|
|
165
|
+
*
|
|
166
|
+
* @param {types.ExecuteTransactionDigest} digest - The transaction digest.
|
|
167
|
+
* @returns {Buffer} The hash bytes.
|
|
168
|
+
*/
|
|
169
|
+
getHashBytes(digest: types.ExecuteTransactionDigest): Buffer {
|
|
170
|
+
const [digestBytes] = types.executeTransactionDigestBeet.serialize(digest)
|
|
171
|
+
|
|
172
|
+
const hash = keccak_256(digestBytes)
|
|
173
|
+
return Buffer.from(hash)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Invokes a transaction.
|
|
178
|
+
*
|
|
179
|
+
* @param {Connection} connection - The connection.
|
|
180
|
+
* @param {number} vid - The validator ID.
|
|
181
|
+
* @param {PublicKey} payer - The payer.
|
|
182
|
+
* @param {TransactionInstruction} instruction - The transaction instruction.
|
|
183
|
+
* @param {number} expiration - The expiration time.
|
|
184
|
+
* @param {SignFunc} sign - The sign function.
|
|
185
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
186
|
+
* @throws {Error} If the DVN is not initialized.
|
|
187
|
+
*/
|
|
188
|
+
async invoke(
|
|
189
|
+
connection: Connection,
|
|
190
|
+
vid: number,
|
|
191
|
+
payer: PublicKey,
|
|
192
|
+
instruction: TransactionInstruction,
|
|
193
|
+
expiration: number,
|
|
194
|
+
sign: SignFunc
|
|
195
|
+
): Promise<TransactionInstruction> {
|
|
196
|
+
const configState = await this.getConfigState(connection, 'confirmed')
|
|
197
|
+
if (!configState) {
|
|
198
|
+
throw new Error('DVN not initialized')
|
|
199
|
+
}
|
|
200
|
+
const [config] = this.dvnDeriver.config()
|
|
201
|
+
const digest: types.ExecuteTransactionDigest = this.getDigest(vid, instruction, expiration)
|
|
202
|
+
const hashBytes = this.getHashBytes(digest)
|
|
203
|
+
const executeHash = this.getExecuteHash(hashBytes)
|
|
204
|
+
const signatures: number[][] = []
|
|
205
|
+
const signResult = await sign.sign(hashBytes)
|
|
206
|
+
signatures.push(...signResult.map((s) => Array.from(s.signature).concat([s.recoveryId])))
|
|
207
|
+
const param: types.InvokeParams = {
|
|
208
|
+
digest,
|
|
209
|
+
signatures,
|
|
210
|
+
}
|
|
211
|
+
const remainingAccounts = instruction.keys.map((key) => {
|
|
212
|
+
key.isSigner = false
|
|
213
|
+
return key
|
|
214
|
+
})
|
|
215
|
+
return instructions.createInvokeInstruction(
|
|
216
|
+
{
|
|
217
|
+
signer: payer,
|
|
218
|
+
config,
|
|
219
|
+
executeHash,
|
|
220
|
+
program: this.programId,
|
|
221
|
+
eventAuthority: this.eventAuthority,
|
|
222
|
+
anchorRemainingAccounts: [
|
|
223
|
+
{
|
|
224
|
+
pubkey: instruction.programId,
|
|
225
|
+
isSigner: false,
|
|
226
|
+
isWritable: false,
|
|
227
|
+
},
|
|
228
|
+
].concat(remainingAccounts),
|
|
229
|
+
} satisfies instructions.InvokeInstructionAccounts,
|
|
230
|
+
{
|
|
231
|
+
params: param,
|
|
232
|
+
} satisfies instructions.InvokeInstructionArgs,
|
|
233
|
+
this.programId
|
|
234
|
+
)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Creates a transaction instruction to set the quorum.
|
|
239
|
+
*
|
|
240
|
+
* @param {number} quorum - The quorum.
|
|
241
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
242
|
+
*/
|
|
243
|
+
createSetQuorumInstruction(quorum: number): TransactionInstruction {
|
|
244
|
+
const params: MultisigConfig = {
|
|
245
|
+
fields: [quorum],
|
|
246
|
+
__kind: 'Quorum',
|
|
247
|
+
}
|
|
248
|
+
const fixedBeet = multisigConfigBeet.toFixedFromValue(params)
|
|
249
|
+
const buffer = Buffer.alloc(fixedBeet.byteSize)
|
|
250
|
+
fixedBeet.write(buffer, 0, params)
|
|
251
|
+
return new TransactionInstruction({
|
|
252
|
+
programId: this.programId,
|
|
253
|
+
keys: [],
|
|
254
|
+
data: buffer,
|
|
255
|
+
})
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Creates a transaction instruction to set the admins.
|
|
260
|
+
*
|
|
261
|
+
* @param {PublicKey[]} admins - The admin public keys.
|
|
262
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
263
|
+
*/
|
|
264
|
+
createSetAdminsInstruction(admins: PublicKey[]): TransactionInstruction {
|
|
265
|
+
const params: MultisigConfig = {
|
|
266
|
+
fields: [admins] satisfies [PublicKey[]],
|
|
267
|
+
__kind: 'Admins',
|
|
268
|
+
}
|
|
269
|
+
const fixedBeet = multisigConfigBeet.toFixedFromValue(params)
|
|
270
|
+
const buffer = Buffer.alloc(fixedBeet.byteSize)
|
|
271
|
+
fixedBeet.write(buffer, 0, params)
|
|
272
|
+
return new TransactionInstruction({
|
|
273
|
+
programId: this.programId,
|
|
274
|
+
keys: [],
|
|
275
|
+
data: buffer,
|
|
276
|
+
})
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Creates a transaction instruction to set the signers.
|
|
281
|
+
*
|
|
282
|
+
* @param {Uint8Array[]} signers - The signer public keys.
|
|
283
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
284
|
+
*/
|
|
285
|
+
createSetSignersInstruction(signers: Uint8Array[]): TransactionInstruction {
|
|
286
|
+
const params: MultisigConfig = {
|
|
287
|
+
fields: [signers.map((s) => Array.from(s))],
|
|
288
|
+
__kind: 'Signers',
|
|
289
|
+
}
|
|
290
|
+
const fixedBeet = multisigConfigBeet.toFixedFromValue(params)
|
|
291
|
+
const buffer = Buffer.alloc(fixedBeet.byteSize)
|
|
292
|
+
fixedBeet.write(buffer, 0, params)
|
|
293
|
+
return new TransactionInstruction({
|
|
294
|
+
programId: this.programId,
|
|
295
|
+
keys: [],
|
|
296
|
+
data: buffer,
|
|
297
|
+
})
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Creates a transaction instruction to set the allowlist.
|
|
302
|
+
*
|
|
303
|
+
* @param {PublicKey[]} allowlist - The allowlist public keys.
|
|
304
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
305
|
+
*/
|
|
306
|
+
createSetAllowlistInstruction(allowlist: PublicKey[]): TransactionInstruction {
|
|
307
|
+
const params: MultisigConfig = {
|
|
308
|
+
fields: [allowlist],
|
|
309
|
+
__kind: 'Allowlist',
|
|
310
|
+
}
|
|
311
|
+
const fixedBeet = multisigConfigBeet.toFixedFromValue(params)
|
|
312
|
+
const buffer = Buffer.alloc(fixedBeet.byteSize)
|
|
313
|
+
fixedBeet.write(buffer, 0, params)
|
|
314
|
+
return new TransactionInstruction({
|
|
315
|
+
programId: this.programId,
|
|
316
|
+
keys: [],
|
|
317
|
+
data: buffer,
|
|
318
|
+
})
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Creates a transaction instruction to set the denylist.
|
|
323
|
+
*
|
|
324
|
+
* @param {PublicKey[]} denylist - The denylist public keys.
|
|
325
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
326
|
+
*/
|
|
327
|
+
createSetDenylistInstruction(denylist: PublicKey[]): TransactionInstruction {
|
|
328
|
+
const params: MultisigConfig = {
|
|
329
|
+
fields: [denylist],
|
|
330
|
+
__kind: 'Denylist',
|
|
331
|
+
}
|
|
332
|
+
const fixedBeet = multisigConfigBeet.toFixedFromValue(params)
|
|
333
|
+
const buffer = Buffer.alloc(fixedBeet.byteSize)
|
|
334
|
+
fixedBeet.write(buffer, 0, params)
|
|
335
|
+
return new TransactionInstruction({
|
|
336
|
+
programId: this.programId,
|
|
337
|
+
keys: [],
|
|
338
|
+
data: buffer,
|
|
339
|
+
})
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Creates a transaction instruction to set the pause state.
|
|
344
|
+
*
|
|
345
|
+
* @param {boolean} pause - The pause state.
|
|
346
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
347
|
+
*/
|
|
348
|
+
createSetPauseInstruction(pause: boolean): TransactionInstruction {
|
|
349
|
+
const params: MultisigConfig = {
|
|
350
|
+
fields: [pause],
|
|
351
|
+
__kind: 'Paused',
|
|
352
|
+
}
|
|
353
|
+
const fixedBeet = multisigConfigBeet.toFixedFromValue(params)
|
|
354
|
+
const buffer = Buffer.alloc(fixedBeet.byteSize)
|
|
355
|
+
fixedBeet.write(buffer, 0, params)
|
|
356
|
+
return new TransactionInstruction({
|
|
357
|
+
programId: this.programId,
|
|
358
|
+
keys: [],
|
|
359
|
+
data: buffer,
|
|
360
|
+
})
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Creates a transaction instruction to set the default multiplier basis points.
|
|
365
|
+
*
|
|
366
|
+
* @param {PublicKey} admin - The admin public key.
|
|
367
|
+
* @param {number} defaultMultiplierBps - The default multiplier basis points.
|
|
368
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
369
|
+
*/
|
|
370
|
+
createSetDefaultMultiplierBpsInstruction(admin: PublicKey, defaultMultiplierBps: number): TransactionInstruction {
|
|
371
|
+
const [configAccount] = this.dvnDeriver.config()
|
|
372
|
+
return instructions.createSetConfigInstruction(
|
|
373
|
+
{
|
|
374
|
+
admin,
|
|
375
|
+
config: configAccount,
|
|
376
|
+
program: this.programId,
|
|
377
|
+
eventAuthority: this.eventAuthority,
|
|
378
|
+
} satisfies instructions.SetConfigInstructionAccounts,
|
|
379
|
+
{
|
|
380
|
+
params: {
|
|
381
|
+
config: {
|
|
382
|
+
fields: [defaultMultiplierBps],
|
|
383
|
+
__kind: 'DefaultMultiplierBps',
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
} satisfies instructions.SetConfigInstructionArgs,
|
|
387
|
+
this.programId
|
|
388
|
+
)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Creates a transaction instruction to change the admins.
|
|
393
|
+
*
|
|
394
|
+
* @param {PublicKey} admin - The admin public key.
|
|
395
|
+
* @param {PublicKey[]} admins - The new admin public keys.
|
|
396
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
397
|
+
*/
|
|
398
|
+
createChangeAdminsInstruction(admin: PublicKey, admins: PublicKey[]): TransactionInstruction {
|
|
399
|
+
const [configAccount] = this.dvnDeriver.config()
|
|
400
|
+
return instructions.createSetConfigInstruction(
|
|
401
|
+
{
|
|
402
|
+
admin,
|
|
403
|
+
config: configAccount,
|
|
404
|
+
program: this.programId,
|
|
405
|
+
eventAuthority: this.eventAuthority,
|
|
406
|
+
} satisfies instructions.SetConfigInstructionAccounts,
|
|
407
|
+
{
|
|
408
|
+
params: {
|
|
409
|
+
config: {
|
|
410
|
+
fields: [admins],
|
|
411
|
+
__kind: 'Admins',
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
} satisfies instructions.SetConfigInstructionArgs,
|
|
415
|
+
this.programId
|
|
416
|
+
)
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Creates a transaction instruction to set the destination configurations.
|
|
421
|
+
*
|
|
422
|
+
* @param {PublicKey} admin - The admin public key.
|
|
423
|
+
* @param {types.DstConfig[]} dstConfigs - The destination configurations.
|
|
424
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
425
|
+
*/
|
|
426
|
+
createSetDstConfigInstruction(admin: PublicKey, dstConfigs: types.DstConfig[]): TransactionInstruction {
|
|
427
|
+
const [configAccount] = this.dvnDeriver.config()
|
|
428
|
+
return instructions.createSetConfigInstruction(
|
|
429
|
+
{
|
|
430
|
+
admin,
|
|
431
|
+
config: configAccount,
|
|
432
|
+
program: this.programId,
|
|
433
|
+
eventAuthority: this.eventAuthority,
|
|
434
|
+
} satisfies instructions.SetConfigInstructionAccounts,
|
|
435
|
+
{
|
|
436
|
+
params: {
|
|
437
|
+
config: {
|
|
438
|
+
fields: [dstConfigs],
|
|
439
|
+
__kind: 'DstConfigs',
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
} satisfies instructions.SetConfigInstructionArgs,
|
|
443
|
+
this.programId
|
|
444
|
+
)
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Creates a transaction instruction to remove the destination configurations.
|
|
449
|
+
*
|
|
450
|
+
* @param {PublicKey} admin - The admin public key.
|
|
451
|
+
* @param {number[]} removeEids - The endpoint IDs to remove.
|
|
452
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
453
|
+
*/
|
|
454
|
+
createRemoveDstConfigInstruction(admin: PublicKey, removeEids: number[]): TransactionInstruction {
|
|
455
|
+
const [configAccount] = this.dvnDeriver.config()
|
|
456
|
+
return instructions.createSetConfigInstruction(
|
|
457
|
+
{
|
|
458
|
+
admin,
|
|
459
|
+
config: configAccount,
|
|
460
|
+
program: this.programId,
|
|
461
|
+
eventAuthority: this.eventAuthority,
|
|
462
|
+
} satisfies instructions.SetConfigInstructionAccounts,
|
|
463
|
+
{
|
|
464
|
+
params: {
|
|
465
|
+
config: {
|
|
466
|
+
fields: [removeEids],
|
|
467
|
+
__kind: 'RemoveDstConfigs',
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
} satisfies instructions.SetConfigInstructionArgs,
|
|
471
|
+
this.programId
|
|
472
|
+
)
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* Creates a transaction instruction to set the message libraries.
|
|
477
|
+
*
|
|
478
|
+
* @param {PublicKey[]} msglibPrograms - The message library public keys.
|
|
479
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
480
|
+
*/
|
|
481
|
+
createSetMsgLibsInstruction(msglibPrograms: PublicKey[]): TransactionInstruction {
|
|
482
|
+
const params: MultisigConfig = {
|
|
483
|
+
fields: [msglibPrograms],
|
|
484
|
+
__kind: 'Msglibs',
|
|
485
|
+
}
|
|
486
|
+
const fixedBeet = multisigConfigBeet.toFixedFromValue(params)
|
|
487
|
+
const buffer = Buffer.alloc(fixedBeet.byteSize)
|
|
488
|
+
fixedBeet.write(buffer, 0, params)
|
|
489
|
+
return new TransactionInstruction({
|
|
490
|
+
programId: this.programId,
|
|
491
|
+
keys: [],
|
|
492
|
+
data: buffer,
|
|
493
|
+
})
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Gets the expiration time.
|
|
498
|
+
*
|
|
499
|
+
* @returns {number} The expiration time.
|
|
500
|
+
*/
|
|
501
|
+
_getExpiration(): number {
|
|
502
|
+
return new Date().getTime() / 1000 + 120
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Sets the message libraries.
|
|
507
|
+
*
|
|
508
|
+
* @param {Connection} connection - The connection.
|
|
509
|
+
* @param {PublicKey} payer - The payer.
|
|
510
|
+
* @param {PublicKey[]} msgLibs - The message library public keys.
|
|
511
|
+
* @param {SignFunc} sign - The sign function.
|
|
512
|
+
* @returns {Promise<TransactionInstruction>} A promise that resolves to the transaction instruction.
|
|
513
|
+
*/
|
|
514
|
+
async setMsgLibs(
|
|
515
|
+
connection: Connection,
|
|
516
|
+
payer: PublicKey,
|
|
517
|
+
msgLibs: PublicKey[],
|
|
518
|
+
sign: SignFunc
|
|
519
|
+
): Promise<TransactionInstruction> {
|
|
520
|
+
const expiration = this._getExpiration()
|
|
521
|
+
return this.invoke(connection, this.vid, payer, this.createSetMsgLibsInstruction(msgLibs), expiration, sign)
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Creates a transaction instruction to set the price feed.
|
|
526
|
+
*
|
|
527
|
+
* @param {PublicKey} admin - The admin public key.
|
|
528
|
+
* @param {PublicKey} priceFeedProgram - The price feed program public key.
|
|
529
|
+
* @returns {TransactionInstruction} The transaction instruction.
|
|
530
|
+
*/
|
|
531
|
+
createSetPriceFeedInstruction(admin: PublicKey, priceFeedProgram: PublicKey): TransactionInstruction {
|
|
532
|
+
const [configAccount] = this.dvnDeriver.config()
|
|
533
|
+
const [priceFeedPda] = new PriceFeedPDADeriver(priceFeedProgram).priceFeed()
|
|
534
|
+
return instructions.createSetConfigInstruction(
|
|
535
|
+
{
|
|
536
|
+
admin,
|
|
537
|
+
config: configAccount,
|
|
538
|
+
program: this.programId,
|
|
539
|
+
eventAuthority: this.eventAuthority,
|
|
540
|
+
} satisfies instructions.SetConfigInstructionAccounts,
|
|
541
|
+
{
|
|
542
|
+
params: {
|
|
543
|
+
config: {
|
|
544
|
+
fields: [priceFeedPda],
|
|
545
|
+
__kind: 'PriceFeed',
|
|
546
|
+
},
|
|
547
|
+
},
|
|
548
|
+
} satisfies instructions.SetConfigInstructionArgs,
|
|
549
|
+
this.programId
|
|
550
|
+
)
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* Gets the account metadata for the CPI (Cross-Program Invocation) of the quote instruction.
|
|
555
|
+
*
|
|
556
|
+
* @param {PublicKey} priceFeedConfig - The price feed configuration public key.
|
|
557
|
+
* @param {PublicKey} priceFeedProgram - The price feed program public key.
|
|
558
|
+
* @param {boolean} payment - Indicates if payment is required.
|
|
559
|
+
* @returns {AccountMeta[]} An array of account metadata.
|
|
560
|
+
*/
|
|
561
|
+
getQuoteIXAccountMetaForCPI(
|
|
562
|
+
priceFeedConfig: PublicKey,
|
|
563
|
+
priceFeedProgram: PublicKey,
|
|
564
|
+
payment: boolean
|
|
565
|
+
): AccountMeta[] {
|
|
566
|
+
const [config] = this.dvnDeriver.config()
|
|
567
|
+
const keys = instructions.createQuoteDvnInstructionAccounts(
|
|
568
|
+
{
|
|
569
|
+
dvnConfig: config,
|
|
570
|
+
priceFeedConfig,
|
|
571
|
+
priceFeedProgram: priceFeedProgram,
|
|
572
|
+
} satisfies instructions.QuoteDvnInstructionAccounts,
|
|
573
|
+
this.programId
|
|
574
|
+
)
|
|
575
|
+
if (payment) {
|
|
576
|
+
// if payment is required, the first account is required to be writable to receive the payment
|
|
577
|
+
keys[0].isWritable = true
|
|
578
|
+
}
|
|
579
|
+
return [
|
|
580
|
+
{
|
|
581
|
+
pubkey: this.programId,
|
|
582
|
+
isWritable: false,
|
|
583
|
+
isSigner: false,
|
|
584
|
+
},
|
|
585
|
+
].concat(keys)
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Gets the configuration state.
|
|
590
|
+
*
|
|
591
|
+
* @param {Connection} connection - The connection to the Solana cluster.
|
|
592
|
+
* @param {Commitment | GetAccountInfoConfig} [commitment='confirmed'] - The commitment level or account info configuration.
|
|
593
|
+
* @returns {Promise<accounts.DvnConfig | null>} A promise that resolves to the configuration state or null if not found.
|
|
594
|
+
*/
|
|
595
|
+
async getConfigState(
|
|
596
|
+
connection: Connection,
|
|
597
|
+
commitment: Commitment | GetAccountInfoConfig = 'confirmed'
|
|
598
|
+
): Promise<accounts.DvnConfig | null> {
|
|
599
|
+
const [config] = this.dvnDeriver.config()
|
|
600
|
+
try {
|
|
601
|
+
return await accounts.DvnConfig.fromAccountAddress(connection, config, commitment)
|
|
602
|
+
} catch (e) {
|
|
603
|
+
return null
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|