Skip to content

Commit

Permalink
V4: edo and delphi (#173)
Browse files Browse the repository at this point in the history
* keys: importing secp256k1 and p256

* signing: tz2, tz3, ledeger

* keys: working with all key types

* forging script_expr

* rpc: adding contextual rpcs

* rpc: adding new RPCs and restructure

* context: testing context queries

* edo: rpc work around edo

* edo: rpc work around edo

* edo: rpc work around edo

* edo: finished up helpers

* edo: wrapping up edo changes

* edo: cleanup for merge
  • Loading branch information
DefinitelyNotAGoat authored Dec 29, 2020
1 parent bdff4cf commit 5190840
Show file tree
Hide file tree
Showing 63 changed files with 23,253 additions and 7,131 deletions.
78 changes: 9 additions & 69 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,75 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).



## [v2.9.0-alpha]

Added support and testing for preapply operations RPC.

## [v2.8.0-alpha]

Added support for forging and unforging operations with the RPC.

## [v2.6.0-alpha]

Adding Carthage changes to constants.
Bug fix for importing wallet.

## [v2.5.2-alpha]

Fixing forge bug.

## [v2.5.1-alpha]

Adding contents type conversions to forge inputs.


## [v2.5.0-alpha]

Adding Forge functions.

## [v2.4.4-alpha]

Adds method to sign operations.
Removes GoTezos struct from forge and unforge operations.

## [v2.4.3-alpha]

Fixes false positive with RPC errors.
Uses .test-fixtures directory for json test data.
Adds missing fields to block structure.

## [v2.4.2-alpha]

Fixes FrozenBalance function.

## [v2.4.1-alpha]

Adding IFace for ease of testing with the library.

## [v2.3.1-alpha]

All balances now have big.Int.

## [v2.2.1-alpha]

Improved the BigInt wrapper.
Started integration tests.

## [v2.1.1-alpha]

Improved documentation.

## [v2.1.0-alpha]

Testing Operations.

## [v2.0.0-alpha]
## [v4.0.0]

Complete redesign of GoTezos.
EDO Support and Design Improvements

### Added
- Contains 76% test coverage.
- Contains local operation forge
- Contains new RPC's
- Returning network response in each RPC function
- Cleaned up testing
- Many new RPC's related to EDO and Delphi
- A new BlockID pattern
- Key management for P256
- Key management for secp256k1
- Forging of script expression for all data types
26 changes: 16 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://godoc.org/github.com/goat-systems/go-tezos/v2)
[![GoDoc](https://godoc.org/github.com/golang/gddo?status.svg)](https://godoc.org/github.com/goat-systems/go-tezos/v4)
# A Tezos Go Library

Go Tezos is a GoLang driven library for your Tezos node. This library has received a grant from the Tezos Foundation to ensure it's continuous development through 2020.
Go Tezos is a GoLang driven library for your Tezos node. This library has received a grant from the Tezos Foundation to ensure it's continuous development through 2020.

## Installation

Get goTezos
Get GoTezos
```
go get github.com/goat-systems/go-tezos/v3
go get github.com/goat-systems/go-tezos/v4
```

### Getting A Block
Expand All @@ -17,32 +17,38 @@ package main
import (
"fmt"
goTezos "github.com/goat-systems/go-tezos/v3/rpc"
goTezos "github.com/goat-systems/go-tezos/v4/rpc"
)
func main() {
rpc, err := client.New("http://127.0.0.1:8732")
if err != nil {
fmt.Printf("could not connect to network: %v", err)
fmt.Printf("failed tp connect to network: %v", err)
}
block, err := rpc.Block(1000)
resp, head, err := client.Block(&rpc.BlockIDHead{})
if err != nil {
fmt.Println(err)
fmt.Printf("failed to get (%s) head block: %s\n", resp.Status(), err.Error())
os.Exit(1)
}
fmt.Println(block)
}
```

### Getting a Cycle
```
cycle, err := rpc.Cycle(50)
resp, cycle, err := rpc.Cycle(50)
if err != nil {
fmt.Println(err)
fmt.Printf("failed to get (%s) cycle: %s\n", resp.Status(), err.Error())
os.Exit(1)
}
fmt.Println(cycle)
```

### More Examples
You can find more examples by looking through the unit tests and integration tests in each package. [Here](example/transaction/transaction.go) is an example on
how to forge and inject an operation.

## Contributing

### The Makefile
Expand Down
42 changes: 18 additions & 24 deletions example/transaction/transaction.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
package main

import (
"encoding/hex"
"fmt"
"math/big"
"os"
"strconv"

"github.com/goat-systems/go-tezos/v3/forge"
"github.com/goat-systems/go-tezos/v3/keys"
"github.com/goat-systems/go-tezos/v3/rpc"
"github.com/goat-systems/go-tezos/v4/forge"
"github.com/goat-systems/go-tezos/v4/keys"
"github.com/goat-systems/go-tezos/v4/rpc"
)

func main() {
key, err := keys.NewKey(keys.NewKeyInput{
Esk: "edesk...",
Password: "password",
})
key, err := keys.FromEncryptedSecret("edesk...", "password")
if err != nil {
fmt.Printf("failed to import keys: %s\n", err.Error())
os.Exit(1)
Expand All @@ -28,18 +24,12 @@ func main() {
os.Exit(1)
}

head, err := client.Head()
if err != nil {
fmt.Printf("failed to get head block: %s\n", err.Error())
os.Exit(1)
}

counter, err := client.Counter(rpc.CounterInput{
Blockhash: head.Hash,
Address: key.PubKey.GetPublicKeyHash(),
resp, counter, err := client.ContractCounter(rpc.ContractCounterInput{
BlockID: &rpc.BlockIDHead{},
ContractID: key.PubKey.GetAddress(),
})
if err != nil {
fmt.Printf("failed to get counter: %s\n", err.Error())
fmt.Printf("failed to get (%s) counter: %s\n", resp.Status(), err.Error())
os.Exit(1)
}
counter++
Expand All @@ -55,25 +45,29 @@ func main() {
Destination: "<some_dest>",
}

resp, head, err := client.Block(&rpc.BlockIDHead{})
if err != nil {
fmt.Printf("failed to get (%s) head block: %s\n", resp.Status(), err.Error())
os.Exit(1)
}

op, err := forge.Encode(head.Hash, transaction.ToContent())
if err != nil {
fmt.Printf("failed to forge transaction: %s\n", err.Error())
os.Exit(1)
}

signature, err := key.Sign(keys.SignInput{
Message: op,
})
signature, err := key.SignHex(op)
if err != nil {
fmt.Printf("failed to sign operation: %s\n", err.Error())
os.Exit(1)
}

ophash, err := client.InjectionOperation(rpc.InjectionOperationInput{
Operation: fmt.Sprintf("%s%s", op, hex.EncodeToString(signature.Bytes)),
resp, ophash, err := client.InjectionOperation(rpc.InjectionOperationInput{
Operation: signature.AppendToHex(op),
})
if err != nil {
fmt.Printf("failed to inject: %s\n", err.Error())
fmt.Printf("failed to inject (%s): %s\n", resp.Status(), err.Error())
os.Exit(1)
}

Expand Down
Loading

0 comments on commit 5190840

Please sign in to comment.