Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

WIP: Chunk Pay id demos #50

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 0 additions & 48 deletions java/src/main/java/io/xpring/demo/PayIdDemo.java

This file was deleted.

24 changes: 24 additions & 0 deletions java/src/main/java/io/xpring/demo/PayIdDemoAll.java
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));
}
}
}
27 changes: 27 additions & 0 deletions java/src/main/java/io/xpring/demo/PayIdDemoBTC.java
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";

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change


// The BTC network to resolve on.
String btcNetwork = "btc-testnet";

// A client to resolve PayIDs on any network..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// A client to resolve PayIDs on any network..
// 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("");


}
}
26 changes: 26 additions & 0 deletions java/src/main/java/io/xpring/demo/PayIdDemoXRPL.java
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;

Copy link
Contributor

Choose a reason for hiding this comment

The 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("");

}
}
37 changes: 37 additions & 0 deletions node/src/index-payid-ALL.js
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// A client to resolve PayIDs on the Bitcoin testnet.
// 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();
20 changes: 1 addition & 19 deletions node/src/index-payid.js → node/src/index-payid-BTC.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// A client to resolve PayIDs on the Bitcoin testnet.
// A client to resolve PayIDs on any network.

const payIdClient = new PayIdClient();

Expand All @@ -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) {
Expand All @@ -58,4 +40,4 @@ process.on("unhandledRejection", (error) => {
process.exit(1);
});

main();
main();
40 changes: 40 additions & 0 deletions node/src/index-payid-XRPL.js
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();
19 changes: 19 additions & 0 deletions swift/Sources/PayID/All.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Foundation
import XpringKit

// The Pay ID to resolve.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// The Pay ID to resolve.
// The PayID to resolve.

let payID = "alice$dev.payid.xpring.money"

// A client to resolve PayIDs on any network..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// A client to resolve PayIDs on any network..
// A client to resolve PayIDs on any network.

let payIDClient = PayIDClient()

// Resolve all addresses
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Resolve all addresses
// 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("")
24 changes: 24 additions & 0 deletions swift/Sources/PayID/BTC.swift
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..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// A client to resolve PayIDs on any network..
// 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)")
}
24 changes: 24 additions & 0 deletions swift/Sources/PayID/XRPL.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Foundation
import XpringKit

// The Pay ID to resolve.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// The Pay ID to resolve.
// 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)")
}
54 changes: 0 additions & 54 deletions swift/Sources/PayID/main.swift

This file was deleted.