stellar-base 0.9.0 → 0.10.0

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
  SHA1:
3
- metadata.gz: 56dbbad8a7ba7b91b79df49f5002eb6d49c05420
4
- data.tar.gz: 40d09c079eefa934a2b89074768e511fcd56e112
3
+ metadata.gz: 549ab91d8bfb91e48d75d4b924d398fb85342e36
4
+ data.tar.gz: 631468aab5e41d20a439ae4b24a44a136eff1b98
5
5
  SHA512:
6
- metadata.gz: c9e3c18fa70289ea4361605170987f2aee62ae9cb2ea1824f12f9b97237343427e51436523e5a8a56ea1c57153d14d188c45e36b49e2ea715ff5911bf86bfe45
7
- data.tar.gz: bb265bfba87aa980c82ba40df3b11282ee8d86ae403b17f4762e573a0def806bcdfae37556ddf717ba81e3d97fe8b4aab3fe9ca2608ba2da7ff75f31f103caa6
6
+ metadata.gz: a74bf53ea5b202bfcff75fbcada4e459a185849ec023dbe63613962c424779c82ed66e35f11b483ec68ffc804a76097e66dfade5a93dce3f8eda7364db37c8d4
7
+ data.tar.gz: 59b96582bcaf5e9869e0df8736129b5ed841d3633ddf4b0230bd6a16781cfb10d39be49cba12f175a93cd02982155451ab2236b184424bb4cecd8084315ce42e
data/CHANGELOG.md CHANGED
@@ -6,7 +6,10 @@ file. This project adheres to [Semantic Versioning](http://semver.org/).
6
6
  As this project is pre 1.0, breaking changes may happen for minor version
7
7
  bumps. A breaking change will get clearly notified in this log.
8
8
 
9
- ## [unreleased](https://github.com/stellar/ruby-stellar-base/compare/v0.9.0...master)
9
+ ## [unreleased](https://github.com/stellar/ruby-stellar-base/compare/v0.10.0...master)
10
+ ## [0.10.0](https://github.com/stellar/ruby-stellar-base/compare/v0.0.0...v0.10.0)
11
+
12
+ - Added memo helpers to `Stellar::Transaction.for_account`, allowing any operation builder (such as `Stellar::Transaction.payment) to provide a custom memo using the `:memo` attribute.
10
13
 
11
14
  ## [0.9.0](https://github.com/stellar/ruby-stellar-base/compare/v0.8.0...v0.9.0)
12
15
 
@@ -1,5 +1,5 @@
1
1
  module Stellar
2
2
  module Base
3
- VERSION = "0.9.0"
3
+ VERSION = "0.10.0"
4
4
  end
5
5
  end
@@ -101,6 +101,7 @@ module Stellar
101
101
  new.tap do |result|
102
102
  result.seq_num = sequence
103
103
  result.fee = fee
104
+ result.memo = make_memo(attributes[:memo])
104
105
  result.source_account = account.account_id
105
106
  result.apply_defaults
106
107
  end
@@ -166,5 +167,24 @@ module Stellar
166
167
  self.memo ||= Memo.new(:memo_none)
167
168
  self.ext ||= Stellar::Transaction::Ext.new 0
168
169
  end
170
+
171
+ private
172
+ def self.make_memo(memo)
173
+ case memo
174
+ when Stellar::Memo ;
175
+ memo
176
+ when nil ;
177
+ nil
178
+ when Integer ;
179
+ Memo.new(:memo_id, memo)
180
+ when String ;
181
+ Memo.new(:memo_text, memo)
182
+ when Array ;
183
+ t, val = *memo
184
+ Memo.new(:"memo_#{t}", val)
185
+ else
186
+ raise ArgumentError, "Bad :memo"
187
+ end
188
+ end
169
189
  end
170
190
  end
@@ -51,4 +51,33 @@ describe Stellar::Transaction do
51
51
  end
52
52
 
53
53
  end
54
+
55
+ describe ".for_account's memo assignment" do
56
+ let(:attrs){{account: Stellar::KeyPair.random, sequence: 1}}
57
+
58
+ def make(memo)
59
+ tx = Stellar::Transaction.for_account(attrs.merge(memo: memo))
60
+ tx.memo
61
+ end
62
+
63
+ it "sets to an ID memo when a number is provided" do
64
+ expect(make(3)).to eql(Stellar::Memo.new(:memo_id, 3))
65
+ end
66
+
67
+ it "sets to an text memo when a number is provided" do
68
+ expect(make("hello")).to eql(Stellar::Memo.new(:memo_text, "hello"))
69
+ end
70
+
71
+ it "uses the provided value directly if already a memo" do
72
+ expect(make(Stellar::Memo.new(:memo_text, "hello"))).to eql(Stellar::Memo.new(:memo_text, "hello"))
73
+ end
74
+
75
+
76
+ it "allows a 2-element array as shorthand" do
77
+ expect(make([:id, 3])).to eql(Stellar::Memo.new(:memo_id, 3))
78
+ expect(make([:text, "h"])).to eql(Stellar::Memo.new(:memo_text, "h"))
79
+ expect(make([:hash, "h"])).to eql(Stellar::Memo.new(:memo_hash, "h"))
80
+ expect(make([:return, "h"])).to eql(Stellar::Memo.new(:memo_return, "h"))
81
+ end
82
+ end
54
83
  end
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.9.0
4
+ version: 0.10.0
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-12-07 00:00:00.000000000 Z
11
+ date: 2015-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xdr