stellar-base 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Rakefile +0 -2
- data/lib/stellar/base/version.rb +1 -1
- data/lib/stellar/convert.rb +34 -0
- data/lib/stellar-base.rb +2 -1
- data/ruby-stellar-base.gemspec +1 -0
- data/spec/lib/stellar/convert_spec.rb +52 -0
- data/tasks/travis.rake +1 -9
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4975e0b08060f21ba3def7e74fb8f410d6bd932e
|
4
|
+
data.tar.gz: 77f77dfed12eecded1b94d2348a01797c34b414f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 212fcee22b67c4ac68bc625d13bd6537dad5db82d504df6c7d75b145b85f2efcc7b2ba780f95d4d9e9858cb682966926c422a9ae4487e3d42075baf3fa49f3e8
|
7
|
+
data.tar.gz: 6ccc731105f397cd3d4550423a45a9f11227ff11466ff4f00f835d76ed2bb3554811ffbd94f15b860dfebf7b0edc1c658cac4b47e5011b8a8e22f0a4fc282b72
|
data/.travis.yml
CHANGED
@@ -6,7 +6,7 @@ rvm:
|
|
6
6
|
- 1.9.3
|
7
7
|
- jruby-1.7.9
|
8
8
|
- jruby-head
|
9
|
-
script:
|
9
|
+
script: bundle exec rake travis
|
10
10
|
notifications:
|
11
11
|
slack:
|
12
12
|
secure: V/6a8KFe067uukrbCJA2R1HPO4xy0YSQ1pwmHVRi5StX+yl+lYsWWJdjdBdT0j3iJBYyPRqU4bQYck+OloxtELnrHCX+OkodxcxW8W/ACc914iIf0FyY9pnusK7ck2awmt4Iuf94YPgi0XTm1aCcm+f0yU7wiIVFpftoXSk1EDY=
|
data/Rakefile
CHANGED
data/lib/stellar/base/version.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Stellar
|
2
|
+
#
|
3
|
+
# Generic format conversion module
|
4
|
+
#
|
5
|
+
module Convert
|
6
|
+
require 'base64'
|
7
|
+
|
8
|
+
def to_hex(string)
|
9
|
+
string.unpack("H*").first
|
10
|
+
end
|
11
|
+
|
12
|
+
def from_hex(hex_string)
|
13
|
+
[hex_string].pack("H*")
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_base64(string)
|
17
|
+
Base64.strict_encode64(string)
|
18
|
+
end
|
19
|
+
|
20
|
+
def from_base64(base64_string)
|
21
|
+
Base64.strict_decode64(base64_string)
|
22
|
+
end
|
23
|
+
|
24
|
+
def base58
|
25
|
+
Stellar::Util::Base58.stellar
|
26
|
+
end
|
27
|
+
|
28
|
+
def pk_to_address(pk)
|
29
|
+
base58.check_encode(:account_id, pk)
|
30
|
+
end
|
31
|
+
|
32
|
+
extend self
|
33
|
+
end
|
34
|
+
end
|
data/lib/stellar-base.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'xdr'
|
2
|
-
require 'rbnacl'
|
2
|
+
require 'rbnacl/libsodium'
|
3
3
|
require 'digest/sha2'
|
4
4
|
require 'active_support/core_ext/object/blank'
|
5
5
|
require 'active_support/core_ext/enumerable'
|
@@ -26,3 +26,4 @@ require_relative './stellar/transaction'
|
|
26
26
|
require_relative './stellar/transaction_envelope'
|
27
27
|
require_relative './stellar/util/base58'
|
28
28
|
require_relative './stellar/util/continued_fraction'
|
29
|
+
require_relative './stellar/convert'
|
data/ruby-stellar-base.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_dependency "xdr", "~> 0.0.2"
|
21
21
|
spec.add_dependency "rbnacl"
|
22
|
+
spec.add_dependency "rbnacl-libsodium", "~> 1.0.3"
|
22
23
|
spec.add_dependency "activesupport", "~> 4"
|
23
24
|
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.7"
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Stellar::Convert, "hex encoding" do
|
4
|
+
subject{ Stellar::Convert }
|
5
|
+
let(:raw) { "\x01\x02\x03\x04" }
|
6
|
+
let(:hex) { "01020304" }
|
7
|
+
let(:base64){ "AQIDBA==" }
|
8
|
+
|
9
|
+
describe "hex encoding" do
|
10
|
+
it "decodes" do
|
11
|
+
expect(subject.from_hex(hex)).to eq(raw)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "encodes" do
|
15
|
+
expect(subject.to_hex(raw)).to eq(hex)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "round trips" do
|
19
|
+
raw1 = subject.from_hex(hex)
|
20
|
+
hex1 = subject.to_hex(raw1)
|
21
|
+
expect(hex1).to eq(hex)
|
22
|
+
|
23
|
+
|
24
|
+
hex2 = subject.to_hex(raw)
|
25
|
+
raw2 = subject.from_hex(hex2)
|
26
|
+
expect(raw2).to eq(raw)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "base64 encoding" do
|
31
|
+
it "decodes" do
|
32
|
+
expect(subject.from_base64(base64)).to eq(raw)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "encodes" do
|
36
|
+
expect(subject.to_base64(raw)).to eq(base64)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "round trips" do
|
40
|
+
raw1 = subject.from_base64(base64)
|
41
|
+
base641 = subject.to_base64(raw1)
|
42
|
+
expect(base641).to eq(base64)
|
43
|
+
|
44
|
+
|
45
|
+
base642 = subject.to_base64(raw)
|
46
|
+
raw2 = subject.from_base64(base642)
|
47
|
+
expect(raw2).to eq(raw)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
end
|
data/tasks/travis.rake
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stellar-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Fleckenstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xdr
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rbnacl-libsodium
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.3
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.3
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: activesupport
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -296,6 +310,7 @@ files:
|
|
296
310
|
- lib/stellar/account_flags.rb
|
297
311
|
- lib/stellar/base.rb
|
298
312
|
- lib/stellar/base/version.rb
|
313
|
+
- lib/stellar/convert.rb
|
299
314
|
- lib/stellar/currency.rb
|
300
315
|
- lib/stellar/key_pair.rb
|
301
316
|
- lib/stellar/operation.rb
|
@@ -305,6 +320,7 @@ files:
|
|
305
320
|
- lib/stellar/util/base58.rb
|
306
321
|
- lib/stellar/util/continued_fraction.rb
|
307
322
|
- ruby-stellar-base.gemspec
|
323
|
+
- spec/lib/stellar/convert_spec.rb
|
308
324
|
- spec/lib/stellar/key_pair_spec.rb
|
309
325
|
- spec/lib/stellar/price_spec.rb
|
310
326
|
- spec/lib/stellar/transaction_envelope_spec.rb
|
@@ -350,6 +366,7 @@ signing_key:
|
|
350
366
|
specification_version: 4
|
351
367
|
summary: 'Stellar client library: XDR'
|
352
368
|
test_files:
|
369
|
+
- spec/lib/stellar/convert_spec.rb
|
353
370
|
- spec/lib/stellar/key_pair_spec.rb
|
354
371
|
- spec/lib/stellar/price_spec.rb
|
355
372
|
- spec/lib/stellar/transaction_envelope_spec.rb
|