This PR addresses the concerns in #51 and allows callers to specify their own dynamic programId. If no programId is specified then the default value from programId.ts is used.
This feature will allow callers to decouple their internal management of their programId's from the generated code files from anchor-client-gen, making anchor-client-gen completely transparent to the integrating project, but still maintains backwards compatibility with the existing API.
example:
static async fetch(
c: Connection,
address: PublicKey,
programId: PublicKey = PROGRAM_ID
): Promise<Counter | null> {
const info = await c.getAccountInfo(address)
if (info === null) {
return null
}
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program")
}
return this.decode(info.data)
}
This PR addresses the concerns in #51 and allows callers to specify their own dynamic programId. If no programId is specified then the default value from
programId.ts
is used.This feature will allow callers to decouple their internal management of their programId's from the generated code files from
anchor-client-gen
, makinganchor-client-ge
n completely transparent to the integrating project, but still maintains backwards compatibility with the existing API.example: