bsv-wallet-postgres 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 37e390c1a01dfcca455d47cd9f7f9f50d7ccaa7dc8ebed8b6cde03c7037efaac
4
- data.tar.gz: cbb545f0833e6f43dde28ed1fb8677de53874f06fea8798052da8cdfb4172868
3
+ metadata.gz: 8c61ec2b4c48854fcba55eeb47bb1d7b3e87129fbf01769e07fc6c30661d1a26
4
+ data.tar.gz: 58f953f0a5d5fb10fb20259d821dc604ba842f8210f53d6f55be12e760ed927c
5
5
  SHA512:
6
- metadata.gz: 9861cc380e77b9d726ab69ce61d9c2401962540ed1617512d615197e123bf1c451b30d4028a9c781abe27c89eee41243b72473410ac613d3dfbac6f129255a5f
7
- data.tar.gz: 9d05a5dac568c660f86963e90d7b2deb0852126b63678395574154f819241e791413ccba139eaaea67ee8009175ba71095d1a58b64dd82332ddfa6b6b0699c9e
6
+ metadata.gz: 5b51ceb9562b914012b2a86ee1c236501f9f714583a55d46a977e6418f0cf490497d7a42349210a0e0ee1436179617d45ded1afca815f0770d563aad8bf4051a
7
+ data.tar.gz: 6f219ead476cf621c654e9692f955962f96f55d02b900bb03f2adfe1549b331abd714036e4af7ef32f1c322e72c452a64ebebdcda46cedc9fc239e601cc0bf5f
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ All notable changes to the `bsv-wallet-postgres` gem are documented here.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
6
6
  and this gem adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 0.6.0 — 2026-04-21
9
+
10
+ ### Added
11
+ - `update_output_basket` implementation on `PostgresStore`, matching the new Store interface method
12
+
13
+ ### Changed
14
+ - Updated for bsv-wallet 0.10.0 namespace changes (`Interface`, `Client`, `Store`)
15
+
8
16
  ## 0.5.0 — 2026-04-16
9
17
 
10
18
  ### Changed — **Breaking**
@@ -2,7 +2,7 @@
2
2
 
3
3
  # Initial wallet schema for BSV::Wallet::PostgresStore.
4
4
  #
5
- # Five tables, all indexed for the query patterns the StorageAdapter
5
+ # Five tables, all indexed for the query patterns the Store
6
6
  # interface exposes. JSONB blobs hold the full hash the SDK stored so
7
7
  # adding fields to bsv-wallet's output/action/certificate records does
8
8
  # not require a schema change — only the fields we actively filter on
@@ -8,7 +8,7 @@ module BSV
8
8
  module Wallet
9
9
  # PostgreSQL-backed storage adapter for +BSV::Wallet+.
10
10
  #
11
- # Implements the full {StorageAdapter} interface against a Sequel
11
+ # Implements the full {Store} interface against a Sequel
12
12
  # +Database+ object. Survives process restarts, scales to multiple
13
13
  # instances, and is thread-safe via Sequel's connection pool.
14
14
  #
@@ -19,7 +19,7 @@ module BSV
19
19
  # BSV::Wallet::PostgresStore.migrate!(db)
20
20
  #
21
21
  # store = BSV::Wallet::PostgresStore.new(db)
22
- # wallet = BSV::Wallet::WalletClient.new(key, storage: store)
22
+ # wallet = BSV::Wallet::Client.new(key, storage: store)
23
23
  #
24
24
  # @example Bringing your own migration runner
25
25
  # # Copy lib/bsv/wallet_postgres/migrations/001_create_wallet_tables.rb
@@ -44,7 +44,7 @@ module BSV
44
44
  # * This class is thread-safe because Sequel is — the adapter itself
45
45
  # holds no mutable state beyond the injected database handle.
46
46
  class PostgresStore
47
- include StorageAdapter
47
+ include Interface::Store
48
48
 
49
49
  MIGRATIONS_DIR = File.expand_path('migrations', __dir__)
50
50
 
@@ -236,6 +236,26 @@ module BSV
236
236
  symbolise_keys(row[:data])
237
237
  end
238
238
 
239
+ # Moves an output from one basket to another (metadata-only).
240
+ #
241
+ # Updates both the +basket+ column and the JSONB +data+ blob.
242
+ # Does not affect the output's state or pending metadata.
243
+ #
244
+ # @param outpoint [String] the outpoint identifier
245
+ # @param new_basket [String] the destination basket name
246
+ # @raise [BSV::Wallet::WalletError] if the outpoint is not found
247
+ # @return [Hash] the updated output hash
248
+ def update_output_basket(outpoint, new_basket)
249
+ ds = @db[:wallet_outputs].where(outpoint: outpoint)
250
+ rows_updated = ds.update(
251
+ basket: new_basket,
252
+ data: Sequel.lit("data || jsonb_build_object('basket', ?)", new_basket)
253
+ )
254
+ raise WalletError, "Output not found: #{outpoint}" if rows_updated.zero?
255
+
256
+ symbolise_keys(ds.first[:data])
257
+ end
258
+
239
259
  # Atomically marks a set of outpoints as +:pending+.
240
260
  #
241
261
  # Uses +UPDATE ... WHERE state = 'spendable' ... RETURNING outpoint+ so that
@@ -38,7 +38,7 @@ module BSV
38
38
  # +@running = false+ but before the worker thread exits will remain
39
39
  # +unsent+ until the next +start+.
40
40
  class SolidQueueAdapter
41
- include BSV::Wallet::BroadcastQueue
41
+ include BSV::Wallet::Interface::BroadcastQueue
42
42
 
43
43
  # Default number of seconds between poll cycles.
44
44
  DEFAULT_POLL_INTERVAL = 8
@@ -52,14 +52,14 @@ module BSV
52
52
  MAX_ATTEMPTS = 5
53
53
 
54
54
  # @param db [Sequel::Database] a Sequel database handle (shared with PostgresStore)
55
- # @param storage [StorageAdapter] wallet storage adapter (must not be MemoryStore)
55
+ # @param storage [Store] wallet storage adapter (must not be MemoryStore)
56
56
  # @param broadcaster [#broadcast] broadcaster object
57
57
  # @param poll_interval [Integer] seconds between worker poll cycles
58
58
  # @param stale_threshold [Integer] seconds before a +sending+ job is retried
59
- # @raise [ArgumentError] if +storage+ is a +BSV::Wallet::MemoryStore+
59
+ # @raise [ArgumentError] if +storage+ is a +BSV::Wallet::Store::Memory+
60
60
  # @raise [ArgumentError] if +broadcaster+ is +nil+
61
61
  def initialize(db:, storage:, broadcaster:, poll_interval: DEFAULT_POLL_INTERVAL, stale_threshold: STALE_THRESHOLD)
62
- if storage.is_a?(BSV::Wallet::MemoryStore)
62
+ if storage.is_a?(BSV::Wallet::Store::Memory)
63
63
  raise ArgumentError, 'SolidQueueAdapter requires a persistent storage adapter — MemoryStore is not supported'
64
64
  end
65
65
  raise ArgumentError, 'SolidQueueAdapter requires a broadcaster' if broadcaster.nil?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module BSV
4
4
  module WalletPostgres
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bsv-wallet-postgres
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Bettison