diff --git a/README.md b/README.md
index 85aab0d..d41ccdf 100755
--- a/README.md
+++ b/README.md
@@ -1,41 +1,57 @@
-
+English | [简体中文](README_CN.md)
+
+
+
+
-# Go sdk for CESS network
+
CESS Network SDK for Go
+
+
[](#LICENSE)
-

+

[](https://pkg.go.dev/github.com/CESSProject/cess-go-sdk)
[](https://github.com/CESSProject/cess-go-sdk/actions/workflows/build&test.yml)
[](https://goreportcard.com/report/github.com/CESSProject/cess-go-sdk)
-The go sdk implementation of the CESS network, which provides RPC calls, status queries, block transactions and other functions.
+CESS Network SDK for Go allows you to access the CESS blockchain network, such as querying block data, transactions, and calling RPC methods. You don't need to deal with API related tasks such as signing and building requests to access the CESS blockchain network. It also allows you to access the storage network, such as uploading or downloading data directly from storage nodes, as well as implementations of file chunking, encryption, and redundancy.
-## 📝 Reporting Vulnerability
-If you find any system errors or you have better suggestions, please submit an issue or PR, or join the [CESS discord](https://discord.gg/mYHTMfBwNS) to communicate with us.
-
-## 📢 Announcement
-**CESS test network rpc endpoints**
+## Bulletin
+- Test Network RPC Endpoint
```
wss://testnet-rpc.cess.network/ws/
```
-## 🚰 CESS test network faucet
+- Test Network Faucet
```
https://www.cess.network/faucet.html
```
-## 🏗 Usage
+## Requirements
+Install a Go environment newer than 1.22.x.
+
+## Installation
-To get the package use the standard:
+Use `go get` to install SDK:
```sh
-go get "github.com/CESSProject/cess-go-sdk"
+go get -u "github.com/CESSProject/cess-go-sdk"
+```
+
+## Quick Use
+Quickly create your SDK client:
+```golang
+cli, err := sdkgo.New(
+ context.Background(),
+ sdkgo.ConnectRpcAddrs("wss://testnet-rpc.cess.network/ws/"),
+)
```
-## ✅ Testing
+
+## Testing
To run test:
@@ -43,10 +59,13 @@ To run test:
make check
```
-## 📖 Document
-
-- [Reference](https://pkg.go.dev/github.com/CESSProject/cess-go-sdk)
+## Documentation
- [Guidebook](https://doc.cess.network/developer/cess-sdk/sdk-golang)
+- [Reference](https://pkg.go.dev/github.com/CESSProject/cess-go-sdk)
+
+## Issues
+
+If you find any system errors or you have better suggestions, please submit an [issue](https://github.com/CESSProject/cess-go-sdk/issues/new) or PR, or join the [CESS discord](https://discord.gg/mYHTMfBwNS) to communicate with us.
## License
diff --git a/README_CN.md b/README_CN.md
new file mode 100644
index 0000000..73a869b
--- /dev/null
+++ b/README_CN.md
@@ -0,0 +1,79 @@
+
+
+
+
+
CESS Network SDK for Go
+
+
+
+[](#LICENSE)
+

+[](https://pkg.go.dev/github.com/CESSProject/cess-go-sdk)
+[](https://github.com/CESSProject/cess-go-sdk/actions/workflows/build&test.yml)
+[](https://goreportcard.com/report/github.com/CESSProject/cess-go-sdk)
+
+
+
+CESS Network SDK for Go 允许您访问CESS区块链网络,如查询区块数据、交易、调用RPC方法。您无需处理 API 相关任务(如签名和构建请求)即可访问CESS区块链网络。还允许您访问存储网络,如直接从存储节点上传或下载数据,以及文件分块,加密,冗余的实现。
+
+## 公告
+- 测试网RPC端点
+```
+wss://testnet-rpc.cess.network/ws/
+```
+
+- 测试网水龙头地址
+```
+https://www.cess.network/faucet.html
+```
+
+## 环境要求
+
+安装比 1.22.x 更新的Go环境。
+
+## 安装
+
+使用 `go get` 安装SDK:
+
+```sh
+go get -u "github.com/CESSProject/cess-go-sdk"
+```
+
+## 快速使用
+
+快速创建您的 SDK 客户端:
+```golang
+cli, err := sdkgo.New(
+ context.Background(),
+ sdkgo.ConnectRpcAddrs("wss://testnet-rpc.cess.network/ws/"),
+)
+```
+
+## 测试
+
+运行测试:
+
+```sh
+make check
+```
+
+## 文档
+
+- [Guidebook](https://doc.cess.network/developer/cess-sdk/sdk-golang)
+- [Reference](https://pkg.go.dev/github.com/CESSProject/cess-go-sdk)
+
+## 问题
+
+如果你发现任何系统错误或者有更好的建议,请提交[issue](https://github.com/CESSProject/cess-go-sdk/issues/new)或者PR,或者加入[CESS discord](https://discord.gg/mYHTMfBwNS)与我们交流。
+
+## License
+
+许可依据 [Apache 2.0](https://github.com/CESSProject/cess-go-sdk/blob/main/LICENSE)
+
+
+
+
+
+
+
+
diff --git a/cfg.go b/cfg.go
index 98d509e..c448010 100644
--- a/cfg.go
+++ b/cfg.go
@@ -12,7 +12,6 @@ import (
"time"
"github.com/CESSProject/cess-go-sdk/chain"
- "github.com/CESSProject/cess-go-sdk/config"
)
// Config describes a set of settings for a client
@@ -26,16 +25,12 @@ type Config struct {
// Option is a client config option that can be given to the client constructor
type Option func(cfg *Config) error
-// // Option is a client config option that can be given to the client constructor
-// type Option func(cfg *Config) error
+const DefaultName = "cess-sdk-go"
// NewSDK constructs a new client from the Config.
//
// This function consumes the config. Do not reuse it (really!).
func (cfg *Config) NewSDK(ctx context.Context) (chain.Chainer, error) {
- if cfg.Name == "" {
- cfg.Name = config.CharacterName_Default
- }
return chain.NewChainClient(ctx, cfg.Name, cfg.Rpc, cfg.Mnemonic, cfg.Timeout)
}
diff --git a/config/config.go b/config/config.go
deleted file mode 100755
index d66b581..0000000
--- a/config/config.go
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- Copyright (C) CESS. All rights reserved.
- Copyright (C) Cumulus Encrypted Storage System. All rights reserved.
-
- SPDX-License-Identifier: Apache-2.0
-*/
-
-package config
-
-const (
- // default name
- CharacterName_Default = "cess-sdk-go"
-)
diff --git a/defaults.go b/defaults.go
index 03c056b..c9eebf0 100755
--- a/defaults.go
+++ b/defaults.go
@@ -21,7 +21,12 @@ var DefaultRpcAddrs = func(cfg *Config) error {
// DefaultTimeout configures the default transaction waiting timeout
var DefaultTimeout = func(cfg *Config) error {
- return cfg.Apply(TransactionTimeout(time.Second * 30))
+ return cfg.Apply(TransactionTimeout(time.Second * 18))
+}
+
+// DefaultTimeout configures the default transaction waiting timeout
+var DefaultSDKName = func(cfg *Config) error {
+ return cfg.Apply(Name(DefaultName))
}
// Complete list of default options and when to fallback on them.
@@ -37,11 +42,14 @@ var defaults = []struct {
fallback: func(cfg *Config) bool { return cfg.Timeout == 0 },
opt: DefaultTimeout,
},
+ {
+ fallback: func(cfg *Config) bool { return cfg.Name == "" },
+ opt: DefaultSDKName,
+ },
}
-// FallbackDefaults applies default options to the libp2p node if and only if no
-// other relevant options have been applied. will be appended to the options
-// passed into New.
+// FallbackDefaults Default options are used if and only
+// if no other relevant options apply.
var FallbackDefaults Option = func(cfg *Config) error {
for _, def := range defaults {
if !def.fallback(cfg) {
diff --git a/sdk.go b/sdk.go
index f7e0c9b..509b0ef 100755
--- a/sdk.go
+++ b/sdk.go
@@ -13,26 +13,22 @@ import (
"github.com/CESSProject/cess-go-sdk/chain"
)
-// New constructs a new sdk client with the given options, falling back on
-// reasonable defaults. The defaults are:
+// NewDefault constructs a new SDK client using the given options and default options.
//
-// - If no rpc address is provided, the sdk client uses the default address
-// "wss://testnet-rpc.cess.network/ws/"
+// If no rpc endpoint are provided, use the default: “wss://testnet-rpc.cess.network/ws/”
//
-// - If no transaction timeout is provided, the sdk client uses the default
-// timeout: time.Duration(time.Second * 6)
+// If no transaction timeout are provided, use the default timeout: 18s
//
-// - The serviceName is used to specify the name of your service
+// If no name are provided, use the default name: cess-sdk-go
func New(ctx context.Context, opts ...Option) (chain.Chainer, error) {
return NewWithoutDefaults(ctx, append(opts, FallbackDefaults)...)
}
-// NewWithoutDefaults constructs a new client with the given options but
-// *without* falling back on reasonable defaults.
+// New constructs a new sdk client with the given options.
//
-// Warning: This function should not be considered a stable interface. We may
-// choose to add required services at any time and, by using this function, you
-// opt-out of any defaults we may provide.
+// If no rpc endpoint are provided, the CESS blockchain network cannot be accessed.
+//
+// If no account mnemonic are provided, block transactions cannot be conducted.
func NewWithoutDefaults(ctx context.Context, opts ...Option) (chain.Chainer, error) {
var cfg Config
if err := cfg.Apply(opts...); err != nil {