Skip to content

Commit a5a046b

Browse files
committed
refactor: mv tokenProgram-related typedefs to tokenProgram pkg
1 parent 78c2b46 commit a5a046b

File tree

11 files changed

+29
-27
lines changed

11 files changed

+29
-27
lines changed

solana/parser_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func TestTokenProgramTransfer(t *testing.T) {
276276
results, _ := Parser(byteValue)
277277
action := results[0].Actions[3]
278278

279-
if transferAction, ok := action.(*types.TokenProgramTransferAction); ok {
279+
if transferAction, ok := action.(*tokenProgram.TransferAction); ok {
280280
assert.Equal(t, transferAction.ProgramID, tokenProgram.Program)
281281
assert.Equal(t, transferAction.ProgramName, tokenProgram.ProgramName)
282282
assert.Equal(t, transferAction.InstructionName, "Transfer")
@@ -296,7 +296,7 @@ func TestTokenProgramTransferChecked(t *testing.T) {
296296
results, _ := Parser(byteValue)
297297
action := results[0].Actions[3]
298298

299-
if transferAction, ok := action.(*types.TokenProgramTransferCheckedAction); ok {
299+
if transferAction, ok := action.(*tokenProgram.TransferCheckedAction); ok {
300300
assert.Equal(t, transferAction.ProgramID, tokenProgram.Program)
301301
assert.Equal(t, transferAction.ProgramName, tokenProgram.ProgramName)
302302
assert.Equal(t, transferAction.InstructionName, "TransferChecked")
@@ -318,7 +318,7 @@ func TestTokenProgramInitializeAccount(t *testing.T) {
318318
results, _ := Parser(byteValue)
319319
action := results[0].Actions[3]
320320

321-
if initAction, ok := action.(*types.TokenProgramInitializeAccountAction); ok {
321+
if initAction, ok := action.(*tokenProgram.InitializeAccountAction); ok {
322322
assert.Equal(t, initAction.ProgramID, tokenProgram.Program)
323323
assert.Equal(t, initAction.ProgramName, tokenProgram.ProgramName)
324324
assert.Equal(t, initAction.InstructionName, "InitializeAccount")

solana/programs/OKXDEXAggregationRouterV2/parsers/commissionSolSwapParser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ func CommissionSolSwap2Parser(result *types.ParsedResult, instruction types.Inst
6666
continue
6767
}
6868
switch p := parsedData.(type) {
69-
case *types.TokenProgramTransferAction:
69+
case *tokenProgram.TransferAction:
7070
if p.From == fromTokenAccount {
7171
fromTokenAmount += p.Amount
7272
}
7373
if p.To == toTokenAccount {
7474
toTokenAmount += p.Amount
7575
}
76-
case *types.TokenProgramTransferCheckedAction:
76+
case *tokenProgram.TransferCheckedAction:
7777
if p.From == fromTokenAccount {
7878
fromTokenAmount += p.Amount
7979
}

solana/programs/OKXDEXAggregationRouterV2/parsers/commissionSplProxySwap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ func CommissionSplProxySwapParser(result *types.ParsedResult, instruction types.
6666
continue
6767
}
6868
switch p := parsedData.(type) {
69-
case *types.TokenProgramTransferAction:
69+
case *tokenProgram.TransferAction:
7070
if p.From == fromTokenAccount {
7171
fromTokenAmount += p.Amount
7272
}
7373
if p.To == toTokenAccount {
7474
toTokenAmount += p.Amount
7575
}
76-
case *types.TokenProgramTransferCheckedAction:
76+
case *tokenProgram.TransferCheckedAction:
7777
if p.From == fromTokenAccount {
7878
fromTokenAmount += p.Amount
7979
}

solana/programs/OKXDEXAggregationRouterV2/parsers/swap.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ func SwapParser(result *types.ParsedResult, instruction types.Instruction, decod
5757
continue
5858
}
5959
switch p := parsedData.(type) {
60-
case *types.TokenProgramTransferAction:
60+
case *tokenProgram.TransferAction:
6161
if p.To == toTokenAccount {
6262
toTokenAmount += p.Amount
6363
}
64-
case *types.TokenProgramTransferCheckedAction:
64+
case *tokenProgram.TransferCheckedAction:
6565
if p.To == toTokenAccount {
6666
toTokenAmount += p.Amount
6767
}

solana/programs/jupiterAggregatorV6/parsers/route.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ func RouteParser(result *types.ParsedResult, instruction types.Instruction) (*ty
6565
continue
6666
}
6767
switch p := parsedData.(type) {
68-
case *types.TokenProgramTransferAction:
68+
case *tokenProgram.TransferAction:
6969
if p.From == fromTokenAccount {
7070
fromTokenAmount += p.Amount
7171
}
7272
if p.To == toTokenAccount {
7373
toTokenAmount += p.Amount
7474
}
75-
case *types.TokenProgramTransferCheckedAction:
75+
case *tokenProgram.TransferCheckedAction:
7676
if p.From == fromTokenAccount {
7777
fromTokenAmount += p.Amount
7878
}

solana/programs/jupiterAggregatorV6/parsers/sharedAccountsRoute.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ func SharedAccountsRouteParser(result *types.ParsedResult, instruction types.Ins
5858
continue
5959
}
6060
switch p := parsedData.(type) {
61-
case *types.TokenProgramTransferAction:
61+
case *tokenProgram.TransferAction:
6262
if p.From == fromTokenAccount {
6363
fromTokenAmount += p.Amount
6464
}
6565
if p.To == toTokenAccount {
6666
toTokenAmount += p.Amount
6767
}
68-
case *types.TokenProgramTransferCheckedAction:
68+
case *tokenProgram.TransferCheckedAction:
6969
if p.From == fromTokenAccount {
7070
fromTokenAmount += p.Amount
7171
}

solana/programs/raydiumLiquidityPoolV4/parsers/swap.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func SwapParser(result *types.ParsedResult, instruction types.Instruction, instr
5959
if err != nil {
6060
continue
6161
}
62-
transferAction, ok := action.(*types.TokenProgramTransferAction)
62+
transferAction, ok := action.(*tokenProgram.TransferAction)
6363
if ok {
6464
if transferAction.To == userDestinationTokenAccount {
6565
toTokenAmount = transferAction.Amount

solana/programs/tokenProgram/parsers/initializeAccount.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"github.com/0xjeffro/tx-parser/solana/types"
66
)
77

8-
func InitializeAccountParser(result *types.ParsedResult, instruction types.Instruction) (*types.TokenProgramInitializeAccountAction, error) {
8+
func InitializeAccountParser(result *types.ParsedResult, instruction types.Instruction) (*tokenProgram.InitializeAccountAction, error) {
99

10-
action := types.TokenProgramInitializeAccountAction{
10+
action := tokenProgram.InitializeAccountAction{
1111
BaseAction: types.BaseAction{
1212
ProgramID: tokenProgram.Program,
1313
ProgramName: tokenProgram.ProgramName,

solana/programs/tokenProgram/parsers/transfer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ type TransferData struct {
1111
Amount uint64
1212
}
1313

14-
func TransferParser(result *types.ParsedResult, instruction types.Instruction, decodedData []byte) (*types.TokenProgramTransferAction, error) {
14+
func TransferParser(result *types.ParsedResult, instruction types.Instruction, decodedData []byte) (*tokenProgram.TransferAction, error) {
1515
var data TransferData
1616
err := borsh.Deserialize(&data, decodedData)
1717
if err != nil {
1818
return nil, err
1919
}
2020

21-
action := types.TokenProgramTransferAction{
21+
action := tokenProgram.TransferAction{
2222
BaseAction: types.BaseAction{
2323
ProgramID: tokenProgram.Program,
2424
ProgramName: tokenProgram.ProgramName,

solana/programs/tokenProgram/parsers/transferChecked.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/near/borsh-go"
88
)
99

10-
func TransferCheckedParser(result *types.ParsedResult, instruction types.Instruction, decodedData []byte) (*types.TokenProgramTransferCheckedAction, error) {
10+
func TransferCheckedParser(result *types.ParsedResult, instruction types.Instruction, decodedData []byte) (*tokenProgram.TransferCheckedAction, error) {
1111
var data TransferData
1212
err := borsh.Deserialize(&data, decodedData)
1313
if err != nil {
@@ -18,7 +18,7 @@ func TransferCheckedParser(result *types.ParsedResult, instruction types.Instruc
1818
fromTokenAccount := result.AccountList[instruction.Accounts[0]]
1919
mint := result.AccountList[instruction.Accounts[1]]
2020
toTokenAccount := result.AccountList[instruction.Accounts[2]]
21-
action := types.TokenProgramTransferCheckedAction{
21+
action := tokenProgram.TransferCheckedAction{
2222
BaseAction: types.BaseAction{
2323
ProgramID: tokenProgram.Program,
2424
ProgramName: tokenProgram.ProgramName,

0 commit comments

Comments
 (0)