diff options
author | obscuren <geffobscura@gmail.com> | 2014-04-30 07:44:02 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-04-30 07:44:02 +0800 |
commit | 64c2550b3154df7f2c75dda559d91046cb559ffd (patch) | |
tree | 4dfbaeac371c73b3518566bb0c2e2a141b7d4b49 /ethereal/ui/library.go | |
parent | 922974c760278b6d49cb6f286b663d60f77d5248 (diff) | |
download | go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.tar go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.gz go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.bz2 go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.lz go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.xz go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.tar.zst go-tangerine-64c2550b3154df7f2c75dda559d91046cb559ffd.zip |
Split off External applications from main library
External applications now accept containers which function as the
frontend where the ExtApplication functions as the backend. Containers
execute within their own engine and have their own context and are
destroyed when released.
Diffstat (limited to 'ethereal/ui/library.go')
-rw-r--r-- | ethereal/ui/library.go | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/ethereal/ui/library.go b/ethereal/ui/library.go index 7f667f2c1..ec5f29f95 100644 --- a/ethereal/ui/library.go +++ b/ethereal/ui/library.go @@ -19,9 +19,24 @@ func NewContract(object *ethchain.StateObject) *Contract { } func (c *Contract) GetStorage(address string) string { - val := c.object.GetMem(ethutil.Big("0x" + address)) + // Because somehow, even if you return nil to QML it + // still has some magical object so we can't rely on + // undefined or null at the QML side + if c.object != nil { + val := c.object.GetMem(ethutil.Big("0x" + address)) - return val.BigInt().String() + return val.BigInt().String() + } + + return "" +} + +func (c *Contract) Value() string { + if c.object != nil { + return c.object.Amount.String() + } + + return "" } type EthLib struct { @@ -63,15 +78,23 @@ func (lib *EthLib) GetKey() string { func (lib *EthLib) GetStateObject(address string) *Contract { stateObject := lib.stateManager.ProcState().GetContract(ethutil.FromHex(address)) + if stateObject != nil { + return NewContract(stateObject) + } - return NewContract(stateObject) + // See GetStorage for explanation on "nil" + return NewContract(nil) } -func (lib *EthLib) Watch(addr string) { - lib.stateManager.Watch(ethutil.FromHex(addr)) +func (lib *EthLib) Watch(addr, storageAddr string) { + // lib.stateManager.Watch(ethutil.FromHex(addr), ethutil.FromHex(storageAddr)) } func (lib *EthLib) CreateTx(recipient, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) { + return lib.Transact(recipient, valueStr, gasStr, gasPriceStr, dataStr) +} + +func (lib *EthLib) Transact(recipient, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) { var hash []byte var contractCreation bool if len(recipient) == 0 { |