diff --git a/java/src/main/java/io/xpring/demo/PayIdDemo.java b/java/src/main/java/io/xpring/demo/PayIdDemo.java deleted file mode 100644 index b31b70c..0000000 --- a/java/src/main/java/io/xpring/demo/PayIdDemo.java +++ /dev/null @@ -1,48 +0,0 @@ -package io.xpring.demo; - -import java.util.List; - -import io.xpring.common.XrplNetwork; -import io.xpring.payid.generated.model.Address; -import io.xpring.payid.generated.model.CryptoAddressDetails; -import io.xpring.payid.PayIdClient; -import io.xpring.payid.XrpPayIdClient; -import io.xpring.payid.PayIdException; - -public class PayIdDemo { - public static void main(String[] args) throws PayIdException { - // The Pay ID to resolve. - String payId = "alice$dev.payid.xpring.money"; - - // The XRP Ledger network to resolve on. - XrplNetwork xrpNetwork = XrplNetwork.MAIN; - - // The BTC network to resolve on. - String btcNetwork = "btc-testnet"; - - // A client to resolve PayIDs on any network.. - PayIdClient payIdClient = new PayIdClient(); - - // A client to resolve PayIDs on the XRP Ledger. - XrpPayIdClient xrpPayIdClient = new XrpPayIdClient(xrpNetwork); - - System.out.println("Resolving PayID: " + payId); - System.out.println("On network: " + btcNetwork); - CryptoAddressDetails btcAddressComponents = payIdClient.cryptoAddressForPayId(payId, btcNetwork); - System.out.println("Resolved to " + btcAddressComponents.getAddress()); - System.out.println(""); - - System.out.println("Resolving PayID: " + payId); - System.out.println("On network: " + xrpNetwork); - String xrpAddress = xrpPayIdClient.xrpAddressForPayId(payId); - System.out.println("Resolved to " + xrpAddress); - System.out.println(""); - - System.out.println("Resolving All PayIDs for: " + payId); - List
allAddresses = payIdClient.allAddressesForPayId(payId); - System.out.println("Resolved to:"); - for (int i = 0; i < allAddresses.size(); i++) { - System.out.println(i + ") " + allAddresses.get(i)); - } - } -} diff --git a/java/src/main/java/io/xpring/demo/PayIdDemoAll.java b/java/src/main/java/io/xpring/demo/PayIdDemoAll.java new file mode 100644 index 0000000..86792d4 --- /dev/null +++ b/java/src/main/java/io/xpring/demo/PayIdDemoAll.java @@ -0,0 +1,24 @@ +package io.xpring.demo; + +import java.util.List; + +import io.xpring.payid.generated.model.Address; +import io.xpring.payid.PayIdClient; +import io.xpring.payid.PayIdException; + +public class PayIdDemoAll { + public static void main(String[] args) throws PayIdException { + // The PayID to resolve. + String payId = "alice$dev.payid.xpring.money"; + + // A client to resolve PayIDs on any network. + PayIdClient payIdClient = new PayIdClient(); + + System.out.println("Resolving All PayIDs for: " + payId); + List
allAddresses = payIdClient.allAddressesForPayId(payId); + System.out.println("Resolved to:"); + for (int i = 0; i < allAddresses.size(); i++) { + System.out.println(i + ") " + allAddresses.get(i)); + } + } +} \ No newline at end of file diff --git a/java/src/main/java/io/xpring/demo/PayIdDemoBTC.java b/java/src/main/java/io/xpring/demo/PayIdDemoBTC.java new file mode 100644 index 0000000..0ed8e99 --- /dev/null +++ b/java/src/main/java/io/xpring/demo/PayIdDemoBTC.java @@ -0,0 +1,27 @@ +package io.xpring.demo; + +import io.xpring.payid.generated.model.CryptoAddressDetails; +import io.xpring.payid.PayIdClient; +import io.xpring.payid.PayIdException; + +public class PayIdDemoBTC { + public static void main(String[] args) throws PayIdException { + // The PayID to resolve. + String payId = "alice$dev.payid.xpring.money"; + + + // The BTC network to resolve on. + String btcNetwork = "btc-testnet"; + + // A client to resolve PayIDs on any network. + PayIdClient payIdClient = new PayIdClient(); + + System.out.println("Resolving PayID: " + payId); + System.out.println("On network: " + btcNetwork); + CryptoAddressDetails btcAddressComponents = payIdClient.cryptoAddressForPayId(payId, btcNetwork); + System.out.println("Resolved to " + btcAddressComponents.getAddress()); + System.out.println(""); + + + } +} \ No newline at end of file diff --git a/java/src/main/java/io/xpring/demo/PayIdDemoXRPL.java b/java/src/main/java/io/xpring/demo/PayIdDemoXRPL.java new file mode 100644 index 0000000..cb10391 --- /dev/null +++ b/java/src/main/java/io/xpring/demo/PayIdDemoXRPL.java @@ -0,0 +1,26 @@ +package io.xpring.demo; + +import io.xpring.common.XrplNetwork; +import io.xpring.payid.XrpPayIdClient; +import io.xpring.payid.PayIdException; + +public class PayIdDemoXRPL { + public static void main(String[] args) throws PayIdException { + // The PayID to resolve. + String payId = "alice$dev.payid.xpring.money"; + + // The XRP Ledger network to resolve on. + XrplNetwork xrpNetwork = XrplNetwork.MAIN; + + + // A client to resolve PayIDs on the XRP Ledger. + XrpPayIdClient xrpPayIdClient = new XrpPayIdClient(xrpNetwork); + + System.out.println("Resolving PayID: " + payId); + System.out.println("On network: " + xrpNetwork); + String xrpAddress = xrpPayIdClient.xrpAddressForPayId(payId); + System.out.println("Resolved to " + xrpAddress); + System.out.println(""); + + } +} \ No newline at end of file diff --git a/node/src/index-payid-All.js b/node/src/index-payid-All.js new file mode 100644 index 0000000..8499159 --- /dev/null +++ b/node/src/index-payid-All.js @@ -0,0 +1,37 @@ +const { PayIdClient, XrpPayIdClient, XrplNetwork } = require("xpring-js"); + +// The PayID to resolve. +const payId = "alice$dev.payid.xpring.money"; + +// A client to resolve PayIDs on any network. +const payIdClient = new PayIdClient(); + +async function main() { + console.log("Resolving All PayIDs for: " + payId); + const allAddresses = await payIdClient.allAddressesForPayId(payId); + console.log("Resolved to:"); + for (let i = 0; i < allAddresses.length; i++) { + console.log(`${i}) ${JSON.stringify(allAddresses[i])}`); + } +} + +function networkToString(network) { + switch (network) { + case XrplNetwork.Dev: + return "Devnet"; + case XrplNetwork.Test: + return "Testnet"; + case XrplNetwork.Main: + return "Mainnet"; + default: + return "Unknown Network"; + } +} + +// Exit with an error code if there is an error. +process.on("unhandledRejection", (error) => { + console.log(`Fatal: ${error}`); + process.exit(1); +}); + +main(); \ No newline at end of file diff --git a/node/src/index-payid.js b/node/src/index-payid-BTC.js similarity index 59% rename from node/src/index-payid.js rename to node/src/index-payid-BTC.js index 1d46871..2285e3f 100644 --- a/node/src/index-payid.js +++ b/node/src/index-payid-BTC.js @@ -3,15 +3,9 @@ const { PayIdClient, XrpPayIdClient, XrplNetwork } = require("xpring-js"); // The PayID to resolve. const payId = "alice$dev.payid.xpring.money"; -// The XRP network to resolve on. -const xrpNetwork = XrplNetwork.Main; - // The BTC network to resolve on. const btcNetwork = "btc-testnet"; -// A client to resolve PayIDs on the XRP Ledger. -const xrpPayIdClient = new XrpPayIdClient(xrpNetwork); - // A client to resolve PayIDs on the Bitcoin testnet. const payIdClient = new PayIdClient(); @@ -25,18 +19,6 @@ async function main() { console.log("Resolved to " + btcAddressComponents.address); console.log(""); - console.log("Resolving PayID: " + payId); - console.log("On network: " + networkToString(xrpNetwork)); - const xrpAddress = await xrpPayIdClient.xrpAddressForPayId(payId); - console.log("Resolved to " + xrpAddress); - console.log(""); - - console.log("Resolving All PayIDs for: " + payId); - const allAddresses = await payIdClient.allAddressesForPayId(payId); - console.log("Resolved to:"); - for (let i = 0; i < allAddresses.length; i++) { - console.log(`${i}) ${JSON.stringify(allAddresses[i])}`); - } } function networkToString(network) { @@ -58,4 +40,4 @@ process.on("unhandledRejection", (error) => { process.exit(1); }); -main(); +main(); \ No newline at end of file diff --git a/node/src/index-payid-XRPL.js b/node/src/index-payid-XRPL.js new file mode 100644 index 0000000..41bef0c --- /dev/null +++ b/node/src/index-payid-XRPL.js @@ -0,0 +1,40 @@ +const { PayIdClient, XrpPayIdClient, XrplNetwork } = require("xpring-js"); + +// The PayID to resolve. +const payId = "alice$dev.payid.xpring.money"; + +// The XRP network to resolve on. +const xrpNetwork = XrplNetwork.Main; + +// A client to resolve PayIDs on the XRP Ledger. +const xrpPayIdClient = new XrpPayIdClient(xrpNetwork); + +async function main() { + console.log("Resolving PayID: " + payId); + console.log("On network: " + networkToString(xrpNetwork)); + const xrpAddress = await xrpPayIdClient.xrpAddressForPayId(payId); + console.log("Resolved to " + xrpAddress); + console.log(""); + +} + +function networkToString(network) { + switch (network) { + case XrplNetwork.Dev: + return "Devnet"; + case XrplNetwork.Test: + return "Testnet"; + case XrplNetwork.Main: + return "Mainnet"; + default: + return "Unknown Network"; + } +} + +// Exit with an error code if there is an error. +process.on("unhandledRejection", (error) => { + console.log(`Fatal: ${error}`); + process.exit(1); +}); + +main(); \ No newline at end of file diff --git a/swift/Sources/PayID/All.swift b/swift/Sources/PayID/All.swift new file mode 100644 index 0000000..17fdbf5 --- /dev/null +++ b/swift/Sources/PayID/All.swift @@ -0,0 +1,19 @@ +import Foundation +import XpringKit + +// The PayID to resolve. +let payID = "alice$dev.payid.xpring.money" + +// A client to resolve PayIDs on any network. +let payIDClient = PayIDClient() + +// Resolve all addresses +print("Resolving All PayIDs for: \(payID)"); +guard case let .success(allAddresses) = payIDClient.allAddresses(for: payID) else { + fatalError("Could not resolve all addresses") +} +print("Resolved to:") +for (index, address) in allAddresses.enumerated() { + print("\(index)) PaymentNetwork: \(address.paymentNetwork), Environment: \(String(describing: address.environment)), Address: \(address.addressDetails.address), Tag: \(String(describing: address.addressDetails.tag))") +} +print("") diff --git a/swift/Sources/PayID/BTC.swift b/swift/Sources/PayID/BTC.swift new file mode 100644 index 0000000..01cda25 --- /dev/null +++ b/swift/Sources/PayID/BTC.swift @@ -0,0 +1,24 @@ +import Foundation +import XpringKit + +// The PayID to resolve. +let payID = "alice$dev.payid.xpring.money" + +// Resolve on Bitcoin testnet. +let btcNetwork = "btc-testnet" + + // A client to resolve PayIDs on any network. +let payIDClient = PayIDClient() + +// Resolve a PayID to a BTC Address using a `PayIDClient`. +print("Resolving PayID: \(payID)") +print("On network: \(btcNetwork)") + +let btcResult = payIDClient.cryptoAddress(for: payID, on: btcNetwork) +switch btcResult { +case .success(let btcAddressComponents): + print("Resolved to \(btcAddressComponents.address)") + print("") +case .failure(let error): + fatalError("Unknown error resolving address: \(error)") +} \ No newline at end of file diff --git a/swift/Sources/PayID/XRPL.swift b/swift/Sources/PayID/XRPL.swift new file mode 100644 index 0000000..e48037a --- /dev/null +++ b/swift/Sources/PayID/XRPL.swift @@ -0,0 +1,24 @@ +import Foundation +import XpringKit + +// The PayID to resolve. +let payID = "alice$dev.payid.xpring.money" + +// The XRP Ledger network to resolve on. +let xrplNetwork = XRPLNetwork.main + +// A client which can resolve PayIDs on the XRP ledger network. +let xrpPayIDClient = XRPPayIDClient(xrplNetwork: .main) + +// Resolve PayID to an XRP Address, using `XRPPayIDClient`. +print("Resolving PayID: \(payID)") +print("On XRP Network: \(xrplNetwork)") + +let xrpResult = xrpPayIDClient.xrpAddress(for: "alice$dev.payid.xpring.money") +switch xrpResult { +case .success(let xrpAddress): + print("Resolved to \(xrpAddress)") + print("") +case .failure(let error): + fatalError("Unknown error resolving address: \(error)") +} \ No newline at end of file diff --git a/swift/Sources/PayID/main.swift b/swift/Sources/PayID/main.swift deleted file mode 100644 index 7503ca6..0000000 --- a/swift/Sources/PayID/main.swift +++ /dev/null @@ -1,54 +0,0 @@ -import Foundation -import XpringKit - -// The Pay ID to resolve. -let payID = "alice$dev.payid.xpring.money" - -// The XRP Ledger network to resolve on. -let xrplNetwork = XRPLNetwork.main - -// A client which can resolve PayIDs on the XRP ledger network. -let xrpPayIDClient = XRPPayIDClient(xrplNetwork: .main) - -// Resolve on Bitcoin testnet. -let btcNetwork = "btc-testnet" - -// A client which can resolve PayIDs on the XRP ledger network. -let payIDClient = PayIDClient() - -// Resolve a PayID to a BTC Address using a `PayIDClient`. -print("Resolving PayID: \(payID)") -print("On network: \(btcNetwork)") - -let btcResult = payIDClient.cryptoAddress(for: payID, on: btcNetwork) -switch btcResult { -case .success(let btcAddressComponents): - print("Resolved to \(btcAddressComponents.address)") - print("") -case .failure(let error): - fatalError("Unknown error resolving address: \(error)") -} - -// Resolve PayID to an XRP Address, using `XRPPayIDClient`. -print("Resolving PayID: \(payID)") -print("On XRP Network: \(xrplNetwork)") - -let xrpResult = xrpPayIDClient.xrpAddress(for: "alice$dev.payid.xpring.money") -switch xrpResult { -case .success(let xrpAddress): - print("Resolved to \(xrpAddress)") - print("") -case .failure(let error): - fatalError("Unknown error resolving address: \(error)") -} - -// Resolve all addresses -print("Resolving All PayIDs for: \(payID)"); -guard case let .success(allAddresses) = payIDClient.allAddresses(for: payID) else { - fatalError("Could not resolve all addresses") -} -print("Resolved to:") -for (index, address) in allAddresses.enumerated() { - print("\(index)) PaymentNetwork: \(address.paymentNetwork), Environment: \(String(describing: address.environment)), Address: \(address.addressDetails.address), Tag: \(String(describing: address.addressDetails.tag))") -} -print("")