Skip to content

Commit e5e6af9

Browse files
committed
refactor
1 parent 510201f commit e5e6af9

File tree

10 files changed

+55
-39
lines changed

10 files changed

+55
-39
lines changed

solana/parser_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
"github.com/0xjeffro/tx-parser/solana/globals"
1212
"github.com/0xjeffro/tx-parser/solana/programs/compute_budget"
13-
"github.com/0xjeffro/tx-parser/solana/programs/jupiterDCA"
13+
"github.com/0xjeffro/tx-parser/solana/programs/jupiter_dca"
1414
"github.com/0xjeffro/tx-parser/solana/programs/pumpfun"
1515
"github.com/0xjeffro/tx-parser/solana/programs/raydiumLiquidityPoolV4"
1616
"github.com/0xjeffro/tx-parser/solana/programs/systemProgram"
@@ -338,9 +338,9 @@ func TestJupiterDcaOpenDcaV2_0(t *testing.T) {
338338
results, _ := Parser(byteValue)
339339
action := results[0].Actions[0]
340340

341-
if DcaAction, ok := action.(*jupiterDCA.OpenV2Action); ok {
342-
assert.Equal(t, DcaAction.ProgramID, jupiterDCA.Program)
343-
assert.Equal(t, DcaAction.ProgramName, jupiterDCA.ProgramName)
341+
if DcaAction, ok := action.(*jupiter_dca.OpenV2Action); ok {
342+
assert.Equal(t, DcaAction.ProgramID, jupiter_dca.Program)
343+
assert.Equal(t, DcaAction.ProgramName, jupiter_dca.ProgramName)
344344
assert.Equal(t, DcaAction.Dca, "7F3Wg8gzekghzqPLGubCSSjZGj6ihVb14A6QmGKjNL92")
345345
assert.Equal(t, DcaAction.User, "BxDjGoj9y33tmkKMK5dRHeUGkSGWEs4H51uHoQaBv9Wz")
346346
assert.Equal(t, DcaAction.Payer, "BxDjGoj9y33tmkKMK5dRHeUGkSGWEs4H51uHoQaBv9Wz")
@@ -368,9 +368,9 @@ func TestJupiterDcaOpenDcaV2_1(t *testing.T) {
368368
results, _ := Parser(byteValue)
369369
action := results[0].Actions[0]
370370

371-
if DcaAction, ok := action.(*jupiterDCA.OpenV2Action); ok {
372-
assert.Equal(t, DcaAction.ProgramID, jupiterDCA.Program)
373-
assert.Equal(t, DcaAction.ProgramName, jupiterDCA.ProgramName)
371+
if DcaAction, ok := action.(*jupiter_dca.OpenV2Action); ok {
372+
assert.Equal(t, DcaAction.ProgramID, jupiter_dca.Program)
373+
assert.Equal(t, DcaAction.ProgramName, jupiter_dca.ProgramName)
374374
assert.Equal(t, DcaAction.Dca, "GxMofmfnZw6ia9DE2KoqjgEd1vp7VuSrhqYqLWLW6bXf")
375375
assert.Equal(t, DcaAction.User, "4vYWDeg6NHUt1VoUZoV8RqZA51AUEd4VCCghA4arfuH7")
376376
assert.Equal(t, DcaAction.Payer, "4vYWDeg6NHUt1VoUZoV8RqZA51AUEd4VCCghA4arfuH7")
@@ -398,9 +398,9 @@ func TestJupiterDcaEndAndClose_0(t *testing.T) {
398398
results, _ := Parser(byteValue)
399399
action := results[0].Actions[1]
400400

401-
if DcaAction, ok := action.(*jupiterDCA.EndAndCloseAction); ok {
402-
assert.Equal(t, DcaAction.ProgramID, jupiterDCA.Program)
403-
assert.Equal(t, DcaAction.ProgramName, jupiterDCA.ProgramName)
401+
if DcaAction, ok := action.(*jupiter_dca.EndAndCloseAction); ok {
402+
assert.Equal(t, DcaAction.ProgramID, jupiter_dca.Program)
403+
assert.Equal(t, DcaAction.ProgramName, jupiter_dca.ProgramName)
404404
assert.Equal(t, DcaAction.Keeper, "JD25qVdtd65FoiXNmR89JjmoJdYk9sjYQeSTZAALFiMy")
405405
assert.Equal(t, DcaAction.Dca, "Cf8vzN89jMzfgg3XpNGMTkzwihzbm1AHnQy1bVyeLVcy")
406406
assert.Equal(t, DcaAction.InputMint, "E1kvzJNxShvvWTrudokpzuc789vRiDXfXG3duCuY6ooE")
@@ -422,9 +422,9 @@ func TestJupiterDcaEndAndClose_1(t *testing.T) {
422422
results, _ := Parser(byteValue)
423423
action := results[0].Actions[1]
424424

425-
if DcaAction, ok := action.(*jupiterDCA.EndAndCloseAction); ok {
426-
assert.Equal(t, DcaAction.ProgramID, jupiterDCA.Program)
427-
assert.Equal(t, DcaAction.ProgramName, jupiterDCA.ProgramName)
425+
if DcaAction, ok := action.(*jupiter_dca.EndAndCloseAction); ok {
426+
assert.Equal(t, DcaAction.ProgramID, jupiter_dca.Program)
427+
assert.Equal(t, DcaAction.ProgramName, jupiter_dca.ProgramName)
428428
assert.Equal(t, DcaAction.Keeper, "JD38n7ynKYcgPpF7k1BhXEeREu1KqptU93fVGy3S624k")
429429
assert.Equal(t, DcaAction.Dca, "DdtdfnA7mPfzbxDfU2hD7DWNe64fWL9eMk3Tb9jw9ncr")
430430
assert.Equal(t, DcaAction.InputMint, "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")
@@ -446,9 +446,9 @@ func TestJupiterDcaCloseDca_0(t *testing.T) {
446446
results, _ := Parser(byteValue)
447447
action := results[0].Actions[0]
448448

449-
if DcaAction, ok := action.(*jupiterDCA.CloseDcaAction); ok {
450-
assert.Equal(t, DcaAction.ProgramID, jupiterDCA.Program)
451-
assert.Equal(t, DcaAction.ProgramName, jupiterDCA.ProgramName)
449+
if DcaAction, ok := action.(*jupiter_dca.CloseDcaAction); ok {
450+
assert.Equal(t, DcaAction.ProgramID, jupiter_dca.Program)
451+
assert.Equal(t, DcaAction.ProgramName, jupiter_dca.ProgramName)
452452
assert.Equal(t, DcaAction.User, "3k2pJD3FtFT8zZLoYRgHEQgays1jYs6LYCKi5MWNPLKJ")
453453
assert.Equal(t, DcaAction.Dca, "565uLdnjfP69rUpGuE7d5rB65V6BoqYknnWrFdt5ebFk")
454454
assert.Equal(t, DcaAction.InputMint, "6T44rfi9BDUdZbEvVddZWVfsGrpC6N1sSSKYnCsLpump")

solana/programs/PhotonProgram/types.go

Lines changed: 0 additions & 1 deletion
This file was deleted.

solana/programs/jupiterDCA/meta.go renamed to solana/programs/jupiter_dca/meta.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package jupiterDCA
1+
package jupiter_dca
22

33
const Program = "DCA265Vj8a9CEuX1eb1LWRnDT7uK6q1xMipnNyatn23M"
44
const ProgramName = "Jupiter DCA Program"

solana/programs/jupiterDCA/parsers/close_dca.go renamed to solana/programs/jupiter_dca/parsers/close_dca.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package parsers
22

33
import (
4-
"github.com/0xjeffro/tx-parser/solana/programs/jupiterDCA"
4+
"github.com/0xjeffro/tx-parser/solana/programs/jupiter_dca"
55
"github.com/0xjeffro/tx-parser/solana/types"
66
)
77

8-
func CloseDcaParser(result *types.ParsedResult, instruction types.Instruction) (*jupiterDCA.CloseDcaAction, error) {
9-
return &jupiterDCA.CloseDcaAction{
8+
func CloseDcaParser(result *types.ParsedResult, instruction types.Instruction) (*jupiter_dca.CloseDcaAction, error) {
9+
return &jupiter_dca.CloseDcaAction{
1010
BaseAction: types.BaseAction{
1111
ProgramID: result.AccountList[instruction.ProgramIDIndex],
12-
ProgramName: jupiterDCA.ProgramName,
12+
ProgramName: jupiter_dca.ProgramName,
1313
InstructionName: "CloseDca",
1414
},
1515
User: result.AccountList[instruction.Accounts[0]],

solana/programs/jupiterDCA/parsers/end_and_close.go renamed to solana/programs/jupiter_dca/parsers/end_and_close.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package parsers
22

33
import (
4-
"github.com/0xjeffro/tx-parser/solana/programs/jupiterDCA"
4+
"github.com/0xjeffro/tx-parser/solana/programs/jupiter_dca"
55
"github.com/0xjeffro/tx-parser/solana/types"
66
)
77

8-
func EndAndCloseParser(result *types.ParsedResult, instruction types.Instruction) (*jupiterDCA.EndAndCloseAction, error) {
9-
return &jupiterDCA.EndAndCloseAction{
8+
func EndAndCloseParser(result *types.ParsedResult, instruction types.Instruction) (*jupiter_dca.EndAndCloseAction, error) {
9+
return &jupiter_dca.EndAndCloseAction{
1010
BaseAction: types.BaseAction{
1111
ProgramID: result.AccountList[instruction.ProgramIDIndex],
12-
ProgramName: jupiterDCA.ProgramName,
12+
ProgramName: jupiter_dca.ProgramName,
1313
InstructionName: "EndAndClose",
1414
},
1515
Keeper: result.AccountList[instruction.Accounts[0]],

solana/programs/jupiterDCA/parsers/index.go renamed to solana/programs/jupiter_dca/parsers/index.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package parsers
22

33
import (
4-
"github.com/0xjeffro/tx-parser/solana/programs/jupiterDCA"
4+
"github.com/0xjeffro/tx-parser/solana/programs/jupiter_dca"
55
"github.com/0xjeffro/tx-parser/solana/types"
66
"github.com/mr-tron/base58"
77
)
@@ -15,17 +15,17 @@ func InstructionRouter(result *types.ParsedResult, instruction types.Instruction
1515
discriminator := *(*[8]byte)(decode[:8])
1616

1717
switch discriminator {
18-
case jupiterDCA.OpenDcaV2Discriminator:
18+
case jupiter_dca.OpenDcaV2Discriminator:
1919
return OpenDcaV2Parser(result, instruction, decode)
20-
case jupiterDCA.EndAndCloseDiscriminator:
20+
case jupiter_dca.EndAndCloseDiscriminator:
2121
return EndAndCloseParser(result, instruction)
22-
case jupiterDCA.CloseDcaDiscriminator:
22+
case jupiter_dca.CloseDcaDiscriminator:
2323
return CloseDcaParser(result, instruction)
2424
default:
2525
return types.UnknownAction{
2626
BaseAction: types.BaseAction{
2727
ProgramID: result.AccountList[instruction.ProgramIDIndex],
28-
ProgramName: jupiterDCA.ProgramName,
28+
ProgramName: jupiter_dca.ProgramName,
2929
InstructionName: "Unknown",
3030
},
3131
}, nil

solana/programs/jupiterDCA/parsers/open_dca_v2.go renamed to solana/programs/jupiter_dca/parsers/open_dca_v2.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package parsers
22

33
import (
44
"encoding/binary"
5-
"github.com/0xjeffro/tx-parser/solana/programs/jupiterDCA"
5+
"github.com/0xjeffro/tx-parser/solana/programs/jupiter_dca"
66
"github.com/0xjeffro/tx-parser/solana/types"
77
)
88

9-
func OpenDcaV2Parser(result *types.ParsedResult, instruction types.Instruction, decodedData []byte) (*jupiterDCA.OpenV2Action, error) {
9+
func OpenDcaV2Parser(result *types.ParsedResult, instruction types.Instruction, decodedData []byte) (*jupiter_dca.OpenV2Action, error) {
1010
var inAmount uint64
1111
var inAmountPerCycle uint64
1212
var cycleFrequency int64
@@ -39,10 +39,10 @@ func OpenDcaV2Parser(result *types.ParsedResult, instruction types.Instruction,
3939
*startAt = int64(binary.LittleEndian.Uint64(decodedData[59:67]))
4040
}
4141

42-
return &jupiterDCA.OpenV2Action{
42+
return &jupiter_dca.OpenV2Action{
4343
BaseAction: types.BaseAction{
4444
ProgramID: result.AccountList[instruction.ProgramIDIndex],
45-
ProgramName: jupiterDCA.ProgramName,
45+
ProgramName: jupiter_dca.ProgramName,
4646
InstructionName: "OpenDcaV2",
4747
},
4848
InAmount: inAmount,

solana/programs/jupiterDCA/types.go renamed to solana/programs/jupiter_dca/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package jupiterDCA
1+
package jupiter_dca
22

33
import "github.com/0xjeffro/tx-parser/solana/types"
44

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package photon_program
2+
3+
import "github.com/0xjeffro/tx-parser/solana/types"
4+
5+
type PhotonPumpfunBuyAction struct {
6+
types.BaseAction
7+
Who string `json:"who"`
8+
FromToken string `json:"fromToken"`
9+
FromTokenAmount uint64 `json:"fromTokenAmount"`
10+
FromTokenDecimals uint64 `json:"fromTokenDecimals"`
11+
ToToken string `json:"toToken"`
12+
ToTokenAmount uint64 `json:"toTokenAmount"`
13+
ToTokenDecimals uint64 `json:"toTokenDecimals"`
14+
15+
PumpfunFee uint64 `json:"pumpfunFee"`
16+
PhotonFee uint64 `json:"photonFee"`
17+
}

solana/router.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import (
55
OKXDEXAggregationRouterV2Parsers "github.com/0xjeffro/tx-parser/solana/programs/OKXDEXAggregationRouterV2/parsers"
66
"github.com/0xjeffro/tx-parser/solana/programs/compute_budget"
77
ComputeBudgetParsers "github.com/0xjeffro/tx-parser/solana/programs/compute_budget/parsers"
8-
"github.com/0xjeffro/tx-parser/solana/programs/jupiterDCA"
9-
JupiterDCA "github.com/0xjeffro/tx-parser/solana/programs/jupiterDCA/parsers"
108
"github.com/0xjeffro/tx-parser/solana/programs/jupiter_aggregator_v6"
119
JupiterAggregatorV6 "github.com/0xjeffro/tx-parser/solana/programs/jupiter_aggregator_v6/parsers"
10+
"github.com/0xjeffro/tx-parser/solana/programs/jupiter_dca"
11+
JupiterDCA "github.com/0xjeffro/tx-parser/solana/programs/jupiter_dca/parsers"
1212
"github.com/0xjeffro/tx-parser/solana/programs/pumpfun"
1313
PumpfunParsers "github.com/0xjeffro/tx-parser/solana/programs/pumpfun/parsers"
1414
"github.com/0xjeffro/tx-parser/solana/programs/raydiumLiquidityPoolV4"
@@ -38,7 +38,7 @@ func router(result *types.ParsedResult, instructionIdx int) (action types.Action
3838
return ComputeBudgetParsers.InstructionRouter(result, instruction)
3939
case pumpfun.Program:
4040
return PumpfunParsers.InstructionRouter(result, instruction)
41-
case jupiterDCA.Program:
41+
case jupiter_dca.Program:
4242
return JupiterDCA.InstructionRouter(result, instruction)
4343
case raydiumLiquidityPoolV4.Program:
4444
return RaydiumLiquidityPoolV4.InstructionRouter(result, instruction, instructionIdx)

0 commit comments

Comments
 (0)