File: src/Xcm/v5/Instruction/InstructionCodec.sol
InstructionCodec
Kind: library
ABI Surface
Errors
error InvalidInstructionLength()error InvalidInstructionPayload()error InvalidInstructionVariant(uint8 variant)
Function Surface
function encode(struct Instruction instruction) internal pure returns (bytes)- Encodes an
Instructioninto SCALE bytes.
- Encodes an
function encodedSizeAt(bytes data, uint256 offset) internal pure returns (uint256)- Returns the number of bytes that an
Instructionoccupies when SCALE-encoded.
- Returns the number of bytes that an
function decode(bytes data) internal pure returns (struct Instruction, uint256)- Decodes an
Instructionfrom SCALE bytes starting at the beginning.
- Decodes an
function decodeAt(bytes data, uint256 offset) internal pure returns (struct Instruction, uint256)- Decodes an
Instructionfrom SCALE bytes starting at a given offset.
- Decodes an
function asWithdrawAsset(struct Instruction instruction) internal pure returns (struct WithdrawAssetParams)- Extracts the decoded
WithdrawAssetParamsfrom aWithdrawAssetinstruction. Reverts if the instruction is not of typeWithdrawAsset.
- Extracts the decoded
function asReserveAssetDeposited(struct Instruction instruction) internal pure returns (struct ReserveAssetDepositedParams)- Extracts the decoded
ReserveAssetDepositedParamsfrom aReserveAssetDepositedinstruction. Reverts if the instruction is not of typeReserveAssetDeposited.
- Extracts the decoded
function asReceiveTeleportedAsset(struct Instruction instruction) internal pure returns (struct ReceiveTeleportedAssetParams)- Extracts the decoded
ReceiveTeleportedAssetParamsfrom aReceiveTeleportedAssetinstruction. Reverts if the instruction is not of typeReceiveTeleportedAsset.
- Extracts the decoded
function asQueryResponse(struct Instruction instruction) internal pure returns (struct QueryResponseParams)- Extracts the decoded
QueryResponseParamsfrom aQueryResponseinstruction. Reverts if the instruction is not of typeQueryResponse.
- Extracts the decoded
function asTransferAsset(struct Instruction instruction) internal pure returns (struct TransferAssetParams)- Extracts the decoded
TransferAssetParamsfrom aTransferAssetinstruction. Reverts if the instruction is not of typeTransferAsset.
- Extracts the decoded
function asTransferReserveAsset(struct Instruction instruction) internal pure returns (struct TransferReserveAssetParams)- Extracts the decoded
TransferReserveAssetParamsfrom aTransferReserveAssetinstruction. Reverts if the instruction is not of typeTransferReserveAsset.
- Extracts the decoded
function asTransact(struct Instruction instruction) internal pure returns (struct TransactParams)- Extracts the decoded
TransactParamsfrom aTransactinstruction. Reverts if the instruction is not of typeTransact.
- Extracts the decoded
function asHrmpNewChannelOpenRequest(struct Instruction instruction) internal pure returns (struct HrmpNewChannelOpenRequestParams)- Extracts the decoded
HrmpNewChannelOpenRequestParamsfrom aHrmpNewChannelOpenRequestinstruction. Reverts if the instruction is not of typeHrmpNewChannelOpenRequest.
- Extracts the decoded
function asHrmpChannelAccepted(struct Instruction instruction) internal pure returns (struct HrmpChannelAcceptedParams)- Extracts the decoded
HrmpChannelAcceptedParamsfrom aHrmpChannelAcceptedinstruction. Reverts if the instruction is not of typeHrmpChannelAccepted.
- Extracts the decoded
function asHrmpChannelClosing(struct Instruction instruction) internal pure returns (struct HrmpChannelClosingParams)- Extracts the decoded
HrmpChannelClosingParamsfrom aHrmpChannelClosinginstruction. Reverts if the instruction is not of typeHrmpChannelClosing.
- Extracts the decoded
function asClearOrigin(struct Instruction instruction) internal pure- Validates a
ClearOrigininstruction payload. Reverts if the instruction is not of typeClearOriginor the payload is invalid.
- Validates a
function asDescendOrigin(struct Instruction instruction) internal pure returns (struct DescendOriginParams)- Extracts the decoded
DescendOriginParamsfrom aDescendOrigininstruction. Reverts if the instruction is not of typeDescendOrigin.
- Extracts the decoded
function asReportError(struct Instruction instruction) internal pure returns (struct ReportErrorParams)- Extracts the decoded
ReportErrorParamsfrom aReportErrorinstruction. Reverts if the instruction is not of typeReportError.
- Extracts the decoded
function asDepositAsset(struct Instruction instruction) internal pure returns (struct DepositAssetParams)- Extracts the decoded
DepositAssetParamsfrom aDepositAssetinstruction. Reverts if the instruction is not of typeDepositAsset.
- Extracts the decoded
function asDepositReserveAsset(struct Instruction instruction) internal pure returns (struct DepositReserveAssetParams)- Extracts the decoded
DepositReserveAssetParamsfrom aDepositReserveAssetinstruction. Reverts if the instruction is not of typeDepositReserveAsset.
- Extracts the decoded
function asExchangeAsset(struct Instruction instruction) internal pure returns (struct ExchangeAssetParams)- Extracts the decoded
ExchangeAssetParamsfrom aExchangeAssetinstruction. Reverts if the instruction is not of typeExchangeAsset.
- Extracts the decoded
function asInitiateReserveWithdraw(struct Instruction instruction) internal pure returns (struct InitiateReserveWithdrawParams)- Extracts the decoded
InitiateReserveWithdrawParamsfrom aInitiateReserveWithdrawinstruction. Reverts if the instruction is not of typeInitiateReserveWithdraw.
- Extracts the decoded
function asInitiateTeleport(struct Instruction instruction) internal pure returns (struct InitiateTeleportParams)- Extracts the decoded
InitiateTeleportParamsfrom aInitiateTeleportinstruction. Reverts if the instruction is not of typeInitiateTeleport.
- Extracts the decoded
function asReportHolding(struct Instruction instruction) internal pure returns (struct ReportHoldingParams)- Extracts the decoded
ReportHoldingParamsfrom aReportHoldinginstruction. Reverts if the instruction is not of typeReportHolding.
- Extracts the decoded
function asBuyExecution(struct Instruction instruction) internal pure returns (struct BuyExecutionParams)- Extracts the decoded
BuyExecutionParamsfrom aBuyExecutioninstruction. Reverts if the instruction is not of typeBuyExecution.
- Extracts the decoded
function asRefundSurplus(struct Instruction instruction) internal pure- Validates a
RefundSurplusinstruction payload. Reverts if the instruction is not of typeRefundSurplusor the payload is invalid.
- Validates a
function asSetErrorHandler(struct Instruction instruction) internal pure returns (struct SetErrorHandlerParams)- Extracts the decoded
SetErrorHandlerParamsfrom aSetErrorHandlerinstruction. Reverts if the instruction is not of typeSetErrorHandler.
- Extracts the decoded
function asSetAppendix(struct Instruction instruction) internal pure returns (struct SetAppendixParams)- Extracts the decoded
SetAppendixParamsfrom aSetAppendixinstruction. Reverts if the instruction is not of typeSetAppendix.
- Extracts the decoded
function asClearError(struct Instruction instruction) internal pure- Validates a
ClearErrorinstruction payload. Reverts if the instruction is not of typeClearErroror the payload is invalid.
- Validates a
function asClaimAsset(struct Instruction instruction) internal pure returns (struct ClaimAssetParams)- Extracts the decoded
ClaimAssetParamsfrom aClaimAssetinstruction. Reverts if the instruction is not of typeClaimAsset.
- Extracts the decoded
function asTrap(struct Instruction instruction) internal pure returns (struct TrapParams)- Extracts the decoded
TrapParamsfrom aTrapinstruction. Reverts if the instruction is not of typeTrap.
- Extracts the decoded
function asSubscribeVersion(struct Instruction instruction) internal pure returns (struct SubscribeVersionParams)- Extracts the decoded
SubscribeVersionParamsfrom aSubscribeVersioninstruction. Reverts if the instruction is not of typeSubscribeVersion.
- Extracts the decoded
function asUnsubscribeVersion(struct Instruction instruction) internal pure- Validates a
UnsubscribeVersioninstruction payload. Reverts if the instruction is not of typeUnsubscribeVersionor the payload is invalid.
- Validates a
function asBurnAsset(struct Instruction instruction) internal pure returns (struct BurnAssetParams)- Extracts the decoded
BurnAssetParamsfrom aBurnAssetinstruction. Reverts if the instruction is not of typeBurnAsset.
- Extracts the decoded
function asExpectAsset(struct Instruction instruction) internal pure returns (struct ExpectAssetParams)- Extracts the decoded
ExpectAssetParamsfrom aExpectAssetinstruction. Reverts if the instruction is not of typeExpectAsset.
- Extracts the decoded
function asExpectOrigin(struct Instruction instruction) internal pure returns (struct ExpectOriginParams)- Extracts the decoded
ExpectOriginParamsfrom aExpectOrigininstruction. Reverts if the instruction is not of typeExpectOrigin.
- Extracts the decoded
function asExpectError(struct Instruction instruction) internal pure returns (struct ExpectErrorParams)- Extracts the decoded
ExpectErrorParamsfrom aExpectErrorinstruction. Reverts if the instruction is not of typeExpectError.
- Extracts the decoded
function asExpectTransactStatus(struct Instruction instruction) internal pure returns (struct ExpectTransactStatusParams)- Extracts the decoded
ExpectTransactStatusParamsfrom aExpectTransactStatusinstruction. Reverts if the instruction is not of typeExpectTransactStatus.
- Extracts the decoded
function asQueryPallet(struct Instruction instruction) internal pure returns (struct QueryPalletParams)- Extracts the decoded
QueryPalletParamsfrom aQueryPalletinstruction. Reverts if the instruction is not of typeQueryPallet.
- Extracts the decoded
function asExpectPallet(struct Instruction instruction) internal pure returns (struct ExpectPalletParams)- Extracts the decoded
ExpectPalletParamsfrom aExpectPalletinstruction. Reverts if the instruction is not of typeExpectPallet.
- Extracts the decoded
function asReportTransactStatus(struct Instruction instruction) internal pure returns (struct ReportTransactStatusParams)- Extracts the decoded
ReportTransactStatusParamsfrom aReportTransactStatusinstruction. Reverts if the instruction is not of typeReportTransactStatus.
- Extracts the decoded
function asClearTransactStatus(struct Instruction instruction) internal pure- Validates a
ClearTransactStatusinstruction payload. Reverts if the instruction is not of typeClearTransactStatusor the payload is invalid.
- Validates a
function asUniversalOrigin(struct Instruction instruction) internal pure returns (struct UniversalOriginParams)- Extracts the decoded
UniversalOriginParamsfrom aUniversalOrigininstruction. Reverts if the instruction is not of typeUniversalOrigin.
- Extracts the decoded
function asExportMessage(struct Instruction instruction) internal pure returns (struct ExportMessageParams)- Extracts the decoded
ExportMessageParamsfrom aExportMessageinstruction. Reverts if the instruction is not of typeExportMessage.
- Extracts the decoded
function asLockAsset(struct Instruction instruction) internal pure returns (struct LockAssetParams)- Extracts the decoded
LockAssetParamsfrom aLockAssetinstruction. Reverts if the instruction is not of typeLockAsset.
- Extracts the decoded
function asUnlockAsset(struct Instruction instruction) internal pure returns (struct UnlockAssetParams)- Extracts the decoded
UnlockAssetParamsfrom aUnlockAssetinstruction. Reverts if the instruction is not of typeUnlockAsset.
- Extracts the decoded
function asNoteUnlockable(struct Instruction instruction) internal pure returns (struct NoteUnlockableParams)- Extracts the decoded
NoteUnlockableParamsfrom aNoteUnlockableinstruction. Reverts if the instruction is not of typeNoteUnlockable.
- Extracts the decoded
function asRequestUnlock(struct Instruction instruction) internal pure returns (struct RequestUnlockParams)- Extracts the decoded
RequestUnlockParamsfrom aRequestUnlockinstruction. Reverts if the instruction is not of typeRequestUnlock.
- Extracts the decoded
function asSetFeesMode(struct Instruction instruction) internal pure returns (struct SetFeesModeParams)- Extracts the decoded
SetFeesModeParamsfrom aSetFeesModeinstruction. Reverts if the instruction is not of typeSetFeesMode.
- Extracts the decoded
function asSetTopic(struct Instruction instruction) internal pure returns (struct SetTopicParams)- Extracts the decoded
SetTopicParamsfrom aSetTopicinstruction. Reverts if the instruction is not of typeSetTopic.
- Extracts the decoded
function asClearTopic(struct Instruction instruction) internal pure- Validates a
ClearTopicinstruction payload. Reverts if the instruction is not of typeClearTopicor the payload is invalid.
- Validates a
function asAliasOrigin(struct Instruction instruction) internal pure returns (struct AliasOriginParams)- Extracts the decoded
AliasOriginParamsfrom aAliasOrigininstruction. Reverts if the instruction is not of typeAliasOrigin.
- Extracts the decoded
function asUnpaidExecution(struct Instruction instruction) internal pure returns (struct UnpaidExecutionParams)- Extracts the decoded
UnpaidExecutionParamsfrom aUnpaidExecutioninstruction. Reverts if the instruction is not of typeUnpaidExecution.
- Extracts the decoded
function asPayFees(struct Instruction instruction) internal pure returns (struct PayFeesParams)- Extracts the decoded
PayFeesParamsfrom aPayFeesinstruction. Reverts if the instruction is not of typePayFees.
- Extracts the decoded
function asInitiateTransfer(struct Instruction instruction) internal pure returns (struct InitiateTransferParams)- Extracts the decoded
InitiateTransferParamsfrom aInitiateTransferinstruction. Reverts if the instruction is not of typeInitiateTransfer.
- Extracts the decoded
function asExecuteWithOrigin(struct Instruction instruction) internal pure returns (struct ExecuteWithOriginParams)- Extracts the decoded
ExecuteWithOriginParamsfrom aExecuteWithOrigininstruction. Reverts if the instruction is not of typeExecuteWithOrigin.
- Extracts the decoded
function asSetHints(struct Instruction instruction) internal pure returns (struct SetHintsParams)- Extracts the decoded
SetHintsParamsfrom aSetHintsinstruction. Reverts if the instruction is not of typeSetHints.
- Extracts the decoded
function \_xcmEncodedSizeAt(bytes data, uint256 offset) private pure returns (uint256)- Returns the encoded size of an XCM byte sequence at offset.
function \_assertVariant(struct Instruction instruction, enum InstructionVariant expectedType) private purefunction \_decodeXcmAt(bytes payload, uint256 offset) private pure returns (bytes, uint256)