eggwallets

package
v0.0.0-...-3acd70f Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Wallets that manage assets in Cartesi Rollups Portals.

Index

Constants

This section is empty.

Variables

View Source
var MaxUint256 *big.Int

Max value for uint256.

Functions

func EncodeERC20Withdraw

func EncodeERC20Withdraw(token common.Address, value *big.Int) []byte

Encode the withdraw request to the portal.

func EncodeEtherWithdraw

func EncodeEtherWithdraw(address common.Address, value *big.Int) []byte

Encode the withdraw request to the portal.

func EtherString

func EtherString(wei *big.Int) string

Generate a string converting Wei to Ether.

Types

type Deposit

type Deposit interface {
	fmt.Stringer

	// Get the deposit sender.
	GetSender() common.Address
}

Asset deposit to a portal.

type ERC20Deposit

type ERC20Deposit struct {
	Token  common.Address
	Sender common.Address
	Amount *big.Int
}

An ERC20 deposit that arrived in the wallet.

func (*ERC20Deposit) GetSender

func (d *ERC20Deposit) GetSender() common.Address

func (*ERC20Deposit) String

func (d *ERC20Deposit) String() string

type ERC20Wallet

type ERC20Wallet struct {
	// contains filtered or unexported fields
}

Wallet that manages ERC20 tokens.

func NewERC20Wallet

func NewERC20Wallet() *ERC20Wallet

Create new ERC20 Wallet.

func (*ERC20Wallet) Addresses

func (w *ERC20Wallet) Addresses(token common.Address) []common.Address

Return the list of addresses that have assets for the given token.

func (*ERC20Wallet) BalanceOf

func (w *ERC20Wallet) BalanceOf(token common.Address, address common.Address) *big.Int

Return the balance of the given address for the given token.

func (*ERC20Wallet) Deposit

func (w *ERC20Wallet) Deposit(payload []byte) (Deposit, []byte, error)

Handle a deposit from the ERC20 portal.

func (*ERC20Wallet) Tokens

func (w *ERC20Wallet) Tokens() []common.Address

Return the list of tokens with assets.

func (*ERC20Wallet) Transfer

func (w *ERC20Wallet) Transfer(
	token common.Address, src common.Address, dst common.Address, value *big.Int) error

Transfer the given amount of tokens from source to destination. Return error if the source doesn't have enough funds.

func (*ERC20Wallet) Withdraw

func (w *ERC20Wallet) Withdraw(
	token common.Address, address common.Address, value *big.Int) ([]byte, error)

Withdraw the asset from the wallet and generate the voucher to withdraw from the portal. Return error if the address doesn't have enough assets.

type EtherDeposit

type EtherDeposit struct {
	Sender common.Address
	Value  *big.Int
}

An Ether deposit that arrived in the wallet.

func (*EtherDeposit) GetSender

func (e *EtherDeposit) GetSender() common.Address

func (*EtherDeposit) String

func (e *EtherDeposit) String() string

type EtherWallet

type EtherWallet struct {
	// contains filtered or unexported fields
}

Wallet that manages Ether.

func NewEtherWallet

func NewEtherWallet() *EtherWallet

Create new Ether Wallet.

func (*EtherWallet) Addresses

func (w *EtherWallet) Addresses() []common.Address

Return the list of addresses that have assets.

func (*EtherWallet) BalanceOf

func (w *EtherWallet) BalanceOf(address common.Address) *big.Int

Return the balance of the given address.

func (*EtherWallet) Deposit

func (w *EtherWallet) Deposit(payload []byte) (Deposit, []byte, error)

Handle a deposit from the Ether portal.

func (*EtherWallet) Transfer

func (w *EtherWallet) Transfer(src common.Address, dst common.Address, value *big.Int) error

Transfer the given amount of funds from source to destination. Return error if the source doesn't have enough funds.

func (*EtherWallet) Withdraw

func (w *EtherWallet) Withdraw(address common.Address, value *big.Int) ([]byte, error)

Withdraw the asset from the wallet and generate the voucher to withdraw from the portal. Return error if the address doesn't have enough assets.

type Wallet

type Wallet interface {

	// Handle the raw bytes of a deposit that came from the portal.
	// After handling the deposit, return the parsed deposit, and the DApp input payload.
	Deposit(input []byte) (Deposit, []byte, error)
}

Manages an asset in a portal.

Jump to

Keyboard shortcuts

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