accumulate

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ACC_KEYPAGE                 = "1"       // bridge ADI keypage
	ACC_LEADER                  = "leader"  // data account: current leader (pubkeyhash)
	ACC_TOKEN_REGISTRY          = "tokens"  // data account: token registry (accumulate token address, evm token address, evm chainid)
	ACC_BRIDGE_FEES             = "fees"    // data account: bridge fees
	ACC_MINT_QUEUE              = "mint"    // data account: mint queue, {chainid}:mint
	ACC_RELEASE_QUEUE           = "release" // data account: release queue, {chainid}:release
	ACC_BRIDGE_STATUS           = "status"  // data account: status (1 = on, 0 = off)
	TOKEN_REGISTRY_VERSION      = "v1"      // validate token registry data entries
	MINT_QUEUE_VERSION          = "v1"      // validate burn events data entries
	RELEASE_QUEUE_VERSION       = "v1"      // validate deposit list data entries
	SIGNATURE_TYPE              = "ed25519"
	ZERO_HASH                   = "0000000000000000000000000000000000000000000000000000000000000000"
	TX_TYPE_SYNTH_TOKEN_DEPOSIT = "syntheticDepositTokens"
	TX_TYPE_SEND_TOKENS         = "sendTokens"
)

Variables

This section is empty.

Functions

func GenerateDataEntry

func GenerateDataEntry(account string, entryhash string) string

Generate data entry in format {entryhash}@{account}

func GenerateMintDataAccount

func GenerateMintDataAccount(adi string, chainId int64, action string, symbol string) string

Generate bridge data account in format audit:{chainId}:{action}:{symbol}

func GeneratePendingChain

func GeneratePendingChain(account string) string

Generate pending chain in format {account}#pending

func GenerateReleaseDataAccount

func GenerateReleaseDataAccount(adi string, chainId int64, action string) string

Generate bridge data account in format audit:{chainId}:{action}

func GenerateTokenAccount

func GenerateTokenAccount(adi string, chainId int64, symbol string) string

Generate bridge token account in format {chainId}-{symbol}

Types

type ADI

type ADI struct {
	Type        string `json:"type" validate:"required,eq=identity"`
	Authorities []*URL `json:"authorities" validate:"required"`
	URL         string `json:"url" validate:"required"`
}

type AccumulateClient

type AccumulateClient struct {
	API           string
	ADI           string
	Signer        string
	PrivateKey    ed25519.PrivateKey
	PublicKey     ed25519.PublicKey
	PublicKeyHash []byte
	Client        jsonrpc.RPCClient
	Validate      *validator.Validate
}

func NewAccumulateClient

func NewAccumulateClient(conf *config.Config) (*AccumulateClient, error)

NewAccumulateClient constructs the Accumulate client

func (*AccumulateClient) ExecuteDirect

func (c *AccumulateClient) ExecuteDirect(params *Params) (*ExecuteDirectResponse, error)

Create calls "execute-direct" tx on Accumulate

func (*AccumulateClient) ImportPrivateKey

func (c *AccumulateClient) ImportPrivateKey(pk string) (*AccumulateClient, error)

ImportPrivateKey imports private key and generates corresponding public key

func (*AccumulateClient) QueryADI

func (c *AccumulateClient) QueryADI(adi *Params) (*QueryADIResponse, error)

QueryADI gets Token info

func (*AccumulateClient) QueryDataEntry

func (c *AccumulateClient) QueryDataEntry(dataAccount *Params) (*QueryDataResponse, error)

QueryLatestDataEntry gets latest data entry from data account

func (*AccumulateClient) QueryDataSet

func (c *AccumulateClient) QueryDataSet(dataAccount *Params) (*QueryDataSetResponse, error)

QueryDataSet gets data entries from data account

func (*AccumulateClient) QueryKeyPage

func (c *AccumulateClient) QueryKeyPage(page *Params) (*QueryKeyPageResponse, error)

QueryKeyPage gets Key page info

func (*AccumulateClient) QueryLatestDataEntry

func (c *AccumulateClient) QueryLatestDataEntry(dataAccount *Params) (*QueryDataResponse, error)

QueryLatestDataEntry gets latest data entry from data account

func (*AccumulateClient) QueryPendingChain

func (c *AccumulateClient) QueryPendingChain(account *Params) (*QueryPendingChainResponse, error)

QueryPendingChain gets data pending data from data or token account

func (*AccumulateClient) QueryToken

func (c *AccumulateClient) QueryToken(token *Params) (*QueryTokenResponse, error)

QueryToken gets Token info

func (*AccumulateClient) QueryTokenAccount

func (c *AccumulateClient) QueryTokenAccount(account *Params) (*QueryTokenAccountResponse, error)

QueryTokenAccount gets Token Account info

func (*AccumulateClient) QueryTokenTx

func (c *AccumulateClient) QueryTokenTx(tx *Params) (*QueryTokenTxResponse, error)

QueryTokenTx gets token tx by url

func (*AccumulateClient) QueryTxHistory

func (c *AccumulateClient) QueryTxHistory(account *Params) (*QueryTxHistoryResponse, error)

QueryTxHistory gets tx history of account

func (*AccumulateClient) RemoteTransaction

func (c *AccumulateClient) RemoteTransaction(from string, txhash string) (string, error)

RemoteTransaction generates remote tx for `execute-direct` API method

func (*AccumulateClient) SendTokens

func (c *AccumulateClient) SendTokens(to string, amount int64, tokenURL string, chainId int64) (string, error)

SendTokens generates sendTokens tx for `execute-direct` API method

func (*AccumulateClient) WriteData

func (c *AccumulateClient) WriteData(dataAccount string, content [][]byte) (string, error)

WriteData generates writeData tx for `execute-direct` API method

type DataEntry

type DataEntry struct {
	EntryHash string `json:"entryHash" validate:"required"`
	Entry     struct {
		Type string   `json:"type" validate:"required"`
		Data []string `json:"data" validate:"gt=0"`
	}
}

type ExecuteDirectResponse

type ExecuteDirectResponse struct {
	Hash            string   `json:"hash"`
	Txid            string   `json:"txid"`
	Message         string   `json:"message"`
	SignatureHashes []string `json:"signatureHashes"`
	SimpleHash      string   `json:"simpleHash"`
}

type Key

type Key struct {
	PublicKeyHash string `json:"publicKeyHash"`
}

type KeyPage

type KeyPage struct {
	Type            string `json:"type" validate:"required,eq=keyPage"`
	KeyBook         string `json:"keyBook" validate:"required"`
	URL             string `json:"url" validate:"required"`
	CreditBalance   int64  `json:"creditBalance"`
	AcceptThreshold int64  `json:"acceptThreshold"`
	Threshold       int64  `json:"threshold"`
	Version         uint64 `json:"version"`
	Keys            []*Key `json:"keys"`
}

type Params

type Params struct {
	URL      string             `json:"url"`
	Count    int64              `json:"count"`
	Start    int64              `json:"start"`
	Expand   bool               `json:"expand"`
	Envelope *protocol.Envelope `json:"envelope"`
}

type QueryADIResponse

type QueryADIResponse struct {
	Data          *ADI       `json:"data"`
	LastBlockTime *time.Time `json:"lastBlockTime" validate:"required,notOlderThanOneMinute"`
}

type QueryDataResponse

type QueryDataResponse struct {
	Data          *DataEntry `json:"data"`
	LastBlockTime *time.Time `json:"lastBlockTime" validate:"required,notOlderThanOneMinute"`
}

type QueryDataSetResponse

type QueryDataSetResponse struct {
	Items []*DataEntry `json:"items"`
}

type QueryKeyPageResponse

type QueryKeyPageResponse struct {
	Data          *KeyPage   `json:"data"`
	LastBlockTime *time.Time `json:"lastBlockTime" validate:"required,notOlderThanOneMinute"`
}

type QueryPendingChainResponse

type QueryPendingChainResponse struct {
	Items         []string   `json:"items"`
	LastBlockTime *time.Time `json:"lastBlockTime" validate:"required,notOlderThanOneMinute"`
}

type QueryTokenAccountResponse

type QueryTokenAccountResponse struct {
	Data          *TokenAccount `json:"data"`
	LastBlockTime *time.Time    `json:"lastBlockTime" validate:"required,notOlderThanOneMinute"`
}

type QueryTokenResponse

type QueryTokenResponse struct {
	Data          *Token     `json:"data"`
	LastBlockTime *time.Time `json:"lastBlockTime" validate:"required,notOlderThanOneMinute"`
}

type QueryTokenTxResponse

type QueryTokenTxResponse struct {
	Type        string   `json:"type" validate:"required"`
	TxHash      string   `json:"transactionHash"`
	TxID        string   `json:"txid"`
	Data        *TokenTx `json:"data"`
	Transaction struct {
		Header struct {
			Memo string `json:"memo"`
		}
	}
}

type QueryTxHistoryResponse

type QueryTxHistoryResponse struct {
	Items []*QueryTokenTxResponse `json:"items"`
}

type Token

type Token struct {
	Type        string `json:"type" validate:"required,eq=tokenIssuer"`
	Authorities []*URL `json:"authorities" validate:"required"`
	URL         string `json:"url" validate:"required"`
	Symbol      string `json:"symbol" validate:"required"`
	Precision   int64  `json:"precision"`
}

type TokenAccount

type TokenAccount struct {
	Type        string `json:"type" validate:"required,oneof=tokenAccount liteTokenAccount"`
	Authorities []*URL `json:"authorities"`
	URL         string `json:"url" validate:"required"`
	TokenURL    string `json:"tokenUrl" validate:"required"`
	Balance     string `json:"balance" validate:"required"`
}

type TokenTx

type TokenTx struct {
	From     string       `json:"from"`
	To       []*TokenTxTo `json:"to"`
	Cause    string       `json:"cause"`
	Source   string       `json:"source"`
	Token    string       `json:"token"`
	Amount   string       `json:"amount"`
	IsRefund bool         `json:"isRefund"`
}

type TokenTxTo

type TokenTxTo struct {
	URL    string `json:"url" validate:"required"`
	Amount string `json:"amount" validate:"required"`
}

type URL

type URL struct {
	URL string `json:"url" validate:"required"`
}

Jump to

Keyboard shortcuts

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