Documentation
¶
Index ¶
- Variables
- func ConfirmEthereumTransaction(hash string, times int, duration time.Duration) (int, error)
- func ExitWithError(v ...interface{})
- func GetTransactionStatus(hash string) (int, error)
- func InitChainFromConfig(reader conf.Reader)
- func ReadConfig(configPath, configName string)
- func RestoreFromConfig(cfg *conf.Config)
- type Authorizer
- type AuthorizerNode
- type AuthorizerNodes
- type Bridge
- func (b *Bridge) BurnWZCN(ctx context.Context, amountTokens int64) (*types.Transaction, error)
- func (b *Bridge) BurnZCN(ctx context.Context) (*transaction.Transaction, error)
- func (b *Bridge) CreateEthClient() (*ethclient.Client, error)
- func (b *Bridge) CreateEthereumWallet() (*EthereumWallet, error)
- func (b *Bridge) CreateSignedTransaction(chainID *big.Int, client *ethclient.Client, fromAddress common.Address, ...) *bind.TransactOpts
- func (b *Bridge) GetEthereumAddress() ether.Address
- func (b *Bridge) GetEthereumWallet() *EthereumWallet
- func (b *Bridge) GetEthereumWalletInfo() (*EthWalletInfo, error)
- func (b *Bridge) GetKeysAddress() (common.Address, *ecdsa.PublicKey, *ecdsa.PrivateKey, error)
- func (b *Bridge) ID() string
- func (b *Bridge) IncreaseBurnerAllowance(ctx context.Context, amountWei wei) (*types.Transaction, error)
- func (b *Bridge) IncrementNonce() int64
- func (b *Bridge) MintWZCN(ctx context.Context, amountTokens wei, payload *ethereum.MintPayload) (*types.Transaction, error)
- func (b *Bridge) MintZCN(ctx context.Context, payload *zcnsc.MintPayload) (*transaction.Transaction, error)
- func (b *Bridge) QueryEthereumMintPayload(zchainBurnHash string) (*ethereum.MintPayload, error)
- func (b *Bridge) QueryZChainMintPayload(ethBurnHash string) (*zcnsc.MintPayload, error)
- func (b *Bridge) RestoreChain()
- func (b *Bridge) SetupChain()
- func (b *Bridge) SetupEthereumWallet()
- func (b *Bridge) SetupSDK(cfg chain.Config)
- func (b *Bridge) SetupWallet()
- type BridgeConfig
- type ClientConfig
- type EthWalletInfo
- type EthereumWallet
- type Instance
- type JobError
- type JobResult
- type JobStatus
- type ProofEthereumBurn
- type ProofZCNBurn
- type WZCNBurnEvent
Constants ¶
This section is empty.
Variables ¶
var ( DefaultClientIDEncoder = func(id string) []byte { return []byte(id) } )
Functions ¶
func ExitWithError ¶ added in v1.3.2
func ExitWithError(v ...interface{})
func GetTransactionStatus ¶
func InitChainFromConfig ¶ added in v1.3.2
func ReadConfig ¶ added in v1.3.2
func ReadConfig(configPath, configName string)
func RestoreFromConfig ¶ added in v1.3.2
Types ¶
type Authorizer ¶
type Authorizer struct {
}
type AuthorizerNode ¶
type AuthorizerNodes ¶
type AuthorizerNodes struct {
NodeMap map[string]*AuthorizerNode `json:"node_map"`
}
func GetAuthorizers ¶
func GetAuthorizers() (*AuthorizerNodes, error)
GetAuthorizers Returns authorizers
type Bridge ¶
type Bridge struct {
*BridgeConfig
*Instance
}
func SetupBridge ¶ added in v1.3.2
SetupBridge Use this from standalone application
func SetupBridgeFromConfig ¶
func SetupBridgeFromConfig() *Bridge
func (*Bridge) BurnWZCN ¶
BurnWZCN Burns WZCN tokens on behalf of the 0ZCN client amountTokens - ZCN tokens clientID - 0ZCN client ERC20 signature: "burn(uint256,bytes)"
func (*Bridge) BurnZCN ¶
func (b *Bridge) BurnZCN(ctx context.Context) (*transaction.Transaction, error)
func (*Bridge) CreateEthereumWallet ¶ added in v1.3.2
func (b *Bridge) CreateEthereumWallet() (*EthereumWallet, error)
func (*Bridge) CreateSignedTransaction ¶
func (*Bridge) GetEthereumAddress ¶
GetEthereumAddress returns ethereum wallet string
func (*Bridge) GetEthereumWallet ¶
func (b *Bridge) GetEthereumWallet() *EthereumWallet
GetEthereumWallet returns ethereum wallet string
func (*Bridge) GetEthereumWalletInfo ¶
func (b *Bridge) GetEthereumWalletInfo() (*EthWalletInfo, error)
func (*Bridge) GetKeysAddress ¶
func (*Bridge) IncreaseBurnerAllowance ¶
func (b *Bridge) 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 (*Bridge) IncrementNonce ¶
func (*Bridge) MintWZCN ¶
func (b *Bridge) MintWZCN(ctx context.Context, amountTokens wei, payload *ethereum.MintPayload) (*types.Transaction, error)
MintWZCN Mint ZCN tokens on behalf of the 0ZCN client amountTokens: ZCN tokens payload: received from authorizers
func (*Bridge) MintZCN ¶
func (b *Bridge) MintZCN(ctx context.Context, payload *zcnsc.MintPayload) (*transaction.Transaction, error)
func (*Bridge) QueryEthereumMintPayload ¶
func (b *Bridge) 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 (*Bridge) QueryZChainMintPayload ¶
func (b *Bridge) 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 (*Bridge) RestoreChain ¶ added in v1.3.2
func (b *Bridge) RestoreChain()
func (*Bridge) SetupChain ¶ added in v1.3.2
func (b *Bridge) SetupChain()
func (*Bridge) SetupEthereumWallet ¶
func (b *Bridge) SetupEthereumWallet()
func (*Bridge) SetupWallet ¶ added in v1.3.2
func (b *Bridge) SetupWallet()
SetupWallet Sets up the wallet and node Wallet setup reads keys from keyfile and registers in the 0chain
type BridgeConfig ¶
type BridgeConfig struct {
// Ethereum mnemonic (derivation of Ethereum owner, public and private key)
Mnemonic string
// Address of Ethereum bridge contract
BridgeAddress string
// Address of WZCN Ethereum wrapped token
WzcnAddress string
// URL of ethereum RPC node (infura or alchemy)
EthereumNodeURL string
// Ethereum chain ID
ChainID string
// Gas limit to execute ethereum transaction
GasLimit uint64
// Value to execute ZCN smart contracts
Value int64
// Authorizers required to confirm (in percents)
ConsensusThreshold int
}
BridgeConfig initializes Ethereum wallet and params
type ClientConfig ¶
func ReadClientConfigFromCmd ¶
func ReadClientConfigFromCmd() *ClientConfig
ReadClientConfigFromCmd reads config from command line
func (ClientConfig) BlockWorker ¶
func (c ClientConfig) BlockWorker() string
func (ClientConfig) LogDir ¶
func (c ClientConfig) LogDir() string
func (ClientConfig) LogLvl ¶
func (c ClientConfig) LogLvl() string
func (ClientConfig) SignatureScheme ¶
func (c ClientConfig) SignatureScheme() string
type EthWalletInfo ¶
type EthereumWallet ¶
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 string `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)