This commit is contained in:
Denis Angell
2023-06-14 22:56:35 +00:00
parent f570b89d71
commit 3e929eff56
18 changed files with 35 additions and 53 deletions

View File

@@ -5,7 +5,10 @@ import {
XrplDefinitionsBase,
} from '../enums'
import { SerializedType, JsonObject } from './serialized-type'
import { xAddressToClassicAddress, isValidXAddress } from '@transia/ripple-address-codec'
import {
xAddressToClassicAddress,
isValidXAddress,
} from '@transia/ripple-address-codec'
import { BinaryParser } from '../serdes/binary-parser'
import { BinarySerializer, BytesList } from '../serdes/binary-serializer'
import { Buffer } from 'buffer/'

View File

@@ -1,9 +1,4 @@
/* eslint-disable max-lines -- There are lots of equivalent constructors which make sense to have here. */
import BigNumber from 'bignumber.js'
import { fromSeed } from 'bip32'
import { mnemonicToSeedSync, validateMnemonic } from 'bip39'
import isEqual from 'lodash/isEqual'
import omitBy from 'lodash/omitBy'
import {
classicAddressToXAddress,
isValidXAddress,
@@ -23,6 +18,11 @@ import {
verify,
sign,
} from '@transia/ripple-keypairs'
import BigNumber from 'bignumber.js'
import { fromSeed } from 'bip32'
import { mnemonicToSeedSync, validateMnemonic } from 'bip39'
import isEqual from 'lodash/isEqual'
import omitBy from 'lodash/omitBy'
import ECDSA from '../ECDSA'
import { ValidationError, XrplError } from '../errors'

View File

@@ -1,5 +1,3 @@
import { BigNumber } from 'bignumber.js'
import { flatMap } from 'lodash'
import { decodeAccountID } from '@transia/ripple-address-codec'
import {
decode,
@@ -8,6 +6,8 @@ import {
encodeForSigningClaim,
} from '@transia/ripple-binary-codec'
import { sign as signWithKeypair, verify } from '@transia/ripple-keypairs'
import { BigNumber } from 'bignumber.js'
import { flatMap } from 'lodash'
import { ValidationError } from '../errors'
import { Signer } from '../models/common'

View File

@@ -1,5 +1,5 @@
import BigNumber from 'bignumber.js'
import { decode } from '@transia/ripple-binary-codec'
import BigNumber from 'bignumber.js'
import type {
AccountTxResponse,

View File

@@ -2,6 +2,7 @@
/* eslint-disable no-bitwise -- flags require bitwise operations */
import { ValidationError } from '../../errors'
import { Hook } from '../common'
import {
AccountRootFlagsInterface,
AccountRootFlags,
@@ -78,10 +79,10 @@ export function setTransactionFlagsToNumber(tx: Transaction): void {
return
case 'SetHook':
tx.Flags = convertSetHookFlagsToNumber(tx.Flags)
tx.Hooks.forEach((h) => {
h.Hook.Flags = convertSetHookFlagsToNumber(
tx.Hooks.forEach((hook: Hook) => {
hook.Hook.Flags = convertSetHookFlagsToNumber(
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- idk
h.Hook.Flags as SetHookFlagsInterface,
hook.Hook.Flags as SetHookFlagsInterface,
)
})
return

View File

@@ -1,5 +1,8 @@
import {
xAddressToClassicAddress,
isValidXAddress,
} from '@transia/ripple-address-codec'
import BigNumber from 'bignumber.js'
import { xAddressToClassicAddress, isValidXAddress } from '@transia/ripple-address-codec'
import type { Client } from '..'
import { ValidationError, XrplError } from '../errors'

View File

@@ -1,4 +1,7 @@
import { xAddressToClassicAddress, isValidXAddress } from '@transia/ripple-address-codec'
import {
xAddressToClassicAddress,
isValidXAddress,
} from '@transia/ripple-address-codec'
/**
* If an address is an X-Address, converts it to a classic address.

View File

@@ -3,8 +3,8 @@
/* eslint-disable no-bitwise -- this file mimics behavior in rippled. It uses
bitwise operators for and-ing numbers with a mask and bit shifting. */
import BigNumber from 'bignumber.js'
import { decode, encode } from '@transia/ripple-binary-codec'
import BigNumber from 'bignumber.js'
import { ValidationError, XrplError } from '../../errors'
import type { Ledger } from '../../models/ledger'

View File

@@ -3,8 +3,8 @@
/* eslint-disable no-bitwise -- this file mimics behavior in rippled. It uses
bitwise operators for and-ing numbers with a mask and bit shifting. */
import BigNumber from 'bignumber.js'
import { decodeAccountID } from '@transia/ripple-address-codec'
import BigNumber from 'bignumber.js'
import hashLedger, {
hashLedgerHeader,

View File

@@ -8,7 +8,7 @@ import {
TRANSACTION_TYPES,
TRANSACTION_TYPE_MAP,
} from '@transia/ripple-binary-codec'
import createHash = require('create-hash')
// import createHash = require('create-hash')
import { XrplError } from '../errors'
import { HookParameter } from '../models/common'
@@ -58,34 +58,6 @@ export function calculateHookOn(arr: Array<keyof TTS>): string {
return hash.toUpperCase()
}
/**
* Calculate the sha256 of a string
*
* @param string - the string to calculate the sha256
* @returns the sha256
*/
export async function sha256(string: string): Promise<string> {
const hash = createHash('sha256')
hash.update(string)
const hashBuffer = hash.digest()
const hashArray = Array.from(new Uint8Array(hashBuffer))
const hashHex = hashArray
// eslint-disable-next-line @typescript-eslint/no-magic-numbers -- Required
.map((bytes) => bytes.toString(16).padStart(2, '0'))
.join('')
return hashHex
}
/**
* Calculate the hex of a namespace
*
* @param namespace - the namespace to calculate the hex
* @returns the hex
*/
export async function hexNamespace(namespace: string): Promise<string> {
return (await sha256(namespace)).toUpperCase()
}
function isHex(value: string): boolean {
return /^[0-9A-F]+$/iu.test(value)
}

View File

@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-magic-numbers -- Doing hex string parsing. */
import BigNumber from 'bignumber.js'
import { encodeAccountID } from '@transia/ripple-address-codec'
import BigNumber from 'bignumber.js'
import { XrplError } from '../errors'

View File

@@ -1,5 +1,5 @@
import { assert } from 'chai'
import { decode } from '@transia/ripple-binary-codec'
import { assert } from 'chai'
import {
AccountSet,

View File

@@ -1,5 +1,5 @@
import { assert } from 'chai'
import { decode } from '@transia/ripple-binary-codec'
import { assert } from 'chai'
import {
AccountSet,

View File

@@ -1,6 +1,6 @@
import { Client } from '@transia/xrpl'
import { assert } from 'chai'
import _ from 'lodash'
import { Client } from 'xrpl'
import {
convertStringToHex,

View File

@@ -1,7 +1,7 @@
import { decode } from '@transia/ripple-binary-codec'
import { assert } from 'chai'
import omit from 'lodash/omit'
import throttle from 'lodash/throttle'
import { decode } from '@transia/ripple-binary-codec'
import {
Client,

View File

@@ -1,8 +1,8 @@
import fs from 'fs'
import path from 'path'
import { assert } from 'chai'
import { encode } from '@transia/ripple-binary-codec'
import { assert } from 'chai'
import { OfferCreate, Transaction, ValidationError } from '../../src'
import {

View File

@@ -1,5 +1,5 @@
import { assert } from 'chai'
import { decode } from '@transia/ripple-binary-codec'
import { assert } from 'chai'
import { NFTokenMint, Payment, Transaction } from '../../src'
import ECDSA from '../../src/ECDSA'

View File

@@ -1,5 +1,5 @@
import { assert } from 'chai'
import { decode, encode } from '@transia/ripple-binary-codec'
import { assert } from 'chai'
import { Transaction, ValidationError } from '../../src'
import Wallet from '../../src/Wallet'