Skip to content

Commit

Permalink
Merge pull request #12 from ultraio/BLOCK-2107-merge-antelope-3.2
Browse files Browse the repository at this point in the history
[BLOCK-2107] merge antelope 3.2
  • Loading branch information
keisuke-kanao authored Jan 22, 2024
2 parents d0b9f9f + 24eab71 commit ce0cb43
Show file tree
Hide file tree
Showing 55 changed files with 3,895 additions and 414 deletions.
17 changes: 17 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Optional -->
## Background
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->

## Summary
<!--- Provide a summary of your changes. -->
<!--- It's a good idea to include the issue you are trying to solve and how to fix it. -->

## Note
<!--- Add More if you need. -->

## Checklist

- [ ] Backward compatible?
- [ ] Test enough in your local environment?
- [ ] Add related test cases?
55 changes: 55 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build and Test

on:
push:
branches:
- develop
pull_request:
branches:
- "**"

jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x, 1.18.x, 1.19.x]
os: [ubuntu-latest, macos-latest]
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Check out code
uses: actions/checkout@v2

- name: Cache Go modules
uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
# Some of the parts in eos-go renders timezone specific dates and as such,
# some of our golden files contains them.
- name: Configure Timezone
uses: szenius/[email protected]
with:
timezoneLinux: "America/New_York"
timezoneMacos: "America/New_York"

- name: Run Tests
run: go test ./...

- name: Build
run: go build ./...
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.envrc
.idea
.DS_Store
.vscode
/dist
31 changes: 31 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
project_name: eos-go

env_files:
github_token: ~/.config/goreleaser/github_token

release:
github:
owner: eoscanada
name: eos-go
draft: true
name_template: '{{.Tag}}'
extra_files:
- glob: ./release/**/*

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'

builds:
- skip: true

archives:
- files:
- LICENSE
- README.md

snapshot:
name_template: "{{ .Tag }}-next"
5 changes: 0 additions & 5 deletions .travis.yml

This file was deleted.

134 changes: 109 additions & 25 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,86 @@
# Change log
## Change log

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]
### Unreleased

### 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.
* Added `action_trace_v1` field
* Added `AsTime` helper functions to convert `TimePoint` and `TimePointSec` to `time.Time`
* Added support for decoding action results
* Raised the minimum supporting Go version 1.13 -> 1.17
* Added unit tests of REST API
* Added `earliest_available_block_num`, `fork_db_head_block_num`, `fork_db_head_block_id`, `last_irreversible_block_time`, `total_cpu_weight`, `total_net_weight`, & `server_full_version_string` fields in `InfoResp`
* Added `head_block_num`, `head_block_time`, `rex_info`, `subjective_cpu_bill_limit`, & `eosio_any_linked_actions` fields in `AccountResp`
* Added the new type `RexInfo`, `LinkedAction`
* Added `linked_actions` in `Permission`
* Added `context_free_data` & `transaction` fields in `PackedTransaction`

### Fixed
- Optional encoding of primitive types.
#### Breaking Changes

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.
* `AccountResp.last_code_update` & `AccountResp.created` in `AccountResp` are now `BlockTimestamp`, were previously `JSONTime`

- 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.
#### Added

### Deprecated
- Renamed `JSONFloat64` to `Float64`, to follow the same convention that was changed years ago with `Uint64`, etc. Type alias left for backwards compatibility.
#### Changed

#### Fixed

* Fixed decoding of table rows with variant types.

* Fixed serialization of `map[K]V` when using `eos.MarshalBinary` so that ordering in which the keys are serialized is in lexicographical order, just like JSON serialization.

* Updated to latest version of `github.com/streamingfast/logging` library.

* Fix NewPrivateKey correctly working with PVT_K1 keys (#177)

* Fixed ABI encoder for `SymbolCode` type.

#### Deprecated

### [**0.10.2**](https://github.com/eoscanada/eos-go/releases/tag/v0.10.2) (January 19th, 2022)

#### Changed

* Changed ABI encoder `varuint32` to re-use existing encoder.

#### Fixed

* Fixed ABI encoder `varint32` types.

### [**0.10.1**](https://github.com/eoscanada/eos-go/releases/tag/v0.10.1) (January 19th, 2022)

#### Breaking Changes

* Renamed [`BlockTimestampFormat`](https://github.com/eoscanada/eos-go/blob/a1623cc5a2223005a4dc7d4dec972d6119de42ff/types.go#L844) to `blockTimestampFormat` making it private.

#### Added

* Add EOSIO Testnet symbol (#165)

* Update ActionResp (#166)

#### Changed

* Updated to latest version of `github.com/streamingfast/logging` library.

* `eos.MarshalBinary` will now refuses to serialize a `map[K]V` if `K`'s type is not comparable.

#### Fixed

* Fixed serialization of `map[K]V` types by sorting the keys to have a stable order.

* Bugfix StringToSymbol (44b6fbd)

* Fixed built-in examples (pointing by default to EOS Nation API nodes) (36114bd)

#### Deprecated

### [**0.10**](https://github.com/eoscanada/eos-go/releases/tag/v0.10.0) (October 16th, 2021)

#### 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 All @@ -50,14 +101,47 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `ExceptLogContext.Level` is now a `ExceptLogLevel`, was previously `string`.
- `ExceptLogContext.Line` is now a `uint64`, was previously `int`.

**Note** While those are flagged as breaking change to augment the visibility, they are really bug fixes to fit with the behavior of `nodeos` directly.
**Note** While those are flagged as breaking change to augment the visibility, they are really bug fixes to fit with the behavior of `nodeos` directly.

- **BREAKING**: The decoding for ABI `variant` was not returning the correct `json` representation. Now ABI `variant` is returned as a two elements array, the first element being the `variant` type name as a `string` and the second the actual value as JSON. For example, assuming a `variant` type defined as `game_type: ["string", "uint32"]`, and a `field` of type `game_type`, before, the JSON serialization would have looked like `{"field":"some_string"}` or `{"field":100}` while after the change, it will get serialized to the correct form `{"field":["string", "some_string"]}` or `{"field":["uint32", 100]}`.

**Note** While this is flagged as breaking change to augment the visibility, this is really a bug fix to fit with the behavior of `nodeos` directly.

- **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()`.
- **BREAKING**: Renamed `ConsoleLog` to `SafeString` for better re-usability in the codebase.

#### Added

- Proper handling for float precision in binary encoding/decoding.
- Added SHiP binary structures
- Added capabilities to read EOSIO Snapshot format (early implementation)
- 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.

#### 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.

- All errors are wrapped using `fmt.Errorf("...: %w", ..., err)` which is standard now in Go.
- 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
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit ce0cb43

Please sign in to comment.