minter 0.2.0 → 1.0.1
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 +208 -278
- data/lib/ffi/{transaction → sign}/compile.rb +5 -3
- data/lib/ffi/sign/go.mod +5 -0
- data/lib/ffi/sign/go.sum +520 -0
- data/lib/ffi/sign/sign-darwin-10.6-amd64.dylib +0 -0
- data/lib/ffi/sign/sign-darwin-10.6-amd64.h +78 -0
- 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/tx_hash/tx-hash-darwin-10.6-amd64.h +100 -0
- data/lib/ffi/tx_hash/tx-hash-linux-amd64.h +100 -0
- data/lib/ffi/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 +5 -3
- data/lib/ffi/wallet/go.mod +5 -0
- data/lib/ffi/wallet/go.sum +525 -0
- data/lib/ffi/wallet/wallet-darwin-10.6-amd64.dylib +0 -0
- data/lib/ffi/wallet/wallet-darwin-10.6-amd64.h +86 -0
- data/lib/ffi/wallet/wallet-linux-amd64.h +86 -0
- data/lib/ffi/wallet/wallet-linux-amd64.so +0 -0
- data/lib/ffi/wallet/wallet.go +50 -0
- data/lib/ffi/wallet/wallet_ffi.rb +1 -1
- data/lib/minter.rb +2 -1
- data/lib/minter/api/client.rb +4 -1
- data/lib/minter/api/connection.rb +6 -0
- data/lib/minter/api/resources/address_resource.rb +2 -6
- data/lib/minter/api/resources/block_resource.rb +2 -3
- data/lib/minter/api/resources/candidate_resource.rb +2 -2
- data/lib/minter/api/resources/coin_resource.rb +2 -2
- data/lib/minter/api/resources/estimate_resource.rb +1 -1
- data/lib/minter/api/resources/events_resource.rb +2 -3
- data/lib/minter/api/resources/max_gas_resource.rb +1 -1
- data/lib/minter/api/resources/nonce_resource.rb +3 -4
- data/lib/minter/api/resources/send_transaction_resource.rb +2 -3
- data/lib/minter/api/resources/transactions_resource.rb +2 -3
- 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_multisig_address_tx.rb +38 -0
- 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 +4 -3
- data/lib/minter/transactions/multi_send_tx.rb +2 -3
- 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 +32 -8
- data/lib/ffi/transaction/transaction_ffi.rb +0 -93
@@ -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,13 +2,13 @@
|
|
2
2
|
|
3
3
|
module Minter
|
4
4
|
class EditCandidateTx < Transaction
|
5
|
-
|
6
|
-
attr_accessor :pubkey, :reward_address, :owner_address, :nonce, :chain_id, :gas_coin, :gas_price
|
5
|
+
attr_accessor :pubkey, :reward_address, :owner_address, :control_address, :nonce, :chain_id, :gas_coin, :gas_price
|
7
6
|
|
8
|
-
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
|
9
8
|
@pubkey = pubkey
|
10
9
|
@reward_address = reward_address
|
11
10
|
@owner_address = owner_address
|
11
|
+
@control_address = control_address
|
12
12
|
@nonce = nonce
|
13
13
|
@chain_id = chain_id
|
14
14
|
@gas_coin = gas_coin
|
@@ -19,6 +19,7 @@ module Minter
|
|
19
19
|
{ PubKey: pubkey,
|
20
20
|
RewardAddress: reward_address,
|
21
21
|
OwnerAddress: owner_address,
|
22
|
+
ControlAddress: control_address,
|
22
23
|
Nonce: nonce,
|
23
24
|
ChainId: chain_id,
|
24
25
|
GasCoin: gas_coin,
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Minter
|
4
4
|
class MultiSendTx < Transaction
|
5
|
-
SIGN_METHOD = :SignMultiSendTransaction
|
6
5
|
attr_accessor :items, :coin, :nonce, :chain_id, :gas_coin, :gas_price
|
7
6
|
|
8
7
|
def initialize(nonce:, chain_id:, gas_coin:, gas_price:)
|
@@ -13,8 +12,8 @@ module Minter
|
|
13
12
|
@items = []
|
14
13
|
end
|
15
14
|
|
16
|
-
def add_item(
|
17
|
-
@items << {
|
15
|
+
def add_item(coin_id:, value:, address_to:)
|
16
|
+
@items << { CoinID: coin_id, Value: value, AddressTo: address_to }
|
18
17
|
end
|
19
18
|
|
20
19
|
def to_params
|
@@ -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: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Nikolaev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05
|
11
|
+
date: 2020-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -131,7 +131,7 @@ dependencies:
|
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '3.9'
|
133
133
|
description: This is a Ruby SDK based on Golang SDK for working with Minter blockchain
|
134
|
-
email:
|
134
|
+
email:
|
135
135
|
executables: []
|
136
136
|
extensions: []
|
137
137
|
extra_rdoc_files: []
|
@@ -141,9 +141,32 @@ 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/go.mod
|
146
|
+
- lib/ffi/sign/go.sum
|
147
|
+
- lib/ffi/sign/sign-darwin-10.6-amd64.dylib
|
148
|
+
- lib/ffi/sign/sign-darwin-10.6-amd64.h
|
149
|
+
- lib/ffi/sign/sign-linux-amd64.h
|
150
|
+
- lib/ffi/sign/sign-linux-amd64.so
|
151
|
+
- lib/ffi/sign/sign.go
|
152
|
+
- lib/ffi/sign/sign_ffi.rb
|
153
|
+
- lib/ffi/tx_hash/compile.rb
|
154
|
+
- lib/ffi/tx_hash/go.mod
|
155
|
+
- lib/ffi/tx_hash/go.sum
|
156
|
+
- lib/ffi/tx_hash/tx-hash-darwin-10.6-amd64.dylib
|
157
|
+
- lib/ffi/tx_hash/tx-hash-darwin-10.6-amd64.h
|
158
|
+
- lib/ffi/tx_hash/tx-hash-linux-amd64.h
|
159
|
+
- lib/ffi/tx_hash/tx-hash-linux-amd64.so
|
160
|
+
- lib/ffi/tx_hash/tx_hash.go
|
161
|
+
- lib/ffi/tx_hash/tx_hash_ffi.rb
|
146
162
|
- lib/ffi/wallet/compile.rb
|
163
|
+
- lib/ffi/wallet/go.mod
|
164
|
+
- lib/ffi/wallet/go.sum
|
165
|
+
- lib/ffi/wallet/wallet-darwin-10.6-amd64.dylib
|
166
|
+
- lib/ffi/wallet/wallet-darwin-10.6-amd64.h
|
167
|
+
- lib/ffi/wallet/wallet-linux-amd64.h
|
168
|
+
- lib/ffi/wallet/wallet-linux-amd64.so
|
169
|
+
- lib/ffi/wallet/wallet.go
|
147
170
|
- lib/ffi/wallet/wallet_ffi.rb
|
148
171
|
- lib/minter.rb
|
149
172
|
- lib/minter/api/client.rb
|
@@ -167,6 +190,7 @@ files:
|
|
167
190
|
- lib/minter/key.rb
|
168
191
|
- lib/minter/transactions/buy_coin_tx.rb
|
169
192
|
- lib/minter/transactions/create_coin_tx.rb
|
193
|
+
- lib/minter/transactions/create_multisig_address_tx.rb
|
170
194
|
- lib/minter/transactions/declare_candidacy_tx.rb
|
171
195
|
- lib/minter/transactions/delegate_tx.rb
|
172
196
|
- lib/minter/transactions/edit_candidate_tx.rb
|
@@ -189,7 +213,7 @@ metadata:
|
|
189
213
|
homepage_uri: https://github.com/rubyroid-team/minter
|
190
214
|
source_code_uri: https://github.com/rubyroid-team/minter
|
191
215
|
changelog_uri: https://github.com/rubyroid-team/minter/blob/master/CHANGELOG.md
|
192
|
-
post_install_message:
|
216
|
+
post_install_message:
|
193
217
|
rdoc_options: []
|
194
218
|
require_paths:
|
195
219
|
- lib
|
@@ -205,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
229
|
version: '0'
|
206
230
|
requirements: []
|
207
231
|
rubygems_version: 3.0.8
|
208
|
-
signing_key:
|
232
|
+
signing_key:
|
209
233
|
specification_version: 4
|
210
234
|
summary: This is a Ruby SDK based on Golang SDK for working with Minter blockchain
|
211
235
|
test_files: []
|
@@ -1,93 +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
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
# Examples of USAGE FFI
|
27
|
-
# ===SEND MNT===
|
28
|
-
# tx_params = {
|
29
|
-
# Nonce: 27,
|
30
|
-
# ChainId: 2,
|
31
|
-
# Type: 1,
|
32
|
-
# AddressTo: "Mx7633980c000139dd3bd24a3f54e06474fa941e16",
|
33
|
-
# Value: 24_000_000_000_000_000_000,
|
34
|
-
# Coin: "MNT",
|
35
|
-
# GasCoin: "MNT",
|
36
|
-
# GasPrice: 10,
|
37
|
-
# PrivateKey: "290cd647206bea71ec06d8dfacce30c872aea3fb1ea333b7f475b70467250ca0"
|
38
|
-
# }
|
39
|
-
# tx = Minter::TransactionFfi.SignTransaction(tx_params.to_json)
|
40
|
-
# Minter::Api::Client.new.send_transaction(transaction: tx)
|
41
|
-
|
42
|
-
# ==CREATE COIN==
|
43
|
-
# tx_params = {
|
44
|
-
# Name: "DEVTWO",
|
45
|
-
# Symbol: "DEVTWO",
|
46
|
-
# InitialAmount: 1000000000000000000,
|
47
|
-
# MaxSupply: 10000000000000000000,
|
48
|
-
# InitialReserve: 10000,
|
49
|
-
# ReserveRation: 10,
|
50
|
-
#
|
51
|
-
# Nonce: 29,
|
52
|
-
# ChainId: 2,
|
53
|
-
# GasCoin: "MNT",
|
54
|
-
# GasPrice: 1,
|
55
|
-
# PrivateKey: "290cd647206bea71ec06d8dfacce30c872aea3fb1ea333b7f475b70467250ca0"
|
56
|
-
# }
|
57
|
-
#
|
58
|
-
# tx = Minter::TransactionFfi.SignCreateCoinTransaction(tx_params.to_json)
|
59
|
-
# Minter::Api::Client.new.send_transaction(transaction: tx)
|
60
|
-
|
61
|
-
# ===SELL_COIN===
|
62
|
-
# tx_params = {
|
63
|
-
# CoinToSell: "DEVDEV",
|
64
|
-
# ValueToSell: 1000,
|
65
|
-
# CoinToBuy: "MNT",
|
66
|
-
# MinimumValueToBuy: 100000000,
|
67
|
-
#
|
68
|
-
# Nonce: 31,
|
69
|
-
# ChainId: 2,
|
70
|
-
# GasCoin: "MNT",
|
71
|
-
# GasPrice: 1,
|
72
|
-
# PrivateKey: "290cd647206bea71ec06d8dfacce30c872aea3fb1ea333b7f475b70467250ca0"
|
73
|
-
# }
|
74
|
-
#
|
75
|
-
# tx = Minter::TransactionFfi.SignSellCoinTransaction(tx_params.to_json)
|
76
|
-
# Minter::Api::Client.new.send_transaction(transaction: tx)
|
77
|
-
|
78
|
-
# ===BUY_COIN===
|
79
|
-
# tx_params = {
|
80
|
-
# CoinToBuy: "DEVDEV",
|
81
|
-
# ValueToBuy: 1000,
|
82
|
-
# CoinToSell: "MNT",
|
83
|
-
# MaximumValueToSell: 100000000,
|
84
|
-
#
|
85
|
-
# Nonce: 31,
|
86
|
-
# ChainId: 2,
|
87
|
-
# GasCoin: "MNT",
|
88
|
-
# GasPrice: 1,
|
89
|
-
# PrivateKey: "290cd647206bea71ec06d8dfacce30c872aea3fb1ea333b7f475b70467250ca0"
|
90
|
-
# }
|
91
|
-
#
|
92
|
-
# tx = Minter::TransactionFfi.SignBuyCoinTransaction(tx_params.to_json)
|
93
|
-
# Minter::Api::Client.new.send_transaction(transaction: tx)
|