stellar-sdk 0.1.1 → 0.2.0
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/examples/04_setting_trust.rb +2 -2
- data/examples/05_fiat_payment.rb +2 -2
- data/lib/stellar/amount.rb +16 -13
- data/lib/stellar/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4aa578fb224a0afd75fbf3c65f3fa87cec56ede
|
4
|
+
data.tar.gz: 35db6e2fe51dec1846ae32ec545352bfd46ed2ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 714339c880444dd968673f8db1ee42348f2dca63b9097fc36f1e6c46fbccf6e42721d5c1b8824188891e902ec92577ccd3078c61a08197fcad4bb8b43d8d9594
|
7
|
+
data.tar.gz: 6a47049ff8c0908a34377989f67e50feec2cf14e88dbef924448d3103ef606e5244e257ec20d791e8f41d6db2e2946b073a01381d8174189f749925fd05776a6
|
@@ -4,9 +4,9 @@ account = Stellar::Account.from_seed("s3fu5vCMrfYouKuk2uB1gCD7EsuuBKY9M4qmnniQMB
|
|
4
4
|
client = Stellar::Client.default_testnet()
|
5
5
|
|
6
6
|
issuer = Stellar::Account.lookup("issuer@haste.co.nz"))
|
7
|
-
|
7
|
+
asset = Stellar::Asset.credit_alphanum4("USD", issuer)
|
8
8
|
|
9
9
|
client.trust({
|
10
10
|
account: account
|
11
|
-
|
11
|
+
asset: asset
|
12
12
|
})
|
data/examples/05_fiat_payment.rb
CHANGED
@@ -4,10 +4,10 @@ account = Stellar::Account.from_seed("s3fu5vCMrfYouKuk2uB1gCD7EsuuBKY9M4qmnniQMB
|
|
4
4
|
client = Stellar::Client.default_testnet()
|
5
5
|
|
6
6
|
issuer = Stellar::Account.lookup("issuer@haste.co.nz"))
|
7
|
-
|
7
|
+
asset = Stellar::Asset.credit_alphanum4("USD", issuer)
|
8
8
|
|
9
9
|
client.send({
|
10
10
|
from: account,
|
11
11
|
to: recipient,
|
12
|
-
amount: Stellar::Amount.new(100,
|
12
|
+
amount: Stellar::Amount.new(100, asset, issuer)
|
13
13
|
}) # => #<OK>
|
data/lib/stellar/amount.rb
CHANGED
@@ -3,35 +3,38 @@ module Stellar
|
|
3
3
|
include Contracts
|
4
4
|
|
5
5
|
attr_reader :amount
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :asset
|
7
7
|
|
8
|
-
Contract Pos,
|
9
|
-
def initialize(amount,
|
8
|
+
Contract Pos, Asset => Any
|
9
|
+
def initialize(amount, asset=Stellar::Asset.native())
|
10
10
|
# TODO: how are we going to handle decimal considerations?
|
11
11
|
|
12
|
-
@amount
|
13
|
-
@
|
12
|
+
@amount = amount
|
13
|
+
@asset = asset
|
14
14
|
end
|
15
15
|
|
16
16
|
|
17
17
|
Contract None => Or[
|
18
|
-
[:
|
18
|
+
[Or[:credit_alphanum4, :credit_alphanum12], String, KeyPair, Pos],
|
19
19
|
[:native, Pos],
|
20
20
|
]
|
21
21
|
def to_payment
|
22
|
-
case
|
23
|
-
when
|
22
|
+
case asset.type
|
23
|
+
when AssetType.asset_type_native
|
24
24
|
[:native, amount]
|
25
|
-
when
|
26
|
-
keypair = KeyPair.from_public_key(
|
27
|
-
[:
|
25
|
+
when AssetType.asset_type_credit_alphanum4
|
26
|
+
keypair = KeyPair.from_public_key(asset.issuer)
|
27
|
+
[:credit_alphanum4, asset, keypair, amount]
|
28
|
+
when AssetType.asset_type_credit_alphanum12
|
29
|
+
keypair = KeyPair.from_public_key(asset.issuer)
|
30
|
+
[:credit_alphanum12, asset, keypair, amount]
|
28
31
|
else
|
29
|
-
raise "Unknown
|
32
|
+
raise "Unknown asset type: #{asset.type}"
|
30
33
|
end
|
31
34
|
end
|
32
35
|
|
33
36
|
def inspect
|
34
|
-
"#<Stellar::Amount #{
|
37
|
+
"#<Stellar::Amount #{asset}(#{amount})>"
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
data/lib/stellar/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED