stellar-base 0.24.0 → 0.28.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/CHANGELOG.md +79 -56
- data/README.md +7 -7
- data/generated/stellar-base-generated.rb +15 -0
- data/generated/stellar/account_flags.rb +9 -4
- data/generated/stellar/account_merge_result.rb +1 -1
- data/generated/stellar/allow_trust_op.rb +3 -18
- data/generated/stellar/asset_code.rb +30 -0
- data/generated/stellar/begin_sponsoring_future_reserves_result.rb +2 -1
- data/generated/stellar/claimable_balance_entry.rb +2 -0
- data/generated/stellar/claimable_balance_entry/ext.rb +4 -0
- data/generated/stellar/claimable_balance_entry_extension_v1.rb +30 -0
- data/generated/stellar/claimable_balance_entry_extension_v1/ext.rb +24 -0
- data/generated/stellar/claimable_balance_flags.rb +22 -0
- data/generated/stellar/clawback_claimable_balance_op.rb +18 -0
- data/generated/stellar/clawback_claimable_balance_result.rb +26 -0
- data/generated/stellar/clawback_claimable_balance_result_code.rb +29 -0
- data/generated/stellar/clawback_op.rb +22 -0
- data/generated/stellar/clawback_result.rb +25 -0
- data/generated/stellar/clawback_result_code.rb +31 -0
- data/generated/stellar/create_passive_sell_offer_op.rb +1 -1
- data/generated/stellar/end_sponsoring_future_reserves_result.rb +2 -1
- data/generated/stellar/operation.rb +6 -0
- data/generated/stellar/operation/body.rb +12 -0
- data/generated/stellar/operation_id.rb +1 -1
- data/generated/stellar/operation_id/id.rb +2 -2
- data/generated/stellar/operation_result.rb +6 -0
- data/generated/stellar/operation_result/tr.rb +12 -0
- data/generated/stellar/operation_type.rb +7 -1
- data/generated/stellar/payment_result_code.rb +1 -1
- data/generated/stellar/revoke_sponsorship_op.rb +1 -2
- data/generated/stellar/set_options_result_code.rb +14 -11
- data/generated/stellar/set_trust_line_flags_op.rb +25 -0
- data/generated/stellar/set_trust_line_flags_result.rb +25 -0
- data/generated/stellar/set_trust_line_flags_result_code.rb +31 -0
- data/generated/stellar/transaction_result_code.rb +1 -1
- data/generated/stellar/trust_line_flags.rb +5 -1
- data/lib/stellar-base.rb +6 -2
- data/lib/stellar/account.rb +59 -0
- data/lib/stellar/asset.rb +10 -0
- data/lib/stellar/compat.rb +6 -7
- data/lib/stellar/concerns/transaction.rb +5 -4
- data/lib/stellar/dsl.rb +32 -5
- data/lib/stellar/ext/xdr.rb +8 -7
- data/lib/stellar/key_pair.rb +22 -23
- data/lib/stellar/ledger_key.rb +4 -2
- data/lib/stellar/muxed_account.rb +16 -0
- data/lib/stellar/operation.rb +89 -19
- data/lib/stellar/transaction.rb +1 -1
- data/lib/stellar/transaction_builder.rb +20 -7
- data/lib/stellar/transaction_envelope.rb +6 -16
- data/lib/stellar/transaction_v0.rb +2 -10
- data/lib/stellar/trust_line_flags.rb +53 -0
- data/lib/stellar/util/strkey.rb +15 -7
- data/lib/stellar/version.rb +3 -0
- metadata +34 -16
- data/generated/stellar/allow_trust_op/asset.rb +0 -33
- data/lib/stellar/base/version.rb +0 -5
@@ -3,15 +3,7 @@ module Stellar
|
|
3
3
|
include Stellar::Concerns::Transaction
|
4
4
|
|
5
5
|
def to_v1
|
6
|
-
Transaction.new(
|
7
|
-
source_account: Stellar::MuxedAccount.new(:key_type_ed25519, source_account),
|
8
|
-
seq_num: seq_num,
|
9
|
-
operations: operations,
|
10
|
-
fee: fee,
|
11
|
-
memo: memo,
|
12
|
-
time_bounds: time_bounds,
|
13
|
-
ext: ext
|
14
|
-
)
|
6
|
+
Transaction.new(**attributes.except(:source_account_ed25519), source_account: source_account)
|
15
7
|
end
|
16
8
|
|
17
9
|
def to_envelope(*key_pairs)
|
@@ -45,7 +37,7 @@ module Stellar
|
|
45
37
|
end
|
46
38
|
|
47
39
|
def source_account
|
48
|
-
source_account_ed25519
|
40
|
+
Stellar::MuxedAccount.ed25519(source_account_ed25519)
|
49
41
|
end
|
50
42
|
end
|
51
43
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Stellar
|
2
|
+
class TrustLineFlags
|
3
|
+
# Converts an array of Stellar::TrustLineFlags members into
|
4
|
+
# an integers suitable for use in in a SetTrustLineFlagsOp.
|
5
|
+
#
|
6
|
+
# @param flags [Array<Stellar::TrustLineFlags>] the flags to combine
|
7
|
+
#
|
8
|
+
# @return [Fixnum] the combined result
|
9
|
+
def self.make_mask(flags)
|
10
|
+
normalize(flags).map(&:value).inject(&:|) || 0
|
11
|
+
end
|
12
|
+
|
13
|
+
# Converts an integer used in SetTrustLineFlagsOp on the set/clear flag options
|
14
|
+
# into an array of Stellar::TrustLineFlags members
|
15
|
+
#
|
16
|
+
# @param combined [Fixnum]
|
17
|
+
# @return [Array<Stellar::AccountFlags>]
|
18
|
+
def self.parse_mask(combined)
|
19
|
+
members.values.select { |m| (m.value & combined) != 0 }
|
20
|
+
end
|
21
|
+
|
22
|
+
# Converts each element of the input array to Stellar::TrustLineFlags instance.
|
23
|
+
#
|
24
|
+
# @param [Array<Stellar::TrustLineFlags,Symbol,#to_s>] input
|
25
|
+
# @return [Array<Stellar::TrustLineFlags>]
|
26
|
+
# @raise [TypeError] if any element of the input cannot be converted
|
27
|
+
def self.normalize(input)
|
28
|
+
input.map do |val|
|
29
|
+
case val
|
30
|
+
when Stellar::TrustLineFlags
|
31
|
+
val
|
32
|
+
when ->(_) { members.key?(val.to_s) }
|
33
|
+
from_name(val.to_s)
|
34
|
+
when ->(_) { members.key?("#{val}_flag") }
|
35
|
+
from_name("#{val}_flag")
|
36
|
+
else
|
37
|
+
raise TypeError, "unknown trustline flag: #{val}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.set_clear_masks(flags)
|
43
|
+
set_flags = []
|
44
|
+
clear_flags = []
|
45
|
+
|
46
|
+
Hash(flags).each do |flag, value|
|
47
|
+
value.present? ? set_flags.push(flag) : clear_flags.push(flag)
|
48
|
+
end
|
49
|
+
|
50
|
+
{set_flags: make_mask(set_flags), clear_flags: make_mask(clear_flags)}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/stellar/util/strkey.rb
CHANGED
@@ -8,7 +8,8 @@ module Stellar
|
|
8
8
|
account_id: [6 << 3].pack("C"), # Base32-encodes to 'G...'
|
9
9
|
seed: [18 << 3].pack("C"), # Base32-encodes to 'S...'
|
10
10
|
pre_auth_tx: [19 << 3].pack("C"), # Base32-encodes to 'T...'
|
11
|
-
hash_x: [23 << 3].pack("C") # Base32-encodes to 'X...'
|
11
|
+
hash_x: [23 << 3].pack("C"), # Base32-encodes to 'X...'
|
12
|
+
muxed: [12 << 3].pack("C") # Base32-encodes to 'M...'
|
12
13
|
}
|
13
14
|
|
14
15
|
def self.check_encode(version, byte_str)
|
@@ -25,13 +26,11 @@ module Stellar
|
|
25
26
|
# @param muxed_account [Stellar::MuxedAccount] account
|
26
27
|
# @return [String] "G.."-like address
|
27
28
|
def self.encode_muxed_account(muxed_account)
|
28
|
-
|
29
|
-
muxed_account.ed25519
|
29
|
+
if muxed_account.ed25519
|
30
|
+
check_encode(:account_id, muxed_account.ed25519)
|
30
31
|
else
|
31
|
-
muxed_account.med25519!.ed25519
|
32
|
+
check_encode(:muxed, muxed_account.med25519!.ed25519 + [muxed_account.med25519!.id].pack("Q>"))
|
32
33
|
end
|
33
|
-
|
34
|
-
check_encode(:account_id, ed25519)
|
35
34
|
end
|
36
35
|
|
37
36
|
# Returns a Stellar::MuxedAccount, forcing the ed25519 discriminant
|
@@ -39,7 +38,16 @@ module Stellar
|
|
39
38
|
# @param strkey [String] address string to decode
|
40
39
|
# @return [Stellar::MuxedAccount] MuxedAccount with ed25519 discriminant
|
41
40
|
def self.decode_muxed_account(strkey)
|
42
|
-
|
41
|
+
case strkey
|
42
|
+
when /^G[0-9A-Z]{55}$/
|
43
|
+
ed25519 = check_decode(:account_id, strkey)
|
44
|
+
Stellar::MuxedAccount.ed25519(ed25519)
|
45
|
+
when /^M[0-9A-Z]{68}$/
|
46
|
+
payload = check_decode(:muxed, strkey)
|
47
|
+
Stellar::MuxedAccount.med25519(ed25519: payload[0, 32], id: payload[32, 8].unpack1("Q>"))
|
48
|
+
else
|
49
|
+
raise "cannot decode MuxedAccount from #{strkey}"
|
50
|
+
end
|
43
51
|
end
|
44
52
|
|
45
53
|
def self.check_decode(expected_version, str)
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stellar-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.28.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Fleckenstein
|
8
8
|
- Sergey Nebolsin
|
9
9
|
- Timur Ramazanov
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-07-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -168,10 +168,10 @@ dependencies:
|
|
168
168
|
- - "~>"
|
169
169
|
- !ruby/object:Gem::Version
|
170
170
|
version: '1.3'
|
171
|
-
description:
|
172
|
-
It consists of classes to read, write,
|
173
|
-
are used in stellar-core
|
174
|
-
email:
|
171
|
+
description: |
|
172
|
+
The stellar-base library is the lowest-level stellar helper library. It consists of classes to read, write,
|
173
|
+
hash, and sign the xdr structures that are used in stellar-core.
|
174
|
+
email:
|
175
175
|
executables: []
|
176
176
|
extensions: []
|
177
177
|
extra_rdoc_files:
|
@@ -193,12 +193,12 @@ files:
|
|
193
193
|
- generated/stellar/account_merge_result.rb
|
194
194
|
- generated/stellar/account_merge_result_code.rb
|
195
195
|
- generated/stellar/allow_trust_op.rb
|
196
|
-
- generated/stellar/allow_trust_op/asset.rb
|
197
196
|
- generated/stellar/allow_trust_result.rb
|
198
197
|
- generated/stellar/allow_trust_result_code.rb
|
199
198
|
- generated/stellar/asset.rb
|
200
199
|
- generated/stellar/asset/alpha_num12.rb
|
201
200
|
- generated/stellar/asset/alpha_num4.rb
|
201
|
+
- generated/stellar/asset_code.rb
|
202
202
|
- generated/stellar/asset_type.rb
|
203
203
|
- generated/stellar/auth.rb
|
204
204
|
- generated/stellar/auth_cert.rb
|
@@ -225,11 +225,20 @@ files:
|
|
225
225
|
- generated/stellar/claim_predicate_type.rb
|
226
226
|
- generated/stellar/claimable_balance_entry.rb
|
227
227
|
- generated/stellar/claimable_balance_entry/ext.rb
|
228
|
+
- generated/stellar/claimable_balance_entry_extension_v1.rb
|
229
|
+
- generated/stellar/claimable_balance_entry_extension_v1/ext.rb
|
230
|
+
- generated/stellar/claimable_balance_flags.rb
|
228
231
|
- generated/stellar/claimable_balance_id.rb
|
229
232
|
- generated/stellar/claimable_balance_id_type.rb
|
230
233
|
- generated/stellar/claimant.rb
|
231
234
|
- generated/stellar/claimant/v0.rb
|
232
235
|
- generated/stellar/claimant_type.rb
|
236
|
+
- generated/stellar/clawback_claimable_balance_op.rb
|
237
|
+
- generated/stellar/clawback_claimable_balance_result.rb
|
238
|
+
- generated/stellar/clawback_claimable_balance_result_code.rb
|
239
|
+
- generated/stellar/clawback_op.rb
|
240
|
+
- generated/stellar/clawback_result.rb
|
241
|
+
- generated/stellar/clawback_result_code.rb
|
233
242
|
- generated/stellar/create_account_op.rb
|
234
243
|
- generated/stellar/create_account_result.rb
|
235
244
|
- generated/stellar/create_account_result_code.rb
|
@@ -355,6 +364,9 @@ files:
|
|
355
364
|
- generated/stellar/set_options_op.rb
|
356
365
|
- generated/stellar/set_options_result.rb
|
357
366
|
- generated/stellar/set_options_result_code.rb
|
367
|
+
- generated/stellar/set_trust_line_flags_op.rb
|
368
|
+
- generated/stellar/set_trust_line_flags_result.rb
|
369
|
+
- generated/stellar/set_trust_line_flags_result_code.rb
|
358
370
|
- generated/stellar/signed_survey_request_message.rb
|
359
371
|
- generated/stellar/signed_survey_response_message.rb
|
360
372
|
- generated/stellar/signer.rb
|
@@ -403,10 +415,10 @@ files:
|
|
403
415
|
- generated/stellar/trust_line_flags.rb
|
404
416
|
- generated/stellar/upgrade_entry_meta.rb
|
405
417
|
- lib/stellar-base.rb
|
418
|
+
- lib/stellar/account.rb
|
406
419
|
- lib/stellar/account_flags.rb
|
407
420
|
- lib/stellar/asset.rb
|
408
421
|
- lib/stellar/base.rb
|
409
|
-
- lib/stellar/base/version.rb
|
410
422
|
- lib/stellar/claim_predicate.rb
|
411
423
|
- lib/stellar/compat.rb
|
412
424
|
- lib/stellar/concerns/transaction.rb
|
@@ -417,6 +429,7 @@ files:
|
|
417
429
|
- lib/stellar/fee_bump_transaction.rb
|
418
430
|
- lib/stellar/key_pair.rb
|
419
431
|
- lib/stellar/ledger_key.rb
|
432
|
+
- lib/stellar/muxed_account.rb
|
420
433
|
- lib/stellar/networks.rb
|
421
434
|
- lib/stellar/operation.rb
|
422
435
|
- lib/stellar/path_payment_strict_receive_result.rb
|
@@ -427,15 +440,20 @@ files:
|
|
427
440
|
- lib/stellar/transaction_builder.rb
|
428
441
|
- lib/stellar/transaction_envelope.rb
|
429
442
|
- lib/stellar/transaction_v0.rb
|
443
|
+
- lib/stellar/trust_line_flags.rb
|
430
444
|
- lib/stellar/util/strkey.rb
|
431
|
-
|
445
|
+
- lib/stellar/version.rb
|
446
|
+
homepage: https://github.com/astroband/ruby-stellar-sdk
|
432
447
|
licenses:
|
433
448
|
- Apache-2.0
|
434
449
|
metadata:
|
435
|
-
|
436
|
-
changelog_uri: https://github.com/astroband/ruby-stellar-sdk/blob/v0.
|
437
|
-
|
438
|
-
|
450
|
+
bug_tracker_uri: https://github.com/astroband/ruby-stellar-sdk/issues
|
451
|
+
changelog_uri: https://github.com/astroband/ruby-stellar-sdk/blob/v0.28.0/base/CHANGELOG.md
|
452
|
+
documentation_uri: https://rubydoc.info/gems/stellar-base/0.28.0/
|
453
|
+
github_repo: ssh://github.com/astroband/ruby-stellar-sdk
|
454
|
+
homepage_uri: https://github.com/astroband/ruby-stellar-sdk/tree/main/base
|
455
|
+
source_code_uri: https://github.com/astroband/ruby-stellar-sdk/tree/v0.28.0/base
|
456
|
+
post_install_message:
|
439
457
|
rdoc_options: []
|
440
458
|
require_paths:
|
441
459
|
- generated
|
@@ -451,8 +469,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
451
469
|
- !ruby/object:Gem::Version
|
452
470
|
version: '0'
|
453
471
|
requirements: []
|
454
|
-
rubygems_version: 3.2.
|
455
|
-
signing_key:
|
472
|
+
rubygems_version: 3.2.22
|
473
|
+
signing_key:
|
456
474
|
specification_version: 4
|
457
475
|
summary: 'Stellar client library: XDR'
|
458
476
|
test_files: []
|
@@ -1,33 +0,0 @@
|
|
1
|
-
# This code was automatically generated using xdrgen
|
2
|
-
# DO NOT EDIT or your changes may be overwritten
|
3
|
-
|
4
|
-
require 'xdr'
|
5
|
-
|
6
|
-
# === xdr source ============================================================
|
7
|
-
#
|
8
|
-
# union switch (AssetType type)
|
9
|
-
# {
|
10
|
-
# // ASSET_TYPE_NATIVE is not allowed
|
11
|
-
# case ASSET_TYPE_CREDIT_ALPHANUM4:
|
12
|
-
# AssetCode4 assetCode4;
|
13
|
-
#
|
14
|
-
# case ASSET_TYPE_CREDIT_ALPHANUM12:
|
15
|
-
# AssetCode12 assetCode12;
|
16
|
-
#
|
17
|
-
# // add other asset types here in the future
|
18
|
-
# }
|
19
|
-
#
|
20
|
-
# ===========================================================================
|
21
|
-
module Stellar
|
22
|
-
class AllowTrustOp
|
23
|
-
class Asset < XDR::Union
|
24
|
-
switch_on AssetType, :type
|
25
|
-
|
26
|
-
switch :asset_type_credit_alphanum4, :asset_code4
|
27
|
-
switch :asset_type_credit_alphanum12, :asset_code12
|
28
|
-
|
29
|
-
attribute :asset_code4, AssetCode4
|
30
|
-
attribute :asset_code12, AssetCode12
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|