minter 0.1.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +80 -8
- data/lib/ffi/{go → sign}/compile.rb +6 -4
- data/lib/ffi/sign/go.mod +5 -0
- data/lib/ffi/sign/go.sum +520 -0
- data/lib/ffi/{transaction-darwin-10.6-amd64.dylib → sign/sign-darwin-10.6-amd64.dylib} +0 -0
- data/lib/ffi/{wallet.h → sign/sign-darwin-10.6-amd64.h} +3 -11
- data/lib/ffi/sign/sign-linux-amd64.h +78 -0
- data/lib/ffi/sign/sign-linux-amd64.so +0 -0
- data/lib/ffi/sign/sign.go +84 -0
- data/lib/ffi/sign/sign_ffi.rb +12 -0
- data/lib/ffi/tx_hash/compile.rb +16 -0
- data/lib/ffi/tx_hash/go.mod +5 -0
- data/lib/ffi/tx_hash/go.sum +525 -0
- data/lib/ffi/tx_hash/tx-hash-darwin-10.6-amd64.dylib +0 -0
- data/lib/ffi/{transaction-linux-amd64.h → tx_hash/tx-hash-darwin-10.6-amd64.h} +13 -17
- data/lib/ffi/tx_hash/tx-hash-linux-amd64.h +100 -0
- data/lib/ffi/{transaction-linux-amd64.so → tx_hash/tx-hash-linux-amd64.so} +0 -0
- data/lib/ffi/tx_hash/tx_hash.go +618 -0
- data/lib/ffi/tx_hash/tx_hash_ffi.rb +25 -0
- data/lib/ffi/wallet/compile.rb +16 -0
- data/lib/ffi/wallet/go.mod +5 -0
- data/lib/ffi/wallet/go.sum +525 -0
- data/lib/ffi/{wallet-darwin-10.6-amd64.dylib → wallet/wallet-darwin-10.6-amd64.dylib} +0 -0
- data/lib/ffi/{wallet-darwin-10.6-amd64.h → wallet/wallet-darwin-10.6-amd64.h} +0 -0
- data/lib/ffi/{wallet-linux-amd64.h → wallet/wallet-linux-amd64.h} +0 -0
- data/lib/ffi/{wallet-linux-amd64.so → wallet/wallet-linux-amd64.so} +0 -0
- data/lib/ffi/wallet/wallet.go +50 -0
- data/lib/ffi/{wallet_ffi.rb → wallet/wallet_ffi.rb} +1 -1
- data/lib/minter.rb +4 -2
- data/lib/minter/api/resources/estimate_resource.rb +1 -1
- data/lib/minter/transactions/buy_coin_tx.rb +1 -8
- data/lib/minter/transactions/create_coin_tx.rb +1 -8
- data/lib/minter/transactions/create_multisig_address_tx.rb +38 -0
- data/lib/minter/transactions/declare_candidacy_tx.rb +1 -8
- data/lib/minter/transactions/delegate_tx.rb +1 -8
- data/lib/minter/transactions/edit_candidate_tx.rb +5 -10
- data/lib/minter/transactions/multi_send_tx.rb +29 -0
- data/lib/minter/transactions/redeem_check_tx.rb +1 -8
- data/lib/minter/transactions/sell_all_coin_tx.rb +1 -8
- data/lib/minter/transactions/sell_coin_tx.rb +1 -8
- data/lib/minter/transactions/send_coin_tx.rb +1 -8
- data/lib/minter/transactions/set_candidate_off_tx.rb +1 -8
- data/lib/minter/transactions/set_candidate_on_tx.rb +1 -8
- data/lib/minter/transactions/signed_tx.rb +3 -3
- data/lib/minter/transactions/transaction.rb +41 -0
- data/lib/minter/transactions/unbond_tx.rb +1 -8
- data/lib/minter/version.rb +1 -1
- data/lib/minter/wallet.rb +3 -2
- metadata +36 -18
- data/lib/ffi/transaction-darwin-10.6-amd64.h +0 -104
- data/lib/ffi/transaction_ffi.rb +0 -94
Binary file
|
File without changes
|
File without changes
|
Binary file
|
@@ -0,0 +1,50 @@
|
|
1
|
+
package main
|
2
|
+
|
3
|
+
import (
|
4
|
+
"C"
|
5
|
+
"github.com/MinterTeam/minter-go-sdk/v2/wallet"
|
6
|
+
|
7
|
+
)
|
8
|
+
|
9
|
+
//export NewMnemonic
|
10
|
+
func NewMnemonic() *C.char {
|
11
|
+
mnemonic, _ := wallet.NewMnemonic()
|
12
|
+
return C.CString(mnemonic)
|
13
|
+
}
|
14
|
+
|
15
|
+
//export PrivateKeyFromMnemonic
|
16
|
+
func PrivateKeyFromMnemonic(mnemonic *C.char) *C.char {
|
17
|
+
seed, _ := wallet.Seed(C.GoString(mnemonic))
|
18
|
+
prKey, _ := wallet.PrivateKeyBySeed(seed)
|
19
|
+
return C.CString(prKey)
|
20
|
+
}
|
21
|
+
|
22
|
+
//export PublicKeyFromPrivateKey
|
23
|
+
func PublicKeyFromPrivateKey(prKey *C.char) *C.char {
|
24
|
+
pubKey, _ := wallet.PublicKeyByPrivateKey(C.GoString(prKey))
|
25
|
+
return C.CString(pubKey)
|
26
|
+
}
|
27
|
+
|
28
|
+
//export AddressFromMnemonic
|
29
|
+
func AddressFromMnemonic(mnemonic *C.char) *C.char {
|
30
|
+
seed, _ := wallet.Seed(C.GoString(mnemonic))
|
31
|
+
prKey, _ := wallet.PrivateKeyBySeed(seed)
|
32
|
+
pubKey, _ := wallet.PublicKeyByPrivateKey(prKey)
|
33
|
+
address, _ := wallet.AddressByPublicKey(pubKey)
|
34
|
+
return C.CString(address)
|
35
|
+
}
|
36
|
+
|
37
|
+
//export AddressFromPrivateKey
|
38
|
+
func AddressFromPrivateKey(prKey *C.char) *C.char {
|
39
|
+
pubKey, _ := wallet.PublicKeyByPrivateKey(C.GoString(prKey))
|
40
|
+
address, _ := wallet.AddressByPublicKey(pubKey)
|
41
|
+
return C.CString(address)
|
42
|
+
}
|
43
|
+
|
44
|
+
//export AddressFromPublicKey
|
45
|
+
func AddressFromPublicKey(mnemonic *C.char) *C.char {
|
46
|
+
address, _ := wallet.AddressByPublicKey(C.GoString(mnemonic))
|
47
|
+
return C.CString(address)
|
48
|
+
}
|
49
|
+
|
50
|
+
func main() {}
|
@@ -4,7 +4,7 @@ require "ffi"
|
|
4
4
|
module Minter
|
5
5
|
module WalletFfi
|
6
6
|
extend FFI::Library
|
7
|
-
filename = RUBY_PLATFORM.match(
|
7
|
+
filename = RUBY_PLATFORM.match("darwin") ? "/wallet-darwin-10.6-amd64.dylib" : "/wallet-linux-amd64.so"
|
8
8
|
ffi_lib File.join(File.dirname(__FILE__), filename)
|
9
9
|
attach_function :NewMnemonic, [], :string
|
10
10
|
attach_function :PrivateKeyFromMnemonic, [:string], :string
|
data/lib/minter.rb
CHANGED
@@ -6,8 +6,10 @@ require "minter/api/client"
|
|
6
6
|
require "minter/version"
|
7
7
|
require "minter/wallet.rb"
|
8
8
|
require "minter/key.rb"
|
9
|
-
require "ffi/wallet_ffi.rb"
|
10
|
-
require "ffi/
|
9
|
+
require "ffi/wallet/wallet_ffi.rb"
|
10
|
+
require "ffi/tx_hash/tx_hash_ffi.rb"
|
11
|
+
require "ffi/sign/sign_ffi.rb"
|
12
|
+
require "minter/transactions/transaction.rb"
|
11
13
|
Dir[File.dirname(__FILE__) + "/minter/transactions/*.rb"].each { |file| require_relative file }
|
12
14
|
|
13
15
|
module Minter
|
@@ -17,7 +17,7 @@ module Minter
|
|
17
17
|
|
18
18
|
def estimate_coin_sell_all(coinToSell:, valueToSell:, coinToBuy:, gasPrice:, height: nil)
|
19
19
|
path = "/estimate_coin_sell_all"
|
20
|
-
params = { coinToSell: coinToSell, valueToSell:
|
20
|
+
params = { coinToSell: coinToSell, valueToSell: valueToSell, coinToBuy: coinToBuy, gasPrice: gasPrice, height: height }.compact
|
21
21
|
get(path, params)
|
22
22
|
end
|
23
23
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Minter
|
4
|
-
class BuyCoinTx
|
4
|
+
class BuyCoinTx < Transaction
|
5
5
|
attr_accessor :coin_to_buy, :value_to_buy, :coin_to_sell, :maximum_value_to_sell, :nonce, :chain_id, :gas_coin, :gas_price
|
6
6
|
|
7
7
|
def initialize(coin_to_buy:, value_to_buy:, coin_to_sell:, maximum_value_to_sell:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -15,13 +15,6 @@ module Minter
|
|
15
15
|
@gas_price = gas_price
|
16
16
|
end
|
17
17
|
|
18
|
-
def sign(private_key)
|
19
|
-
params = to_params
|
20
|
-
params[:PrivateKey] = private_key
|
21
|
-
tx_hash = Minter::TransactionFfi.SignBuyCoinTransaction(params.to_json)
|
22
|
-
SignedTx.new(tx_hash)
|
23
|
-
end
|
24
|
-
|
25
18
|
def to_params
|
26
19
|
{ CoinToBuy: coin_to_buy,
|
27
20
|
ValueToBuy: value_to_buy,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Minter
|
4
|
-
class CreateCoinTx
|
4
|
+
class CreateCoinTx < Transaction
|
5
5
|
attr_accessor :name, :symbol, :initial_amount, :max_supply, :initial_reserve, :reserve_ratio, :nonce, :chain_id, :gas_coin, :gas_price
|
6
6
|
|
7
7
|
def initialize(name:, symbol:, initial_amount:, max_supply:, initial_reserve:, reserve_ratio:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -17,13 +17,6 @@ module Minter
|
|
17
17
|
@gas_price = gas_price
|
18
18
|
end
|
19
19
|
|
20
|
-
def sign(private_key)
|
21
|
-
params = to_params
|
22
|
-
params[:PrivateKey] = private_key
|
23
|
-
tx_hash = Minter::TransactionFfi.SignCreateCoinTransaction(params.to_json)
|
24
|
-
SignedTx.new(tx_hash)
|
25
|
-
end
|
26
|
-
|
27
20
|
def to_params
|
28
21
|
{ Name: name,
|
29
22
|
Symbol: symbol,
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Minter
|
4
|
+
class CreateMultisigAddressTx < Transaction
|
5
|
+
attr_accessor :addresses, :threshold, :nonce, :chain_id, :gas_coin, :gas_price
|
6
|
+
|
7
|
+
def initialize(threshold:, nonce:, chain_id:, gas_coin:, gas_price:)
|
8
|
+
@threshold = threshold
|
9
|
+
@nonce = nonce
|
10
|
+
@chain_id = chain_id
|
11
|
+
@gas_coin = gas_coin
|
12
|
+
@gas_price = gas_price
|
13
|
+
@addresses = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_address(address:, weight:)
|
17
|
+
@addresses << { Address: address, Weight: weight }
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_params
|
21
|
+
{
|
22
|
+
Threshold: threshold,
|
23
|
+
Nonce: nonce,
|
24
|
+
ChainId: chain_id,
|
25
|
+
GasCoin: gas_coin,
|
26
|
+
GasPrice: gas_price,
|
27
|
+
Addresses: addresses
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def multisig_address
|
32
|
+
result = JSON.parse(Minter::TxHashFfi.GetMultisigAddress(to_params.to_json))
|
33
|
+
raise TransactionError, result["error"] unless result["success"] == "true"
|
34
|
+
|
35
|
+
result["multisig_address"]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Minter
|
4
|
-
class DeclareCandidacyTx
|
4
|
+
class DeclareCandidacyTx < Transaction
|
5
5
|
attr_accessor :address, :pubkey, :commission, :coin, :stake, :nonce, :chain_id, :gas_coin, :gas_price
|
6
6
|
|
7
7
|
def initialize(address:, pubkey:, commission:, coin:, stake:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -16,13 +16,6 @@ module Minter
|
|
16
16
|
@gas_price = gas_price
|
17
17
|
end
|
18
18
|
|
19
|
-
def sign(private_key)
|
20
|
-
params = to_params
|
21
|
-
params[:PrivateKey] = private_key
|
22
|
-
tx_hash = Minter::TransactionFfi.SignDeclareCandidacyTransaction(params.to_json)
|
23
|
-
SignedTx.new(tx_hash)
|
24
|
-
end
|
25
|
-
|
26
19
|
def to_params
|
27
20
|
{ Address: address,
|
28
21
|
PubKey: pubkey,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Minter
|
4
|
-
class DelegateTx
|
4
|
+
class DelegateTx < Transaction
|
5
5
|
attr_accessor :pubkey, :coin, :value, :nonce, :chain_id, :gas_coin, :gas_price
|
6
6
|
|
7
7
|
def initialize(pubkey:, coin:, value:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -14,13 +14,6 @@ module Minter
|
|
14
14
|
@gas_price = gas_price
|
15
15
|
end
|
16
16
|
|
17
|
-
def sign(private_key)
|
18
|
-
params = to_params
|
19
|
-
params[:PrivateKey] = private_key
|
20
|
-
tx_hash = Minter::TransactionFfi.SignDelegateTransaction(params.to_json)
|
21
|
-
SignedTx.new(tx_hash)
|
22
|
-
end
|
23
|
-
|
24
17
|
def to_params
|
25
18
|
{ PubKey: pubkey,
|
26
19
|
Coin: coin,
|
@@ -1,30 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Minter
|
4
|
-
class EditCandidateTx
|
5
|
-
attr_accessor :pubkey, :reward_address, :owner_address, :nonce, :chain_id, :gas_coin, :gas_price
|
4
|
+
class EditCandidateTx < Transaction
|
5
|
+
attr_accessor :pubkey, :reward_address, :owner_address, :control_address, :nonce, :chain_id, :gas_coin, :gas_price
|
6
6
|
|
7
|
-
def initialize(pubkey:, reward_address:, owner_address:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
7
|
+
def initialize(pubkey:, reward_address:, owner_address:, control_address:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
8
8
|
@pubkey = pubkey
|
9
9
|
@reward_address = reward_address
|
10
10
|
@owner_address = owner_address
|
11
|
+
@control_address = control_address
|
11
12
|
@nonce = nonce
|
12
13
|
@chain_id = chain_id
|
13
14
|
@gas_coin = gas_coin
|
14
15
|
@gas_price = gas_price
|
15
16
|
end
|
16
17
|
|
17
|
-
def sign(private_key)
|
18
|
-
params = to_params
|
19
|
-
params[:PrivateKey] = private_key
|
20
|
-
tx_hash = Minter::TransactionFfi.SignEditCandidateTransaction(params.to_json)
|
21
|
-
SignedTx.new(tx_hash)
|
22
|
-
end
|
23
|
-
|
24
18
|
def to_params
|
25
19
|
{ PubKey: pubkey,
|
26
20
|
RewardAddress: reward_address,
|
27
21
|
OwnerAddress: owner_address,
|
22
|
+
ControlAddress: control_address,
|
28
23
|
Nonce: nonce,
|
29
24
|
ChainId: chain_id,
|
30
25
|
GasCoin: gas_coin,
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Minter
|
4
|
+
class MultiSendTx < Transaction
|
5
|
+
attr_accessor :items, :coin, :nonce, :chain_id, :gas_coin, :gas_price
|
6
|
+
|
7
|
+
def initialize(nonce:, chain_id:, gas_coin:, gas_price:)
|
8
|
+
@nonce = nonce
|
9
|
+
@chain_id = chain_id
|
10
|
+
@gas_coin = gas_coin
|
11
|
+
@gas_price = gas_price
|
12
|
+
@items = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def add_item(coin_id:, value:, address_to:)
|
16
|
+
@items << { CoinID: coin_id, Value: value, AddressTo: address_to }
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_params
|
20
|
+
{
|
21
|
+
Nonce: nonce,
|
22
|
+
ChainId: chain_id,
|
23
|
+
GasCoin: gas_coin,
|
24
|
+
GasPrice: gas_price,
|
25
|
+
Items: items
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Minter
|
4
|
-
class RedeemCheckTx
|
4
|
+
class RedeemCheckTx < Transaction
|
5
5
|
attr_accessor :check, :proof, :nonce, :chain_id, :gas_coin, :gas_price
|
6
6
|
|
7
7
|
def initialize(check:, proof:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -13,13 +13,6 @@ module Minter
|
|
13
13
|
@gas_price = gas_price
|
14
14
|
end
|
15
15
|
|
16
|
-
def sign(private_key)
|
17
|
-
params = to_params
|
18
|
-
params[:PrivateKey] = private_key
|
19
|
-
tx_hash = Minter::TransactionFfi.SignRedeemCheckTransaction(params.to_json)
|
20
|
-
SignedTx.new(tx_hash)
|
21
|
-
end
|
22
|
-
|
23
16
|
def to_params
|
24
17
|
{ Check: check,
|
25
18
|
Proof: proof,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Minter
|
4
|
-
class SellAllCoinTx
|
4
|
+
class SellAllCoinTx < Transaction
|
5
5
|
attr_accessor :coin_to_sell, :coin_to_buy, :minimum_value_to_buy, :nonce, :chain_id, :gas_coin, :gas_price
|
6
6
|
|
7
7
|
def initialize(coin_to_sell:, coin_to_buy:, minimum_value_to_buy:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -14,13 +14,6 @@ module Minter
|
|
14
14
|
@gas_price = gas_price
|
15
15
|
end
|
16
16
|
|
17
|
-
def sign(private_key)
|
18
|
-
params = to_params
|
19
|
-
params[:PrivateKey] = private_key
|
20
|
-
tx_hash = Minter::TransactionFfi.SignSellAllCoinTransaction(params.to_json)
|
21
|
-
SignedTx.new(tx_hash)
|
22
|
-
end
|
23
|
-
|
24
17
|
def to_params
|
25
18
|
{ CoinToSell: coin_to_sell,
|
26
19
|
CoinToBuy: coin_to_buy,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Minter
|
4
|
-
class SellCoinTx
|
4
|
+
class SellCoinTx < Transaction
|
5
5
|
attr_accessor :coin_to_sell, :value_to_sell, :coin_to_buy, :minimum_value_to_buy, :nonce, :chain_id, :gas_coin, :gas_price
|
6
6
|
|
7
7
|
def initialize(coin_to_sell:, value_to_sell:, coin_to_buy:, minimum_value_to_buy:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -15,13 +15,6 @@ module Minter
|
|
15
15
|
@gas_price = gas_price
|
16
16
|
end
|
17
17
|
|
18
|
-
def sign(private_key)
|
19
|
-
params = to_params
|
20
|
-
params[:PrivateKey] = private_key
|
21
|
-
tx_hash = Minter::TransactionFfi.SignSellCoinTransaction(params.to_json)
|
22
|
-
SignedTx.new(tx_hash)
|
23
|
-
end
|
24
|
-
|
25
18
|
def to_params
|
26
19
|
{ CoinToSell: coin_to_sell,
|
27
20
|
ValueToSell: value_to_sell,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Minter
|
4
|
-
class SendCoinTx
|
4
|
+
class SendCoinTx < Transaction
|
5
5
|
attr_accessor :type, :address_to, :value, :coin, :nonce, :chain_id, :gas_coin, :gas_price
|
6
6
|
|
7
7
|
def initialize(address_to:, value:, coin:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -14,13 +14,6 @@ module Minter
|
|
14
14
|
@gas_price = gas_price
|
15
15
|
end
|
16
16
|
|
17
|
-
def sign(private_key)
|
18
|
-
params = to_params
|
19
|
-
params[:PrivateKey] = private_key
|
20
|
-
tx_hash = Minter::TransactionFfi.SignTransaction(params.to_json)
|
21
|
-
SignedTx.new(tx_hash)
|
22
|
-
end
|
23
|
-
|
24
17
|
def to_params
|
25
18
|
{ AddressTo: address_to,
|
26
19
|
Value: value,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Minter
|
4
|
-
class SetCandidateOffTx
|
4
|
+
class SetCandidateOffTx < Transaction
|
5
5
|
attr_accessor :pubkey, :nonce, :chain_id, :gas_coin, :gas_price
|
6
6
|
|
7
7
|
def initialize(pubkey:, nonce:, chain_id:, gas_coin:, gas_price:)
|
@@ -12,13 +12,6 @@ module Minter
|
|
12
12
|
@gas_price = gas_price
|
13
13
|
end
|
14
14
|
|
15
|
-
def sign(private_key)
|
16
|
-
params = to_params
|
17
|
-
params[:PrivateKey] = private_key
|
18
|
-
tx_hash = Minter::TransactionFfi.SignSetCandidateOffTransaction(params.to_json)
|
19
|
-
SignedTx.new(tx_hash)
|
20
|
-
end
|
21
|
-
|
22
15
|
def to_params
|
23
16
|
{ PubKey: pubkey,
|
24
17
|
Nonce: nonce,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Minter
|
4
|
-
class SetCandidateOnTx
|
4
|
+
class SetCandidateOnTx < Transaction
|
5
5
|
attr_accessor :pubkey, :nonce, :chain_id, :gas_coin, :gas_price
|
6
6
|
|
7
7
|
def initialize(pubkey:, nonce:, chain_id:, gas_coin:, gas_price:)
|
@@ -12,13 +12,6 @@ module Minter
|
|
12
12
|
@gas_price = gas_price
|
13
13
|
end
|
14
14
|
|
15
|
-
def sign(private_key)
|
16
|
-
params = to_params
|
17
|
-
params[:PrivateKey] = private_key
|
18
|
-
tx_hash = Minter::TransactionFfi.SignSetCandidateOnTransaction(params.to_json)
|
19
|
-
SignedTx.new(tx_hash)
|
20
|
-
end
|
21
|
-
|
22
15
|
def to_params
|
23
16
|
{ PubKey: pubkey,
|
24
17
|
Nonce: nonce,
|
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
module Minter
|
4
4
|
class SignedTx
|
5
|
-
attr_reader :tx_hash
|
5
|
+
attr_reader :tx_hash, :transaction
|
6
6
|
|
7
|
-
def initialize(tx_hash)
|
7
|
+
def initialize(tx_hash: nil, transaction: nil)
|
8
8
|
@tx_hash = tx_hash
|
9
|
+
@transaction = transaction
|
9
10
|
end
|
10
11
|
|
11
12
|
def send
|
12
|
-
# TODO: maybe create client one time
|
13
13
|
Minter::Api::Client.new.send_transaction(transaction: tx_hash)
|
14
14
|
end
|
15
15
|
end
|