Skip to content

Commit

Permalink
Prepare for 0.10 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthieu Vachon committed Oct 16, 2021
1 parent 16e0fe3 commit 12388aa
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 80 deletions.
59 changes: 32 additions & 27 deletions CHANGELOG.md
Expand Up @@ -3,33 +3,11 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.10] (October 16th, 2021)

### Added
- Greatly improved performance of `NameToString` (`~230%`) method.
- `TimePoint` will decode with `0` nanoseconds, when the `fitNodeos` flag is set on the ABI.
- Ability to decode a `int128` and `uint128` in decimal format when `fitNodeos` flag is set on the ABI
- Ability to decode nested `arrays` in ABI decoder.
- Added `BlockState.Header` field of type `SignedBlockHeader` that was previously missing from the struct definition.
- Added `BlockState.AdditionalSignatures` field of type `[]ecc.Signature` that was previously missing from the struct definition.
- Added `ActionTrace.ContextFree` field of type `bool` that was previously missing from the struct definition.

### Fixed
- Optional encoding of primitive types.

A struct with a non-pointer type tagged with `eos:"optional"` is now properly encoded at the binary level. **Important** that means that for non-pointer type, when the value of the type is the "emtpy" value according to Golang rules, it will be written as not-present at the binary level. If it's something that you do want want, use a pointer to a primitive type. It's actually a good habit to use a pointer type for "optional" element anyway, to increase awarness.

- Fix json tags for delegatebw action data.
- Unpacking binary `Except` now correctly works.
- Unpacking binary `Action` and `ActionTrace` now correctly works.
- Unpacking binary `TransactionTrace` now correctly works.
- Unpacking binary `TransactionReceipt` type will now correctly set the inner `TransactionWithID.ID` field correctly.
- Unpacking binary `BlockState` now correctly works but is restricted to EOSIO 2.0.x version.

### Deprecated
- Renamed `JSONFloat64` to `Float64`, to follow the same convention that was changed years ago with `Uint64`, etc. Type alias left for backwards compatibility.
### Breaking Changes
- **BREAKING**: We started adding an initial `context.Context` to all interruptible functions. All method performing an HTTP call have the new parameter as well as a bunch of other method. We cannot list all of them. If the caller already have a `context.Context` value, pass it to the function that now require one. Otherwise, simply pass `context.Background()`.

### Changed
- **BREAKING**: Fixed binary unpacking of `BlockState`, `TransactionTrace`, `SignedTransaction`, `Action` (and some inner types). This required changing a few struct fields to better fit with EOSIO definition, here the full list:
- `MerkleRoot.ActiveNodes` is now a `[]Checksum256`, was previously `[]string`
- `MerkleRoot.NodeCount` is now a `uint64`, was previously `uint32`
Expand Down Expand Up @@ -58,6 +36,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- **BREAKING**: The serialization for `ExtendedAsset` was aligned with the `eos` codebase. Beforehand, it would serialize the field name `"Contract"` with a capital `C`, and the `Asset` field as `"asset"` where it should have been `"quantity"`.

- **BREAKING**: We started adding an initial `context.Context` to all interruptible functions. All method performing an HTTP call have the new parameter as well as a bunch of other method. We cannot list all of them. If the caller already have a `context.Context` value, pass it to the function that now require one. Otherwise, simply pass `context.Background()`.
### Added
- Added architecture to support binary decoding/encoding Variant objects, see []
- Greatly improved performance of `NameToString` (`~230%`) method.
- `TimePoint` will decode with `0` nanoseconds, when the `fitNodeos` flag is set on the ABI.
- Ability to decode a `int128` and `uint128` in decimal format when `fitNodeos` flag is set on the ABI
- Ability to decode nested `arrays` in ABI decoder.
- Added `BlockState.Header` field of type `SignedBlockHeader` that was previously missing from the struct definition.
- Added `BlockState.AdditionalSignatures` field of type `[]ecc.Signature` that was previously missing from the struct definition.
- Added `ActionTrace.ContextFree` field of type `bool` that was previously missing from the struct definition.
- Normalized all logging to use `streamingfast/logging` and its trace enabled support.

### Changed

- All errors are wrapped using `fmt.Errorf("...: %w", ..., err)` which is standard now in Go.
- All errors are wrapped using `fmt.Errorf("...: %w", ..., err)` which is standard now in Go.

### Fixed
- Optional encoding of primitive types.

A struct with a non-pointer type tagged with `eos:"optional"` is now properly encoded at the binary level. **Important** that means that for non-pointer type, when the value of the type is the "emtpy" value according to Golang rules, it will be written as not-present at the binary level. If it's something that you do want want, use a pointer to a primitive type. It's actually a good habit to use a pointer type for "optional" element anyway, to increase awarness.

- Fix json tags for delegatebw action data.
- Unpacking binary `Except` now correctly works.
- Unpacking binary `Action` and `ActionTrace` now correctly works.
- Unpacking binary `TransactionTrace` now correctly works.
- Unpacking binary `TransactionReceipt` type will now correctly set the inner `TransactionWithID.ID` field correctly.
- Unpacking binary `BlockState` now correctly works but is restricted to EOSIO 2.0.x version.

### Deprecated
- Renamed `AccountRAMDelta` to `AccountDelta` which is the correct name in EOSIO.
- Renamed `JSONFloat64` to `Float64`, to follow the same convention that was changed years ago with `Uint64`, etc. Type alias left for backwards compatibility.
69 changes: 44 additions & 25 deletions README-cn.md
@@ -1,11 +1,10 @@
用 Go 语言与 EOS.IO 交互的 API 库
=========================
## 用 Go 语言与 EOS.IO 交互的 API 库

[![GoDoc](https://godoc.org/github.com/eoscanada/eos-go?status.svg)](https://godoc.org/github.com/eoscanada/eos-go)

该库提供对数据架构(二进制打包和JSON接口)的简单访问,
以及对远程或本地运行的EOS.IO RPC服务器的API调用。
它提供钱包功能(KeyBag),或者可以通过 `keosd` 钱包签署交易。
以及对远程或本地运行的EOS.IO RPC服务器的API调用。
它提供钱包功能(KeyBag),或者可以通过 `keosd` 钱包签署交易。
它还明白端口9876上的P2P协议。

截至6月的发布之前,这个库不断的在变化。 先不要期望稳定性,
Expand All @@ -14,39 +13,59 @@
该库主网启动编排工具是 `eosio` 的基础,网址:
https://github.com/eoscanada/eos-bios


基本用法
-----------
### 基本用法

```go
api := eos.New("http://testnet1.eos.io")
package main

import (
"context"
"encoding/json"
"fmt"

eos "github.com/eoscanada/eos-go"
cli "github.com/streamingfast/cli"
)

func main() {
api := eos.New("https://api.eosn.io")
ctx := context.Background()

infoResp, err := api.GetInfo(ctx)
cli.NoError(err, "unable to get chain info")

infoResp, _ := api.GetInfo(ctx)
accountResp, _ := api.GetAccount(ctx, "initn")
fmt.Println("Permission for initn:", accountResp.Permissions[0].RequiredAuth.Keys)
fmt.Println("Chain Info", toJson(infoResp))

accountResp, _ := api.GetAccount(ctx, "eosio")
fmt.Println("Account Info", toJson(accountResp))
}

func toJson(v interface{}) string {
out, err := json.MarshalIndent(v, "", " ")
cli.NoError(err, "unable to marshal json")

return string(out)
}
```

`eosio.system``eosio.token`_Actions_ 合约分别在:
* https://github.com/eoscanada/eos-go/tree/master/system ([godocs](https://godoc.org/github.com/eoscanada/eos-go/system))
* https://github.com/eoscanada/eos-go/tree/master/token ([godocs](https://godoc.org/github.com/eoscanada/eos-go/token))
### 例子

范例
-------
#### 参考

看看库的用法的例子:
* API
* [获取链信息](./example_api_get_info_test.go)
* [转账代币](./example_api_transfer_eos_test.go)
* 解码/编码
* [解码表行](./example_abi_decode_test.go)

* https://github.com/eoscanada/eos-bios/blob/master/bios/bios.go
* https://github.com/eoscanada/eos-bios/blob/master/bios/ops.go
* `cmd/` 下还有一些其他的 `main` 工具包。
### 二进制文件

`cmd/` 下的 `main` 包中有一些二进制文件,主要围绕 P2P 通信。

召集开源贡献者
------------
### 召集开源贡献者

我们欢迎所有的开源贡献,直接用 GitHub-fu来提议、帮我们改进吧。


证书
-------
### 证书

MIT
68 changes: 41 additions & 27 deletions README.md
@@ -1,5 +1,4 @@
EOS.IO API library for Go
=========================
## EOS.IO API library for Go

[点击查看中文版](./README-cn.md)

Expand All @@ -19,38 +18,52 @@ This library is the basis for the `eos-bios` launch orchestrator tool
at https://github.com/eoscanada/eos-bios


Basic usage
-----------
### Basic usage

```go
api := eos.New("http://testnet1.eos.io")
package main

infoResp, _ := api.GetInfo(ctx)
accountResp, _ := api.GetAccount(ctx, "initn")
fmt.Println("Permission for initn:", accountResp.Permissions[0].RequiredAuth.Keys)
```
import (
"context"
"encoding/json"
"fmt"

`eosio.system` and `eosio.token` contract _Actions_ are respectively in:
* https://github.com/eoscanada/eos-go/tree/master/system ([godocs](https://godoc.org/github.com/eoscanada/eos-go/system))
* https://github.com/eoscanada/eos-go/tree/master/token ([godocs](https://godoc.org/github.com/eoscanada/eos-go/token))
eos "github.com/eoscanada/eos-go"
cli "github.com/streamingfast/cli"
)

Binaries
--------
func main() {
api := eos.New("https://api.eosn.io")
ctx := context.Background()

There is some binaries in `main` packages under `cmd/`, mainly around P2P communication.
infoResp, err := api.GetInfo(ctx)
cli.NoError(err, "unable to get chain info")

Example
-------
fmt.Println("Chain Info", toJson(infoResp))

accountResp, _ := api.GetAccount(ctx, "eosio")
fmt.Println("Account Info", toJson(accountResp))
}

### Reference
func toJson(v interface{}) string {
out, err := json.MarshalIndent(v, "", " ")
cli.NoError(err, "unable to marshal json")

return string(out)
}
```

### Examples

#### Reference

* API
* [Get Chain Information](./example_api_get_info_test.go)
* [Transfer Token](./example_api_transfer_eos_test.go)
* Decoding/Encoding
* [Decode Table Row](./example_abi_decode_test.go)

### Running
#### Running

The easiest way to see the actual output for a given example is to add a line
`// Output: any` at the very end of the test, looks like this for
Expand Down Expand Up @@ -84,20 +97,21 @@ requires having the authorizations and balance necessary to perform the
transaction. It's quite possible to run them through a development environment
however.

#### Environment Variables
### Binaries

There is some binaries in `main` packages under `cmd/`, mainly around P2P communication.

### Environment Variables

All examples uses by default the `https://mainnet.eos.dfuse.io` API endpoint for all
HTTP communication and `peering.mainnet.eoscanada.com` for P2P communication.
All examples uses by default the `https://api.eosn.io` API endpoint for all
HTTP communication and `peering.eosn.io` for P2P communication.
They can respectively be overridden by specifying environment variable
`EOS_GO_API_URL` and `EOS_GO_P2P_ENDPOINT` respectively.

Contributing
------------
### Contributing

Any contributions are welcome, use your standard GitHub-fu to pitch in and improve.


License
-------
### License

MIT
2 changes: 1 addition & 1 deletion blockslog/blockslog_test.go
Expand Up @@ -9,5 +9,5 @@ import (
func TestMe(t *testing.T) {
t.Skip("Update me so that it's not tied to a particular machine!")

require.NoError(t, Process("/home/abourget/dfuse/dfuse-eosio/proj/mainnet/mindreader/data/blocks/blocks.log"))
require.NoError(t, Process("/some/path/blocks.log"))
}

0 comments on commit 12388aa

Please sign in to comment.