-
Notifications
You must be signed in to change notification settings - Fork 14
WIP: Chunk Pay id demos #50
base: master
Are you sure you want to change the base?
Changes from all commits
a740538
752bb29
6c36f3b
ec1e746
295a15a
5955190
7498218
2bef964
490aa96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 Pay ID 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<Address> allAddresses = payIdClient.allAddressesForPayId(payId); | ||
System.out.println("Resolved to:"); | ||
for (int i = 0; i < allAddresses.size(); i++) { | ||
System.out.println(i + ") " + allAddresses.get(i)); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -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 Pay ID 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.. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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(""); | ||||||
|
||||||
|
||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -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 Pay ID to resolve. | ||||
String payId = "alice$dev.payid.xpring.money"; | ||||
|
||||
// The XRP Ledger network to resolve on. | ||||
XrplNetwork xrpNetwork = XrplNetwork.MAIN; | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
|
||||
// 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(""); | ||||
|
||||
} | ||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -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 the Bitcoin testnet. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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(); |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||||
import Foundation | ||||||
import XpringKit | ||||||
|
||||||
// The Pay ID to resolve. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
let payID = "alice$dev.payid.xpring.money" | ||||||
|
||||||
// A client to resolve PayIDs on any network.. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
let payIDClient = PayIDClient() | ||||||
|
||||||
// Resolve all addresses | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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("") |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,24 @@ | ||||||
import Foundation | ||||||
import XpringKit | ||||||
|
||||||
// The Pay ID 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.. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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)") | ||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,24 @@ | ||||||
import Foundation | ||||||
import XpringKit | ||||||
|
||||||
// The Pay ID to resolve. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
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)") | ||||||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.