minter 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +52 -4
- data/lib/ffi/{transaction → sign}/compile.rb +5 -3
- data/lib/ffi/sign/sign_ffi.rb +12 -0
- data/lib/ffi/tx_hash/compile.rb +16 -0
- data/lib/ffi/tx_hash/tx_hash_ffi.rb +25 -0
- data/lib/ffi/wallet/compile.rb +5 -3
- data/lib/ffi/wallet/wallet_ffi.rb +1 -1
- data/lib/minter.rb +2 -1
- data/lib/minter/transactions/buy_coin_tx.rb +0 -1
- data/lib/minter/transactions/create_coin_tx.rb +0 -1
- data/lib/minter/transactions/{create_multisiq_address_tx.rb → create_multisig_address_tx.rb} +5 -11
- data/lib/minter/transactions/declare_candidacy_tx.rb +0 -2
- data/lib/minter/transactions/delegate_tx.rb +0 -1
- data/lib/minter/transactions/edit_candidate_tx.rb +0 -1
- data/lib/minter/transactions/multi_send_tx.rb +0 -1
- data/lib/minter/transactions/redeem_check_tx.rb +0 -1
- data/lib/minter/transactions/sell_all_coin_tx.rb +0 -1
- data/lib/minter/transactions/sell_coin_tx.rb +0 -1
- data/lib/minter/transactions/send_coin_tx.rb +0 -2
- data/lib/minter/transactions/set_candidate_off_tx.rb +0 -1
- data/lib/minter/transactions/set_candidate_on_tx.rb +0 -1
- data/lib/minter/transactions/signed_tx.rb +3 -3
- data/lib/minter/transactions/transaction.rb +34 -10
- data/lib/minter/transactions/unbond_tx.rb +0 -1
- data/lib/minter/version.rb +1 -1
- metadata +7 -5
- data/lib/ffi/transaction/transaction_ffi.rb +0 -94
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2d85833d44cf775519ae1b0df6bc8ccf534385bee66987f12faa99df0d29374
|
4
|
+
data.tar.gz: 7fc304397e7cc9079e81512ae722148c8f1d6397e23851d0098297ea5138e35b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35c26150780d7efc77481e8ce8647f4cbe2344ffbd84329c9e2a081fb467ff198c8466f4d315dcba062870553d76c8d94c73917036f9d31e2b8cf362fcf43ff4
|
7
|
+
data.tar.gz: a30987140a968126e241bf2dc8005d811e2ac71eda91685c49037b4250b19238549b69837af41c833faf258332bac057d5aaf75a612c06a58a960dad45e408da
|
data/README.md
CHANGED
@@ -62,6 +62,7 @@ Or install it yourself as:
|
|
62
62
|
- [Unbond](#unbond-transaction)
|
63
63
|
- [Multisend](#multisend-transaction)
|
64
64
|
- [EditCandidate](#edit-candidate-transaction)
|
65
|
+
- [CreateMultisigAddress](#create-multisig-address)
|
65
66
|
- [Sign transaction](#sign-transaction)
|
66
67
|
- [Single signature](#single-signature)
|
67
68
|
- [Multi signature](#multi-signatures)
|
@@ -544,14 +545,31 @@ transaction = Minter::SendCoinTx.new(
|
|
544
545
|
gas_price: 10
|
545
546
|
)
|
546
547
|
|
547
|
-
signed_tx = sign(private_key)
|
548
|
+
signed_tx = transaction.sign(private_key)
|
548
549
|
signed_tx.tx_hash
|
549
550
|
#=> "0xf88501020a8a4d4e540000000000000001abea8a4d4e540000000000000094e7812ab98ac5ac37e2ab20da3136ad91bb22d49789014d1120d7b1600000808001b845f8431ba07fde3c0e8d9ffb5fd7025099c9f3672deffab0b784787f5d45ea8f27b0ffe989a02f7cd63ac0d75e559f540d8b33464b11da4605e623d62a5b2ddce5adf70c35cb"
|
550
551
|
```
|
551
552
|
|
552
553
|
#### Multi signatures
|
553
554
|
```ruby
|
554
|
-
|
555
|
+
multisig_address = "Mxeda4bb5456f5eb8a19f57c8c6ec844d05feae879"
|
556
|
+
private_key1 = "4de029ca7b95c163f88c66e6351f2a986a48834b4681ec1e43eed5d120227103"
|
557
|
+
private_key2 = "49e48cd0f81e7aabfc840301c66f00318f50b25c79664c3f337d7ad4f919638e"
|
558
|
+
transaction = Minter::SendCoinTx.new(
|
559
|
+
address_to: "Mxe7812ab98ac5ac37e2ab20da3136ad91bb22d497",
|
560
|
+
value: 4_000_000_000_000_000_000,
|
561
|
+
coin: "MNT",
|
562
|
+
nonce: 2,
|
563
|
+
chain_id: 2,
|
564
|
+
gas_coin: "MNT",
|
565
|
+
gas_price: 10
|
566
|
+
)
|
567
|
+
signed_tx = transaction.multisign(multisig_address, private_key1, private_key2)
|
568
|
+
#=> #<Minter::SignedTx:0x00007fe340120090
|
569
|
+
# @transaction=
|
570
|
+
# #<Minter::SendCoinTx:0x00007fe3411da908 @address_to="Mxe7812ab98ac5ac37e2ab20da3136ad91bb22d497", @chain_id=2, @coin="MNT", @gas_coin="MNT", @gas_price=10, @nonce=2, @value=4000000000000000000>,
|
571
|
+
# @tx_hash=
|
572
|
+
# "0xf8e202020a8a4d4e540000000000000001aae98a4d4e540000000000000094e7812ab98ac5ac37e2ab20da3136ad91bb22d497883782dace9d900000808002b8a3f8a194eda4bb5456f5eb8a19f57c8c6ec844d05feae879f88af8431ba0287dd3956acae624abc25e6ba60018f60a80e144f5678ceb35c35613fcd363bfa01886706c7ffa0e6ccfc7c3dda186d3e8beea5214c30502ad9a24d8a29ced685af8431ba0302a560b420ed0da95f4f8425ac605a2462d35449e44557f152c4308845e1710a04cd1b834752e3a26b0fd543a20e3ef99ca233b049e064146c6a8cdf19d895552">
|
555
573
|
```
|
556
574
|
|
557
575
|
### Create transaction
|
@@ -822,7 +840,25 @@ Minter::EditCandidateTx.new(
|
|
822
840
|
Transaction for creating multisignature address.
|
823
841
|
|
824
842
|
```ruby
|
825
|
-
|
843
|
+
address1 = "Mx08d920c5d93dbf23038fe1a54bbb34f41f77677c"
|
844
|
+
address2 = "Mx9c7f68ff71b5819c41e8f87cc99bdf6359da3d75"
|
845
|
+
address3 = "Mx9c7f68ff71b5819c41e8f87cc99bdf6359da3d75"
|
846
|
+
private_key = "ae089b32e4e0976ca6888cb1023148bd1a9f1cc28c5d442e52e586754ff48d63"
|
847
|
+
|
848
|
+
transaction = Minter::CreateMultisigAddressTx.new(
|
849
|
+
threshold: 7,
|
850
|
+
nonce: 11,
|
851
|
+
chain_id: 2,
|
852
|
+
gas_coin: "MNT",
|
853
|
+
gas_price: 1
|
854
|
+
)
|
855
|
+
|
856
|
+
transaction.add_address(address: address1, weight: 1)
|
857
|
+
transaction.add_address(address: address2, weight: 3)
|
858
|
+
transaction.add_address(address: address3, weight: 5)
|
859
|
+
|
860
|
+
transaction.multisig_address
|
861
|
+
=> "Mxc0edeaee8750330d01bcefcbd34198b2ef7b1167"
|
826
862
|
```
|
827
863
|
#### Multisend transaction
|
828
864
|
|
@@ -850,7 +886,19 @@ transaction.add_item(
|
|
850
886
|
```
|
851
887
|
### Get fee of transaction
|
852
888
|
```ruby
|
853
|
-
|
889
|
+
transaction = Minter::SendCoinTx.new(
|
890
|
+
address_to: "Mxe7812ab98ac5ac37e2ab20da3136ad91bb22d497",
|
891
|
+
value: 24_000_000_000_000_000_000,
|
892
|
+
coin: "MNT",
|
893
|
+
nonce: 65,
|
894
|
+
chain_id: 2,
|
895
|
+
gas_coin: "MNT",
|
896
|
+
gas_price: 10
|
897
|
+
)
|
898
|
+
|
899
|
+
transaction.fee
|
900
|
+
#=> ""
|
901
|
+
|
854
902
|
```
|
855
903
|
### Decode Transaction
|
856
904
|
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
out_path = "./sign"
|
2
4
|
arg_string = ""
|
3
5
|
{
|
4
6
|
out: out_path,
|
5
|
-
targets: [
|
6
|
-
buildmode:
|
7
|
+
targets: ["linux/amd64", "darwin/amd64"],
|
8
|
+
buildmode: "c-shared"
|
7
9
|
}.each_pair do |name, args|
|
8
10
|
arg_string += "-#{name}"
|
9
11
|
arg_string += "=#{[args].flatten.join(',')}" unless args.nil?
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ffi"
|
4
|
+
module Minter
|
5
|
+
module SignFfi
|
6
|
+
extend FFI::Library
|
7
|
+
filename = RUBY_PLATFORM.match("darwin") ? "/sign-darwin-10.6-amd64.dylib" : "/sign-linux-amd64.so"
|
8
|
+
ffi_lib File.join(File.dirname(__FILE__), filename)
|
9
|
+
attach_function :Sign, [:string], :string
|
10
|
+
attach_function :MultiSign, [:string], :string
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
out_path = "./tx-hash"
|
4
|
+
arg_string = ""
|
5
|
+
{
|
6
|
+
out: out_path,
|
7
|
+
targets: ["linux/amd64", "darwin/amd64"],
|
8
|
+
buildmode: "c-shared"
|
9
|
+
}.each_pair do |name, args|
|
10
|
+
arg_string += "-#{name}"
|
11
|
+
arg_string += "=#{[args].flatten.join(',')}" unless args.nil?
|
12
|
+
arg_string += " "
|
13
|
+
end
|
14
|
+
|
15
|
+
puts "xgo #{arg_string.strip} ./"
|
16
|
+
system("xgo #{arg_string.strip} ./")
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ffi"
|
4
|
+
module Minter
|
5
|
+
module TxHashFfi
|
6
|
+
extend FFI::Library
|
7
|
+
filename = RUBY_PLATFORM.match("darwin") ? "/tx-hash-darwin-10.6-amd64.dylib" : "/tx-hash-linux-amd64.so"
|
8
|
+
ffi_lib File.join(File.dirname(__FILE__), filename)
|
9
|
+
attach_function :BuyCoinTx, [:string], :string
|
10
|
+
attach_function :CreateCoinTx, [:string], :string
|
11
|
+
attach_function :CreateMultisigAddressTx, [:string], :string
|
12
|
+
attach_function :GetMultisigAddress, [:string], :string
|
13
|
+
attach_function :DeclareCandidacyTx, [:string], :string
|
14
|
+
attach_function :DelegateTx, [:string], :string
|
15
|
+
attach_function :EditCandidateTx, [:string], :string
|
16
|
+
attach_function :MultiSendTx, [:string], :string
|
17
|
+
attach_function :RedeemCheckTx, [:string], :string
|
18
|
+
attach_function :SellAllCoinTx, [:string], :string
|
19
|
+
attach_function :SellCoinTx, [:string], :string
|
20
|
+
attach_function :SendCoinTx, [:string], :string
|
21
|
+
attach_function :SetCandidateOffTx, [:string], :string
|
22
|
+
attach_function :SetCandidateOnTx, [:string], :string
|
23
|
+
attach_function :UnbondTx, [:string], :string
|
24
|
+
end
|
25
|
+
end
|
data/lib/ffi/wallet/compile.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
out_path = "./wallet"
|
2
4
|
arg_string = ""
|
3
5
|
{
|
4
6
|
out: out_path,
|
5
|
-
targets: [
|
6
|
-
buildmode:
|
7
|
+
targets: ["linux/amd64", "darwin/amd64"],
|
8
|
+
buildmode: "c-shared"
|
7
9
|
}.each_pair do |name, args|
|
8
10
|
arg_string += "-#{name}"
|
9
11
|
arg_string += "=#{[args].flatten.join(',')}" unless args.nil?
|
@@ -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
@@ -7,7 +7,8 @@ require "minter/version"
|
|
7
7
|
require "minter/wallet.rb"
|
8
8
|
require "minter/key.rb"
|
9
9
|
require "ffi/wallet/wallet_ffi.rb"
|
10
|
-
require "ffi/
|
10
|
+
require "ffi/tx_hash/tx_hash_ffi.rb"
|
11
|
+
require "ffi/sign/sign_ffi.rb"
|
11
12
|
require "minter/transactions/transaction.rb"
|
12
13
|
Dir[File.dirname(__FILE__) + "/minter/transactions/*.rb"].each { |file| require_relative file }
|
13
14
|
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Minter
|
4
4
|
class BuyCoinTx < Transaction
|
5
|
-
SIGN_METHOD = :SignBuyCoinTransaction
|
6
5
|
attr_accessor :coin_to_buy, :value_to_buy, :coin_to_sell, :maximum_value_to_sell, :nonce, :chain_id, :gas_coin, :gas_price
|
7
6
|
|
8
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
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Minter
|
4
4
|
class CreateCoinTx < Transaction
|
5
|
-
SIGN_METHOD = :SignCreateCoinTransaction
|
6
5
|
attr_accessor :name, :symbol, :initial_amount, :max_supply, :initial_reserve, :reserve_ratio, :nonce, :chain_id, :gas_coin, :gas_price
|
7
6
|
|
8
7
|
def initialize(name:, symbol:, initial_amount:, max_supply:, initial_reserve:, reserve_ratio:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
data/lib/minter/transactions/{create_multisiq_address_tx.rb → create_multisig_address_tx.rb}
RENAMED
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Minter
|
4
|
-
class
|
5
|
-
SIGN_METHOD = :SignCreateMultisiqAddressTransaction
|
4
|
+
class CreateMultisigAddressTx < Transaction
|
6
5
|
attr_accessor :addresses, :threshold, :nonce, :chain_id, :gas_coin, :gas_price
|
7
6
|
|
8
7
|
def initialize(threshold:, nonce:, chain_id:, gas_coin:, gas_price:)
|
@@ -29,16 +28,11 @@ module Minter
|
|
29
28
|
}
|
30
29
|
end
|
31
30
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
31
|
+
def multisig_address
|
32
|
+
result = JSON.parse(Minter::TxHashFfi.GetMultisigAddress(to_params.to_json))
|
33
|
+
raise TransactionError, result["error"] unless result["success"] == "true"
|
35
34
|
|
36
|
-
result
|
37
|
-
if result["success"]
|
38
|
-
[SignedTx.new(result["tx_hash"]), result["multisiq_address"]]
|
39
|
-
else
|
40
|
-
raise TransactionError, result["error"]
|
41
|
-
end
|
35
|
+
result["multisig_address"]
|
42
36
|
end
|
43
37
|
end
|
44
38
|
end
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
module Minter
|
4
4
|
class DeclareCandidacyTx < Transaction
|
5
|
-
SIGN_METHOD = :SignDeclareCandidacyTransaction
|
6
|
-
|
7
5
|
attr_accessor :address, :pubkey, :commission, :coin, :stake, :nonce, :chain_id, :gas_coin, :gas_price
|
8
6
|
|
9
7
|
def initialize(address:, pubkey:, commission:, coin:, stake:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Minter
|
4
4
|
class DelegateTx < Transaction
|
5
|
-
SIGN_METHOD = :SignDelegateTransaction
|
6
5
|
attr_accessor :pubkey, :coin, :value, :nonce, :chain_id, :gas_coin, :gas_price
|
7
6
|
|
8
7
|
def initialize(pubkey:, coin:, value:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Minter
|
4
4
|
class EditCandidateTx < Transaction
|
5
|
-
SIGN_METHOD = :SignEditCandidateTransaction
|
6
5
|
attr_accessor :pubkey, :reward_address, :owner_address, :nonce, :chain_id, :gas_coin, :gas_price
|
7
6
|
|
8
7
|
def initialize(pubkey:, reward_address:, owner_address:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Minter
|
4
4
|
class RedeemCheckTx < Transaction
|
5
|
-
SIGN_METHOD = :SignRedeemCheckTransaction
|
6
5
|
attr_accessor :check, :proof, :nonce, :chain_id, :gas_coin, :gas_price
|
7
6
|
|
8
7
|
def initialize(check:, proof:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Minter
|
4
4
|
class SellAllCoinTx < Transaction
|
5
|
-
SIGN_METHOD = :SignSellAllCoinTransaction
|
6
5
|
attr_accessor :coin_to_sell, :coin_to_buy, :minimum_value_to_buy, :nonce, :chain_id, :gas_coin, :gas_price
|
7
6
|
|
8
7
|
def initialize(coin_to_sell:, coin_to_buy:, minimum_value_to_buy:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Minter
|
4
4
|
class SellCoinTx < Transaction
|
5
|
-
SIGN_METHOD = :SignSellCoinTransaction
|
6
5
|
attr_accessor :coin_to_sell, :value_to_sell, :coin_to_buy, :minimum_value_to_buy, :nonce, :chain_id, :gas_coin, :gas_price
|
7
6
|
|
8
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
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
module Minter
|
4
4
|
class SendCoinTx < Transaction
|
5
|
-
SIGN_METHOD = :SignTransaction
|
6
|
-
|
7
5
|
attr_accessor :type, :address_to, :value, :coin, :nonce, :chain_id, :gas_coin, :gas_price
|
8
6
|
|
9
7
|
def initialize(address_to:, value:, coin:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
@@ -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
|
@@ -1,17 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minter
|
2
4
|
class TransactionError < StandardError; end
|
5
|
+
class SignError < StandardError; end
|
3
6
|
|
4
7
|
class Transaction
|
5
8
|
def sign(private_key)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
sign_params = {}
|
10
|
+
sign_params[:PrivateKey] = private_key
|
11
|
+
sign_params[:TxHash] = tx_hash
|
12
|
+
|
13
|
+
result = JSON.parse(Minter::SignFfi.Sign(sign_params.to_json))
|
14
|
+
raise SignError, result["error"] unless result["success"] == "true"
|
15
|
+
|
16
|
+
SignedTx.new(tx_hash: result["tx_hash"], transaction: self)
|
17
|
+
end
|
18
|
+
|
19
|
+
def multisign(multisig_address, *private_keys)
|
20
|
+
multisign_params = {}
|
21
|
+
multisign_params[:PrivateKeys] = private_keys
|
22
|
+
multisign_params[:TxHash] = tx_hash(multisign: true)
|
23
|
+
multisign_params[:MultiSigAddress] = multisig_address
|
24
|
+
|
25
|
+
result = JSON.parse(Minter::SignFfi.MultiSign(multisign_params.to_json))
|
26
|
+
raise SignError, result["error"] unless result["success"] == "true"
|
27
|
+
|
28
|
+
SignedTx.new(tx_hash: result["tx_hash"], transaction: self)
|
29
|
+
end
|
30
|
+
|
31
|
+
def tx_hash(multisign: false)
|
32
|
+
transaction_params = to_params
|
33
|
+
transaction_params[:SignatureType] = multisign ? 2 : 1
|
34
|
+
|
35
|
+
result = JSON.parse(Minter::TxHashFfi.send(self.class.to_s.split("::")[1], transaction_params.to_json))
|
36
|
+
raise TransactionError, result["error"] unless result["success"] == "true"
|
37
|
+
|
38
|
+
result["tx_hash"]
|
15
39
|
end
|
16
40
|
end
|
17
|
-
end
|
41
|
+
end
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Minter
|
4
4
|
class UnbondTx < Transaction
|
5
|
-
SIGN_METHOD = :SignUnbondTransaction
|
6
5
|
attr_accessor :pubkey, :coin, :value, :nonce, :chain_id, :gas_coin, :gas_price
|
7
6
|
|
8
7
|
def initialize(pubkey:, coin:, value:, nonce:, chain_id:, gas_coin:, gas_price:) # rubocop:disable Metrics/ParameterLists
|
data/lib/minter/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Nikolaev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -141,8 +141,10 @@ files:
|
|
141
141
|
- README.md
|
142
142
|
- bin/console
|
143
143
|
- bin/setup
|
144
|
-
- lib/ffi/
|
145
|
-
- lib/ffi/
|
144
|
+
- lib/ffi/sign/compile.rb
|
145
|
+
- lib/ffi/sign/sign_ffi.rb
|
146
|
+
- lib/ffi/tx_hash/compile.rb
|
147
|
+
- lib/ffi/tx_hash/tx_hash_ffi.rb
|
146
148
|
- lib/ffi/wallet/compile.rb
|
147
149
|
- lib/ffi/wallet/wallet_ffi.rb
|
148
150
|
- lib/minter.rb
|
@@ -167,7 +169,7 @@ files:
|
|
167
169
|
- lib/minter/key.rb
|
168
170
|
- lib/minter/transactions/buy_coin_tx.rb
|
169
171
|
- lib/minter/transactions/create_coin_tx.rb
|
170
|
-
- lib/minter/transactions/
|
172
|
+
- lib/minter/transactions/create_multisig_address_tx.rb
|
171
173
|
- lib/minter/transactions/declare_candidacy_tx.rb
|
172
174
|
- lib/minter/transactions/delegate_tx.rb
|
173
175
|
- lib/minter/transactions/edit_candidate_tx.rb
|
@@ -1,94 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "ffi"
|
4
|
-
module Minter
|
5
|
-
module TransactionFfi
|
6
|
-
extend FFI::Library
|
7
|
-
filename = RUBY_PLATFORM.match('darwin') ? "/transaction-darwin-10.6-amd64.dylib" : "/transaction-linux-amd64.so"
|
8
|
-
ffi_lib File.join(File.dirname(__FILE__), filename)
|
9
|
-
attach_function :SignTransaction, [:string], :string
|
10
|
-
attach_function :DecodeTransaction, [:string], :string
|
11
|
-
attach_function :SignCreateCoinTransaction, [:string], :string
|
12
|
-
attach_function :SignSellCoinTransaction, [:string], :string
|
13
|
-
attach_function :SignBuyCoinTransaction, [:string], :string
|
14
|
-
attach_function :SignSellAllCoinTransaction, [:string], :string
|
15
|
-
attach_function :SignDeclareCandidacyTransaction, [:string], :string
|
16
|
-
attach_function :SignDelegateTransaction, [:string], :string
|
17
|
-
attach_function :SignUnbondTransaction, [:string], :string
|
18
|
-
attach_function :SignSetCandidateOffTransaction, [:string], :string
|
19
|
-
attach_function :SignSetCandidateOnTransaction, [:string], :string
|
20
|
-
attach_function :SignRedeemCheckTransaction, [:string], :string
|
21
|
-
attach_function :SignEditCandidateTransaction, [:string], :string
|
22
|
-
attach_function :SignMultiSendTransaction, [:string], :string
|
23
|
-
attach_function :SignCreateMultisiqAddressTransaction, [:string], :string
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Examples of USAGE FFI
|
28
|
-
# ===SEND MNT===
|
29
|
-
# tx_params = {
|
30
|
-
# Nonce: 27,
|
31
|
-
# ChainId: 2,
|
32
|
-
# Type: 1,
|
33
|
-
# AddressTo: "Mx7633980c000139dd3bd24a3f54e06474fa941e16",
|
34
|
-
# Value: 24_000_000_000_000_000_000,
|
35
|
-
# Coin: "MNT",
|
36
|
-
# GasCoin: "MNT",
|
37
|
-
# GasPrice: 10,
|
38
|
-
# PrivateKey: "290cd647206bea71ec06d8dfacce30c872aea3fb1ea333b7f475b70467250ca0"
|
39
|
-
# }
|
40
|
-
# tx = Minter::TransactionFfi.SignTransaction(tx_params.to_json)
|
41
|
-
# Minter::Api::Client.new.send_transaction(transaction: tx)
|
42
|
-
|
43
|
-
# ==CREATE COIN==
|
44
|
-
# tx_params = {
|
45
|
-
# Name: "DEVTWO",
|
46
|
-
# Symbol: "DEVTWO",
|
47
|
-
# InitialAmount: 1000000000000000000,
|
48
|
-
# MaxSupply: 10000000000000000000,
|
49
|
-
# InitialReserve: 10000,
|
50
|
-
# ReserveRation: 10,
|
51
|
-
#
|
52
|
-
# Nonce: 29,
|
53
|
-
# ChainId: 2,
|
54
|
-
# GasCoin: "MNT",
|
55
|
-
# GasPrice: 1,
|
56
|
-
# PrivateKey: "290cd647206bea71ec06d8dfacce30c872aea3fb1ea333b7f475b70467250ca0"
|
57
|
-
# }
|
58
|
-
#
|
59
|
-
# tx = Minter::TransactionFfi.SignCreateCoinTransaction(tx_params.to_json)
|
60
|
-
# Minter::Api::Client.new.send_transaction(transaction: tx)
|
61
|
-
|
62
|
-
# ===SELL_COIN===
|
63
|
-
# tx_params = {
|
64
|
-
# CoinToSell: "DEVDEV",
|
65
|
-
# ValueToSell: 1000,
|
66
|
-
# CoinToBuy: "MNT",
|
67
|
-
# MinimumValueToBuy: 100000000,
|
68
|
-
#
|
69
|
-
# Nonce: 31,
|
70
|
-
# ChainId: 2,
|
71
|
-
# GasCoin: "MNT",
|
72
|
-
# GasPrice: 1,
|
73
|
-
# PrivateKey: "290cd647206bea71ec06d8dfacce30c872aea3fb1ea333b7f475b70467250ca0"
|
74
|
-
# }
|
75
|
-
#
|
76
|
-
# tx = Minter::TransactionFfi.SignSellCoinTransaction(tx_params.to_json)
|
77
|
-
# Minter::Api::Client.new.send_transaction(transaction: tx)
|
78
|
-
|
79
|
-
# ===BUY_COIN===
|
80
|
-
# tx_params = {
|
81
|
-
# CoinToBuy: "DEVDEV",
|
82
|
-
# ValueToBuy: 1000,
|
83
|
-
# CoinToSell: "MNT",
|
84
|
-
# MaximumValueToSell: 100000000,
|
85
|
-
#
|
86
|
-
# Nonce: 31,
|
87
|
-
# ChainId: 2,
|
88
|
-
# GasCoin: "MNT",
|
89
|
-
# GasPrice: 1,
|
90
|
-
# PrivateKey: "290cd647206bea71ec06d8dfacce30c872aea3fb1ea333b7f475b70467250ca0"
|
91
|
-
# }
|
92
|
-
#
|
93
|
-
# tx = Minter::TransactionFfi.SignBuyCoinTransaction(tx_params.to_json)
|
94
|
-
# Minter::Api::Client.new.send_transaction(transaction: tx)
|