Documentation ¶
Index ¶
- Constants
- func NewService(cashiers []TokenCashier, batchSize uint16, processInterval time.Duration, ...) (*service, error)
- func StartServer(srv *service, grpcPort int, grpcProxyPort int)
- type AbstractRecorder
- type AbstractTransfer
- type Recorder
- func (recorder *Recorder) AddTransfer(at AbstractTransfer, status TransferStatus) error
- func (recorder *Recorder) AmountOfTransferred(cashier, token common.Address) (*big.Int, error)
- func (recorder *Recorder) ConfirmTransfer(at AbstractTransfer) error
- func (recorder *Recorder) MarkTransferAsPending(at AbstractTransfer) error
- func (recorder *Recorder) SettleTransfer(at AbstractTransfer) error
- func (recorder *Recorder) Start(ctx context.Context) error
- func (recorder *Recorder) Stop(ctx context.Context) error
- func (recorder *Recorder) TipHeight(cashier string) (uint64, error)
- func (recorder *Recorder) Transfer(_id common.Hash) (AbstractTransfer, error)
- func (recorder *Recorder) TransfersToSettle(cashier string) ([]AbstractTransfer, error)
- func (recorder *Recorder) TransfersToSubmit(cashier string) ([]AbstractTransfer, error)
- func (recorder *Recorder) UnsettledTransfers() ([]string, error)
- func (recorder *Recorder) UpdateSyncHeight(cashier string, height uint64) error
- func (recorder *Recorder) UpsertTransfer(at AbstractTransfer) error
- type SOLRecorder
- func (recorder *SOLRecorder) AddTransfer(at AbstractTransfer, status TransferStatus) error
- func (recorder *SOLRecorder) ConfirmTransfer(at AbstractTransfer) error
- func (recorder *SOLRecorder) MarkTransferAsPending(at AbstractTransfer) error
- func (recorder *SOLRecorder) SettleTransfer(at AbstractTransfer) error
- func (recorder *SOLRecorder) Start(ctx context.Context) error
- func (recorder *SOLRecorder) Stop(ctx context.Context) error
- func (recorder *SOLRecorder) TipHeight(cashier string) (uint64, error)
- func (recorder *SOLRecorder) Transfer(_ common.Hash) (AbstractTransfer, error)
- func (recorder *SOLRecorder) TransfersToSettle(string) ([]AbstractTransfer, error)
- func (recorder *SOLRecorder) TransfersToSubmit(string) ([]AbstractTransfer, error)
- func (recorder *SOLRecorder) UnsettledTransfers() ([]string, error)
- func (recorder *SOLRecorder) UpdateSyncHeight(cashier string, height uint64) error
- func (recorder *SOLRecorder) UpsertTransfer(at AbstractTransfer) error
- type Service
- type SignHandler
- type TokenCashier
- type Transfer
- func (t *Transfer) Amount() *big.Int
- func (t *Transfer) BlockHeight() uint64
- func (t *Transfer) Cashier() util.Address
- func (t *Transfer) CoToken() util.Address
- func (t *Transfer) ID() []byte
- func (t *Transfer) Index() *big.Int
- func (t *Transfer) Payload() []byte
- func (t *Transfer) Recipient() util.Address
- func (t *Transfer) Sender() util.Address
- func (t *Transfer) SetID(id common.Hash)
- func (t *Transfer) Status() TransferStatus
- func (t *Transfer) ToTypesTransfer() *types.Transfer
- func (t *Transfer) Token() util.Address
- type TransferStatus
- type Version
Constants ¶
const ( // TransferNew stands for a new transfer TransferNew TransferStatus = "new" // TransferPending stands for a pending transfer TransferPending = "pending" // TransferReady stands for a new transfer ready to sign TransferReady = "ready" // SubmissionConfirmed stands for a confirmed witness SubmissionConfirmed = "confirmed" // TransferSettled stands for a settled transfer TransferSettled = "settled" // TransferInvalid stands for an invalid transfer TransferInvalid = "invalid" // NoPayload is version without payload NoPayload Version = "no-payload" // Payload is version with payload Payload Version = "payload" // ToSolana is version with payload to solana ToSolana Version = "to-solana" )
Variables ¶
This section is empty.
Functions ¶
func NewService ¶
func NewService( cashiers []TokenCashier, batchSize uint16, processInterval time.Duration, disableSubmit bool, ) (*service, error)
NewService creates a new witness service
func StartServer ¶
Types ¶
type AbstractRecorder ¶
type AbstractRecorder interface { Start(ctx context.Context) error Stop(ctx context.Context) error AddTransfer(tx AbstractTransfer, status TransferStatus) error UpsertTransfer(tx AbstractTransfer) error TipHeight(id string) (uint64, error) UpdateSyncHeight(id string, height uint64) error Transfer(id common.Hash) (AbstractTransfer, error) UnsettledTransfers() ([]string, error) TransfersToSubmit(string) ([]AbstractTransfer, error) TransfersToSettle(string) ([]AbstractTransfer, error) SettleTransfer(tx AbstractTransfer) error ConfirmTransfer(tx AbstractTransfer) error MarkTransferAsPending(tx AbstractTransfer) error }
type AbstractTransfer ¶
type AbstractTransfer interface { Cashier() util.Address Token() util.Address CoToken() util.Address Index() *big.Int Sender() util.Address Recipient() util.Address Payload() []byte Amount() *big.Int ID() []byte SetID(common.Hash) Status() TransferStatus BlockHeight() uint64 ToTypesTransfer() *types.Transfer }
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder is a logger based on sql to record exchange events
func NewRecorder ¶
func NewRecorder( store *db.SQLStore, transferTableName string, tokenPairs map[common.Address]util.Address, tokenWhitelists map[common.Address]map[common.Address]struct{}, tokenMintPairs map[string]util.Address, tokenRound map[common.Address]int, addrDecoder util.AddressDecoder, ) *Recorder
NewRecorder returns a recorder for exchange
func (*Recorder) AddTransfer ¶
func (recorder *Recorder) AddTransfer(at AbstractTransfer, status TransferStatus) error
AddTransfer creates a new transfer record
func (*Recorder) AmountOfTransferred ¶
func (*Recorder) ConfirmTransfer ¶
func (recorder *Recorder) ConfirmTransfer(at AbstractTransfer) error
ConfirmTransfer marks a record as confirmed
func (*Recorder) MarkTransferAsPending ¶
func (recorder *Recorder) MarkTransferAsPending(at AbstractTransfer) error
MarkTransferAsPending marks a record as pending
func (*Recorder) SettleTransfer ¶
func (recorder *Recorder) SettleTransfer(at AbstractTransfer) error
SettleTransfer marks a record as settled
func (*Recorder) Transfer ¶
func (recorder *Recorder) Transfer(_id common.Hash) (AbstractTransfer, error)
func (*Recorder) TransfersToSettle ¶
func (recorder *Recorder) TransfersToSettle(cashier string) ([]AbstractTransfer, error)
TransfersToSettle returns the list of transfers to confirm
func (*Recorder) TransfersToSubmit ¶
func (recorder *Recorder) TransfersToSubmit(cashier string) ([]AbstractTransfer, error)
TransfersToSubmit returns the list of transfers to submit
func (*Recorder) UnsettledTransfers ¶
func (*Recorder) UpdateSyncHeight ¶
func (*Recorder) UpsertTransfer ¶
func (recorder *Recorder) UpsertTransfer(at AbstractTransfer) error
type SOLRecorder ¶
type SOLRecorder struct {
// contains filtered or unexported fields
}
SOLRecorder is the recorder for Solana
func NewSOLRecorder ¶
func NewSOLRecorder( store *db.SQLStore, transferTableName string, tokenPairs map[solcommon.PublicKey]util.Address, tokenRound map[solcommon.PublicKey]int, addrDecoder util.AddressDecoder, ) *SOLRecorder
NewSOLRecorder returns a recorder for exchange
func (*SOLRecorder) AddTransfer ¶
func (recorder *SOLRecorder) AddTransfer(at AbstractTransfer, status TransferStatus) error
AddTransfer creates a new transfer record
func (*SOLRecorder) ConfirmTransfer ¶
func (recorder *SOLRecorder) ConfirmTransfer(at AbstractTransfer) error
ConfirmTransfer marks a record as confirmed
func (*SOLRecorder) MarkTransferAsPending ¶
func (recorder *SOLRecorder) MarkTransferAsPending(at AbstractTransfer) error
MarkTransferAsPending marks a record as pending
func (*SOLRecorder) SettleTransfer ¶
func (recorder *SOLRecorder) SettleTransfer(at AbstractTransfer) error
SettleTransfer marks a record as settled
func (*SOLRecorder) Start ¶
func (recorder *SOLRecorder) Start(ctx context.Context) error
Start starts the recorder
func (*SOLRecorder) Stop ¶
func (recorder *SOLRecorder) Stop(ctx context.Context) error
Stop stops the recorder
func (*SOLRecorder) TipHeight ¶
func (recorder *SOLRecorder) TipHeight(cashier string) (uint64, error)
TipHeight returns the tip height of all the transfers in the recorder
func (*SOLRecorder) Transfer ¶
func (recorder *SOLRecorder) Transfer(_ common.Hash) (AbstractTransfer, error)
func (*SOLRecorder) TransfersToSettle ¶
func (recorder *SOLRecorder) TransfersToSettle(string) ([]AbstractTransfer, error)
TransfersToSettle returns the list of transfers to confirm
func (*SOLRecorder) TransfersToSubmit ¶
func (recorder *SOLRecorder) TransfersToSubmit(string) ([]AbstractTransfer, error)
TransfersToSubmit returns the list of transfers to submit
func (*SOLRecorder) UnsettledTransfers ¶
func (recorder *SOLRecorder) UnsettledTransfers() ([]string, error)
UnsettledTransfers returns the list of unsettled transfers
func (*SOLRecorder) UpdateSyncHeight ¶
func (recorder *SOLRecorder) UpdateSyncHeight(cashier string, height uint64) error
func (*SOLRecorder) UpsertTransfer ¶
func (recorder *SOLRecorder) UpsertTransfer(at AbstractTransfer) error
type Service ¶
type Service interface { // Start starts the service Start(context.Context) error // Stop stops the service Stop(context.Context) error }
Service manages to exchange iotex coin to ERC20 token on ethereum
type SignHandler ¶
func NewEd25519SignHandler ¶
func NewEd25519SignHandler(privateKey *ed25519.PrivateKey) SignHandler
func NewSecp256k1SignHandler ¶
func NewSecp256k1SignHandler(privateKey *ecdsa.PrivateKey) SignHandler
type TokenCashier ¶
type TokenCashier interface { Start(context.Context) error Stop(context.Context) error ID() string GetRecorder() AbstractRecorder PullTransfersByHeight(blockHeight uint64) error PullTransfers(blockCount uint16) error SubmitTransfers() error CheckTransfers() error ProcessStales() error }
TokenCashier defines the interface to pull transfers from chain in a block range
func NewTokenCashierOnEthereum ¶
func NewTokenCashierOnEthereum( id string, version Version, relayerURL string, ethereumClient *ethclient.Client, cashierContractAddr common.Address, previousCashierAddr common.Address, tokenSafeContractAddr common.Address, validatorContractAddr []byte, recorder *Recorder, startBlockHeight uint64, confirmBlockNumber uint8, signHandler SignHandler, reverseRecorder *Recorder, reverseCashierContractAddr common.Address, ) (TokenCashier, error)
NewTokenCashierOnEthereum creates a new TokenCashier on ethereum
func NewTokenCashierOnSolana ¶
func NewTokenCashierOnSolana( id string, relayerURL string, solanaClient *client.Client, cashier solcommon.PublicKey, validatorAddr common.Address, recorder *SOLRecorder, startBlockHeight uint64, qpsLimit uint32, signHandler SignHandler, disablePull bool, ) (TokenCashier, error)
type Transfer ¶
type Transfer struct {
// contains filtered or unexported fields
}
Transfer defines a record
func (*Transfer) BlockHeight ¶
func (*Transfer) Status ¶
func (t *Transfer) Status() TransferStatus