diff --git a/contracts/generated/contract_reader_interface/Createevent.go b/contracts/generated/contract_reader_interface/Createevent.go new file mode 100644 index 000000000..ca5de4071 --- /dev/null +++ b/contracts/generated/contract_reader_interface/Createevent.go @@ -0,0 +1,146 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package contract_reader_interface + +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_treeout "github.com/gagliardetto/treeout" +) + +// Createevent is the `createevent` instruction. +type Createevent struct { + Data *TestStructData + + // [0] = [SIGNER] signer + // + // [1] = [] systemProgram + ag_solanago.AccountMetaSlice `bin:"-"` +} + +// NewCreateeventInstructionBuilder creates a new `Createevent` instruction builder. +func NewCreateeventInstructionBuilder() *Createevent { + nd := &Createevent{ + AccountMetaSlice: make(ag_solanago.AccountMetaSlice, 2), + } + return nd +} + +// SetData sets the "data" parameter. +func (inst *Createevent) SetData(data TestStructData) *Createevent { + inst.Data = &data + return inst +} + +// SetSignerAccount sets the "signer" account. +func (inst *Createevent) SetSignerAccount(signer ag_solanago.PublicKey) *Createevent { + inst.AccountMetaSlice[0] = ag_solanago.Meta(signer).SIGNER() + return inst +} + +// GetSignerAccount gets the "signer" account. +func (inst *Createevent) GetSignerAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(0) +} + +// SetSystemProgramAccount sets the "systemProgram" account. +func (inst *Createevent) SetSystemProgramAccount(systemProgram ag_solanago.PublicKey) *Createevent { + inst.AccountMetaSlice[1] = ag_solanago.Meta(systemProgram) + return inst +} + +// GetSystemProgramAccount gets the "systemProgram" account. +func (inst *Createevent) GetSystemProgramAccount() *ag_solanago.AccountMeta { + return inst.AccountMetaSlice.Get(1) +} + +func (inst Createevent) Build() *Instruction { + return &Instruction{BaseVariant: ag_binary.BaseVariant{ + Impl: inst, + TypeID: Instruction_Createevent, + }} +} + +// ValidateAndBuild validates the instruction parameters and accounts; +// if there is a validation error, it returns the error. +// Otherwise, it builds and returns the instruction. +func (inst Createevent) ValidateAndBuild() (*Instruction, error) { + if err := inst.Validate(); err != nil { + return nil, err + } + return inst.Build(), nil +} + +func (inst *Createevent) Validate() error { + // Check whether all (required) parameters are set: + { + if inst.Data == nil { + return errors.New("Data parameter is not set") + } + } + + // Check whether all (required) accounts are set: + { + if inst.AccountMetaSlice[0] == nil { + return errors.New("accounts.Signer is not set") + } + if inst.AccountMetaSlice[1] == nil { + return errors.New("accounts.SystemProgram is not set") + } + } + return nil +} + +func (inst *Createevent) EncodeToTree(parent ag_treeout.Branches) { + parent.Child(ag_format.Program(ProgramName, ProgramID)). + // + ParentFunc(func(programBranch ag_treeout.Branches) { + programBranch.Child(ag_format.Instruction("Createevent")). + // + ParentFunc(func(instructionBranch ag_treeout.Branches) { + + // Parameters of the instruction: + instructionBranch.Child("Params[len=1]").ParentFunc(func(paramsBranch ag_treeout.Branches) { + paramsBranch.Child(ag_format.Param("Data", *inst.Data)) + }) + + // Accounts of the instruction: + instructionBranch.Child("Accounts[len=2]").ParentFunc(func(accountsBranch ag_treeout.Branches) { + accountsBranch.Child(ag_format.Meta(" signer", inst.AccountMetaSlice.Get(0))) + accountsBranch.Child(ag_format.Meta("systemProgram", inst.AccountMetaSlice.Get(1))) + }) + }) + }) +} + +func (obj Createevent) MarshalWithEncoder(encoder *ag_binary.Encoder) (err error) { + // Serialize `Data` param: + err = encoder.Encode(obj.Data) + if err != nil { + return err + } + return nil +} +func (obj *Createevent) UnmarshalWithDecoder(decoder *ag_binary.Decoder) (err error) { + // Deserialize `Data`: + err = decoder.Decode(&obj.Data) + if err != nil { + return err + } + return nil +} + +// NewCreateeventInstruction declares a new Createevent instruction with the provided parameters and accounts. +func NewCreateeventInstruction( + // Parameters: + data TestStructData, + // Accounts: + signer ag_solanago.PublicKey, + systemProgram ag_solanago.PublicKey) *Createevent { + return NewCreateeventInstructionBuilder(). + SetData(data). + SetSignerAccount(signer). + SetSystemProgramAccount(systemProgram) +} diff --git a/contracts/generated/contract_reader_interface/Createevent_test.go b/contracts/generated/contract_reader_interface/Createevent_test.go new file mode 100644 index 000000000..ce8bb1dad --- /dev/null +++ b/contracts/generated/contract_reader_interface/Createevent_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package contract_reader_interface + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Createevent(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Createevent"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Createevent) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Createevent) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/contracts/generated/contract_reader_interface/Initializecfg_test.go b/contracts/generated/contract_reader_interface/Initializecfg_test.go new file mode 100644 index 000000000..f9a99862f --- /dev/null +++ b/contracts/generated/contract_reader_interface/Initializecfg_test.go @@ -0,0 +1,32 @@ +// Code generated by https://github.com/gagliardetto/anchor-go. DO NOT EDIT. + +package contract_reader_interface + +import ( + "bytes" + ag_gofuzz "github.com/gagliardetto/gofuzz" + ag_require "github.com/stretchr/testify/require" + "strconv" + "testing" +) + +func TestEncodeDecode_Initializecfg(t *testing.T) { + fu := ag_gofuzz.New().NilChance(0) + for i := 0; i < 1; i++ { + t.Run("Initializecfg"+strconv.Itoa(i), func(t *testing.T) { + { + params := new(Initializecfg) + fu.Fuzz(params) + params.AccountMetaSlice = nil + buf := new(bytes.Buffer) + err := encodeT(*params, buf) + ag_require.NoError(t, err) + got := new(Initializecfg) + err = decodeT(got, buf.Bytes()) + got.AccountMetaSlice = nil + ag_require.NoError(t, err) + ag_require.Equal(t, params, got) + } + }) + } +} diff --git a/pkg/solana/logpoller/log_poller.go b/pkg/solana/logpoller/log_poller.go index bc626150f..616bcc7a7 100644 --- a/pkg/solana/logpoller/log_poller.go +++ b/pkg/solana/logpoller/log_poller.go @@ -468,7 +468,7 @@ func (lp *Service) replayComplete(from, to int64) bool { return true } -func appendBuffered(ch <-chan Block, max int, blocks []Block) []Block { +func appendBuffered(ch <-chan Block, maxNum int, blocks []Block) []Block { for { select { case block, ok := <-ch: @@ -477,7 +477,7 @@ func appendBuffered(ch <-chan Block, max int, blocks []Block) []Block { } blocks = append(blocks, block) - if len(blocks) >= max { + if len(blocks) >= maxNum { return blocks } default: