Browse Source

ts: Change the `Program` constructor's `idl` parameter type to `any` (#3181)

acheron 1 year ago
parent
commit
04b2153007
2 changed files with 5 additions and 6 deletions
  1. 1 0
      CHANGELOG.md
  2. 4 6
      ts/packages/anchor/src/program/index.ts

+ 1 - 0
CHANGELOG.md

@@ -70,6 +70,7 @@ The minor version will be incremented upon a breaking change and the patch versi
 - lang, ts: Remove "8 byte" requirement from discriminator error messages ([#3161](https://github.com/coral-xyz/anchor/pull/3161)).
 - lang: Remove `discriminator` method from `Discriminator` trait ([#3163](https://github.com/coral-xyz/anchor/pull/3163)).
 - 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)).
 
 ## [0.30.1] - 2024-06-20
 

+ 4 - 6
ts/packages/anchor/src/program/index.ts

@@ -279,27 +279,25 @@ export class Program<IDL extends Idl = Idl> {
    *                          public keys of missing accounts when building instructions
    */
   public constructor(
-    idl: IDL,
+    idl: any,
     provider: Provider = getProvider(),
     coder?: Coder,
     getCustomResolver?: (
       instruction: IdlInstruction
     ) => CustomAccountResolver<IDL> | undefined
   ) {
-    const camelCasedIdl = convertIdlToCamelCase(idl);
-
     // Fields.
-    this._idl = camelCasedIdl;
+    this._idl = convertIdlToCamelCase(idl);
     this._rawIdl = idl;
     this._provider = provider;
     this._programId = translateAddress(idl.address);
-    this._coder = coder ?? new BorshCoder(camelCasedIdl);
+    this._coder = coder ?? new BorshCoder(this._idl);
     this._events = new EventManager(this._programId, provider, this._coder);
 
     // Dynamic namespaces.
     const [rpc, instruction, transaction, account, simulate, methods, views] =
       NamespaceFactory.build(
-        camelCasedIdl,
+        this._idl,
         this._coder,
         this._programId,
         provider,