Skip to content

Commit

Permalink
ts: Upgrade typescript to 5.5.4 (#3221)
Browse files Browse the repository at this point in the history
  • Loading branch information
acheroncrypto authored Sep 3, 2024
1 parent afcf493 commit 1152f90
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion ts/packages/anchor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 1 addition & 3 deletions ts/packages/anchor/src/program/namespace/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,7 @@ export class MethodsBuilder<
});
}

public async simulate(
options?: ConfirmOptions
): Promise<SimulateResponse<any, any>> {
public async simulate(options?: ConfirmOptions): Promise<SimulateResponse> {
if (this._resolveAccounts) {
await this._accountsResolver.resolve();
}
Expand Down
23 changes: 8 additions & 15 deletions ts/packages/anchor/src/program/namespace/simulate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<IDL>[number]);
events.push(event);
}
}
return { events, raw: logs };
Expand Down Expand Up @@ -102,11 +102,7 @@ export default class SimulateFactory {
export type SimulateNamespace<
IDL extends Idl = Idl,
I extends AllInstructions<IDL> = AllInstructions<IDL>
> = MakeInstructionsNamespace<
IDL,
I,
Promise<SimulateResponse<AllEvents<IDL>[number], IdlTypes<IDL>>>
>;
> = MakeInstructionsNamespace<IDL, I, Promise<SimulateResponse>>;

/**
* SimulateFn is a single method generated from an IDL. It simulates a method
Expand All @@ -117,13 +113,10 @@ export type SimulateNamespace<
export type SimulateFn<
IDL extends Idl = Idl,
I extends AllInstructions<IDL> = AllInstructions<IDL>
> = InstructionContextFn<
IDL,
I,
Promise<SimulateResponse<AllEvents<IDL>[number], IdlTypes<IDL>>>
>;
> = InstructionContextFn<IDL, I, Promise<SimulateResponse>>;

export type SimulateResponse<E extends IdlEvent, Defined> = {
events: readonly Event<E, Defined>[];
// TODO: Infer event types
export type SimulateResponse = {
events: readonly Event[];
raw: readonly string[];
};
7 changes: 6 additions & 1 deletion ts/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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==
Expand All @@ -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"
Expand Down

0 comments on commit 1152f90

Please sign in to comment.