mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-12-06 17:27:57 +00:00
Merge pull request #2378 from XRPLF/3.0-redocly
Update xrpl.js to 3.0 across xrpl.org
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
"pbkdf2-hmac": "^1.1.0",
|
||||
"prompt": "^1.3.0",
|
||||
"qrcode": "^1.5.1",
|
||||
"xrpl": "^2.11.0"
|
||||
"xrpl": "^3.0.0"
|
||||
},
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -16,6 +16,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^16.0.3",
|
||||
"xrpl": "^2.11.0"
|
||||
"xrpl": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { defineConfig, loadEnv } from 'vite';
|
||||
|
||||
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
|
||||
import polyfillNode from 'rollup-plugin-polyfill-node';
|
||||
|
||||
const viteConfig = ({ mode }) => {
|
||||
@@ -14,12 +13,6 @@ const viteConfig = ({ mode }) => {
|
||||
define: {
|
||||
global: 'globalThis',
|
||||
},
|
||||
plugins: [
|
||||
NodeGlobalsPolyfillPlugin({
|
||||
process: true,
|
||||
buffer: true,
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
build: {
|
||||
@@ -29,11 +22,6 @@ const viteConfig = ({ mode }) => {
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
events: 'events',
|
||||
crypto: 'crypto-browserify',
|
||||
stream: 'stream-browserify',
|
||||
http: 'stream-http',
|
||||
https: 'https-browserify',
|
||||
ws: 'xrpl/dist/npm/client/WSWrapper',
|
||||
},
|
||||
},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,11 +19,7 @@ npm run hello
|
||||
```
|
||||
|
||||
```sh
|
||||
npm run async-poll
|
||||
```
|
||||
|
||||
```sh
|
||||
npm run async-subscribe
|
||||
npm run async
|
||||
```
|
||||
|
||||
```sh
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"pbkdf2-hmac": "^1.1.0",
|
||||
"open": "^8.4.0",
|
||||
"toml": "^3.0.0",
|
||||
"xrpl": "^2.6.0"
|
||||
"xrpl": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "22.3.25"
|
||||
|
||||
@@ -12,7 +12,7 @@ const main = async ()=> {
|
||||
|
||||
// Check if the check ID is provided --------------------------------------
|
||||
if (checkId.length === 0) {
|
||||
console.log("Please edit this snippet to provide a check ID. You can get a check ID by running create_check.js.");
|
||||
console.log("Please edit this snippet to provide a check ID. You can get a check ID by running create-check.js.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ const main = async () => {
|
||||
|
||||
// Check if the check ID is provided --------------------------------------
|
||||
if (checkId.length === 0) {
|
||||
console.log("Please edit this snippet to provide a check ID. You can get a check ID by running create_check.js.");
|
||||
console.log("Please edit this snippet to provide a check ID. You can get a check ID by running create-check.js.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ripple-lib": "^1.0.0-beta.1",
|
||||
"xrpl": "^2.11.0"
|
||||
"xrpl": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ async function main() {
|
||||
// Get credentials from the Faucet -------------------------------------------
|
||||
console.log("Requesting address from the faucet...")
|
||||
const wallet = (await client.fundWallet()).wallet
|
||||
const issuer = (await client.fundWallet()).wallet
|
||||
|
||||
// To use an existing account, use code such as the following:
|
||||
// const wallet = xrpl.Wallet.fromSeed(process.env['USE_SEED'])
|
||||
@@ -34,7 +35,7 @@ async function main() {
|
||||
"Account": wallet.address,
|
||||
"TakerPays": {
|
||||
currency: "TST",
|
||||
issuer: "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd",
|
||||
issuer: issuer.address,
|
||||
value: "25"
|
||||
},
|
||||
"TakerGets": xrpl.xrpToDrops(25*10*1.16)
|
||||
@@ -68,7 +69,7 @@ async function main() {
|
||||
"command": "amm_info",
|
||||
"asset": {
|
||||
"currency": "TST",
|
||||
"issuer": "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd",
|
||||
"issuer": issuer.address,
|
||||
},
|
||||
"asset2": {
|
||||
"currency": foo_amount.currency,
|
||||
@@ -106,7 +107,7 @@ async function main() {
|
||||
"Account": wallet.address,
|
||||
"Amount": {
|
||||
currency: "TST",
|
||||
issuer: "rP9jPyP5kyvFRb6ZiRghAGw5u8SGAmU4bd",
|
||||
issuer: issuer.address,
|
||||
value: "15"
|
||||
},
|
||||
"Amount2": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"xrpl": "2.11.0"
|
||||
"xrpl": "3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
"dotenv": "^16.3.1",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^5.2.2",
|
||||
"xrpl": "2.11.0"
|
||||
"xrpl": "3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"dependencies": {
|
||||
"five-bells-condition": "*",
|
||||
"ripple-lib": "^0.17.6",
|
||||
"xrpl": "^2.11.0"
|
||||
"xrpl": "^3.0.0"
|
||||
},
|
||||
"//": "Intended for Node.js version ?.? and higher"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"xrpl": "^2.11.0"
|
||||
"xrpl": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"xrpl": "^2.11.0"
|
||||
"xrpl": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"xrpl": "^2.11.0"
|
||||
"xrpl": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,16 +3,49 @@
|
||||
// Organize imports
|
||||
const assert = require("assert")
|
||||
const brorand = require("brorand")
|
||||
const BN = require("bn.js")
|
||||
const { BigNumber } = require("bignumber.js")
|
||||
const elliptic = require("elliptic");
|
||||
const Ed25519 = elliptic.eddsa('ed25519');
|
||||
const Secp256k1 = elliptic.ec('secp256k1');
|
||||
const hashjs = require("hash.js");
|
||||
const Sha512 = require("ripple-keypairs/dist/Sha512")
|
||||
const isomorphic = require("@xrplf/isomorphic/sha512")
|
||||
const noble = require('@noble/curves/abstract/utils')
|
||||
const { codec, encodeAccountPublic, encodeNodePublic } = require("ripple-address-codec");
|
||||
|
||||
const XRPL_SEED_PREFIX = 0x21
|
||||
|
||||
class Sha512 {
|
||||
// instantiate empty sha512 hash
|
||||
hash = isomorphic.sha512.create()
|
||||
|
||||
static half(input) {
|
||||
return new Sha512().add(input).first256()
|
||||
}
|
||||
|
||||
add(bytes) {
|
||||
this.hash.update(bytes)
|
||||
return this
|
||||
}
|
||||
|
||||
addU32(i) {
|
||||
const buffer = new Uint8Array(4)
|
||||
new DataView(buffer.buffer).setUint32(0, i)
|
||||
return this.add(buffer)
|
||||
}
|
||||
|
||||
finish() {
|
||||
return this.hash.digest()
|
||||
}
|
||||
|
||||
first256() {
|
||||
return this.finish().slice(0, 32)
|
||||
}
|
||||
|
||||
first256BigInt() {
|
||||
return noble.bytesToNumberBE(this.first256())
|
||||
}
|
||||
}
|
||||
|
||||
const isHex = function(value) {
|
||||
const regex = new RegExp(/^[0-9a-f]+$/, 'i')
|
||||
return regex.test(value)
|
||||
@@ -27,7 +60,7 @@ const bytesToHex = function(bytes) {
|
||||
|
||||
const hexToBytes = function(hex) {
|
||||
assert.ok(hex.length % 2 === 0);
|
||||
return hex.length === 0 ? [] : new BN(hex, 16).toArray(null, hex.length / 2);
|
||||
return hex.length === 0 ? [] : new BigNumber(hex, 16).toArray(null, hex.length / 2);
|
||||
}
|
||||
|
||||
const encodeUTF8 = function (string) {
|
||||
@@ -87,7 +120,7 @@ class Seed {
|
||||
const publicKey = prefix + bytesToHex(Ed25519.keyFromSecret(rawPrivateKey).pubBytes());
|
||||
return { privateKey, publicKey };
|
||||
}
|
||||
|
||||
|
||||
_deriveSecp256K1Keypair(entropy, options) {
|
||||
const prefix = '00';
|
||||
const privateKey = prefix + this._deriveSecp256K1PrivateKey(entropy, options).toString(16, 64).toUpperCase()
|
||||
@@ -112,27 +145,25 @@ class Seed {
|
||||
// Almost everyone just uses the first account, `0`.
|
||||
const accountIndex = opts.accountIndex || 0;
|
||||
|
||||
return this._deriveScalar(publicGen.encodeCompressed(), accountIndex)
|
||||
.add(privateGen)
|
||||
.mod(order);
|
||||
const scalar = this._deriveScalar(publicGen.encodeCompressed(), accountIndex)
|
||||
return BigNumber(scalar).plus(privateGen).mod(order);
|
||||
}
|
||||
|
||||
_deriveScalar(bytes, discrim) {
|
||||
const order = Secp256k1.curve.n;
|
||||
for (let i = 0; i <= 0xffffffff; i++) {
|
||||
// We hash the bytes to find a 256 bit number, looping until we are sure it
|
||||
const order = Secp256k1.curve.n
|
||||
for (let i = 0; i <= 0xffff_ffff; i++) {
|
||||
// We hash the bytes to find a 256-bit number, looping until we are sure it
|
||||
// is less than the order of the curve.
|
||||
const hasher = new Sha512.default().add(bytes);
|
||||
const hasher = new Sha512().add(bytes)
|
||||
// If the optional discriminator index was passed in, update the hash.
|
||||
if (discrim !== undefined) {
|
||||
hasher.addU32(discrim);
|
||||
hasher.addU32(discrim)
|
||||
}
|
||||
hasher.addU32(i);
|
||||
const key = hasher.first256BN();
|
||||
hasher.addU32(i)
|
||||
const key = hasher.first256BigInt()
|
||||
/* istanbul ignore else */
|
||||
/* istanbul ignore else */
|
||||
if (key.cmpn(0) > 0 && key.cmp(order) < 0) {
|
||||
return key;
|
||||
if (key > 0 && key < order) {
|
||||
return key
|
||||
}
|
||||
}
|
||||
// This error is practically impossible to reach.
|
||||
@@ -141,10 +172,10 @@ class Seed {
|
||||
// How often will an (essentially) random number generated by Sha512 be larger than that?
|
||||
// There's 2^32 chances (the for loop) to get a number smaller than the order,
|
||||
// and it's rare that you'll even get past the first loop iteration.
|
||||
// Note that in TypeScript we actually need the throw, otherwise the function signature would be BN | undefined
|
||||
// Note that in TypeScript we actually need the throw, otherwise the function signature would be bigint | undefined
|
||||
//
|
||||
/* istanbul ignore next */
|
||||
throw new Error('impossible unicorn ;)');
|
||||
throw new Error('impossible unicorn ;)')
|
||||
}
|
||||
|
||||
getBase58ED25519Account() {
|
||||
|
||||
@@ -3,7 +3,16 @@
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"xrpl": "^2.11.0"
|
||||
"@noble/curves": "^1.3.0",
|
||||
"@xrplf/isomorphic": "^1.0.0",
|
||||
"bignumber.js": "^9.1.2",
|
||||
"brorand": "^1.1.0",
|
||||
"elliptic": "^6.5.4",
|
||||
"hash.js": "^1.1.7",
|
||||
"ripple-address-codec": "^5.0.0",
|
||||
"ripple-keypairs": "^2.0.0",
|
||||
"secp256k1": "^5.0.0",
|
||||
"xrpl": "^3.0.0"
|
||||
},
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"xrpl": "^2.11.0"
|
||||
"xrpl": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@
|
||||
"author": "",
|
||||
"license": "CC0-1.0",
|
||||
"dependencies": {
|
||||
"xrpl": "^2.11.0"
|
||||
"xrpl": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"xrpl": "^2.11.0"
|
||||
"xrpl": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"xrpl": "^2.11.0",
|
||||
"xrpl": "^3.0.0",
|
||||
"bignumber.js": "^9.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,14 @@
|
||||
"version": "0.1.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"assert": "^2.1.0",
|
||||
"big-integer": "^1.6.52",
|
||||
"buffer": "^6.0.3",
|
||||
"decimal.js": "^10.4.3",
|
||||
"fs": "^0.0.1-security",
|
||||
"minimist": "^1.2.7",
|
||||
"xrpl": "^2.11.0"
|
||||
"ripple-address-codec": "^5.0.0",
|
||||
"xrpl": "^3.0.0"
|
||||
},
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"xrpl": "^2.11.0"
|
||||
"xrpl": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ In addition to the above features, you'll also learn a bit about Events, IPC (in
|
||||
"pbkdf2-hmac": "^1.1.0",
|
||||
"open": "^8.4.0",
|
||||
"toml": "^3.0.0",
|
||||
"xrpl": "^2.6.0"
|
||||
"xrpl": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"electron": "22.3.24"
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
"react18-json-view": "^0.2.6",
|
||||
"smol-toml": "^1.1.3",
|
||||
"use-query-params": "^2.2.1",
|
||||
"xrpl": "^3.0.0-beta.1"
|
||||
"xrpl": "^3.0.0"
|
||||
},
|
||||
"overrides": {
|
||||
"react": "^18.2.0",
|
||||
|
||||
Reference in New Issue
Block a user