From c836f8a0b52b1a6ba4c2998a136bbe8e9248e810 Mon Sep 17 00:00:00 2001 From: streamich Date: Mon, 11 Mar 2024 10:05:51 +0100 Subject: [PATCH] =?UTF-8?q?style:=20=F0=9F=92=84=20run=20Prettier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/web3/adl/hamt-crdt/Hamt.ts | 2 +- src/web3/adl/hamt-crdt/HamtFrame.ts | 9 ++++++--- src/web3/adl/hamt-crdt/__tests__/HamtCrdt.spec.ts | 2 +- src/web3/codec/Codecs.ts | 4 ++-- src/web3/codec/codecs/cbor.ts | 4 ++-- src/web3/codec/codecs/writer.ts | 2 +- src/web3/codec/index.ts | 8 ++++---- src/web3/codec/types.ts | 2 +- 8 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/web3/adl/hamt-crdt/Hamt.ts b/src/web3/adl/hamt-crdt/Hamt.ts index 9a978d40c8..bd8245361e 100644 --- a/src/web3/adl/hamt-crdt/Hamt.ts +++ b/src/web3/adl/hamt-crdt/Hamt.ts @@ -38,7 +38,7 @@ export class Hamt implements types.HamtApi { const future = new Defer(); this._loading = future.promise; try { - const [prev, seq, ops, data] = await this.deps.cas.get(cid) as types.HamtRootFrameDto; + const [prev, seq, ops, data] = (await this.deps.cas.get(cid)) as types.HamtRootFrameDto; this.prev = prev; this.seq = seq; this._root.loadDto(data, null); diff --git a/src/web3/adl/hamt-crdt/HamtFrame.ts b/src/web3/adl/hamt-crdt/HamtFrame.ts index 01d1c999ef..d7db93f788 100644 --- a/src/web3/adl/hamt-crdt/HamtFrame.ts +++ b/src/web3/adl/hamt-crdt/HamtFrame.ts @@ -15,7 +15,10 @@ export class HamtFrame { /** Maybe instead of `_dirty`, just consider `id` === `null` to mean there are unsaved changes. */ protected _dirty: boolean = false; - constructor(protected readonly cas: CidCasStruct, public cid: Cid | null) {} + constructor( + protected readonly cas: CidCasStruct, + public cid: Cid | null, + ) {} protected async ensureLoaded(): Promise { if (this._loading) return this._loading.promise; @@ -34,7 +37,7 @@ export class HamtFrame { const id = this.cid; if (!id) throw new Error('ID_NOT_SET'); this._loading = new Defer(); - const data = await this.cas.get(id) as types.HamtFrameDto; + const data = (await this.cas.get(id)) as types.HamtFrameDto; this.loadDto(data, id); this._loading.resolve(); this._loading = null; @@ -207,7 +210,7 @@ export class HamtFrame { } public toDto(): types.HamtFrameDto { - const children = this._children.map((child) => child ? child.cid : null); + const children = this._children.map((child) => (child ? child.cid : null)); const dto: types.HamtFrameDto = [this._entries, children]; return dto; } diff --git a/src/web3/adl/hamt-crdt/__tests__/HamtCrdt.spec.ts b/src/web3/adl/hamt-crdt/__tests__/HamtCrdt.spec.ts index a123874030..bc3089efa2 100644 --- a/src/web3/adl/hamt-crdt/__tests__/HamtCrdt.spec.ts +++ b/src/web3/adl/hamt-crdt/__tests__/HamtCrdt.spec.ts @@ -212,7 +212,7 @@ describe('HamtCrdt', () => { const [cid] = await hamt.save(); expect(cas._map.size).toBe(size + 1); const blob = await cas.get(cid); - const found = toArr(blob).findIndex(octet => octet === data); + const found = toArr(blob).findIndex((octet) => octet === data); expect(found > -1).toBe(true); }); diff --git a/src/web3/codec/Codecs.ts b/src/web3/codec/Codecs.ts index 1e4ecf5fbd..7229348474 100644 --- a/src/web3/codec/Codecs.ts +++ b/src/web3/codec/Codecs.ts @@ -1,5 +1,5 @@ -import {MulticodecIpld} from "../multiformats"; -import type {IpldCodec} from "./types"; +import {MulticodecIpld} from '../multiformats'; +import type {IpldCodec} from './types'; export class Codecs { protected readonly map = new Map(); diff --git a/src/web3/codec/codecs/cbor.ts b/src/web3/codec/codecs/cbor.ts index 9c3387c93b..4fc3bcc0f7 100644 --- a/src/web3/codec/codecs/cbor.ts +++ b/src/web3/codec/codecs/cbor.ts @@ -11,13 +11,13 @@ const encoder = new (class extends CborEncoderDag { } })(writer); -const decoder = new class extends CborDecoderDag { +const decoder = new (class extends CborDecoderDag { public readTagRaw(tag: number): Cid | unknown { const value = this.val(); if (tag === 42) return Cid.fromBinary(value as Uint8Array); throw new Error('UNKNOWN_TAG'); } -} +})(); export const cbor: IpldCodec = { name: 'DAG-CBOR', diff --git a/src/web3/codec/codecs/writer.ts b/src/web3/codec/codecs/writer.ts index 2d093e6085..fd58d8bb9f 100644 --- a/src/web3/codec/codecs/writer.ts +++ b/src/web3/codec/codecs/writer.ts @@ -1,3 +1,3 @@ -import {Writer} from "../../../util/buffers/Writer"; +import {Writer} from '../../../util/buffers/Writer'; export const writer = new Writer(); diff --git a/src/web3/codec/index.ts b/src/web3/codec/index.ts index b373fe712c..77f5672358 100644 --- a/src/web3/codec/index.ts +++ b/src/web3/codec/index.ts @@ -1,7 +1,7 @@ -import {MulticodecIpld} from "../multiformats"; -import {Codecs} from "./Codecs"; -import {raw} from "./codecs/raw"; -import {cbor} from "./codecs/cbor"; +import {MulticodecIpld} from '../multiformats'; +import {Codecs} from './Codecs'; +import {raw} from './codecs/raw'; +import {cbor} from './codecs/cbor'; export * from './types'; export * from './Codecs'; diff --git a/src/web3/codec/types.ts b/src/web3/codec/types.ts index 4d38042ca3..c02c6ae304 100644 --- a/src/web3/codec/types.ts +++ b/src/web3/codec/types.ts @@ -1,4 +1,4 @@ -import type {BinaryJsonDecoder, BinaryJsonEncoder} from "../../json-pack/types"; +import type {BinaryJsonDecoder, BinaryJsonEncoder} from '../../json-pack/types'; export interface IpldCodec { name: string;