aboutsummaryrefslogtreecommitdiffstats
path: root/mobile
diff options
context:
space:
mode:
Diffstat (limited to 'mobile')
-rw-r--r--mobile/android_test.go15
-rw-r--r--mobile/bind.go6
-rw-r--r--mobile/ethclient.go4
-rw-r--r--mobile/ethereum.go5
-rw-r--r--mobile/geth.go1
-rw-r--r--mobile/types.go28
6 files changed, 31 insertions, 28 deletions
diff --git a/mobile/android_test.go b/mobile/android_test.go
index 345e009b4..3d3bd66d0 100644
--- a/mobile/android_test.go
+++ b/mobile/android_test.go
@@ -72,7 +72,7 @@ public class AndroidTest extends InstrumentationTestCase {
Transaction tx = new Transaction(
1, new Address("0x0000000000000000000000000000000000000000"),
- new BigInt(0), new BigInt(0), new BigInt(1), null); // Random empty transaction
+ new BigInt(0), 0, new BigInt(1), null); // Random empty transaction
BigInt chain = new BigInt(1); // Chain identifier of the main net
// Sign a transaction with a single authorization
@@ -164,12 +164,17 @@ func TestAndroid(t *testing.T) {
t.Skip("command gradle not found, skipping")
}
if sdk := os.Getenv("ANDROID_HOME"); sdk == "" {
- t.Skip("ANDROID_HOME environment var not set, skipping")
+ // Android SDK not explicitly given, try to auto-resolve
+ autopath := filepath.Join(os.Getenv("HOME"), "Android", "Sdk")
+ if _, err := os.Stat(autopath); err != nil {
+ t.Skip("ANDROID_HOME environment var not set, skipping")
+ }
+ os.Setenv("ANDROID_HOME", autopath)
}
if _, err := exec.Command("which", "gomobile").CombinedOutput(); err != nil {
t.Log("gomobile missing, installing it...")
- if _, err := exec.Command("go", "install", "golang.org/x/mobile/cmd/gomobile").CombinedOutput(); err != nil {
- t.Fatalf("install failed: %v", err)
+ if out, err := exec.Command("go", "get", "golang.org/x/mobile/cmd/gomobile").CombinedOutput(); err != nil {
+ t.Fatalf("install failed: %v\n%s", err, string(out))
}
t.Log("initializing gomobile...")
start := time.Now()
@@ -239,7 +244,7 @@ const gradleConfig = `buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.5.0'
+ classpath 'com.android.tools.build:gradle:2.2.3'
}
}
allprojects {
diff --git a/mobile/bind.go b/mobile/bind.go
index e8164d523..d6e621a25 100644
--- a/mobile/bind.go
+++ b/mobile/bind.go
@@ -77,7 +77,7 @@ func (opts *TransactOpts) GetFrom() *Address { return &Address{opts.opts.From
func (opts *TransactOpts) GetNonce() int64 { return opts.opts.Nonce.Int64() }
func (opts *TransactOpts) GetValue() *BigInt { return &BigInt{opts.opts.Value} }
func (opts *TransactOpts) GetGasPrice() *BigInt { return &BigInt{opts.opts.GasPrice} }
-func (opts *TransactOpts) GetGasLimit() int64 { return opts.opts.GasLimit.Int64() }
+func (opts *TransactOpts) GetGasLimit() int64 { return int64(opts.opts.GasLimit) }
// GetSigner cannot be reliably implemented without identity preservation (https://github.com/golang/go/issues/16876)
// func (opts *TransactOpts) GetSigner() Signer { return &signer{opts.opts.Signer} }
@@ -99,7 +99,7 @@ func (opts *TransactOpts) SetSigner(s Signer) {
}
func (opts *TransactOpts) SetValue(value *BigInt) { opts.opts.Value = value.bigint }
func (opts *TransactOpts) SetGasPrice(price *BigInt) { opts.opts.GasPrice = price.bigint }
-func (opts *TransactOpts) SetGasLimit(limit int64) { opts.opts.GasLimit = big.NewInt(limit) }
+func (opts *TransactOpts) SetGasLimit(limit int64) { opts.opts.GasLimit = uint64(limit) }
func (opts *TransactOpts) SetContext(context *Context) { opts.opts.Context = context.context }
// BoundContract is the base wrapper object that reflects a contract on the
@@ -138,7 +138,7 @@ func BindContract(address *Address, abiJSON string, client *EthereumClient) (con
return nil, err
}
return &BoundContract{
- contract: bind.NewBoundContract(address.address, parsed, client.client, client.client),
+ contract: bind.NewBoundContract(address.address, parsed, client.client, client.client, client.client),
address: address.address,
}, nil
}
diff --git a/mobile/ethclient.go b/mobile/ethclient.go
index 758863b6d..66399c6b5 100644
--- a/mobile/ethclient.go
+++ b/mobile/ethclient.go
@@ -298,9 +298,9 @@ func (ec *EthereumClient) SuggestGasPrice(ctx *Context) (price *BigInt, _ error)
// the current pending state of the backend blockchain. There is no guarantee that this is
// the true gas limit requirement as other transactions may be added or removed by miners,
// but it should provide a basis for setting a reasonable default.
-func (ec *EthereumClient) EstimateGas(ctx *Context, msg *CallMsg) (gas *BigInt, _ error) {
+func (ec *EthereumClient) EstimateGas(ctx *Context, msg *CallMsg) (gas int64, _ error) {
rawGas, err := ec.client.EstimateGas(ctx.context, msg.msg)
- return &BigInt{rawGas}, err
+ return int64(rawGas), err
}
// SendTransaction injects a signed transaction into the pending pool for execution.
diff --git a/mobile/ethereum.go b/mobile/ethereum.go
index c9bb3013c..0eb1d9055 100644
--- a/mobile/ethereum.go
+++ b/mobile/ethereum.go
@@ -20,7 +20,6 @@ package geth
import (
"errors"
- "math/big"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/common"
@@ -49,7 +48,7 @@ func NewCallMsg() *CallMsg {
}
func (msg *CallMsg) GetFrom() *Address { return &Address{msg.msg.From} }
-func (msg *CallMsg) GetGas() int64 { return msg.msg.Gas.Int64() }
+func (msg *CallMsg) GetGas() int64 { return int64(msg.msg.Gas) }
func (msg *CallMsg) GetGasPrice() *BigInt { return &BigInt{msg.msg.GasPrice} }
func (msg *CallMsg) GetValue() *BigInt { return &BigInt{msg.msg.Value} }
func (msg *CallMsg) GetData() []byte { return msg.msg.Data }
@@ -61,7 +60,7 @@ func (msg *CallMsg) GetTo() *Address {
}
func (msg *CallMsg) SetFrom(address *Address) { msg.msg.From = address.address }
-func (msg *CallMsg) SetGas(gas int64) { msg.msg.Gas = big.NewInt(gas) }
+func (msg *CallMsg) SetGas(gas int64) { msg.msg.Gas = uint64(gas) }
func (msg *CallMsg) SetGasPrice(price *BigInt) { msg.msg.GasPrice = price.bigint }
func (msg *CallMsg) SetValue(value *BigInt) { msg.msg.Value = value.bigint }
func (msg *CallMsg) SetData(data []byte) { msg.msg.Data = common.CopyBytes(data) }
diff --git a/mobile/geth.go b/mobile/geth.go
index 7b39faade..7e3b8f491 100644
--- a/mobile/geth.go
+++ b/mobile/geth.go
@@ -116,7 +116,6 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) {
P2P: p2p.Config{
NoDiscovery: true,
DiscoveryV5: true,
- DiscoveryV5Addr: ":0",
BootstrapNodesV5: config.BootstrapNodes.nodes,
ListenAddr: ":0",
NAT: nat.Any(),
diff --git a/mobile/types.go b/mobile/types.go
index b7f8a3bc1..4790afcef 100644
--- a/mobile/types.go
+++ b/mobile/types.go
@@ -112,8 +112,8 @@ func (h *Header) GetReceiptHash() *Hash { return &Hash{h.header.ReceiptHash} }
func (h *Header) GetBloom() *Bloom { return &Bloom{h.header.Bloom} }
func (h *Header) GetDifficulty() *BigInt { return &BigInt{h.header.Difficulty} }
func (h *Header) GetNumber() int64 { return h.header.Number.Int64() }
-func (h *Header) GetGasLimit() int64 { return h.header.GasLimit.Int64() }
-func (h *Header) GetGasUsed() int64 { return h.header.GasUsed.Int64() }
+func (h *Header) GetGasLimit() int64 { return int64(h.header.GasLimit) }
+func (h *Header) GetGasUsed() int64 { return int64(h.header.GasUsed) }
func (h *Header) GetTime() int64 { return h.header.Time.Int64() }
func (h *Header) GetExtra() []byte { return h.header.Extra }
func (h *Header) GetMixDigest() *Hash { return &Hash{h.header.MixDigest} }
@@ -189,8 +189,8 @@ func (b *Block) GetReceiptHash() *Hash { return &Hash{b.block.ReceiptHash()} }
func (b *Block) GetBloom() *Bloom { return &Bloom{b.block.Bloom()} }
func (b *Block) GetDifficulty() *BigInt { return &BigInt{b.block.Difficulty()} }
func (b *Block) GetNumber() int64 { return b.block.Number().Int64() }
-func (b *Block) GetGasLimit() int64 { return b.block.GasLimit().Int64() }
-func (b *Block) GetGasUsed() int64 { return b.block.GasUsed().Int64() }
+func (b *Block) GetGasLimit() int64 { return int64(b.block.GasLimit()) }
+func (b *Block) GetGasUsed() int64 { return int64(b.block.GasUsed()) }
func (b *Block) GetTime() int64 { return b.block.Time().Int64() }
func (b *Block) GetExtra() []byte { return b.block.Extra() }
func (b *Block) GetMixDigest() *Hash { return &Hash{b.block.MixDigest()} }
@@ -212,8 +212,8 @@ type Transaction struct {
}
// NewTransaction creates a new transaction with the given properties.
-func NewTransaction(nonce int64, to *Address, amount, gasLimit, gasPrice *BigInt, data []byte) *Transaction {
- return &Transaction{types.NewTransaction(uint64(nonce), to.address, amount.bigint, gasLimit.bigint, gasPrice.bigint, common.CopyBytes(data))}
+func NewTransaction(nonce int64, to *Address, amount *BigInt, gasLimit int64, gasPrice *BigInt, data []byte) *Transaction {
+ return &Transaction{types.NewTransaction(uint64(nonce), to.address, amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data))}
}
// NewTransactionFromRLP parses a transaction from an RLP data dump.
@@ -256,7 +256,7 @@ func (tx *Transaction) String() string {
}
func (tx *Transaction) GetData() []byte { return tx.tx.Data() }
-func (tx *Transaction) GetGas() int64 { return tx.tx.Gas().Int64() }
+func (tx *Transaction) GetGas() int64 { return int64(tx.tx.Gas()) }
func (tx *Transaction) GetGasPrice() *BigInt { return &BigInt{tx.tx.GasPrice()} }
func (tx *Transaction) GetValue() *BigInt { return &BigInt{tx.tx.Value()} }
func (tx *Transaction) GetNonce() int64 { return int64(tx.tx.Nonce()) }
@@ -353,10 +353,10 @@ func (r *Receipt) String() string {
return r.receipt.String()
}
-func (r *Receipt) GetPostState() []byte { return r.receipt.PostState }
-func (r *Receipt) GetCumulativeGasUsed() *BigInt { return &BigInt{r.receipt.CumulativeGasUsed} }
-func (r *Receipt) GetBloom() *Bloom { return &Bloom{r.receipt.Bloom} }
-func (r *Receipt) GetLogs() *Logs { return &Logs{r.receipt.Logs} }
-func (r *Receipt) GetTxHash() *Hash { return &Hash{r.receipt.TxHash} }
-func (r *Receipt) GetContractAddress() *Address { return &Address{r.receipt.ContractAddress} }
-func (r *Receipt) GetGasUsed() *BigInt { return &BigInt{r.receipt.GasUsed} }
+func (r *Receipt) GetPostState() []byte { return r.receipt.PostState }
+func (r *Receipt) GetCumulativeGasUsed() int64 { return int64(r.receipt.CumulativeGasUsed) }
+func (r *Receipt) GetBloom() *Bloom { return &Bloom{r.receipt.Bloom} }
+func (r *Receipt) GetLogs() *Logs { return &Logs{r.receipt.Logs} }
+func (r *Receipt) GetTxHash() *Hash { return &Hash{r.receipt.TxHash} }
+func (r *Receipt) GetContractAddress() *Address { return &Address{r.receipt.ContractAddress} }
+func (r *Receipt) GetGasUsed() int64 { return int64(r.receipt.GasUsed) }