remitmd 0.3.0 → 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 +5 -0
- data/lib/remitmd/mock.rb +39 -10
- data/lib/remitmd/models.rb +4 -11
- data/lib/remitmd/wallet.rb +37 -19
- 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,10 @@ 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
|
+
|
|
41
45
|
def delete(path)
|
|
42
46
|
request(:delete, path, nil)
|
|
43
47
|
end
|
|
@@ -71,6 +75,7 @@ module Remitmd
|
|
|
71
75
|
req = case method
|
|
72
76
|
when :get then Net::HTTP::Get.new(full_path)
|
|
73
77
|
when :post then Net::HTTP::Post.new(full_path)
|
|
78
|
+
when :patch then Net::HTTP::Patch.new(full_path)
|
|
74
79
|
when :delete then Net::HTTP::Delete.new(full_path)
|
|
75
80
|
end
|
|
76
81
|
|
data/lib/remitmd/mock.rb
CHANGED
|
@@ -130,6 +130,10 @@ 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
|
+
|
|
133
137
|
def delete(path)
|
|
134
138
|
dispatch("DELETE", path, nil)
|
|
135
139
|
end
|
|
@@ -414,20 +418,45 @@ module Remitmd
|
|
|
414
418
|
"has_more" => false,
|
|
415
419
|
}
|
|
416
420
|
|
|
417
|
-
#
|
|
418
|
-
in ["POST", "/
|
|
419
|
-
to = fetch!(b, :to)
|
|
420
|
-
amount = decimal!(b, :amount)
|
|
421
|
+
# Deposit forfeit
|
|
422
|
+
in ["POST", path] if path.end_with?("/forfeit") && path.include?("/deposits/")
|
|
421
423
|
{
|
|
422
|
-
"id" => new_id("
|
|
423
|
-
"
|
|
424
|
-
"
|
|
425
|
-
"amount" => amount.to_s("F"),
|
|
426
|
-
"type" => b[:type] || "direct",
|
|
427
|
-
"expires_at" => now,
|
|
424
|
+
"id" => new_id("tx"),
|
|
425
|
+
"tx_hash" => "0x#{SecureRandom.hex(32)}",
|
|
426
|
+
"chain_id" => ChainId::BASE_SEPOLIA,
|
|
428
427
|
"created_at" => now,
|
|
429
428
|
}
|
|
430
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
|
+
|
|
431
460
|
else
|
|
432
461
|
{}
|
|
433
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.
|
|
@@ -548,6 +548,29 @@ module Remitmd
|
|
|
548
548
|
nil
|
|
549
549
|
end
|
|
550
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
|
+
|
|
551
574
|
# ─── Canonical name aliases ──────────────────────────────────────────────
|
|
552
575
|
|
|
553
576
|
# Canonical name for create_tab.
|
|
@@ -565,11 +588,6 @@ module Remitmd
|
|
|
565
588
|
create_bounty(amount, task_description, deadline, max_attempts: max_attempts, permit: permit)
|
|
566
589
|
end
|
|
567
590
|
|
|
568
|
-
# Alias for propose_intent.
|
|
569
|
-
def express_intent(to, amount, type: "direct")
|
|
570
|
-
propose_intent(to, amount, type: type)
|
|
571
|
-
end
|
|
572
|
-
|
|
573
591
|
# ─── One-time operator links ───────────────────────────────────────────────
|
|
574
592
|
|
|
575
593
|
# Generate a one-time URL for the operator to fund this wallet.
|
data/lib/remitmd.rb
CHANGED