diff --git a/README.md b/README.md index 4c9bbf1..75a8f9b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,29 @@ # [WIP] lighthouse_go +Uses `github.com/fluxrpc/solana-go` v0.1.9 and requires Go 1.26.4 or newer. +Binary serialization uses `github.com/fluxrpc/solana-go/binary`. Create codecs +with `binary.NewEncoder(nil)` and `binary.NewDecoder(data)`, then call the +bindings' `MarshalWithEncoder` and `UnmarshalWithDecoder` methods. Instruction +payload decoders consume parameters only; `lighthouse.DecodeInstruction` consumes +the full instruction, including its one-byte discriminator. Instruction IDs and +`BaseVariant.TypeID` are now `uint8`; explicit dispatch replaces the old variant +registry. Golden tests cover byte compatibility for all 18 instruction types. + +The service and generated bindings accept Flux public keys and return Flux +instructions. Use `lighthouse.DecodeInstruction` directly; Flux does not provide +the previous SDK's global instruction decoder registry. `EncodeToTree` remains +available with plain-text labels; the previous SDK-specific `TextEncode` method +has been removed. + +The bindings were adapted from anchor-go output. When regenerating from +`lighthouse.json`, preserve the Flux imports, explicit binary codecs, instruction +dispatch, account accessors, and local tree formatting helpers. + +Run `go test ./...` for tests. Live RPC tests require `RPC_URL`; simulation tests +also require `TEST_KEYPAIR` pointing to a Solana keypair file. These can be set in +the environment or `.env`; tests skip when the required configuration is absent. +The offline Flux transaction test is `go test . -run TestFluxInstructionTransaction`. ### Progress -- [x] Token Account Multi \ No newline at end of file +- [x] Token Account Multi diff --git a/generated/lighthouse/AssertAccountData.go b/generated/lighthouse/AssertAccountData.go index 878a327..33be050 100644 --- a/generated/lighthouse/AssertAccountData.go +++ b/generated/lighthouse/AssertAccountData.go @@ -4,9 +4,10 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -43,7 +44,7 @@ func (inst *AssertAccountData) SetAssertion(assertion AccountDataAssertion) *Ass // SetTargetAccountAccount sets the "targetAccount" account. // Target account to be asserted func (inst *AssertAccountData) SetTargetAccountAccount(targetAccount ag_solanago.PublicKey) *AssertAccountData { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetAccount) + inst.AccountMetaSlice[0] = targetAccount.Meta() return inst } @@ -54,7 +55,7 @@ func (inst *AssertAccountData) GetTargetAccountAccount() *ag_solanago.AccountMet } func (inst AssertAccountData) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertAccountData, }} @@ -112,31 +113,27 @@ func (inst *AssertAccountData) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj AssertAccountData) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertAccountData) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertion` param: - err = encoder.Encode(obj.Assertion) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertion == nil { + return errors.New("Assertion parameter is not set") } - return nil -} -func (obj *AssertAccountData) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertion).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertion`: - err = decoder.Decode(&obj.Assertion) - if err != nil { + return encoder.Err() +} +func (obj *AssertAccountData) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertion = new(AccountDataAssertion) + if err := (*obj.Assertion).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertAccountDataInstruction declares a new AssertAccountData instruction with the provided parameters and accounts. @@ -151,3 +148,12 @@ func NewAssertAccountDataInstruction( SetAssertion(assertion). SetTargetAccountAccount(targetAccount) } + +func (inst AssertAccountData) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertAccountData) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertAccountDataMulti.go b/generated/lighthouse/AssertAccountDataMulti.go index c62effb..2cf9012 100644 --- a/generated/lighthouse/AssertAccountDataMulti.go +++ b/generated/lighthouse/AssertAccountDataMulti.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -43,7 +43,7 @@ func (inst *AssertAccountDataMulti) SetAssertions(assertions AccountDataAssertio // SetTargetAccountAccount sets the "targetAccount" account. // Target account to be asserted func (inst *AssertAccountDataMulti) SetTargetAccountAccount(targetAccount ag_solanago.PublicKey) *AssertAccountDataMulti { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetAccount) + inst.AccountMetaSlice[0] = targetAccount.Meta() return inst } @@ -54,7 +54,7 @@ func (inst *AssertAccountDataMulti) GetTargetAccountAccount() *ag_solanago.Accou } func (inst AssertAccountDataMulti) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertAccountDataMulti, }} @@ -112,31 +112,27 @@ func (inst *AssertAccountDataMulti) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj AssertAccountDataMulti) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertAccountDataMulti) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertions` param: - err = encoder.Encode(obj.Assertions) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertions == nil { + return errors.New("Assertions parameter is not set") } - return nil -} -func (obj *AssertAccountDataMulti) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertions).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertions`: - err = decoder.Decode(&obj.Assertions) - if err != nil { + return encoder.Err() +} +func (obj *AssertAccountDataMulti) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertions = new(AccountDataAssertions) + if err := (*obj.Assertions).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertAccountDataMultiInstruction declares a new AssertAccountDataMulti instruction with the provided parameters and accounts. @@ -151,3 +147,12 @@ func NewAssertAccountDataMultiInstruction( SetAssertions(assertions). SetTargetAccountAccount(targetAccount) } + +func (inst AssertAccountDataMulti) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertAccountDataMulti) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertAccountDelta.go b/generated/lighthouse/AssertAccountDelta.go index a8828c8..b1bf9ab 100644 --- a/generated/lighthouse/AssertAccountDelta.go +++ b/generated/lighthouse/AssertAccountDelta.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -46,7 +46,7 @@ func (inst *AssertAccountDelta) SetAssertion(assertion AccountDeltaAssertion) *A // SetAccountAAccount sets the "accountA" account. // Account A where the delta is calculated from func (inst *AssertAccountDelta) SetAccountAAccount(accountA ag_solanago.PublicKey) *AssertAccountDelta { - inst.AccountMetaSlice[0] = ag_solanago.Meta(accountA) + inst.AccountMetaSlice[0] = accountA.Meta() return inst } @@ -59,7 +59,7 @@ func (inst *AssertAccountDelta) GetAccountAAccount() *ag_solanago.AccountMeta { // SetAccountBAccount sets the "accountB" account. // Account B where the delta is calculated to func (inst *AssertAccountDelta) SetAccountBAccount(accountB ag_solanago.PublicKey) *AssertAccountDelta { - inst.AccountMetaSlice[1] = ag_solanago.Meta(accountB) + inst.AccountMetaSlice[1] = accountB.Meta() return inst } @@ -70,7 +70,7 @@ func (inst *AssertAccountDelta) GetAccountBAccount() *ag_solanago.AccountMeta { } func (inst AssertAccountDelta) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertAccountDelta, }} @@ -132,31 +132,27 @@ func (inst *AssertAccountDelta) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj AssertAccountDelta) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertAccountDelta) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertion` param: - err = encoder.Encode(obj.Assertion) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertion == nil { + return errors.New("Assertion parameter is not set") } - return nil -} -func (obj *AssertAccountDelta) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertion).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertion`: - err = decoder.Decode(&obj.Assertion) - if err != nil { + return encoder.Err() +} +func (obj *AssertAccountDelta) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertion = new(AccountDeltaAssertion) + if err := (*obj.Assertion).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertAccountDeltaInstruction declares a new AssertAccountDelta instruction with the provided parameters and accounts. @@ -173,3 +169,12 @@ func NewAssertAccountDeltaInstruction( SetAccountAAccount(accountA). SetAccountBAccount(accountB) } + +func (inst AssertAccountDelta) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertAccountDelta) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertAccountInfo.go b/generated/lighthouse/AssertAccountInfo.go index f9555d5..4b717d0 100644 --- a/generated/lighthouse/AssertAccountInfo.go +++ b/generated/lighthouse/AssertAccountInfo.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -43,7 +43,7 @@ func (inst *AssertAccountInfo) SetAssertion(assertion AccountInfoAssertion) *Ass // SetTargetAccountAccount sets the "targetAccount" account. // Target account to be asserted func (inst *AssertAccountInfo) SetTargetAccountAccount(targetAccount ag_solanago.PublicKey) *AssertAccountInfo { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetAccount) + inst.AccountMetaSlice[0] = targetAccount.Meta() return inst } @@ -54,7 +54,7 @@ func (inst *AssertAccountInfo) GetTargetAccountAccount() *ag_solanago.AccountMet } func (inst AssertAccountInfo) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertAccountInfo, }} @@ -112,31 +112,27 @@ func (inst *AssertAccountInfo) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj AssertAccountInfo) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertAccountInfo) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertion` param: - err = encoder.Encode(obj.Assertion) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertion == nil { + return errors.New("Assertion parameter is not set") } - return nil -} -func (obj *AssertAccountInfo) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertion).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertion`: - err = decoder.Decode(&obj.Assertion) - if err != nil { + return encoder.Err() +} +func (obj *AssertAccountInfo) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertion = new(AccountInfoAssertion) + if err := (*obj.Assertion).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertAccountInfoInstruction declares a new AssertAccountInfo instruction with the provided parameters and accounts. @@ -151,3 +147,12 @@ func NewAssertAccountInfoInstruction( SetAssertion(assertion). SetTargetAccountAccount(targetAccount) } + +func (inst AssertAccountInfo) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertAccountInfo) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertAccountInfoMulti.go b/generated/lighthouse/AssertAccountInfoMulti.go index 1452980..e94748c 100644 --- a/generated/lighthouse/AssertAccountInfoMulti.go +++ b/generated/lighthouse/AssertAccountInfoMulti.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -43,7 +43,7 @@ func (inst *AssertAccountInfoMulti) SetAssertions(assertions AccountInfoAssertio // SetTargetAccountAccount sets the "targetAccount" account. // Target account to be asserted func (inst *AssertAccountInfoMulti) SetTargetAccountAccount(targetAccount ag_solanago.PublicKey) *AssertAccountInfoMulti { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetAccount) + inst.AccountMetaSlice[0] = targetAccount.Meta() return inst } @@ -54,7 +54,7 @@ func (inst *AssertAccountInfoMulti) GetTargetAccountAccount() *ag_solanago.Accou } func (inst AssertAccountInfoMulti) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertAccountInfoMulti, }} @@ -112,54 +112,23 @@ func (inst *AssertAccountInfoMulti) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj AssertAccountInfoMulti) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertAccountInfoMulti) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - - err = encoder.WriteUint8(uint8(len(obj.Assertions))) - if err != nil { + encoder.WriteUint8(uint8((*obj.LogLevel))) + if err := obj.Assertions.MarshalWithEncoder(encoder); err != nil { return err } - - // Serialize `Assertions` param: - for _, at := range obj.Assertions { - err := at.MarshalWithEncoder(encoder) - if err != nil { - return err - } - } - return nil + return encoder.Err() } -func (obj *AssertAccountInfoMulti) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - { - _, _ = decoder.ReadUint8() - } - - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { - return err - } - - assertCount, err := decoder.ReadUint8() - if err != nil { +func (obj *AssertAccountInfoMulti) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + if err := obj.Assertions.UnmarshalWithDecoder(decoder); err != nil { return err } - - // Deserialize `Assertions`: - for i := uint8(0); i < assertCount; i++ { - var assert AccountInfoAssertion - - if err := assert.UnmarshalWithDecoder(decoder); err != nil { - return err - } - obj.Assertions = append(obj.Assertions, &assert) - } - - return nil + return decoder.Err() } // NewAssertAccountInfoMultiInstruction declares a new AssertAccountInfoMulti instruction with the provided parameters and accounts. @@ -174,3 +143,12 @@ func NewAssertAccountInfoMultiInstruction( SetAssertions(assertions). SetTargetAccountAccount(targetAccount) } + +func (inst AssertAccountInfoMulti) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertAccountInfoMulti) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertAccountInfoMulti_test.go b/generated/lighthouse/AssertAccountInfoMulti_test.go index 4bad897..e3b92d1 100644 --- a/generated/lighthouse/AssertAccountInfoMulti_test.go +++ b/generated/lighthouse/AssertAccountInfoMulti_test.go @@ -4,14 +4,13 @@ package lighthouse import ( "bytes" - ag_gofuzz "github.com/gagliardetto/gofuzz" ag_require "github.com/stretchr/testify/require" "strconv" "testing" ) func TestEncodeDecode_AssertAccountInfoMulti(t *testing.T) { - fu := ag_gofuzz.New().NilChance(0) + fu := assertionFuzzer() for i := 0; i < 1; i++ { t.Run("AssertAccountInfoMulti"+strconv.Itoa(i), func(t *testing.T) { { diff --git a/generated/lighthouse/AssertAccountInfo_test.go b/generated/lighthouse/AssertAccountInfo_test.go index 70357b7..552bae0 100644 --- a/generated/lighthouse/AssertAccountInfo_test.go +++ b/generated/lighthouse/AssertAccountInfo_test.go @@ -4,14 +4,13 @@ package lighthouse import ( "bytes" - ag_gofuzz "github.com/gagliardetto/gofuzz" ag_require "github.com/stretchr/testify/require" "strconv" "testing" ) func TestEncodeDecode_AssertAccountInfo(t *testing.T) { - fu := ag_gofuzz.New().NilChance(0) + fu := assertionFuzzer() for i := 0; i < 1; i++ { t.Run("AssertAccountInfo"+strconv.Itoa(i), func(t *testing.T) { { diff --git a/generated/lighthouse/AssertBubblegumTreeConfigAccount.go b/generated/lighthouse/AssertBubblegumTreeConfigAccount.go index b48678a..9c56994 100644 --- a/generated/lighthouse/AssertBubblegumTreeConfigAccount.go +++ b/generated/lighthouse/AssertBubblegumTreeConfigAccount.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -43,7 +43,7 @@ func (inst *AssertBubblegumTreeConfigAccount) SetAssertion(assertion BubblegumTr // SetTargetAccountAccount sets the "targetAccount" account. // Target mpl-bubblegum tree config account to be asserted func (inst *AssertBubblegumTreeConfigAccount) SetTargetAccountAccount(targetAccount ag_solanago.PublicKey) *AssertBubblegumTreeConfigAccount { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetAccount) + inst.AccountMetaSlice[0] = targetAccount.Meta() return inst } @@ -54,7 +54,7 @@ func (inst *AssertBubblegumTreeConfigAccount) GetTargetAccountAccount() *ag_sola } func (inst AssertBubblegumTreeConfigAccount) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertBubblegumTreeConfigAccount, }} @@ -112,31 +112,27 @@ func (inst *AssertBubblegumTreeConfigAccount) EncodeToTree(parent ag_treeout.Bra }) } -func (obj AssertBubblegumTreeConfigAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertBubblegumTreeConfigAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertion` param: - err = encoder.Encode(obj.Assertion) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertion == nil { + return errors.New("Assertion parameter is not set") } - return nil -} -func (obj *AssertBubblegumTreeConfigAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertion).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertion`: - err = decoder.Decode(&obj.Assertion) - if err != nil { + return encoder.Err() +} +func (obj *AssertBubblegumTreeConfigAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertion = new(BubblegumTreeConfigAssertion) + if err := (*obj.Assertion).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertBubblegumTreeConfigAccountInstruction declares a new AssertBubblegumTreeConfigAccount instruction with the provided parameters and accounts. @@ -151,3 +147,12 @@ func NewAssertBubblegumTreeConfigAccountInstruction( SetAssertion(assertion). SetTargetAccountAccount(targetAccount) } + +func (inst AssertBubblegumTreeConfigAccount) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertBubblegumTreeConfigAccount) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertMerkleTreeAccount.go b/generated/lighthouse/AssertMerkleTreeAccount.go index b2e27cc..f1ecfac 100644 --- a/generated/lighthouse/AssertMerkleTreeAccount.go +++ b/generated/lighthouse/AssertMerkleTreeAccount.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -49,7 +49,7 @@ func (inst *AssertMerkleTreeAccount) SetAssertion(assertion MerkleTreeAssertion) // SetTargetMerkleTreeAccount sets the "targetMerkleTree" account. // Target merkle tree account to be asserted func (inst *AssertMerkleTreeAccount) SetTargetMerkleTreeAccount(targetMerkleTree ag_solanago.PublicKey) *AssertMerkleTreeAccount { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetMerkleTree) + inst.AccountMetaSlice[0] = targetMerkleTree.Meta() return inst } @@ -62,7 +62,7 @@ func (inst *AssertMerkleTreeAccount) GetTargetMerkleTreeAccount() *ag_solanago.A // SetRootAccount sets the "root" account. // The current root of the merkle tree func (inst *AssertMerkleTreeAccount) SetRootAccount(root ag_solanago.PublicKey) *AssertMerkleTreeAccount { - inst.AccountMetaSlice[1] = ag_solanago.Meta(root) + inst.AccountMetaSlice[1] = root.Meta() return inst } @@ -75,7 +75,7 @@ func (inst *AssertMerkleTreeAccount) GetRootAccount() *ag_solanago.AccountMeta { // SetSplAccountCompressionAccount sets the "splAccountCompression" account. // SPL account compression program func (inst *AssertMerkleTreeAccount) SetSplAccountCompressionAccount(splAccountCompression ag_solanago.PublicKey) *AssertMerkleTreeAccount { - inst.AccountMetaSlice[2] = ag_solanago.Meta(splAccountCompression) + inst.AccountMetaSlice[2] = splAccountCompression.Meta() return inst } @@ -86,7 +86,7 @@ func (inst *AssertMerkleTreeAccount) GetSplAccountCompressionAccount() *ag_solan } func (inst AssertMerkleTreeAccount) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertMerkleTreeAccount, }} @@ -152,31 +152,27 @@ func (inst *AssertMerkleTreeAccount) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj AssertMerkleTreeAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertMerkleTreeAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertion` param: - err = encoder.Encode(obj.Assertion) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertion == nil { + return errors.New("Assertion parameter is not set") } - return nil -} -func (obj *AssertMerkleTreeAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertion).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertion`: - err = decoder.Decode(&obj.Assertion) - if err != nil { + return encoder.Err() +} +func (obj *AssertMerkleTreeAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertion = new(MerkleTreeAssertion) + if err := (*obj.Assertion).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertMerkleTreeAccountInstruction declares a new AssertMerkleTreeAccount instruction with the provided parameters and accounts. @@ -195,3 +191,12 @@ func NewAssertMerkleTreeAccountInstruction( SetRootAccount(root). SetSplAccountCompressionAccount(splAccountCompression) } + +func (inst AssertMerkleTreeAccount) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertMerkleTreeAccount) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertMintAccount.go b/generated/lighthouse/AssertMintAccount.go index 58f2450..a662cff 100644 --- a/generated/lighthouse/AssertMintAccount.go +++ b/generated/lighthouse/AssertMintAccount.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -43,7 +43,7 @@ func (inst *AssertMintAccount) SetAssertion(assertion MintAccountAssertion) *Ass // SetTargetAccountAccount sets the "targetAccount" account. // Target account to be asserted func (inst *AssertMintAccount) SetTargetAccountAccount(targetAccount ag_solanago.PublicKey) *AssertMintAccount { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetAccount) + inst.AccountMetaSlice[0] = targetAccount.Meta() return inst } @@ -54,7 +54,7 @@ func (inst *AssertMintAccount) GetTargetAccountAccount() *ag_solanago.AccountMet } func (inst AssertMintAccount) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertMintAccount, }} @@ -112,31 +112,27 @@ func (inst *AssertMintAccount) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj AssertMintAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertMintAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertion` param: - err = encoder.Encode(obj.Assertion) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertion == nil { + return errors.New("Assertion parameter is not set") } - return nil -} -func (obj *AssertMintAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertion).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertion`: - err = decoder.Decode(&obj.Assertion) - if err != nil { + return encoder.Err() +} +func (obj *AssertMintAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertion = new(MintAccountAssertion) + if err := (*obj.Assertion).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertMintAccountInstruction declares a new AssertMintAccount instruction with the provided parameters and accounts. @@ -151,3 +147,12 @@ func NewAssertMintAccountInstruction( SetAssertion(assertion). SetTargetAccountAccount(targetAccount) } + +func (inst AssertMintAccount) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertMintAccount) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertMintAccountMulti.go b/generated/lighthouse/AssertMintAccountMulti.go index 7301561..dd63904 100644 --- a/generated/lighthouse/AssertMintAccountMulti.go +++ b/generated/lighthouse/AssertMintAccountMulti.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -43,7 +43,7 @@ func (inst *AssertMintAccountMulti) SetAssertions(assertions MintAccountAssertio // SetTargetAccountAccount sets the "targetAccount" account. // Target account to be asserted func (inst *AssertMintAccountMulti) SetTargetAccountAccount(targetAccount ag_solanago.PublicKey) *AssertMintAccountMulti { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetAccount) + inst.AccountMetaSlice[0] = targetAccount.Meta() return inst } @@ -54,7 +54,7 @@ func (inst *AssertMintAccountMulti) GetTargetAccountAccount() *ag_solanago.Accou } func (inst AssertMintAccountMulti) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertMintAccountMulti, }} @@ -112,31 +112,27 @@ func (inst *AssertMintAccountMulti) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj AssertMintAccountMulti) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertMintAccountMulti) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertions` param: - err = encoder.Encode(obj.Assertions) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertions == nil { + return errors.New("Assertions parameter is not set") } - return nil -} -func (obj *AssertMintAccountMulti) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertions).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertions`: - err = decoder.Decode(&obj.Assertions) - if err != nil { + return encoder.Err() +} +func (obj *AssertMintAccountMulti) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertions = new(MintAccountAssertions) + if err := (*obj.Assertions).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertMintAccountMultiInstruction declares a new AssertMintAccountMulti instruction with the provided parameters and accounts. @@ -151,3 +147,12 @@ func NewAssertMintAccountMultiInstruction( SetAssertions(assertions). SetTargetAccountAccount(targetAccount) } + +func (inst AssertMintAccountMulti) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertMintAccountMulti) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertStakeAccount.go b/generated/lighthouse/AssertStakeAccount.go index b107cb2..67229af 100644 --- a/generated/lighthouse/AssertStakeAccount.go +++ b/generated/lighthouse/AssertStakeAccount.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -43,7 +43,7 @@ func (inst *AssertStakeAccount) SetAssertion(assertion StakeAccountAssertion) *A // SetTargetAccountAccount sets the "targetAccount" account. // Target account to be asserted func (inst *AssertStakeAccount) SetTargetAccountAccount(targetAccount ag_solanago.PublicKey) *AssertStakeAccount { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetAccount) + inst.AccountMetaSlice[0] = targetAccount.Meta() return inst } @@ -54,7 +54,7 @@ func (inst *AssertStakeAccount) GetTargetAccountAccount() *ag_solanago.AccountMe } func (inst AssertStakeAccount) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertStakeAccount, }} @@ -112,31 +112,27 @@ func (inst *AssertStakeAccount) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj AssertStakeAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertStakeAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertion` param: - err = encoder.Encode(obj.Assertion) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertion == nil { + return errors.New("Assertion parameter is not set") } - return nil -} -func (obj *AssertStakeAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertion).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertion`: - err = decoder.Decode(&obj.Assertion) - if err != nil { + return encoder.Err() +} +func (obj *AssertStakeAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertion = new(StakeAccountAssertion) + if err := (*obj.Assertion).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertStakeAccountInstruction declares a new AssertStakeAccount instruction with the provided parameters and accounts. @@ -151,3 +147,12 @@ func NewAssertStakeAccountInstruction( SetAssertion(assertion). SetTargetAccountAccount(targetAccount) } + +func (inst AssertStakeAccount) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertStakeAccount) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertStakeAccountMulti.go b/generated/lighthouse/AssertStakeAccountMulti.go index e6ca00d..861b9ff 100644 --- a/generated/lighthouse/AssertStakeAccountMulti.go +++ b/generated/lighthouse/AssertStakeAccountMulti.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -43,7 +43,7 @@ func (inst *AssertStakeAccountMulti) SetAssertions(assertions StakeAccountAssert // SetTargetAccountAccount sets the "targetAccount" account. // Target account to be asserted func (inst *AssertStakeAccountMulti) SetTargetAccountAccount(targetAccount ag_solanago.PublicKey) *AssertStakeAccountMulti { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetAccount) + inst.AccountMetaSlice[0] = targetAccount.Meta() return inst } @@ -54,7 +54,7 @@ func (inst *AssertStakeAccountMulti) GetTargetAccountAccount() *ag_solanago.Acco } func (inst AssertStakeAccountMulti) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertStakeAccountMulti, }} @@ -112,31 +112,27 @@ func (inst *AssertStakeAccountMulti) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj AssertStakeAccountMulti) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertStakeAccountMulti) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertions` param: - err = encoder.Encode(obj.Assertions) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertions == nil { + return errors.New("Assertions parameter is not set") } - return nil -} -func (obj *AssertStakeAccountMulti) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertions).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertions`: - err = decoder.Decode(&obj.Assertions) - if err != nil { + return encoder.Err() +} +func (obj *AssertStakeAccountMulti) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertions = new(StakeAccountAssertions) + if err := (*obj.Assertions).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertStakeAccountMultiInstruction declares a new AssertStakeAccountMulti instruction with the provided parameters and accounts. @@ -151,3 +147,12 @@ func NewAssertStakeAccountMultiInstruction( SetAssertions(assertions). SetTargetAccountAccount(targetAccount) } + +func (inst AssertStakeAccountMulti) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertStakeAccountMulti) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertSysvarClock.go b/generated/lighthouse/AssertSysvarClock.go index d048df0..d0b4ef6 100644 --- a/generated/lighthouse/AssertSysvarClock.go +++ b/generated/lighthouse/AssertSysvarClock.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -39,7 +39,7 @@ func (inst *AssertSysvarClock) SetAssertion(assertion SysvarClockAssertion) *Ass } func (inst AssertSysvarClock) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertSysvarClock, }} @@ -92,31 +92,27 @@ func (inst *AssertSysvarClock) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj AssertSysvarClock) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertSysvarClock) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertion` param: - err = encoder.Encode(obj.Assertion) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertion == nil { + return errors.New("Assertion parameter is not set") } - return nil -} -func (obj *AssertSysvarClock) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertion).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertion`: - err = decoder.Decode(&obj.Assertion) - if err != nil { + return encoder.Err() +} +func (obj *AssertSysvarClock) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertion = new(SysvarClockAssertion) + if err := (*obj.Assertion).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertSysvarClockInstruction declares a new AssertSysvarClock instruction with the provided parameters and accounts. @@ -128,3 +124,12 @@ func NewAssertSysvarClockInstruction( SetLogLevel(logLevel). SetAssertion(assertion) } + +func (inst AssertSysvarClock) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertSysvarClock) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertTokenAccount.go b/generated/lighthouse/AssertTokenAccount.go index 9cc0d84..edbc242 100644 --- a/generated/lighthouse/AssertTokenAccount.go +++ b/generated/lighthouse/AssertTokenAccount.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -43,7 +43,7 @@ func (inst *AssertTokenAccount) SetAssertion(assertion TokenAccountAssertion) *A // SetTargetAccountAccount sets the "targetAccount" account. // Target account to be asserted func (inst *AssertTokenAccount) SetTargetAccountAccount(targetAccount ag_solanago.PublicKey) *AssertTokenAccount { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetAccount) + inst.AccountMetaSlice[0] = targetAccount.Meta() return inst } @@ -54,7 +54,7 @@ func (inst *AssertTokenAccount) GetTargetAccountAccount() *ag_solanago.AccountMe } func (inst AssertTokenAccount) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertTokenAccount, }} @@ -112,31 +112,27 @@ func (inst *AssertTokenAccount) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj AssertTokenAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertTokenAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertion` param: - err = obj.Assertion.MarshalWithEncoder(encoder) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertion == nil { + return errors.New("Assertion parameter is not set") } - return nil -} -func (obj *AssertTokenAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertion).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertion`: - err = obj.Assertion.UnmarshalWithDecoder(decoder) - if err != nil { + return encoder.Err() +} +func (obj *AssertTokenAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertion = new(TokenAccountAssertion) + if err := (*obj.Assertion).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertTokenAccountInstruction declares a new AssertTokenAccount instruction with the provided parameters and accounts. @@ -151,3 +147,12 @@ func NewAssertTokenAccountInstruction( SetAssertion(assertion). SetTargetAccountAccount(targetAccount) } + +func (inst AssertTokenAccount) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertTokenAccount) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertTokenAccountMulti.go b/generated/lighthouse/AssertTokenAccountMulti.go index 9ad40ae..e8f9543 100644 --- a/generated/lighthouse/AssertTokenAccountMulti.go +++ b/generated/lighthouse/AssertTokenAccountMulti.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -43,7 +43,7 @@ func (inst *AssertTokenAccountMulti) SetAssertions(assertions TokenAccountAssert // SetTargetAccountAccount sets the "targetAccount" account. // Target account to be asserted func (inst *AssertTokenAccountMulti) SetTargetAccountAccount(targetAccount ag_solanago.PublicKey) *AssertTokenAccountMulti { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetAccount) + inst.AccountMetaSlice[0] = targetAccount.Meta() return inst } @@ -54,7 +54,7 @@ func (inst *AssertTokenAccountMulti) GetTargetAccountAccount() *ag_solanago.Acco } func (inst AssertTokenAccountMulti) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertTokenAccountMulti, }} @@ -112,54 +112,23 @@ func (inst *AssertTokenAccountMulti) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj AssertTokenAccountMulti) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - err = encoder.WriteUint8(uint8(*obj.LogLevel)) - if err != nil { - return err +func (obj AssertTokenAccountMulti) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - - err = encoder.WriteUint8(uint8(len(obj.Assertions))) - if err != nil { + encoder.WriteUint8(uint8((*obj.LogLevel))) + if err := obj.Assertions.MarshalWithEncoder(encoder); err != nil { return err } - - // Serialize `Assertions` param: - for _, at := range obj.Assertions { - err := at.MarshalWithEncoder(encoder) - if err != nil { - return err - } - } - - return nil + return encoder.Err() } -func (obj AssertTokenAccountMulti) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - { - _, _ = decoder.ReadUint8() - } - - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { - return err - } - - assertCount, err := decoder.ReadUint8() - if err != nil { +func (obj *AssertTokenAccountMulti) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + if err := obj.Assertions.UnmarshalWithDecoder(decoder); err != nil { return err } - - // Deserialize `Assertions`: - for i := uint8(0); i < assertCount; i++ { - var assert TokenAccountAssertion - - if err := assert.UnmarshalWithDecoder(decoder); err != nil { - return err - } - obj.Assertions = append(obj.Assertions, &assert) - } - - return nil + return decoder.Err() } // NewAssertTokenAccountMultiInstruction declares a new AssertTokenAccountMulti instruction with the provided parameters and accounts. @@ -174,3 +143,12 @@ func NewAssertTokenAccountMultiInstruction( SetAssertions(assertions). SetTargetAccountAccount(targetAccount) } + +func (inst AssertTokenAccountMulti) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertTokenAccountMulti) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertTokenAccountMulti_test.go b/generated/lighthouse/AssertTokenAccountMulti_test.go index 2a528ab..4f09c7a 100644 --- a/generated/lighthouse/AssertTokenAccountMulti_test.go +++ b/generated/lighthouse/AssertTokenAccountMulti_test.go @@ -4,14 +4,13 @@ package lighthouse import ( "bytes" - ag_gofuzz "github.com/gagliardetto/gofuzz" ag_require "github.com/stretchr/testify/require" "strconv" "testing" ) func TestEncodeDecode_AssertTokenAccountMulti(t *testing.T) { - fu := ag_gofuzz.New().NilChance(0) + fu := assertionFuzzer() for i := 0; i < 1; i++ { t.Run("AssertTokenAccountMulti"+strconv.Itoa(i), func(t *testing.T) { { diff --git a/generated/lighthouse/AssertTokenAccount_test.go b/generated/lighthouse/AssertTokenAccount_test.go index d35cb87..2cf5eef 100644 --- a/generated/lighthouse/AssertTokenAccount_test.go +++ b/generated/lighthouse/AssertTokenAccount_test.go @@ -4,14 +4,13 @@ package lighthouse import ( "bytes" - ag_gofuzz "github.com/gagliardetto/gofuzz" ag_require "github.com/stretchr/testify/require" "strconv" "testing" ) func TestEncodeDecode_AssertTokenAccount(t *testing.T) { - fu := ag_gofuzz.New().NilChance(0) + fu := assertionFuzzer() for i := 0; i < 1; i++ { t.Run("AssertTokenAccount"+strconv.Itoa(i), func(t *testing.T) { { diff --git a/generated/lighthouse/AssertUpgradeableLoaderAccount.go b/generated/lighthouse/AssertUpgradeableLoaderAccount.go index b5a9dcb..4db3b03 100644 --- a/generated/lighthouse/AssertUpgradeableLoaderAccount.go +++ b/generated/lighthouse/AssertUpgradeableLoaderAccount.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -43,7 +43,7 @@ func (inst *AssertUpgradeableLoaderAccount) SetAssertion(assertion UpgradeableLo // SetTargetAccountAccount sets the "targetAccount" account. // Target account to be asserted func (inst *AssertUpgradeableLoaderAccount) SetTargetAccountAccount(targetAccount ag_solanago.PublicKey) *AssertUpgradeableLoaderAccount { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetAccount) + inst.AccountMetaSlice[0] = targetAccount.Meta() return inst } @@ -54,7 +54,7 @@ func (inst *AssertUpgradeableLoaderAccount) GetTargetAccountAccount() *ag_solana } func (inst AssertUpgradeableLoaderAccount) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertUpgradeableLoaderAccount, }} @@ -112,31 +112,27 @@ func (inst *AssertUpgradeableLoaderAccount) EncodeToTree(parent ag_treeout.Branc }) } -func (obj AssertUpgradeableLoaderAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertUpgradeableLoaderAccount) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertion` param: - err = encoder.Encode(obj.Assertion) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertion == nil { + return errors.New("Assertion parameter is not set") } - return nil -} -func (obj *AssertUpgradeableLoaderAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertion).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertion`: - err = decoder.Decode(&obj.Assertion) - if err != nil { + return encoder.Err() +} +func (obj *AssertUpgradeableLoaderAccount) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertion = new(UpgradeableLoaderStateAssertion) + if err := (*obj.Assertion).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertUpgradeableLoaderAccountInstruction declares a new AssertUpgradeableLoaderAccount instruction with the provided parameters and accounts. @@ -151,3 +147,12 @@ func NewAssertUpgradeableLoaderAccountInstruction( SetAssertion(assertion). SetTargetAccountAccount(targetAccount) } + +func (inst AssertUpgradeableLoaderAccount) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertUpgradeableLoaderAccount) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/AssertUpgradeableLoaderAccountMulti.go b/generated/lighthouse/AssertUpgradeableLoaderAccountMulti.go index c3ddc4d..5e4178b 100644 --- a/generated/lighthouse/AssertUpgradeableLoaderAccountMulti.go +++ b/generated/lighthouse/AssertUpgradeableLoaderAccountMulti.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -43,7 +43,7 @@ func (inst *AssertUpgradeableLoaderAccountMulti) SetAssertions(assertions Upgrad // SetTargetAccountAccount sets the "targetAccount" account. // Target account to be asserted func (inst *AssertUpgradeableLoaderAccountMulti) SetTargetAccountAccount(targetAccount ag_solanago.PublicKey) *AssertUpgradeableLoaderAccountMulti { - inst.AccountMetaSlice[0] = ag_solanago.Meta(targetAccount) + inst.AccountMetaSlice[0] = targetAccount.Meta() return inst } @@ -54,7 +54,7 @@ func (inst *AssertUpgradeableLoaderAccountMulti) GetTargetAccountAccount() *ag_s } func (inst AssertUpgradeableLoaderAccountMulti) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_AssertUpgradeableLoaderAccountMulti, }} @@ -112,31 +112,27 @@ func (inst *AssertUpgradeableLoaderAccountMulti) EncodeToTree(parent ag_treeout. }) } -func (obj AssertUpgradeableLoaderAccountMulti) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `LogLevel` param: - err = encoder.Encode(obj.LogLevel) - if err != nil { - return err +func (obj AssertUpgradeableLoaderAccountMulti) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.LogLevel == nil { + return errors.New("LogLevel parameter is not set") } - // Serialize `Assertions` param: - err = encoder.Encode(obj.Assertions) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.LogLevel))) + if obj.Assertions == nil { + return errors.New("Assertions parameter is not set") } - return nil -} -func (obj *AssertUpgradeableLoaderAccountMulti) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `LogLevel`: - err = decoder.Decode(&obj.LogLevel) - if err != nil { + if err := (*obj.Assertions).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `Assertions`: - err = decoder.Decode(&obj.Assertions) - if err != nil { + return encoder.Err() +} +func (obj *AssertUpgradeableLoaderAccountMulti) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.LogLevel = new(LogLevel) + (*obj.LogLevel) = LogLevel(decoder.ReadUint8()) + obj.Assertions = new(UpgradeableLoaderStateAssertions) + if err := (*obj.Assertions).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewAssertUpgradeableLoaderAccountMultiInstruction declares a new AssertUpgradeableLoaderAccountMulti instruction with the provided parameters and accounts. @@ -151,3 +147,12 @@ func NewAssertUpgradeableLoaderAccountMultiInstruction( SetAssertions(assertions). SetTargetAccountAccount(targetAccount) } + +func (inst AssertUpgradeableLoaderAccountMulti) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *AssertUpgradeableLoaderAccountMulti) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/MemoryClose.go b/generated/lighthouse/MemoryClose.go index e5cb3ec..316e575 100644 --- a/generated/lighthouse/MemoryClose.go +++ b/generated/lighthouse/MemoryClose.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -49,7 +49,7 @@ func (inst *MemoryClose) SetMemoryBump(memoryBump uint8) *MemoryClose { // SetProgramIdAccount sets the "programId" account. // Lighthouse program func (inst *MemoryClose) SetProgramIdAccount(programId ag_solanago.PublicKey) *MemoryClose { - inst.AccountMetaSlice[0] = ag_solanago.Meta(programId) + inst.AccountMetaSlice[0] = programId.Meta() return inst } @@ -62,7 +62,7 @@ func (inst *MemoryClose) GetProgramIdAccount() *ag_solanago.AccountMeta { // SetPayerAccount sets the "payer" account. // Payer account func (inst *MemoryClose) SetPayerAccount(payer ag_solanago.PublicKey) *MemoryClose { - inst.AccountMetaSlice[1] = ag_solanago.Meta(payer).WRITE().SIGNER() + inst.AccountMetaSlice[1] = payer.Meta().WRITE().SIGNER() return inst } @@ -75,7 +75,7 @@ func (inst *MemoryClose) GetPayerAccount() *ag_solanago.AccountMeta { // SetMemoryAccount sets the "memory" account. // Memory account func (inst *MemoryClose) SetMemoryAccount(memory ag_solanago.PublicKey) *MemoryClose { - inst.AccountMetaSlice[2] = ag_solanago.Meta(memory).WRITE() + inst.AccountMetaSlice[2] = memory.Meta().WRITE() return inst } @@ -86,7 +86,7 @@ func (inst *MemoryClose) GetMemoryAccount() *ag_solanago.AccountMeta { } func (inst MemoryClose) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_MemoryClose, }} @@ -152,31 +152,23 @@ func (inst *MemoryClose) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj MemoryClose) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `MemoryId` param: - err = encoder.Encode(obj.MemoryId) - if err != nil { - return err +func (obj MemoryClose) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.MemoryId == nil { + return errors.New("MemoryId parameter is not set") } - // Serialize `MemoryBump` param: - err = encoder.Encode(obj.MemoryBump) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.MemoryId))) + if obj.MemoryBump == nil { + return errors.New("MemoryBump parameter is not set") } - return nil + encoder.WriteUint8(uint8((*obj.MemoryBump))) + return encoder.Err() } -func (obj *MemoryClose) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `MemoryId`: - err = decoder.Decode(&obj.MemoryId) - if err != nil { - return err - } - // Deserialize `MemoryBump`: - err = decoder.Decode(&obj.MemoryBump) - if err != nil { - return err - } - return nil +func (obj *MemoryClose) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.MemoryId = new(uint8) + (*obj.MemoryId) = uint8(decoder.ReadUint8()) + obj.MemoryBump = new(uint8) + (*obj.MemoryBump) = uint8(decoder.ReadUint8()) + return decoder.Err() } // NewMemoryCloseInstruction declares a new MemoryClose instruction with the provided parameters and accounts. @@ -195,3 +187,12 @@ func NewMemoryCloseInstruction( SetPayerAccount(payer). SetMemoryAccount(memory) } + +func (inst MemoryClose) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *MemoryClose) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/MemoryWrite.go b/generated/lighthouse/MemoryWrite.go index 76379b7..a03cffd 100644 --- a/generated/lighthouse/MemoryWrite.go +++ b/generated/lighthouse/MemoryWrite.go @@ -4,9 +4,9 @@ package lighthouse import ( "errors" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_format "github.com/gagliardetto/solana-go/text/format" + ag_format "github.com/alphabatem/lighthouse_go/internal/format" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -69,7 +69,7 @@ func (inst *MemoryWrite) SetWriteType(writeType WriteType) *MemoryWrite { // SetProgramIdAccount sets the "programId" account. // Lighthouse program func (inst *MemoryWrite) SetProgramIdAccount(programId ag_solanago.PublicKey) *MemoryWrite { - inst.AccountMetaSlice[0] = ag_solanago.Meta(programId) + inst.AccountMetaSlice[0] = programId.Meta() return inst } @@ -82,7 +82,7 @@ func (inst *MemoryWrite) GetProgramIdAccount() *ag_solanago.AccountMeta { // SetSystemProgramAccount sets the "systemProgram" account. // System program func (inst *MemoryWrite) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *MemoryWrite { - inst.AccountMetaSlice[1] = ag_solanago.Meta(systemProgram) + inst.AccountMetaSlice[1] = systemProgram.Meta() return inst } @@ -95,7 +95,7 @@ func (inst *MemoryWrite) GetSystemProgramAccount() *ag_solanago.AccountMeta { // SetPayerAccount sets the "payer" account. // Payer account func (inst *MemoryWrite) SetPayerAccount(payer ag_solanago.PublicKey) *MemoryWrite { - inst.AccountMetaSlice[2] = ag_solanago.Meta(payer).WRITE().SIGNER() + inst.AccountMetaSlice[2] = payer.Meta().WRITE().SIGNER() return inst } @@ -108,7 +108,7 @@ func (inst *MemoryWrite) GetPayerAccount() *ag_solanago.AccountMeta { // SetMemoryAccount sets the "memory" account. // Memory account func (inst *MemoryWrite) SetMemoryAccount(memory ag_solanago.PublicKey) *MemoryWrite { - inst.AccountMetaSlice[3] = ag_solanago.Meta(memory).WRITE() + inst.AccountMetaSlice[3] = memory.Meta().WRITE() return inst } @@ -121,7 +121,7 @@ func (inst *MemoryWrite) GetMemoryAccount() *ag_solanago.AccountMeta { // SetSourceAccountAccount sets the "sourceAccount" account. // Account to be written to memory func (inst *MemoryWrite) SetSourceAccountAccount(sourceAccount ag_solanago.PublicKey) *MemoryWrite { - inst.AccountMetaSlice[4] = ag_solanago.Meta(sourceAccount) + inst.AccountMetaSlice[4] = sourceAccount.Meta() return inst } @@ -132,7 +132,7 @@ func (inst *MemoryWrite) GetSourceAccountAccount() *ag_solanago.AccountMeta { } func (inst MemoryWrite) Build() *Instruction { - return &Instruction{BaseVariant: ag_binary.BaseVariant{ + return &Instruction{BaseVariant: BaseVariant{ Impl: inst, TypeID: Instruction_MemoryWrite, }} @@ -214,51 +214,39 @@ func (inst *MemoryWrite) EncodeToTree(parent ag_treeout.Branches) { }) } -func (obj MemoryWrite) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `MemoryId` param: - err = encoder.Encode(obj.MemoryId) - if err != nil { - return err +func (obj MemoryWrite) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if obj.MemoryId == nil { + return errors.New("MemoryId parameter is not set") } - // Serialize `MemoryBump` param: - err = encoder.Encode(obj.MemoryBump) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.MemoryId))) + if obj.MemoryBump == nil { + return errors.New("MemoryBump parameter is not set") } - // Serialize `WriteOffset` param: - err = encoder.Encode(obj.WriteOffset) - if err != nil { - return err + encoder.WriteUint8(uint8((*obj.MemoryBump))) + if obj.WriteOffset == nil { + return errors.New("WriteOffset parameter is not set") } - // Serialize `WriteType` param: - err = encoder.Encode(obj.WriteType) - if err != nil { - return err + encoder.WriteUint64(uint64((*obj.WriteOffset))) + if obj.WriteType == nil { + return errors.New("WriteType parameter is not set") } - return nil -} -func (obj *MemoryWrite) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `MemoryId`: - err = decoder.Decode(&obj.MemoryId) - if err != nil { - return err - } - // Deserialize `MemoryBump`: - err = decoder.Decode(&obj.MemoryBump) - if err != nil { + if err := (*obj.WriteType).MarshalWithEncoder(encoder); err != nil { return err } - // Deserialize `WriteOffset`: - err = decoder.Decode(&obj.WriteOffset) - if err != nil { - return err - } - // Deserialize `WriteType`: - err = decoder.Decode(&obj.WriteType) - if err != nil { + return encoder.Err() +} +func (obj *MemoryWrite) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.MemoryId = new(uint8) + (*obj.MemoryId) = uint8(decoder.ReadUint8()) + obj.MemoryBump = new(uint8) + (*obj.MemoryBump) = uint8(decoder.ReadUint8()) + obj.WriteOffset = new(CompactU64) + (*obj.WriteOffset) = CompactU64(decoder.ReadUint64()) + obj.WriteType = new(WriteType) + if err := (*obj.WriteType).UnmarshalWithDecoder(decoder); err != nil { return err } - return nil + return decoder.Err() } // NewMemoryWriteInstruction declares a new MemoryWrite instruction with the provided parameters and accounts. @@ -285,3 +273,12 @@ func NewMemoryWriteInstruction( SetMemoryAccount(memory). SetSourceAccountAccount(sourceAccount) } + +func (inst MemoryWrite) GetAccounts() []*ag_solanago.AccountMeta { + return inst.AccountMetaSlice +} + +func (inst *MemoryWrite) SetAccounts(accounts []*ag_solanago.AccountMeta) error { + inst.AccountMetaSlice = accounts + return nil +} diff --git a/generated/lighthouse/binary_helpers.go b/generated/lighthouse/binary_helpers.go new file mode 100644 index 0000000..ae6052f --- /dev/null +++ b/generated/lighthouse/binary_helpers.go @@ -0,0 +1,22 @@ +package lighthouse + +import ( + "fmt" + + "github.com/fluxrpc/solana-go/binary" +) + +// These helpers retain the Borsh byte-vector layout used by the bindings. +func writeByteSlice(encoder *binary.Encoder, data []byte) error { + if uint64(len(data)) > uint64(^uint32(0)) { + return fmt.Errorf("byte vector is too large: %d", len(data)) + } + encoder.WriteUint32(uint32(len(data))) + encoder.WriteBytes(data) + return encoder.Err() +} + +func readByteSlice(decoder *binary.Decoder) []byte { + n := decoder.ReadUint32() + return decoder.ReadBytesCopy(int(n)) +} diff --git a/generated/lighthouse/instructions.go b/generated/lighthouse/instructions.go index bab4785..0b3cef1 100644 --- a/generated/lighthouse/instructions.go +++ b/generated/lighthouse/instructions.go @@ -3,12 +3,10 @@ package lighthouse import ( - "bytes" "fmt" ag_spew "github.com/davecgh/go-spew/spew" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" - ag_text "github.com/gagliardetto/solana-go/text" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ag_treeout "github.com/gagliardetto/treeout" ) @@ -16,57 +14,50 @@ var ProgramID ag_solanago.PublicKey = ag_solanago.MustPublicKeyFromBase58("L2TEx func SetProgramID(pubkey ag_solanago.PublicKey) { ProgramID = pubkey - ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) } const ProgramName = "Lighthouse" -func init() { - if !ProgramID.IsZero() { - ag_solanago.RegisterInstructionDecoder(ProgramID, registryDecodeInstruction) - } -} - var ( - Instruction_MemoryWrite = ag_binary.TypeID(ag_binary.TypeIDFromUint8(0)) + Instruction_MemoryWrite = uint8(0) - Instruction_MemoryClose = ag_binary.TypeID(ag_binary.TypeIDFromUint8(1)) + Instruction_MemoryClose = uint8(1) - Instruction_AssertAccountData = ag_binary.TypeID(ag_binary.TypeIDFromUint8(2)) + Instruction_AssertAccountData = uint8(2) - Instruction_AssertAccountDataMulti = ag_binary.TypeID(ag_binary.TypeIDFromUint8(3)) + Instruction_AssertAccountDataMulti = uint8(3) - Instruction_AssertAccountDelta = ag_binary.TypeID(ag_binary.TypeIDFromUint8(4)) + Instruction_AssertAccountDelta = uint8(4) - Instruction_AssertAccountInfo = ag_binary.TypeID(ag_binary.TypeIDFromUint8(5)) + Instruction_AssertAccountInfo = uint8(5) - Instruction_AssertAccountInfoMulti = ag_binary.TypeID(ag_binary.TypeIDFromUint8(6)) + Instruction_AssertAccountInfoMulti = uint8(6) - Instruction_AssertMintAccount = ag_binary.TypeID(ag_binary.TypeIDFromUint8(7)) + Instruction_AssertMintAccount = uint8(7) - Instruction_AssertMintAccountMulti = ag_binary.TypeID(ag_binary.TypeIDFromUint8(8)) + Instruction_AssertMintAccountMulti = uint8(8) - Instruction_AssertTokenAccount = ag_binary.TypeID(ag_binary.TypeIDFromUint8(9)) + Instruction_AssertTokenAccount = uint8(9) - Instruction_AssertTokenAccountMulti = ag_binary.TypeID(ag_binary.TypeIDFromUint8(10)) + Instruction_AssertTokenAccountMulti = uint8(10) - Instruction_AssertStakeAccount = ag_binary.TypeID(ag_binary.TypeIDFromUint8(11)) + Instruction_AssertStakeAccount = uint8(11) - Instruction_AssertStakeAccountMulti = ag_binary.TypeID(ag_binary.TypeIDFromUint8(12)) + Instruction_AssertStakeAccountMulti = uint8(12) - Instruction_AssertUpgradeableLoaderAccount = ag_binary.TypeID(ag_binary.TypeIDFromUint8(13)) + Instruction_AssertUpgradeableLoaderAccount = uint8(13) - Instruction_AssertUpgradeableLoaderAccountMulti = ag_binary.TypeID(ag_binary.TypeIDFromUint8(14)) + Instruction_AssertUpgradeableLoaderAccountMulti = uint8(14) - Instruction_AssertSysvarClock = ag_binary.TypeID(ag_binary.TypeIDFromUint8(15)) + Instruction_AssertSysvarClock = uint8(15) - Instruction_AssertMerkleTreeAccount = ag_binary.TypeID(ag_binary.TypeIDFromUint8(16)) + Instruction_AssertMerkleTreeAccount = uint8(16) - Instruction_AssertBubblegumTreeConfigAccount = ag_binary.TypeID(ag_binary.TypeIDFromUint8(17)) + Instruction_AssertBubblegumTreeConfigAccount = uint8(17) ) // InstructionIDToName returns the name of the instruction given its ID. -func InstructionIDToName(id ag_binary.TypeID) string { +func InstructionIDToName(id uint8) string { switch id { case Instruction_MemoryWrite: return "MemoryWrite" @@ -109,124 +100,117 @@ func InstructionIDToName(id ag_binary.TypeID) string { } } +// BaseVariant holds the one-byte Lighthouse discriminator and its payload. +type BaseVariant struct { + TypeID uint8 + Impl interface{} +} + type Instruction struct { - ag_binary.BaseVariant + BaseVariant } func (inst *Instruction) EncodeToTree(parent ag_treeout.Branches) { - if enToTree, ok := inst.Impl.(ag_text.EncodableToTree); ok { + if enToTree, ok := inst.Impl.(interface{ EncodeToTree(ag_treeout.Branches) }); ok { enToTree.EncodeToTree(parent) } else { parent.Child(ag_spew.Sdump(inst)) } } -var InstructionImplDef = ag_binary.NewVariantDefinition( - ag_binary.AnchorTypeIDEncoding, - []ag_binary.VariantType{ - { - "memory_write", (*MemoryWrite)(nil), - }, - { - "memory_close", (*MemoryClose)(nil), - }, - { - "assert_account_data", (*AssertAccountData)(nil), - }, - { - "assert_account_data_multi", (*AssertAccountDataMulti)(nil), - }, - { - "assert_account_delta", (*AssertAccountDelta)(nil), - }, - { - "assert_account_info", (*AssertAccountInfo)(nil), - }, - { - "assert_account_info_multi", (*AssertAccountInfoMulti)(nil), - }, - { - "assert_mint_account", (*AssertMintAccount)(nil), - }, - { - "assert_mint_account_multi", (*AssertMintAccountMulti)(nil), - }, - { - "assert_token_account", (*AssertTokenAccount)(nil), - }, - { - "assert_token_account_multi", (*AssertTokenAccountMulti)(nil), - }, - { - "assert_stake_account", (*AssertStakeAccount)(nil), - }, - { - "assert_stake_account_multi", (*AssertStakeAccountMulti)(nil), - }, - { - "assert_upgradeable_loader_account", (*AssertUpgradeableLoaderAccount)(nil), - }, - { - "assert_upgradeable_loader_account_multi", (*AssertUpgradeableLoaderAccountMulti)(nil), - }, - { - "assert_sysvar_clock", (*AssertSysvarClock)(nil), - }, - { - "assert_merkle_tree_account", (*AssertMerkleTreeAccount)(nil), - }, - { - "assert_bubblegum_tree_config_account", (*AssertBubblegumTreeConfigAccount)(nil), - }, - }, -) - func (inst *Instruction) ProgramID() ag_solanago.PublicKey { return ProgramID } func (inst *Instruction) Accounts() (out []*ag_solanago.AccountMeta) { - return inst.Impl.(ag_solanago.AccountsGettable).GetAccounts() + return inst.Impl.(interface { + GetAccounts() []*ag_solanago.AccountMeta + }).GetAccounts() } func (inst *Instruction) Data() ([]byte, error) { - buf := new(bytes.Buffer) - if err := ag_binary.NewBorshEncoder(buf).Encode(inst); err != nil { - return nil, fmt.Errorf("unable to encode instruction: %w", err) + encoder := ag_binary.NewEncoder(nil) + if err := inst.MarshalWithEncoder(encoder); err != nil { + return nil, err } - return buf.Bytes(), nil -} - -func (inst *Instruction) TextEncode(encoder *ag_text.Encoder, option *ag_text.Option) error { - return encoder.Encode(inst.Impl, option) + return encoder.Bytes(), encoder.Err() } func (inst *Instruction) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { - return inst.BaseVariant.UnmarshalBinaryVariant(decoder, InstructionImplDef) -} - -func (inst *Instruction) MarshalWithEncoder(encoder *ag_binary.Encoder) error { - err := encoder.WriteUint8(inst.TypeID.Uint8()) - if err != nil { - return fmt.Errorf("unable to write variant type: %w", err) + inst.Impl = nil + inst.TypeID = decoder.ReadUint8() + if err := decoder.Err(); err != nil { + return err + } + var value interface { + UnmarshalWithDecoder(*ag_binary.Decoder) error + } + switch inst.TypeID { + case Instruction_MemoryWrite: + value = new(MemoryWrite) + case Instruction_MemoryClose: + value = new(MemoryClose) + case Instruction_AssertAccountData: + value = new(AssertAccountData) + case Instruction_AssertAccountDataMulti: + value = new(AssertAccountDataMulti) + case Instruction_AssertAccountDelta: + value = new(AssertAccountDelta) + case Instruction_AssertAccountInfo: + value = new(AssertAccountInfo) + case Instruction_AssertAccountInfoMulti: + value = new(AssertAccountInfoMulti) + case Instruction_AssertMintAccount: + value = new(AssertMintAccount) + case Instruction_AssertMintAccountMulti: + value = new(AssertMintAccountMulti) + case Instruction_AssertTokenAccount: + value = new(AssertTokenAccount) + case Instruction_AssertTokenAccountMulti: + value = new(AssertTokenAccountMulti) + case Instruction_AssertStakeAccount: + value = new(AssertStakeAccount) + case Instruction_AssertStakeAccountMulti: + value = new(AssertStakeAccountMulti) + case Instruction_AssertUpgradeableLoaderAccount: + value = new(AssertUpgradeableLoaderAccount) + case Instruction_AssertUpgradeableLoaderAccountMulti: + value = new(AssertUpgradeableLoaderAccountMulti) + case Instruction_AssertSysvarClock: + value = new(AssertSysvarClock) + case Instruction_AssertMerkleTreeAccount: + value = new(AssertMerkleTreeAccount) + case Instruction_AssertBubblegumTreeConfigAccount: + value = new(AssertBubblegumTreeConfigAccount) + default: + return fmt.Errorf("unknown instruction ID %d", inst.TypeID) } - return encoder.Encode(inst.Impl) + if err := value.UnmarshalWithDecoder(decoder); err != nil { + return err + } + inst.Impl = value + return decoder.Err() } -func registryDecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (interface{}, error) { - inst, err := DecodeInstruction(accounts, data) - if err != nil { - return nil, err +func (inst *Instruction) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + value, ok := inst.Impl.(interface { + MarshalWithEncoder(*ag_binary.Encoder) error + }) + if !ok { + return fmt.Errorf("instruction %d has no encoder", inst.TypeID) } - return inst, nil + encoder.WriteUint8(inst.TypeID) + return value.MarshalWithEncoder(encoder) } func DecodeInstruction(accounts []*ag_solanago.AccountMeta, data []byte) (*Instruction, error) { inst := new(Instruction) - if err := ag_binary.NewBorshDecoder(data).Decode(inst); err != nil { + if err := inst.UnmarshalWithDecoder(ag_binary.NewDecoder(data)); err != nil { return nil, fmt.Errorf("unable to decode instruction: %w", err) } - if v, ok := inst.Impl.(ag_solanago.AccountsSettable); ok { + if v, ok := inst.Impl.(interface { + SetAccounts([]*ag_solanago.AccountMeta) error + }); ok { err := v.SetAccounts(accounts) if err != nil { return nil, fmt.Errorf("unable to set accounts for instruction: %w", err) diff --git a/generated/lighthouse/testing_utils.go b/generated/lighthouse/testing_utils.go index a2e19f7..0501e24 100644 --- a/generated/lighthouse/testing_utils.go +++ b/generated/lighthouse/testing_utils.go @@ -5,16 +5,33 @@ package lighthouse import ( "bytes" "fmt" - ag_binary "github.com/gagliardetto/binary" + ag_binary "github.com/fluxrpc/solana-go/binary" ) func encodeT(data interface{}, buf *bytes.Buffer) error { - if err := ag_binary.NewBorshEncoder(buf).Encode(data); err != nil { + encoder := ag_binary.NewEncoder(nil) + value, ok := data.(interface { + MarshalWithEncoder(*ag_binary.Encoder) error + }) + if !ok { + return fmt.Errorf("%T has no encoder", data) + } + if err := value.MarshalWithEncoder(encoder); err != nil { return fmt.Errorf("unable to encode instruction: %w", err) } - return nil + if err := encoder.Err(); err != nil { + return err + } + _, err := buf.Write(encoder.Bytes()) + return err } func decodeT(dst interface{}, data []byte) error { - return ag_binary.NewBorshDecoder(data).Decode(dst) + value, ok := dst.(interface { + UnmarshalWithDecoder(*ag_binary.Decoder) error + }) + if !ok { + return fmt.Errorf("%T has no decoder", dst) + } + return value.UnmarshalWithDecoder(ag_binary.NewDecoder(data)) } diff --git a/generated/lighthouse/types.go b/generated/lighthouse/types.go index 51f272a..c2a20ce 100644 --- a/generated/lighthouse/types.go +++ b/generated/lighthouse/types.go @@ -3,11 +3,9 @@ package lighthouse import ( - "encoding/binary" - "errors" "fmt" - ag_binary "github.com/gagliardetto/binary" - ag_solanago "github.com/gagliardetto/solana-go" + ag_solanago "github.com/fluxrpc/solana-go" + ag_binary "github.com/fluxrpc/solana-go/binary" ) type TestAccountV1 struct { @@ -32,321 +30,11 @@ type TestAccountV1 struct { Vec []byte } -func (obj TestAccountV1) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `U8` param: - err = encoder.Encode(obj.U8) - if err != nil { - return err - } - // Serialize `I8` param: - err = encoder.Encode(obj.I8) - if err != nil { - return err - } - // Serialize `U16` param: - err = encoder.Encode(obj.U16) - if err != nil { - return err - } - // Serialize `I16` param: - err = encoder.Encode(obj.I16) - if err != nil { - return err - } - // Serialize `U32` param: - err = encoder.Encode(obj.U32) - if err != nil { - return err - } - // Serialize `I32` param: - err = encoder.Encode(obj.I32) - if err != nil { - return err - } - // Serialize `U64` param: - err = encoder.Encode(obj.U64) - if err != nil { - return err - } - // Serialize `I64` param: - err = encoder.Encode(obj.I64) - if err != nil { - return err - } - // Serialize `U128` param: - err = encoder.Encode(obj.U128) - if err != nil { - return err - } - // Serialize `I128` param: - err = encoder.Encode(obj.I128) - if err != nil { - return err - } - // Serialize `Bytes` param: - err = encoder.Encode(obj.Bytes) - if err != nil { - return err - } - // Serialize `TrueField` param: - err = encoder.Encode(obj.TrueField) - if err != nil { - return err - } - // Serialize `FalseField` param: - err = encoder.Encode(obj.FalseField) - if err != nil { - return err - } - // Serialize `OptionU8` param (optional): - { - if obj.OptionU8 == nil { - err = encoder.WriteBool(false) - if err != nil { - return err - } - } else { - err = encoder.WriteBool(true) - if err != nil { - return err - } - err = encoder.Encode(obj.OptionU8) - if err != nil { - return err - } - } - } - // Serialize `OptionU8None` param (optional): - { - if obj.OptionU8None == nil { - err = encoder.WriteBool(false) - if err != nil { - return err - } - } else { - err = encoder.WriteBool(true) - if err != nil { - return err - } - err = encoder.Encode(obj.OptionU8None) - if err != nil { - return err - } - } - } - // Serialize `OptionU16` param (optional): - { - if obj.OptionU16 == nil { - err = encoder.WriteBool(false) - if err != nil { - return err - } - } else { - err = encoder.WriteBool(true) - if err != nil { - return err - } - err = encoder.Encode(obj.OptionU16) - if err != nil { - return err - } - } - } - // Serialize `OptionU16None` param (optional): - { - if obj.OptionU16None == nil { - err = encoder.WriteBool(false) - if err != nil { - return err - } - } else { - err = encoder.WriteBool(true) - if err != nil { - return err - } - err = encoder.Encode(obj.OptionU16None) - if err != nil { - return err - } - } - } - // Serialize `Pubkey` param: - err = encoder.Encode(obj.Pubkey) - if err != nil { - return err - } - // Serialize `Vec` param: - err = encoder.Encode(obj.Vec) - if err != nil { - return err - } - return nil -} - -func (obj *TestAccountV1) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `U8`: - err = decoder.Decode(&obj.U8) - if err != nil { - return err - } - // Deserialize `I8`: - err = decoder.Decode(&obj.I8) - if err != nil { - return err - } - // Deserialize `U16`: - err = decoder.Decode(&obj.U16) - if err != nil { - return err - } - // Deserialize `I16`: - err = decoder.Decode(&obj.I16) - if err != nil { - return err - } - // Deserialize `U32`: - err = decoder.Decode(&obj.U32) - if err != nil { - return err - } - // Deserialize `I32`: - err = decoder.Decode(&obj.I32) - if err != nil { - return err - } - // Deserialize `U64`: - err = decoder.Decode(&obj.U64) - if err != nil { - return err - } - // Deserialize `I64`: - err = decoder.Decode(&obj.I64) - if err != nil { - return err - } - // Deserialize `U128`: - err = decoder.Decode(&obj.U128) - if err != nil { - return err - } - // Deserialize `I128`: - err = decoder.Decode(&obj.I128) - if err != nil { - return err - } - // Deserialize `Bytes`: - err = decoder.Decode(&obj.Bytes) - if err != nil { - return err - } - // Deserialize `TrueField`: - err = decoder.Decode(&obj.TrueField) - if err != nil { - return err - } - // Deserialize `FalseField`: - err = decoder.Decode(&obj.FalseField) - if err != nil { - return err - } - // Deserialize `OptionU8` (optional): - { - ok, err := decoder.ReadBool() - if err != nil { - return err - } - if ok { - err = decoder.Decode(&obj.OptionU8) - if err != nil { - return err - } - } - } - // Deserialize `OptionU8None` (optional): - { - ok, err := decoder.ReadBool() - if err != nil { - return err - } - if ok { - err = decoder.Decode(&obj.OptionU8None) - if err != nil { - return err - } - } - } - // Deserialize `OptionU16` (optional): - { - ok, err := decoder.ReadBool() - if err != nil { - return err - } - if ok { - err = decoder.Decode(&obj.OptionU16) - if err != nil { - return err - } - } - } - // Deserialize `OptionU16None` (optional): - { - ok, err := decoder.ReadBool() - if err != nil { - return err - } - if ok { - err = decoder.Decode(&obj.OptionU16None) - if err != nil { - return err - } - } - } - // Deserialize `Pubkey`: - err = decoder.Decode(&obj.Pubkey) - if err != nil { - return err - } - // Deserialize `Vec`: - err = decoder.Decode(&obj.Vec) - if err != nil { - return err - } - return nil -} - type AccountDataAssertion struct { Offset CompactU64 Assertion DataValueAssertion } -func (obj AccountDataAssertion) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - // Serialize `Offset` param: - err = encoder.Encode(obj.Offset) - if err != nil { - return err - } - // Serialize `Assertion` param: - err = encoder.Encode(obj.Assertion) - if err != nil { - return err - } - return nil -} - -func (obj *AccountDataAssertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - // Deserialize `Offset`: - err = decoder.Decode(&obj.Offset) - if err != nil { - return err - } - // Deserialize `Assertion`: - err = decoder.Decode(&obj.Assertion) - if err != nil { - return err - } - return nil -} - type DataValueAssertion []byte type AccountDataAssertions []AccountDataAssertion @@ -423,125 +111,6 @@ func (t *TokenAccountAssertion) TypeString() string { return "Unknown" } -func (t TokenAccountAssertion) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - err = encoder.WriteUint8(t.Type()) - if err != nil { - return err - } - - if t.Mint != nil { - _, err = encoder.Write(t.Mint.Bytes()) - if err != nil { - return err - } - } - - if t.Owner != nil { - _, err = encoder.Write(t.Owner.Bytes()) - if err != nil { - return err - } - } - if t.Amount != nil { - err = encoder.WriteUint64(*t.Amount, binary.LittleEndian) - if err != nil { - return err - } - } - if t.Delegate != nil { - _, err = encoder.Write(t.Delegate.Bytes()) - if err != nil { - return err - } - } - if t.State != nil { - _, err = encoder.Write(*t.State) - if err != nil { - return err - } - } - if t.IsNative != nil { - err = encoder.WriteBool(*t.IsNative) - if err != nil { - return err - } - } - if t.DelegatedAmount != nil { - err = encoder.WriteUint64(*t.DelegatedAmount, binary.LittleEndian) - if err != nil { - return err - } - } - if t.CloseAuthority != nil { - _, err = encoder.Write(t.CloseAuthority.Bytes()) - if err != nil { - return err - } - } - - err = encoder.WriteUint8(t.Operator) - if err != nil { - return err - } - - return nil -} - -func (t TokenAccountAssertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - byt, err := decoder.ReadUint8() - if err != nil { - return err - } - - switch byt { - case 0: //Mint - if err := decoder.Decode(&t.Mint); err != nil { - return err - } - case 1: //Owner - if err := decoder.Decode(&t.Owner); err != nil { - return err - } - case 2: //Amount - if err := decoder.Decode(&t.Amount); err != nil { - return err - } - case 3: //Delegate - opk, err := decoder.ReadByte() - if err != nil { - return err - } - - if opk == 1 { - if err := decoder.Decode(&t.Delegate); err != nil { - return err - } - } else { - t.Delegate = &ag_solanago.PublicKey{} - } - case 4: //State - if err := decoder.Decode(&t.State); err != nil { - return err - } - case 5: //IsNative - if err := decoder.Decode(&t.IsNative); err != nil { - return err - } - case 6: //DelegatedAmount - if err := decoder.Decode(&t.DelegatedAmount); err != nil { - return err - } - case 7: //CloseAuthority - if err := decoder.Decode(&t.CloseAuthority); err != nil { - return err - } - default: - return errors.New(fmt.Sprintf("unknown assertation type (%v)", byt)) - } - - return decoder.Decode(&t.Operator) -} - type AccountInfoAssertions []*AccountInfoAssertion // Placeholders for assertions @@ -585,118 +154,550 @@ func (t *AccountInfoAssertion) Type() uint8 { return 99 } -func (t AccountInfoAssertion) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { - err = encoder.WriteUint8(t.Type()) - if err != nil { +type SysvarClockAssertion Assertion +type StakeAccountAssertions Assertion +type AccountDeltaAssertion Assertion +type BubblegumTreeConfigAssertion Assertion +type MerkleTreeAssertion Assertion +type MintAccountAssertion Assertion +type MintAccountAssertions Assertion +type StakeAccountAssertion Assertion +type UpgradeableLoaderStateAssertion Assertion +type UpgradeableLoaderStateAssertions Assertion +type WriteType Assertion + +type Assertion struct { + Typ uint8 + Data []byte +} + +func (obj TestAccountV1) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint8(uint8(obj.U8)) + encoder.WriteUint8(uint8(obj.I8)) + encoder.WriteUint16(uint16(obj.U16)) + encoder.WriteUint16(uint16(obj.I16)) + encoder.WriteUint32(uint32(obj.U32)) + encoder.WriteUint32(uint32(obj.I32)) + encoder.WriteUint64(uint64(obj.U64)) + encoder.WriteInt64(int64(obj.I64)) + if err := obj.U128.MarshalWithEncoder(encoder); err != nil { + return err + } + if err := obj.I128.MarshalWithEncoder(encoder); err != nil { + return err + } + encoder.WriteBytes(obj.Bytes[:]) + encoder.WriteBool(bool(obj.TrueField)) + encoder.WriteBool(bool(obj.FalseField)) + encoder.WriteOption(obj.OptionU8 != nil) + if obj.OptionU8 != nil { + encoder.WriteUint8(uint8((*obj.OptionU8))) + } + encoder.WriteOption(obj.OptionU8None != nil) + if obj.OptionU8None != nil { + encoder.WriteUint8(uint8((*obj.OptionU8None))) + } + encoder.WriteOption(obj.OptionU16 != nil) + if obj.OptionU16 != nil { + encoder.WriteUint16(uint16((*obj.OptionU16))) + } + encoder.WriteOption(obj.OptionU16None != nil) + if obj.OptionU16None != nil { + encoder.WriteUint16(uint16((*obj.OptionU16None))) + } + encoder.WritePublicKey(ag_solanago.PublicKey(obj.Pubkey)) + if err := writeByteSlice(encoder, obj.Vec); err != nil { return err } + return encoder.Err() +} +func (obj *TestAccountV1) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.U8 = uint8(decoder.ReadUint8()) + obj.I8 = int8(decoder.ReadUint8()) + obj.U16 = uint16(decoder.ReadUint16()) + obj.I16 = int16(decoder.ReadUint16()) + obj.U32 = uint32(decoder.ReadUint32()) + obj.I32 = int32(decoder.ReadUint32()) + obj.U64 = uint64(decoder.ReadUint64()) + obj.I64 = int64(decoder.ReadInt64()) + if err := obj.U128.UnmarshalWithDecoder(decoder); err != nil { + return err + } + if err := obj.I128.UnmarshalWithDecoder(decoder); err != nil { + return err + } + copy(obj.Bytes[:], decoder.ReadBytes(32)) + obj.TrueField = bool(decoder.ReadBool()) + obj.FalseField = bool(decoder.ReadBool()) + obj.OptionU8 = nil + if decoder.ReadOption() { + obj.OptionU8 = new(uint8) + (*obj.OptionU8) = uint8(decoder.ReadUint8()) + } + obj.OptionU8None = nil + if decoder.ReadOption() { + obj.OptionU8None = new(uint8) + (*obj.OptionU8None) = uint8(decoder.ReadUint8()) + } + obj.OptionU16 = nil + if decoder.ReadOption() { + obj.OptionU16 = new(uint16) + (*obj.OptionU16) = uint16(decoder.ReadUint16()) + } + obj.OptionU16None = nil + if decoder.ReadOption() { + obj.OptionU16None = new(uint16) + (*obj.OptionU16None) = uint16(decoder.ReadUint16()) + } + obj.Pubkey = ag_solanago.PublicKey(decoder.ReadPublicKey()) + obj.Vec = readByteSlice(decoder) + return decoder.Err() +} - if t.Lamports != nil { - err = encoder.WriteUint64(*t.Lamports, binary.LittleEndian) - if err != nil { - return err - } +func (obj AccountDataAssertion) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint64(uint64(obj.Offset)) + if err := writeByteSlice(encoder, obj.Assertion); err != nil { + return err } - if t.DataLength != nil { - err = encoder.WriteUint64(*t.DataLength, binary.LittleEndian) - if err != nil { - return err - } + return encoder.Err() +} +func (obj *AccountDataAssertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.Offset = CompactU64(decoder.ReadUint64()) + obj.Assertion = readByteSlice(decoder) + return decoder.Err() +} + +func (obj Assertion) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint8(obj.Typ) + if err := writeByteSlice(encoder, obj.Data); err != nil { + return err } - if t.Owner != nil { - _, err = encoder.Write(t.Owner.Bytes()) - if err != nil { - return err - } + return encoder.Err() +} +func (obj *Assertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.Typ = decoder.ReadUint8() + obj.Data = readByteSlice(decoder) + return decoder.Err() +} + +func (obj SysvarClockAssertion) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint8(obj.Typ) + if err := writeByteSlice(encoder, obj.Data); err != nil { + return err } - if t.RentEpoch != nil { - err = encoder.WriteUint64(*t.RentEpoch, binary.LittleEndian) - if err != nil { - return err - } + return encoder.Err() +} +func (obj *SysvarClockAssertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.Typ = decoder.ReadUint8() + obj.Data = readByteSlice(decoder) + return decoder.Err() +} + +func (obj StakeAccountAssertions) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint8(obj.Typ) + if err := writeByteSlice(encoder, obj.Data); err != nil { + return err } - if t.IsSigner != nil { - err = encoder.WriteBool(*t.IsSigner) - if err != nil { - return err - } + return encoder.Err() +} +func (obj *StakeAccountAssertions) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.Typ = decoder.ReadUint8() + obj.Data = readByteSlice(decoder) + return decoder.Err() +} + +func (obj AccountDeltaAssertion) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint8(obj.Typ) + if err := writeByteSlice(encoder, obj.Data); err != nil { + return err } - if t.IsWritable != nil { - err = encoder.WriteBool(*t.IsWritable) - if err != nil { - return err - } + return encoder.Err() +} +func (obj *AccountDeltaAssertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.Typ = decoder.ReadUint8() + obj.Data = readByteSlice(decoder) + return decoder.Err() +} + +func (obj BubblegumTreeConfigAssertion) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint8(obj.Typ) + if err := writeByteSlice(encoder, obj.Data); err != nil { + return err } - if t.Executable != nil { - err = encoder.WriteBool(*t.Executable) - if err != nil { - return err - } + return encoder.Err() +} +func (obj *BubblegumTreeConfigAssertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.Typ = decoder.ReadUint8() + obj.Data = readByteSlice(decoder) + return decoder.Err() +} + +func (obj MerkleTreeAssertion) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint8(obj.Typ) + if err := writeByteSlice(encoder, obj.Data); err != nil { + return err + } + return encoder.Err() +} +func (obj *MerkleTreeAssertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.Typ = decoder.ReadUint8() + obj.Data = readByteSlice(decoder) + return decoder.Err() +} + +func (obj MintAccountAssertion) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint8(obj.Typ) + if err := writeByteSlice(encoder, obj.Data); err != nil { + return err } + return encoder.Err() +} +func (obj *MintAccountAssertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.Typ = decoder.ReadUint8() + obj.Data = readByteSlice(decoder) + return decoder.Err() +} - err = encoder.WriteUint8(t.Operator) - if err != nil { +func (obj MintAccountAssertions) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint8(obj.Typ) + if err := writeByteSlice(encoder, obj.Data); err != nil { return err } - return nil + return encoder.Err() +} +func (obj *MintAccountAssertions) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.Typ = decoder.ReadUint8() + obj.Data = readByteSlice(decoder) + return decoder.Err() +} + +func (obj StakeAccountAssertion) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint8(obj.Typ) + if err := writeByteSlice(encoder, obj.Data); err != nil { + return err + } + return encoder.Err() +} +func (obj *StakeAccountAssertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.Typ = decoder.ReadUint8() + obj.Data = readByteSlice(decoder) + return decoder.Err() } -func (t AccountInfoAssertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { - byt, err := decoder.ReadUint8() - if err != nil { +func (obj UpgradeableLoaderStateAssertion) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint8(obj.Typ) + if err := writeByteSlice(encoder, obj.Data); err != nil { return err } + return encoder.Err() +} +func (obj *UpgradeableLoaderStateAssertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.Typ = decoder.ReadUint8() + obj.Data = readByteSlice(decoder) + return decoder.Err() +} - switch byt { +func (obj UpgradeableLoaderStateAssertions) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint8(obj.Typ) + if err := writeByteSlice(encoder, obj.Data); err != nil { + return err + } + return encoder.Err() +} +func (obj *UpgradeableLoaderStateAssertions) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.Typ = decoder.ReadUint8() + obj.Data = readByteSlice(decoder) + return decoder.Err() +} - case 0: //Lamports - if err := decoder.Decode(t.Lamports); err != nil { - return err +func (obj WriteType) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + encoder.WriteUint8(obj.Typ) + if err := writeByteSlice(encoder, obj.Data); err != nil { + return err + } + return encoder.Err() +} +func (obj *WriteType) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + obj.Typ = decoder.ReadUint8() + obj.Data = readByteSlice(decoder) + return decoder.Err() +} + +func (obj TokenAccountAssertion) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + count := 0 + if obj.Mint != nil { + count++ + } + if obj.Owner != nil { + count++ + } + if obj.Amount != nil { + count++ + } + if obj.Delegate != nil { + count++ + } + if obj.State != nil { + count++ + } + if obj.IsNative != nil { + count++ + } + if obj.DelegatedAmount != nil { + count++ + } + if obj.CloseAuthority != nil { + count++ + } + if count != 1 { + return fmt.Errorf("TokenAccountAssertion requires exactly one assertion value, got %d", count) + } + encoder.WriteUint8(obj.Type()) + if obj.Mint != nil { + encoder.WritePublicKey(ag_solanago.PublicKey((*obj.Mint))) + } + if obj.Owner != nil { + encoder.WritePublicKey(ag_solanago.PublicKey((*obj.Owner))) + } + if obj.Amount != nil { + encoder.WriteUint64(uint64((*obj.Amount))) + } + if obj.Delegate != nil { + encoder.WritePublicKey(ag_solanago.PublicKey((*obj.Delegate))) + } + if obj.State != nil { + if len(*obj.State) != 1 { + return fmt.Errorf("State requires one byte") } - case 1: //DataLength - if err := decoder.Decode(t.DataLength); err != nil { + encoder.WriteBytes(*obj.State) + } + if obj.IsNative != nil { + encoder.WriteBool(bool((*obj.IsNative))) + } + if obj.DelegatedAmount != nil { + encoder.WriteUint64(uint64((*obj.DelegatedAmount))) + } + if obj.CloseAuthority != nil { + encoder.WritePublicKey(ag_solanago.PublicKey((*obj.CloseAuthority))) + } + encoder.WriteUint8(obj.Operator) + return encoder.Err() +} +func (obj *TokenAccountAssertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + *obj = TokenAccountAssertion{} + tag := decoder.ReadUint8() + if err := decoder.Err(); err != nil { + return err + } + switch tag { + case 0: + obj.Mint = new(ag_solanago.PublicKey) + (*obj.Mint) = ag_solanago.PublicKey(decoder.ReadPublicKey()) + case 1: + obj.Owner = new(ag_solanago.PublicKey) + (*obj.Owner) = ag_solanago.PublicKey(decoder.ReadPublicKey()) + case 2: + obj.Amount = new(uint64) + (*obj.Amount) = uint64(decoder.ReadUint64()) + case 3: + obj.Delegate = new(ag_solanago.PublicKey) + (*obj.Delegate) = ag_solanago.PublicKey(decoder.ReadPublicKey()) + case 4: + value := decoder.ReadBytesCopy(1) + obj.State = &value + case 5: + obj.IsNative = new(bool) + (*obj.IsNative) = bool(decoder.ReadBool()) + case 6: + obj.DelegatedAmount = new(uint64) + (*obj.DelegatedAmount) = uint64(decoder.ReadUint64()) + case 7: + obj.CloseAuthority = new(ag_solanago.PublicKey) + (*obj.CloseAuthority) = ag_solanago.PublicKey(decoder.ReadPublicKey()) + default: + return fmt.Errorf("unknown TokenAccountAssertion type %d", tag) + } + obj.Operator = decoder.ReadUint8() + return decoder.Err() +} + +func (obj AccountInfoAssertion) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + count := 0 + if obj.Lamports != nil { + count++ + } + if obj.DataLength != nil { + count++ + } + if obj.Owner != nil { + count++ + } + if obj.RentEpoch != nil { + count++ + } + if obj.IsSigner != nil { + count++ + } + if obj.IsWritable != nil { + count++ + } + if obj.Executable != nil { + count++ + } + if count != 1 { + return fmt.Errorf("AccountInfoAssertion requires exactly one assertion value, got %d", count) + } + encoder.WriteUint8(obj.Type()) + if obj.Lamports != nil { + encoder.WriteUint64(uint64((*obj.Lamports))) + } + if obj.DataLength != nil { + encoder.WriteUint64(uint64((*obj.DataLength))) + } + if obj.Owner != nil { + encoder.WritePublicKey(ag_solanago.PublicKey((*obj.Owner))) + } + if obj.RentEpoch != nil { + encoder.WriteUint64(uint64((*obj.RentEpoch))) + } + if obj.IsSigner != nil { + encoder.WriteBool(bool((*obj.IsSigner))) + } + if obj.IsWritable != nil { + encoder.WriteBool(bool((*obj.IsWritable))) + } + if obj.Executable != nil { + encoder.WriteBool(bool((*obj.Executable))) + } + encoder.WriteUint8(obj.Operator) + return encoder.Err() +} +func (obj *AccountInfoAssertion) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + *obj = AccountInfoAssertion{} + tag := decoder.ReadUint8() + if err := decoder.Err(); err != nil { + return err + } + switch tag { + case 0: + obj.Lamports = new(uint64) + (*obj.Lamports) = uint64(decoder.ReadUint64()) + case 1: + obj.DataLength = new(uint64) + (*obj.DataLength) = uint64(decoder.ReadUint64()) + case 2: + obj.Owner = new(ag_solanago.PublicKey) + (*obj.Owner) = ag_solanago.PublicKey(decoder.ReadPublicKey()) + case 4: + obj.RentEpoch = new(uint64) + (*obj.RentEpoch) = uint64(decoder.ReadUint64()) + case 5: + obj.IsSigner = new(bool) + (*obj.IsSigner) = bool(decoder.ReadBool()) + case 6: + obj.IsWritable = new(bool) + (*obj.IsWritable) = bool(decoder.ReadBool()) + case 7: + obj.Executable = new(bool) + (*obj.Executable) = bool(decoder.ReadBool()) + default: + return fmt.Errorf("unknown AccountInfoAssertion type %d", tag) + } + obj.Operator = decoder.ReadUint8() + return decoder.Err() +} + +func (obj AccountDataAssertions) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if uint64(len(obj)) > 4294967295 { + return fmt.Errorf("too many assertions: %d", len(obj)) + } + encoder.WriteUint32(uint32(len(obj))) + for _, item := range obj { + if err := item.MarshalWithEncoder(encoder); err != nil { return err } - case 2: //Owner - if err := decoder.Decode(t.Owner); err != nil { + } + return encoder.Err() +} +func (obj *AccountDataAssertions) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + n := uint64(decoder.ReadUint32()) + if err := decoder.Err(); err != nil { + return err + } + if n > uint64(decoder.Remaining()) { + return fmt.Errorf("assertion count exceeds remaining data") + } + *obj = make(AccountDataAssertions, int(n)) + for i := range *obj { + if err := (*obj)[i].UnmarshalWithDecoder(decoder); err != nil { return err } - case 4: //RentEpoch - if err := decoder.Decode(t.RentEpoch); err != nil { - return err + } + return decoder.Err() +} + +func (obj TokenAccountAssertions) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if uint64(len(obj)) > 255 { + return fmt.Errorf("too many assertions: %d", len(obj)) + } + encoder.WriteUint8(uint8(len(obj))) + for _, item := range obj { + if item == nil { + return fmt.Errorf("nil assertion") } - case 5: //IsSigner - if err := decoder.Decode(t.IsSigner); err != nil { + if err := item.MarshalWithEncoder(encoder); err != nil { return err } - case 6: //IsWritable - if err := decoder.Decode(t.IsWritable); err != nil { + } + return encoder.Err() +} +func (obj *TokenAccountAssertions) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + n := uint64(decoder.ReadUint8()) + if err := decoder.Err(); err != nil { + return err + } + if n > uint64(decoder.Remaining()) { + return fmt.Errorf("assertion count exceeds remaining data") + } + *obj = make(TokenAccountAssertions, int(n)) + for i := range *obj { + (*obj)[i] = new(TokenAccountAssertion) + if err := (*obj)[i].UnmarshalWithDecoder(decoder); err != nil { return err } - case 7: //Executable - if err := decoder.Decode(t.Executable); err != nil { + } + return decoder.Err() +} + +func (obj AccountInfoAssertions) MarshalWithEncoder(encoder *ag_binary.Encoder) error { + if uint64(len(obj)) > 255 { + return fmt.Errorf("too many assertions: %d", len(obj)) + } + encoder.WriteUint8(uint8(len(obj))) + for _, item := range obj { + if item == nil { + return fmt.Errorf("nil assertion") + } + if err := item.MarshalWithEncoder(encoder); err != nil { return err } - default: - return errors.New(fmt.Sprintf("unknown assertation type (%v)", byt)) } - - return decoder.Decode(&t.Operator) + return encoder.Err() } - -type SysvarClockAssertion Assertion -type StakeAccountAssertions Assertion -type AccountDeltaAssertion Assertion -type BubblegumTreeConfigAssertion Assertion -type MerkleTreeAssertion Assertion -type MintAccountAssertion Assertion -type MintAccountAssertions Assertion -type StakeAccountAssertion Assertion -type UpgradeableLoaderStateAssertion Assertion -type UpgradeableLoaderStateAssertions Assertion -type WriteType Assertion - -type Assertion struct { - Typ uint8 - Data []byte +func (obj *AccountInfoAssertions) UnmarshalWithDecoder(decoder *ag_binary.Decoder) error { + n := uint64(decoder.ReadUint8()) + if err := decoder.Err(); err != nil { + return err + } + if n > uint64(decoder.Remaining()) { + return fmt.Errorf("assertion count exceeds remaining data") + } + *obj = make(AccountInfoAssertions, int(n)) + for i := range *obj { + (*obj)[i] = new(AccountInfoAssertion) + if err := (*obj)[i].UnmarshalWithDecoder(decoder); err != nil { + return err + } + } + return decoder.Err() } diff --git a/go.mod b/go.mod index 6aea65b..96f8692 100644 --- a/go.mod +++ b/go.mod @@ -1,45 +1,31 @@ module github.com/alphabatem/lighthouse_go -go 1.24.2 +go 1.26.4 require ( github.com/alphabatem/common v1.2.0 - github.com/alphabatem/solana-go v0.0.0-20241206170112-10aa273a9a76 github.com/davecgh/go-spew v1.1.1 - github.com/gagliardetto/binary v0.8.0 + github.com/fluxrpc/solana-go v0.1.9 github.com/gagliardetto/gofuzz v1.2.2 - github.com/gagliardetto/solana-go v1.12.0 github.com/gagliardetto/treeout v0.1.4 github.com/joho/godotenv v1.5.1 - github.com/stretchr/testify v1.10.0 + github.com/stretchr/testify v1.11.1 ) require ( - filippo.io/edwards25519 v1.1.0 // indirect - github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect - github.com/blendle/zapdriver v1.3.1 // indirect - github.com/fatih/color v1.18.0 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.17.11 // indirect - github.com/logrusorgru/aurora v2.0.3+incompatible // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mitchellh/go-testing-interface v1.14.1 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/mostynb/zstdpool-freelist v0.0.0-20201229113212-927304c0c3b1 // indirect - github.com/mr-tron/base58 v1.2.0 // indirect + github.com/bytedance/gopkg v0.1.4 // indirect + github.com/bytedance/sonic v1.15.2 // indirect + github.com/bytedance/sonic/loader v0.5.2 // indirect + github.com/cloudwego/base64x v0.1.7 // indirect + github.com/fluxrpc/base58 v1.2.0 // indirect + github.com/klauspost/compress v1.19.2 // indirect + github.com/klauspost/cpuid/v2 v2.4.0 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/oasisprotocol/curve25519-voi v0.0.0-20251114093237-2ab5a27a1729 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091 // indirect - go.mongodb.org/mongo-driver v1.17.1 // indirect - go.uber.org/atomic v1.11.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - go.uber.org/ratelimit v0.2.0 // indirect - go.uber.org/zap v1.27.0 // indirect - golang.org/x/crypto v0.31.0 // indirect - golang.org/x/sys v0.29.0 // indirect - golang.org/x/term v0.28.0 // indirect - golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + golang.org/x/arch v0.30.0 // indirect + golang.org/x/crypto v0.55.0 // indirect + golang.org/x/sys v0.47.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..1a86d2a --- /dev/null +++ b/go.sum @@ -0,0 +1,320 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alphabatem/common v1.2.0 h1:gQdu7r02hVoEyRAy37qcsYYdx4SstL0nFA5hQA5PHCE= +github.com/alphabatem/common v1.2.0/go.mod h1:ORLH+0FEduGevMuYM8mt9ML3+BANTd7aBT6zRx1B8V0= +github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y= +github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bytedance/gopkg v0.1.4 h1:oZnQwnX82KAIWb7033bEwtxvTqXcYMxDBaQxo5JJHWM= +github.com/bytedance/gopkg v0.1.4/go.mod h1:v1zWfPm21Fb+OsyXN2VAHdL6TBb2L88anLQgdyje6R4= +github.com/bytedance/sonic v1.15.2 h1:90H+rcF/FwLXwfB1cudOLq/je83n683Utf4Cbp0xHCo= +github.com/bytedance/sonic v1.15.2/go.mod h1:mT2NbXunuaEbnZ+mRIX/vYqKISmgEuHFDI4UzmKx2SA= +github.com/bytedance/sonic/loader v0.5.2 h1:0QtP1gevc1OZ6/H8Lb9BRZiCXd1Ftjd3OKuj1T1lBIo= +github.com/bytedance/sonic/loader v0.5.2/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudwego/base64x v0.1.7 h1:NppS+Fgzg5ovhn4NkUXaDT3x9jldgH5ToMCqzBSi2zI= +github.com/cloudwego/base64x v0.1.7/go.mod h1:Cu1PV9zfrSf7ET2tIbWbbEy7jO7HHJ13q4X2SQ8aWYg= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= +github.com/fluxrpc/base58 v1.2.0 h1:/BKqSC9I7KfhoJOcUVw2mZOlF22WvgZYoHqD3U9YPu0= +github.com/fluxrpc/base58 v1.2.0/go.mod h1:lHCDrkJr1/MZuOnpfPE6a5DLhgvj5YzgVzOD18j9K50= +github.com/fluxrpc/solana-go v0.1.9 h1:ldg4goLaRRcrMn8nUCdtCiwpBku49rlprrf6/WpHwos= +github.com/fluxrpc/solana-go v0.1.9/go.mod h1:BVLQM1tTflDRs8/avXdzhxrt8GNbsbTGAob4hEzPKnE= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/gagliardetto/gofuzz v1.2.2 h1:XL/8qDMzcgvR4+CyRQW9UGdwPRPMHVJfqQ/uMvSUuQw= +github.com/gagliardetto/gofuzz v1.2.2/go.mod h1:bkH/3hYLZrMLbfYWA0pWzXmi5TTRZnu4pMGZBkqMKvY= +github.com/gagliardetto/treeout v0.1.4 h1:ozeYerrLCmCubo1TcIjFiOWTTGteOOHND1twdFpgwaw= +github.com/gagliardetto/treeout v0.1.4/go.mod h1:loUefvXTrlRG5rYmJmExNryyBRh8f89VZhmMOyCyqok= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/go-redis/redis/v7 v7.4.1/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= +github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= +github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= +github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= +github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= +github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= +github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= +github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= +github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= +github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= +github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= +github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= +github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= +github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= +github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= +github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= +github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= +github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= +github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= +github.com/kevinburke/nacl v0.0.0-20210405173606-cd9060f5f776/go.mod h1:VUp2yfq+wAk8hMl3NNN34fXjzUD9xMpGvUL8eSJz9Ns= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/klauspost/compress v1.19.2 h1:hMRETovs/pu/dVWN7zIT1PGG8t509MwT6bO7XSi26R8= +github.com/klauspost/compress v1.19.2/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ= +github.com/klauspost/cpuid/v2 v2.4.0 h1:S6Hrbc7+ywsr0r+RLapfGBHfyefhCTwEh3A0tV913Dw= +github.com/klauspost/cpuid/v2 v2.4.0/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= +github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/oasisprotocol/curve25519-voi v0.0.0-20251114093237-2ab5a27a1729 h1:yfQ2sO9WJXUAIUR+g7NUkxJSKCAFJcR5sUDu+ZmjTZI= +github.com/oasisprotocol/curve25519-voi v0.0.0-20251114093237-2ab5a27a1729/go.mod h1:hVoHR2EVESiICEMbg137etN/Lx+lSrHPTD39Z/uE+2s= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.6.0/go.mod h1:ZLOG9ck3JLRdB5MgO8f+lLTe83AXG6ro35rLTxvnIl4= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +go.mongodb.org/mongo-driver v1.4.2/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= +golang.org/x/arch v0.30.0 h1:sB9h+1gRGa2+LauFSV0tm8bK1J2yo1bx6/Uyi/P6DTU= +golang.org/x/arch v0.30.0/go.mod h1:0X+GdSIP+kL5wPmpK7sdkEVTt2XoYP0cSjQSbZBwOi8= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/crypto v0.55.0 h1:+KWHjbgOaAQ66dh/YlkZKHlz9ZUlq61AFirAR9ntP8M= +golang.org/x/crypto v0.55.0/go.mod h1:uq0V9dE/fzQuJtbnL+2EhWOE63vo164FY8xqEnV9xis= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs= +golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/internal/format/format.go b/internal/format/format.go new file mode 100644 index 0000000..1a326c3 --- /dev/null +++ b/internal/format/format.go @@ -0,0 +1,35 @@ +// Package format provides plain-text labels for Lighthouse instruction trees. +package format + +import ( + "fmt" + "strings" + + "github.com/davecgh/go-spew/spew" + solana "github.com/fluxrpc/solana-go" +) + +func Program(name string, id solana.PublicKey) string { + return fmt.Sprintf("Program: %s %s", name, id) +} + +func Instruction(name string) string { return "Instruction: " + name } + +func Param(name string, value interface{}) string { + valueText := strings.TrimSpace(spew.Sdump(value)) + return name + ": " + strings.ReplaceAll(valueText, "\n", "\n"+strings.Repeat(" ", len(name)+2)) +} + +func Meta(name string, meta *solana.AccountMeta) string { + if meta == nil { + return name + ": " + } + var roles []string + if meta.IsWritable { + roles = append(roles, "WRITE") + } + if meta.IsSigner { + roles = append(roles, "SIGN") + } + return fmt.Sprintf("%s: %s [%s]", name, meta.PublicKey, strings.Join(roles, ", ")) +} diff --git a/migration_test.go b/migration_test.go new file mode 100644 index 0000000..326aa36 --- /dev/null +++ b/migration_test.go @@ -0,0 +1,42 @@ +package lighthouse_go + +import ( + "testing" + + "github.com/alphabatem/lighthouse_go/generated/lighthouse" + solana "github.com/fluxrpc/solana-go" + "github.com/stretchr/testify/require" +) + +func TestFluxInstructionTransaction(t *testing.T) { + svc := LighthouseService{} + require.NoError(t, svc.Start()) + svc.SetLogLevel(lighthouse.LogLevel(0)) + account := solana.PublicKey{1} + payer := solana.PublicKey{2} + ix, err := svc.AssertTokenAccountAmountInstruction(account, 42, lighthouse.IntegerOperator_Equal) + require.NoError(t, err) + require.Equal(t, lighthouse.ProgramID, ix.ProgramID()) + require.Equal(t, []*solana.AccountMeta{{PublicKey: account}}, ix.Accounts()) + data, err := ix.Data() + require.NoError(t, err) + // Instruction 10, log level 0, one amount assertion, little-endian 42, equal. + require.Equal(t, []byte{10, 0, 1, 2, 42, 0, 0, 0, 0, 0, 0, 0, 0}, data) + decodedInstruction, err := lighthouse.DecodeInstruction(ix.Accounts(), data) + require.NoError(t, err) + require.Equal(t, ix.Accounts(), decodedInstruction.Accounts()) + require.Equal(t, uint64(42), *decodedInstruction.Impl.(*lighthouse.AssertTokenAccountMulti).Assertions[0].Amount) + + tx, err := solana.NewTransaction([]solana.Instruction{ix}, solana.Hash{3}, solana.TransactionPayer(payer)) + require.NoError(t, err) + wire, err := tx.MarshalBinary() + require.NoError(t, err) + decoded, err := solana.TransactionFromBytes(wire) + require.NoError(t, err) + require.Len(t, decoded.Message.Instructions, 1) + compiled := decoded.Message.Instructions[0] + require.Equal(t, data, []byte(compiled.Data)) + require.Equal(t, lighthouse.ProgramID, decoded.Message.AccountKeys[compiled.ProgramIDIndex]) + require.Len(t, compiled.Accounts, 1) + require.Equal(t, account, decoded.Message.AccountKeys[compiled.Accounts[0]]) +} diff --git a/service.go b/service.go index 60acafe..af6e5f6 100644 --- a/service.go +++ b/service.go @@ -3,7 +3,7 @@ package lighthouse_go import ( "github.com/alphabatem/common/context" "github.com/alphabatem/lighthouse_go/generated/lighthouse" - "github.com/gagliardetto/solana-go" + solana "github.com/fluxrpc/solana-go" ) type LighthouseService struct { diff --git a/service_test.go b/service_test.go index ecced68..21696ac 100644 --- a/service_test.go +++ b/service_test.go @@ -1,34 +1,37 @@ package lighthouse_go import ( - "bytes" "context" - "encoding/binary" "github.com/alphabatem/lighthouse_go/generated/lighthouse" - "github.com/alphabatem/solana-go/rpc_cached" - bin "github.com/gagliardetto/binary" - "github.com/gagliardetto/solana-go" - "github.com/gagliardetto/solana-go/rpc" + solana "github.com/fluxrpc/solana-go" + bin "github.com/fluxrpc/solana-go/binary" + "github.com/fluxrpc/solana-go/rpc" "github.com/joho/godotenv" - "log" "os" "testing" ) -func init() { - err := godotenv.Load(".env") - if err != nil { - log.Fatal("Error loading .env file") +func integrationRPC(t *testing.T, needsKeypair bool) *rpc.Client { + t.Helper() + if err := godotenv.Load(".env"); err != nil && !os.IsNotExist(err) { + t.Fatal(err) + } + if os.Getenv("RPC_URL") == "" { + t.Skip("set RPC_URL to run integration tests") + } + if needsKeypair && os.Getenv("TEST_KEYPAIR") == "" { + t.Skip("set TEST_KEYPAIR to run simulation tests") } + return rpc.New(os.Getenv("RPC_URL")) } func TestLighthouseService_AssertTokenAccountInstruction_Decode(t *testing.T) { sig := solana.MustSignatureFromBase58("2CJ8oLPbtYmjtcXMjn1u89QVX3EJWJDzjR1HQWw1nDSqQpHWuLQhbecDMSRXXg9bkSWFy8AmckE7Ue4RpjTddQtd") - c := rpc_cached.New(os.Getenv("RPC_URl")) + c := integrationRPC(t, false) z := uint64(0) - txn, err := c.Raw().GetTransaction(context.TODO(), sig, &rpc.GetTransactionOpts{Commitment: rpc.CommitmentConfirmed, MaxSupportedTransactionVersion: &z}) + txn, err := c.GetTransactionWithOpts(context.TODO(), sig, &rpc.GetTransactionOpts{Commitment: rpc.CommitmentConfirmed, MaxSupportedTransactionVersion: &z}) if err != nil { t.Fatal(err) } @@ -43,7 +46,7 @@ func TestLighthouseService_AssertTokenAccountInstruction_Decode(t *testing.T) { pk := solana.PublicKeyFromBytes(tokenAtaAssertIx.Data[len(tokenAtaAssertIx.Data)-33 : len(tokenAtaAssertIx.Data)-1]) var dix lighthouse.AssertTokenAccountMulti - err = dix.UnmarshalWithDecoder(bin.NewBinDecoder(tokenAtaAssertIx.Data)) + err = dix.UnmarshalWithDecoder(bin.NewDecoder(tokenAtaAssertIx.Data[1:])) if err != nil { t.Fatal(err) } @@ -81,9 +84,9 @@ func TestLighthouseService_AssertTokenAccountInstruction_Decode(t *testing.T) { } func TestLighthouseService_AssertTokenAccountAmountInstruction(t *testing.T) { - c := rpc_cached.New(os.Getenv("RPC_URL")) + c := integrationRPC(t, true) - hash, err := c.GetLatestBlockhash() + hash, err := c.GetLatestBlockhash(context.TODO(), rpc.CommitmentConfirmed) if err != nil { t.Fatal(err) } @@ -119,7 +122,7 @@ func TestLighthouseService_AssertTokenAccountAmountInstruction(t *testing.T) { txn.Signatures = []solana.Signature{solana.Signature{}} - sim, err := c.Raw().SimulateTransactionWithOpts(context.TODO(), txn, &rpc.SimulateTransactionOpts{ + sim, err := c.SimulateTransactionWithOpts(context.TODO(), txn, &rpc.SimulateTransactionOpts{ SigVerify: false, Commitment: rpc.CommitmentProcessed, }) @@ -136,9 +139,9 @@ func TestLighthouseService_AssertTokenAccountAmountInstruction(t *testing.T) { } func TestLighthouseService_AssertAccountInfoInstruction(t *testing.T) { - c := rpc_cached.New(os.Getenv("RPC_URL")) + c := integrationRPC(t, true) - hash, err := c.GetLatestBlockhash() + hash, err := c.GetLatestBlockhash(context.TODO(), rpc.CommitmentConfirmed) if err != nil { t.Fatal(err) } @@ -153,7 +156,7 @@ func TestLighthouseService_AssertAccountInfoInstruction(t *testing.T) { t.Fatal(err) } - accInfo, err := c.GetAccountInfo(kp.PublicKey(), true) + accInfo, err := c.GetAccountInfo(context.TODO(), kp.PublicKey()) if err != nil { t.Fatal(err) } @@ -191,13 +194,13 @@ func TestLighthouseService_AssertAccountInfoInstruction(t *testing.T) { // t.Fatal(err) //} // - //sig, err := c.Raw().SendTransactionWithOpts(context.TODO(), txn, rpc.TransactionOpts{SkipPreflight: true}) + //sig, err := c.SendTransactionWithOpts(context.TODO(), txn, rpc.TransactionOpts{SkipPreflight: true}) //if err != nil { // t.Fatal(err) //} //log.Printf("Sig: %s", sig) - sim, err := c.Raw().SimulateTransactionWithOpts(context.TODO(), txn, &rpc.SimulateTransactionOpts{ + sim, err := c.SimulateTransactionWithOpts(context.TODO(), txn, &rpc.SimulateTransactionOpts{ SigVerify: false, Commitment: rpc.CommitmentProcessed, }) @@ -216,13 +219,12 @@ func TestLighthouseService_AssertAccountInfoInstruction(t *testing.T) { func NewComputeBudgetSetUnitLimitInstruction(units uint32) solana.Instruction { computeBudget := solana.MustPublicKeyFromBase58("ComputeBudget111111111111111111111111111111") - buf := new(bytes.Buffer) - borshEncoder := bin.NewBorshEncoder(buf) + borshEncoder := bin.NewEncoder(nil) - _ = borshEncoder.Encode(uint8(2)) //2 = Set Compute Unit Limit - _ = borshEncoder.WriteUint64(uint64(units), binary.LittleEndian) + borshEncoder.WriteUint8(2) //2 = Set Compute Unit Limit + borshEncoder.WriteUint32(units) - inst2 := solana.NewInstruction(computeBudget, solana.AccountMetaSlice{}, buf.Bytes()) + inst2 := solana.NewInstruction(computeBudget, solana.AccountMetaSlice{}, borshEncoder.Bytes()) return inst2 } @@ -230,13 +232,12 @@ func NewComputeBudgetSetUnitLimitInstruction(units uint32) solana.Instruction { func NewComputeBudgetSetUnitPriceInstruction(mLamports uint64) solana.Instruction { computeBudget := solana.MustPublicKeyFromBase58("ComputeBudget111111111111111111111111111111") - buf := new(bytes.Buffer) - borshEncoder := bin.NewBorshEncoder(buf) + borshEncoder := bin.NewEncoder(nil) - _ = borshEncoder.WriteUint8(uint8(3)) //3 = Set Compute Unit Bids - _ = borshEncoder.WriteUint64(mLamports, binary.LittleEndian) + borshEncoder.WriteUint8(3) //3 = Set Compute Unit Bids + borshEncoder.WriteUint64(mLamports) - inst2 := solana.NewInstruction(computeBudget, solana.AccountMetaSlice{}, buf.Bytes()) + inst2 := solana.NewInstruction(computeBudget, solana.AccountMetaSlice{}, borshEncoder.Bytes()) return inst2 }