|
| 1 | +package codec |
| 2 | + |
| 3 | +import ( |
| 4 | + commoncodec "github.com/smartcontractkit/chainlink-common/pkg/codec" |
| 5 | + "github.com/smartcontractkit/chainlink-common/pkg/codec/encodings" |
| 6 | + commontypes "github.com/smartcontractkit/chainlink-common/pkg/types" |
| 7 | + |
| 8 | + solcommoncodec "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/common" |
| 9 | + codecv1 "github.com/smartcontractkit/chainlink-solana/pkg/solana/codec/v1" |
| 10 | +) |
| 11 | + |
| 12 | +// Backward-compatible aliases for the old pkg/solana/codec public API. |
| 13 | +// The underlying implementation now lives in pkg/solana/codec/v1 and pkg/solana/codec/common. |
| 14 | + |
| 15 | +type ChainConfigType = solcommoncodec.ChainConfigType |
| 16 | + |
| 17 | +const ( |
| 18 | + ChainConfigTypeAccountDef = solcommoncodec.ChainConfigTypeAccountDef |
| 19 | + ChainConfigTypeInstructionDef = solcommoncodec.ChainConfigTypeInstructionDef |
| 20 | + ChainConfigTypeEventDef = solcommoncodec.ChainConfigTypeEventDef |
| 21 | +) |
| 22 | + |
| 23 | +type Config = solcommoncodec.Config |
| 24 | +type ChainConfig = solcommoncodec.ChainConfig |
| 25 | +type Entry = solcommoncodec.Entry |
| 26 | +type ParsedTypes = solcommoncodec.ParsedTypes |
| 27 | + |
| 28 | +var DecoderHooks = solcommoncodec.DecoderHooks |
| 29 | + |
| 30 | +func WrapItemType(forEncoding bool, contractName, itemType string) string { |
| 31 | + return solcommoncodec.WrapItemType(forEncoding, contractName, itemType) |
| 32 | +} |
| 33 | + |
| 34 | +func AddEntries(defs map[string]Entry, modByTypeName map[string]map[string]commoncodec.Modifier) error { |
| 35 | + return solcommoncodec.AddEntries(defs, modByTypeName) |
| 36 | +} |
| 37 | + |
| 38 | +func EntryAsModifierRemoteCodec(entry Entry, itemType string) (commontypes.RemoteCodec, error) { |
| 39 | + return solcommoncodec.EntryAsModifierRemoteCodec(entry, itemType) |
| 40 | +} |
| 41 | + |
| 42 | +type IDL = codecv1.IDL |
| 43 | +type IdlConstant = codecv1.IdlConstant |
| 44 | +type IdlTypeDefSlice = codecv1.IdlTypeDefSlice |
| 45 | +type IdlEvent = codecv1.IdlEvent |
| 46 | +type IdlEventField = codecv1.IdlEventField |
| 47 | +type IdlInstruction = codecv1.IdlInstruction |
| 48 | +type IdlAccountItemSlice = codecv1.IdlAccountItemSlice |
| 49 | +type IdlAccountItem = codecv1.IdlAccountItem |
| 50 | +type IdlAccount = codecv1.IdlAccount |
| 51 | +type IdlAccounts = codecv1.IdlAccounts |
| 52 | +type IdlField = codecv1.IdlField |
| 53 | +type PDATypeDef = codecv1.PDATypeDef |
| 54 | +type PDASeed = codecv1.PDASeed |
| 55 | +type IdlTypeAsString = codecv1.IdlTypeAsString |
| 56 | +type IdlTypeVec = codecv1.IdlTypeVec |
| 57 | +type IdlTypeOption = codecv1.IdlTypeOption |
| 58 | +type IdlTypeDefined = codecv1.IdlTypeDefined |
| 59 | +type IdlTypeArray = codecv1.IdlTypeArray |
| 60 | +type IdlType = codecv1.IdlType |
| 61 | +type IdlTypeDef = codecv1.IdlTypeDef |
| 62 | +type IdlTypeDefTyKind = codecv1.IdlTypeDefTyKind |
| 63 | +type IdlTypeDefTyStruct = codecv1.IdlTypeDefTyStruct |
| 64 | +type IdlTypeDefTyEnum = codecv1.IdlTypeDefTyEnum |
| 65 | +type IdlTypeDefTy = codecv1.IdlTypeDefTy |
| 66 | +type IdlEnumVariantSlice = codecv1.IdlEnumVariantSlice |
| 67 | +type IdlTypeDefStruct = codecv1.IdlTypeDefStruct |
| 68 | +type IdlEnumVariant = codecv1.IdlEnumVariant |
| 69 | +type IdlEnumFields = codecv1.IdlEnumFields |
| 70 | +type IdlEnumFieldsNamed = codecv1.IdlEnumFieldsNamed |
| 71 | +type IdlEnumFieldsTuple = codecv1.IdlEnumFieldsTuple |
| 72 | +type IdlErrorCode = codecv1.IdlErrorCode |
| 73 | + |
| 74 | +const ( |
| 75 | + IdlTypeDefTyKindStruct = codecv1.IdlTypeDefTyKindStruct |
| 76 | + IdlTypeDefTyKindEnum = codecv1.IdlTypeDefTyKindEnum |
| 77 | + IdlTypeDefTyKindCustom = codecv1.IdlTypeDefTyKindCustom |
| 78 | +) |
| 79 | + |
| 80 | +const ( |
| 81 | + IdlTypeBool = codecv1.IdlTypeBool |
| 82 | + IdlTypeU8 = codecv1.IdlTypeU8 |
| 83 | + IdlTypeI8 = codecv1.IdlTypeI8 |
| 84 | + IdlTypeU16 = codecv1.IdlTypeU16 |
| 85 | + IdlTypeI16 = codecv1.IdlTypeI16 |
| 86 | + IdlTypeU32 = codecv1.IdlTypeU32 |
| 87 | + IdlTypeI32 = codecv1.IdlTypeI32 |
| 88 | + IdlTypeU64 = codecv1.IdlTypeU64 |
| 89 | + IdlTypeI64 = codecv1.IdlTypeI64 |
| 90 | + IdlTypeU128 = codecv1.IdlTypeU128 |
| 91 | + IdlTypeI128 = codecv1.IdlTypeI128 |
| 92 | + IdlTypeBytes = codecv1.IdlTypeBytes |
| 93 | + IdlTypeString = codecv1.IdlTypeString |
| 94 | + IdlTypePublicKey = codecv1.IdlTypePublicKey |
| 95 | + IdlTypeUnixTimestamp = codecv1.IdlTypeUnixTimestamp |
| 96 | + IdlTypeHash = codecv1.IdlTypeHash |
| 97 | + IdlTypeDuration = codecv1.IdlTypeDuration |
| 98 | +) |
| 99 | + |
| 100 | +const DefaultHashBitLength = codecv1.DefaultHashBitLength |
| 101 | + |
| 102 | +var NilIdlTypeDefTy = codecv1.NilIdlTypeDefTy |
| 103 | + |
| 104 | +func NewIdlStringType(asString IdlTypeAsString) IdlType { |
| 105 | + return codecv1.NewIdlStringType(asString) |
| 106 | +} |
| 107 | + |
| 108 | +type AccountIDLTypes = codecv1.AccountIDLTypes |
| 109 | +type InstructionArgsIDLTypes = codecv1.InstructionArgsIDLTypes |
| 110 | +type EventIDLTypes = codecv1.EventIDLTypes |
| 111 | + |
| 112 | +func NewAccountEntry(offchainName string, idlTypes AccountIDLTypes, includeDiscriminator bool, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { |
| 113 | + return codecv1.NewAccountEntry(offchainName, idlTypes, includeDiscriminator, mod, builder) |
| 114 | +} |
| 115 | + |
| 116 | +func NewPDAEntry(offchainName string, pdaTypeDef PDATypeDef, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { |
| 117 | + return codecv1.NewPDAEntry(offchainName, pdaTypeDef, mod, builder) |
| 118 | +} |
| 119 | + |
| 120 | +func NewInstructionArgsEntry(offChainName string, idlTypes InstructionArgsIDLTypes, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { |
| 121 | + return codecv1.NewInstructionArgsEntry(offChainName, idlTypes, mod, builder) |
| 122 | +} |
| 123 | + |
| 124 | +func NewEventArgsEntryWrapper(offChainName string, contractIdl string, includeDiscriminator bool, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { |
| 125 | + return codecv1.NewEventArgsEntryWrapper(offChainName, contractIdl, includeDiscriminator, mod, builder) |
| 126 | +} |
| 127 | + |
| 128 | +func NewEventArgsEntry(offChainName string, idlTypes EventIDLTypes, includeDiscriminator bool, mod commoncodec.Modifier, builder encodings.Builder) (Entry, error) { |
| 129 | + return codecv1.NewEventArgsEntry(offChainName, idlTypes, includeDiscriminator, mod, builder) |
| 130 | +} |
| 131 | + |
| 132 | +func NewOnRampAddress(builder encodings.Builder) encodings.TypeCodec { |
| 133 | + return codecv1.NewOnRampAddress(builder) |
| 134 | +} |
| 135 | + |
| 136 | +func NewCodec(conf Config) (commontypes.RemoteCodec, error) { |
| 137 | + return codecv1.NewCodec(conf) |
| 138 | +} |
| 139 | + |
| 140 | +func CreateCodecEntry(idlDefinition interface{}, offChainName string, idl IDL, mod commoncodec.Modifier) (entry Entry, err error) { |
| 141 | + return codecv1.CreateCodecEntry(idlDefinition, offChainName, idl, mod) |
| 142 | +} |
| 143 | + |
| 144 | +func CreateCodecEntryWrapper(cfgType ChainConfigType, mod commoncodec.Modifier, onChainName, offChainName, idlString string) (entry Entry, err error) { |
| 145 | + return codecv1.CreateCodecEntryWrapper(cfgType, mod, onChainName, offChainName, idlString) |
| 146 | +} |
| 147 | + |
| 148 | +func FindDefinitionFromIDL(cfgType ChainConfigType, chainSpecificName string, idl IDL) (interface{}, error) { |
| 149 | + return codecv1.FindDefinitionFromIDL(cfgType, chainSpecificName, idl) |
| 150 | +} |
| 151 | + |
| 152 | +func ExtractEventIDL(eventName string, idl IDL) (IdlEvent, error) { |
| 153 | + return codecv1.ExtractEventIDL(eventName, idl) |
| 154 | +} |
| 155 | + |
| 156 | +func NewIDLAccountCodec(idl IDL, builder encodings.Builder) (commontypes.RemoteCodec, error) { |
| 157 | + return codecv1.NewIDLAccountCodec(idl, builder) |
| 158 | +} |
| 159 | + |
| 160 | +func NewNamedModifierCodec(original commontypes.RemoteCodec, itemType string, modifier commoncodec.Modifier) (commontypes.RemoteCodec, error) { |
| 161 | + return codecv1.NewNamedModifierCodec(original, itemType, modifier) |
| 162 | +} |
| 163 | + |
| 164 | +func NewIDLDefinedTypesCodec(idl IDL, builder encodings.Builder) (commontypes.RemoteCodec, error) { |
| 165 | + return codecv1.NewIDLDefinedTypesCodec(idl, builder) |
| 166 | +} |
0 commit comments