gosdk

package module
v0.0.0-...-025e626 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 9, 2023 License: Apache-2.0 Imports: 37 Imported by: 0

README

fbc Go SDK

fbc Go SDK is a lightweight Go library to interact with fbc.

1. Components

  • client.go - The main client of GO SDK is created in this file. Developers are supposed to set up the config with own requirement during the client creation.
  • expose - Abstraction with the interfaces of each module. The implements of it are filled in the folder module.
  • module - The main logic for GO SDK queries and txs are classified by their own module names in fbc. Developers can find out the concrete designs under the specific module folder. Please focus on the files, tx.go and query.go.
  • mocks - Mock client tools for unit test of the main client in GO SDK.
  • sample - A clear short user guide.
  • types - The necessary struct set of fbc is built here. Developers are allowed to import some basic types like Dec and AccAddress directly if they want.
  • utils - A useful tool set for the one who is going to send more transactions and queries, is spilt by module names as the file names. Beyond, the operation of account keys with mnemonics remains in the file account.go.

2. Installation

Go version above 1.15 is required.

The developer can get the fbc Go SDK directly by git clone from github : https://github.com/okex/fbc-go-sdk

3. API

The api functions of transactions and queries are all under the path expose. You can find more details in fbc-docs : https://fbc-docs.readthedocs.io/en/latest/api/sdk/go-sdk.html

4. Tendermint query

fbc Go SDK also provides node query functions so that the underlying information of the blockchain is available for developers.

The tendermint query functions could be found in the file exposed/tendermint.go . Developers could make it through with the file module/tendermint/query.go and get clear how to invoke them.

5. Example

Client seems necessary to every operation with Go SDK. Here are the examples :

	// rpcURL should be modified according to the actual situation
	rpcURL   = "https://rpc.fibochain.org"
	name     = "alice"
	passWd   = "12345678"
	mnemonic = "giggle sibling fun arrow elevator spoon blood grocery laugh tortoise culture tool"
	addr     = "fb1qj5c07sm6jetjz8f509qtrxgh4psxkv3htfcuj"
	
	// build the client with own config
	config, _ := sdk.NewClientConfig(rpcURL, "fbc-1230", sdk.BroadcastBlock, "0.00002fibo", 200000, 0, "")
	client := sdk.NewClient(config)

	// create your account key info by 'name','passWd' and 'mnemonic'
	keyInfo, _, _ := utils.CreateAccountWithMnemo(mnemonic, name, passWd)

	// get info of your account from fbc
	accInfo, _ := client.Auth().QueryAccount(keyInfo.GetAddress().String())

	// transfer some fibo to addr
	res, _ := client.Token().Send(keyInfo, passWd, addr, "0.1024fibo", "my memo", accInfo.GetAccountNumber(), accInfo.GetSequence())

You can invoke more and more api functions with the object client.

6. Testing

All changes and addition of codes will be pushed with unit tests strictly.

7. Contributing

No doubt that it's admirable to make contributions to fbc Go SDK. You can provide your code as long as you have tested it with a local client and your unit test showed its validity.

Documentation

Index

Constants

View Source
const (
	BroadcastSync  = types.BroadcastSync
	BroadcastAsync = types.BroadcastAsync
	BroadcastBlock = types.BroadcastBlock

	// vote for the proposal
	VoteYes        = "yes"
	VoteAbstain    = "abstain"
	VoteNo         = "no"
	VoteNoWithVeto = "no_with_veto"
)

const

Variables

View Source
var (
	// NewClientConfig gives an easy way for the callers to set client config
	NewClientConfig = types.NewClientConfig
)

Functions

func NewEthClient

func NewEthClient(ctx context.Context, rawurl string) (*ethClient, error)

Types

type Account

type Account = auth.Account

auth

type Block

type Block = tendermint.Block

tendermint

type BlockResults

type BlockResults = tendermint.ResultBlockResults

nolint

type BookRes

type BookRes = order.BookRes

order

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client - structure of the main client of FbChain GoSDK

func NewClient

func NewClient(config gosdktypes.ClientConfig) Client

NewClient creates a new instance of Client

func (*Client) AmmSwap

func (cli *Client) AmmSwap() exposed.AmmSwap

nolint

func (*Client) Auth

func (cli *Client) Auth() exposed.Auth

func (*Client) Dex

func (cli *Client) Dex() exposed.Dex

func (*Client) Distribution

func (cli *Client) Distribution() exposed.Distribution

func (*Client) Evm

func (cli *Client) Evm() exposed.Evm

func (*Client) Farm

func (cli *Client) Farm() exposed.Farm

func (*Client) Feesplit

func (cli *Client) Feesplit() exposed.Feesplit

func (*Client) GetConfig

func (cli *Client) GetConfig() gosdktypes.ClientConfig

GetConfig returns the client config

func (*Client) Governance

func (cli *Client) Governance() exposed.Governance

func (*Client) Ibc

func (cli *Client) Ibc() exposed.Ibc

func (*Client) Order

func (cli *Client) Order() exposed.Order

func (*Client) Slashing

func (cli *Client) Slashing() exposed.Slashing

func (*Client) Staking

func (cli *Client) Staking() exposed.Staking

func (*Client) Tendermint

func (cli *Client) Tendermint() exposed.Tendermint

func (*Client) Token

func (cli *Client) Token() exposed.Token

type DelegatorResponse

type DelegatorResponse = staking.DelegatorResponse

nolint

type FarmPool

type FarmPool = farm.FarmPool

farm

type LockInfo

type LockInfo = farm.LockInfo

nolint

type OrderDetail

type OrderDetail = order.OrderDetail

nolint

type Proposal

type Proposal = governance.Proposal

governance

type QueryResCode

type QueryResCode = evm.QueryResCode

evm

type QueryResStorage

type QueryResStorage = evm.QueryResStorage

nolint

type ResultCommit

type ResultCommit = tendermint.ResultCommit

nolint

type ResultTx

type ResultTx = tendermint.ResultTx

nolint

type ResultTxSearch

type ResultTxSearch = tendermint.ResultTxSearch

nolint

type ResultValidators

type ResultValidators = tendermint.ResultValidators

nolint

type SwapTokenPair

type SwapTokenPair = ammswap.SwapTokenPair

ammswap

type TokenPair

type TokenPair = dex.TokenPair

dex

type TokenResp

type TokenResp = token.TokenResp

token

type TxResponse

type TxResponse = sdk.TxResponse

nolint

type Validator

type Validator = staking.Validator

staking

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL