solana.js: published 2.0.68

- fixed VrfJson
This commit is contained in:
Conner Gallagher 2023-01-03 22:02:09 -07:00
parent 909b488454
commit 82c3efbe45
3 changed files with 21 additions and 10 deletions

View File

@ -1,12 +1,12 @@
{ {
"name": "@switchboard-xyz/solana.js", "name": "@switchboard-xyz/solana.js",
"version": "2.0.67", "version": "2.0.68",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@switchboard-xyz/solana.js", "name": "@switchboard-xyz/solana.js",
"version": "2.0.67", "version": "2.0.68",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@project-serum/anchor": "^0.26.0", "@project-serum/anchor": "^0.26.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "@switchboard-xyz/solana.js", "name": "@switchboard-xyz/solana.js",
"version": "2.0.67", "version": "2.0.68",
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"description": "API wrapper for integrating with the Switchboard V2 program on Solana", "description": "API wrapper for integrating with the Switchboard V2 program on Solana",

View File

@ -1,6 +1,6 @@
import { AccountMeta, Keypair, PublicKey } from '@solana/web3.js'; import { AccountMeta, Keypair, PublicKey } from '@solana/web3.js';
import { CreateQueueVrfParams } from '../accounts'; import { CreateQueueVrfParams, Callback } from '../accounts';
import { Callback } from '../generated'; import { Callback as CallbackJson } from '../generated';
import { import {
keypairToString, keypairToString,
loadKeypair, loadKeypair,
@ -28,7 +28,18 @@ export class VrfJson implements IVrfJson {
if (!('callback' in object)) { if (!('callback' in object)) {
throw new Error(`VRF has no callback defined`); throw new Error(`VRF has no callback defined`);
} }
this.callback = Callback.fromJSON(object.callback); const callbackJson = CallbackJson.fromJSON(object.callback);
this.callback = {
programId: callbackJson.programId,
accounts: callbackJson.accounts.map((a): AccountMeta => {
return {
pubkey: a.pubkey,
isSigner: a.isSigner,
isWritable: a.isWritable,
};
}),
ixData: Buffer.from(callbackJson.ixData),
};
// permissions // permissions
this.enable = parseBoolean(object, 'enable', false); this.enable = parseBoolean(object, 'enable', false);
@ -69,15 +80,15 @@ export class VrfJson implements IVrfJson {
toJSON() { toJSON() {
return { return {
callback: { callback: {
programId: this.callback.programId, programId: this.callback.programId.toBase58(),
accounts: this.callback.accounts.map((a): AccountMeta => { accounts: this.callback.accounts.map(a => {
return { return {
pubkey: a.pubkey, pubkey: a.pubkey.toBase58(),
isSigner: a.isSigner, isSigner: a.isSigner,
isWritable: a.isWritable, isWritable: a.isWritable,
}; };
}), }),
isData: Buffer.from(this.callback.ixData), isData: `[${new Uint8Array(this.callback.ixData)}]`,
}, },
keypair: keypairToString(this.vrfKeypair), keypair: keypairToString(this.vrfKeypair),
authority: this.authority?.toBase58() ?? undefined, authority: this.authority?.toBase58() ?? undefined,