Skip to content

Commit b8fa08c

Browse files
committed
refactor
Move RaydiumLiquidityPoolV4-related type definitions to RaydiumLiquidityPool Package
1 parent 18475bd commit b8fa08c

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

solana/parser_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ func TestRaydiumLiquidityPoolV4Swap_0(t *testing.T) {
471471
results, _ := Parser(byteValue)
472472
action := results[0].Actions[4]
473473

474-
if swapAction, ok := action.(*types.RaydiumLiquidityPoolV4SwapAction); ok {
474+
if swapAction, ok := action.(*raydiumLiquidityPoolV4.SwapAction); ok {
475475
assert.Equal(t, swapAction.ProgramID, raydiumLiquidityPoolV4.Program)
476476
assert.Equal(t, swapAction.ProgramName, raydiumLiquidityPoolV4.ProgramName)
477477
assert.Equal(t, swapAction.InstructionName, "Swap")
@@ -496,7 +496,7 @@ func TestRaydiumLiquidityPoolV4Swap_1(t *testing.T) {
496496
results, _ := Parser(byteValue)
497497
action := results[0].Actions[4]
498498

499-
if swapAction, ok := action.(*types.RaydiumLiquidityPoolV4SwapAction); ok {
499+
if swapAction, ok := action.(*raydiumLiquidityPoolV4.SwapAction); ok {
500500
assert.Equal(t, swapAction.ProgramID, raydiumLiquidityPoolV4.Program)
501501
assert.Equal(t, swapAction.ProgramName, raydiumLiquidityPoolV4.ProgramName)
502502
assert.Equal(t, swapAction.InstructionName, "Swap")
@@ -521,7 +521,7 @@ func TestRaydiumLiquidityPoolV4Swap_2(t *testing.T) {
521521
results, _ := Parser(byteValue)
522522
action := results[0].Actions[3]
523523

524-
if swapAction, ok := action.(*types.RaydiumLiquidityPoolV4SwapAction); ok {
524+
if swapAction, ok := action.(*raydiumLiquidityPoolV4.SwapAction); ok {
525525
assert.Equal(t, swapAction.ProgramID, raydiumLiquidityPoolV4.Program)
526526
assert.Equal(t, swapAction.ProgramName, raydiumLiquidityPoolV4.ProgramName)
527527
assert.Equal(t, swapAction.InstructionName, "Swap")

solana/programs/raydiumLiquidityPoolV4/parsers/swap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type SwapData struct {
1515
MinimumAmountOut uint64
1616
}
1717

18-
func SwapParser(result *types.ParsedResult, instruction types.Instruction, instructionIdx int, decodedData []byte) (*types.RaydiumLiquidityPoolV4SwapAction, error) {
18+
func SwapParser(result *types.ParsedResult, instruction types.Instruction, instructionIdx int, decodedData []byte) (*raydiumLiquidityPoolV4.SwapAction, error) {
1919
var swapData SwapData
2020
err := borsh.Deserialize(&swapData, decodedData)
2121
if err != nil {
@@ -68,7 +68,7 @@ func SwapParser(result *types.ParsedResult, instruction types.Instruction, instr
6868
}
6969
}
7070

71-
action := types.RaydiumLiquidityPoolV4SwapAction{
71+
action := raydiumLiquidityPoolV4.SwapAction{
7272
BaseAction: types.BaseAction{
7373
ProgramID: raydiumLiquidityPoolV4.Program,
7474
ProgramName: raydiumLiquidityPoolV4.ProgramName,

solana/types/raydiumLiquidityPoolV4Action.go renamed to solana/programs/raydiumLiquidityPoolV4/types.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
package types
1+
package raydiumLiquidityPoolV4
22

3-
type RaydiumLiquidityPoolV4SwapAction struct {
4-
BaseAction
3+
import "github.com/0xjeffro/tx-parser/solana/types"
4+
5+
type SwapAction struct {
6+
types.BaseAction
57
Who string `json:"who"`
68
FromToken string `json:"fromToken"`
79
FromTokenAmount uint64 `json:"fromTokenAmount"`

0 commit comments

Comments
 (0)