diff --git a/client/client.go b/client/client.go index b1bfd146452d730b88f3a237cdf8308cdfd6e7b7..d2674c01c51347331909986fc2a710c7d3a1720c 100644 --- a/client/client.go +++ b/client/client.go @@ -71,23 +71,6 @@ func (erisNodeClient *ErisNodeClient) Broadcast(tx txs.Tx) (*txs.Receipt, error) //------------------------------------------------------------------------------------ // RPC requests other than transaction related -// GetAccount returns a copy of the account -func (erisNodeClient *ErisNodeClient) GetAccount(address []byte) (*acc.Account, error) { - client := rpcclient.NewClientURI(erisNodeClient.broadcastRPC) - account, err := tendermint_client.GetAccount(client, address) - if err != nil { - err = fmt.Errorf("Error connecting to node (%s) to fetch account (%X): %s", - erisNodeClient.broadcastRPC, address, err.Error()) - return nil, err - } - if account == nil { - err = fmt.Errorf("Unknown account %X at node (%s)", address, erisNodeClient.broadcastRPC) - return nil, err - } - - return account.Copy(), nil -} - // Status returns the ChainId (GenesisHash), validator's PublicKey, latest block hash // the block height and the latest block time. func (erisNodeClient *ErisNodeClient) Status() (ChainId []byte, ValidatorPublicKey []byte, LatestBlockHash []byte, LatestBlockHeight int, LatestBlockTime int64, err error) { @@ -137,3 +120,42 @@ func (erisNodeClient *ErisNodeClient) QueryContractCode(address, code, data []by return callResult.Return, callResult.GasUsed, nil } +// GetAccount returns a copy of the account +func (erisNodeClient *ErisNodeClient) GetAccount(address []byte) (*acc.Account, error) { + client := rpcclient.NewClientURI(erisNodeClient.broadcastRPC) + account, err := tendermint_client.GetAccount(client, address) + if err != nil { + err = fmt.Errorf("Error connecting to node (%s) to fetch account (%X): %s", + erisNodeClient.broadcastRPC, address, err.Error()) + return nil, err + } + if account == nil { + err = fmt.Errorf("Unknown account %X at node (%s)", address, erisNodeClient.broadcastRPC) + return nil, err + } + + return account.Copy(), nil +} + +// DumpStorage +func (erisNodeClient *ErisNodeClient) DumpStorage(address []byte) (storageRoot []byte) + + +//-------------------------------------------------------------------------------------------- +// Name registry + +func (erisNodeClient *ErisNodeClient) GetName(name string) (owner []byte, data []byte, expirationBlock int, err error) { + client := rpcclient.NewClientURI(erisNodeClient.broadcastRPC) + entryResult, err := tendermint_client.GetName(client, name) + if err != nil { + err = fmt.Errorf("Error connecting to node (%s) to get name registrar entry for name (%s)", + erisNodeClient.broadcastRPC, name) + return nil, nil, 0, err + } + // unwrap return results + owner = *entryResult.Owner + data = []byte(entryResult.Data) + expirationBlock = entryResult.Expires + return +} + diff --git a/client/core/transaction_factory.go b/client/core/transaction_factory.go index 73c6f5c2814b182a9588f960b2504acab1a9d910..92400243f22f1b670d6fef5968db87f37f5dcee2 100644 --- a/client/core/transaction_factory.go +++ b/client/core/transaction_factory.go @@ -184,30 +184,6 @@ func Permissions(nodeClient client.NodeClient, keyClient keys.KeyClient, pubkey, return tx, nil } -// type NameGetter struct { -// client cclient.Client -// } - -// func (n NameGetter) GetNameRegEntry(name string) *txs.NameRegEntry { -// entry, err := n.client.GetName(name) -// if err != nil { -// panic(err) -// } -// return entry.Entry -// } - -/* -func coreNewAccount(nodeAddr, pubkey, chainID string) (*types.NewAccountTx, error) { - pub, _, _, err := checkCommon(nodeAddr, pubkey, "", "0", "0") - if err != nil { - return nil, err - } - - client := cclient.NewClient(nodeAddr, "HTTP") - return types.NewNewAccountTx(NameGetter{client}, pub, chainID) -} -*/ - // func Bond(nodeAddr, signAddr, pubkey, unbondAddr, amtS, nonceS string) (*txs.BondTx, error) { // pub, amt, nonce, err := checkCommon(nodeAddr, signAddr, pubkey, "", amtS, nonceS) // if err != nil {