Skip to content
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

fix: fixed soljuno to fit new solana version #266

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion solana/client/types/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type BlockConfig struct {

func NewDefaultBlockConfig() BlockConfig {
return BlockConfig{
Encoding: "jsonParsed",
Encoding: "json",
TransactionDetails: "full",
Rewards: true,
Commitment: "finalized",
Expand Down
6 changes: 6 additions & 0 deletions solana/client/types/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ type UiTransactionStatusMeta struct {
PreTokenBalances []TransactionTokenBalance `json:"preTokenBalances"`
PostTokenBalances []TransactionTokenBalance `json:"postTokenBalances"`
Rewards []Reward `json:"rewards"`
LoadedAddresses LoadedAddress `json:"loadedAddresses"`
}

type LoadedAddress struct {
Readonly []string `json:"readonly"`
Writable []string `json:"writable"`
}

type UiTransaction struct {
Expand Down
19 changes: 9 additions & 10 deletions types/solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ func (tx Tx) Successful() bool {
func NewTxFromTxResult(parserManager manager.ParserManager, slot uint64, index int, txResult clienttypes.EncodedTransactionWithStatusMeta) Tx {
signature := txResult.Transaction.Signatures[0]
rawMsg := txResult.Transaction.Message
accountKeys := rawMsg.AccountKeys
accountKeys := append(rawMsg.AccountKeys, txResult.Meta.LoadedAddresses.Writable...)
accountKeys = append(accountKeys, txResult.Meta.LoadedAddresses.Readonly...)

// Put innerstructions to map in order to create inner instructions after the main instruction
var innerInstructionMap = make(map[uint8][]clienttypes.UiCompiledInstruction)
Expand All @@ -139,21 +140,19 @@ func NewTxFromTxResult(parserManager manager.ParserManager, slot uint64, index i

instructions := make([]Instruction, 0, len(txResult.Transaction.Message.Instructions)+len(txResult.Meta.InnerInstructions))
for i, instruction := range rawMsg.Instructions {
var accounts []string
innerIndex := 0
accounts = getAccounts(accountKeys, instruction.Accounts)
instructionAccounts := getAccounts(accountKeys, instruction.Accounts)
programID := accountKeys[instruction.ProgramIDIndex]
parsed := parserManager.Parse(accounts, programID, instruction.Data)
instructions = append(instructions, NewInstruction(signature, slot, i, innerIndex, accountKeys[instruction.ProgramIDIndex], accounts, instruction.Data, parsed))
innerIndex++
parsed := parserManager.Parse(instructionAccounts, programID, instruction.Data)
instructions = append(instructions, NewInstruction(signature, slot, i, innerIndex, accountKeys[instruction.ProgramIDIndex], instructionAccounts, instruction.Data, parsed))

if inner, ok := innerInstructionMap[uint8(i)]; ok {
for _, innerInstruction := range inner {
accounts = getAccounts(accountKeys, innerInstruction.Accounts)
programID := accountKeys[innerInstruction.ProgramIDIndex]
parsed := parserManager.Parse(accounts, programID, innerInstruction.Data)
instructions = append(instructions, NewInstruction(signature, slot, i, innerIndex, accountKeys[innerInstruction.ProgramIDIndex], accounts, innerInstruction.Data, parsed))
innerIndex++
innerInstructionAccounts := getAccounts(accountKeys, innerInstruction.Accounts)
programID := accountKeys[innerInstruction.ProgramIDIndex]
parsed := parserManager.Parse(innerInstructionAccounts, programID, innerInstruction.Data)
instructions = append(instructions, NewInstruction(signature, slot, i, innerIndex, accountKeys[innerInstruction.ProgramIDIndex], innerInstructionAccounts, innerInstruction.Data, parsed))
}
}
}
Expand Down