Documentation
¶
Index ¶
- Variables
- func GenerateEthAccount() (address string, privateKey string, err error)
- func NewProvider(backend Backend) *provider
- func Version() struct{ ... }
- func VersionNum() int
- func VersionStr() string
- type Account
- type Address
- type Backend
- type Hash
- type Manager
- func (manager *Manager) ClaimTFC(ctx context.Context, amount *big.Int, nonce *big.Int, signature string, ...) (doneCh chan interface{}, errCh chan error)
- func (manager *Manager) ClaimTFCSync(ctx context.Context, amount *big.Int, nonce *big.Int, signature string, ...) (err error)
- func (manager *Manager) GetUnusedNonce() (nonce *big.Int, err error)
- func (manager *Manager) IsNonceUsed(nonce *big.Int) (used bool, err error)
- func (manager *Manager) SignTFCClaim(recipient Address, amount *big.Int, nonce *big.Int, signer *Account) (signature string, err error)
- func (manager *Manager) Signer() (signerAddress Address, err error)
- func (manager *Manager) TFCAddress() (tfcAddress Address, err error)
- func (manager *Manager) UntilClaimTFCComplete(ctx context.Context, recipient Address, amount *big.Int, nonce *big.Int, ...) (doneCh chan interface{}, errCh chan error)
- type MockBackend
- type MockEthereum
- type SDK
- func (p SDK) AsyncTransaction(ctx context.Context, txHash common.Hash, confirmationNumber int) (receiptCh chan *types.Receipt, errCh chan error)
- func (sdk *SDK) CreateAccount() (account *Account)
- func (sdk *SDK) DefaultAccount() *Account
- func (sdk *SDK) DeployManager(ctx context.Context, deployer *Account) (managerAddressCh chan Address, errCh chan error)
- func (sdk *SDK) DeployManagerSync(ctx context.Context, deployer *Account) (managerAddress Address, err error)
- func (sdk *SDK) DeployTFC(ctx context.Context, deployer *Account) (tfcAddressCh chan Address, errCh chan error)
- func (sdk *SDK) DeployTFCSync(ctx context.Context, deployer *Account) (tfcAddress Address, err error)
- func (sdk *SDK) Manager(managerAddress Address) (manager *Manager, err error)
- func (sdk *SDK) RetrieveAccount(privateKey string) (account *Account, err error)
- func (sdk *SDK) SetDefaultAccount(privateKey string) (err error)
- func (sdk *SDK) TFC(tfcAddress Address) (tfc *TFC, err error)
- func (sdk *SDK) Version() struct{ ... }
- type TFC
- func (tfc *TFC) Allowance(owner Address, spender Address) (amount *big.Int, err error)
- func (tfc *TFC) Approve(ctx context.Context, spender Address, amount *big.Int, sender *Account) (doneCh chan interface{}, errCh chan error)
- func (p TFC) AsyncTransaction(ctx context.Context, txHash common.Hash, confirmationNumber int) (receiptCh chan *types.Receipt, errCh chan error)
- func (tfc *TFC) BalanceOf(address Address) (balance *big.Int, err error)
- func (tfc *TFC) BridgeTFCExchange(ctx context.Context, depositTransactionHash string, amount *big.Int, ...) (recipient Address, transactionHashErr error, doneCh chan interface{}, ...)
- func (tfc *TFC) BridgeTFCExchangeAsync(ctx context.Context, depositTransactionHash string, amount *big.Int, ...) (recipient Address, mintTransactionHash string, err error)
- func (tfc *TFC) CheckTransactionFeeDeposit(ctx context.Context, depositTransactionHash string, ...) (recipient Address, depositAmount *big.Int, err error)
- func (tfc *TFC) Decimals() (decimals uint8, err error)
- func (tfc *TFC) EstimateTFCExchangeFee(ctx context.Context, recipient Address, amount *big.Int, ...) (requiredTransferAmount *big.Int, estimatedGas uint64, gasPrice *big.Int, ...)
- func (tfc *TFC) Mint(ctx context.Context, to Address, amount *big.Int, sender *Account) (doneCh chan interface{}, errCh chan error)
- func (tfc *TFC) MintSync(ctx context.Context, to Address, amount *big.Int, sender *Account) (err error)
- func (tfc *TFC) Name() (name string, err error)
- func (tfc *TFC) SendMintTransaction(ctx context.Context, recipient Address, amount *big.Int, minter *Account, ...) (mintTransactionHash string, err error)
- func (tfc *TFC) Symbol() (symbol string, err error)
- func (tfc *TFC) TotalSupply() (totalSupply *big.Int, err error)
- func (tfc *TFC) Transfer(ctx context.Context, to Address, amount *big.Int, sender *Account) (doneCh chan interface{}, errCh chan error)
- func (tfc *TFC) TransferFrom(ctx context.Context, from Address, to string, amount *big.Int, sender *Account) (doneCh chan interface{}, errCh chan error)
- func (tfc *TFC) TransferSync(ctx context.Context, to Address, amount *big.Int, sender *Account) (err error)
- func (tfc *TFC) UntilBridgeTFCExchangeComplete(ctx context.Context, mintTransactionHash string, confirmationRequirement int) (doneCh chan interface{}, errCh chan error)
Constants ¶
This section is empty.
Variables ¶
var ( UnknownTransactionHashErr = errors.New("unknown transaction hash") UnconfirmedTransactionErr = errors.New("transaction does not have enough block confirmation") InsufficientBalanceErr = errors.New("account does not have enough balance") InsufficientGasErr = errors.New("insufficient gas for transaction") InsufficientTransactionFeeErr = errors.New("transaction fee is not enough to cover gas * gas price") InvalidDepositErr = errors.New("transaction fee deposit is invalid") )
var ( UnimplementedError = errors.New("unimplemented") NoPrivateKeyError = errors.New("no private key is provided") InvalidPrivateKeyError = errors.New("invalid private key") InvalidAddressError = errors.New("invalid Ethereum address") )
var ConfirmationRequirement = 0
var PredefinedAccounts = make([]*Account, len(PredefinedPrivateKeys))
var PredefinedPrivateKeys = []string{
"0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d",
"0x6cbed15c793ce57650b9877cf6fa156fbef513c4e6134f022a85b1ffdd59b2a1",
"0x6370fd033278c143179d81c5526140625662b8daa446c22ee2d73db3707e620c",
"0x646f1ce2fdad0e6deeeb5c7e8e5543bdde65e86029e2fd9fc169899c440a7913",
"0xadd53f9a7e588d003326d1cbf9e4a43c061aadd9bc938c843a79e7b4fd2ad743",
"0x395df67f0c2d2d9fe1ad08d1bc8b6627011959b79c53d7dd6a3536a33ab8a4fd",
"0xe485d098507f54e7733a205420dfddbe58db035fa577fc294ebd14db90767a52",
"0xa453611d9419d0e56f499079478fd72c37b251a94bfde4d19872c44cf65386e3",
"0x829e924fdf021ba3dbbc4225edfece9aca04b929d6e75613329ca6f1d31c0bb4",
"0xb0057716d5917badaf911b193b12b910811c1497b5bada8d7711f758981c3773",
}
Functions ¶
func GenerateEthAccount ¶
* Generate a ethereum Account. If any error happens inside, the third return value, err, will be non-nil. Otherwise err will be nil, with the first and second return value being Address and privateKey of the generated Account.
func NewProvider ¶ added in v0.0.3
func NewProvider(backend Backend) *provider
func VersionNum ¶ added in v0.0.8
func VersionNum() int
func VersionStr ¶ added in v0.0.8
func VersionStr() string
Types ¶
type Account ¶ added in v0.0.3
type Account struct {
// contains filtered or unexported fields
}
func (*Account) PrivateKey ¶ added in v0.0.3
type Manager ¶ added in v0.0.3
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶ added in v0.0.3
* Create a new TFC instance by providing the sdk object and the Address of TFC ERC20 contract
func (*Manager) ClaimTFCSync ¶ added in v0.0.3
func (*Manager) GetUnusedNonce ¶ added in v0.0.3
func (*Manager) IsNonceUsed ¶ added in v0.0.3
func (*Manager) SignTFCClaim ¶ added in v0.0.3
func (*Manager) TFCAddress ¶ added in v0.0.3
* Returns the name of the token, i.e. TFCToken
type MockBackend ¶ added in v0.0.3
type MockBackend struct { *backends.SimulatedBackend // contains filtered or unexported fields }
func NewMockBackend ¶ added in v0.0.3
func NewMockBackend() *MockBackend
func (*MockBackend) SendTransaction ¶ added in v0.0.3
func (b *MockBackend) SendTransaction(ctx context.Context, tx *types.Transaction) error
func (*MockBackend) SubscribeNewTransaction ¶ added in v0.0.3
func (b *MockBackend) SubscribeNewTransaction(ch chan *types.Transaction) event.Subscription
type MockEthereum ¶ added in v0.0.3
type MockEthereum struct { Backend *MockBackend // contains filtered or unexported fields }
func NewMockEthereum ¶ added in v0.0.3
func NewMockEthereum() *MockEthereum
func (*MockEthereum) Start ¶ added in v0.0.3
func (eth *MockEthereum) Start()
func (*MockEthereum) Stop ¶ added in v0.0.3
func (eth *MockEthereum) Stop()
type SDK ¶
type SDK struct {
// contains filtered or unexported fields
}
func NewSDKWithBackend ¶ added in v0.0.3
func (SDK) AsyncTransaction ¶ added in v0.0.3
func (*SDK) CreateAccount ¶ added in v0.0.3
func (*SDK) DefaultAccount ¶ added in v0.0.2
* DefaultAccount returns the current default Account in sdk (can be set via SetDefaultAccount())
func (*SDK) DeployManager ¶ added in v0.0.3
func (*SDK) DeployManagerSync ¶ added in v0.0.3
func (*SDK) DeployTFCSync ¶ added in v0.0.3
func (*SDK) RetrieveAccount ¶ added in v0.0.3
func (*SDK) SetDefaultAccount ¶ added in v0.0.2
setDefaultAccount sets the default Account to sign ethereum transactions by providing its privateKey
type TFC ¶
type TFC struct {
// contains filtered or unexported fields
}
func NewTFC ¶
* Create a new TFC instance by providing the sdk object and the Address of TFC ERC20 contract
func (*TFC) Approve ¶
func (tfc *TFC) Approve(ctx context.Context, spender Address, amount *big.Int, sender *Account) (doneCh chan interface{}, errCh chan error)
* Allows spender to withdraw from the current Account (specified in SDK) multiple times, up to the given amount.
This function requires privateKey has been set in SDK.
func (TFC) AsyncTransaction ¶ added in v0.0.3
func (*TFC) BridgeTFCExchange ¶ added in v0.1.0
func (*TFC) BridgeTFCExchangeAsync ¶ added in v0.1.2
func (*TFC) CheckTransactionFeeDeposit ¶ added in v0.2.0
func (*TFC) Decimals ¶
* Returns the number of decimals the token uses - e.g. 8, means to divide the token amount by 100000000 to get its user representation.
func (*TFC) EstimateTFCExchangeFee ¶ added in v0.2.0
func (*TFC) Mint ¶
func (tfc *TFC) Mint(ctx context.Context, to Address, amount *big.Int, sender *Account) (doneCh chan interface{}, errCh chan error)
* Generate the amount of tokens and put them in the balance of the given "to" Account. This function can only be called by Account (specified in SDK) which has MINTER_ROLE of smart contract.
This function requires privateKey has been set in SDK.
func (*TFC) SendMintTransaction ¶ added in v0.2.0
func (*TFC) TotalSupply ¶
* Returns the total token supply.
func (*TFC) Transfer ¶
func (tfc *TFC) Transfer(ctx context.Context, to Address, amount *big.Int, sender *Account) (doneCh chan interface{}, errCh chan error)
* Transfer the amount of balance from current Account (specified in SDK) to the given "to" Account.
This function requires privateKey has been set in SDK.
func (*TFC) TransferFrom ¶
func (tfc *TFC) TransferFrom(ctx context.Context, from Address, to string, amount *big.Int, sender *Account) (doneCh chan interface{}, errCh chan error)
* Transfer the amount of balance from the given "from" Account to the given "to" Account.
This function requires privateKey has been set in SDK, which will be used to sign the ethereum transaction.