fix: catch up to account field renaming
This commit is contained in:
@ -82,8 +82,8 @@ function jsonRpcResult(resultDescription: any) {
|
||||
*/
|
||||
const AccountInfoResult = struct({
|
||||
executable: 'boolean',
|
||||
loader_program_id: 'array',
|
||||
program_id: 'array',
|
||||
loader: 'array',
|
||||
owner: 'array',
|
||||
tokens: 'number',
|
||||
userdata: 'array',
|
||||
});
|
||||
@ -149,12 +149,15 @@ const SendTokensRpcResult = jsonRpcResult('string');
|
||||
*
|
||||
* @typedef {Object} AccountInfo
|
||||
* @property {number} tokens Number of tokens assigned to the account
|
||||
* @property {PublicKey} programId Identifier of the program assigned to the account
|
||||
* @property {PublicKey} owner Identifier of the program that owns the account
|
||||
* @property {?Buffer} userdata Optional userdata assigned to the account
|
||||
* @property {PublicKey} loader Identifier of the loader for this account
|
||||
* @property {boolean} executable `true` if this account's userdata contains a loaded program
|
||||
*/
|
||||
type AccountInfo = {
|
||||
executable: boolean,
|
||||
programId: PublicKey,
|
||||
loader: PublicKey,
|
||||
owner: PublicKey,
|
||||
tokens: number,
|
||||
userdata: Buffer,
|
||||
};
|
||||
@ -268,9 +271,9 @@ export class Connection {
|
||||
|
||||
return {
|
||||
executable: result.executable,
|
||||
loader: new PublicKey(result.loader),
|
||||
owner: new PublicKey(result.owner),
|
||||
tokens: result.tokens,
|
||||
programId: new PublicKey(result.program_id),
|
||||
loaderProgramId: new PublicKey(result.loader_program_id),
|
||||
userdata: Buffer.from(result.userdata),
|
||||
};
|
||||
}
|
||||
@ -474,9 +477,9 @@ export class Connection {
|
||||
|
||||
sub.callback({
|
||||
executable: result.executable,
|
||||
loader: new PublicKey(result.loader),
|
||||
owner: new PublicKey(result.owner),
|
||||
tokens: result.tokens,
|
||||
programId: new PublicKey(result.program_id),
|
||||
loaderProgramId: new PublicKey(result.loader_program_id),
|
||||
userdata: Buffer.from(result.userdata),
|
||||
});
|
||||
return true;
|
||||
|
@ -305,9 +305,9 @@ export class Token {
|
||||
*/
|
||||
async tokenInfo(): Promise<TokenInfo> {
|
||||
const accountInfo = await this.connection.getAccountInfo(this.token);
|
||||
if (!accountInfo.programId.equals(this.programId)) {
|
||||
if (!accountInfo.owner.equals(this.programId)) {
|
||||
throw new Error(
|
||||
`Invalid token programId: ${JSON.stringify(accountInfo.programId)}`,
|
||||
`Invalid token owner: ${JSON.stringify(accountInfo.owner)}`,
|
||||
);
|
||||
}
|
||||
|
||||
@ -328,8 +328,8 @@ export class Token {
|
||||
*/
|
||||
async accountInfo(account: PublicKey): Promise<TokenAccountInfo> {
|
||||
const accountInfo = await this.connection.getAccountInfo(account);
|
||||
if (!accountInfo.programId.equals(this.programId)) {
|
||||
throw new Error(`Invalid token account programId`);
|
||||
if (!accountInfo.owner.equals(this.programId)) {
|
||||
throw new Error(`Invalid token account owner`);
|
||||
}
|
||||
|
||||
const userdata = Buffer.from(accountInfo.userdata);
|
||||
|
Reference in New Issue
Block a user