ts: Add associated client code (#626)

This commit is contained in:
Armani Ferrante 2021-08-20 11:39:07 -07:00 committed by GitHub
parent 541dbfbe37
commit 3be29425ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -241,6 +241,25 @@ export class AccountClient {
programId: this._programId,
});
}
/**
* Function returning the associated account. Args are keys to associate.
* Order matters.
*/
async associated(...args: Array<PublicKey | Buffer>): Promise<any> {
const addr = await this.associatedAddress(...args);
return await this.fetch(addr);
}
/**
* Function returning the associated address. Args are keys to associate.
* Order matters.
*/
async associatedAddress(
...args: Array<PublicKey | Buffer>
): Promise<PublicKey> {
return await pubkeyUtil.associated(this._programId, ...args);
}
}
/**