-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice.go
More file actions
57 lines (42 loc) · 1.97 KB
/
service.go
File metadata and controls
57 lines (42 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package lighthouse_go
import (
"github.com/alphabatem/common/context"
"github.com/alphabatem/lighthouse_go/generated/lighthouse"
"github.com/gagliardetto/solana-go"
)
type LighthouseService struct {
context.DefaultService
logLevel lighthouse.LogLevel
}
const LIGHTHOUSE_SVC = "lighthouse_svc"
func (svc LighthouseService) Id() string {
return LIGHTHOUSE_SVC
}
func (svc *LighthouseService) Start() error {
svc.logLevel = lighthouse.LogLevel_FailedPlaintextMessage
return nil
}
func (svc *LighthouseService) SetLogLevel(level lighthouse.LogLevel) {
svc.logLevel = level
}
func (svc *LighthouseService) AssertTokenAccountAmountMinMaxInstruction(tokenAccount solana.PublicKey, minAmount uint64, maxAmount uint64) (solana.Instruction, error) {
ix := lighthouse.NewAssertTokenAccountMultiInstruction(svc.logLevel, []*lighthouse.TokenAccountAssertion{
{Amount: &minAmount, Operator: uint8(lighthouse.IntegerOperator_GreaterThanOrEqual)},
{Amount: &maxAmount, Operator: uint8(lighthouse.IntegerOperator_LessThanOrEqual)},
}, tokenAccount)
return ix.Build(), nil
}
func (svc *LighthouseService) AssertTokenAccountAmountInstruction(tokenAccount solana.PublicKey, amount uint64, operator lighthouse.IntegerOperator) (solana.Instruction, error) {
ix := lighthouse.NewAssertTokenAccountMultiInstruction(svc.logLevel, []*lighthouse.TokenAccountAssertion{
{Amount: &amount, Operator: uint8(operator)},
}, tokenAccount)
return ix.Build(), nil
}
func (svc *LighthouseService) AssertAccountInfoInstruction(account solana.PublicKey, assert []*lighthouse.AccountInfoAssertion) (solana.Instruction, error) {
ix := lighthouse.NewAssertAccountInfoMultiInstruction(svc.logLevel, assert, account)
return ix.Build(), nil
}
func (svc *LighthouseService) AssertTokenAccountInstruction(tokenAccount solana.PublicKey, assert []*lighthouse.TokenAccountAssertion) (solana.Instruction, error) {
ix := lighthouse.NewAssertTokenAccountMultiInstruction(svc.logLevel, assert, tokenAccount)
return ix.Build(), nil
}