Documentation ¶
Index ¶
- Constants
- Variables
- func DexInitialize(genesis *types.Context, classMap map[string]uint64, ...) (*common.Address, *common.Address, *common.Address, *common.Address, ...)
- func Exec(ctx *types.Context, user common.Address, contAddr common.Address, ...) ([]interface{}, error)
- func Exp(a, b *big.Int) *big.Int
- func FormulatorInitialize(genesis *types.Context, classMap map[string]uint64, mev, admin common.Address, ...) (*common.Address, error)
- func GetAbi(abiPath string) (map[string]interface{}, *abi.ABI, error)
- func GetCC(ctx *types.Context, contAddr common.Address, user common.Address) (*types.ContractContext, error)
- func GetSingers(chainID *big.Int) ([]key.Key, error)
- func HaveSameElements(a, b []common.Address) bool
- func MevInitialize(ctx *types.Context, classMap map[string]uint64, owner common.Address, ...) (*common.Address, error)
- func NewRewardPoolTx(senderKey key.Key, nonceIncrement uint64, provider types.Provider, ...) (*RewardPool, *TxWithSigner, error)
- func RemoveChainData(path string) error
- func Sub(a, b *big.Int) *big.Int
- func ToAmount(b *big.Int) *amount.Amount
- func TokenApprove(ctx *types.Context, token, owner, spender common.Address) error
- type EvmContract
- type FormulatorContract
- func (c *FormulatorContract) BuyFormulatorTx(senderKey key.Key, tokenID common.Address) *TxWithSigner
- func (c *FormulatorContract) CreateAlphaTx(senderKey key.Key) *TxWithSigner
- func (c *FormulatorContract) CreateOmegaTx(senderKey key.Key, tokenIDs []common.Address) *TxWithSigner
- func (c *FormulatorContract) CreateSigmaTx(senderKey key.Key, tokenIDs []common.Address) *TxWithSigner
- func (c *FormulatorContract) RegisterSalesTx(senderKey key.Key, tokenID common.Address, amt *amount.Amount) *TxWithSigner
- func (c *FormulatorContract) RevokeTx(senderKey key.Key, tokenID common.Address) *TxWithSigner
- func (c *FormulatorContract) SyncGeneratorTx(senderKey key.Key) *TxWithSigner
- func (c *FormulatorContract) TransferFromTx(senderKey key.Key, from, to, tokenID common.Address) *TxWithSigner
- type GoContract
- type IEvmContract
- type InitContextInfo
- type JsonClient
- func (jc *JsonClient) GetBlockByNumber(height uint32, isFull bool) map[string]interface{}
- func (jc *JsonClient) GetLogs(filterMap map[string]interface{}) []*types.Log
- func (jc *JsonClient) GetTransactionReceipt(hash common.Hash) map[string]interface{}
- func (jc *JsonClient) ViewCall(to *common.Address, method string, params ...any) interface{}
- type Mrc20Token
- type RewardPool
- type RouterContract
- type TestBlockChain
- type TokenContract
- type TsMock
- func (t *TsMock) AddBlock(b *types.Block)
- func (t *TsMock) AddressTxList(From common.Address, index, size int) ([]itxsearch.TxList, error)
- func (t *TsMock) Block(i uint32) (*types.Block, error)
- func (t *TsMock) BlockHeight(bh hash.Hash256) (uint32, error)
- func (t *TsMock) BlockList(index int) []*itxsearch.BlockInfo
- func (t *TsMock) Name() string
- func (t *TsMock) OnBlockConnected(b *types.Block, loader types.Loader)
- func (t *TsMock) OnLoadChain(loader types.Loader) error
- func (t *TsMock) OnTransactionFail(height uint32, txs []*types.Transaction, err []error)
- func (t *TsMock) OnTransactionInPoolExpired(txs []*types.Transaction)
- func (t *TsMock) Reward(cont, rewarder common.Address) (*amount.Amount, error)
- func (t *TsMock) TokenTxList(From common.Address, index, size int) ([]itxsearch.TxList, error)
- func (t *TsMock) Tx(height uint32, index uint16) (map[string]interface{}, error)
- func (t *TsMock) TxIndex(th hash.Hash256) (itxsearch.TxID, error)
- func (t *TsMock) TxList(index, size int) ([]itxsearch.TxList, error)
- type TxWithSigner
- func DeployFormulatorTx(tb *TestBlockChain, senderKey key.Key, mev, admin common.Address) (*TxWithSigner, error)
- func DeployTokenTx(tb *TestBlockChain, senderKey key.Key, name, symbol string, ...) (*TxWithSigner, error)
- func MakeGoTx(senderKey key.Key, provider types.Provider, cont *common.Address, ...) *TxWithSigner
- func NewEvmContractTx(cont IEvmContract, senderKey key.Key, nonceIncrement uint64, ...) (*TxWithSigner, error)
- func NewTxWithSigner(tx *types.Transaction, signer key.Key) *TxWithSigner
- type UserReward
Constants ¶
const ( ChainDataPath = "_data" BloomDataPath = "_bloombits" BloomBitsBlocks = 24 BloomConfirms = 10 )
const GasLimit uint64 = 0x1DCD6500 // 500000000
Variables ¶
var ( ErrFileRead = errors.New("File Read Error") ErrArgument = errors.New("Argument Error") )
var ( Zero = big.NewInt(0) ZeroAmount = amount.NewAmount(0, 0) MaxUint256 = ToAmount(Sub(Exp(big.NewInt(2), big.NewInt(256)), big.NewInt(1))) ZeroAddress = common.Address{} )
var ( ChainID = big.NewInt(61337) // mainnet 1, testnet 65535, local 61337 Version = uint16(2) GasPrice = big.NewInt(748488682) )
var DefaultFormulatorPolicy = &formulator.FormulatorPolicy{ AlphaAmount: amount.NewAmount(200000, 0), SigmaCount: 4, SigmaBlocks: 200, OmegaCount: 2, OmegaBlocks: 300, HyperAmount: amount.NewAmount(3000000, 0), MinStakeAmount: amount.NewAmount(100, 0), }
var DefaultInitContextInfo = &InitContextInfo{}
Functions ¶
func DexInitialize ¶
func DexInitialize(genesis *types.Context, classMap map[string]uint64, owner, winner common.Address, intialSupplyMap map[common.Address]*amount.Amount) (*common.Address, *common.Address, *common.Address, *common.Address, *common.Address, *common.Address, error)
DexInitialize deploy dex contracts and mint neccesary tokens to sigers
func Exec ¶
func Exec(ctx *types.Context, user common.Address, contAddr common.Address, methodName string, args []interface{}) ([]interface{}, error)
Exec calls ContractContext.Exec from Context
func FormulatorInitialize ¶
func FormulatorInitialize(genesis *types.Context, classMap map[string]uint64, mev, admin common.Address, alphaOwners, sigmaOwners, omegaOwners []common.Address) (*common.Address, error)
FormulatorInitialize deploy formulator contract and set alpha, sigma and omega Owners
func GetCC ¶
func GetCC(ctx *types.Context, contAddr common.Address, user common.Address) (*types.ContractContext, error)
GetCC gets ContractContext from Contex with given contract address and user address
func GetSingers ¶
getSigners gets signers which are same with hardhat node users in order to test in tandem
func HaveSameElements ¶
HaveSameElements tells whether a and b contain the same elements.
func MevInitialize ¶
func MevInitialize(ctx *types.Context, classMap map[string]uint64, owner common.Address, initialSupplyMap map[common.Address]*amount.Amount) (*common.Address, error)
MevInitialize deploy mev Token, mint to sigers and register mainToken as mev
func NewRewardPoolTx ¶
func NewRewardPoolTx(senderKey key.Key, nonceIncrement uint64, provider types.Provider, tokenAddress *common.Address) (*RewardPool, *TxWithSigner, error)
NewRewardPoolTx makes New Reward Pool deploy Transaction
func RemoveChainData ¶
RemoveChainData removes data directory which includes data files
Types ¶
type EvmContract ¶
Evm Contract
func (*EvmContract) MakeEvmTx ¶
func (c *EvmContract) MakeEvmTx(senderKey key.Key, nonceIncrement uint64, method string, args ...any) (*TxWithSigner, error)
MakeEvmTx makes Evm Tx by argument([]any) @arg nonceIncrement : 한 signer가 동시여 여러개의 transaction을 실행할경우 nonceIncrement로 조정해 주어야 한다.
func (*EvmContract) SetAddress ¶
func (c *EvmContract) SetAddress(addr *common.Address)
SetAddress sets the address of EvmContract
type FormulatorContract ¶
type FormulatorContract struct {
GoContract
}
Formulator is a Go Formulator Contract
func BindFormulatorContract ¶
func BindFormulatorContract(address *common.Address, provider types.Provider) *FormulatorContract
NewFormulatorContract gets the depoloyed formulator contract by address
func (*FormulatorContract) BuyFormulatorTx ¶
func (c *FormulatorContract) BuyFormulatorTx(senderKey key.Key, tokenID common.Address) *TxWithSigner
BuyFormulatorTx returns the BuyFormulator method tx of the Formulator contract
func (*FormulatorContract) CreateAlphaTx ¶
func (c *FormulatorContract) CreateAlphaTx(senderKey key.Key) *TxWithSigner
CreateAlphaTx returns the CreateAlpha method tx of the Formulator contract
func (*FormulatorContract) CreateOmegaTx ¶
func (c *FormulatorContract) CreateOmegaTx(senderKey key.Key, tokenIDs []common.Address) *TxWithSigner
CreateOmegaTx returns the CreateOmega method tx of the Formulator contract
func (*FormulatorContract) CreateSigmaTx ¶
func (c *FormulatorContract) CreateSigmaTx(senderKey key.Key, tokenIDs []common.Address) *TxWithSigner
CreateSigmaTx returns the CreateSigma method tx of the Formulator contract
func (*FormulatorContract) RegisterSalesTx ¶
func (c *FormulatorContract) RegisterSalesTx(senderKey key.Key, tokenID common.Address, amt *amount.Amount) *TxWithSigner
RegisterSalesTx returns the RegisterSales method tx of the Formulator contract
func (*FormulatorContract) RevokeTx ¶
func (c *FormulatorContract) RevokeTx(senderKey key.Key, tokenID common.Address) *TxWithSigner
RevokeTx returns the Revoke method tx of the Formulator contract
func (*FormulatorContract) SyncGeneratorTx ¶
func (c *FormulatorContract) SyncGeneratorTx(senderKey key.Key) *TxWithSigner
SyncGeneratorTx returns the SyncGenerator method tx of the Formulator contract
func (*FormulatorContract) TransferFromTx ¶
func (c *FormulatorContract) TransferFromTx(senderKey key.Key, from, to, tokenID common.Address) *TxWithSigner
TransferFromTx returns the TransferFrom method tx of the Formulator contract
type GoContract ¶
GoContract
func (*GoContract) SetAddress ¶
func (c *GoContract) SetAddress(addr *common.Address)
SetAddress sets the address of GoContract
func (*GoContract) SetProvider ¶
func (c *GoContract) SetProvider(provider types.Provider)
SetProvider sets the provider of GoContract
type IEvmContract ¶
type IEvmContract interface { Set(abi *abi.ABI, provider types.Provider, addr *common.Address) SetAddress(*common.Address) // contains filtered or unexported methods }
Evm Contract Interface
type InitContextInfo ¶
type InitContextInfo struct { InitGenesisHash string InitHash string InitHeight uint32 InitTimestamp uint64 }
InitContextInfo struct is parameters for meverse chain with non-zero initheight
type JsonClient ¶
type JsonClient struct {
// contains filtered or unexported fields
}
JsonClient is a json-rpc senter
func NewJsonClient ¶
func NewJsonClient(tb *TestBlockChain) *JsonClient
NewJsonClient makes a new JsonClient
func (*JsonClient) GetBlockByNumber ¶
func (jc *JsonClient) GetBlockByNumber(height uint32, isFull bool) map[string]interface{}
GetBlockByNumber executes an eth_getBlockByNumber json-rpc
func (*JsonClient) GetLogs ¶
func (jc *JsonClient) GetLogs(filterMap map[string]interface{}) []*types.Log
GetLogs executes an eth_getLogs json-rpc filterMap := map[string]interface{}{} filterMap["address"] = address.String() filterMap["blockHash"] = blockHash.String() filterMap["fromBlock"] = fmt.Sprintf("0x%x", *big.Int) filterMap["toBlock"] = fmt.Sprintf("0x%x", *big.Int) filterMap["topics"] = []interface{}{[]interface{}{transferHash.String()}} or
[]interface{}{transferHash.String()}
topics : service/bloomservice/filter.go FilterQuery struct 참조
func (*JsonClient) GetTransactionReceipt ¶
func (jc *JsonClient) GetTransactionReceipt(hash common.Hash) map[string]interface{}
GetTransactionReceipt executes an eth_getTransactionReceipt json-rpc
type Mrc20Token ¶
type Mrc20Token struct {
EvmContract
}
Mrc20Token is deployed by Go-Contract, but has a similiar ERC20-token-abi
func NewMrc20Token ¶
func NewMrc20Token(tb *TestBlockChain, senderKey key.Key, name, symbol string) (*Mrc20Token, error)
NewMrc20Token deploy Go Token Contract and convert to Evm MRC20 Token
func NewMrc20TokenFromAddress ¶
func NewMrc20TokenFromAddress(contractAddress *common.Address, provider types.Provider) (*Mrc20Token, error)
NewMrc20TokenFromAddress makes Mrc20Token EVm Contract with address
type RewardPool ¶
type RewardPool struct {
EvmContract
}
type RewardPool Contract source code : fleta2.0/contracts/RewardPool/RewardPool.sol
func (*RewardPool) AddRewardTx ¶
func (c *RewardPool) AddRewardTx(senderKey key.Key, nonceIncrement uint64, total *big.Int, userRewards []UserReward) (*TxWithSigner, error)
AddRewardTx returns the addReward method tx of the RewardPool contract
func (*RewardPool) ClaimTx ¶
func (c *RewardPool) ClaimTx(senderKey key.Key, nonceIncrement uint64) (*TxWithSigner, error)
ClaimTx returns the claim method tx of the RewardPool contract
type RouterContract ¶
type RouterContract struct {
GoContract
}
Router is a Go Router Contract
func BindRouterContract ¶
func BindRouterContract(address *common.Address, provider types.Provider) *RouterContract
NewGoContract makes new Go Contract
func (*RouterContract) UniAddLiquidityTx ¶
func (c *RouterContract) UniAddLiquidityTx(senderKey key.Key, token0, token1 common.Address, amountADesired, amountBDesired, amountAMin, amountBMin *amount.Amount) *TxWithSigner
UniAddLiquidityTx returns the UniAddLiquidity method tx of the Router contract
type TestBlockChain ¶
type TestBlockChain struct { ChainID *big.Int // Version uint16 Path string // 화일저장 디렉토리 Chain *chain.Chain Store *chain.Store Provider types.Provider FrKeyMap map[common.Address]key.Key ClassMap map[string]uint64 StepMiliSeconds uint64 // interval from previous transaction Ts itxsearch.ITxSearch Bs *bloomservice.BloomBitService // contains filtered or unexported fields }
TestBlockChain is blockchain mock for testing
func NewTestBlockChain ¶
func NewTestBlockChainWithGenesis ¶
func NewTestBlockChainWithGenesis(path string, deletePath bool, chainID *big.Int, version uint16, genesis *types.Context, admin common.Address, cfg *InitContextInfo, classMap map[string]uint64) (*TestBlockChain, error)
NewTestBlockChain makes new test blockchain
func (*TestBlockChain) AddBlock ¶
func (tb *TestBlockChain) AddBlock(txs []*TxWithSigner) (*types.Block, error)
AddBlock adds a block containing txs The block time forwarded by tb.StepMiliSeconds
func (*TestBlockChain) HandleJRPC ¶
func (tb *TestBlockChain) HandleJRPC(req *apiserver.JRPCRequest) interface{}
newContext calls chain.NewContext()
func (*TestBlockChain) MustAddBlock ¶
func (tb *TestBlockChain) MustAddBlock(txs []*TxWithSigner) *types.Block
MustAddBlock adds a block containing txs without err The block time forwarded by tb.StepMiliSeconds
type TokenContract ¶
type TokenContract struct {
GoContract
}
Token is a Go Token Contract
func BindTokenContract ¶
func BindTokenContract(address *common.Address, provider types.Provider) *TokenContract
NewGoContract makes new Go Contract
func (*TokenContract) ApproveTx ¶
func (c *TokenContract) ApproveTx(senderKey key.Key, to common.Address, amt *amount.Amount) *TxWithSigner
ApproveTx returns the Approve method tx of the Token contract
func (*TokenContract) TransferTx ¶
func (c *TokenContract) TransferTx(senderKey key.Key, to common.Address, amt *amount.Amount) *TxWithSigner
TransferTx returns the Transfer method tx of the Token contract
type TsMock ¶
type TsMock struct {
// contains filtered or unexported fields
}
tsMock is the mock of txsearch service range로 검색할 경우 txsearch는 필요없기 때문에 mock으로 가능
func (*TsMock) AddressTxList ¶
func (*TsMock) OnBlockConnected ¶
OnBlockConnected called when a block is connected to the chain
func (*TsMock) OnLoadChain ¶
OnLoadChain called when the chain loaded
func (*TsMock) OnTransactionFail ¶
func (t *TsMock) OnTransactionFail(height uint32, txs []*types.Transaction, err []error)
OnTransactionFail called when the tx fail
func (*TsMock) OnTransactionInPoolExpired ¶
func (t *TsMock) OnTransactionInPoolExpired(txs []*types.Transaction)
OnLoadChain called when the chain loaded
func (*TsMock) TokenTxList ¶
type TxWithSigner ¶
type TxWithSigner struct { Tx *types.Transaction Signer key.Key }
non-evmtype transaction with signer key
func DeployFormulatorTx ¶
func DeployFormulatorTx(tb *TestBlockChain, senderKey key.Key, mev, admin common.Address) (*TxWithSigner, error)
DeployFormulatorTx makes the formulator deploy tx
func DeployTokenTx ¶
func DeployTokenTx(tb *TestBlockChain, senderKey key.Key, name, symbol string, initialSupplyMap map[common.Address]*amount.Amount) (*TxWithSigner, error)
DeployTokenTx makes the token deploy tx
func MakeGoTx ¶
func MakeGoTx(senderKey key.Key, provider types.Provider, cont *common.Address, method string, args ...any) *TxWithSigner
MakeGoContract makes go Contract transaction
func NewEvmContractTx ¶
func NewEvmContractTx(cont IEvmContract, senderKey key.Key, nonceIncrement uint64, provider types.Provider, abiPath string, args ...any) (*TxWithSigner, error)
NewEvmContract makes new Contract, abiPath is relative path
func NewTxWithSigner ¶
func NewTxWithSigner(tx *types.Transaction, signer key.Key) *TxWithSigner
NewTxWithSigner makes a new TxWithSigner struct