common

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxHashLen   = 20
	MMJsonObjStr = `` /* 1335-byte string literal not displayed */

)
View Source
const (
	ParamOwner   = "0x00"
	ParamManager = "0x01"
)
View Source
const (
	ChainTypeCkb   ChainType = 0
	ChainTypeEth   ChainType = 1
	ChainTypeBtc   ChainType = 2
	ChainTypeTron  ChainType = 3
	ChainTypeMixin ChainType = 4

	HexPreFix            = "0x"
	TronPreFix           = "41"
	TronBase58PreFix     = "T"
	DasLockCkbPreFix     = "00"
	DasLockEthPreFix     = "03"
	DasLockTronPreFix    = "04"
	DasLockEth712PreFix  = "05"
	DasLockEd25519PreFix = "06"
)
View Source
const (
	TronMessageHeader    = "\x19TRON Signed Message:\n%d"
	EthMessageHeader     = "\x19Ethereum Signed Message:\n%d"
	Ed25519MessageHeader = "\x18Ed25519 Signed Message:\n%d"
)
View Source
const (
	DasAccountSuffix  = ".bit"
	DasLockArgsLen    = 42
	DasLockArgsLenMax = 66
	DasAccountIdLen   = 20
	HashBytesLen      = 32

	ExpireTimeLen    = 8
	NextAccountIdLen = 20

	ExpireTimeEndIndex      = HashBytesLen + DasAccountIdLen + NextAccountIdLen + ExpireTimeLen
	NextAccountIdStartIndex = HashBytesLen + DasAccountIdLen
	NextAccountIdEndIndex   = NextAccountIdStartIndex + NextAccountIdLen
)
View Source
const (
	OneCkb                            = uint64(1e8)
	DasLockWithBalanceTypeOccupiedCkb = uint64(116 * 1e8)
	ProposalCellOccupiedCkb           = uint64(106 * 1e8)
	MinCellOccupiedCkb                = uint64(61 * 1e8)
	PercentRateBase                   = 1e4
	UsdRateBase                       = 1e6

	AccountStatusNormal    uint8 = 0
	AccountStatusOnSale    uint8 = 1
	AccountStatusOnAuction uint8 = 2

	OneYearSec = int64(3600 * 24 * 365)
)
View Source
const (
	ArgsQuoteCell  = "0x00"
	ArgsTimeCell   = "0x01"
	ArgsHeightCell = "0x02"
)
View Source
const (
	WitnessDas                  = "das"
	WitnessDasCharLen           = 3
	WitnessDasTableTypeEndIndex = 7
)
View Source
const (
	DataTypeNew          DataType = 0
	DataTypeOld          DataType = 1
	DataTypeDep          DataType = 2
	GoDataEntityVersion1 uint32   = 1
	GoDataEntityVersion2 uint32   = 2
)

Variables

This section is empty.

Functions

func AccountCharsToAccount

func AccountCharsToAccount(accountChars *molecule.AccountChars) string

func Blake2b

func Blake2b(acc []byte) []byte

func Bytes2Hex

func Bytes2Hex(b []byte) string

func Capacity2Str

func Capacity2Str(capacity uint64) string

func ConvertScriptToAddress

func ConvertScriptToAddress(mode address.Mode, script *types.Script) (string, error)

func GetAccountCellExpiredAtFromOutputData

func GetAccountCellExpiredAtFromOutputData(data []byte) (uint64, error)

func GetAccountCellNextAccountIdFromOutputData

func GetAccountCellNextAccountIdFromOutputData(data []byte) ([]byte, error)

func GetAccountIdByAccount

func GetAccountIdByAccount(acc string) []byte

func GetAccountLength

func GetAccountLength(account string) uint8

func GetMaxHashLenData

func GetMaxHashLenData(data []byte) string

func GetMaxHashLenParams

func GetMaxHashLenParams(s string) string

func GetMaxHashLenScript

func GetMaxHashLenScript(script *types.Script, dasContractName DasContractName) string

func GetNormalLockScript

func GetNormalLockScript(args string) *types.Script

GetNormalLockScript normal script

func GetNormalLockScriptByMultiSig

func GetNormalLockScriptByMultiSig(args string) *types.Script

GetNormalLockScriptByMultiSig multi sig

func GetScript

func GetScript(codeHash, args string) *types.Script

func Has0xPrefix

func Has0xPrefix(str string) bool

func Hex2Bytes

func Hex2Bytes(s string) []byte

func OutPoint2String

func OutPoint2String(txHash string, index uint) string

func OutPointStruct2String

func OutPointStruct2String(o *types.OutPoint) string

func OutputDataToAccountId

func OutputDataToAccountId(data []byte) ([]byte, error)

func ScriptToTypeId

func ScriptToTypeId(script *types.Script) types.Hash

script to type id

func String2OutPoint

func String2OutPoint(str string) (txHash string, index uint)

func String2OutPointStruct

func String2OutPointStruct(str string) *types.OutPoint

func TronBase58ToHex

func TronBase58ToHex(address string) (string, error)

func TronHexToBase58

func TronHexToBase58(address string) (string, error)

Types

type ActionDataType

type ActionDataType = string
const (
	ActionDataTypeActionData         ActionDataType = "0x00000000" // action data
	ActionDataTypeAccountCell        ActionDataType = "0x01000000" // account cell
	ActionDataTypeAccountSaleCell    ActionDataType = "0x02000000" // account sale cell
	ActionDataTypeAccountAuctionCell ActionDataType = "0x03000000" // account auction cell
	ActionDataTypeProposalCell       ActionDataType = "0x04000000" // proposal cell
	ActionDataTypePreAccountCell     ActionDataType = "0x05000000" // pre account cell
	ActionDataTypeIncomeCell         ActionDataType = "0x06000000" // income cell
	ActionDataTypeOfferCell          ActionDataType = "0x07000000" // offer cell
)

type BetaAction

type BetaAction = string
const (
	BetaActionConfig                 BetaAction = "config"
	BetaActionApplyRegister          BetaAction = "apply_register"
	BetaActionRefundApply            BetaAction = "refund_apply"
	BetaActionPreRegister            BetaAction = "pre_register"
	BetaActionPropose                BetaAction = "propose"
	BetaActionTransferAccount        BetaAction = "transfer_account"
	BetaActionRenewAccount           BetaAction = "renew_account"
	BetaActionExtendPropose          BetaAction = "extend_proposal"
	BetaActionConfirmProposal        BetaAction = "confirm_proposal"
	BetaActionRecycleProposal        BetaAction = "recycle_proposal"
	BetaActionWithdrawFromWallet     BetaAction = "withdraw_from_wallet"
	BetaActionEditManager            BetaAction = "edit_manager"
	BetaActionEditRecords            BetaAction = "edit_records"
	BetaActionStartAccountSale       BetaAction = "start_account_sale"
	BetaActionEditAccountSale        BetaAction = "edit_account_sale"
	BetaActionCancelAccountSale      BetaAction = "cancel_account_sale"
	BetaActionBuyAccount             BetaAction = "buy_account"
	BetaActionSellAccount            BetaAction = "sell_account"
	BetaActionCreateIncome           BetaAction = "create_income"
	BetaActionConsolidateIncome      BetaAction = "consolidate_income"
	BetaActionDeclareReverseRecord   BetaAction = "declare_reverse_record"
	BetaActionRedeclareReverseRecord BetaAction = "redeclare_reverse_record"
	BetaActionRetractReverseRecord   BetaAction = "retract_reverse_record"
	BetaActionTransfer               BetaAction = "transfer"

	BetaActionMakeOffer   BetaAction = "make_offer"
	BetaActionEditOffer   BetaAction = "edit_offer"
	BetaActionCancelOffer BetaAction = "cancel_offer"
	BetaActionAcceptOffer BetaAction = "accept_offer"
)

type ChainType

type ChainType int

func (ChainType) String

func (c ChainType) String() string

type ConfigCellTypeArgs

type ConfigCellTypeArgs = string
const (
	ConfigCellTypeArgsAccount         ConfigCellTypeArgs = "0x64000000"
	ConfigCellTypeArgsApply           ConfigCellTypeArgs = "0x65000000"
	ConfigCellTypeArgsIncome          ConfigCellTypeArgs = "0x67000000"
	ConfigCellTypeArgsMain            ConfigCellTypeArgs = "0x68000000"
	ConfigCellTypeArgsPrice           ConfigCellTypeArgs = "0x69000000"
	ConfigCellTypeArgsProposal        ConfigCellTypeArgs = "0x6a000000"
	ConfigCellTypeArgsProfitRate      ConfigCellTypeArgs = "0x6b000000"
	ConfigCellTypeArgsRecordNamespace ConfigCellTypeArgs = "0x6c000000"
	ConfigCellTypeArgsRelease         ConfigCellTypeArgs = "0x6d000000"
	ConfigCellTypeArgsUnavailable     ConfigCellTypeArgs = "0x6e000000"
	ConfigCellTypeArgsSecondaryMarket ConfigCellTypeArgs = "0x6f000000"
	ConfigCellTypeArgsReverseRecord   ConfigCellTypeArgs = "0x70000000"

	ConfigCellTypeArgsPreservedAccount00 ConfigCellTypeArgs = "0x10270000"
	ConfigCellTypeArgsPreservedAccount01 ConfigCellTypeArgs = "0x11270000"
	ConfigCellTypeArgsPreservedAccount02 ConfigCellTypeArgs = "0x12270000"
	ConfigCellTypeArgsPreservedAccount03 ConfigCellTypeArgs = "0x13270000"
	ConfigCellTypeArgsPreservedAccount04 ConfigCellTypeArgs = "0x14270000"
	ConfigCellTypeArgsPreservedAccount05 ConfigCellTypeArgs = "0x15270000"
	ConfigCellTypeArgsPreservedAccount06 ConfigCellTypeArgs = "0x16270000"
	ConfigCellTypeArgsPreservedAccount07 ConfigCellTypeArgs = "0x17270000"
	ConfigCellTypeArgsPreservedAccount08 ConfigCellTypeArgs = "0x18270000"
	ConfigCellTypeArgsPreservedAccount09 ConfigCellTypeArgs = "0x19270000"
	ConfigCellTypeArgsPreservedAccount10 ConfigCellTypeArgs = "0x1a270000"
	ConfigCellTypeArgsPreservedAccount11 ConfigCellTypeArgs = "0x1b270000"
	ConfigCellTypeArgsPreservedAccount12 ConfigCellTypeArgs = "0x1c270000"
	ConfigCellTypeArgsPreservedAccount13 ConfigCellTypeArgs = "0x1d270000"
	ConfigCellTypeArgsPreservedAccount14 ConfigCellTypeArgs = "0x1e270000"
	ConfigCellTypeArgsPreservedAccount15 ConfigCellTypeArgs = "0x1f270000"
	ConfigCellTypeArgsPreservedAccount16 ConfigCellTypeArgs = "0x20270000"
	ConfigCellTypeArgsPreservedAccount17 ConfigCellTypeArgs = "0x21270000"
	ConfigCellTypeArgsPreservedAccount18 ConfigCellTypeArgs = "0x22270000"
	ConfigCellTypeArgsPreservedAccount19 ConfigCellTypeArgs = "0x23270000"

	ConfigCellTypeArgsCharSetEmoji ConfigCellTypeArgs = "0xa0860100"
	ConfigCellTypeArgsCharSetDigit ConfigCellTypeArgs = "0xa1860100"
	ConfigCellTypeArgsCharSetEn    ConfigCellTypeArgs = "0xa2860100"
	ConfigCellTypeArgsCharSetHanS  ConfigCellTypeArgs = "0xa3860100"
	ConfigCellTypeArgsCharSetHanT  ConfigCellTypeArgs = "0xa4860100"
)

func GetConfigCellTypeArgsPreservedAccountByIndex

func GetConfigCellTypeArgsPreservedAccountByIndex(index uint32) ConfigCellTypeArgs

type DasAlgorithmId

type DasAlgorithmId int
const (
	DasAlgorithmIdCkb     DasAlgorithmId = 0
	DasAlgorithmIdEth     DasAlgorithmId = 3
	DasAlgorithmIdTron    DasAlgorithmId = 4
	DasAlgorithmIdEth712  DasAlgorithmId = 5
	DasAlgorithmIdEd25519 DasAlgorithmId = 6
)

func (DasAlgorithmId) Bytes

func (d DasAlgorithmId) Bytes() []byte

func (DasAlgorithmId) ToSoScriptType

func (d DasAlgorithmId) ToSoScriptType() SoScriptType

type DasContractName

type DasContractName string
const (
	DasContractNameAlwaysSuccess  DasContractName = "always-success"
	DasContractNameConfigCellType DasContractName = "config-cell-type"

	DasContractNameDispatchCellType DasContractName = "das-lock"
	DasContractNameAccountCellType  DasContractName = "account-cell-type"
	DasContractNameBalanceCellType  DasContractName = "balance-cell-type"

	DasContractNameApplyRegisterCellType DasContractName = "apply-register-cell-type"
	DasContractNamePreAccountCellType    DasContractName = "pre-account-cell-type"
	DasContractNameProposalCellType      DasContractName = "proposal-cell-type"

	DasContractNameIncomeCellType      DasContractName = "income-cell-type"
	DasContractNameAccountSaleCellType DasContractName = "account-sale-cell-type"

	DasContractNameReverseRecordCellType DasContractName = "reverse-record-cell-type"
	DASContractNameOfferCellType         DasContractName = "offer-cell-type"
)

type DasNetType

type DasNetType = int
const (
	DasNetTypeMainNet  DasNetType = 1
	DasNetTypeTestnet2 DasNetType = 2
	DasNetTypeTestnet3 DasNetType = 3
)

type DataType

type DataType = int

type MMJsonAction

type MMJsonAction struct {
	Action string `json:"action"`
	Params string `json:"params"`
}

type MMJsonCellInfo

type MMJsonCellInfo struct {
	Capacity  string `json:"capacity"`
	LockStr   string `json:"lock"`
	TypeStr   string `json:"type"`
	Data      string `json:"data"`
	ExtraData string `json:"extraData"`
}

type MMJsonObj

type MMJsonObj struct {
	Types struct {
		EIP712Domain []struct {
			Name string `json:"name"`
			Type string `json:"type"`
		} `json:"EIP712Domain"`
		Action []struct {
			Name string `json:"name"`
			Type string `json:"type"`
		} `json:"Action"`
		Cell []struct {
			Name string `json:"name"`
			Type string `json:"type"`
		} `json:"Cell"`
		Transaction []struct {
			Name string `json:"name"`
			Type string `json:"type"`
		} `json:"Transaction"`
	} `json:"types"`
	PrimaryType string `json:"primaryType"`
	Domain      struct {
		ChainID           int64  `json:"chainId"`
		Name              string `json:"name"`
		VerifyingContract string `json:"verifyingContract"`
		Version           string `json:"version"`
	} `json:"domain"`
	Message struct {
		DasMessage      string           `json:"DAS_MESSAGE"`
		InputsCapacity  string           `json:"inputsCapacity"`
		OutputsCapacity string           `json:"outputsCapacity"`
		Fee             string           `json:"fee"`
		Digest          string           `json:"digest"`
		Action          *MMJsonAction    `json:"action"`
		Inputs          []MMJsonCellInfo `json:"inputs"`
		Outputs         []MMJsonCellInfo `json:"outputs"`
	} `json:"message"`
}

func (*MMJsonObj) String

func (m *MMJsonObj) String() string

type SoScriptType

type SoScriptType string
const (
	SoScriptTypeEd25519  SoScriptType = "Ed25519"
	SoScriptTypeEth      SoScriptType = "Eth"
	SoScriptTypeTron     SoScriptType = "Tron"
	SoScriptTypeCkb      SoScriptType = "Ckb"
	SoScriptTypeCkbMulti SoScriptType = "CkbMulti"
)

Jump to

Keyboard shortcuts

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