xrpl-ruby 0.9.0 → 0.9.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b52d066f91b01da1ccdbbe8229cadc3b40b54d79a1234f0ac96f0f131159a06
4
- data.tar.gz: 57fc035044049efff0bae7418e48e6ffee589a2cec5d763b056b07d6c23d0b10
3
+ metadata.gz: 7a1c55dbc3009b560835b548bc4d9438ba6db78522bba892df27f55da5062e38
4
+ data.tar.gz: beace0bdd4432bb8066c85bf7c9f08ff1c3f9620b561f89c07eed4303d0dc123
5
5
  SHA512:
6
- metadata.gz: 4fd54f7b3c12b2cdf35ceecf7a226526900e31e866f16ad3b138d86ac98571e8cf501904b478fa5fa3ace4a8f49ae0e7ee160a33ba8fbd7031d0563cb59876eb
7
- data.tar.gz: 5e61d8a4da0bf7e517b22ae77d3b5ea2580ae36f2751fba690051482c449d2778fb3be9886167e0160ad45d08cc1639afd9eb9b39fefa074163d712b06f1f64b
6
+ metadata.gz: e60d54f4c8f1dd7022a171541dac1c851dc990f82c527458f495335f3f64132c93cf794748da215b4cbb154868853b1302245c6f1e38becf62df0c18d4a256c7
7
+ data.tar.gz: 4092bb66dc708147a33f1c4a84a599e358948efac34c18838463efc50eace671a118c74f6af827ffca79ce71e09d693aa4d66aec292aebc2c85cca7deaf9b8e6
data/CHANGELOG.md CHANGED
@@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.9.1] - 2026-11-02
11
+
12
+ A patch release with one fix: codec types now produce valid JSON inside
13
+ `JSON.generate`, which before gave invalid JSON or raised. Nothing else
14
+ changes; the codec's own calls behave as in 0.9.0. Codec fixtures 39/39
15
+ and 263/263, both ways; all 10 Testnet specs pass on the release commit.
16
+
17
+ ### Fixed
18
+
19
+ - **Codec types work inside `JSON.generate`.** Every type answered Ruby's
20
+ JSON library the way it answers the codec: with the value, not with JSON
21
+ text. As a result `JSON.generate({ 'x' => obj })`
22
+ - gave invalid JSON for a Uint64 or AccountId (`{"x":00000000000036D6}`),
23
+ - raised `TypeError` for a Uint32 or an STObject.
24
+
25
+ Called with a `JSON::State`, which is what `JSON.generate`,
26
+ `pretty_generate` and `dump` pass, `to_json` now renders the codec value as
27
+ JSON. Every other call is unchanged, so the codec's own
28
+ `to_json(definitions, field_name)` still returns the value. For encoders
29
+ that ask for `as_json` instead (ActiveSupport), the types answer with the
30
+ codec value as well.
31
+
10
32
  ## [0.9.0] - 2026-11-02
11
33
 
12
34
  Batch (XLS-56) and permission delegation (XLS-75), both enabled on Mainnet
@@ -2,6 +2,31 @@
2
2
 
3
3
  module BinaryCodec
4
4
  class SerializedType
5
+ # to_json has two callers that want different things. The codec calls
6
+ # to_json(definitions, field_name) and expects the value as rippled
7
+ # renders it - an Integer, a String, a Hash (CLAUDE.md §2.8). Ruby's JSON
8
+ # library calls to_json(state) for an object inside JSON.generate,
9
+ # pretty_generate or dump and expects a JSON text. Without telling them
10
+ # apart, a Uint64 or AccountId came out as unquoted, invalid JSON and a
11
+ # Uint32 or STObject raised TypeError.
12
+ #
13
+ # This module sits in front of every type's to_json: given a JSON::State
14
+ # it renders the codec value as JSON, any other call reaches the type
15
+ # unchanged.
16
+ module JSONState
17
+ def to_json(*args)
18
+ state = args.first
19
+ return super unless defined?(::JSON::State) && state.is_a?(::JSON::State)
20
+
21
+ super().to_json(state)
22
+ end
23
+ end
24
+
25
+ def self.inherited(subclass)
26
+ super
27
+ subclass.prepend(JSONState)
28
+ end
29
+ prepend JSONState
5
30
 
6
31
  attr_reader :bytes
7
32
 
@@ -69,6 +94,14 @@ module BinaryCodec
69
94
  to_hex
70
95
  end
71
96
 
97
+ # The codec value, for encoders that ask for as_json rather than
98
+ # to_json (ActiveSupport): the same value to_json gives the codec.
99
+ #
100
+ # @return [Object] an Integer, String, Array or Hash
101
+ def as_json(*)
102
+ to_json
103
+ end
104
+
72
105
  # Returns the value of the serialized type
73
106
  # @return [Object] - The value of the serialized type
74
107
  def value_of
data/lib/xrpl/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module XRPL
4
- VERSION = '0.9.0'
4
+ VERSION = '0.9.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xrpl-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Busse