punm parser

This commit is contained in:
thloyi
2025-11-21 12:01:44 +08:00
parent a945f3b45d
commit f86c5591c1
13 changed files with 228 additions and 148 deletions

View File

@@ -10,31 +10,31 @@ type setComputeData struct {
Units uint64
}
func budgetParser(result *RawTx, instr Instruction, innerInstructions InnerInstructions, offset [2]uint, tx *Tx) ([2]uint, error) {
func budgetParser(tx *Tx, instr Instruction, _ InnerInstructions, offset [2]uint) ([2]uint, error) {
if offset[1] != 0 {
return increaseOffset(offset), nil
}
decode := result.Transaction.Message.Instructions[offset[0]].Data
decode := instr.Data
discriminator := decode[0]
switch discriminator {
case setComputeUnitLimitDiscriminator:
return computeUnitLimitParser(result, offset, tx, decode[1:])
return computeUnitLimitParser(offset, tx, decode[1:])
case setComputeUnitPriceDiscriminator:
return computeUnitPriceParser(result, offset, tx, decode[1:])
return computeUnitPriceParser(offset, tx, decode[1:])
default:
return increaseOffset(offset), nil
}
}
func computeUnitLimitParser(_ *RawTx, offset [2]uint, _ *Tx, decodedData []byte) ([2]uint, error) {
func computeUnitLimitParser(offset [2]uint, _ *Tx, decodedData []byte) ([2]uint, error) {
if len(decodedData) < 8 {
return increaseOffset(offset), nil
}
return increaseOffset(offset), nil
}
func computeUnitPriceParser(_ *RawTx, offset [2]uint, tx *Tx, decodedData []byte) ([2]uint, error) {
func computeUnitPriceParser(offset [2]uint, tx *Tx, decodedData []byte) ([2]uint, error) {
if len(decodedData) < 8 {
return increaseOffset(offset), nil
}