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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/keoken/token.rb +3 -3
- data/lib/keoken/version.rb +1 -1
- data/spec/keoken_spec.rb +31 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d41ed0451c7929d237d77b895dd201561446d6175363b582285b1b29b46bcd77
|
4
|
+
data.tar.gz: 5ff14c7e524b385192afd4b473ac54b638fd371cef5e22f298ad9b9102ec7301
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f062ab5ec5e97e2c4d8f4cf13dc26de5af33b9899612981ce52f80f4d78cf4d9a01eb1ec9603afc906389ea0382676c232dad350fab0b6b3b02755cdb541348
|
7
|
+
data.tar.gz: 1ec4e631b9279d5ff915cd73faffa1f66fc6afad6680b0b5d2586fac4e5b0935527151c1c748e4b0525c710e15d5b5cca408fabb41424aa99b9747c29925158d
|
data/Gemfile.lock
CHANGED
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
|
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
|
100
|
+
Keoken::AMOUNT_SIZE - (amount.to_s(16).length + 1)
|
101
101
|
end
|
102
102
|
|
103
103
|
def name_to_hex(name)
|
data/lib/keoken/version.rb
CHANGED
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('
|
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('
|
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
|
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('
|
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
|
185
|
+
it 'format to_json' do
|
170
186
|
json = JSON.parse(@transaction_token.to_json)
|
171
|
-
expect(json[
|
187
|
+
expect(json['out']).to(
|
172
188
|
eq(
|
173
189
|
[
|
174
190
|
{
|
175
|
-
|
176
|
-
|
191
|
+
'value' => '0.00117415',
|
192
|
+
'scriptPubKey' => 'OP_DUP OP_HASH160 4c2791f07c046ef21d688f12296f91ad7b44d2bb OP_EQUALVERIFY OP_CHECKSIG',
|
177
193
|
},
|
178
194
|
{
|
179
|
-
|
180
|
-
|
195
|
+
'value' => '0.08751169',
|
196
|
+
'scriptPubKey' => 'OP_DUP OP_HASH160 7bb97684cc43e2f8ea0ed1d50dddce3ebf800638 OP_EQUALVERIFY OP_CHECKSIG',
|
181
197
|
},
|
182
198
|
{
|
183
|
-
|
184
|
-
|
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('
|
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: '
|
242
|
+
op_return_data: '6a0400004b501800000000746573742d6b656f6b656e0000000000000f4240',
|
227
243
|
script_type: 'PAYTOOPRETURN'
|
228
244
|
}
|
229
245
|
]
|