XRPLF / xrpl.js

A JavaScript/TypeScript API for interacting with the XRP Ledger in Node.js and the browser
https://xrpl.org/
1.2k stars 511 forks source link

Export schemaValidator as part of API and isValidAddress as part of schemaValidator #915

Closed movitto closed 4 years ago

movitto commented 6 years ago

Greetings! Related to #770, we're looking for a quick way to validate addresses & secrets. ripple-lib has this functionality built in via the mechanisms in $subject, but they are not exposed publically.

Yes ripple-keypairs has this functionality (and ripple-address-codec?) but those projects do not incorporate a 'gulpfile' so that they can be bundled for browser access! Having less experience with nodejs tools than in other languages, it was just easier for me to modify the exports of ripple-lib to expose the aforementioned methods than to figure out everything that's needed to build ripple-keypairs into a single package.

I can send a PR exposing the methods if desired, else please advise how to access this functionality from a browser environment, it'd be great to be using stock ripple libs w/out mods!!!

Thanks for the great library and all of ripple's efforts!

movitto commented 6 years ago

In case anyone was wondering, to expose schemaValidator, I simply modified src/api.ts to remove 'schemaValidator' from the PRIVATE map:

https://github.com/ripple/ripple-lib/blob/develop/src/api.ts#L103

static _PRIVATE = {
    validate: validate,
    RangeSet,
    ledgerUtils
}

And added 'schemaValidator' to the 'RippleAPI' class properties below:

https://github.com/ripple/ripple-lib/blob/develop/src/api.ts#L308

schemaValidator = schemaValidator


Simply build according to the build instructions on the ripple website (npm run build) and you're good to go!

intelliot commented 6 years ago

Would you like to create a PR?

movitto commented 6 years ago

PR sent, thanks for taking the time to consider this.

wilsonianb commented 6 years ago

As a follow up, should the exposed methods be added to the docs?

movitto commented 6 years ago

@wilsonianb PR #927 sent

intelliot commented 4 years ago

This is done. Docs: https://xrpl.org/rippleapi-reference.html#schemavalidator