From 0db410a9699077f9a6379653f632fb78419ce010 Mon Sep 17 00:00:00 2001 From: Hakkyung Lee <17398672+hklee93@users.noreply.github.com> Date: Wed, 17 May 2023 19:43:27 +0900 Subject: [PATCH 1/7] drop wallet_private_key from init param --- lib/pi_network.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pi_network.rb b/lib/pi_network.rb index 398d732..47e679d 100644 --- a/lib/pi_network.rb +++ b/lib/pi_network.rb @@ -12,8 +12,9 @@ class PiNetwork attr_reader :base_url attr_reader :from_address - def initialize(api_key, wallet_private_key, options = {}) - validate_private_seed_format!(wallet_private_key) + def initialize(api_key, options = {}) + private_key = options[:wallet_private_key] + validate_private_seed_format!(private_key) if private_key.present? @api_key = api_key @account = load_account(wallet_private_key) @base_url = options[:base_url] || "https://api.minepi.com" From c6eac514417003cd5e20475d2ce4c452b74cbbc0 Mon Sep 17 00:00:00 2001 From: Hakkyung Lee <17398672+hklee93@users.noreply.github.com> Date: Wed, 17 May 2023 19:43:33 +0900 Subject: [PATCH 2/7] adding new error --- lib/errors.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/errors.rb b/lib/errors.rb index 6670dc4..3552d88 100644 --- a/lib/errors.rb +++ b/lib/errors.rb @@ -27,5 +27,8 @@ def initialize(message, payment_id, txid) @payment_id = payment_id @txid = txid end + + class WalletPrivateKeyNotFoundError < StandardError + end end end \ No newline at end of file From defca9fd52dad76c747aab0abca16888bba8ecbc Mon Sep 17 00:00:00 2001 From: Hakkyung Lee <17398672+hklee93@users.noreply.github.com> Date: Wed, 17 May 2023 19:51:18 +0900 Subject: [PATCH 3/7] renamed from key to seed --- lib/errors.rb | 2 +- lib/pi_network.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/errors.rb b/lib/errors.rb index 3552d88..68180c8 100644 --- a/lib/errors.rb +++ b/lib/errors.rb @@ -28,7 +28,7 @@ def initialize(message, payment_id, txid) @txid = txid end - class WalletPrivateKeyNotFoundError < StandardError + class WalletPrivateSeedNotFoundError < StandardError end end end \ No newline at end of file diff --git a/lib/pi_network.rb b/lib/pi_network.rb index 47e679d..7e69f27 100644 --- a/lib/pi_network.rb +++ b/lib/pi_network.rb @@ -13,7 +13,7 @@ class PiNetwork attr_reader :from_address def initialize(api_key, options = {}) - private_key = options[:wallet_private_key] + private_key = options[:wallet_private_seed] validate_private_seed_format!(private_key) if private_key.present? @api_key = api_key @account = load_account(wallet_private_key) From 404b9ad9435848bc14045fc8fc3252403f7ef53f Mon Sep 17 00:00:00 2001 From: Hakkyung Lee <17398672+hklee93@users.noreply.github.com> Date: Wed, 17 May 2023 19:52:24 +0900 Subject: [PATCH 4/7] fixing naming --- lib/pi_network.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pi_network.rb b/lib/pi_network.rb index 7e69f27..990ae06 100644 --- a/lib/pi_network.rb +++ b/lib/pi_network.rb @@ -13,10 +13,10 @@ class PiNetwork attr_reader :from_address def initialize(api_key, options = {}) - private_key = options[:wallet_private_seed] - validate_private_seed_format!(private_key) if private_key.present? + wallet_private_seed = options[:wallet_private_seed] + validate_private_seed_format!(wallet_private_seed) if wallet_private_seed.present? @api_key = api_key - @account = load_account(wallet_private_key) + @account = load_account(wallet_private_seed) @base_url = options[:base_url] || "https://api.minepi.com" @open_payments = {} From d3ac0f04484a9affc3bf90dc65abdb8d7f4a1d47 Mon Sep 17 00:00:00 2001 From: Hakkyung Lee <17398672+hklee93@users.noreply.github.com> Date: Wed, 17 May 2023 19:57:48 +0900 Subject: [PATCH 5/7] raise the error in submit_payment --- lib/pi_network.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/pi_network.rb b/lib/pi_network.rb index 990ae06..cdd7cdd 100644 --- a/lib/pi_network.rb +++ b/lib/pi_network.rb @@ -58,6 +58,10 @@ def create_payment(payment_data) end def submit_payment(payment_id) + raise Errors::WalletPrivateSeedNotFoundError.new( + "You need to initialize the SDK with wallet_private_seed to call this method." + ) if self.account.nil? + payment = @open_payments[payment_id] if payment.nil? || payment["identifier"] != payment_id From 8cecdf9121874c63569cd80aea1841d45464edfc Mon Sep 17 00:00:00 2001 From: Hakkyung Lee <17398672+hklee93@users.noreply.github.com> Date: Wed, 17 May 2023 19:59:50 +0900 Subject: [PATCH 6/7] line --- lib/pi_network.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pi_network.rb b/lib/pi_network.rb index cdd7cdd..a4c6e39 100644 --- a/lib/pi_network.rb +++ b/lib/pi_network.rb @@ -15,6 +15,7 @@ class PiNetwork def initialize(api_key, options = {}) wallet_private_seed = options[:wallet_private_seed] validate_private_seed_format!(wallet_private_seed) if wallet_private_seed.present? + @api_key = api_key @account = load_account(wallet_private_seed) @base_url = options[:base_url] || "https://api.minepi.com" From 5c4abfbe0edc7a29f23b8d79cb85aaff38eb2aba Mon Sep 17 00:00:00 2001 From: Hakkyung Lee <17398672+hklee93@users.noreply.github.com> Date: Wed, 17 May 2023 20:15:03 +0900 Subject: [PATCH 7/7] bumping minor --- pinetwork.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pinetwork.gemspec b/pinetwork.gemspec index 221d1c1..9b305e4 100644 --- a/pinetwork.gemspec +++ b/pinetwork.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |s| s.name = "pinetwork" - s.version = "0.1.2" + s.version = "0.2.0" s.summary = "Pi Network Ruby" s.description = "Pi Network backend library for Ruby-based webservers." s.authors = ["Pi Core Team"]