Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add seed in response object #46

Merged
merged 3 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 11 additions & 5 deletions src/routes/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Request, Response } from "express";
import { getConnectedClient, resetClient } from "../client";
import { getDestinationAccount } from "../destination-wallet";
import { Client, Payment, Wallet, xrpToDrops } from "xrpl";
import { Account } from "../types";
import { Account, FundedResponse } from "../types";
import { fundingWallet } from "../wallet";
import { BigQuery } from "@google-cloud/bigquery";
import { config } from "../config";
Expand All @@ -15,6 +15,7 @@ export default async function (req: Request, res: Response) {
const client = await getConnectedClient();

let account: Account;
let wallet: Wallet;

if (req.body.destination) {
try {
Expand All @@ -26,7 +27,7 @@ export default async function (req: Request, res: Response) {
});
}
} else {
const wallet = Wallet.generate();
wallet = Wallet.generate();
account = {
xAddress: wallet.getXAddress(),
address: wallet.classicAddress,
Expand Down Expand Up @@ -83,11 +84,16 @@ export default async function (req: Request, res: Response) {
}

const status = result.engine_result;
const response = {
account,
amount: Number(amount),

const response: FundedResponse = {
account: account,
amount: amount,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this changed from Number(amount)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed the type to number

};

if (wallet.seed) {
response.seed = wallet.seed;
}

if (status === "tesSUCCESS" || status === "terQUEUED") {
console.log(
`${rTracer.id()} | Funded ${
Expand Down
13 changes: 9 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
export interface Account {
xAddress: string,
classicAddress: string,
address: string,
tag?: number | boolean
xAddress: string;
classicAddress: string;
address: string;
tag?: number | boolean;
}
export interface FundedResponse {
account: Account;
amount: string;
seed?: string;
}