Skip to content

Commit

Permalink
Add types for the evm
Browse files Browse the repository at this point in the history
  • Loading branch information
nolag committed Nov 15, 2023
1 parent 7fce04a commit 917ecec
Show file tree
Hide file tree
Showing 5 changed files with 2,728 additions and 0 deletions.
60 changes: 60 additions & 0 deletions core/services/relay/evm/types/abi_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package types

import (
"reflect"
)

//go:generate go run gen.go

var typeMap = map[string]*AbiEncodingType{
"bool": {
Native: reflect.TypeOf(true),
Checked: reflect.TypeOf(true),
},
"int8": {
Native: reflect.TypeOf(int8(0)),
Checked: reflect.TypeOf(int8(0)),
},
"int16": {
Native: reflect.TypeOf(int16(0)),
Checked: reflect.TypeOf(int16(0)),
},
"int32": {
Native: reflect.TypeOf(int32(0)),
Checked: reflect.TypeOf(int32(0)),
},
"int64": {
Native: reflect.TypeOf(int64(0)),
Checked: reflect.TypeOf(int64(0)),
},
"uint8": {
Native: reflect.TypeOf(uint8(0)),
Checked: reflect.TypeOf(uint8(0)),
},
"uint16": {
Native: reflect.TypeOf(uint16(0)),
Checked: reflect.TypeOf(uint16(0)),
},
"uint32": {
Native: reflect.TypeOf(uint32(0)),
Checked: reflect.TypeOf(uint32(0)),
},
"uint64": {
Native: reflect.TypeOf(uint64(0)),
Checked: reflect.TypeOf(uint64(0)),
},
"string": {
Native: reflect.TypeOf(""),
Checked: reflect.TypeOf(""),
},
}

type AbiEncodingType struct {
Native reflect.Type
Checked reflect.Type
}

func GetType(name string) (*AbiEncodingType, bool) {
abiType, ok := typeMap[name]
return abiType, ok
}
300 changes: 300 additions & 0 deletions core/services/relay/evm/types/byte_types_gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
package types

import "reflect"

type bytes1 [1]byte

func init() {
typeMap["bytes1"] = &AbiEncodingType{
Native: reflect.TypeOf([1]byte{}),
Checked: reflect.TypeOf(bytes1{}),
}
}

type bytes2 [2]byte

func init() {
typeMap["bytes2"] = &AbiEncodingType{
Native: reflect.TypeOf([2]byte{}),
Checked: reflect.TypeOf(bytes2{}),
}
}

type bytes3 [3]byte

func init() {
typeMap["bytes3"] = &AbiEncodingType{
Native: reflect.TypeOf([3]byte{}),
Checked: reflect.TypeOf(bytes3{}),
}
}

type bytes4 [4]byte

func init() {
typeMap["bytes4"] = &AbiEncodingType{
Native: reflect.TypeOf([4]byte{}),
Checked: reflect.TypeOf(bytes4{}),
}
}

type bytes5 [5]byte

func init() {
typeMap["bytes5"] = &AbiEncodingType{
Native: reflect.TypeOf([5]byte{}),
Checked: reflect.TypeOf(bytes5{}),
}
}

type bytes6 [6]byte

func init() {
typeMap["bytes6"] = &AbiEncodingType{
Native: reflect.TypeOf([6]byte{}),
Checked: reflect.TypeOf(bytes6{}),
}
}

type bytes7 [7]byte

func init() {
typeMap["bytes7"] = &AbiEncodingType{
Native: reflect.TypeOf([7]byte{}),
Checked: reflect.TypeOf(bytes7{}),
}
}

type bytes8 [8]byte

func init() {
typeMap["bytes8"] = &AbiEncodingType{
Native: reflect.TypeOf([8]byte{}),
Checked: reflect.TypeOf(bytes8{}),
}
}

type bytes9 [9]byte

func init() {
typeMap["bytes9"] = &AbiEncodingType{
Native: reflect.TypeOf([9]byte{}),
Checked: reflect.TypeOf(bytes9{}),
}
}

type bytes10 [10]byte

func init() {
typeMap["bytes10"] = &AbiEncodingType{
Native: reflect.TypeOf([10]byte{}),
Checked: reflect.TypeOf(bytes10{}),
}
}

type bytes11 [11]byte

func init() {
typeMap["bytes11"] = &AbiEncodingType{
Native: reflect.TypeOf([11]byte{}),
Checked: reflect.TypeOf(bytes11{}),
}
}

type bytes12 [12]byte

func init() {
typeMap["bytes12"] = &AbiEncodingType{
Native: reflect.TypeOf([12]byte{}),
Checked: reflect.TypeOf(bytes12{}),
}
}

type bytes13 [13]byte

func init() {
typeMap["bytes13"] = &AbiEncodingType{
Native: reflect.TypeOf([13]byte{}),
Checked: reflect.TypeOf(bytes13{}),
}
}

type bytes14 [14]byte

func init() {
typeMap["bytes14"] = &AbiEncodingType{
Native: reflect.TypeOf([14]byte{}),
Checked: reflect.TypeOf(bytes14{}),
}
}

type bytes15 [15]byte

func init() {
typeMap["bytes15"] = &AbiEncodingType{
Native: reflect.TypeOf([15]byte{}),
Checked: reflect.TypeOf(bytes15{}),
}
}

type bytes16 [16]byte

func init() {
typeMap["bytes16"] = &AbiEncodingType{
Native: reflect.TypeOf([16]byte{}),
Checked: reflect.TypeOf(bytes16{}),
}
}

type bytes17 [17]byte

func init() {
typeMap["bytes17"] = &AbiEncodingType{
Native: reflect.TypeOf([17]byte{}),
Checked: reflect.TypeOf(bytes17{}),
}
}

type bytes18 [18]byte

func init() {
typeMap["bytes18"] = &AbiEncodingType{
Native: reflect.TypeOf([18]byte{}),
Checked: reflect.TypeOf(bytes18{}),
}
}

type bytes19 [19]byte

func init() {
typeMap["bytes19"] = &AbiEncodingType{
Native: reflect.TypeOf([19]byte{}),
Checked: reflect.TypeOf(bytes19{}),
}
}

type bytes20 [20]byte

func init() {
typeMap["bytes20"] = &AbiEncodingType{
Native: reflect.TypeOf([20]byte{}),
Checked: reflect.TypeOf(bytes20{}),
}
}

type bytes21 [21]byte

func init() {
typeMap["bytes21"] = &AbiEncodingType{
Native: reflect.TypeOf([21]byte{}),
Checked: reflect.TypeOf(bytes21{}),
}
}

type bytes22 [22]byte

func init() {
typeMap["bytes22"] = &AbiEncodingType{
Native: reflect.TypeOf([22]byte{}),
Checked: reflect.TypeOf(bytes22{}),
}
}

type bytes23 [23]byte

func init() {
typeMap["bytes23"] = &AbiEncodingType{
Native: reflect.TypeOf([23]byte{}),
Checked: reflect.TypeOf(bytes23{}),
}
}

type bytes24 [24]byte

func init() {
typeMap["bytes24"] = &AbiEncodingType{
Native: reflect.TypeOf([24]byte{}),
Checked: reflect.TypeOf(bytes24{}),
}
}

type bytes25 [25]byte

func init() {
typeMap["bytes25"] = &AbiEncodingType{
Native: reflect.TypeOf([25]byte{}),
Checked: reflect.TypeOf(bytes25{}),
}
}

type bytes26 [26]byte

func init() {
typeMap["bytes26"] = &AbiEncodingType{
Native: reflect.TypeOf([26]byte{}),
Checked: reflect.TypeOf(bytes26{}),
}
}

type bytes27 [27]byte

func init() {
typeMap["bytes27"] = &AbiEncodingType{
Native: reflect.TypeOf([27]byte{}),
Checked: reflect.TypeOf(bytes27{}),
}
}

type bytes28 [28]byte

func init() {
typeMap["bytes28"] = &AbiEncodingType{
Native: reflect.TypeOf([28]byte{}),
Checked: reflect.TypeOf(bytes28{}),
}
}

type bytes29 [29]byte

func init() {
typeMap["bytes29"] = &AbiEncodingType{
Native: reflect.TypeOf([29]byte{}),
Checked: reflect.TypeOf(bytes29{}),
}
}

type bytes30 [30]byte

func init() {
typeMap["bytes30"] = &AbiEncodingType{
Native: reflect.TypeOf([30]byte{}),
Checked: reflect.TypeOf(bytes30{}),
}
}

type bytes31 [31]byte

func init() {
typeMap["bytes31"] = &AbiEncodingType{
Native: reflect.TypeOf([31]byte{}),
Checked: reflect.TypeOf(bytes31{}),
}
}

type bytes32 [32]byte

func init() {
typeMap["bytes32"] = &AbiEncodingType{
Native: reflect.TypeOf([32]byte{}),
Checked: reflect.TypeOf(bytes32{}),
}
}

type bytes0 [0]byte

func init() {
typeMap["bytes0"] = &AbiEncodingType{
Native: reflect.TypeOf([0]byte{}),
Checked: reflect.TypeOf(bytes0{}),
}
}
Loading

0 comments on commit 917ecec

Please sign in to comment.