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

Feature/typescript xrpl.js #42

Merged
merged 26 commits into from
Aug 7, 2023
Merged

Conversation

jonathanlei
Copy link
Contributor

High Level Overview of Change

upgrade faucet code to typescript and using xrpl.js V2, use tickets to arrange and track sequence numbers.
break up routes into separate files and clean up code.

Context of Change

CBDC team pointed out the existing faucet doesn't work with custom networkIds and will need an update to support them

Type of Change

  • [X ] New feature (non-breaking change which adds functionality)

index.js Outdated Show resolved Hide resolved
src/config.ts Outdated Show resolved Hide resolved
src/routes/accounts.ts Outdated Show resolved Hide resolved
@ckniffen
Copy link
Contributor

Have you tested this on a standalone rippled instance with a high networkId?

package.json Show resolved Hide resolved
src/client.ts Outdated Show resolved Hide resolved
src/client.ts Outdated Show resolved Hide resolved
src/client.ts Outdated Show resolved Hide resolved
src/client.ts Show resolved Hide resolved
src/client.ts Outdated Show resolved Hide resolved
src/client.ts Outdated Show resolved Hide resolved
src/config.ts Outdated
@@ -0,0 +1,57 @@
export interface Config {
NODE_ENV: "production" | "development"
PORT: string
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the values that have "defaults" later on be optional here?

Also I'd recommend grouping the "optional" fields at the end, and giving them a comment above like '// Optional - See "defaults" for default valuesto clarify that they do have to be in the final object, but maybe not the.config` file.

Maybe instead of having one type, Config should be the type passed around in the code, and ConfigFile should represent the type that users provide, which is used to generate the full Config object.

src/destination-wallet.ts Outdated Show resolved Hide resolved
src/index.ts Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
src/index.ts Show resolved Hide resolved
src/routes/accounts.ts Outdated Show resolved Hide resolved
src/routes/accounts.ts Outdated Show resolved Hide resolved
src/config.ts Outdated
NODE_ENV: "production" | "development"
PORT: string
RIPPLED_URI: string
FUNDING_ADDRESS: string
Copy link
Contributor

Choose a reason for hiding this comment

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

FUNDING_ADDRESS doesnt seem to be used. I made a mistake in not including this as part of the initial rewrite. It should be used to cover the case that the faucet account is rekeyed and the secret is now different than the original one to create the account. This existed in the previous version but I stupidly deleted it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

where in the previous version does it exist? can't seem to find it

Copy link
Contributor

Choose a reason for hiding this comment

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

It uses it here https://github.com/xpring-eng/testnet-faucet/blob/master/index.js#L173. By it being used this way though it requires you to always specify both properties.

I think it would be better since we are using the wallet class to supply it there.

Copy link
Contributor

Choose a reason for hiding this comment

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

fromSeed(FUNDING_SEED, { masterAddress: FUNDING_ADDRESS })

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

src/routes/info.ts Show resolved Hide resolved
export default async function (req: Request, res: Response) {
let client = await getConnectedClient();
try {
const serverInfo: ServerInfoResponse = await client.request({
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: server_info, fee and account_info could all happen at the same time via a Promise.all

src/routes/status.ts Show resolved Hide resolved
ledger_index: "current",
queue: true,
});
console.log(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Use template strings to clean up these logging statements

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

src/ticket-queue.ts Outdated Show resolved Hide resolved
src/utils.ts Show resolved Hide resolved
140,
config.MAX_TICKET_COUNT - ticketQueue.length
);
console.log(
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Should we add request id to these logs to keep track of the request that necessitated getting more tickets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

src/ticket-queue.ts Outdated Show resolved Hide resolved
src/ticket-queue.ts Outdated Show resolved Hide resolved
src/ticket-queue.ts Outdated Show resolved Hide resolved
package.json Outdated
@@ -2,18 +2,27 @@
"name": "testnet-faucet",
"version": "1.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should bump the version of this to 2.0.0

src/client.ts Show resolved Hide resolved
src/routes/accounts.ts Outdated Show resolved Hide resolved
src/client.ts Show resolved Hide resolved
src/ticket-queue.ts Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
src/routes/accounts.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@JST5000 JST5000 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@intelliot intelliot left a comment

Choose a reason for hiding this comment

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

If it works, it works... and if it doesn't, then revert.

@jonathanlei jonathanlei merged commit fe7b989 into master Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants