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