Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Del file #206

Merged
merged 18 commits into from
May 12, 2024
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ If you find any system errors or you have better suggestions, please submit an i
wss://testnet-rpc0.cess.cloud/ws/
wss://testnet-rpc1.cess.cloud/ws/
wss://testnet-rpc2.cess.cloud/ws/
wss://testnet-rpc3.cess.cloud/ws/
```
**CESS test network bootstrap node**
```
_dnsaddr.boot-bucket-testnet.cess.cloud
_dnsaddr.boot-miner-testnet.cess.cloud
```

## 🚰 CESS test network faucet
Expand All @@ -38,19 +39,16 @@ https://testnet-faucet.cess.cloud/
To get the package use the standard:

```sh
go get -u "github.com/CESSProject/cess-go-sdk"
go get "github.com/CESSProject/cess-go-sdk"
```

## ✅ Testing

To run test:

1. Run a [CESS node](https://github.com/CESSProject/cess) locally.
2. Run the command

```sh
go test -v
```
```sh
make check
```

## 📖 Document

Expand Down
54 changes: 54 additions & 0 deletions cfg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
Copyright (C) CESS. All rights reserved.
Copyright (C) Cumulus Encrypted Storage System. All rights reserved.

SPDX-License-Identifier: Apache-2.0
*/

package sdkgo

import (
"context"
"time"

"github.com/CESSProject/cess-go-sdk/chain"
"github.com/CESSProject/cess-go-sdk/config"
)

// Config describes a set of settings for a client
type Config struct {
Rpc []string
Mnemonic string
Name string
Timeout time.Duration
}

// 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

// 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.ChainClient, error) {
if cfg.Name == "" {
cfg.Name = config.CharacterName_Default
}
return chain.NewChainClient(ctx, cfg.Name, cfg.Rpc, cfg.Mnemonic, cfg.Timeout)
}

// Apply applies the given options to the config, returning the first error
// encountered (if any).
func (cfg *Config) Apply(opts ...Option) error {
for _, opt := range opts {
if opt == nil {
continue
}
if err := opt(cfg); err != nil {
return err
}
}
return nil
}
Loading
Loading