Documentation
¶
Index ¶
- Variables
- type ATALookup
- type AccountConstant
- type AccountLookup
- type AccountsFromLookupTable
- type ChainContractReader
- type ContractReader
- type ContractWriterConfig
- type DerivedLookupTable
- type EventDefinitions
- type IDL
- type IdlAccount
- type IdlAccountItem
- type IdlAccountItemSlice
- type IdlAccounts
- type IdlConstant
- type IdlEnumFields
- type IdlEnumFieldsNamed
- type IdlEnumFieldsTuple
- type IdlEnumVariant
- type IdlEnumVariantSlice
- type IdlErrorCode
- type IdlEvent
- type IdlEventField
- type IdlField
- type IdlInstruction
- type IdlType
- func (env *IdlType) GetArray() *IdlTypeArray
- func (env *IdlType) GetIdlTypeDefined() *IdlTypeDefined
- func (env *IdlType) GetIdlTypeOption() *IdlTypeOption
- func (env *IdlType) GetIdlTypeVec() *IdlTypeVec
- func (env *IdlType) GetString() IdlTypeAsString
- func (env *IdlType) IsArray() bool
- func (env *IdlType) IsIdlTypeDefined() bool
- func (env *IdlType) IsIdlTypeOption() bool
- func (env *IdlType) IsIdlTypeVec() bool
- func (env *IdlType) IsString() bool
- func (env IdlType) MarshalJSON() ([]byte, error)
- func (env *IdlType) UnmarshalJSON(data []byte) error
- type IdlTypeArray
- type IdlTypeAsString
- type IdlTypeDef
- type IdlTypeDefSlice
- type IdlTypeDefStruct
- type IdlTypeDefTy
- type IdlTypeDefTyEnum
- type IdlTypeDefTyKind
- type IdlTypeDefTyStruct
- type IdlTypeDefined
- type IdlTypeOption
- type IdlTypeVec
- type IndexedField
- type InternalField
- type Lookup
- type LookupTables
- type MetaBool
- type MethodConfig
- type MultiReader
- type PDALookups
- type PDASeed
- type PDATypeDef
- type PollingFilter
- type ProgramConfig
- type ReadDefinition
- type ReadType
- type Seed
Constants ¶
This section is empty.
Variables ¶
var NilIdlTypeDefTy = IdlTypeDef{Type: IdlTypeDefTy{ Kind: "struct", Fields: &IdlTypeDefStruct{}, }}
Functions ¶
This section is empty.
Types ¶
type ATALookup ¶
type ATALookup struct {
// Field that determines whether the ATA lookup is necessary. Basically
// just need to check this field exists. Dot separated location.
Location string
// If the field exists, initialize a ATA account using the Wallet, Token Program, and Mint addresses below
WalletAddress Lookup
TokenProgram Lookup // Deprecated: The token program is now fetched from the mint account
MintAddress Lookup
Optional bool
}
type AccountConstant ¶
type AccountConstant struct {
Name string `json:"name,omitempty"`
Address string `json:"address"`
IsSigner bool `json:"isSigner,omitempty"`
IsWritable bool `json:"isWritable,omitempty"`
}
AccountConstant represents a fixed address, provided in Base58 format, converted into a `solana.PublicKey`.
type AccountLookup ¶
type AccountLookup struct {
Name string `json:"name,omitempty"`
Location string `json:"location"`
// IsSigner and IsWritable can either be a constant bool or a location to a bitmap which decides the bools
IsSigner MetaBool `json:"isSigner,omitempty"`
IsWritable MetaBool `json:"isWritable,omitempty"`
}
AccountLookup dynamically derives an account address from args using a specified location path.
type AccountsFromLookupTable ¶
type AccountsFromLookupTable struct {
LookupTableName string `json:"lookupTableName"`
IncludeIndexes []int `json:"includeIndexes"`
}
AccountsFromLookupTable extracts accounts from a lookup table that was previously read and stored in memory.
type ChainContractReader ¶
type ChainContractReader struct {
IDL `json:"anchorIDL"`
*PollingFilter `json:"pollingFilter,omitempty"`
// Reads key is the off-chain name for this read.
Reads map[string]ReadDefinition `json:"reads"`
}
func (*ChainContractReader) UnmarshalJSON ¶
func (c *ChainContractReader) UnmarshalJSON(bytes []byte) error
type ContractReader ¶
type ContractReader struct {
Namespaces map[string]ChainContractReader `json:"namespaces"`
// Whichever namespace or i.e. Binding from the list is Bound first will share that address with the rest of the group.
// Namespaces that were bound after the first one still have to be Bound to be initialised.
// If they are Bound with an empty address string, they will use the address of the first Bound contract.
// If they are Bound with a non-empty address string, an error will be thrown unless the address matches the address of the first Bound shared contract.
AddressShareGroups [][]string `json:"addressShareGroups,omitempty"`
}
func (*ContractReader) UnmarshalJSON ¶
func (c *ContractReader) UnmarshalJSON(bytes []byte) error
type ContractWriterConfig ¶
type ContractWriterConfig struct {
Programs map[string]ProgramConfig `json:"programs"`
}
nolint // ignoring naming suggestion
type DerivedLookupTable ¶
type DerivedLookupTable struct {
Name string `json:"name,omitempty"`
Accounts Lookup `json:"accounts"`
Optional bool `json:"optional"`
}
DerivedLookupTable represents a lookup table that is used to derive addresses for a program.
type EventDefinitions ¶
type EventDefinitions struct {
IndexedField0 *IndexedField `json:"indexedField0"`
IndexedField1 *IndexedField `json:"indexedField1"`
IndexedField2 *IndexedField `json:"indexedField2"`
IndexedField3 *IndexedField `json:"indexedField3"`
// PollingFilter should be defined on a contract level in ContractPollingFilter, unless event needs to override the
// contract level filter options.
*PollingFilter `json:"pollingFilter,omitempty"`
}
type IDL ¶
type IDL struct {
Version string `json:"version"`
Name string `json:"name"`
Instructions []IdlInstruction `json:"instructions"`
Accounts IdlTypeDefSlice `json:"accounts,omitempty"`
Types IdlTypeDefSlice `json:"types,omitempty"`
Events []IdlEvent `json:"events,omitempty"`
Errors []IdlErrorCode `json:"errors,omitempty"`
Constants []IdlConstant `json:"constants,omitempty"`
}
https://github.com/project-serum/anchor/blob/97e9e03fb041b8b888a9876a7c0676d9bb4736f3/ts/src/idl.ts
type IdlAccount ¶
type IdlAccountItem ¶
type IdlAccountItem struct {
IdlAccount *IdlAccount
IdlAccounts *IdlAccounts
}
type IdlAccountItem = IdlAccount | IdlAccounts;
func (IdlAccountItem) MarshalJSON ¶
func (env IdlAccountItem) MarshalJSON() ([]byte, error)
func (*IdlAccountItem) UnmarshalJSON ¶
func (env *IdlAccountItem) UnmarshalJSON(data []byte) error
type IdlAccountItemSlice ¶
type IdlAccountItemSlice []IdlAccountItem
func (IdlAccountItemSlice) NumAccounts ¶
func (slice IdlAccountItemSlice) NumAccounts() (count int)
type IdlAccounts ¶
type IdlAccounts struct {
Name string `json:"name"`
Docs []string `json:"docs"` // @custom
Accounts IdlAccountItemSlice `json:"accounts"`
}
A nested/recursive version of IdlAccount.
type IdlConstant ¶
type IdlEnumFields ¶
type IdlEnumFields struct {
IdlEnumFieldsNamed *IdlEnumFieldsNamed
IdlEnumFieldsTuple *IdlEnumFieldsTuple
}
type IdlEnumFields = IdlEnumFieldsNamed | IdlEnumFieldsTuple;
func (*IdlEnumFields) UnmarshalJSON ¶
func (env *IdlEnumFields) UnmarshalJSON(data []byte) error
TODO: verify with examples
type IdlEnumFieldsNamed ¶
type IdlEnumFieldsNamed []IdlField
type IdlEnumFieldsTuple ¶
type IdlEnumFieldsTuple []IdlType
type IdlEnumVariant ¶
type IdlEnumVariant struct {
Name string `json:"name"`
Docs []string `json:"docs"` // @custom
Fields *IdlEnumFields `json:"fields,omitempty"`
}
func (*IdlEnumVariant) IsUint8 ¶
func (variant *IdlEnumVariant) IsUint8() bool
type IdlEnumVariantSlice ¶
type IdlEnumVariantSlice []IdlEnumVariant
func (IdlEnumVariantSlice) IsAllUint8 ¶
func (slice IdlEnumVariantSlice) IsAllUint8() bool
func (IdlEnumVariantSlice) IsSimpleEnum ¶
func (slice IdlEnumVariantSlice) IsSimpleEnum() bool
type IdlErrorCode ¶
type IdlEvent ¶
type IdlEvent struct {
Name string `json:"name"`
Fields []IdlEventField `json:"fields"`
}
type IdlEventField ¶
type IdlInstruction ¶
type IdlInstruction struct {
Name string `json:"name"`
Docs []string `json:"docs"` // @custom
Accounts IdlAccountItemSlice `json:"accounts"`
Args []IdlField `json:"args"`
}
type IdlType ¶
type IdlType struct {
AsString IdlTypeAsString
AsIdlTypeVec *IdlTypeVec
AsIdlTypeDefined *IdlTypeDefined
AsIdlTypeArray *IdlTypeArray
// contains filtered or unexported fields
}
Wrapper type:
func NewIdlStringType ¶
func NewIdlStringType(asString IdlTypeAsString) IdlType
func (*IdlType) GetArray ¶
func (env *IdlType) GetArray() *IdlTypeArray
func (*IdlType) GetIdlTypeDefined ¶
func (env *IdlType) GetIdlTypeDefined() *IdlTypeDefined
func (*IdlType) GetIdlTypeOption ¶
func (env *IdlType) GetIdlTypeOption() *IdlTypeOption
func (*IdlType) GetIdlTypeVec ¶
func (env *IdlType) GetIdlTypeVec() *IdlTypeVec
func (*IdlType) IsIdlTypeDefined ¶
func (*IdlType) IsIdlTypeOption ¶
func (*IdlType) IsIdlTypeVec ¶
func (IdlType) MarshalJSON ¶
func (*IdlType) UnmarshalJSON ¶
type IdlTypeAsString ¶
type IdlTypeAsString string
const ( IdlTypeBool IdlTypeAsString = "bool" IdlTypeU8 IdlTypeAsString = "u8" IdlTypeI8 IdlTypeAsString = "i8" IdlTypeU16 IdlTypeAsString = "u16" IdlTypeI16 IdlTypeAsString = "i16" IdlTypeU32 IdlTypeAsString = "u32" IdlTypeI32 IdlTypeAsString = "i32" IdlTypeU64 IdlTypeAsString = "u64" IdlTypeI64 IdlTypeAsString = "i64" IdlTypeU128 IdlTypeAsString = "u128" IdlTypeI128 IdlTypeAsString = "i128" IdlTypeBytes IdlTypeAsString = "bytes" IdlTypeString IdlTypeAsString = "string" IdlTypePublicKey IdlTypeAsString = "publicKey" // Custom additions: IdlTypeUnixTimestamp IdlTypeAsString = "unixTimestamp" IdlTypeHash IdlTypeAsString = "hash" IdlTypeDuration IdlTypeAsString = "duration" )
type IdlTypeDef ¶
type IdlTypeDef struct {
Name string `json:"name"`
Type IdlTypeDefTy `json:"type"`
}
type IdlTypeDefSlice ¶
type IdlTypeDefSlice []IdlTypeDef
func (IdlTypeDefSlice) GetByName ¶
func (named IdlTypeDefSlice) GetByName(name string) *IdlTypeDef
type IdlTypeDefStruct ¶
type IdlTypeDefStruct = []IdlField
type IdlTypeDefTy ¶
type IdlTypeDefTy struct {
Kind IdlTypeDefTyKind `json:"kind"`
Fields *IdlTypeDefStruct `json:"fields,omitempty"`
Variants IdlEnumVariantSlice `json:"variants,omitempty"`
Codec string `json:"codec,omitempty"`
}
type IdlTypeDefTyEnum ¶
type IdlTypeDefTyEnum struct {
Kind IdlTypeDefTyKind `json:"kind"` // == "enum"
Variants IdlEnumVariantSlice `json:"variants,omitempty"`
}
type IdlTypeDefTyKind ¶
type IdlTypeDefTyKind string
const ( IdlTypeDefTyKindStruct IdlTypeDefTyKind = "struct" IdlTypeDefTyKindEnum IdlTypeDefTyKind = "enum" IdlTypeDefTyKindCustom IdlTypeDefTyKind = "custom" )
type IdlTypeDefTyStruct ¶
type IdlTypeDefTyStruct struct {
Kind IdlTypeDefTyKind `json:"kind"` // == "struct"
Fields *IdlTypeDefStruct `json:"fields,omitempty"`
}
type IdlTypeDefined ¶
type IdlTypeDefined struct {
Defined string `json:"defined"`
}
User defined type.
type IdlTypeOption ¶
type IdlTypeOption struct {
Option IdlType `json:"option"`
}
type IdlTypeVec ¶
type IdlTypeVec struct {
Vec IdlType `json:"vec"`
}
type IndexedField ¶
type InternalField ¶
type Lookup ¶
type Lookup struct {
Optional bool
AccountConstant *AccountConstant `json:"accountConstant,omitempty"`
AccountLookup *AccountLookup `json:"accountLookup,omitempty"`
PDALookups *PDALookups `json:"pdas,omitempty"`
AccountsFromLookupTable *AccountsFromLookupTable `json:"accountsFromLookupTable,omitempty"`
}
type LookupTables ¶
type LookupTables struct {
DerivedLookupTables []DerivedLookupTable `json:"derivedLookupTables,omitempty"`
StaticLookupTables [][32]byte `json:"staticLookupTables,omitempty"` // solana.PublicKey
}
LookupTables represents a list of lookup tables that are used to derive addresses for a program.
type MethodConfig ¶
type MethodConfig struct {
FromAddress string `json:"fromAddress"`
InputModifications codec.ModifiersConfig `json:"inputModifications,omitempty"`
ChainSpecificName string `json:"chainSpecificName"`
LookupTables LookupTables `json:"lookupTables,omitempty"`
Accounts []Lookup `json:"accounts"`
ATAs []ATALookup `json:"atas,omitempty"`
// Location in the args where the debug ID is stored
DebugIDLocation string `json:"debugIDLocation,omitempty"`
ArgsTransform string `json:"argsTransform,omitempty"`
// Overhead added to calculated compute units in the args transform
ComputeUnitLimitOverhead uint32 `json:"ComputeUnitLimitOverhead,omitempty"`
// Configs for buffering payloads to support larger transaction sizes for this method
BufferPayloadMethod string `json:"bufferPayloadMethod,omitempty"`
}
type MultiReader ¶
type MultiReader struct {
// Reads is a list of reads that is sequentially read to fill out a complete response for the parent read.
// Parent ReadDefinition has to define codec modifiers which adds fields that are to be filled out by the reads in Reads.
Reads []ReadDefinition `json:"reads,omitempty"`
// ReuseParams If true, params from parent read will be reused for all MultiReader Reads.
ReuseParams bool `json:"reuseParams"`
}
type PDALookups ¶
type PDALookups struct {
Name string `json:"name,omitempty"`
// The public key of the PDA to be combined with seeds. If there are multiple PublicKeys
// there will be multiple PDAs generated by combining each PublicKey with the seeds.
PublicKey Lookup `json:"publicKey"`
// Seeds to be derived from an additional lookup
Seeds []Seed `json:"seeds"`
IsSigner bool `json:"isSigner,omitempty"`
IsWritable bool `json:"isWritable,omitempty"`
// OPTIONAL: On-chain location and type of desired data from PDA (e.g. a sub-account of the data account)
InternalField InternalField `json:"internalField,omitempty"`
}
PDALookups generates Program Derived Addresses (PDA) by combining a derived public key with one or more seeds.
type PDATypeDef ¶
type PDATypeDef struct {
Prefix []byte `json:"prefix,omitempty"`
Seeds []PDASeed `json:"seeds,omitempty"`
}
PDA is a struct that does not correlate to an official IDL type It is needed to encode seeds to calculate the address for PDA account reads
type PollingFilter ¶
type PollingFilter struct {
Retention *time.Duration `json:"retention,omitempty"` // maximum amount of time to retain logs
MaxLogsKept *int64 `json:"maxLogsKept,omitempty"` // maximum number of logs to retain ( 0 = unlimited )
StartingBlock *int64 `json:"startingBlock,omitempty"` // which block to start looking for logs
IncludeReverted *bool `json:"includeReverted"` // whether to include logs emitted by transactions which failed while executing on chain
}
type ProgramConfig ¶
type ProgramConfig struct {
Methods map[string]MethodConfig `json:"methods"`
IDL string `json:"idl"`
}
type ReadDefinition ¶
type ReadDefinition struct {
ChainSpecificName string `json:"chainSpecificName"`
ReadType ReadType `json:"readType,omitempty"`
ErrOnMissingAccountData bool `json:"errOnMissingAccountData,omitempty"`
InputModifications codec.ModifiersConfig `json:"inputModifications,omitempty"`
OutputModifications codec.ModifiersConfig `json:"outputModifications,omitempty"`
PDADefinition PDATypeDef `json:"pdaDefinition,omitempty"` // Only used for PDA account reads
MultiReader *MultiReader `json:"multiReader,omitempty"`
EventDefinitions *EventDefinitions `json:"eventDefinitions,omitempty"`
// ResponseAddressHardCoder hardcodes the address of the contract into the defined field in the response.
ResponseAddressHardCoder *codec.HardCodeModifierConfig `json:"responseAddressHardCoder,omitempty"`
}
func (ReadDefinition) HasPollingFilter ¶
func (d ReadDefinition) HasPollingFilter() bool