remitmd 0.2.5 → 0.4.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/lib/remitmd/http.rb +12 -2
- data/lib/remitmd/mock.rb +43 -10
- data/lib/remitmd/models.rb +4 -11
- data/lib/remitmd/wallet.rb +65 -14
- data/lib/remitmd.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8ea560fba297ec6f5d69e5f9a0aedd35c832d075f95ffa899dea1dd73455b92
|
|
4
|
+
data.tar.gz: cb0a69a1c200337866fb204ffd8419a805c815d0d6980770fde356cca3c234b7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a1bd3b20c90b07ad619d8d429afab47a906102b77d29d15620eedee158bb55f7f02512072f096ce9c55412f14695901a590122f3c9e043eab957303dfaf98d49
|
|
7
|
+
data.tar.gz: 76fcf0164b8b325bd6f1509caad8fa0fac0eae613723f0c8e8839c69d2d78ea6fb87859680f7d88126b7f49a95ee20fb3305721513e034498032c4ccef9bd223
|
data/lib/remitmd/http.rb
CHANGED
|
@@ -38,6 +38,14 @@ module Remitmd
|
|
|
38
38
|
request(:post, path, body)
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
+
def patch(path, body = nil)
|
|
42
|
+
request(:patch, path, body)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def delete(path)
|
|
46
|
+
request(:delete, path, nil)
|
|
47
|
+
end
|
|
48
|
+
|
|
41
49
|
private
|
|
42
50
|
|
|
43
51
|
def request(method, path, body)
|
|
@@ -65,8 +73,10 @@ module Remitmd
|
|
|
65
73
|
def build_request(method, path, body, idempotency_key = nil)
|
|
66
74
|
full_path = "#{@uri.path}#{path}"
|
|
67
75
|
req = case method
|
|
68
|
-
when :get
|
|
69
|
-
when :post
|
|
76
|
+
when :get then Net::HTTP::Get.new(full_path)
|
|
77
|
+
when :post then Net::HTTP::Post.new(full_path)
|
|
78
|
+
when :patch then Net::HTTP::Patch.new(full_path)
|
|
79
|
+
when :delete then Net::HTTP::Delete.new(full_path)
|
|
70
80
|
end
|
|
71
81
|
|
|
72
82
|
# Generate 32-byte random nonce and Unix timestamp.
|
data/lib/remitmd/mock.rb
CHANGED
|
@@ -130,6 +130,14 @@ module Remitmd
|
|
|
130
130
|
dispatch("POST", path, body)
|
|
131
131
|
end
|
|
132
132
|
|
|
133
|
+
def patch(path, body = nil)
|
|
134
|
+
dispatch("PATCH", path, body)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def delete(path)
|
|
138
|
+
dispatch("DELETE", path, nil)
|
|
139
|
+
end
|
|
140
|
+
|
|
133
141
|
private
|
|
134
142
|
|
|
135
143
|
def dispatch(method, path, body)
|
|
@@ -410,20 +418,45 @@ module Remitmd
|
|
|
410
418
|
"has_more" => false,
|
|
411
419
|
}
|
|
412
420
|
|
|
413
|
-
#
|
|
414
|
-
in ["POST", "/
|
|
415
|
-
to = fetch!(b, :to)
|
|
416
|
-
amount = decimal!(b, :amount)
|
|
421
|
+
# Deposit forfeit
|
|
422
|
+
in ["POST", path] if path.end_with?("/forfeit") && path.include?("/deposits/")
|
|
417
423
|
{
|
|
418
|
-
"id" => new_id("
|
|
419
|
-
"
|
|
420
|
-
"
|
|
421
|
-
"amount" => amount.to_s("F"),
|
|
422
|
-
"type" => b[:type] || "direct",
|
|
423
|
-
"expires_at" => now,
|
|
424
|
+
"id" => new_id("tx"),
|
|
425
|
+
"tx_hash" => "0x#{SecureRandom.hex(32)}",
|
|
426
|
+
"chain_id" => ChainId::BASE_SEPOLIA,
|
|
424
427
|
"created_at" => now,
|
|
425
428
|
}
|
|
426
429
|
|
|
430
|
+
# Bounty reclaim
|
|
431
|
+
in ["POST", path] if path.end_with?("/reclaim") && path.include?("/bounties/")
|
|
432
|
+
{
|
|
433
|
+
"id" => new_id("tx"),
|
|
434
|
+
"tx_hash" => "0x#{SecureRandom.hex(32)}",
|
|
435
|
+
"chain_id" => ChainId::BASE_SEPOLIA,
|
|
436
|
+
"created_at" => now,
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
# Webhook update
|
|
440
|
+
in ["PATCH", path] if path.start_with?("/webhooks/")
|
|
441
|
+
webhook_id = path.split("/").last
|
|
442
|
+
{
|
|
443
|
+
"id" => webhook_id,
|
|
444
|
+
"wallet" => MockRemit::MOCK_ADDRESS,
|
|
445
|
+
"url" => b[:url] || "https://example.com/hook",
|
|
446
|
+
"events" => b[:events] || [],
|
|
447
|
+
"chains" => ["base-sepolia"],
|
|
448
|
+
"active" => b.key?(:active) ? b[:active] : true,
|
|
449
|
+
"created_at" => now,
|
|
450
|
+
"updated_at" => now,
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
# Wallet settings update
|
|
454
|
+
in ["PATCH", "/wallet/settings"]
|
|
455
|
+
{
|
|
456
|
+
"wallet" => MockRemit::MOCK_ADDRESS,
|
|
457
|
+
"display_name" => b[:display_name],
|
|
458
|
+
}
|
|
459
|
+
|
|
427
460
|
else
|
|
428
461
|
{}
|
|
429
462
|
end
|
data/lib/remitmd/models.rb
CHANGED
|
@@ -349,21 +349,14 @@ module Remitmd
|
|
|
349
349
|
private :decimal, :parse_time
|
|
350
350
|
end
|
|
351
351
|
|
|
352
|
-
class
|
|
352
|
+
class WalletSettings < Model
|
|
353
353
|
def initialize(attrs)
|
|
354
354
|
h = attrs.transform_keys(&:to_s)
|
|
355
|
-
@
|
|
356
|
-
@
|
|
357
|
-
@to = h["to"]
|
|
358
|
-
@amount = decimal(h["amount"])
|
|
359
|
-
@type = h["type"]
|
|
360
|
-
@expires_at = parse_time(h["expires_at"])
|
|
361
|
-
@created_at = parse_time(h["created_at"])
|
|
355
|
+
@wallet = h["wallet"]
|
|
356
|
+
@display_name = h["display_name"]
|
|
362
357
|
end
|
|
363
358
|
|
|
364
|
-
attr_reader :
|
|
365
|
-
|
|
366
|
-
private :decimal, :parse_time
|
|
359
|
+
attr_reader :wallet, :display_name
|
|
367
360
|
end
|
|
368
361
|
|
|
369
362
|
class Budget < Model
|
data/lib/remitmd/wallet.rb
CHANGED
|
@@ -459,6 +459,13 @@ module Remitmd
|
|
|
459
459
|
Bounty.new(@transport.post("/bounties/#{bounty_id}/award", { submission_id: submission_id }))
|
|
460
460
|
end
|
|
461
461
|
|
|
462
|
+
# Reclaim an expired or cancelled bounty (called by the poster).
|
|
463
|
+
# @param bounty_id [String]
|
|
464
|
+
# @return [Transaction]
|
|
465
|
+
def reclaim_bounty(bounty_id)
|
|
466
|
+
Transaction.new(@transport.post("/bounties/#{bounty_id}/reclaim", {}))
|
|
467
|
+
end
|
|
468
|
+
|
|
462
469
|
# List bounties with optional filters.
|
|
463
470
|
# @param status [String, nil] filter by status (open, claimed, awarded, expired)
|
|
464
471
|
# @param poster [String, nil] filter by poster wallet address
|
|
@@ -504,26 +511,19 @@ module Remitmd
|
|
|
504
511
|
Transaction.new(@transport.post("/deposits/#{deposit_id}/return", {}))
|
|
505
512
|
end
|
|
506
513
|
|
|
514
|
+
# Forfeit a deposit (called by the depositor to surrender their deposit).
|
|
515
|
+
# @param deposit_id [String]
|
|
516
|
+
# @return [Transaction]
|
|
517
|
+
def forfeit_deposit(deposit_id)
|
|
518
|
+
Transaction.new(@transport.post("/deposits/#{deposit_id}/forfeit", {}))
|
|
519
|
+
end
|
|
520
|
+
|
|
507
521
|
# Lock a security deposit.
|
|
508
522
|
# @deprecated Use {#place_deposit} instead
|
|
509
523
|
def lock_deposit(provider, amount, expires_in_secs, permit: nil)
|
|
510
524
|
place_deposit(provider, amount, expires_in_secs: expires_in_secs, permit: permit)
|
|
511
525
|
end
|
|
512
526
|
|
|
513
|
-
# ─── Payment Intents ─────────────────────────────────────────────────────
|
|
514
|
-
|
|
515
|
-
# Propose a payment intent for counterpart approval before execution.
|
|
516
|
-
# @param to [String] 0x-prefixed address
|
|
517
|
-
# @param amount [Numeric] amount in USDC
|
|
518
|
-
# @param type [String] payment type - "direct", "escrow", "tab"
|
|
519
|
-
# @return [Intent]
|
|
520
|
-
def propose_intent(to, amount, type: "direct")
|
|
521
|
-
validate_address!(to)
|
|
522
|
-
validate_amount!(amount)
|
|
523
|
-
body = { to: to, amount: amount.to_s, type: type }
|
|
524
|
-
Intent.new(@transport.post("/intents", body))
|
|
525
|
-
end
|
|
526
|
-
|
|
527
527
|
# ─── Webhooks ─────────────────────────────────────────────────────────────
|
|
528
528
|
|
|
529
529
|
# Register a webhook endpoint to receive event notifications.
|
|
@@ -537,6 +537,57 @@ module Remitmd
|
|
|
537
537
|
Webhook.new(@transport.post("/webhooks", body))
|
|
538
538
|
end
|
|
539
539
|
|
|
540
|
+
# List all registered webhooks for this wallet.
|
|
541
|
+
def list_webhooks
|
|
542
|
+
@transport.get("/webhooks").map { |w| Webhook.new(w) }
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
# Delete a webhook by ID.
|
|
546
|
+
def delete_webhook(webhook_id)
|
|
547
|
+
@transport.delete("/webhooks/#{webhook_id}")
|
|
548
|
+
nil
|
|
549
|
+
end
|
|
550
|
+
|
|
551
|
+
# Update an existing webhook's URL, events, or active status.
|
|
552
|
+
# @param webhook_id [String]
|
|
553
|
+
# @param url [String, nil] new URL
|
|
554
|
+
# @param events [Array<String>, nil] new event types
|
|
555
|
+
# @param active [Boolean, nil] new active status
|
|
556
|
+
# @return [Webhook]
|
|
557
|
+
def update_webhook(webhook_id, url: nil, events: nil, active: nil)
|
|
558
|
+
body = {}
|
|
559
|
+
body[:url] = url unless url.nil?
|
|
560
|
+
body[:events] = events unless events.nil?
|
|
561
|
+
body[:active] = active unless active.nil?
|
|
562
|
+
Webhook.new(@transport.patch("/webhooks/#{webhook_id}", body))
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
# Update wallet display settings.
|
|
566
|
+
# @param display_name [String, nil] new display name
|
|
567
|
+
# @return [WalletSettings]
|
|
568
|
+
def update_wallet_settings(display_name: nil)
|
|
569
|
+
body = {}
|
|
570
|
+
body[:display_name] = display_name unless display_name.nil?
|
|
571
|
+
WalletSettings.new(@transport.patch("/wallet/settings", body))
|
|
572
|
+
end
|
|
573
|
+
|
|
574
|
+
# ─── Canonical name aliases ──────────────────────────────────────────────
|
|
575
|
+
|
|
576
|
+
# Canonical name for create_tab.
|
|
577
|
+
def open_tab(provider, limit_amount, per_unit = 0.0, expires_in_secs: 86_400, permit: nil)
|
|
578
|
+
create_tab(provider, limit_amount, per_unit, expires_in_secs: expires_in_secs, permit: permit)
|
|
579
|
+
end
|
|
580
|
+
|
|
581
|
+
# Canonical name for create_stream.
|
|
582
|
+
def open_stream(payee, rate_per_second, max_total, permit: nil)
|
|
583
|
+
create_stream(payee, rate_per_second, max_total, permit: permit)
|
|
584
|
+
end
|
|
585
|
+
|
|
586
|
+
# Canonical name for create_bounty.
|
|
587
|
+
def post_bounty(amount, task_description, deadline, max_attempts: 10, permit: nil)
|
|
588
|
+
create_bounty(amount, task_description, deadline, max_attempts: max_attempts, permit: permit)
|
|
589
|
+
end
|
|
590
|
+
|
|
540
591
|
# ─── One-time operator links ───────────────────────────────────────────────
|
|
541
592
|
|
|
542
593
|
# Generate a one-time URL for the operator to fund this wallet.
|
data/lib/remitmd.rb
CHANGED