-
Notifications
You must be signed in to change notification settings - Fork 911
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
feat(simulated_transaction): Add Inner Instructions #2756
feat(simulated_transaction): Add Inner Instructions #2756
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! I haven't tested this as an RPC call yet, but comparing to the RPC docs there seem to be some differences here
I'm guessing that some of this is that jsonParsed
encoding can produce decoded inner instructions, and the docs are missing that. But the field names also seem to differ from the docs a bit.
Do you by any chance have any example simulateTransaction
calls you've been testing with that I could use to review this a bit better?
@mcintyre94 ah that's my bad! I was trying to reuse the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating this! I'm still a little confused about how some of the Rust enums map to these data structures. But I might be interpreting things wrong, and I don't have an RPC that can test this atm.
|
||
export type ParsedNewInnerInstruction = { | ||
index: number; | ||
instructions: UiInstruction[]; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure where this comes from, but can we just re-use UiInnerInstructions
?
Do you have time to knock this out @0xIchigo, or would you like us to finish it up? |
gm @steveluscher ! Totally up to you — I was waiting for us (i.e., Helius) to update our fleet to 1.18 so I could run some sample transactions to see the correct responses |
Example of an unparsed inner instruction: "innerInstructions": [
{
"index": 0,
"instructions": [
{
"accounts": [
"9hUi6B4rqntMzvEz6HKTv9MAq2KJ7s3FvBxHBFf2WkS7",
"7Qpk9MmLevLeCKZqLQRfiucfR7P13XGtMhu7z5fbw3jN",
"8oxdgaw4EzgAVsisY1hhuZpTP3TLgkNYx7o1FrJwPfrs",
"Fo36995qyeK9n7sc7bxTTLgiPCQGukExGTvLdWRs5n68",
"J8x6y5G7GmTkuKTbbCAnfhn72vaUU2qsB6je9oKFigHM",
"CzK26LWpoU9UjSrZkVu97oZj63abJrNv1zp9Hy2zZdy5",
"AVNMK6wiGfppdQNg9WKfMRBXefDPGZFh2f3o1fRbgN8n"
],
"data": "19TzxKPM1",
"programId": "zDEXqXEG7gAyxb1Kg9mK5fPnUdENCGKzWrM21RMdWRq",
"stackHeight": 2
}
]
}
] Modified the simulate transaction call on https://explorer.solana.com/tx/5f47YKxsAmZV31QmFmVH8vHY9zdChAEJTKw2cc1nX8tdZ6XTTWdctevBLiCGncbTYqfL3LZZLHTwUBWCkHjyDCs5/inspect to pass And one where some are parsed: "innerInstructions": [
{
"index": 4,
"instructions": [
{
"parsed": {
"info": {
"lamports": 1113600,
"newAccount": "GhVgUsQ2N4ttchFFtMwtdjCiSRgQwAM2eUotWDA1ADQe",
"owner": "3tZPEagumHvtgBhivFJCmhV9AyhBHGW9VgdsK52i4gwP",
"source": "25xPxkziuZzKbcTxYHYRQq5gzA4SN4xVHnQN2UKktTNY",
"space": 32
},
"type": "createAccount"
},
"program": "system",
"programId": "11111111111111111111111111111111",
"stackHeight": 2
}
]
},
{
"index": 5,
"instructions": [
{
"accounts": [
"G5FEXmMK9QgUYheS9DADpVbAMSWex5TD3YbCVj4sreoZ",
"LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo",
"3YMPvTLn5C2oLh6vRGMgxGsDGJGFLZz92hwoYT4qnEzA",
"ChpcDw3SwjUoai9xdTvTn9ju1QcK44GE9Cp2g9uYSMqP",
"HkKorCHbaWAQRLqUJkwdBD5HaMGJZpD6rENUC7hWhPgp",
"7W87mhpyasAcW77ki2bf2Qs3gqUNgYKR8hVHczYETmUA",
"Ap4DHrnVybF2wXoKxBdFEEJ1Yew8KhZtMUShusHfpump",
"So11111111111111111111111111111111111111112",
"BUG68ajmw4twTgL8yif8vaK23oZUf3XM7zRLgSazEWfd",
"LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo",
"25xPxkziuZzKbcTxYHYRQq5gzA4SN4xVHnQN2UKktTNY",
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"D1ZN9Wj1fRSUQfCjhvnu1hqDMT7hzjzBBpi12nVniYD6",
"LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo",
"2yXR2ybQHRgqtAC51WwKZnNt5gjNZR78AWsT5EzY4uFc",
"31BCwmmHVbGQVPYFrWsHby4yYaS2PtBojhAoWfjfeh18"
],
"data": "PgQWtn8ozix5ipTqV4Ms6sCsUo4prGBqq",
"programId": "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo",
"stackHeight": 2
},
{
"parsed": {
"info": {
"authority": "25xPxkziuZzKbcTxYHYRQq5gzA4SN4xVHnQN2UKktTNY",
"destination": "ChpcDw3SwjUoai9xdTvTn9ju1QcK44GE9Cp2g9uYSMqP",
"mint": "So11111111111111111111111111111111111111112",
"source": "HkKorCHbaWAQRLqUJkwdBD5HaMGJZpD6rENUC7hWhPgp",
"tokenAmount": {
"amount": "2534011000",
"decimals": 9,
"uiAmount": 2.534011,
"uiAmountString": "2.534011"
}
},
"type": "transferChecked"
},
"program": "spl-token",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"stackHeight": 3
},
{
"parsed": {
"info": {
"authority": "G5FEXmMK9QgUYheS9DADpVbAMSWex5TD3YbCVj4sreoZ",
"destination": "7W87mhpyasAcW77ki2bf2Qs3gqUNgYKR8hVHczYETmUA",
"mint": "Ap4DHrnVybF2wXoKxBdFEEJ1Yew8KhZtMUShusHfpump",
"source": "3YMPvTLn5C2oLh6vRGMgxGsDGJGFLZz92hwoYT4qnEzA",
"tokenAmount": {
"amount": "142226232988",
"decimals": 6,
"uiAmount": 142226.232988,
"uiAmountString": "142226.232988"
}
},
"type": "transferChecked"
},
"program": "spl-token",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"stackHeight": 3
},
{
"accounts": [
"D1ZN9Wj1fRSUQfCjhvnu1hqDMT7hzjzBBpi12nVniYD6"
],
"data": "yCGxBopjnVNQkNP5usq1PpL4UxKhD69eFHE2ykhVSYEW1RYvu29Da84bmMAS91uZi91DepyEwaRqreBR29yi5zgRawHA9bi14c8p1zXvrAuNPRGPcHWqx6cc9ynUkxHo2fMTAoaSf9MNjxWaPhEQzr4CLk2pkMAwx75n6Kq8TqW34sN5fKNkSMewSvW8PffqjpCdJo",
"programId": "LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo",
"stackHeight": 3
},
{
"accounts": [
"D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf"
],
"data": "QMqFu4fYGGeUEysFnenhAvBobXTzswhLdvQq6s8axxcbKUPRksm2543pJNNNHVd1VJ58FCg7NVh9cMuPYiMKNyfUpUXSDci9arMkqVwgC1zp935dMUGSepSh5bZikjbvpZ41sHjcBwBzZAWBVgSW2FyzQnW8MeaUQwcWk3AgrveSRxK",
"programId": "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4",
"stackHeight": 2
},
{
"accounts": [
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"9tNgYNmgf8XCEyvMEXgRwGUPXMyLYbtQScvXGsxXWWZi",
"5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1",
"9tNgYNmgf8XCEyvMEXgRwGUPXMyLYbtQScvXGsxXWWZi",
"8kFrDne6y1E9Wnebs7xS6eXJYHoVF43AfPUwGzd1gEmB",
"8nrYAQAfTysFpq1g59P4yTPJupCwFcWDjhqLaQPpJwWM",
"9tNgYNmgf8XCEyvMEXgRwGUPXMyLYbtQScvXGsxXWWZi",
"9tNgYNmgf8XCEyvMEXgRwGUPXMyLYbtQScvXGsxXWWZi",
"9tNgYNmgf8XCEyvMEXgRwGUPXMyLYbtQScvXGsxXWWZi",
"9tNgYNmgf8XCEyvMEXgRwGUPXMyLYbtQScvXGsxXWWZi",
"9tNgYNmgf8XCEyvMEXgRwGUPXMyLYbtQScvXGsxXWWZi",
"9tNgYNmgf8XCEyvMEXgRwGUPXMyLYbtQScvXGsxXWWZi",
"9tNgYNmgf8XCEyvMEXgRwGUPXMyLYbtQScvXGsxXWWZi",
"9tNgYNmgf8XCEyvMEXgRwGUPXMyLYbtQScvXGsxXWWZi",
"7W87mhpyasAcW77ki2bf2Qs3gqUNgYKR8hVHczYETmUA",
"HkKorCHbaWAQRLqUJkwdBD5HaMGJZpD6rENUC7hWhPgp",
"25xPxkziuZzKbcTxYHYRQq5gzA4SN4xVHnQN2UKktTNY"
],
"data": "6EnMsN5NnnGB5MyfVDN6QrK",
"programId": "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8",
"stackHeight": 2
},
{
"parsed": {
"info": {
"amount": "142226232988",
"authority": "25xPxkziuZzKbcTxYHYRQq5gzA4SN4xVHnQN2UKktTNY",
"destination": "8nrYAQAfTysFpq1g59P4yTPJupCwFcWDjhqLaQPpJwWM",
"source": "7W87mhpyasAcW77ki2bf2Qs3gqUNgYKR8hVHczYETmUA"
},
"type": "transfer"
},
"program": "spl-token",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"stackHeight": 3
},
{
"parsed": {
"info": {
"amount": "2477814592",
"authority": "5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1",
"destination": "HkKorCHbaWAQRLqUJkwdBD5HaMGJZpD6rENUC7hWhPgp",
"source": "8kFrDne6y1E9Wnebs7xS6eXJYHoVF43AfPUwGzd1gEmB"
},
"type": "transfer"
},
"program": "spl-token",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"stackHeight": 3
},
{
"accounts": [
"D8cy77BBepLMngZx6ZukaTff5hCt1HrWyKk3Hnd9oitf"
],
"data": "QMqFu4fYGGeUEysFnenhAvR83g86EDDNxzUskfkWKYCBPWe1hqgD6jgKAXr6aYoEQcUmTdi3nY764YdkSkiXjff4uA11bvtJxVE4Dj5zeTT5auuSofAuhBY9jUzKZyH9F5Z165NjVh9gmVHijhjXS5sUt3WVQKYUBcnaLngEDbXm4AB",
"programId": "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4",
"stackHeight": 2
}
]
}
] So I think the types are basically (pseudocode): type UnparsedInnerInstruction = {
accounts: Address[],
data: Base58EncodedString,
programId: Address,
stackHeight: number
}
type ParsedInnerInstruction = {
parsed: {
info: any,
type: string // or enum if we can find the values?
},
program: string, // or enum if we can find the values?
programId: Address,
stackHeight: number
}
type InnerInstructions = (UnparsedInnerInstruction | ParsedInnerInstruction)[] |
@0xIchigo Sorry for all the back and forth here, I should have looked into this more closely before. We can make this PR much simpler, we don't need to define any new types. The reason for the type errors you're getting is because the existing But if you do The relevant types already defined here are: export type ParsedInnerInstruction = {
index: number;
instructions: (ParsedInstruction | PartiallyDecodedInstruction)[];
};
export type ParsedInstruction = {
/** Name of the program for this instruction */
program: string;
/** ID of the program for this instruction */
programId: PublicKey;
/** Parsed instruction info */
parsed: any;
};
export type PartiallyDecodedInstruction = {
/** Program id called by this instruction */
programId: PublicKey;
/** Public keys of accounts passed to this instruction */
accounts: Array<PublicKey>;
/** Raw base-58 instruction data */
data: string;
}; This is exactly what we're seeing in practice from the Given the types are exactly the same, let's just re-use them. I think you can exactly re-use from /** An array of cross program invoked parsed instructions */
innerInstructions?: ParsedInnerInstruction[] | null; |
Ahhh that's my bad for overcomplicating things — should be all good now! cc @steveluscher @mcintyre94 |
ad23ff4
to
be1b4f4
Compare
…ponse, because that makes it optional on the result
be1b4f4
to
8c9ee5f
Compare
🎉 This PR is included in version 1.94.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up. |
This PR aims to address the issue I've outlined in #2755 where the
innerInstructions
parameter is missing for transaction simulations