Update linter peer dependencies (#2168)

This commit is contained in:
Jackson Mills
2023-02-07 15:00:55 -08:00
committed by GitHub
parent 7dd38f6a76
commit bef2f79fee
15 changed files with 5327 additions and 2001 deletions

View File

@@ -86,15 +86,6 @@ class Wallet {
public readonly classicAddress: string
public readonly seed?: string
/**
* Alias for wallet.classicAddress.
*
* @returns The wallet's classic address.
*/
public get address(): string {
return this.classicAddress
}
/**
* Creates a new Wallet.
*
@@ -120,6 +111,15 @@ class Wallet {
this.seed = opts.seed
}
/**
* Alias for wallet.classicAddress.
*
* @returns The wallet's classic address.
*/
public get address(): string {
return this.classicAddress
}
/**
* Generates a new Wallet using a generated seed.
*

View File

@@ -74,6 +74,15 @@ export default class WSWrapper extends EventEmitter {
}
}
/**
* Get the ready state of the websocket.
*
* @returns The Websocket's ready state.
*/
public get readyState(): number {
return this.ws.readyState
}
/**
* Closes the websocket.
*
@@ -94,13 +103,4 @@ export default class WSWrapper extends EventEmitter {
public send(message: string): void {
this.ws.send(message)
}
/**
* Get the ready state of the websocket.
*
* @returns The Websocket's ready state.
*/
public get readyState(): number {
return this.ws.readyState
}
}

View File

@@ -212,6 +212,24 @@ export class Connection extends EventEmitter {
}
}
/**
* Gets the state of the websocket.
*
* @returns The Websocket's ready state.
*/
private get state(): WebsocketState {
return this.ws ? this.ws.readyState : WebSocket.CLOSED
}
/**
* Returns whether the server should be connected.
*
* @returns Whether the server should be connected.
*/
private get shouldBeConnected(): boolean {
return this.ws !== null
}
/**
* Returns whether the websocket is connected.
*
@@ -367,7 +385,7 @@ export class Connection extends EventEmitter {
return this.url ?? ''
}
// eslint-disable-next-line @typescript-eslint/no-empty-function -- Does nothing on default
// eslint-disable-next-line @typescript-eslint/no-empty-function, class-methods-use-this -- Does nothing on default
public readonly trace: (id: string, message: string) => void = () => {}
/**
@@ -410,24 +428,6 @@ export class Connection extends EventEmitter {
}
}
/**
* Gets the state of the websocket.
*
* @returns The Websocket's ready state.
*/
private get state(): WebsocketState {
return this.ws ? this.ws.readyState : WebSocket.CLOSED
}
/**
* Returns whether the server should be connected.
*
* @returns Whether the server should be connected.
*/
private get shouldBeConnected(): boolean {
return this.ws !== null
}
/**
* Handler for what to do once the connection to the server is open.
*

View File

@@ -1,3 +1,4 @@
/* eslint-disable jsdoc/require-jsdoc -- Request has many aliases, but they don't need unique docs */
/* eslint-disable @typescript-eslint/member-ordering -- TODO: remove when instance methods aren't members */
/* eslint-disable max-lines -- Client is a large file w/ lots of imports/exports */
import * as assert from 'assert'

View File

@@ -33,6 +33,26 @@ class InnerNode extends Node {
this.empty = true
}
/**
* Get the hash of a LeafNode.
*
* @returns Hash of the LeafNode.
*/
public get hash(): string {
if (this.empty) {
return HEX_ZERO
}
let hex = ''
for (let iter = 0; iter <= SLOT_MAX; iter++) {
const child = this.leaves[iter]
const hash: string = child == null ? HEX_ZERO : child.hash
hex += hash
}
const prefix = HashPrefix.INNER_NODE.toString(HEX)
return sha512Half(prefix + hex)
}
/**
* Adds an item to the InnerNode.
*
@@ -99,26 +119,6 @@ class InnerNode extends Node {
}
return this.leaves[slot]
}
/**
* Get the hash of a LeafNode.
*
* @returns Hash of the LeafNode.
*/
public get hash(): string {
if (this.empty) {
return HEX_ZERO
}
let hex = ''
for (let iter = 0; iter <= SLOT_MAX; iter++) {
const child = this.leaves[iter]
const hash: string = child == null ? HEX_ZERO : child.hash
hex += hash
}
const prefix = HashPrefix.INNER_NODE.toString(HEX)
return sha512Half(prefix + hex)
}
}
export default InnerNode

View File

@@ -28,18 +28,6 @@ class LeafNode extends Node {
this.data = data
}
/**
* Add item to Leaf.
*
* @param tag - Index of the Node.
* @param node - Node to insert.
* @throws When called, because LeafNodes cannot addItem.
*/
public addItem(tag: string, node: Node): void {
throw new XrplError('Cannot call addItem on a LeafNode')
this.addItem(tag, node)
}
/**
* Get the hash of a LeafNode.
*
@@ -64,6 +52,18 @@ class LeafNode extends Node {
throw new XrplError('Tried to hash a SHAMap node of unknown type.')
}
}
/**
* Add item to Leaf.
*
* @param tag - Index of the Node.
* @param node - Node to insert.
* @throws When called, because LeafNodes cannot addItem.
*/
public addItem(tag: string, node: Node): void {
throw new XrplError('Cannot call addItem on a LeafNode')
this.addItem(tag, node)
}
}
export default LeafNode

View File

@@ -2,6 +2,10 @@ import InnerNode from './InnerNode'
import LeafNode from './LeafNode'
import { NodeType } from './node'
/**
* SHAMap is the hash structure used to model ledgers.
* If the root hash is equivalent, that means all nodes should be equivalent as well.
*/
class SHAMap {
public root: InnerNode
@@ -12,6 +16,15 @@ class SHAMap {
this.root = new InnerNode(0)
}
/**
* Get the hash of the SHAMap.
*
* @returns The hash of the root of the SHAMap.
*/
public get hash(): string {
return this.root.hash
}
/**
* Add an item to the SHAMap.
*
@@ -22,15 +35,6 @@ class SHAMap {
public addItem(tag: string, data: string, type: NodeType): void {
this.root.addItem(tag, new LeafNode(tag, data, type))
}
/**
* Get the hash of the SHAMap.
*
* @returns The hash of the root of the SHAMap.
*/
public get hash(): string {
return this.root.hash
}
}
export * from './node'

View File

@@ -9,6 +9,6 @@ export enum NodeType {
* Abstract base class for SHAMapNode.
*/
export abstract class Node {
public abstract addItem(_tag: string, _node: Node): void
public abstract get hash(): string
public abstract addItem(_tag: string, _node: Node): void
}

View File

@@ -14,10 +14,7 @@
"esModuleInterop": true,
"suppressImplicitAnyIndexErrors": false,
"resolveJsonModule": true,
"preserveSymlinks": true,
"preserveSymlinks": true
},
"include": [
"src/**/*.ts",
"src/**/*.json"
]
"include": ["src/**/*.ts", "src/**/*.json"]
}