Skip to content

Commit

Permalink
add env file, fix error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanlei committed Jan 11, 2024
1 parent 11d9c8f commit 9fa56fd
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 16 deletions.
29 changes: 29 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

# production or development
NODE_ENV="production"
# local port the faucet will be hosted on
PORT=3000
# testnet websocket address - Fill in other test networks url if needed
RIPPLED_URI="wss://s.altnet.rippletest.net:51233"
# funding address & secret, using genesis account is not recommended, please prefund your faucet account
FUNDING_ADDRESS=
FUNDING_SECRET=
# default faucet funding amount
XRP_AMOUNT= 1000

# Big Query credentials
BIGQUERY_PRIVATE_KEY=""
BIGQUERY_CLIENT_EMAIL=""
BIGQUERY_PROJECT_ID=""
BIGQUERY_DATASET_ID = ""
BIGQUERY_TABLE_ID = ""

# Caspian credentials
CASPIAN_ENDPOINT=""
CASPIAN_API_KEY=""
CASPIAN_PRODUCER_NAME=""
CASPIAN_ENTITY_NAME=""
CASPIAN_SCHEMA_TYPE=""
CASPIAN_SCHEMA_VERSION=


11 changes: 10 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ Funds new Testnet accounts

## Usage

### Run the server:
### Run the server (example):

#### command line
```
npm install
NODE_ENV="production" PORT=3000 RIPPLED_URI="wss://s.altnet.rippletest.net:51233" FUNDING_ADDRESS=rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe FUNDING_SECRET=<secret> XRP_AMOUNT=10000
npm start
```

#### using env file
or fill out `.env` file using `.env.example` and run
```
npm install
npm start
```

### Fund a new account:

```
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 8 additions & 12 deletions src/routes/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,12 @@ export default async function (req: Request, res: Response) {
payment.DestinationTag = account.tag;
}

let transactionHash = fundingWallet.sign(payment).hash;
try {
let result;
const signedPayment = fundingWallet.sign(payment);
let transactionHash = signedPayment.hash;
try {
let response = await submitPaymentWithTicket(
payment,
client,
fundingWallet
);
({ result, hash: transactionHash } = response);
result = await submitPaymentWithTicket(payment, client, fundingWallet);
transactionHash = result.hash;
} catch (err) {
console.log(
`${rTracer.id()} | Failed to submit payment ${transactionHash}: ${err}`
Expand All @@ -92,12 +87,11 @@ export default async function (req: Request, res: Response) {
return;
}

const status = result.engine_result;

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

if (wallet && wallet.seed) {
Expand Down Expand Up @@ -202,7 +196,9 @@ async function submitPaymentWithTicket(
}

if (retryCount >= maxRetries) {
throw new Error(`Failed to submit transaction ${hash} with ticket after multiple attempts`);
throw new Error(
`Failed to submit transaction ${hash} with ticket after multiple attempts`
);
}

return { result, hash };
Expand Down
4 changes: 3 additions & 1 deletion src/ticket-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ export async function getTicket(client: Client) {
})
.catch((error) => {
console.log(
`Failed to create tickets. Error: ${JSON.stringify(error)} Message: ${error?.message}`
`Failed to create tickets. Error: ${JSON.stringify(error)} Message: ${
error?.message
}`
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export interface Account {
export interface FundedResponse {
account: Account;
amount: number;
paymentHash: string;
transactionHash: string;
seed?: string;
}

0 comments on commit 9fa56fd

Please sign in to comment.