From b3b4ee2fcdce45ffa5568ed0ebc68a28c2262073 Mon Sep 17 00:00:00 2001 From: Kohei Taniguchi Date: Wed, 30 Jul 2025 11:52:54 +0900 Subject: [PATCH] Add wallet_id argument to the Glueby::Wallet#create --- lib/glueby/wallet.rb | 4 ++-- spec/glueby/wallet_spec.rb | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/glueby/wallet.rb b/lib/glueby/wallet.rb index fc8f0aff..6ff72a21 100644 --- a/lib/glueby/wallet.rb +++ b/lib/glueby/wallet.rb @@ -5,8 +5,8 @@ class Wallet attr_reader :internal_wallet class << self - def create - new(Glueby::Internal::Wallet.create) + def create(wallet_id = nil) + new(Glueby::Internal::Wallet.create(wallet_id)) end def load(wallet_id) diff --git a/spec/glueby/wallet_spec.rb b/spec/glueby/wallet_spec.rb index d9578f9c..0edcc4d9 100644 --- a/spec/glueby/wallet_spec.rb +++ b/spec/glueby/wallet_spec.rb @@ -3,7 +3,7 @@ RSpec.describe 'Glueby::Wallet' do class TestWalletAdapter < Glueby::Internal::Wallet::AbstractWalletAdapter def create_wallet(wallet_id = nil) - "wallet_id:1" + wallet_id ? wallet_id : "wallet_id:1" end def list_unspent(wallet_id, only_finalized = true, label = nil, color_id: nil) utxos = [ @@ -112,6 +112,23 @@ def token_utxos(wallet_id, color_id, only_finalized, per, page) end end + describe '#create' do + subject { Glueby::Wallet.create } + + it 'returns Glueby::Wallet instance' do + expect(subject).to be_a Glueby::Wallet + end + + context 'with wallet_id' do + let(:wallet_id) { 'wallet_id' } + subject { Glueby::Wallet.create(wallet_id) } + + it 'created wallet has specified wallet_id' do + expect(subject.id).to eq(wallet_id) + end + end + end + describe '#balances' do subject { wallet.balances(only_finalized) }