-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add support for getTransaction RPC method
#68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
67f829f
XC-293: Re-organize sol_rpc_types into sub-modules
lpahlavi 0243fa4
XC-293: Clippy
lpahlavi 535a8e6
XC-293: Clippy
lpahlavi d8e3142
XC-293: Add new types: part1
lpahlavi 67eff6f
XC-293: Add new types: part2
lpahlavi 7cb6bfe
Merge branch 'main' into lpahlavi/XC-293-get-transaction-v2
lpahlavi aacae82
XC-293: Clippy
lpahlavi 11e2872
XC-293: Use OptionSerializer::or_skip
lpahlavi 4a49327
XC-293: Add some unit tests
lpahlavi 8384ecf
XC-293: Add end-to-end test
lpahlavi bdd3069
XC-293: Fix end-to-end test
lpahlavi 2e5b5f6
XC-293: Clippy
lpahlavi 1981470
XC-293: Rollback Candid changes
lpahlavi fc01635
XC-293: Print to stdout
lpahlavi f91e335
XC-293: Explicitely echo command outputs
lpahlavi ad43948
XC-293: Add Candid interface for getTransactionCyclesCost
lpahlavi 9b32a69
XC-293: Add complete Candid interface
lpahlavi eb0f7b7
XC-293: Fix typo in examples.sh
lpahlavi a5a4675
XC-293: Remove unnecessary output in examples.sh
lpahlavi 055997f
XC-293: Small bash fixes
lpahlavi f499758
XC-293: Remove quotes around $FLAGS
lpahlavi a2a35e8
XC-293: Adapt response size estimate for getBlock based on transactio…
lpahlavi e650430
XC-293: Increase response size estimate for get_transaction
lpahlavi 0a6f8fa
XC-293: Fix indexing for getBlock response
lpahlavi 20af877
XC-293: Add more cycles to getBlock call
lpahlavi 1c7f4be
XC-293: Add more cycles to getBlock call
lpahlavi 566e2ba
XC-293: Address review feedback
lpahlavi 47b5964
XC-293: Clippy
lpahlavi 9cf518a
XC-293: Address review feedback
lpahlavi f5a592a
XC-293: Add explicit try_from instead of try_into
lpahlavi fdb5640
XC-293: Clippy
lpahlavi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,6 +189,14 @@ type GetAccountInfoParams = record { | |
| // Example: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" | ||
| type Pubkey = text; | ||
|
|
||
| // Ed25519 signature as a base-58 encoded string. | ||
| // Example: "5LrcE2f6uvydKRquEJ8xp19heGxSvqsVbcqUeFoiWbXe8JNip7ftPQNTAVPyTK7ijVdpkzmKKaAQR7MWMmujAhXD" | ||
| type Signature = text; | ||
|
|
||
| // A Solana blockhash as a bse58-encoded string. | ||
| // Example: "DzfXchZJoLMG3cNftcf2sw7qatkkuwQf4xH15N5wkKAb" | ||
| type Blockhash = text; | ||
|
|
||
| // Solana account info. | ||
| type AccountInfo = record { | ||
| // Number of lamports assigned to this account. | ||
|
|
@@ -241,6 +249,15 @@ type AccountEncoding = variant { | |
| jsonParsed; | ||
| }; | ||
|
|
||
| // The parameters for a Solana `getTransaction` RPC method call. | ||
| // TODO XC-293: documentation | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO |
||
| type GetTransactionParams = record { | ||
| signature: Signature; | ||
| commitment: opt CommitmentLevel; | ||
| maxSupportedTransactionVersion: opt nat8; | ||
| encoding: opt variant { base58; base64 }; | ||
| }; | ||
|
|
||
| // The parameters for a Solana `sendTransaction` RPC method call. | ||
| type SendTransactionParams = record { | ||
| // Fully-signed transaction, as encoded string. | ||
|
|
@@ -283,6 +300,9 @@ type MultiGetAccountInfoResult = variant { | |
| type GetBlockParams = record { | ||
| // Slot number of the block to fetch. | ||
| slot: Slot; | ||
| // Specifies what transaction details to include in the response. | ||
| // If this field is not specified, the default value of "none" will be used. | ||
| transactionDetails: opt TransactionDetails; | ||
| // The commitment describes how finalized a block is at that point in time. | ||
| commitment: opt variant { confirmed; finalized }; | ||
| // The max transaction version to return in responses. | ||
|
|
@@ -303,15 +323,18 @@ type Timestamp = int64; | |
| type ConfirmedBlock = record { | ||
| // The blockhash of this block's parent, as base-58 encoded string; if the parent block is not | ||
| // available due to ledger cleanup, this field will return "11111111111111111111111111111111". | ||
| previousBlockhash: text; | ||
| previousBlockhash: Blockhash; | ||
| // The blockhash of this block, as base-58 encoded string. | ||
| blockhash: text; | ||
| blockhash: Blockhash; | ||
| // The slot index of this block's parent. | ||
| parentSlot: nat64; | ||
| // Estimated production time. | ||
| blockTime: opt Timestamp; | ||
| // The number of blocks beneath this block. | ||
| blockHeight: opt nat64; | ||
| // The signatures of the transactions in this block. Included if the request parameter `transactionDetails` is not | ||
| // `none`. | ||
| signatures: opt vec Signature; | ||
| }; | ||
|
|
||
| // Represents the result of a call to the `getBlock` Solana RPC method. | ||
|
|
@@ -324,6 +347,172 @@ type MultiGetBlockResult = variant { | |
| Inconsistent : vec record { RpcSource; GetBlockResult }; | ||
| }; | ||
|
|
||
| // TODO XC-293: Format and add documentation | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO |
||
| type CompiledInstruction = record { | ||
| data : text; | ||
| accounts : blob; | ||
| programIdIndex : nat8; | ||
| stackHeight : opt nat32; | ||
| }; | ||
| type EncodedTransaction = variant { | ||
| Binary : record { text; variant { base58; base64 } }; | ||
| LegacyBinary : text; | ||
| }; | ||
| type Instruction = variant { Compiled : CompiledInstruction }; | ||
| type InnerInstructions = record { | ||
| instructions : vec Instruction; | ||
| index : nat8; | ||
| }; | ||
| type InstructionError = variant { | ||
| ModifiedProgramId; | ||
| CallDepth; | ||
| Immutable; | ||
| GenericError; | ||
| ExecutableAccountNotRentExempt; | ||
| IncorrectAuthority; | ||
| PrivilegeEscalation; | ||
| ReentrancyNotAllowed; | ||
| InvalidInstructionData; | ||
| RentEpochModified; | ||
| IllegalOwner; | ||
| ComputationalBudgetExceeded; | ||
| ExecutableDataModified; | ||
| ExecutableLamportChange; | ||
| UnbalancedInstruction; | ||
| ProgramEnvironmentSetupFailure; | ||
| IncorrectProgramId; | ||
| UnsupportedSysvar; | ||
| UnsupportedProgramId; | ||
| AccountDataTooSmall; | ||
| NotEnoughAccountKeys; | ||
| AccountBorrowFailed; | ||
| InvalidRealloc; | ||
| AccountNotExecutable; | ||
| AccountNotRentExempt; | ||
| Custom : nat32; | ||
| AccountDataSizeChanged; | ||
| MaxAccountsDataAllocationsExceeded; | ||
| ExternalAccountLamportSpend; | ||
| ExternalAccountDataModified; | ||
| MissingAccount; | ||
| ProgramFailedToComplete; | ||
| MaxInstructionTraceLengthExceeded; | ||
| InvalidAccountData; | ||
| ProgramFailedToCompile; | ||
| ExecutableModified; | ||
| InvalidAccountOwner; | ||
| MaxSeedLengthExceeded; | ||
| AccountAlreadyInitialized; | ||
| AccountBorrowOutstanding; | ||
| ReadonlyDataModified; | ||
| UninitializedAccount; | ||
| InvalidArgument; | ||
| BorshIoError : text; | ||
| BuiltinProgramsMustConsumeComputeUnits; | ||
| MissingRequiredSignature; | ||
| DuplicateAccountOutOfSync; | ||
| MaxAccountsExceeded; | ||
| ArithmeticOverflow; | ||
| InvalidError; | ||
| InvalidSeeds; | ||
| DuplicateAccountIndex; | ||
| ReadonlyLamportChange; | ||
| InsufficientFunds; | ||
| }; | ||
| type LoadedAddresses = record { writable : vec Pubkey; readonly : vec Pubkey }; | ||
| type Reward = record { | ||
| lamports : int64; | ||
| commission : opt nat8; | ||
| pubkey : Pubkey; | ||
| rewardType : opt variant { Fee; Rent; Voting; Staking }; | ||
| postBalance : nat64; | ||
| }; | ||
| type TokenAmount = record { | ||
| decimals : nat8; | ||
| uiAmount : opt float64; | ||
| uiAmountString : text; | ||
| amount : text; | ||
| }; | ||
| type TransactionDetails = variant { none; signatures }; | ||
| type TransactionError = variant { | ||
lpahlavi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ProgramCacheHitMaxLimit; | ||
| InvalidAccountForFee; | ||
| AddressLookupTableNotFound; | ||
| MissingSignatureForFee; | ||
| WouldExceedAccountDataBlockLimit; | ||
| AccountInUse; | ||
| DuplicateInstruction : nat8; | ||
| AccountNotFound; | ||
| TooManyAccountLocks; | ||
| InvalidAccountIndex; | ||
| AlreadyProcessed; | ||
| WouldExceedAccountDataTotalLimit; | ||
| InvalidAddressLookupTableIndex; | ||
| SanitizeFailure; | ||
| ResanitizationNeeded; | ||
| InvalidRentPayingAccount; | ||
| MaxLoadedAccountsDataSizeExceeded; | ||
| InvalidAddressLookupTableData; | ||
| InvalidWritableAccount; | ||
| WouldExceedMaxAccountCostLimit; | ||
| InvalidLoadedAccountsDataSizeLimit; | ||
| InvalidProgramForExecution; | ||
| InstructionError : record { nat8; InstructionError }; | ||
| InsufficientFundsForRent : record { account_index : nat8 }; | ||
| UnsupportedVersion; | ||
| ClusterMaintenance; | ||
| WouldExceedMaxVoteCostLimit; | ||
| SignatureFailure; | ||
| ProgramAccountNotFound; | ||
| AccountLoadedTwice; | ||
| ProgramExecutionTemporarilyRestricted : record { account_index : nat8 }; | ||
| AccountBorrowOutstanding; | ||
| WouldExceedMaxBlockCostLimit; | ||
| InvalidAddressLookupTableOwner; | ||
| InsufficientFundsForFee; | ||
| CallChainTooDeep; | ||
| UnbalancedTransaction; | ||
| CommitCancelled; | ||
| BlockhashNotFound; | ||
| }; | ||
| type TransactionInfo = record { | ||
| blockTime : opt Timestamp; | ||
| meta : opt TransactionStatusMeta; | ||
| transaction : EncodedTransaction; | ||
| slot : nat64; | ||
| version : opt variant { Legacy; Number : nat8 }; | ||
| }; | ||
| type TransactionStatusMeta = record { | ||
| fee : nat64; | ||
| status : variant { Ok; Err: TransactionError }; | ||
| innerInstructions : opt vec InnerInstructions; | ||
| postTokenBalances : opt vec TransactionTokenBalance; | ||
| preBalances : vec nat64; | ||
| postBalances : vec nat64; | ||
| returnData : opt record { data : text; programId : Pubkey }; | ||
| logMessages : opt vec text; | ||
| rewards : opt vec Reward; | ||
| loadedAddresses : opt LoadedAddresses; | ||
| preTokenBalances : opt vec TransactionTokenBalance; | ||
| computeUnitsConsumed : opt nat64; | ||
| }; | ||
| type TransactionTokenBalance = record { | ||
| owner : opt Pubkey; | ||
| mint : text; | ||
| programId : opt Pubkey; | ||
| accountIndex : nat8; | ||
| uiTokenAmount : TokenAmount; | ||
| }; | ||
|
|
||
| // Represents the result of a call to the `getTransaction` Solana RPC method. | ||
| type GetTransactionResult = variant { Ok : opt TransactionInfo; Err : RpcError }; | ||
|
|
||
| // Represents an aggregated result from multiple RPC calls to the `getTransaction` Solana RPC method. | ||
| type MultiGetTransactionResult = variant { | ||
| Consistent : GetTransactionResult; | ||
| Inconsistent : vec record { RpcSource; GetTransactionResult }; | ||
| }; | ||
|
|
||
| // Represents a Solana slot | ||
| type Slot = nat64; | ||
|
|
||
|
|
@@ -336,11 +525,8 @@ type MultiGetSlotResult = variant { | |
| Inconsistent : vec record { RpcSource; GetSlotResult }; | ||
| }; | ||
|
|
||
| // First transaction signature embedded in the transaction, as base-58 encoded string. | ||
| type TransactionId = text; | ||
|
|
||
| // Represents the result of a call to the `sendTransaction` Solana RPC method. | ||
| type SendTransactionResult = variant { Ok : TransactionId; Err : RpcError }; | ||
| type SendTransactionResult = variant { Ok : Signature; Err : RpcError }; | ||
|
|
||
| // Represents an aggregated result from multiple RPC calls to the `sendTransaction` Solana RPC method. | ||
| type MultiSendTransactionResult = variant { | ||
|
|
@@ -435,6 +621,10 @@ service : (InstallArgs,) -> { | |
| getSlot : (RpcSources, opt GetSlotRpcConfig, opt GetSlotParams) -> (MultiGetSlotResult); | ||
| getSlotCyclesCost : (RpcSources, opt GetSlotRpcConfig, opt GetSlotParams) -> (RequestCostResult) query; | ||
|
|
||
| // Call the Solana `getTransaction` RPC method and return the resulting slot. | ||
| getTransaction : (RpcSources, opt RpcConfig, GetTransactionParams) -> (MultiGetTransactionResult); | ||
| getTransactionCyclesCost : (RpcSources, opt RpcConfig, GetTransactionParams) -> (RequestCostResult) query; | ||
|
|
||
| // Call the Solana `sendTransaction` RPC method and return the resulting transaction ID. | ||
| sendTransaction : (RpcSources, opt RpcConfig, SendTransactionParams) -> (MultiSendTransactionResult); | ||
| sendTransactionCyclesCost : (RpcSources, opt RpcConfig, SendTransactionParams) -> (RequestCostResult) query; | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.