assets

package
v0.77.0-preview.3 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAssetDoesNotExist        = errors.New("asset does not exist")
	ErrUnknownAssetSource       = errors.New("unknown asset source")
	ErrErc20AddressAlreadyInUse = errors.New("erc20 address already in use")
	ErrUnknownChainID           = errors.New("erc20 chain-id does not correspond to a bridge")
)
View Source
var ErrUpdatingAssetWithDifferentTypeOfAsset = errors.New("updating asset with different type of asset")

Functions

func LoadGenesisState

func LoadGenesisState(bytes []byte) (map[string]*types.AssetDetails, error)

Types

type Asset

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

func NewAsset

func NewAsset(a isAsset) *Asset

func (*Asset) BuiltinAsset

func (a *Asset) BuiltinAsset() (*builtin.Builtin, bool)

func (*Asset) DecimalPlaces

func (a *Asset) DecimalPlaces() uint64

func (*Asset) ERC20

func (a *Asset) ERC20() (*erc20.ERC20, bool)

func (*Asset) IsBuiltinAsset

func (a *Asset) IsBuiltinAsset() bool

func (*Asset) IsERC20

func (a *Asset) IsERC20() bool

func (*Asset) ToAssetType

func (a *Asset) ToAssetType() *types.Asset

func (*Asset) Update

func (a *Asset) Update(updatedAsset *Asset) error

type AssetDetails

type AssetDetails struct {
	Name     string  `json:"name"`
	Symbol   string  `json:"symbol"`
	Decimals uint64  `json:"decimals"`
	Quantum  string  `json:"quantum"`
	Source   *Source `json:"source"`
}

func (*AssetDetails) IntoProto

func (a *AssetDetails) IntoProto() (*types.AssetDetails, error)

type BuiltinAsset

type BuiltinAsset struct {
	MaxFaucetAmountMint string `json:"max_faucet_amount_mint"`
}

type Config

type Config struct {
	Level encoding.LogLevel `long:"log-level"`
}

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.

type ERC20BridgeView

type ERC20BridgeView interface {
	FindAsset(asset *types.AssetDetails) error
}

type Erc20

type Erc20 struct {
	ContractAddress   string `json:"contract_address"`
	LifetimeLimit     string `json:"lifetime_limit"`
	WithdrawThreshold string `json:"withdraw_threshold"`
	ChainID           string `json:"chain_id"`
}

type GenesisState

type GenesisState map[string]AssetDetails

func DefaultGenesisState

func DefaultGenesisState() GenesisState

type Notary added in v0.55.0

type Notary interface {
	StartAggregate(resID string, kind types.NodeSignatureKind, signature []byte)
	OfferSignatures(kind types.NodeSignatureKind, f func(id string) []byte)
}

type Service

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

func New

func New(
	ctx context.Context,
	log *logging.Logger,
	cfg Config,
	nw nweth.EthereumWallet,
	primaryEthClient erc20.ETHClient,
	secondaryEthClient erc20.ETHClient,
	broker broker.Interface,
	primaryBridgeView ERC20BridgeView,
	secondaryBridgeView ERC20BridgeView,
	notary Notary,
	isValidator bool,
) (*Service, error)

func (*Service) ApplyAssetUpdate

func (s *Service) ApplyAssetUpdate(ctx context.Context, assetID string) error

func (*Service) Checkpoint

func (s *Service) Checkpoint() ([]byte, error)

func (*Service) Enable

func (s *Service) Enable(ctx context.Context, assetID string) error

Enable move the state of an from pending the list of valid and accepted assets.

func (*Service) EnactPendingAsset added in v0.55.0

func (s *Service) EnactPendingAsset(id string)

EnactPendingAsset the given id for an asset has just been enacted by the governance engine so we now need to generate signatures so that the asset can be listed.

func (*Service) Get

func (s *Service) Get(assetID string) (*Asset, error)

func (*Service) GetEnabledAssets

func (s *Service) GetEnabledAssets() []*types.Asset

func (*Service) GetState

func (s *Service) GetState(k string) ([]byte, []types.StateProvider, error)

func (*Service) GetVegaIDFromEthereumAddress

func (s *Service) GetVegaIDFromEthereumAddress(address string) string

func (*Service) IsEnabled

func (s *Service) IsEnabled(assetID string) bool

func (*Service) Keys

func (s *Service) Keys() []string

func (*Service) Load

func (s *Service) Load(ctx context.Context, cp []byte) error

func (*Service) LoadState

func (s *Service) LoadState(ctx context.Context, p *types.Payload) ([]types.StateProvider, error)

func (*Service) Name

func (*Service) Name() types.CheckpointName

func (*Service) Namespace

func (s *Service) Namespace() types.SnapshotNamespace

func (*Service) NewAsset

func (s *Service) NewAsset(ctx context.Context, proposalID string, assetDetails *types.AssetDetails) (string, error)

NewAsset add a new asset to the pending list of assets the ref is the reference of proposal which submitted the new asset returns the assetID and an error.

func (*Service) OnStateLoaded added in v0.76.0

func (s *Service) OnStateLoaded(ctx context.Context) error

func (*Service) OnTick added in v0.71.0

func (s *Service) OnTick(_ context.Context, _ time.Time)

func (*Service) ReloadConf

func (s *Service) ReloadConf(cfg Config)

ReloadConf updates the internal configuration.

func (*Service) SetBridgeChainID added in v0.76.0

func (s *Service) SetBridgeChainID(chainID string, primary bool)

SetBridgeChainID sets the chain-ids for the bridge once we have processed the network parameters this is necessary so that non-validator nodes (which cannot just ask the eth-client) can know what they are.

func (*Service) SetPendingListing

func (s *Service) SetPendingListing(ctx context.Context, assetID string) error

SetPendingListing update the state of an asset from proposed to pending listing on the bridge.

func (*Service) SetRejected

func (s *Service) SetRejected(ctx context.Context, assetID string) error

SetRejected update the state of an asset from proposed to pending listing on the bridge.

func (*Service) StageAssetUpdate

func (s *Service) StageAssetUpdate(updatedAssetProto *types.Asset) error

func (*Service) Stopped

func (s *Service) Stopped() bool

func (*Service) ValidateAsset

func (s *Service) ValidateAsset(assetID string) error

func (*Service) ValidateAssetNonValidator

func (s *Service) ValidateAssetNonValidator(assetID string) error

ValidateAssetNonValidator is only to be used by non-validators at startup when loading genesis file. We just assume assets are valid.

func (*Service) ValidateEthereumAddress added in v0.76.0

func (s *Service) ValidateEthereumAddress(address, chainID string) error

ValidateEthereumAddress checks that the given ERC20 address and chainID corresponds to one of Vega's bridges and isn't the address of an asset that already exists.

type Source

type Source struct {
	BuiltinAsset *BuiltinAsset `json:"builtin_asset,omitempty"`
	Erc20        *Erc20        `json:"erc20,omitempty"`
}

Directories

Path Synopsis
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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