Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
firelizzard18 committed Jul 11, 2024
1 parent 27ac2c1 commit 69c4254
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 528 deletions.
2 changes: 1 addition & 1 deletion pkg/api/v3/types_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -7724,7 +7724,7 @@ func init() {
}, "RecordRange", "recordRange")

encoding.RegisterTypeDefinition(&[]*encoding.TypeField{
encoding.NewTypeField("type", "uint64"),
encoding.NewTypeField("type", "ServiceType"),
encoding.NewTypeField("argument", "string"),
}, "ServiceAddress", "serviceAddress")

Expand Down
14 changes: 4 additions & 10 deletions pkg/types/encoding/eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ var EIP712DomainHash []byte
var Eip712Domain = EIP712Domain{
Name: "Accumulate",
Version: "1.0.0",

// Use a fake domain for the moment
ChainId: big.NewInt(1),
// ChainId: big.NewInt(281),
ChainId: big.NewInt(281),
}

type Eip712Encoder struct {
Expand Down Expand Up @@ -123,7 +120,6 @@ func mapEnumTypes[T any, R any](f Func[T, R]) (string, map[string]string) {
}
op, err := f(*enumType)
if err != nil {
//fmt.Println("Error calling function with enum:", err)
continue
}

Expand Down Expand Up @@ -175,7 +171,7 @@ func FromTypedInterfaceToBytes(v interface{}, typesAliasMap map[string]string) (
return nil, fmt.Errorf("invalid data entry type: %T", vv["type"])
}

b, err := d.hash(vv, t) //encodeData(vv, t, d)
b, err := d.hash(vv, t)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -509,7 +505,7 @@ func NewTypeField(n string, tp string) *TypeField {
return nil, fmt.Errorf("eip712 field %s", tp)
}

b, err := fields.hash(v, tp) //encodeData(m, tp, fields)
b, err := fields.hash(v, tp)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -751,9 +747,7 @@ func FromfloatToBytes(value float64) ([]byte, error) {
}

func hexStringToBytes(hexStr string) ([]byte, error) {
if strings.HasPrefix(hexStr, "0x") {
hexStr = hexStr[2:]
}
hexStr = strings.TrimPrefix(hexStr, "0x")
b, err := hex.DecodeString(hexStr)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion protocol/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ func SignEip712TypedData(sig *Eip712TypedDataSignature, privateKey []byte, outer

sig.TransactionHash = txn.Hash()
sig.Signature, err = eth.Sign(hash, priv)
return nil
return err
}

// GetSigner returns Signer.
Expand Down
6 changes: 6 additions & 0 deletions protocol/signature_eip712.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Copyright 2024 The Accumulate Authors
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

package protocol

import (
Expand Down
2 changes: 1 addition & 1 deletion scripts/images/ci-golang/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG VERSION=1.20
FROM golang:${VERSION}

RUN apt update -y && apt install -y git-lfs
RUN apt update -y && apt install -y git-lfs nodejs npm
Loading

0 comments on commit 69c4254

Please sign in to comment.