Versions in this module Expand all Collapse all v0 v0.0.1 Oct 8, 2022 Changes in this version + const SCAddressNumLeadingZeros + var ErrBuiltinFuncWrapperNotInitialized = errors.New("builtin function not found or container not initialized") + var ErrInsufficientFunds = errors.New("insufficient funds") + var ErrInvalidAddressLength = errors.New("invalid address length") + var ErrNilWorldMock = errors.New("nil worldmock") + var ErrOperationNotPermitted = errors.New("operation not permitted") + var ErrTrieHandlingNotImplemented = errors.New("trie handling not implemented") + var WorldMarshalizer = &marshal.GogoProtoMarshalizer + func GenerateMockAddress(creatorAddress []byte, creatorNonce uint64) []byte + func IsSmartContractAddress(address []byte) bool + type Account struct + Address []byte + AsyncCallData string + Balance *big.Int + BalanceDelta *big.Int + Code []byte + CodeHash []byte + CodeMetadata []byte + DeveloperReward *big.Int + Exists bool + IsSmartContract bool + MockWorld *MockWorld + Nonce uint64 + OwnerAddress []byte + RootHash []byte + ShardID uint32 + Storage map[string][]byte + Username []byte + func (a *Account) AccountDataHandler() vmcommon.AccountDataHandler + func (a *Account) AddToBalance(value *big.Int) error + func (a *Account) AddToDeveloperReward(value *big.Int) + func (a *Account) AddressBytes() []byte + func (a *Account) ChangeOwnerAddress(sender []byte, newAddress []byte) error + func (a *Account) ClaimDeveloperRewards(sender []byte) (*big.Int, error) + func (a *Account) ClearDataCaches() + func (a *Account) Clone() *Account + func (a *Account) DirtyData() map[string][]byte + func (a *Account) GetBalance() *big.Int + func (a *Account) GetCode() []byte + func (a *Account) GetCodeHash() []byte + func (a *Account) GetCodeMetadata() []byte + func (a *Account) GetDeveloperReward() *big.Int + func (a *Account) GetNonce() uint64 + func (a *Account) GetOwnerAddress() []byte + func (a *Account) GetRootHash() []byte + func (a *Account) GetTokenBalance(tokenIdentifier []byte, nonce uint64) (*big.Int, error) + func (a *Account) GetTokenBalanceUint64(tokenIdentifier []byte, nonce uint64) (uint64, error) + func (a *Account) GetTokenData(tokenIdentifier []byte, nonce uint64, systemAccStorage map[string][]byte) (*mect.MECToken, error) + func (a *Account) GetUserName() []byte + func (a *Account) IncreaseNonce(nonce uint64) + func (a *Account) IsInterfaceNil() bool + func (a *Account) RetrieveValue(key []byte) ([]byte, error) + func (a *Account) SaveKeyValue(key []byte, value []byte) error + func (a *Account) SetBalance(balance int64) + func (a *Account) SetCode(code []byte) + func (a *Account) SetCodeAndMetadata(code []byte, codeMetadata *vmcommon.CodeMetadata) + func (a *Account) SetCodeHash(hash []byte) + func (a *Account) SetCodeMetadata(codeMetadata []byte) + func (a *Account) SetOwnerAddress(address []byte) + func (a *Account) SetRootHash(hash []byte) + func (a *Account) SetTokenBalance(tokenIdentifier []byte, nonce uint64, balance *big.Int) error + func (a *Account) SetTokenBalanceUint64(tokenIdentifier []byte, nonce uint64, balance uint64) error + func (a *Account) SetTokenData(tokenIdentifier []byte, nonce uint64, tokenData *mect.MECToken) error + func (a *Account) SetTokenRolesAsStrings(tokenIdentifier []byte, rolesAsStrings []string) error + func (a *Account) SetUserName(userName []byte) + func (a *Account) StorageValue(key string) []byte + func (a *Account) SubFromBalance(value *big.Int) error + func (a *Account) Validate() error + type AccountMap map[string]*Account + func NewAccountMap() AccountMap + func (am AccountMap) Clone() AccountMap + func (am AccountMap) CreateAccount(address []byte, world *MockWorld) *Account + func (am AccountMap) CreateSmartContractAccount(owner []byte, address []byte, code []byte, world *MockWorld) *Account + func (am AccountMap) CreateSmartContractAccountWithCodeHash(owner []byte, address []byte, code []byte, codeHash []byte, world *MockWorld) *Account + func (am AccountMap) DeleteAccount(address []byte) + func (am AccountMap) GetAccount(address []byte) *Account + func (am AccountMap) LoadAccountStorageFrom(otherAM AccountMap) error + func (am AccountMap) PutAccount(account *Account) + func (am AccountMap) PutAccounts(accounts []*Account) + type BlockInfo struct + BlockEpoch uint32 + BlockNonce uint64 + BlockRound uint64 + BlockTimestamp uint64 + RandomSeed *[48]byte + func (bi *BlockInfo) GetRandomSeedSlice() []byte + type BuiltinFunctionsWrapper struct + Container vmcommon.BuiltInFunctionContainer + MapDNSAddresses map[string]struct{} + Marshalizer vmcommon.Marshalizer + World *MockWorld + func NewBuiltinFunctionsWrapper(world *MockWorld, gasMap config.GasScheduleMap) (*BuiltinFunctionsWrapper, error) + func (bf *BuiltinFunctionsWrapper) GetBuiltinFunctionNames() vmcommon.FunctionNames + func (bf *BuiltinFunctionsWrapper) GetTokenBalance(address []byte, tokenIdentifier []byte, nonce uint64) (*big.Int, error) + func (bf *BuiltinFunctionsWrapper) GetTokenData(address []byte, tokenIdentifier []byte, nonce uint64) (*mect.MECToken, error) + func (bf *BuiltinFunctionsWrapper) PerformDirectMECTTransfer(sender []byte, receiver []byte, token []byte, nonce uint64, value *big.Int, ...) (uint64, error) + func (bf *BuiltinFunctionsWrapper) PerformDirectMultiMECTTransfer(sender []byte, receiver []byte, mectTransfers []*mj.MECTTxData, ...) (uint64, error) + func (bf *BuiltinFunctionsWrapper) ProcessBuiltInFunction(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error) + func (bf *BuiltinFunctionsWrapper) SetTokenData(address []byte, tokenIdentifier []byte, nonce uint64, tokenData *mect.MECToken) error + type MockAccountsAdapter struct + Snapshots []AccountMap + World *MockWorld + func NewMockAccountsAdapter(world *MockWorld) *MockAccountsAdapter + func (m *MockAccountsAdapter) Commit() ([]byte, error) + func (m *MockAccountsAdapter) GetCode(codeHash []byte) []byte + func (m *MockAccountsAdapter) GetExistingAccount(address []byte) (vmcommon.AccountHandler, error) + func (m *MockAccountsAdapter) GetNumCheckpoints() uint32 + func (m *MockAccountsAdapter) IsInterfaceNil() bool + func (m *MockAccountsAdapter) IsPruningEnabled() bool + func (m *MockAccountsAdapter) JournalLen() int + func (m *MockAccountsAdapter) LoadAccount(address []byte) (vmcommon.AccountHandler, error) + func (m *MockAccountsAdapter) RecreateTrie(_ []byte) error + func (m *MockAccountsAdapter) RemoveAccount(address []byte) error + func (m *MockAccountsAdapter) RevertToSnapshot(snapshotIndex int) error + func (m *MockAccountsAdapter) RootHash() ([]byte, error) + func (m *MockAccountsAdapter) SaveAccount(account vmcommon.AccountHandler) error + func (m *MockAccountsAdapter) SetStateCheckpoint(_ []byte, _ context.Context) + func (m *MockAccountsAdapter) SnapshotState(_ []byte, _ context.Context) + type MockWorld struct + AccountsAdapter vmcommon.AccountsAdapter + AcctMap AccountMap + Blockhashes [][]byte + BuiltinFuncs *BuiltinFunctionsWrapper + CompiledCode map[string][]byte + CurrentBlockInfo *BlockInfo + Err error + IsLimitedTransferValue bool + IsPausedValue bool + LastCreatedContractAddress []byte + NewAddressMocks []*NewAddressMock + PreviousBlockInfo *BlockInfo + SelfShardID uint32 + StateRootHash []byte + func NewMockWorld() *MockWorld + func (b *MockWorld) Clear() + func (b *MockWorld) ClearCompiledCodes() + func (b *MockWorld) CommitChanges() error + func (b *MockWorld) CommunicationIdentifier(destShardID uint32) string + func (b *MockWorld) ComputeId(address []byte) uint32 + func (b *MockWorld) CreateStateBackup() + func (b *MockWorld) CurrentEpoch() uint32 + func (b *MockWorld) CurrentNonce() uint64 + func (b *MockWorld) CurrentRandomSeed() []byte + func (b *MockWorld) CurrentRound() uint64 + func (b *MockWorld) CurrentTimeStamp() uint64 + func (b *MockWorld) GetAllState(accountAddress []byte) (map[string][]byte, error) + func (b *MockWorld) GetBlockhash(nonce uint64) ([]byte, error) + func (b *MockWorld) GetBuiltinFunctionNames() vmcommon.FunctionNames + func (b *MockWorld) GetCode(acc vmcommon.UserAccountHandler) []byte + func (b *MockWorld) GetCompiledCode(codeHash []byte) (bool, []byte) + func (b *MockWorld) GetMECTToken(address []byte, tokenIdentifier []byte, nonce uint64) (*mect.MECToken, error) + func (b *MockWorld) GetShardOfAddress(address []byte) uint32 + func (b *MockWorld) GetSnapshot() int + func (b *MockWorld) GetStateRootHash() []byte + func (b *MockWorld) GetStorageData(accountAddress []byte, key []byte) ([]byte, error) + func (b *MockWorld) GetUserAccount(address []byte) (vmcommon.UserAccountHandler, error) + func (b *MockWorld) InitBuiltinFunctions(gasMap config.GasScheduleMap) error + func (b *MockWorld) IsInterfaceNil() bool + func (b *MockWorld) IsLimitedTransfer(_ []byte) bool + func (b *MockWorld) IsPaused(_ []byte) bool + func (b *MockWorld) IsPayable(sndAddress []byte, rcvAddress []byte) (bool, error) + func (b *MockWorld) IsSmartContract(address []byte) bool + func (b *MockWorld) LastEpoch() uint32 + func (b *MockWorld) LastNonce() uint64 + func (b *MockWorld) LastRandomSeed() []byte + func (b *MockWorld) LastRound() uint64 + func (b *MockWorld) LastTimeStamp() uint64 + func (b *MockWorld) NewAddress(creatorAddress []byte, creatorNonce uint64, _ []byte) ([]byte, error) + func (b *MockWorld) NumberOfShards() uint32 + func (b *MockWorld) ProcessBuiltInFunction(input *vmcommon.ContractCallInput) (*vmcommon.VMOutput, error) + func (b *MockWorld) RevertToSnapshot(snapshot int) error + func (b *MockWorld) RollbackChanges() error + func (b *MockWorld) SameShard(firstAddress []byte, secondAddress []byte) bool + func (b *MockWorld) SaveCompiledCode(codeHash []byte, code []byte) + func (b *MockWorld) SelfId() uint32 + func (b *MockWorld) SetCurrentBlockHash(blockHash []byte) + func (b *MockWorld) UpdateAccountFromOutputAccount(modAcct *vmcommon.OutputAccount) + func (b *MockWorld) UpdateAccounts(outputAccounts map[string]*vmcommon.OutputAccount, accountsToDelete [][]byte) error + func (b *MockWorld) UpdateBalance(address []byte, newBalance *big.Int) error + func (b *MockWorld) UpdateBalanceWithDelta(address []byte, balanceDelta *big.Int) error + func (b *MockWorld) UpdateWorldStateBefore(fromAddr []byte, gasLimit uint64, gasPrice uint64) error + type NewAddressMock struct + CreatorAddress []byte + CreatorNonce uint64 + NewAddress []byte