-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* update delete file and tee extrinsic * update Audit * update balance * update treasury * update filebank * update cfg * update oss * update storage handler * update sminer * update staking * update TeeWorker * update chain, rpc_call * update tee,treasury * update sign * update file * update sdk * update extrinsic_name * update sdk
- Loading branch information
Showing
46 changed files
with
6,871 additions
and
6,021 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
Oops, something went wrong.