Armani Ferrante 3 éve
szülő
commit
900cc7389a
2 módosított fájl, 12 hozzáadás és 10 törlés
  1. 8 8
      ts/src/coder/borsh/state.ts
  2. 4 2
      ts/src/program/namespace/state.ts

+ 8 - 8
ts/src/coder/borsh/state.ts

@@ -35,12 +35,12 @@ export class BorshStateCoder {
     return this.layout.decode(data);
   }
 
-	// Calculates unique 8 byte discriminator prepended to all anchor state accounts.
-	async discriminator(name: string): Promise<Buffer> {
-		let ns = features.isSet("anchor-deprecated-state") ? "account" : "state";
-		return Buffer.from(sha256.digest(`${ns}:${name}`)).slice(
-			0,
-			this.header.discriminatorSize()
-		);
-	}
+  // Calculates unique 8 byte discriminator prepended to all anchor state accounts.
+  async discriminator(name: string): Promise<Buffer> {
+    let ns = features.isSet("anchor-deprecated-state") ? "account" : "state";
+    return Buffer.from(sha256.digest(`${ns}:${name}`)).slice(
+      0,
+      this.header.discriminatorSize()
+    );
+  }
 }

+ 4 - 2
ts/src/program/namespace/state.ts

@@ -85,7 +85,7 @@ export class StateClient<IDL extends Idl> {
     public readonly provider: Provider = getProvider(),
     /**
      * Returns the coder. Note that we use BorshCoder and not `Coder` because
-		 * the deprecated state abstraction only applies to Anchor programs.
+     * the deprecated state abstraction only applies to Anchor programs.
      */
     public readonly coder: BorshCoder = new BorshCoder(idl)
   ) {
@@ -173,7 +173,9 @@ export class StateClient<IDL extends Idl> {
       throw new Error("State is not specified in IDL.");
     }
 
-    const expectedDiscriminator = await this.coder.state.discriminator(state.struct.name);
+    const expectedDiscriminator = await this.coder.state.discriminator(
+      state.struct.name
+    );
     const discriminator = this.coder.state.header.parseDiscriminator(
       accountInfo.data
     );