diff options
author | Maran <maran.hidskes@gmail.com> | 2014-05-05 20:16:53 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2014-05-05 20:16:53 +0800 |
commit | 87a5e94525af7b5d63868ec102f6512c7bb4357b (patch) | |
tree | 0d4aea8d2bb609b623638be37125fe10b1b4ac02 /ethpub | |
parent | b98cc2fb4e296c7a9efe50293cc43d6f9ef6f23d (diff) | |
parent | 5757f5df2a5ffc4207ab2be5f1280d4f2e95d303 (diff) | |
download | go-tangerine-87a5e94525af7b5d63868ec102f6512c7bb4357b.tar go-tangerine-87a5e94525af7b5d63868ec102f6512c7bb4357b.tar.gz go-tangerine-87a5e94525af7b5d63868ec102f6512c7bb4357b.tar.bz2 go-tangerine-87a5e94525af7b5d63868ec102f6512c7bb4357b.tar.lz go-tangerine-87a5e94525af7b5d63868ec102f6512c7bb4357b.tar.xz go-tangerine-87a5e94525af7b5d63868ec102f6512c7bb4357b.tar.zst go-tangerine-87a5e94525af7b5d63868ec102f6512c7bb4357b.zip |
Merge branch 'develop' into feature/rpc
Diffstat (limited to 'ethpub')
-rw-r--r-- | ethpub/pub.go | 21 | ||||
-rw-r--r-- | ethpub/types.go | 36 |
2 files changed, 47 insertions, 10 deletions
diff --git a/ethpub/pub.go b/ethpub/pub.go index 64109dbfa..431f173a0 100644 --- a/ethpub/pub.go +++ b/ethpub/pub.go @@ -54,6 +54,27 @@ func (lib *PEthereum) GetStateObject(address string) *PStateObject { return NewPStateObject(nil) } +func (lib *PEthereum) GetStorage(address, storageAddress string) string { + return lib.GetStateObject(address).GetStorage(storageAddress) +} + +func (lib *PEthereum) GetTxCount(address string) int { + return lib.GetStateObject(address).Nonce() +} + +func (lib *PEthereum) IsContract(address string) bool { + return lib.GetStateObject(address).IsContract() +} + +func (lib *PEthereum) SecretToAddress(key string) string { + pair, err := ethchain.NewKeyPairFromSec(ethutil.FromHex(key)) + if err != nil { + return "" + } + + return ethutil.Hex(pair.Address()) +} + func (lib *PEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) (*PReceipt, error) { return lib.createTx(key, recipient, valueStr, gasStr, gasPriceStr, dataStr, "") } diff --git a/ethpub/types.go b/ethpub/types.go index 522f0e7ac..7f25e48a6 100644 --- a/ethpub/types.go +++ b/ethpub/types.go @@ -59,16 +59,6 @@ func NewPReciept(contractCreation bool, creationAddress, hash, address []byte) * } } -/* -type PKeyRing struct { - Keys []interface{} -} - -func NewPKeyRing(keys []interface{}) *PKeyRing { - return &PKeyRing{Keys: keys} -} -*/ - type PStateObject struct { object *ethchain.StateObject } @@ -105,3 +95,29 @@ func (c *PStateObject) Address() string { return "" } + +func (c *PStateObject) Nonce() int { + if c.object != nil { + return int(c.object.Nonce) + } + + return 0 +} + +func (c *PStateObject) IsContract() bool { + if c.object != nil { + return len(c.object.Script()) > 0 + } + + return false +} + +type PStorageState struct { + StateAddress string + Address string + Value string +} + +func NewPStorageState(storageObject *ethchain.StorageState) *PStorageState { + return &PStorageState{ethutil.Hex(storageObject.StateAddress), ethutil.Hex(storageObject.Address), storageObject.Value.String()} +} |