aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Gottfrid <derek@codecubed.com>2019-02-07 18:49:22 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-02-07 18:49:22 +0800
commit4097ba6a005f3abc6fadb35cba0a80fcb7425aa2 (patch)
tree9d2056ff9c59b69522105f7f6f23b6ef4a029989
parent26aea736736dc70257b1c11676f626ab775e9339 (diff)
downloadgo-tangerine-4097ba6a005f3abc6fadb35cba0a80fcb7425aa2.tar
go-tangerine-4097ba6a005f3abc6fadb35cba0a80fcb7425aa2.tar.gz
go-tangerine-4097ba6a005f3abc6fadb35cba0a80fcb7425aa2.tar.bz2
go-tangerine-4097ba6a005f3abc6fadb35cba0a80fcb7425aa2.tar.lz
go-tangerine-4097ba6a005f3abc6fadb35cba0a80fcb7425aa2.tar.xz
go-tangerine-4097ba6a005f3abc6fadb35cba0a80fcb7425aa2.tar.zst
go-tangerine-4097ba6a005f3abc6fadb35cba0a80fcb7425aa2.zip
mobile: add ability to create transactions for deploying contracts (#16104)
-rw-r--r--mobile/types.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/mobile/types.go b/mobile/types.go
index 443d07ea9..1a0389cb5 100644
--- a/mobile/types.go
+++ b/mobile/types.go
@@ -197,8 +197,18 @@ type Transaction struct {
tx *types.Transaction
}
-// NewTransaction creates a new transaction with the given properties.
+// NewContractCreation creates a new transaction for deploying a new contract with
+// the given properties.
+func NewContractCreation(nonce int64, amount *BigInt, gasLimit int64, gasPrice *BigInt, data []byte) *Transaction {
+ return &Transaction{types.NewContractCreation(uint64(nonce), amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data))}
+}
+
+// NewTransaction creates a new transaction with the given properties. Contracts
+// can be created by transacting with a nil recipient.
func NewTransaction(nonce int64, to *Address, amount *BigInt, gasLimit int64, gasPrice *BigInt, data []byte) *Transaction {
+ if to == nil {
+ return &Transaction{types.NewContractCreation(uint64(nonce), amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data))}
+ }
return &Transaction{types.NewTransaction(uint64(nonce), to.address, amount.bigint, uint64(gasLimit), gasPrice.bigint, common.CopyBytes(data))}
}