mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +00:00
build: update typescript version (#1601)
This commit is contained in:
committed by
Mayukha Vadari
parent
148cac6f3f
commit
0dc1e08350
18
package-lock.json
generated
18
package-lock.json
generated
@@ -29,7 +29,7 @@
|
||||
"@types/puppeteer": "5.4.4",
|
||||
"@typescript-eslint/eslint-plugin": "^4.30.0",
|
||||
"@typescript-eslint/parser": "^4.0.0",
|
||||
"@xrplf/eslint-config": "^1.3",
|
||||
"@xrplf/eslint-config": "^1.3.0",
|
||||
"@xrplf/prettier-config": "^1.2.0",
|
||||
"assert": "^2.0.0",
|
||||
"buffer": "^6.0.2",
|
||||
@@ -58,8 +58,8 @@
|
||||
"stream-browserify": "^3.0.0",
|
||||
"stream-http": "3.2.0",
|
||||
"ts-loader": "^9.2.5",
|
||||
"ts-node": "^10.1.0",
|
||||
"typescript": "^3.9.10",
|
||||
"ts-node": "^10.2.1",
|
||||
"typescript": "^4.4.2",
|
||||
"url": "^0.11.0",
|
||||
"webpack": "^5.6.0",
|
||||
"webpack-bundle-analyzer": "^4.1.0",
|
||||
@@ -8220,9 +8220,9 @@
|
||||
"integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g=="
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "3.9.10",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz",
|
||||
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==",
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz",
|
||||
"integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
@@ -15207,9 +15207,9 @@
|
||||
"integrity": "sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g=="
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.9.10",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.10.tgz",
|
||||
"integrity": "sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==",
|
||||
"version": "4.4.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz",
|
||||
"integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==",
|
||||
"dev": true
|
||||
},
|
||||
"unbox-primitive": {
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
"@types/puppeteer": "5.4.4",
|
||||
"@typescript-eslint/eslint-plugin": "^4.30.0",
|
||||
"@typescript-eslint/parser": "^4.0.0",
|
||||
"@xrplf/eslint-config": "^1.3",
|
||||
"@xrplf/eslint-config": "^1.3.0",
|
||||
"@xrplf/prettier-config": "^1.2.0",
|
||||
"assert": "^2.0.0",
|
||||
"buffer": "^6.0.2",
|
||||
@@ -68,8 +68,8 @@
|
||||
"stream-browserify": "^3.0.0",
|
||||
"stream-http": "3.2.0",
|
||||
"ts-loader": "^9.2.5",
|
||||
"ts-node": "^10.1.0",
|
||||
"typescript": "^3.9.10",
|
||||
"ts-node": "^10.2.1",
|
||||
"typescript": "^4.4.2",
|
||||
"url": "^0.11.0",
|
||||
"webpack": "^5.6.0",
|
||||
"webpack-bundle-analyzer": "^4.1.0",
|
||||
|
||||
@@ -349,8 +349,9 @@ export class Connection extends EventEmitter {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Must be a JSON dictionary
|
||||
data = JSON.parse(message)
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- Errors have messages
|
||||
if (error instanceof Error) {
|
||||
this.emit('error', 'badMessage', error.message, message)
|
||||
}
|
||||
return
|
||||
}
|
||||
if (data.type == null && data.error) {
|
||||
@@ -366,11 +367,12 @@ export class Connection extends EventEmitter {
|
||||
try {
|
||||
this.requestManager.handleResponse(data)
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- Errors have messages
|
||||
if (error instanceof Error) {
|
||||
this.emit('error', 'badMessage', error.message, message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the state of the websocket.
|
||||
@@ -435,12 +437,14 @@ export class Connection extends EventEmitter {
|
||||
this.connectionManager.resolveAllAwaiting()
|
||||
this.emit('connected')
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
this.connectionManager.rejectAllAwaiting(error)
|
||||
// Ignore this error, propagate the root cause.
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function -- Need empty catch
|
||||
await this.disconnect().catch(() => {})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private intentionalDisconnect(): void {
|
||||
const retryTimeout = this.retryConnectionBackoff.duration()
|
||||
|
||||
@@ -17,8 +17,8 @@ export default class RequestManager {
|
||||
private readonly promisesAwaitingResponse = new Map<
|
||||
string | number,
|
||||
{
|
||||
resolve: (value?: Response | PromiseLike<Response>) => void
|
||||
reject: (value?: Error) => void
|
||||
resolve: (value: Response | PromiseLike<Response>) => void
|
||||
reject: (value: Error) => void
|
||||
timer: NodeJS.Timeout
|
||||
}
|
||||
>()
|
||||
@@ -109,11 +109,12 @@ export default class RequestManager {
|
||||
if (timer.unref) {
|
||||
timer.unref()
|
||||
}
|
||||
const newPromise = new Promise(
|
||||
(resolve: (value?: Response | PromiseLike<Response>) => void, reject) => {
|
||||
const newPromise = new Promise<Response>(
|
||||
(resolve: (value: Response | PromiseLike<Response>) => void, reject) => {
|
||||
this.promisesAwaitingResponse.set(newId, { resolve, reject, timer })
|
||||
},
|
||||
)
|
||||
|
||||
return [newId, newRequest, newPromise]
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import { isValidClassicAddress } from 'ripple-address-codec'
|
||||
|
||||
import type { Client } from '..'
|
||||
import { errors } from '../common'
|
||||
import { RippledError } from '../common/errors'
|
||||
import { RippledError, XRPLFaucetError } from '../common/errors'
|
||||
import { GeneratedAddress } from '../utils/generateAddress'
|
||||
|
||||
import Wallet from '.'
|
||||
@@ -104,7 +104,7 @@ async function generateFaucetWallet(
|
||||
resolve(fundWallet)
|
||||
} else {
|
||||
reject(
|
||||
new errors.XRPLFaucetError(
|
||||
new XRPLFaucetError(
|
||||
`Unable to fund address with faucet after waiting ${
|
||||
INTERVAL_SECONDS * MAX_ATTEMPTS
|
||||
} seconds`,
|
||||
@@ -112,11 +112,15 @@ async function generateFaucetWallet(
|
||||
)
|
||||
}
|
||||
} catch (err) {
|
||||
reject(new errors.XRPLFaucetError(err))
|
||||
if (err instanceof Error) {
|
||||
reject(new XRPLFaucetError(err.message))
|
||||
}
|
||||
|
||||
reject(err)
|
||||
}
|
||||
} else {
|
||||
reject(
|
||||
new errors.XRPLFaucetError(
|
||||
new XRPLFaucetError(
|
||||
`The faucet account classic address is undefined`,
|
||||
),
|
||||
)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { assert } from 'chai'
|
||||
import { assert, expect } from 'chai'
|
||||
import binary from 'ripple-binary-codec'
|
||||
|
||||
import { ValidationError } from '../../src/common/errors'
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
import { setupClient, teardownClient } from '../setupClient'
|
||||
@@ -347,22 +348,29 @@ describe('client.sign', function () {
|
||||
Fee: '12',
|
||||
}
|
||||
const secret = 'shsWGZcmZz6YsWWmcnpfr6fLTdtFV'
|
||||
|
||||
try {
|
||||
this.client.sign(JSON.stringify(offerCreate), secret)
|
||||
return await Promise.reject(
|
||||
new Error('this.client.sign should have thrown'),
|
||||
)
|
||||
} catch (error) {
|
||||
if (error instanceof ValidationError) {
|
||||
assert.equal(error.name, 'ValidationError')
|
||||
assert.equal(
|
||||
error.message,
|
||||
'Serialized transaction does not match original txJSON. See `error.data`',
|
||||
)
|
||||
assert.deepEqual(error.data.diff, {
|
||||
expect(error.data).to.deep.include({
|
||||
diff: {
|
||||
TakerGets: {
|
||||
value: '3.14',
|
||||
},
|
||||
},
|
||||
})
|
||||
} else {
|
||||
assert(false)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -3,6 +3,7 @@ import { assert } from 'chai'
|
||||
import rippled from '../fixtures/rippled'
|
||||
import {setupClient, teardownClient} from '../setupClient'
|
||||
|
||||
|
||||
describe('Subscription', function () {
|
||||
beforeEach(setupClient)
|
||||
afterEach(teardownClient)
|
||||
|
||||
@@ -262,6 +262,10 @@ describe('Connection', function () {
|
||||
try {
|
||||
await this.client.connect()
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error)) {
|
||||
throw error
|
||||
}
|
||||
|
||||
assert.instanceOf(error, DisconnectedError)
|
||||
assert.strictEqual(
|
||||
error.message,
|
||||
|
||||
@@ -78,9 +78,12 @@ export default function createMockRippled(port: number): MockedWebSocketServer {
|
||||
)
|
||||
}
|
||||
} catch (err) {
|
||||
if (!(err instanceof Error)) {
|
||||
throw err
|
||||
}
|
||||
|
||||
if (!mock.suppressOutput) {
|
||||
// eslint-disable-next-line no-console, @typescript-eslint/restrict-template-expressions -- Error
|
||||
console.error(`Error: ${err.message}`)
|
||||
console.error(err.message)
|
||||
}
|
||||
if (request != null) {
|
||||
conn.send(
|
||||
|
||||
@@ -66,6 +66,10 @@ export async function assertRejects(
|
||||
await promise
|
||||
assert(false, 'Expected an error to be thrown')
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error)) {
|
||||
throw error
|
||||
}
|
||||
|
||||
assert(error instanceof instanceOf, error.message)
|
||||
if (typeof message === 'string') {
|
||||
assert.strictEqual(error.message, message)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { ValidationError } from '../../src/common/errors'
|
||||
import { ValidationError, XrplError } from '../../src/common/errors'
|
||||
import { computeLedgerHash } from '../../src/utils'
|
||||
import requests from '../fixtures/requests'
|
||||
import responses from '../fixtures/responses'
|
||||
@@ -27,6 +27,10 @@ describe('computeLedgerHash', function () {
|
||||
try {
|
||||
hash = computeLedgerHash(ledger, { computeTreeHashes: true })
|
||||
} catch (error) {
|
||||
if (!(error instanceof XrplError)) {
|
||||
throw error
|
||||
}
|
||||
|
||||
assert(error instanceof ValidationError)
|
||||
if (error instanceof ValidationError) {
|
||||
assert.strictEqual(
|
||||
|
||||
Reference in New Issue
Block a user