Documentation ¶
Index ¶
- Constants
- Variables
- func AccountExists(homedir, address string) bool
- func ConfirmEthereumTransaction(hash string, times int, duration time.Duration) (int, error)
- func CreateHash(message string) common.Hash
- func CreateInitialClientConfig(filename, homedir, ethereumAddress, bridgeAddress, wzcnAddress, ... string, ...)
- func CreateInitialOwnerConfig(filename, homedir, ethereumAddress, bridgeAddress, wzcnAddress, ... string, ...)
- func CreateKeyStorage(homedir, password string) error
- func CreateSignedTransaction(chainID *big.Int, client *ethclient.Client, fromAddress common.Address, ...) *bind.TransactOpts
- func DeleteAccount(homedir, address string) bool
- func ExitWithError(v ...interface{})
- func GetAuthorizer(id string, cb zcncore.GetInfoCallback) (err error)
- func GetAuthorizers(cb zcncore.GetInfoCallback) (err error)
- func GetConfigDir() string
- func GetGlobalConfig(cb zcncore.GetInfoCallback) (err error)
- func GetTransactionStatus(hash string) (int, error)
- func ImportAccount(homedir, mnemonic, password string) (string, error)
- func ListStorageAccounts(homedir string) []common.Address
- func UpdateClientEthereumAddress(homedir, address string) (err error)
- type AuthorizerNode
- type AuthorizerNodesResponse
- type AuthorizerResponse
- type Bridge
- type BridgeClient
- func (b *BridgeClient) BurnWZCN(ctx context.Context, amountTokens int64) (*types.Transaction, error)
- func (b *BridgeClient) BurnZCN(ctx context.Context, amount int64) (*transaction.Transaction, error)
- func (b *BridgeClient) GetBalance() (*big.Int, error)
- func (b *BridgeClient) ID() string
- func (b *BridgeClient) IncreaseBurnerAllowance(ctx context.Context, amountWei Wei) (*types.Transaction, error)
- func (b *BridgeClient) IncrementNonce() int64
- func (b *BridgeClient) MintWZCN(ctx context.Context, payload *ethereum.MintPayload) (*types.Transaction, error)
- func (b *BridgeClient) MintZCN(ctx context.Context, payload *zcnsc.MintPayload) (*transaction.Transaction, error)
- func (b *BridgeClient) QueryEthereumMintPayload(zchainBurnHash string) (*ethereum.MintPayload, error)
- func (b *BridgeClient) QueryZChainMintPayload(ethBurnHash string) (*zcnsc.MintPayload, error)
- func (b *BridgeClient) SignWithEthereumChain(message string) ([]byte, error)
- func (b *BridgeClient) VerifyZCNTransaction(ctx context.Context, hash string) (*transaction.Transaction, error)
- type BridgeClientConfig
- type BridgeConfig
- type BridgeOwner
- type BridgeOwnerYaml
- type BridgeSDKConfig
- type ContractsRegistry
- type EthereumConfig
- type Instance
- type JobError
- type JobResult
- type JobStatus
- type ProofEthereumBurn
- type ProofZCNBurn
- type WZCNBurnEvent
- type Wei
Constants ¶
const ( BridgeClientConfigName = "bridge.yaml" OwnerClientConfigName = "owner.yaml" ZChainsClientConfigName = "config.yaml" EthereumWalletClientConfigName = "wallet.json" EthereumWalletStorageDir = "wallets" ClientConfigKeyName = "bridge" OwnerConfigKeyName = "owner" )
Variables ¶
var ( DefaultClientIDEncoder = func(id string) []byte { return []byte(id) } )
var Logger logger.Logger
Functions ¶
func AccountExists ¶ added in v1.3.5
AccountExists checks if account exists
func CreateHash ¶ added in v1.3.5
func CreateInitialClientConfig ¶ added in v1.3.6
func CreateInitialClientConfig( filename, homedir, ethereumAddress, bridgeAddress, wzcnAddress, ethereumNodeURL, password string, gas, value int64, consensus float64, )
CreateInitialClientConfig create initial config for the bridge client using argument, filename - where file is saved (default: HOME/.zcn), ethereumAddress - client Ethereum address (should be also registered in the local key storage), bridgeAddress - bridge contract address, wzcnAddress - token contract address, ethereumNodeURL - Ethereum node url (usually, Infura/Alchemy), gas - default gas value for Ethereum transaction, value - is a default value for Ethereum transaction, default is 0, consensus - is a consensus to find for burn/mint tickets
func CreateInitialOwnerConfig ¶ added in v1.3.6
func CreateInitialOwnerConfig( filename, homedir, ethereumAddress, bridgeAddress, wzcnAddress, authorizersAddress, ethereumNodeURL, password string, gas, value int64, )
CreateInitialOwnerConfig create initial config for the bridge owner using argument, filename - where file is saved (default: HOME/.zcn), ethereumAddress - client Ethereum address (should be also registered in the local key storage), bridgeAddress - bridge contract address, wzcnAddress - token contract address, authorizersAddress - authorizersAddress contract address, ethereumNodeURL - Ethereum node url (usually, Infura/Alchemy), gas - default gas value for Ethereum transaction, value - is a default value for Ethereum transaction, default is 0,
func CreateKeyStorage ¶ added in v1.3.5
CreateKeyStorage create, restore or unlock key storage
func CreateSignedTransaction ¶ added in v1.3.5
func DeleteAccount ¶ added in v1.4.7
DeleteAccount deletes account from wallet
func ExitWithError ¶ added in v1.3.2
func ExitWithError(v ...interface{})
func GetAuthorizer ¶ added in v1.7.1
func GetAuthorizer(id string, cb zcncore.GetInfoCallback) (err error)
GetAuthorizer returned authorizer by ID
func GetAuthorizers ¶
func GetAuthorizers(cb zcncore.GetInfoCallback) (err error)
GetAuthorizers Returns authorizers
func GetConfigDir ¶ added in v1.3.5
func GetConfigDir() string
func GetGlobalConfig ¶ added in v1.7.1
func GetGlobalConfig(cb zcncore.GetInfoCallback) (err error)
GetGlobalConfig Returns global config
func GetTransactionStatus ¶
func ImportAccount ¶ added in v1.3.5
ImportAccount inmports account using mnemonic
func ListStorageAccounts ¶ added in v1.3.5
ListStorageAccounts List available accounts
func UpdateClientEthereumAddress ¶ added in v1.4.2
UpdateClientEthereumAddress updates Ethereum address
Types ¶
type AuthorizerNode ¶
type AuthorizerNodesResponse ¶ added in v1.7.1
type AuthorizerNodesResponse struct {
Nodes []*AuthorizerNode `json:"nodes"`
}
type AuthorizerResponse ¶ added in v1.7.1
type AuthorizerResponse struct { AuthorizerID string `json:"id"` URL string `json:"url"` // Configuration Fee common.Balance `json:"fee"` // Geolocation Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` // Stats LastHealthCheck int64 `json:"last_health_check"` // stake_pool_settings DelegateWallet string `json:"delegate_wallet"` MinStake common.Balance `json:"min_stake"` MaxStake common.Balance `json:"max_stake"` NumDelegates int `json:"num_delegates"` ServiceCharge float64 `json:"service_charge"` }
type Bridge ¶
type Bridge struct {
Owner *BridgeOwnerYaml `yaml:"owner"`
}
type BridgeClient ¶ added in v1.3.5
type BridgeClient struct { *BridgeConfig *BridgeClientConfig *Instance }
func CreateBridgeClient ¶ added in v1.3.5
func CreateBridgeClient(cfg *viper.Viper) *BridgeClient
func SetupBridgeClientSDK ¶ added in v1.3.5
func SetupBridgeClientSDK(cfg *BridgeSDKConfig) *BridgeClient
SetupBridgeClientSDK Use this from standalone application 0Chain SDK initialization is required
func (*BridgeClient) BurnWZCN ¶ added in v1.3.5
func (b *BridgeClient) BurnWZCN(ctx context.Context, amountTokens int64) (*types.Transaction, error)
BurnWZCN Burns WZCN tokens on behalf of the 0ZCN client amountTokens - ZCN tokens clientID - 0ZCN client ERC20 signature: "burn(uint256,bytes)"
func (*BridgeClient) BurnZCN ¶ added in v1.3.5
func (b *BridgeClient) BurnZCN(ctx context.Context, amount int64) (*transaction.Transaction, error)
BurnZCN burns ZCN tokens before conversion from ZCN to WZCN as a first step
func (*BridgeClient) GetBalance ¶ added in v1.3.5
func (b *BridgeClient) GetBalance() (*big.Int, error)
GetBalance returns balance of the current client
func (*BridgeClient) IncreaseBurnerAllowance ¶ added in v1.3.5
func (b *BridgeClient) IncreaseBurnerAllowance(ctx context.Context, amountWei Wei) (*types.Transaction, error)
IncreaseBurnerAllowance Increases allowance for bridge contract address to transfer WZCN tokens on behalf of the token owner to the Burn TokenPool During the burn the script transfers amount from token owner to the bridge burn token pool Example: owner wants to burn some amount. The contract will transfer some amount from owner address to the pool. So the owner must call IncreaseAllowance of the WZCN token with 2 parameters: spender address which is the bridge contract and amount to be burned (transferred) ERC20 signature: "increaseAllowance(address,uint256)"
func (*BridgeClient) IncrementNonce ¶ added in v1.3.5
func (b *BridgeClient) IncrementNonce() int64
func (*BridgeClient) MintWZCN ¶ added in v1.3.5
func (b *BridgeClient) MintWZCN(ctx context.Context, payload *ethereum.MintPayload) (*types.Transaction, error)
MintWZCN Mint ZCN tokens on behalf of the 0ZCN client payload: received from authorizers
func (*BridgeClient) MintZCN ¶ added in v1.3.5
func (b *BridgeClient) MintZCN(ctx context.Context, payload *zcnsc.MintPayload) (*transaction.Transaction, error)
MintZCN mints ZCN tokens after receiving proof-of-burn of WZCN tokens
func (*BridgeClient) QueryEthereumMintPayload ¶ added in v1.3.5
func (b *BridgeClient) QueryEthereumMintPayload(zchainBurnHash string) (*ethereum.MintPayload, error)
QueryEthereumMintPayload gets burn ticket and creates mint payload to be minted in the Ethereum chain zchainBurnHash - Ethereum burn transaction hash
func (*BridgeClient) QueryZChainMintPayload ¶ added in v1.3.5
func (b *BridgeClient) QueryZChainMintPayload(ethBurnHash string) (*zcnsc.MintPayload, error)
QueryZChainMintPayload gets burn ticket and creates mint payload to be minted in the ZChain ethBurnHash - Ethereum burn transaction hash
func (*BridgeClient) SignWithEthereumChain ¶ added in v1.3.5
func (b *BridgeClient) SignWithEthereumChain(message string) ([]byte, error)
SignWithEthereumChain signs the digest with Ethereum chain signer taking key from the current user key storage
func (*BridgeClient) VerifyZCNTransaction ¶ added in v1.3.5
func (b *BridgeClient) VerifyZCNTransaction(ctx context.Context, hash string) (*transaction.Transaction, error)
VerifyZCNTransaction verifies 0CHain transaction
type BridgeClientConfig ¶ added in v1.3.5
type BridgeClientConfig struct { ContractsRegistry EthereumConfig EthereumAddress string Password string Homedir string }
func (*BridgeClientConfig) CreateSignedTransactionFromKeyStore ¶ added in v1.4.7
func (b *BridgeClientConfig) CreateSignedTransactionFromKeyStore(client *ethclient.Client, gasLimitUnits uint64) *bind.TransactOpts
type BridgeConfig ¶
type BridgeConfig struct {
ConsensusThreshold float64
}
type BridgeOwner ¶ added in v1.3.5
type BridgeOwner struct { *BridgeClientConfig *Instance }
func CreateBridgeOwner ¶ added in v1.3.5
func CreateBridgeOwner(cfg *viper.Viper) *BridgeOwner
func SetupBridgeOwnerSDK ¶ added in v1.3.5
func SetupBridgeOwnerSDK(cfg *BridgeSDKConfig) *BridgeOwner
SetupBridgeOwnerSDK Use this from standalone application to initialize bridge owner. 0Chain SDK initialization is not required in this case
func (*BridgeOwner) AddEthereumAuthorizer ¶ added in v1.3.5
func (b *BridgeOwner) AddEthereumAuthorizer(ctx context.Context, address common.Address) (*types.Transaction, error)
AddEthereumAuthorizer Adds authorizer to Ethereum bridge. Only contract deployer can call this method
func (*BridgeOwner) AddEthereumAuthorizers ¶ added in v1.3.5
func (b *BridgeOwner) AddEthereumAuthorizers(configDir string)
type BridgeOwnerYaml ¶ added in v1.3.6
type BridgeOwnerYaml struct { // KeyStorage unlock storage Password string `yaml:"Password"` // User's address EthereumAddress string `yaml:"EthereumAddress"` // Address of Ethereum bridge contract BridgeAddress string `yaml:"BridgeAddress"` // Address of WZCN token (Example: https://ropsten.etherscan.io/token/0x930E1BE76461587969Cb7eB9BFe61166b1E70244) WzcnAddress string `yaml:"WzcnAddress"` // Address of Authorizers smart contract AuthorizersAddress string `yaml:"AuthorizersAddress"` // URL of ethereum RPC node (infura or alchemy) EthereumNodeURL string `yaml:"EthereumNodeURL"` // Gas limit to execute ethereum transaction GasLimit int64 `yaml:"GasLimit"` // Value to execute ZCN smart contracts in wei Value int64 `yaml:"Value"` }
type BridgeSDKConfig ¶ added in v1.3.5
type BridgeSDKConfig struct { LogLevel *string LogPath *string ConfigBridgeFile *string ConfigChainFile *string ConfigDir *string Development *bool }
func ReadClientConfigFromCmd ¶
func ReadClientConfigFromCmd() *BridgeSDKConfig
ReadClientConfigFromCmd reads config from command line Bridge has several configs: Chain config at ~/.zcn/config.json User 0Chain wallet config at ~/.zcn/wallet.json User EthBridge config ~/.zcn/bridge.json Owner EthBridge config ~/.zcn/bridgeowner.json
type ContractsRegistry ¶ added in v1.3.5
type EthereumConfig ¶ added in v1.3.5
type EthereumConfig struct { // URL of ethereum RPC node (infura or alchemy) EthereumNodeURL string // Gas limit to execute ethereum transaction GasLimit uint64 // Value to execute Ethereum smart contracts (default = 0) Value int64 }
func (*EthereumConfig) CreateEthClient ¶ added in v1.3.5
func (b *EthereumConfig) CreateEthClient() (*ethclient.Client, error)
type JobError ¶
type JobError struct {
// contains filtered or unexported fields
}
JobError result of internal request wrapped in authorizer job
func (*JobError) MarshalJSON ¶
func (*JobError) UnmarshalJSON ¶
type JobResult ¶
type JobResult interface { // Error = Status of Authorizer job Error() error // Data returns the actual result Data() interface{} // SetAuthorizerID Assigns authorizer ID to the Job SetAuthorizerID(ID string) // GetAuthorizerID returns authorizer ID GetAuthorizerID() string }
JobResult = Authorizer task result, it wraps actual result of the query inside authorizer
type ProofEthereumBurn ¶
type ProofEthereumBurn struct { TxnID string `json:"ethereum_txn_id"` Nonce int64 `json:"nonce"` Amount int64 `json:"amount"` ReceivingClientID string `json:"receiving_client_id"` // 0ZCN address Signature string `json:"signature"` }
ProofEthereumBurn Authorizer returns this type for Ethereum transaction
type ProofZCNBurn ¶
type ProofZCNBurn struct { AuthorizerID string `json:"authorizer_id,omitempty"` TxnID string `json:"0chain_txn_id"` Nonce int64 `json:"nonce"` Amount int64 `json:"amount"` EthereumAddress string `json:"ethereum_address"` Signature []byte `json:"signatures"` }
ProofZCNBurn Authorizer returns this type for ZCN transaction
func (*ProofZCNBurn) Data ¶
func (r *ProofZCNBurn) Data() interface{}
func (*ProofZCNBurn) Error ¶
func (r *ProofZCNBurn) Error() error
func (*ProofZCNBurn) GetAuthorizerID ¶
func (r *ProofZCNBurn) GetAuthorizerID() string
func (*ProofZCNBurn) SetAuthorizerID ¶
func (r *ProofZCNBurn) SetAuthorizerID(id string)
type WZCNBurnEvent ¶
type WZCNBurnEvent struct { // AuthorizerID Authorizer ID AuthorizerID string `json:"authorizer_id,omitempty"` // BurnTicket Returns burn ticket BurnTicket *ProofEthereumBurn `json:"ticket,omitempty"` // Err gives error of job on server side Err *JobError `json:"err,omitempty"` // Status gives job status on server side (authoriser) Status JobStatus `json:"status,omitempty"` }
WZCNBurnEvent returned from burn ticket handler of: /v1/ether/burnticket/get
func (*WZCNBurnEvent) Data ¶
func (r *WZCNBurnEvent) Data() interface{}
func (*WZCNBurnEvent) Error ¶
func (r *WZCNBurnEvent) Error() error
func (*WZCNBurnEvent) GetAuthorizerID ¶
func (r *WZCNBurnEvent) GetAuthorizerID() string
func (*WZCNBurnEvent) SetAuthorizerID ¶
func (r *WZCNBurnEvent) SetAuthorizerID(id string)