solana.js: added buffer relayer load methods

This commit is contained in:
Conner Gallagher 2022-12-14 14:45:18 -07:00
parent be3bcd7dd6
commit 23acc15a83
1 changed files with 34 additions and 0 deletions

View File

@ -281,6 +281,30 @@ export class BufferRelayerAccount extends Account<types.BufferRelayerAccountData
};
}
public async toAccountsJSON(
_bufferRelayer?: types.BufferRelayerAccountData,
_queueAccount?: QueueAccount,
_queue?: types.OracleQueueAccountData
): Promise<BufferRelayerAccountsJSON> {
const { bufferRelayer, queue, permission, escrow } =
await this.fetchAccounts(_bufferRelayer, _queueAccount, _queue);
return {
publicKey: this.publicKey,
balance: this.program.mint.fromTokenAmount(escrow.data.amount),
...bufferRelayer.data.toJSON(),
queue: {
publicKey: queue.publicKey,
...queue.data.toJSON(),
},
permission: {
publicKey: permission.publicKey,
bump: permission.bump,
...permission.data.toJSON(),
},
};
}
public async fetchAccounts(
_bufferRelayer?: types.BufferRelayerAccountData,
_queueAccount?: QueueAccount,
@ -361,3 +385,13 @@ export type BufferRelayerAccounts = {
balance: number;
};
};
export type BufferRelayerAccountsJSON = types.BufferRelayerAccountDataJSON & {
publicKey: PublicKey;
balance: number;
queue: types.OracleQueueAccountDataJSON & { publicKey: PublicKey };
permission: types.PermissionAccountDataJSON & {
bump: number;
publicKey: PublicKey;
};
};