diff --git a/chain/chain.go b/chain/chain.go index 53b42f5..ace6692 100644 --- a/chain/chain.go +++ b/chain/chain.go @@ -152,7 +152,7 @@ func (c *ChainSDK) GetTokenSymbol() string { return c.tokenSymbol } -func (c *ChainSDK) GetCharacterName() string { +func (c *ChainSDK) GetRoleName() string { return c.name } diff --git a/config/config.go b/config/config.go index 9320305..735ec64 100644 --- a/config/config.go +++ b/config/config.go @@ -36,13 +36,13 @@ const ( // NewSDK constructs a new client from the Config. // // This function consumes the config. Do not reuse it (really!). -func (cfg *Config) NewSDK(characterName string) (sdk.SDK, error) { - if characterName != CharacterName_Bucket && - characterName != CharacterName_Deoss && - characterName != CharacterName_Client { +func (cfg *Config) NewSDK(roleName string) (sdk.SDK, error) { + if roleName != CharacterName_Bucket && + roleName != CharacterName_Deoss && + roleName != CharacterName_Client { return nil, fmt.Errorf("invalid character name") } - return chain.NewChainSDK(characterName, cfg.Rpc, cfg.Mnemonic, cfg.Timeout) + return chain.NewChainSDK(roleName, cfg.Rpc, cfg.Mnemonic, cfg.Timeout) } // Apply applies the given options to the config, returning the first error diff --git a/core/sdk/sdk.go b/core/sdk/sdk.go index f68952f..6f443a7 100644 --- a/core/sdk/sdk.go +++ b/core/sdk/sdk.go @@ -162,8 +162,11 @@ type SDK interface { // SetChainState sets the state of the chain node. SetChainState(state bool) - // GetCharacterName returns the character name. - GetCharacterName() string + // GetRoleName returns the role name. + GetRoleName() string + + // GetTokenSymbol returns the token symbol + GetTokenSymbol() string // Reconnect for reconnecting chains. Reconnect() error diff --git a/defaults.go b/defaults.go index 092f684..0368e7f 100644 --- a/defaults.go +++ b/defaults.go @@ -9,7 +9,7 @@ package sdkgo import "github.com/CESSProject/sdk-go/core/pattern" -// DefaultRpcAddrs configures client to use default RPC address. +// DefaultRpcAddrs configures the default rpc address var DefaultRpcAddrs = func(cfg *Config) error { rpcAddrs := []string{ "wss://testnet-rpc0.cess.cloud/ws/", @@ -18,15 +18,12 @@ var DefaultRpcAddrs = func(cfg *Config) error { return cfg.Apply(ConnectRpcAddrs(rpcAddrs)) } -// DefaultListenPort configures client to use default listen port. +// DefaultTimeout configures the default transaction waiting timeout var DefaultTimeout = func(cfg *Config) error { return cfg.Apply(TransactionTimeout(pattern.BlockInterval)) } // Complete list of default options and when to fallback on them. -// -// Please *DON'T* specify default options any other way. Putting this all here -// makes tracking defaults *much* easier. var defaults = []struct { fallback func(cfg *Config) bool opt Option diff --git a/examples.go b/examples.go index 4c7f53e..dd4284c 100644 --- a/examples.go +++ b/examples.go @@ -36,7 +36,7 @@ func Example_RegisterDeoss() { if err != nil { panic(err) } - txhash, _, err := cli.Register(cli.GetCharacterName(), cli.GetSignatureAccPulickey(), "", 0) + txhash, _, err := cli.Register(cli.GetRoleName(), cli.GetSignatureAccPulickey(), "", 0) if err != nil { panic(err) } @@ -53,7 +53,7 @@ func Example_RegisterStorageNode() { if err != nil { panic(err) } - txhash, _, err := cli.Register(cli.GetCharacterName(), cli.GetSignatureAccPulickey(), "cXxxx...xxx", 100000) + txhash, _, err := cli.Register(cli.GetRoleName(), cli.GetSignatureAccPulickey(), "cXxxx...xxx", 100000) if err != nil { panic(err) } diff --git a/options.go b/options.go index 044c991..eedbdc4 100644 --- a/options.go +++ b/options.go @@ -13,8 +13,7 @@ import ( "github.com/CESSProject/sdk-go/core/pattern" ) -// ConnectRpcAddrs configures client to connect to the given RPC -// addresses. +// ConnectRpcAddrs configuration rpc address func ConnectRpcAddrs(s []string) Option { return func(cfg *Config) error { cfg.Rpc = s @@ -22,7 +21,7 @@ func ConnectRpcAddrs(s []string) Option { } } -// Workspace configures client to use the given workspace. +// Mnemonic configures the mnemonic of the signature account func Mnemonic(mnemonic string) Option { return func(cfg *Config) error { cfg.Mnemonic = mnemonic @@ -30,7 +29,7 @@ func Mnemonic(mnemonic string) Option { } } -// TransactionTimeout configures the transaction timeout period. +// TransactionTimeout configures the waiting timeout for a transaction func TransactionTimeout(timeout time.Duration) Option { return func(cfg *Config) error { if timeout < pattern.BlockInterval {