From 1152f9019a142e4345548008000e73411cf40230 Mon Sep 17 00:00:00 2001 From: acheron <98934430+acheroncrypto@users.noreply.github.com> Date: Tue, 3 Sep 2024 23:57:30 +0200 Subject: [PATCH] ts: Upgrade `typescript` to 5.5.4 (#3221) --- CHANGELOG.md | 1 + ts/packages/anchor/package.json | 2 +- .../anchor/src/program/namespace/methods.ts | 4 +--- .../anchor/src/program/namespace/simulate.ts | 23 +++++++------------ ts/yarn.lock | 7 +++++- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4002405dd4..63b6a1cbf7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,6 +84,7 @@ The minor version will be incremented upon a breaking change and the patch versi - docker: Upgrade `node` to 20.16.0 LTS ([#3179](https://github.com/coral-xyz/anchor/pull/3179)). - ts: Change the `Program` constructor's `idl` parameter type to `any` ([#3181](https://github.com/coral-xyz/anchor/pull/3181)). - lang, spl: Remove `borsh 0.9` support ([#3199](https://github.com/coral-xyz/anchor/pull/3199)). +- ts: Upgrade `typescript` to `5.5.4` and remove the generic parameters of `SimulateResponse` ([#3221](https://github.com/coral-xyz/anchor/pull/3221)). ## [0.30.1] - 2024-06-20 diff --git a/ts/packages/anchor/package.json b/ts/packages/anchor/package.json index 9e14d67f1a..5e78c50279 100644 --- a/ts/packages/anchor/package.json +++ b/ts/packages/anchor/package.json @@ -76,7 +76,7 @@ "ts-node": "^9.0.0", "tslib": "^2.3.1", "typedoc": "^0.22.10", - "typescript": "^4.5.2" + "typescript": "^5.5.4" }, "files": [ "dist", diff --git a/ts/packages/anchor/src/program/namespace/methods.ts b/ts/packages/anchor/src/program/namespace/methods.ts index 471c21158a..7cce79dce8 100644 --- a/ts/packages/anchor/src/program/namespace/methods.ts +++ b/ts/packages/anchor/src/program/namespace/methods.ts @@ -332,9 +332,7 @@ export class MethodsBuilder< }); } - public async simulate( - options?: ConfirmOptions - ): Promise> { + public async simulate(options?: ConfirmOptions): Promise { if (this._resolveAccounts) { await this._accountsResolver.resolve(); } diff --git a/ts/packages/anchor/src/program/namespace/simulate.ts b/ts/packages/anchor/src/program/namespace/simulate.ts index 8735fa26e9..3d0c7ee508 100644 --- a/ts/packages/anchor/src/program/namespace/simulate.ts +++ b/ts/packages/anchor/src/program/namespace/simulate.ts @@ -5,7 +5,7 @@ import { splitArgsAndCtx } from "../context.js"; import { TransactionFn } from "./transaction.js"; import { EventParser, Event } from "../event.js"; import { Coder } from "../../coder/index.js"; -import { Idl, IdlEvent } from "../../idl.js"; +import { Idl, IdlEvent, IdlTypeDef } from "../../idl.js"; import { translateError } from "../../error.js"; import { AllEvents, @@ -51,11 +51,11 @@ export default class SimulateFactory { throw new Error("Simulated logs not found"); } - const events = []; + const events: Event[] = []; if (idl.events) { let parser = new EventParser(programId, coder); for (const event of parser.parseLogs(logs)) { - events.push(event as AllEvents[number]); + events.push(event); } } return { events, raw: logs }; @@ -102,11 +102,7 @@ export default class SimulateFactory { export type SimulateNamespace< IDL extends Idl = Idl, I extends AllInstructions = AllInstructions -> = MakeInstructionsNamespace< - IDL, - I, - Promise[number], IdlTypes>> ->; +> = MakeInstructionsNamespace>; /** * SimulateFn is a single method generated from an IDL. It simulates a method @@ -117,13 +113,10 @@ export type SimulateNamespace< export type SimulateFn< IDL extends Idl = Idl, I extends AllInstructions = AllInstructions -> = InstructionContextFn< - IDL, - I, - Promise[number], IdlTypes>> ->; +> = InstructionContextFn>; -export type SimulateResponse = { - events: readonly Event[]; +// TODO: Infer event types +export type SimulateResponse = { + events: readonly Event[]; raw: readonly string[]; }; diff --git a/ts/yarn.lock b/ts/yarn.lock index 3eb1983180..bf16fa2405 100644 --- a/ts/yarn.lock +++ b/ts/yarn.lock @@ -4803,7 +4803,7 @@ typedoc@^0.22.10: minimatch "^5.1.0" shiki "^0.10.1" -typescript@*, typescript@^4.5.2: +typescript@*: version "4.9.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.3.tgz#3aea307c1746b8c384435d8ac36b8a2e580d85db" integrity sha512-CIfGzTelbKNEnLpLdGFgdyKhG23CKdKgQPOBc+OUNrkJ2vr+KSzsSV5kq5iWhEQbok+quxgGzrAtGWCyU7tHnA== @@ -4813,6 +4813,11 @@ typescript@=4.6.2: resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4" integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg== +typescript@^5.5.4: + version "5.5.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba" + integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q== + universalify@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.2.0.tgz#6451760566fa857534745ab1dde952d1b1761be0"