remitmd 0.1.8 → 0.1.9

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: 8c2b03f3cb2f1a05e9a33845448154e4d34fda42f65af31823be2f30fb14b6fe
4
- data.tar.gz: 3d6dc094058152593779b5430899400d7b9d6543693ee3dd35dfd08b88f4c131
3
+ metadata.gz: 05f736527efb603117342dec70fc553420aa04d4dbc3ca8db5fccd8b31b7a9cb
4
+ data.tar.gz: a7f143bc6302d96cc1ca492c7f8393cdd98b039e86747fee1e7bf36a919b83d0
5
5
  SHA512:
6
- metadata.gz: deca4edd8beb6ac2d798102a83838762d746f4508bf5e852bb1b43d74aed1fa24a7b328bc4880560fc5ab60f5bd2c937277123183c3c45cc430bf02407f5c5c8
7
- data.tar.gz: c8b3bd0dc87584d00abe0b3acb37a52fa16f1f9af337780dd6aecc861f2cd542d2d684d636b28bef6b0227c13002c3c70388809d2e38a2874255bde0dd1c3932
6
+ metadata.gz: d998125805f98cf6ccbd389ec8df96655cb66a47e51b57d274c6090cdbb00a31c713f915282f166982d85dc2d3db3ce14a9c294f7ff0c00d049252590c661f10
7
+ data.tar.gz: 0dad289442caafe80bcbf83b13f38f5e7d70c7adacd0ad8b6a12172e6c27a6aae872a9b97c29537fb6ee0783eb2d3261da4eb47889f677aba12a15c10bc05ab3
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > [Skill MD](https://remit.md) · [Docs](https://remit.md/docs) · [Agent Spec](https://remit.md/agent.md)
4
4
 
5
- Universal payment protocol for AI agents Ruby client library.
5
+ Universal payment protocol for AI agents - Ruby client library.
6
6
 
7
7
  [![CI](https://github.com/remit-md/sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/remit-md/sdk/actions/workflows/ci.yml)
8
8
  [![Gem Version](https://badge.fury.io/rb/remitmd.svg)](https://badge.fury.io/rb/remitmd)
@@ -47,7 +47,7 @@ Permits are auto-signed. Every payment method fetches the on-chain USDC nonce, s
47
47
 
48
48
  ## Local Signer (Recommended)
49
49
 
50
- The local signer delegates key management to `remit signer`, a localhost HTTP server that holds your encrypted key. Your agent only needs a URL and token no private key in the environment.
50
+ The local signer delegates key management to `remit signer`, a localhost HTTP server that holds your encrypted key. Your agent only needs a URL and token - no private key in the environment.
51
51
 
52
52
  ```bash
53
53
  export REMIT_SIGNER_URL=http://127.0.0.1:7402
@@ -93,7 +93,7 @@ contracts = wallet.get_contracts
93
93
  sig = wallet.sign_tab_charge(contracts.tab, tab.id, 3_000_000, 1)
94
94
  wallet.charge_tab(tab.id, 0.003, 0.003, 1, sig)
95
95
 
96
- # Close when done unused funds return
96
+ # Close when done - unused funds return
97
97
  wallet.close_tab(tab.id)
98
98
  ```
99
99
 
@@ -156,9 +156,9 @@ end
156
156
 
157
157
  ```ruby
158
158
  mock.was_paid?(address, amount) # true/false
159
- mock.total_paid_to(address) # BigDecimal sum of all payments to address
159
+ mock.total_paid_to(address) # BigDecimal - sum of all payments to address
160
160
  mock.transaction_count # Integer
161
- mock.balance # BigDecimal current balance
161
+ mock.balance # BigDecimal - current balance
162
162
  mock.transactions # Array<Transaction>
163
163
  mock.set_balance(amount) # Override starting balance
164
164
  mock.reset # Clear all state
@@ -274,11 +274,11 @@ Remitmd::RemitWallet.new(private_key: key, chain: "base_sepolia") # Base Sepoli
274
274
  Permits are auto-signed by default. If you need manual control (custom deadline, pre-signed permits, or offline signing), pass a `PermitSignature` explicitly:
275
275
 
276
276
  ```ruby
277
- # sign_permit: convenience auto-fetches nonce, converts amount to base units
277
+ # sign_permit: convenience - auto-fetches nonce, converts amount to base units
278
278
  permit = wallet.sign_permit("0xRouterAddress...", 5.00, deadline: Time.now.to_i + 7200)
279
279
  tx = wallet.pay("0xRecipient...", 5.00, permit: permit)
280
280
 
281
- # sign_usdc_permit: full control raw base units, explicit nonce
281
+ # sign_usdc_permit: full control - raw base units, explicit nonce
282
282
  permit = wallet.sign_usdc_permit(
283
283
  "0xRouterAddress...", # spender
284
284
  5_000_000, # value in base units (6 decimals)
@@ -291,6 +291,6 @@ tx = wallet.pay("0xRecipient...", 5.00, permit: permit)
291
291
 
292
292
  ## License
293
293
 
294
- MIT see [LICENSE](LICENSE)
294
+ MIT - see [LICENSE](LICENSE)
295
295
 
296
296
  [Documentation](https://remit.md/docs) · [Protocol Spec](https://remit.md) · [GitHub](https://github.com/remit-md/sdk)
data/lib/remitmd/a2a.rb CHANGED
@@ -135,7 +135,7 @@ module Remitmd
135
135
 
136
136
  # ─── A2A JSON-RPC client ────────────────────────────────────────────────────
137
137
 
138
- # A2A JSON-RPC client send payments and manage tasks via the A2A protocol.
138
+ # A2A JSON-RPC client - send payments and manage tasks via the A2A protocol.
139
139
  #
140
140
  # @example
141
141
  # card = Remitmd::AgentCard.discover("https://remit.md")
@@ -15,7 +15,7 @@ module Remitmd
15
15
  # puts e.doc_url # => "https://remit.md/docs/api-reference/error-codes#invalid_address"
16
16
  # end
17
17
  class RemitError < StandardError
18
- # Error code constants matches TS SDK (28 codes)
18
+ # Error code constants - matches TS SDK (28 codes)
19
19
  # Auth errors
20
20
  INVALID_SIGNATURE = "INVALID_SIGNATURE"
21
21
  NONCE_REUSED = "NONCE_REUSED"
@@ -80,7 +80,7 @@ module Remitmd
80
80
  @code = code
81
81
  @doc_url = "https://remit.md/docs/api-reference/error-codes##{code.downcase}"
82
82
  @context = context
83
- super("[#{code}] #{message} #{@doc_url}")
83
+ super("[#{code}] #{message} - #{@doc_url}")
84
84
  end
85
85
  end
86
86
  end
data/lib/remitmd/http.rb CHANGED
@@ -74,7 +74,7 @@ module Remitmd
74
74
  nonce_hex = "0x#{nonce_bytes.unpack1("H*")}"
75
75
  timestamp = Time.now.to_i
76
76
 
77
- # Strip query string before signing only the path is included in EIP-712.
77
+ # Strip query string before signing - only the path is included in EIP-712.
78
78
  sign_path = full_path.split("?").first
79
79
  http_method = method.to_s.upcase
80
80
  digest = eip712_hash(http_method, sign_path, timestamp, nonce_bytes)
@@ -100,7 +100,7 @@ module Remitmd
100
100
  # Domain: name="remit.md", version="0.1", chainId, verifyingContract
101
101
  # Struct: APIRequest(string method, string path, uint256 timestamp, bytes32 nonce)
102
102
  def eip712_hash(method, path, timestamp, nonce_bytes)
103
- # Type hashes (string constants keccak256 of the type string)
103
+ # Type hashes (string constants - keccak256 of the type string)
104
104
  domain_type_hash = keccak256_bytes(
105
105
  "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
106
106
  )
@@ -162,7 +162,7 @@ module Remitmd
162
162
  raise RemitError.new(code, err["message"] || "Bad request", context: parsed)
163
163
  when 401
164
164
  raise RemitError.new(RemitError::UNAUTHORIZED,
165
- "Authentication failed check your private key and chain ID")
165
+ "Authentication failed - check your private key and chain ID")
166
166
  when 429
167
167
  raise RemitError.new(RemitError::RATE_LIMITED,
168
168
  "Rate limit exceeded. See https://remit.md/docs/api-reference/rate-limits")
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Remitmd
4
- # Pure-Ruby Keccak-256 (Ethereum variant NOT SHA-3).
4
+ # Pure-Ruby Keccak-256 (Ethereum variant - NOT SHA-3).
5
5
  #
6
6
  # SHA-3 uses different padding (0x06 instead of 0x01).
7
7
  # This implementation matches Ethereum's keccak256.
data/lib/remitmd/mock.rb CHANGED
@@ -175,7 +175,7 @@ module Remitmd
175
175
  @state[:pending_invoices][id] = b
176
176
  { "id" => id, "status" => "pending" }
177
177
 
178
- # Escrow create (step 2 fund with invoice_id)
178
+ # Escrow create (step 2 - fund with invoice_id)
179
179
  in ["POST", "/escrows"]
180
180
  invoice_id = fetch!(b, :invoice_id)
181
181
  inv = @state[:pending_invoices].delete(invoice_id)
@@ -4,12 +4,12 @@ require "openssl"
4
4
  require "securerandom"
5
5
 
6
6
  module Remitmd
7
- # secp256k1 field prime p (constant never changes)
7
+ # secp256k1 field prime p (constant - never changes)
8
8
  SECP256K1_P = OpenSSL::BN.new(
9
9
  "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F", 16
10
10
  ).freeze
11
11
 
12
- # Precomputed (p + 1) / 4 the modular square root exponent for p ≡ 3 (mod 4).
12
+ # Precomputed (p + 1) / 4 - the modular square root exponent for p ≡ 3 (mod 4).
13
13
  # Avoids BN division at runtime (which returns Integer on some OpenSSL versions).
14
14
  SECP256K1_SQRT_EXP = OpenSSL::BN.new(
15
15
  "3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFFFFF0C", 16
@@ -66,7 +66,7 @@ module Remitmd
66
66
  group = @key.group
67
67
  n = group.order
68
68
 
69
- # ECDSA sign dsa_sign_asn1 uses the input directly as the hash (no pre-hashing)
69
+ # ECDSA sign - dsa_sign_asn1 uses the input directly as the hash (no pre-hashing)
70
70
  der = @key.dsa_sign_asn1(digest_bytes)
71
71
  asn1 = OpenSSL::ASN1.decode(der)
72
72
  bn_r = asn1.value[0].value
@@ -104,7 +104,7 @@ module Remitmd
104
104
  break
105
105
  end
106
106
  end
107
- raise "Could not determine recovery ID key or hash may be invalid" if v.nil?
107
+ raise "Could not determine recovery ID - key or hash may be invalid" if v.nil?
108
108
 
109
109
  # Build 65-byte Ethereum signature: r (32) || s (32) || v (1)
110
110
  r_bytes = [bn_r.to_s(16).rjust(64, "0")].pack("H*")
@@ -129,13 +129,13 @@ module Remitmd
129
129
  def recover_r_point(group, bn_r, parity)
130
130
  p = SECP256K1_P
131
131
  x = bn_r
132
- # y² = x³ + 7 (mod p) secp256k1 curve equation
132
+ # y² = x³ + 7 (mod p) - secp256k1 curve equation
133
133
  x3 = x.mod_exp(OpenSSL::BN.new("3"), p)
134
134
  rhs = x3 + OpenSSL::BN.new("7")
135
135
  y_squared = rhs % p
136
136
  # Tonelli–Shanks: since p ≡ 3 mod 4, sqrt = y²^((p+1)/4) mod p
137
137
  y = y_squared.mod_exp(SECP256K1_SQRT_EXP, p)
138
- # Verify that y² ≡ y_squared (mod p) i.e., a square root exists
138
+ # Verify that y² ≡ y_squared (mod p) - i.e., a square root exists
139
139
  return nil unless y.mod_mul(y, p) == y_squared
140
140
 
141
141
  y = p - y if (y.to_i & 1) != parity
@@ -148,7 +148,7 @@ module Remitmd
148
148
  end
149
149
 
150
150
  def derive_address(public_key)
151
- # Uncompressed public key: 04 || x (32) || y (32) skip the 0x04 prefix
151
+ # Uncompressed public key: 04 || x (32) || y (32) - skip the 0x04 prefix
152
152
  pub_bytes = [public_key.to_octet_string(:uncompressed).unpack1("H*")[2..]].pack("H*")
153
153
  keccak = keccak256_hex(pub_bytes)
154
154
  "0x#{keccak[-40..]}"
@@ -28,7 +28,7 @@ module Remitmd
28
28
 
29
29
  # @param private_key [String, nil] 0x-prefixed hex private key
30
30
  # @param signer [Signer, nil] custom signer (pass instead of private_key)
31
- # @param chain [String] chain name "base", "base_sepolia"
31
+ # @param chain [String] chain name - "base", "base_sepolia"
32
32
  # @param api_url [String, nil] override API base URL
33
33
  # @param transport [Object, nil] inject mock transport (used by MockRemit)
34
34
  def initialize(private_key: nil, signer: nil, chain: "base", api_url: nil, router_address: nil, transport: nil)
@@ -157,7 +157,7 @@ module Remitmd
157
157
  # @param to [String] recipient 0x-prefixed address
158
158
  # @param amount [Numeric, BigDecimal] amount in USDC (e.g. 1.50)
159
159
  # @param memo [String, nil] optional note
160
- # @param permit [PermitSignature, nil] EIP-2612 permit auto-signed if nil
160
+ # @param permit [PermitSignature, nil] EIP-2612 permit - auto-signed if nil
161
161
  # @return [Transaction]
162
162
  def pay(to, amount, memo: nil, permit: nil)
163
163
  validate_address!(to)
@@ -176,7 +176,7 @@ module Remitmd
176
176
  # @param amount [Numeric] amount in USDC
177
177
  # @param memo [String, nil] optional note
178
178
  # @param expires_in_secs [Integer, nil] optional expiry in seconds from now
179
- # @param permit [PermitSignature, nil] EIP-2612 permit auto-signed if nil
179
+ # @param permit [PermitSignature, nil] EIP-2612 permit - auto-signed if nil
180
180
  # @return [Escrow]
181
181
  def create_escrow(payee, amount, memo: nil, expires_in_secs: nil, permit: nil)
182
182
  validate_address!(payee)
@@ -237,7 +237,7 @@ module Remitmd
237
237
  # @param limit_amount [Numeric] maximum tab credit in USDC
238
238
  # @param per_unit [Numeric] USDC per API call
239
239
  # @param expires_in_secs [Integer] optional expiry duration in seconds (default: 86400)
240
- # @param permit [PermitSignature, nil] EIP-2612 permit auto-signed if nil
240
+ # @param permit [PermitSignature, nil] EIP-2612 permit - auto-signed if nil
241
241
  # @return [Tab]
242
242
  def create_tab(provider, limit_amount, per_unit = 0.0, expires_in_secs: 86_400, permit: nil)
243
243
  validate_address!(provider)
@@ -430,7 +430,7 @@ module Remitmd
430
430
  # @param payee [String] 0x-prefixed address of the stream recipient
431
431
  # @param rate_per_second [Numeric] USDC per second
432
432
  # @param max_total [Numeric] maximum total USDC for the stream
433
- # @param permit [PermitSignature, nil] EIP-2612 permit auto-signed if nil
433
+ # @param permit [PermitSignature, nil] EIP-2612 permit - auto-signed if nil
434
434
  # @return [Stream]
435
435
  def create_stream(payee, rate_per_second, max_total, permit: nil)
436
436
  validate_address!(payee)
@@ -468,7 +468,7 @@ module Remitmd
468
468
  # @param task_description [String] task description
469
469
  # @param deadline [Integer] deadline as Unix timestamp
470
470
  # @param max_attempts [Integer] maximum submission attempts (default: 10)
471
- # @param permit [PermitSignature, nil] EIP-2612 permit auto-signed if nil
471
+ # @param permit [PermitSignature, nil] EIP-2612 permit - auto-signed if nil
472
472
  # @return [Bounty]
473
473
  def create_bounty(amount, task_description, deadline, max_attempts: 10, permit: nil)
474
474
  validate_amount!(amount)
@@ -522,7 +522,7 @@ module Remitmd
522
522
  # @param provider [String] 0x-prefixed provider address
523
523
  # @param amount [Numeric] amount in USDC
524
524
  # @param expires_in_secs [Integer] expiry duration in seconds (default: 3600)
525
- # @param permit [PermitSignature, nil] EIP-2612 permit auto-signed if nil
525
+ # @param permit [PermitSignature, nil] EIP-2612 permit - auto-signed if nil
526
526
  # @return [Deposit]
527
527
  def place_deposit(provider, amount, expires_in_secs: 3600, permit: nil)
528
528
  validate_address!(provider)
@@ -556,7 +556,7 @@ module Remitmd
556
556
  # Propose a payment intent for counterpart approval before execution.
557
557
  # @param to [String] 0x-prefixed address
558
558
  # @param amount [Numeric] amount in USDC
559
- # @param type [String] payment type "direct", "escrow", "tab"
559
+ # @param type [String] payment type - "direct", "escrow", "tab"
560
560
  # @return [Intent]
561
561
  def propose_intent(to, amount, type: "direct")
562
562
  validate_address!(to)
@@ -583,7 +583,7 @@ module Remitmd
583
583
  # Generate a one-time URL for the operator to fund this wallet.
584
584
  # @param messages [Array<Hash>, nil] chat-style messages (each with :role and :text)
585
585
  # @param agent_name [String, nil] agent display name shown on the funding page
586
- # @param permit [PermitSignature, nil] EIP-2612 permit auto-signed if nil
586
+ # @param permit [PermitSignature, nil] EIP-2612 permit - auto-signed if nil
587
587
  # @return [LinkResponse]
588
588
  def create_fund_link(messages: nil, agent_name: nil, permit: nil)
589
589
  body = {}
@@ -601,7 +601,7 @@ module Remitmd
601
601
  # Generate a one-time URL for the operator to withdraw funds.
602
602
  # @param messages [Array<Hash>, nil] chat-style messages (each with :role and :text)
603
603
  # @param agent_name [String, nil] agent display name shown on the withdraw page
604
- # @param permit [PermitSignature, nil] EIP-2612 permit auto-signed if nil
604
+ # @param permit [PermitSignature, nil] EIP-2612 permit - auto-signed if nil
605
605
  # @return [LinkResponse]
606
606
  def create_withdraw_link(messages: nil, agent_name: nil, permit: nil)
607
607
  body = {}
@@ -710,7 +710,7 @@ module Remitmd
710
710
 
711
711
  # Auto-sign a permit for the given contract type and amount.
712
712
  # Returns nil on failure instead of raising, so callers can proceed without a permit.
713
- # @param contract [String] contract key "router", "escrow", "tab", etc.
713
+ # @param contract [String] contract key - "router", "escrow", "tab", etc.
714
714
  # @param amount [Numeric] amount in USDC
715
715
  # @return [PermitSignature, nil]
716
716
  def auto_permit(contract, amount)
@@ -21,7 +21,7 @@ module Remitmd
21
21
  end
22
22
  end
23
23
 
24
- # x402 client fetch wrapper that auto-pays HTTP 402 Payment Required responses.
24
+ # x402 client - fetch wrapper that auto-pays HTTP 402 Payment Required responses.
25
25
  #
26
26
  # On receiving a 402, the client:
27
27
  # 1. Decodes the PAYMENT-REQUIRED header (base64 JSON)
@@ -6,7 +6,7 @@ require "json"
6
6
  require "base64"
7
7
 
8
8
  module Remitmd
9
- # x402 paywall for service providers gate HTTP endpoints behind payments.
9
+ # x402 paywall for service providers - gate HTTP endpoints behind payments.
10
10
  #
11
11
  # Providers use this class to:
12
12
  # - Return HTTP 402 responses with properly formatted PAYMENT-REQUIRED headers
@@ -29,9 +29,9 @@ module Remitmd
29
29
  # @param facilitator_url [String] base URL of the remit.md facilitator
30
30
  # @param facilitator_token [String] bearer JWT for authenticating calls to /api/v1/x402/verify
31
31
  # @param max_timeout_seconds [Integer] how long the payment authorization remains valid
32
- # @param resource [String, nil] V2 URL or path of the resource being protected
33
- # @param description [String, nil] V2 human-readable description
34
- # @param mime_type [String, nil] V2 MIME type of the resource
32
+ # @param resource [String, nil] V2 - URL or path of the resource being protected
33
+ # @param description [String, nil] V2 - human-readable description
34
+ # @param mime_type [String, nil] V2 - MIME type of the resource
35
35
  def initialize( # rubocop:disable Metrics/ParameterLists
36
36
  wallet_address:,
37
37
  amount_usdc:,
data/lib/remitmd.rb CHANGED
@@ -12,7 +12,7 @@ require_relative "remitmd/a2a"
12
12
  require_relative "remitmd/x402_client"
13
13
  require_relative "remitmd/x402_paywall"
14
14
 
15
- # remit.md Ruby SDK universal payment protocol for AI agents.
15
+ # remit.md Ruby SDK - universal payment protocol for AI agents.
16
16
  #
17
17
  # @example Direct payment
18
18
  # wallet = Remitmd::RemitWallet.new(private_key: ENV["REMITMD_PRIVATE_KEY"])
@@ -26,5 +26,5 @@ require_relative "remitmd/x402_paywall"
26
26
  # mock.was_paid?("0x0000000000000000000000000000000000000001", 1.00) # => true
27
27
  #
28
28
  module Remitmd
29
- VERSION = "0.1.8"
29
+ VERSION = "0.1.9"
30
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remitmd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - remit.md