keoken 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14e0efe0081278e084d03fe333a3dbc852dd5b6c219e7b4c45198c69944a24b0
4
- data.tar.gz: a8c4681e653efe43ad9dd2aac60e8c168ab767c03226e0758bed791180bf4ca6
3
+ metadata.gz: d41ed0451c7929d237d77b895dd201561446d6175363b582285b1b29b46bcd77
4
+ data.tar.gz: 5ff14c7e524b385192afd4b473ac54b638fd371cef5e22f298ad9b9102ec7301
5
5
  SHA512:
6
- metadata.gz: ec05b3fe77a60e3fe07dd94004d8c775e82e292e71736bcfb8b35323a604e69003adc30975124e2dbf6fdecb2955d193107fea5a8ed4edcb1d0b2389899acf13
7
- data.tar.gz: 540bac210aae1f70ed8f25d5706cec7adcd4cd343efb18283a1616d64408c25d51a261c31006b623cbb76987da6b1d10ca176ca925b8f9b238d0e9df646fadc3
6
+ metadata.gz: 5f062ab5ec5e97e2c4d8f4cf13dc26de5af33b9899612981ce52f80f4d78cf4d9a01eb1ec9603afc906389ea0382676c232dad350fab0b6b3b02755cdb541348
7
+ data.tar.gz: 1ec4e631b9279d5ff915cd73faffa1f66fc6afad6680b0b5d2586fac4e5b0935527151c1c748e4b0525c710e15d5b5cca408fabb41424aa99b9747c29925158d
data/Gemfile.lock CHANGED
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- keoken (0.2.6)
10
+ keoken (0.2.7)
11
11
  bitcoin-ruby (~> 0.0.18)
12
12
 
13
13
  GEM
data/lib/keoken/token.rb CHANGED
@@ -43,12 +43,12 @@ module Keoken
43
43
  #
44
44
  def send_amount(amount)
45
45
  raise Keoken::Error::IdNotFound unless @id
46
- asset_length = Keoken::ASSET_ID_SIZE - @id.to_s.length - 1
46
+ asset_length = Keoken::ASSET_ID_SIZE - @id.to_s.length
47
47
  @data_script =
48
48
  [
49
49
  Keoken::VERSION_NODE,
50
50
  Keoken::TYPE_SEND_TOKEN,
51
- Keoken::PREFIX_BYTE_ASSET_ID[0..asset_length] + @id.to_s,
51
+ Keoken::PREFIX_BYTE_ASSET_ID[0..(asset_length - 1)] + @id.to_s,
52
52
  Keoken::PREFIX_BYTE_AMOUNT[0..prefix_length(amount)] + amount.to_s(16)
53
53
  ].flatten.join
54
54
  self
@@ -97,7 +97,7 @@ module Keoken
97
97
  end
98
98
 
99
99
  def prefix_length(amount)
100
- Keoken::AMOUNT_SIZE - amount.to_s.length - 1
100
+ Keoken::AMOUNT_SIZE - (amount.to_s(16).length + 1)
101
101
  end
102
102
 
103
103
  def name_to_hex(name)
@@ -1,3 +1,3 @@
1
1
  module Keoken
2
- VERSION = '0.2.7'.freeze
2
+ VERSION = '0.2.8'.freeze
3
3
  end
data/spec/keoken_spec.rb CHANGED
@@ -21,7 +21,15 @@ describe Keoken do
21
21
  token = Keoken::Token.new(name: 'test-keoken')
22
22
  token.create(1_000_000)
23
23
  expect(token.hex).to(
24
- eq('6a0400004b501700000000746573742d6b656f6b656e00000000000f4240')
24
+ eq('6a0400004b501800000000746573742d6b656f6b656e0000000000000f4240')
25
+ )
26
+ end
27
+
28
+ it 'creates the Bitprim token' do
29
+ token = Keoken::Token.new(name: 'Bitprim')
30
+ token.create(1_000_000)
31
+ expect(token.hex).to(
32
+ eq('6a0400004b5014000000004269747072696d0000000000000f4240')
25
33
  )
26
34
  end
27
35
 
@@ -35,11 +43,19 @@ describe Keoken do
35
43
  expect { token.send_amount(1_000_000) }.to raise_error(Keoken::Error::IdNotFound)
36
44
  end
37
45
 
46
+ it 'send 100 to token with 2 id' do
47
+ token = Keoken::Token.new(id: 2)
48
+ token.send_amount(100)
49
+ expect(token.hex).to(
50
+ eq('6a0400004b501000000001000000020000000000000064')
51
+ )
52
+ end
53
+
38
54
  it 'send 1_000_000 to token with 34 id' do
39
55
  token = Keoken::Token.new(id: 34)
40
56
  token.send_amount(1_000_000)
41
57
  expect(token.hex).to(
42
- eq('6a0400004b50f0000000100000034000000000f4240')
58
+ eq('6a0400004b5010000000010000003400000000000f4240')
43
59
  )
44
60
  end
45
61
 
@@ -119,7 +135,7 @@ describe Keoken do
119
135
  },
120
136
  {
121
137
  "value" => "0.00000000",
122
- "scriptPubKey" => "OP_RETURN 00004b50 00000000746573742d6b656f6b656e00000000000f4240",
138
+ "scriptPubKey" => "OP_RETURN 00004b50 00000000746573742d6b656f6b656e0000000000000f4240",
123
139
  },
124
140
  ]
125
141
  )
@@ -129,7 +145,7 @@ describe Keoken do
129
145
  it 'raw transaction' do
130
146
  raw = @transaction_token.raw
131
147
  expect(raw).to start_with('0100000001dae8143d5422d5e1018c43732baa74ac3114d4399a1f58a9ea7e31f656938a44010000006')
132
- expect(raw).to end_with('6a0400004b501700000000746573742d6b656f6b656e00000000000f424000000000')
148
+ expect(raw).to end_with('6a0400004b501800000000746573742d6b656f6b656e0000000000000f424000000000')
133
149
  end
134
150
 
135
151
  it 'broadcast transaction' do
@@ -166,23 +182,23 @@ describe Keoken do
166
182
  @transaction_token.build_for_send_amount(key.addr, 'mnTd41YZ1e1YqsaPNJh3wkeSUrFvp1guzi', key, script)
167
183
  end
168
184
 
169
- it "format to_json" do
185
+ it 'format to_json' do
170
186
  json = JSON.parse(@transaction_token.to_json)
171
- expect(json["out"]).to(
187
+ expect(json['out']).to(
172
188
  eq(
173
189
  [
174
190
  {
175
- "value" => "0.00117415",
176
- "scriptPubKey" => "OP_DUP OP_HASH160 4c2791f07c046ef21d688f12296f91ad7b44d2bb OP_EQUALVERIFY OP_CHECKSIG",
191
+ 'value' => '0.00117415',
192
+ 'scriptPubKey' => 'OP_DUP OP_HASH160 4c2791f07c046ef21d688f12296f91ad7b44d2bb OP_EQUALVERIFY OP_CHECKSIG',
177
193
  },
178
194
  {
179
- "value" => "0.08751169",
180
- "scriptPubKey" => "OP_DUP OP_HASH160 7bb97684cc43e2f8ea0ed1d50dddce3ebf800638 OP_EQUALVERIFY OP_CHECKSIG",
195
+ 'value' => '0.08751169',
196
+ 'scriptPubKey' => 'OP_DUP OP_HASH160 7bb97684cc43e2f8ea0ed1d50dddce3ebf800638 OP_EQUALVERIFY OP_CHECKSIG',
181
197
  },
182
198
  {
183
- "value" => "0.00000000",
184
- "scriptPubKey" => "OP_RETURN 00004b50 000000010000012300000000007a1200",
185
- },
199
+ 'value' => '0.00000000',
200
+ 'scriptPubKey' => 'OP_RETURN 00004b50 0000000100000123000000000007a120'
201
+ }
186
202
  ]
187
203
  )
188
204
  )
@@ -191,7 +207,7 @@ describe Keoken do
191
207
  it 'raw transaction' do
192
208
  raw = @transaction_token.raw
193
209
  expect(raw).to start_with('0100000001dae8143d5422d5e1018c43732baa74ac3114d4399a1f58a9ea7e31f656938a4401000000')
194
- expect(raw).to end_with('6a0400004b5010000000010000012300000000007a120000000000')
210
+ expect(raw).to end_with('6a0400004b50100000000100000123000000000007a12000000000')
195
211
  end
196
212
  end
197
213
 
@@ -223,7 +239,7 @@ describe Keoken do
223
239
  },
224
240
  {
225
241
  amount: '0',
226
- op_return_data: '6a0400004b501700000000746573742d6b656f6b656e00000000000f4240',
242
+ op_return_data: '6a0400004b501800000000746573742d6b656f6b656e0000000000000f4240',
227
243
  script_type: 'PAYTOOPRETURN'
228
244
  }
229
245
  ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keoken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bitex