Skip to content

Commit f9f505a

Browse files
committed
init registry
1 parent a887bc1 commit f9f505a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

solana/registry/registry.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package registry
2+
3+
import "github.com/0xjeffro/tx-parser/solana/types"
4+
5+
type ProgramParser struct {
6+
ProgramName string
7+
ProgramID string
8+
ProgramParserFunc func(*types.Instruction, types.Instruction) (types.Action, error)
9+
}
10+
11+
var programParsers = make(map[string]ProgramParser)
12+
13+
func Register(parser ProgramParser) {
14+
programParsers[parser.ProgramID] = parser
15+
}
16+
17+
func GetAllProgramParsers() []ProgramParser {
18+
result := make([]ProgramParser, 0, len(programParsers))
19+
for _, p := range programParsers {
20+
result = append(result, p)
21+
}
22+
return result
23+
}
24+
25+
func GetParserByID(programID string) (ProgramParser, bool) {
26+
p, ok := programParsers[programID]
27+
return p, ok
28+
}

0 commit comments

Comments
 (0)