# README
TFchain go client
- This library is a go implementation of a client for the TFChain.
- Internally, our own fork of https://github.com/centrifuge/go-substrate-rpc-client is used to make substrate rpc calls.
- Used in multiple repos like zos, rmb-go, and terraform-provider-grid.
Usage
To make substrate calls:
-
First, start a substrate connection against the desired url for the chain:
manager := NewManager("wss://tfchain.grid.tf/ws") substrateConnection, err := manager.Substrate()
-
These are the urls for different chain networks:
- devnet: wss://tfchain.dev.grid.tf/ws
- testnet: wss://tfchain.test.grid.tf/ws
- qanet: wss://tfchain.qa.grid.tf/ws
- mainnet: wss://tfchain.grid.tf/ws
-
It is the user's responsibility to close the connection.
defer substrateConnection.Close()
-
Then, a user could use the provided api calls to communicate with the chain. like:
contractID, err := substrateConnection.CreateNodeContract(identity, nodeID, body, hash, publicIPsCount, solutionProviderID)
-
Also, if a connection is closed for some reason like timing out, internally, it is reopened if nothing blocks.
-
All provided api calls are found under the Substrate struct.
Run tests
To run the tests, you could either run it against a local docker image of the TFChain, or against devnet
-
Run against local docker image
To run tests against a local docker image of tfchain, you need to set CI environment variable to anything actually.
docker run -d -p 9944:9944 threefolddev/tfchain:2.2.0-rc8 --dev --ws-external sleep 3 export CI="true" go test . -v
-
Run against devnet
unset CI go test . -v
Test Coverage
- 30.6% of statements
Workflows
# Functions
FromAddress creates an AccountID from a SS58 address.
No description provided by the author
NewHexHash will create a new hash from a hex input (32 bytes).
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ErrInvalidVersion is returned if version 4bytes is invalid.
No description provided by the author
No description provided by the author
ErrNotFound is returned if an object is not found.
No description provided by the author
ErrUnknownVersion is returned if version number is not supported.
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Balance.
No description provided by the author
No description provided by the author
BridgeBurnTransactionCreated.
BridgeBurnTransactionExpired.
No description provided by the author
No description provided by the author
BurnTransactionProcessed.
BurnTransactionProposed.
BurnTransactionReady.
BurnTransactionSignatureAdded.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Consumption structure.
DEPRECATED ConsumptionReportReceived.
Contract structure.
ContractBill structure.
ContractBilled.
ContractCreated is the contract created event.
ContractDeployed.
No description provided by the author
No description provided by the author
No description provided by the author
ContractState enum.
No description provided by the author
ContractUpdated is the contract updated event.
No description provided by the author
No description provided by the author
No description provided by the author
DiscountLevel enum.
Entity type.
No description provided by the author
EntityProof struct.
No description provided by the author
No description provided by the author
EventRecords is a struct that extends the default events with our events.
No description provided by the author
Farm type.
NodeCertification is a substrate enum.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
IPsFreed.
IPsReserved.
Location type.
to handle council member events that are not defined in base types.
MintCompleted.
No description provided by the author
MintTransactionExpired.
MintTransactionProposed.
MintTransactionVoted.
No description provided by the author
NameContractCanceled.
Node type.
NodeCertification is a substrate enum.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NodeContractCanceled.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Consumption structure.
ConsumptionReportReceived.
No description provided by the author
OptionBoardSerial type.
No description provided by the author
OptionFarmingPolicyLimit type.
No description provided by the author
OptionPublicConfig type.
OptionRelay type.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PublicConfig type.
PublicIP structure.
PublicIPInput structure.
No description provided by the author
RefundTransactionCreated.
RefundTransactionProcessed.
RefundTransactionReady.
RefundTransactionSignatureAdded.
No description provided by the author
RentContractCanceled.
Resources type.
Role type.
No description provided by the author
ServiceContract struct.
ServiceContractBill struct.
ServiceContractBilled.
ServiceContractCanceled.
ServiceContractCreated.
ServiceContractState enum.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Substrate client.
No description provided by the author
TokensBurned.
Twin struct.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
User from substrate.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Versioned base for all types.
No description provided by the author
No description provided by the author
# Type aliases
AccountID type.
No description provided by the author
No description provided by the author
numeric enum for unit.