mixin_bot 2.2.0 → 2.2.2

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: 2bbc251caedc50e5324a90713c291cf019b2bf0fa003a7ad4df3401af5b175fa
4
- data.tar.gz: cb7e858d5073bb2fc8bd5e487027fc10a684b8ff05dbc2949aa48270808e1f0a
3
+ metadata.gz: 5a607209836b8c47fbcff727229f7ab93940f9b1dc5a99d4ab307345ffa952a0
4
+ data.tar.gz: aae920ac21d384f0a978b7e4a07e20df5c55cc6016cd7fbce1fa5231c638b742
5
5
  SHA512:
6
- metadata.gz: 758781312e8be1e922eee338ed4ddfd3154c44ea25fb1d7e2b67d9e3ea8298381e4cc4d6df33904c35b831545d136da14c4af1630fdabe7789d3761a1617d6d9
7
- data.tar.gz: a5350e9812115ef75e39a906e6fb48aa55189692887ee037c0dc3f29cf67b00e70b912575fbe5b9d1f44d93be29c520c2a3142804671c1bcfd3bc96dcfee6b9a
6
+ metadata.gz: 46937ef32ab9ada8e3218c682fbe36a4086f7688ed5cf21ed5ad5aab575f9e8d8fe65c45220748021194500b486a538a06ddaa4d653af6762d65744c0bff51f8
7
+ data.tar.gz: 4a6d552a0fc8476105cf553b79ab1f2c231db95acc4cedec9131cc805758c1a68fd9845bc819f5396a42c297b3caf20f119a57e9cd066ab37d7f1cb7de04edb5
data/AGENTS.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # AGENTS.md — MixinBot
2
2
 
3
- Ruby gem (v2.2.0): Mixin Network REST SDK + `mixinbot` CLI. Parity targets: [bot-api-go-client](https://github.com/MixinNetwork/bot-api-go-client), [bot-api-nodejs-client](https://github.com/MixinNetwork/bot-api-nodejs-client).
3
+ Ruby gem (v2.2.1): Mixin Network REST SDK + `mixinbot` CLI. Parity targets: [bot-api-go-client](https://github.com/MixinNetwork/bot-api-go-client), [bot-api-nodejs-client](https://github.com/MixinNetwork/bot-api-nodejs-client).
4
4
 
5
5
  ## Commands
6
6
 
data/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.2.2] - 2026-05-24
11
+
12
+ ### Fixed
13
+
14
+ - **Safe transfer raw encoding** — version 5 transactions now always encode and decode the references count (including `0000` when empty), matching the Mixin kernel and official Go/TS SDKs. Fixes `/safe/transaction/requests` rejection after the v2 transaction encoder refactor.
15
+
16
+ ## [2.2.1] - 2026-05-24
17
+
18
+ ### Changed
19
+
20
+ - **Billing preflight `increment`** — `ensure_app_billing_credit!` accepts an `increment` parameter (default `0`) instead of reading `app_properties.price`. `create_user` / `create_safe_user` default to `0.5` per billed user; pass `increment: 0` for free-tier headroom.
21
+
10
22
  ## [2.2.0] - 2026-05-24
11
23
 
12
24
  ### Added
data/README.md CHANGED
@@ -6,7 +6,7 @@ Ruby SDK and CLI for [Mixin Network](https://developers.mixin.one/docs): authent
6
6
 
7
7
  The gem aims for **parity with the official [bot-api-go-client](https://github.com/MixinNetwork/bot-api-go-client)** Go SDK and **[bot-api-nodejs-client](https://github.com/MixinNetwork/bot-api-nodejs-client)** Node SDK. See [API_COVERAGE.md](API_COVERAGE.md) for the full mapping; run `rake mixin_bot:api_coverage` to confirm no gaps are marked missing.
8
8
 
9
- Current gem version: **2.2.0** (see [CHANGELOG.md](CHANGELOG.md) for breaking changes and deprecations).
9
+ Current gem version: **2.2.1** (see [CHANGELOG.md](CHANGELOG.md) for breaking changes and deprecations).
10
10
 
11
11
  ## Requirements
12
12
 
@@ -29,21 +29,22 @@ module MixinBot
29
29
  # creating a network user). Skipped when +force+ is true.
30
30
  #
31
31
  # @param force [Boolean] skip the preflight and call the API anyway
32
+ # @param increment [Numeric, String] estimated cost added to total billing
33
+ # cost for headroom (default +0+)
32
34
  # @raise [InsufficientAppBillingError] when +credit+ is not greater than
33
- # total cost plus the next user fee from {app_properties}
35
+ # total cost plus +increment+
34
36
  #
35
- def ensure_app_billing_credit!(force: false, access_token: nil)
37
+ def ensure_app_billing_credit!(force: false, access_token: nil, increment: 0)
36
38
  return if force
37
39
 
38
40
  app_id = config.app_id
39
41
  billing = app_billing(app_id, access_token:)['data']
40
- properties = app_properties(access_token:)['data']
41
42
 
42
43
  credit = billing_decimal billing['credit']
43
44
  cost_users = billing_decimal billing.dig('cost', 'users')
44
45
  cost_resources = billing_decimal billing.dig('cost', 'resources')
45
46
  cost = cost_users + cost_resources
46
- increment = billing_decimal properties['price']
47
+ increment = billing_decimal increment
47
48
 
48
49
  return if credit > cost + increment
49
50
 
@@ -23,6 +23,10 @@ module MixinBot
23
23
  # the new TIP PIN has time to propagate on the server side.
24
24
  TIP_PIN_PROPAGATION_DELAY = 1
25
25
 
26
+ # Billed cost per network user created via {#create_user} (USD), after
27
+ # the free tier. Pass +increment: 0+ to skip headroom for the new user.
28
+ CREATE_USER_BILLING_INCREMENT = '0.5'
29
+
26
30
  def user(user_id, access_token: nil)
27
31
  path = format('/users/%<user_id>s', user_id:)
28
32
  client.get path, access_token:
@@ -39,11 +43,13 @@ module MixinBot
39
43
  # @param key [String, nil] optional 32-byte Ed25519 seed
40
44
  # @param force [Boolean] when false (default), verify app billing credit
41
45
  # headroom before calling the API; when true, skip the preflight
46
+ # @param increment [Numeric, String] billing headroom for the new user
47
+ # (defaults to {CREATE_USER_BILLING_INCREMENT}; use +0+ on free tier)
42
48
  # @return [Hash] Mixin response merged with the hex-encoded private key
43
49
  # @raise [InsufficientAppBillingError] when billing credit lacks headroom
44
50
  #
45
- def create_user(full_name, key: nil, force: false)
46
- ensure_app_billing_credit!(force:)
51
+ def create_user(full_name, key: nil, force: false, increment: CREATE_USER_BILLING_INCREMENT)
52
+ ensure_app_billing_credit!(force:, increment:)
47
53
 
48
54
  keypair = JOSE::JWA::Ed25519.keypair key
49
55
  session_secret = Base64.urlsafe_encode64 keypair[0], padding: false
@@ -92,6 +98,7 @@ module MixinBot
92
98
  # @param spend_key [String, nil] optional 32-byte spend Ed25519 seed
93
99
  # @param force [Boolean] forwarded to {#create_user}; see billing preflight
94
100
  # there
101
+ # @param increment [Numeric, String] forwarded to {#create_user}
95
102
  # @return [Hash] keystore with +:app_id+, +:session_id+,
96
103
  # +:session_private_key+, +:server_public_key+ and +:spend_key+
97
104
  # @raise [MixinBot::Error] when registration ultimately fails. Transient
@@ -100,13 +107,13 @@ module MixinBot
100
107
  # @raise [InsufficientAppBillingError] when {#create_user} billing
101
108
  # preflight fails
102
109
  #
103
- def create_safe_user(name, private_key: nil, spend_key: nil, force: false)
110
+ def create_safe_user(name, private_key: nil, spend_key: nil, force: false, increment: CREATE_USER_BILLING_INCREMENT)
104
111
  session_keypair = JOSE::JWA::Ed25519.keypair private_key
105
112
  spend_keypair = JOSE::JWA::Ed25519.keypair spend_key
106
113
 
107
114
  spend_key_hex = spend_keypair[1].unpack1('H*')
108
115
 
109
- user = create_user name, key: session_keypair[1][...32], force: force
116
+ user = create_user name, key: session_keypair[1][...32], force: force, increment: increment
110
117
  data = user.fetch('data')
111
118
 
112
119
  keystore = {
@@ -26,7 +26,7 @@ module MixinBot
26
26
 
27
27
  decode_inputs
28
28
  decode_outputs
29
- decode_references if @tx.version >= Transaction::REFERENCES_TX_VERSION && @tx.references.present?
29
+ decode_references if @tx.version >= Transaction::REFERENCES_TX_VERSION
30
30
 
31
31
  extra_size = MixinBot.utils.decode_uint32 @buf.shift(4)
32
32
  @tx.extra = @buf.shift(extra_size).pack('C*')
@@ -23,7 +23,7 @@ module MixinBot
23
23
 
24
24
  bytes += encode_inputs
25
25
  bytes += encode_outputs
26
- bytes += encode_references if @tx.version >= Transaction::REFERENCES_TX_VERSION && @tx.references.present?
26
+ bytes += encode_references if @tx.version >= Transaction::REFERENCES_TX_VERSION
27
27
 
28
28
  extra_bytes = @tx.extra.bytes
29
29
  raise InvalidTransactionFormatError, 'extra is too long' if extra_bytes.size > Transaction::MAX_EXTRA_SIZE
@@ -173,9 +173,10 @@ module MixinBot
173
173
  def encode_references
174
174
  bytes = []
175
175
 
176
- bytes += MixinBot.utils.encode_uint16 @tx.references.size
176
+ references = Array(@tx.references)
177
+ bytes += MixinBot.utils.encode_uint16 references.size
177
178
 
178
- @tx.references.each do |reference|
179
+ references.each do |reference|
179
180
  bytes += [reference].pack('H*').bytes
180
181
  end
181
182
 
@@ -11,5 +11,5 @@ module MixinBot
11
11
  #
12
12
  # @see https://semver.org/
13
13
  #
14
- VERSION = '2.2.0'
14
+ VERSION = '2.2.2'
15
15
  end
data/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # MixinBot
2
2
 
3
- > Ruby SDK and CLI for Mixin Network: Safe UTXO transfers, REST API, Blaze messaging, transaction crypto, optional MVM helpers. Ruby >= 3.2. Gem version 2.2.0.
3
+ > Ruby SDK and CLI for Mixin Network: Safe UTXO transfers, REST API, Blaze messaging, transaction crypto, optional MVM helpers. Ruby >= 3.2. Gem version 2.2.1.
4
4
 
5
5
  Important notes:
6
6
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixin_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - an-lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-23 00:00:00.000000000 Z
11
+ date: 2026-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport