Skip to content

Commit b79dc92

Browse files
Realize jakarta operations in TzKT
1 parent 60b2c2b commit b79dc92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1230
-882
lines changed

cmd/tezgen/generator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"text/template"
1010

1111
"github.com/dipdup-net/go-lib/cmd/tezgen/types"
12-
"github.com/dipdup-net/go-lib/tzkt/api"
12+
"github.com/dipdup-net/go-lib/tzkt/data"
1313
"github.com/iancoleman/strcase"
1414
)
1515

@@ -27,7 +27,7 @@ var (
2727
)
2828

2929
// Generate -
30-
func Generate(schema api.ContractJSONSchema, name, contract, dest string) error {
30+
func Generate(schema data.ContractJSONSchema, name, contract, dest string) error {
3131
if dest == "" {
3232
output, err := os.Getwd()
3333
if err != nil {
@@ -65,7 +65,7 @@ func generateContractObject(name, contract, dest string, result types.ContractTy
6565
})
6666
}
6767

68-
func generateContractTypes(schema api.ContractJSONSchema, packageName, dest string) (types.ContractTypeResult, error) {
68+
func generateContractTypes(schema data.ContractJSONSchema, packageName, dest string) (types.ContractTypeResult, error) {
6969
result, err := types.GenerateContractTypes(schema, packageName)
7070
if err != nil {
7171
return result, err

cmd/tezgen/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os"
99

1010
"github.com/dipdup-net/go-lib/tzkt/api"
11+
"github.com/dipdup-net/go-lib/tzkt/data"
1112
"github.com/go-playground/validator/v10"
1213
)
1314

@@ -34,7 +35,7 @@ func main() {
3435
log.Panic(err)
3536
}
3637

37-
var response api.ContractJSONSchema
38+
var response data.ContractJSONSchema
3839
var err error
3940

4041
if args.File == "" {

cmd/tezgen/types/address.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package types
22

33
import (
44
"github.com/dave/jennifer/jen"
5-
"github.com/dipdup-net/go-lib/tzkt/api"
5+
"github.com/dipdup-net/go-lib/tzkt/data"
66
)
77

88
// Address -
99
type Address struct{}
1010

1111
// AsField -
12-
func (Address) AsField(name, path string, schema api.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
12+
func (Address) AsField(name, path string, schema data.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
1313
tags := map[string]string{
1414
"json": name,
1515
}
@@ -24,7 +24,7 @@ func (Address) AsField(name, path string, schema api.JSONSchema, isRequired bool
2424
}
2525

2626
// AsCode -
27-
func (Address) AsCode(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
27+
func (Address) AsCode(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
2828
typName := result.GetName("Address", name)
2929
return Code{
3030
Statement: jen.Comment(typName).Line().Type().Id(typName).Add(
@@ -35,7 +35,7 @@ func (Address) AsCode(name, path string, schema api.JSONSchema, result *Contract
3535
}
3636

3737
// AsType -
38-
func (Address) AsType(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
38+
func (Address) AsType(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
3939
return Code{
4040
Statement: jen.Add(
4141
jen.Qual("github.com/dipdup-net/go-lib/tools/tezgen", "Address"),

cmd/tezgen/types/big_map.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import (
44
"fmt"
55

66
"github.com/dave/jennifer/jen"
7-
"github.com/dipdup-net/go-lib/tzkt/api"
7+
"github.com/dipdup-net/go-lib/tzkt/data"
88
)
99

1010
// GenerateBigMap -
11-
func GenerateBigMap(bigMap api.BigMapJSONSchema, result *ContractTypeResult) error {
11+
func GenerateBigMap(bigMap data.BigMapJSONSchema, result *ContractTypeResult) error {
1212
keyTypeName, err := Generate(fmt.Sprintf("key_%s", bigMap.Name), bigMap.Key, result)
1313
if err != nil {
1414
return err
@@ -65,7 +65,7 @@ func GenerateBigMap(bigMap api.BigMapJSONSchema, result *ContractTypeResult) err
6565
type BigMap struct{}
6666

6767
// AsField -
68-
func (BigMap) AsField(name, path string, schema api.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
68+
func (BigMap) AsField(name, path string, schema data.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
6969
tags := map[string]string{
7070
"json": name,
7171
}
@@ -86,15 +86,15 @@ func (BigMap) AsField(name, path string, schema api.JSONSchema, isRequired bool,
8686
}
8787

8888
// AsCode -
89-
func (BigMap) AsCode(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
89+
func (BigMap) AsCode(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
9090
return Code{
9191
Statement: nil,
9292
Name: result.GetName("BigMap", name),
9393
}, nil
9494
}
9595

9696
// AsType -
97-
func (BigMap) AsType(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
97+
func (BigMap) AsType(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
9898
typName := result.GetName("BigMap", name)
9999
return Code{
100100
Statement: jen.Id(typName),

cmd/tezgen/types/bool.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package types
22

33
import (
44
"github.com/dave/jennifer/jen"
5-
"github.com/dipdup-net/go-lib/tzkt/api"
5+
"github.com/dipdup-net/go-lib/tzkt/data"
66
)
77

88
// Bool -
99
type Bool struct{}
1010

1111
// AsField -
12-
func (Bool) AsField(name, path string, schema api.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
12+
func (Bool) AsField(name, path string, schema data.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
1313
tags := map[string]string{
1414
"json": name,
1515
}
@@ -22,7 +22,7 @@ func (Bool) AsField(name, path string, schema api.JSONSchema, isRequired bool, r
2222
}
2323

2424
// AsCode -
25-
func (Bool) AsCode(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
25+
func (Bool) AsCode(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
2626
typ := result.GetName("Bool", name)
2727
return Code{
2828
Statement: jen.Comment(typ).Line().Type().Id(typ).Bool().Line(),
@@ -31,7 +31,7 @@ func (Bool) AsCode(name, path string, schema api.JSONSchema, result *ContractTyp
3131
}
3232

3333
// AsType -
34-
func (Bool) AsType(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
34+
func (Bool) AsType(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
3535
return Code{
3636
Statement: jen.Bool(),
3737
Name: result.GetName("Bool", name),

cmd/tezgen/types/bytes.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package types
22

33
import (
44
"github.com/dave/jennifer/jen"
5-
"github.com/dipdup-net/go-lib/tzkt/api"
5+
"github.com/dipdup-net/go-lib/tzkt/data"
66
)
77

88
// Bytes -
99
type Bytes struct{}
1010

1111
// AsField -
12-
func (Bytes) AsField(name, path string, schema api.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
12+
func (Bytes) AsField(name, path string, schema data.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
1313
tags := map[string]string{
1414
"json": name,
1515
}
@@ -24,7 +24,7 @@ func (Bytes) AsField(name, path string, schema api.JSONSchema, isRequired bool,
2424
}
2525

2626
// AsCode -
27-
func (Bytes) AsCode(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
27+
func (Bytes) AsCode(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
2828
typName := result.GetName("Bytes", name)
2929
return Code{
3030
Statement: jen.Comment(typName).Line().Type().Id(typName).Add(
@@ -35,7 +35,7 @@ func (Bytes) AsCode(name, path string, schema api.JSONSchema, result *ContractTy
3535
}
3636

3737
// AsType -
38-
func (Bytes) AsType(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
38+
func (Bytes) AsType(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
3939
return Code{
4040
Statement: jen.Add(
4141
jen.Qual("github.com/dipdup-net/go-lib/tools/tezgen", "Bytes"),

cmd/tezgen/types/contract.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package types
22

33
import (
44
"github.com/dave/jennifer/jen"
5-
"github.com/dipdup-net/go-lib/tzkt/api"
5+
"github.com/dipdup-net/go-lib/tzkt/data"
66
)
77

88
// Contract -
99
type Contract struct{}
1010

1111
// AsField -
12-
func (Contract) AsField(name, path string, schema api.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
12+
func (Contract) AsField(name, path string, schema data.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
1313
tags := map[string]string{
1414
"json": name,
1515
}
@@ -24,7 +24,7 @@ func (Contract) AsField(name, path string, schema api.JSONSchema, isRequired boo
2424
}
2525

2626
// AsCode -
27-
func (Contract) AsCode(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
27+
func (Contract) AsCode(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
2828
typName := result.GetName("Contract", name)
2929
return Code{
3030
Statement: jen.Comment(typName).Line().Type().Id(typName).Add(
@@ -35,7 +35,7 @@ func (Contract) AsCode(name, path string, schema api.JSONSchema, result *Contrac
3535
}
3636

3737
// AsType -
38-
func (Contract) AsType(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
38+
func (Contract) AsType(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
3939
return Code{
4040
Statement: jen.Add(
4141
jen.Qual("github.com/dipdup-net/go-lib/tools/tezgen", "Contract"),

cmd/tezgen/types/general.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"strconv"
77

88
"github.com/dave/jennifer/jen"
9-
"github.com/dipdup-net/go-lib/tzkt/api"
9+
"github.com/dipdup-net/go-lib/tzkt/data"
1010
"github.com/iancoleman/strcase"
1111
"github.com/pkg/errors"
1212
)
@@ -20,9 +20,9 @@ var reservedNames = map[string]string{
2020

2121
// Type -
2222
type Type interface {
23-
AsField(name, path string, schema api.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error)
24-
AsCode(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error)
25-
AsType(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error)
23+
AsField(name, path string, schema data.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error)
24+
AsCode(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error)
25+
AsType(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error)
2626
}
2727

2828
// Code -
@@ -32,7 +32,7 @@ type Code struct {
3232
}
3333

3434
// Generate -
35-
func Generate(name string, schema api.JSONSchema, result *ContractTypeResult) (string, error) {
35+
func Generate(name string, schema data.JSONSchema, result *ContractTypeResult) (string, error) {
3636
typ, err := selectType(schema)
3737
if err != nil {
3838
return "", err
@@ -90,7 +90,7 @@ type BigMapData struct {
9090
}
9191

9292
// GenerateContractTypes -
93-
func GenerateContractTypes(schema api.ContractJSONSchema, packageName string) (ContractTypeResult, error) {
93+
func GenerateContractTypes(schema data.ContractJSONSchema, packageName string) (ContractTypeResult, error) {
9494
result := ContractTypeResult{
9595
File: jen.NewFile(packageName),
9696
Entrypoints: make(map[string]EntrypointData),
@@ -110,7 +110,7 @@ func GenerateContractTypes(schema api.ContractJSONSchema, packageName string) (C
110110
return result, nil
111111
}
112112

113-
func generateForContract(schema api.ContractJSONSchema, result *ContractTypeResult) error {
113+
func generateForContract(schema data.ContractJSONSchema, result *ContractTypeResult) error {
114114
for _, entrypoint := range schema.Entrypoints {
115115
entrypointType, err := Generate(entrypoint.Name, entrypoint.Parameter, result)
116116
if err != nil {
@@ -140,7 +140,7 @@ func generateForContract(schema api.ContractJSONSchema, result *ContractTypeResu
140140
return nil
141141
}
142142

143-
func selectType(schema api.JSONSchema) (Type, error) {
143+
func selectType(schema data.JSONSchema) (Type, error) {
144144
switch schema.Type {
145145
case "object":
146146
switch schema.Comment {

cmd/tezgen/types/int.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package types
22

33
import (
44
"github.com/dave/jennifer/jen"
5-
"github.com/dipdup-net/go-lib/tzkt/api"
5+
"github.com/dipdup-net/go-lib/tzkt/data"
66
)
77

88
// Int -
99
type Int struct{}
1010

1111
// AsField -
12-
func (Int) AsField(name, path string, schema api.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
12+
func (Int) AsField(name, path string, schema data.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
1313
tags := map[string]string{
1414
"json": name,
1515
}
@@ -24,7 +24,7 @@ func (Int) AsField(name, path string, schema api.JSONSchema, isRequired bool, re
2424
}
2525

2626
// AsCode -
27-
func (Int) AsCode(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
27+
func (Int) AsCode(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
2828
typ := result.GetName(schema.Comment, name)
2929
return Code{
3030
Statement: jen.Comment(typ).Line().Type().Id(typ).Add(
@@ -35,7 +35,7 @@ func (Int) AsCode(name, path string, schema api.JSONSchema, result *ContractType
3535
}
3636

3737
// AsType -
38-
func (Int) AsType(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
38+
func (Int) AsType(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
3939
return Code{
4040
Statement: jen.Add(
4141
jen.Qual("github.com/dipdup-net/go-lib/tools/tezgen", "Int"),

cmd/tezgen/types/key_hash.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ package types
22

33
import (
44
"github.com/dave/jennifer/jen"
5-
"github.com/dipdup-net/go-lib/tzkt/api"
5+
"github.com/dipdup-net/go-lib/tzkt/data"
66
)
77

88
// KeyHash -
99
type KeyHash struct{}
1010

1111
// AsField -
12-
func (KeyHash) AsField(name, path string, schema api.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
12+
func (KeyHash) AsField(name, path string, schema data.JSONSchema, isRequired bool, result *ContractTypeResult) (jen.Code, error) {
1313
tags := map[string]string{
1414
"json": name,
1515
}
@@ -22,7 +22,7 @@ func (KeyHash) AsField(name, path string, schema api.JSONSchema, isRequired bool
2222
}
2323

2424
// AsCode -
25-
func (KeyHash) AsCode(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
25+
func (KeyHash) AsCode(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
2626
typName := result.GetName("KeyHash", name)
2727
return Code{
2828
Statement: jen.Comment(typName).Line().Type().Id(typName).String().Line(),
@@ -31,7 +31,7 @@ func (KeyHash) AsCode(name, path string, schema api.JSONSchema, result *Contract
3131
}
3232

3333
// AsType -
34-
func (KeyHash) AsType(name, path string, schema api.JSONSchema, result *ContractTypeResult) (Code, error) {
34+
func (KeyHash) AsType(name, path string, schema data.JSONSchema, result *ContractTypeResult) (Code, error) {
3535
return Code{
3636
Statement: jen.String(),
3737
Name: name,

0 commit comments

Comments
 (0)