ts prettier
This commit is contained in:
parent
e9f8623337
commit
900cc7389a
|
@ -35,12 +35,12 @@ export class BorshStateCoder {
|
||||||
return this.layout.decode(data);
|
return this.layout.decode(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculates unique 8 byte discriminator prepended to all anchor state accounts.
|
// Calculates unique 8 byte discriminator prepended to all anchor state accounts.
|
||||||
async discriminator(name: string): Promise<Buffer> {
|
async discriminator(name: string): Promise<Buffer> {
|
||||||
let ns = features.isSet("anchor-deprecated-state") ? "account" : "state";
|
let ns = features.isSet("anchor-deprecated-state") ? "account" : "state";
|
||||||
return Buffer.from(sha256.digest(`${ns}:${name}`)).slice(
|
return Buffer.from(sha256.digest(`${ns}:${name}`)).slice(
|
||||||
0,
|
0,
|
||||||
this.header.discriminatorSize()
|
this.header.discriminatorSize()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ export class StateClient<IDL extends Idl> {
|
||||||
public readonly provider: Provider = getProvider(),
|
public readonly provider: Provider = getProvider(),
|
||||||
/**
|
/**
|
||||||
* Returns the coder. Note that we use BorshCoder and not `Coder` because
|
* 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)
|
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.");
|
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(
|
const discriminator = this.coder.state.header.parseDiscriminator(
|
||||||
accountInfo.data
|
accountInfo.data
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue