store

package
v0.0.0-...-ddfbed8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSchema

func InitSchema(db *sql.DB) error

func IsDuplicateError

func IsDuplicateError(err error) bool

func Migrate

func Migrate(db *sql.DB, dir migrate.MigrationDirection, max int) error

Types

type Action

type Action string
const (
	Withdraw Action = "withdraw"
	Refund   Action = "refund"
)

type Blockchain

type Blockchain string
const (
	Stellar  Blockchain = "stellar"
	Ethereum Blockchain = "ethereum"
)

type DB

type DB struct {
	Session db.SessionInterface
}

func (*DB) DeleteSignatureRequest

func (m *DB) DeleteSignatureRequest(ctx context.Context, request SignatureRequest) error

func (*DB) GetEthereumDeposit

func (m *DB) GetEthereumDeposit(ctx context.Context, id string) (EthereumDeposit, error)

func (*DB) GetEthereumSignature

func (m *DB) GetEthereumSignature(ctx context.Context, action Action, depositID string) (EthereumSignature, error)

func (*DB) GetLastLedgerCloseTime

func (m *DB) GetLastLedgerCloseTime(ctx context.Context) (time.Time, error)

func (*DB) GetLastLedgerSequence

func (m *DB) GetLastLedgerSequence(ctx context.Context) (uint32, error)

func (*DB) GetOutgoingStellarTransaction

func (m *DB) GetOutgoingStellarTransaction(ctx context.Context, action Action, depositID string) (OutgoingStellarTransaction, error)

func (*DB) GetSignatureRequests

func (m *DB) GetSignatureRequests(ctx context.Context) ([]SignatureRequest, error)

func (*DB) GetStellarDeposit

func (m *DB) GetStellarDeposit(ctx context.Context, id string) (StellarDeposit, error)

func (*DB) HistoryStellarTransactionExists

func (m *DB) HistoryStellarTransactionExists(ctx context.Context, memoHash string) (bool, error)

func (*DB) InsertEthereumDeposit

func (m *DB) InsertEthereumDeposit(ctx context.Context, deposit EthereumDeposit) error

func (*DB) InsertHistoryStellarTransaction

func (m *DB) InsertHistoryStellarTransaction(ctx context.Context, tx HistoryStellarTransaction) error

func (*DB) InsertSignatureRequest

func (m *DB) InsertSignatureRequest(ctx context.Context, request SignatureRequest) error

func (*DB) InsertStellarDeposit

func (m *DB) InsertStellarDeposit(ctx context.Context, deposit StellarDeposit) error

func (*DB) UpdateLastLedgerCloseTime

func (m *DB) UpdateLastLedgerCloseTime(ctx context.Context, closeTime time.Time) error

func (*DB) UpdateLastLedgerSequence

func (m *DB) UpdateLastLedgerSequence(ctx context.Context, ledgerSequence uint32) error

func (*DB) UpsertEthereumSignature

func (m *DB) UpsertEthereumSignature(ctx context.Context, newSig EthereumSignature) error

func (*DB) UpsertOutgoingStellarTransaction

func (m *DB) UpsertOutgoingStellarTransaction(ctx context.Context, newtx OutgoingStellarTransaction) error

type EthereumDeposit

type EthereumDeposit struct {
	// ID is the globally unique id for this deposit
	ID string `db:"id"`
	// Token is the address (0x0 in the case that eth was deposited)
	// of the tokens which were deposited to the bridge
	Token string `db:"token"`
	// Sender is the address of the account which deposited the tokens
	Sender string `db:"sender"`
	// Destination is the intended recipient of the bridge transfer
	Destination string `db:"destination"`
	// Amount is the amount of tokens which were deposited to the bridge
	// contract
	Amount string `db:"amount"`
	// Hash is the hash of the transaction containing the deposit
	Hash string `db:"hash"`
	// LogIndex is the log index within the ethereum block of the deposit event
	// emitted by the bridge contract
	LogIndex uint `db:"log_index"`
	// BlockNumber is the sequence number of the block containing the deposit
	// transaction
	BlockNumber uint64 `db:"block_number"`
	// BlockTime is the unix timestamp of the deposit
	BlockTime int64 `db:"block_time"`
}

type EthereumSignature

type EthereumSignature struct {
	Address    string `db:"address"`
	Token      string `db:"token"`
	Amount     string `db:"amount"`
	Signature  string `db:"signature"`
	Expiration int64  `db:"expiration"`
	Action     Action `db:"requested_action"`
	DepositID  string `db:"deposit_id"`
}

EthereumSignature represents a signature for a withdrawal / refund against the bridge ethereum smart contract

type HistoryStellarTransaction

type HistoryStellarTransaction struct {
	Hash     string `db:"hash"`
	Envelope string `db:"envelope"`
	// MemoHash represents:
	//   - Ethereum deposit ID in case of withdrawals in Ethereum->Stellar flow
	//   - Stellar transaction hash in case of refunds in Stellar->Ethereum flow
	MemoHash string `db:"memo_hash"`
}

type OutgoingStellarTransaction

type OutgoingStellarTransaction struct {
	Envelope      string `db:"envelope"`
	SourceAccount string `db:"source_account"`
	Sequence      int64  `db:"sequence"`
	Action        Action `db:"requested_action"`
	DepositID     string `db:"deposit_id"`
}

type SignatureRequest

type SignatureRequest struct {
	DepositChain Blockchain `db:"deposit_chain"`
	Action       Action     `db:"requested_action"`
	DepositID    string     `db:"deposit_id"`
}

type StellarDeposit

type StellarDeposit struct {
	// ID is the globally unique id for this deposit
	// and is equal to deposit transaction hash
	ID string `db:"id"`
	// Asset is the string encoding of the Stellar assets
	// which were deposited to the bridge
	Asset string `db:"asset"`
	// Sender is the address of the account which deposited the tokens
	Sender string `db:"sender"`
	// Destination is the intended recipient of the bridge transfer
	Destination string `db:"destination"`
	// Amount is the amount of tokens which were deposited to the bridge
	// contract
	Amount string `db:"amount"`
	// LedgerTime is the unix timestamp of the deposit
	LedgerTime int64 `db:"ledger_time"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL