chore: release

This commit is contained in:
Conner Gallagher 2023-07-11 11:51:04 -06:00
parent 3169759a49
commit dc8d155b62
322 changed files with 4493 additions and 5041 deletions

View File

@ -4227,9 +4227,9 @@ checksum = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f"
[[package]]
name = "switchboard-common"
version = "0.8.1"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ba2cc1d6055e0989756adc4f54fa1e27d684ce08d6164da23900e93ac0b13b6"
checksum = "c5a03303674fb73b1dbe6cfc83aa8faa0e99264472a47177a1803f7475b318d1"
dependencies = [
"getrandom 0.2.10",
"hex",
@ -4249,7 +4249,7 @@ dependencies = [
[[package]]
name = "switchboard-solana"
version = "0.8.4"
version = "0.9.1"
dependencies = [
"anchor-client",
"anchor-lang",
@ -4258,6 +4258,7 @@ dependencies = [
"bytemuck",
"chrono",
"cron",
"hex",
"rust_decimal",
"sgx-quote",
"solana-address-lookup-table-program",
@ -4265,6 +4266,7 @@ dependencies = [
"solana-program",
"superslice",
"switchboard-common",
"tokio",
]
[[package]]

View File

@ -17,5 +17,5 @@ cpi = ["no-entrypoint"]
[dependencies]
# switchboard-solana = "0.8.4"
switchboard-solana = { version = "0.8.4", path = "../../../rust/switchboard-solana" }
switchboard-solana = { version = "0.9.1", path = "../../../rust/switchboard-solana" }
bytemuck = "1.13.1"

View File

@ -40,7 +40,6 @@
"prettier": "^2.4.1",
"prettier-plugin-organize-imports": "^2.3.4",
"shx": "^0.3.4",
"switchboard-solana": "workspace:*",
"ts-mocha": "^9.0.2",
"ts-node": "^10.9.1",
"typescript": "^4.9.3"

View File

@ -12,4 +12,4 @@ no-entrypoint = []
[dependencies]
# switchboard-solana = "0.8.4"
switchboard-solana = { version = "0.8.4", path = "../../../rust/switchboard-solana" }
switchboard-solana = { version = "0.9.1", path = "../../../rust/switchboard-solana" }

View File

@ -25,7 +25,6 @@
"@types/node": "^17.0.45",
"chai": "^4.3.6",
"mocha": "^9.0.3",
"switchboard-solana": "workspace:*",
"ts-mocha": "^9.0.2",
"ts-node": "^10.4.0",
"typescript": "^4.7"

View File

@ -6,9 +6,11 @@ seeds = false
skip-lint = false
[programs.localnet]
basic_oracle = "CE1HrS25FhvPjcAH4Zjka6uJBbYrDRY7uZ8PPSkiUwAh"
basic_oracle = "8GHcguBXZEfKaLxRrBvis7LqPcFjBszv4ZYBgKwCUipS"
[provider]
# cluster = "https://switchbo-switchbo-6225.devnet.rpcpool.com/f6fb9f02-0777-498b-b8f5-67cbb1fc0d14"
# wallet = "~/switchboard_environments_v2/devnet/upgrade_authority/upgrade_authority.json"
cluster = "Localnet"
wallet = "~/.config/solana/id.json"

File diff suppressed because it is too large Load Diff

View File

@ -17,6 +17,10 @@ cpi = ["no-entrypoint"]
default = []
[dependencies]
switchboard-solana = "0.8.4"
# switchboard-solana = { version = "0.8.4", path = "../../../rust/switchboard-solana" }
switchboard-solana = { version = "=0.9.1" }
# switchboard-solana = { version = "0.9.1", path = "../../../../../rust/switchboard-solana" }
bytemuck = "^1"
anchor-lang = { version = "0.28.0", features = [
"init-if-needed",
"allow-missing-optionals"
] }

View File

@ -7,27 +7,24 @@
"directory": "examples/functions/01_basic_oracle"
},
"scripts": {
"build": "anchor build",
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
"build:anchor": "anchor build",
"clean": "pnpm exec rimraf node_modules .anchor lib .turbo"
},
"dependencies": {
"@coral-xyz/anchor": "^0.28.0",
"@solana/spl-token": "^0.3.6",
"@solana/web3.js": "^1.77.3",
"@switchboard-xyz/common": "^2.2.4",
"@switchboard-xyz/oracle": "^2.1.13",
"@solana/web3.js": "^1.78.0",
"@switchboard-xyz/common": "*",
"@switchboard-xyz/oracle": "*",
"@switchboard-xyz/solana.js": "workspace:*"
},
"devDependencies": {
"chai": "^4.3.4",
"mocha": "^9.0.3",
"ts-mocha": "^10.0.0",
"@types/bn.js": "^5.1.0",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.0.0",
"typescript": "^4.3.5",
"prettier": "^2.6.2",
"switchboard-solana": "workspace:*"
"@types/node": "^20.4.0",
"chai": "^4.3.4",
"mocha": "^9.0.3",
"ts-mocha": "^10.0.0"
}
}

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,5 @@ tokio = "^1"
futures = "0.3"
serde = "^1"
serde_json = "^1"
switchboard-utils = "0.8.0"
# switchboard-utils = { version = "0.8.1", path = "../../../../../sbv2-core/rust/switchboard-utils" }
switchboard-solana = "0.8.4"
# switchboard-solana = { version = "0.8.4", path = "../../../../rust/switchboard-solana" }
switchboard-utils = { version = "0.8.0" }
switchboard-solana = { version = "=0.9.1" }

View File

@ -22,4 +22,7 @@ COPY --from=builder /sgx/app /sgx
# Get the measurement from the enclave
RUN /get_measurement.sh
RUN cp /app.manifest.sgx /sgx/app.manifest.sgx
RUN cp /app.sig /sgx/app.sig
ENTRYPOINT ["bash", "/boot.sh"]

View File

@ -4,7 +4,6 @@
"build:function": "make"
},
"dependencies": {
"switchboard-solana": "workspace:*",
"basic-oracle": "workspace:*"
}
}

View File

@ -173,11 +173,6 @@ impl Binance {
let ixn = Instruction {
program_id: basic_oracle::ID,
accounts: vec![
AccountMeta {
pubkey: program_state_pubkey,
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: oracle_pubkey,
is_signer: false,
@ -188,11 +183,6 @@ impl Binance {
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: runner.quote,
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: runner.signer,
is_signer: true,
@ -211,4 +201,4 @@ pub fn parse_string_value(value: &str) -> i128 {
let f64_value = value.parse::<f64>().unwrap();
let sb_decimal = SwitchboardDecimal::from_f64(f64_value);
sb_decimal.scale_to(9)
}
}

View File

@ -21,18 +21,11 @@ pub struct Initialize<'info> {
)]
pub oracle: AccountLoader<'info, MyOracleState>,
#[account(
constraint = function.load()?.authority == program.key()
)]
pub function: AccountLoader<'info, FunctionAccountData>,
/// CHECK:
pub authority: Signer<'info>,
#[account(mut)]
pub payer: Signer<'info>,
// SYSTEM ACCOUNTS
pub system_program: Program<'info, System>,
}
@ -43,19 +36,18 @@ impl Initialize<'_> {
pub fn validate(
&self,
_ctx: &Context<Self>,
params: &InitializeParams,
_params: &InitializeParams,
) -> anchor_lang::Result<()> {
Ok(())
}
pub fn actuate(ctx: &Context<Self>, params: &InitializeParams) -> anchor_lang::Result<()> {
pub fn actuate(ctx: &Context<Self>, _params: &InitializeParams) -> anchor_lang::Result<()> {
let program = &mut ctx.accounts.program.load_init()?;
program.bump = *ctx.bumps.get("program").unwrap_or(&0);
program.bump = *ctx.bumps.get("program").unwrap();
program.authority = ctx.accounts.authority.key();
program.function = ctx.accounts.function.key();
let oracle = &mut ctx.accounts.oracle.load_init()?;
oracle.bump = *ctx.bumps.get("oracle").unwrap_or(&0);
oracle.bump = *ctx.bumps.get("oracle").unwrap();
Ok(())
}
}
}

View File

@ -6,3 +6,6 @@ pub use refresh_prices::*;
pub mod set_function;
pub use set_function::*;
pub mod trigger_function;
pub use trigger_function::*;

View File

@ -2,13 +2,6 @@ use crate::*;
#[derive(Accounts)]
pub struct RefreshPrices<'info> {
#[account(
seeds = [PROGRAM_SEED],
bump = program_state.load()?.bump,
has_one = function @ BasicOracleError::IncorrectSwitchboardFunction,
)]
pub program_state: AccountLoader<'info, MyProgramState>,
#[account(
mut,
seeds = [ORACLE_SEED],
@ -16,22 +9,21 @@ pub struct RefreshPrices<'info> {
)]
pub oracle: AccountLoader<'info, MyOracleState>,
// We use this to derive and verify the functions enclave state
// We use this to verify the functions enclave state
#[account(
constraint =
FunctionAccountData::validate_enclave(
&function.to_account_info(),
&enclave.to_account_info(),
&enclave_signer.to_account_info()
)?
constraint =
function.load()?.validate(
&enclave_signer.to_account_info()
)? @ BasicOracleError::FunctionValidationFailed
// FunctionAccountData::validate(
// &function.to_account_info(),
// &enclave_signer.to_account_info()
// )? @ BasicOracleError::FunctionValidationFailed
)]
pub function: AccountLoader<'info, FunctionAccountData>,
pub enclave: AccountLoader<'info, EnclaveAccountData>,
pub enclave_signer: Signer<'info>,
}
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
pub struct RefreshPricesParams {
pub rows: Vec<OracleDataWithTradingSymbol>,
@ -48,8 +40,9 @@ impl RefreshPrices<'_> {
pub fn actuate(ctx: &Context<Self>, params: &RefreshPricesParams) -> anchor_lang::Result<()> {
let oracle = &mut ctx.accounts.oracle.load_mut()?;
msg!("saving oracle data");
oracle.save_rows(&params.rows)?;
Ok(())
}
}
}

View File

@ -18,22 +18,20 @@ pub struct SetFunction<'info> {
}
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
pub struct SetFunctionParams {
}
pub struct SetFunctionParams { }
impl SetFunction<'_> {
pub fn validate(
&self,
_ctx: &Context<Self>,
params: &SetFunctionParams,
_params: &SetFunctionParams,
) -> anchor_lang::Result<()> {
Ok(())
}
pub fn actuate(ctx: &Context<Self>, params: &SetFunctionParams) -> anchor_lang::Result<()> {
pub fn actuate(ctx: &Context<Self>, _params: &SetFunctionParams) -> anchor_lang::Result<()> {
let program = &mut ctx.accounts.program.load_init()?;
program.function = ctx.accounts.function.key();
Ok(())
}
}
}

View File

@ -0,0 +1,43 @@
use crate::*;
use switchboard_solana::attestation_program::instructions::function_trigger::FunctionTrigger;
use switchboard_solana::SWITCHBOARD_ATTESTATION_PROGRAM_ID;
#[derive(Accounts)]
#[instruction(params: TriggerFunctionParams)] // rpc parameters hint
pub struct TriggerFunction<'info> {
#[account(
has_one = authority,
has_one = attestation_queue,
)]
pub function: AccountLoader<'info, FunctionAccountData>,
pub attestation_queue: AccountLoader<'info, AttestationQueueAccountData>,
pub authority: Signer<'info>,
/// CHECK: address is explicit
#[account(address = SWITCHBOARD_ATTESTATION_PROGRAM_ID)]
pub attestation_program: AccountInfo<'info>,
}
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
pub struct TriggerFunctionParams { }
impl TriggerFunction<'_> {
pub fn validate(
&self,
_ctx: &Context<Self>,
_params: &TriggerFunctionParams,
) -> anchor_lang::Result<()> {
Ok(())
}
pub fn actuate(ctx: &Context<Self>, _params: &TriggerFunctionParams) -> anchor_lang::Result<()> {
FunctionTrigger {
function: ctx.accounts.function.clone(),
authority: ctx.accounts.authority.clone(),
attestation_queue: ctx.accounts.attestation_queue.clone(),
}.invoke(ctx.accounts.attestation_program.clone())?;
Ok(())
}
}

View File

@ -13,12 +13,12 @@ pub enum BasicOracleError {
InvalidTrustedSigner,
#[msg("Invalid MRENCLAVE")]
InvalidMrEnclave,
#[msg("Switchboard QuoteAccount has an empty MrEnclave (invalid)")]
EmptySwitchboardQuote,
#[msg("Failed to find a valid trading symbol for this price")]
InvalidSymbol,
#[msg("FunctionAccount pubkey did not match program_state.function")]
IncorrectSwitchboardFunction,
#[msg("FunctionAccount pubkey did not match program_state.function")]
InvalidSwitchboardFunction,
#[msg("FunctionAccount was not validated successfully")]
FunctionValidationFailed,
}

View File

@ -1,4 +1,7 @@
pub mod actions;
pub use actions::*;
pub use switchboard_solana::prelude::*;
declare_id!("EF68PJkRqQu2VthTSy19kg6TWynMtRmLpxcMDKEdLC8t");
pub mod error;
pub use error::*;
@ -9,10 +12,7 @@ pub use model::*;
pub mod utils;
pub use utils::*;
pub mod actions;
pub use actions::*;
declare_id!("CE1HrS25FhvPjcAH4Zjka6uJBbYrDRY7uZ8PPSkiUwAh");
pub const PROGRAM_SEED: &[u8] = b"BASICORACLE";
@ -45,4 +45,12 @@ pub mod basic_oracle {
) -> anchor_lang::Result<()> {
SetFunction::actuate(&ctx, &params)
}
}
#[access_control(ctx.accounts.validate(&ctx, &params))]
pub fn trigger_function(
ctx: Context<TriggerFunction>,
params: TriggerFunctionParams,
) -> anchor_lang::Result<()> {
TriggerFunction::actuate(&ctx, &params)
}
}

View File

@ -1,18 +1,22 @@
// eslint-disable-next-line node/no-unpublished-import
import type { BasicOracle } from "../target/types/basic_oracle";
import { printLogs } from "./utils";
import type { Program } from "@coral-xyz/anchor";
import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { BasicOracle } from "../target/types/basic_oracle";
import {
AttestationQueueAccount,
SwitchboardProgram,
type BootstrappedAttestationQueue,
FunctionAccount,
parseMrEnclave,
MrEnclave,
types,
attestationTypes,
AttestationProgramStateAccount,
} from "@switchboard-xyz/solana.js";
import { sleep } from "@switchboard-xyz/common";
import type { FunctionAccount, MrEnclave } from "@switchboard-xyz/solana.js";
import { SwitchboardWallet } from "@switchboard-xyz/solana.js";
import {
AttestationProgramStateAccount,
AttestationQueueAccount,
attestationTypes,
type BootstrappedAttestationQueue,
parseMrEnclave,
SwitchboardProgram,
types,
} from "@switchboard-xyz/solana.js";
const unixTimestamp = () => Math.floor(Date.now() / 1000);
@ -49,28 +53,47 @@ describe("basic_oracle", () => {
)[0];
let switchboard: BootstrappedAttestationQueue;
let wallet: SwitchboardWallet;
let functionAccount: FunctionAccount;
before(async () => {
const switchboardProgram = await SwitchboardProgram.fromProvider(
program.provider as anchor.AnchorProvider
);
await AttestationProgramStateAccount.getOrCreate(switchboardProgram);
switchboard = await AttestationQueueAccount.bootstrapNewQueue(
switchboardProgram
);
[functionAccount] = await FunctionAccount.create(
switchboard.attestationQueueAccount.program,
{
container: "switchboardlabs/basic-oracle-function",
version: "latest",
schedule: "15 * * * * *",
mrEnclave: MRENCLAVE,
attestationQueue: switchboard.attestationQueueAccount,
authority: programStatePubkey,
}
console.log(`programStatePubkey: ${programStatePubkey}`);
[wallet] = await SwitchboardWallet.create(
switchboard.program,
switchboard.attestationQueue.publicKey,
payer,
"MySharedWallet",
16
);
console.log(`wallet: ${wallet.publicKey}`);
[functionAccount] =
await switchboard.attestationQueue.account.createFunction(
{
name: "test function",
metadata: "this function handles XYZ for my protocol",
schedule: "15 * * * * *",
container: "switchboardlabs/basic-oracle-function",
version: "latest",
mrEnclave: MRENCLAVE,
authority: programStatePubkey,
},
wallet
);
console.log(`functionAccount: ${functionAccount.publicKey}`);
});
it("Is initialized!", async () => {
@ -81,7 +104,8 @@ describe("basic_oracle", () => {
program: programStatePubkey,
oracle: oraclePubkey,
authority: payer,
function: functionAccount.publicKey,
payer: payer,
// function: functionAccount.publicKey,
})
.rpc()
.catch((err) => {
@ -114,13 +138,13 @@ describe("basic_oracle", () => {
const securedSigner = anchor.web3.Keypair.generate();
const rewardAddress =
await switchboard.attestationQueueAccount.program.mint.getOrCreateAssociatedUser(
payer
);
await switchboard.program.mint.getOrCreateAssociatedUser(payer);
const functionState = await functionAccount.loadData();
// TODO: generate function verify ixn
const functionVerifyIxn = attestationTypes.functionVerify(
switchboard.attestationQueueAccount.program,
switchboard.program,
{
params: {
observedTime: new anchor.BN(unixTimestamp()),
@ -132,16 +156,13 @@ describe("basic_oracle", () => {
{
function: functionAccount.publicKey,
functionEnclaveSigner: securedSigner.publicKey,
verifierEnclaveSigner: switchboard.verifier.signer.publicKey,
verifierQuote: switchboard.verifier.quoteAccount.publicKey,
attestationQueue: switchboard.attestationQueueAccount.publicKey,
escrow: functionAccount.getEscrow(),
verifier: switchboard.verifier.publicKey,
verifierSigner: switchboard.verifier.signer.publicKey,
attestationQueue: switchboard.attestationQueue.publicKey,
escrowWallet: functionState.escrowWallet,
escrowTokenWallet: functionState.escrowTokenWallet,
receiver: rewardAddress,
verifierPermission: switchboard.verifier.permissionAccount.publicKey,
state:
switchboard.attestationQueueAccount.program.attestationProgramState
.publicKey,
fnQuote: functionAccount.getEnclaveAccount()[0].publicKey,
tokenProgram: anchor.utils.token.TOKEN_PROGRAM_ID,
}
);
@ -175,22 +196,18 @@ describe("basic_oracle", () => {
],
})
.accounts({
programState: programStatePubkey,
oracle: oraclePubkey,
function: functionAccount.publicKey,
enclave: functionAccount.getEnclaveAccount()[0].publicKey,
enclaveSigner: securedSigner.publicKey,
})
.preInstructions([functionVerifyIxn])
.signers([switchboard.verifier.signer, securedSigner])
.rpc()
.catch((err) => {
console.error(err);
throw err;
});
.rpc({ skipPreflight: true });
console.log("Your transaction signature", tx);
await printLogs(switchboard.program.connection, tx ? tx : "");
await sleep(5000);
const oracleState = await program.account.myOracleState.fetch(oraclePubkey);

View File

@ -0,0 +1,16 @@
import type { Connection } from "@solana/web3.js";
import { sleep } from "@switchboard-xyz/common";
export async function printLogs(
connection: Connection,
tx: string,
v0Txn?: boolean,
delay = 3000
) {
await sleep(delay);
const parsed = await connection.getParsedTransaction(tx, {
commitment: "confirmed",
maxSupportedTransactionVersion: v0Txn ? 0 : undefined,
});
console.log(parsed?.meta?.logMessages?.join("\n"));
}

View File

@ -5,14 +5,8 @@
}
},
"compilerOptions": {
"types": [
"mocha",
"chai",
"node"
],
"typeRoots": [
"./node_modules/@types"
],
"types": ["mocha", "chai", "node"],
"typeRoots": ["./node_modules/@types"],
"module": "commonjs",
"noEmit": true,
"esModuleInterop": true,
@ -20,23 +14,14 @@
"strictNullChecks": false,
"target": "es6",
"paths": {
"@switchboard-xyz/solana.js": [
"../../../javascript/solana.js"
]
"@switchboard-xyz/solana.js": ["../../../javascript/solana.js"]
}
},
"include": [
"tests/**/*",
"./cli.ts",
"./client/**/*"
],
"exclude": [
"target",
"lib"
],
"include": ["tests/**/*", "target/types/*.ts"],
"exclude": ["target", "lib"],
"references": [
{
"path": "../../../javascript/solana.js"
"path": "../../../../../javascript/solana.js"
}
]
}
}

View File

@ -4235,9 +4235,9 @@ checksum = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f"
[[package]]
name = "switchboard-common"
version = "0.8.1"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ba2cc1d6055e0989756adc4f54fa1e27d684ce08d6164da23900e93ac0b13b6"
checksum = "c5a03303674fb73b1dbe6cfc83aa8faa0e99264472a47177a1803f7475b318d1"
dependencies = [
"getrandom 0.2.10",
"hex",
@ -4249,7 +4249,7 @@ dependencies = [
[[package]]
name = "switchboard-solana"
version = "0.8.4"
version = "0.9.1"
dependencies = [
"anchor-client",
"anchor-lang",
@ -4258,6 +4258,7 @@ dependencies = [
"bytemuck",
"chrono",
"cron",
"hex",
"rust_decimal",
"sgx-quote",
"solana-address-lookup-table-program",
@ -4265,6 +4266,7 @@ dependencies = [
"solana-program",
"superslice",
"switchboard-common",
"tokio",
]
[[package]]

View File

@ -17,5 +17,4 @@ cpi = ["no-entrypoint"]
[dependencies]
bytemuck = "1.13.1"
switchboard-solana = { path = "../../../rust/switchboard-solana", version = "0.8.4" }
# switchboard-solana = { version = "^0.8.4", path = "../../../rust/switchboard-solana" }
switchboard-solana = { version = "^0.9.1", path = "../../../rust/switchboard-solana" }

View File

@ -1,6 +1,6 @@
{
"name": "@switchboard-xyz/solana.js",
"version": "2.3.3",
"version": "2.4.1",
"author": "",
"license": "MIT",
"description": "A Typescript client to interact with Switchboard on Solana.",

View File

@ -1,6 +1,7 @@
import * as borsh from "@coral-xyz/borsh";
import { Connection, SYSVAR_CLOCK_PUBKEY } from "@solana/web3.js";
import { BN } from "@switchboard-xyz/common";
import type { Connection } from "@solana/web3.js";
import { SYSVAR_CLOCK_PUBKEY } from "@solana/web3.js";
import type { BN } from "@switchboard-xyz/common";
export interface SolanaClockDataFields {
slot: BN;

View File

@ -1,4 +1,4 @@
import { SwitchboardProgram } from "./SwitchboardProgram.js";
import type { SwitchboardProgram } from "./SwitchboardProgram.js";
/**
* Switchboard wrapper for anchor program errors.

View File

@ -1,7 +1,7 @@
import * as types from "./generated/index.js";
import type * as types from "./generated/index.js";
import * as anchor from "@coral-xyz/anchor";
import { BN } from "@switchboard-xyz/common";
import type * as anchor from "@coral-xyz/anchor";
import type { BN } from "@switchboard-xyz/common";
export type AggregatorAddJobEvent = {
feedPubkey: anchor.web3.PublicKey;

View File

@ -1,19 +1,21 @@
import {
AggregatorAccount,
BufferRelayerAccount,
CrankAccount,
import type {
CreateQueueBufferRelayerParams,
CreateQueueCrankParams,
CreateQueueFeedParams,
CreateQueueOracleParams,
CreateQueueVrfParams,
QueueInitParams,
} from "./accounts/index.js";
import {
AggregatorAccount,
BufferRelayerAccount,
CrankAccount,
JobAccount,
LeaseAccount,
OracleAccount,
PermissionAccount,
ProgramStateAccount,
QueueAccount,
QueueInitParams,
VrfAccount,
} from "./accounts/index.js";
import {
@ -28,12 +30,12 @@ import {
SbState,
VrfAccountData,
} from "./generated/index.js";
import {
import type {
SendTransactionOptions,
SwitchboardProgram,
} from "./SwitchboardProgram.js";
import { TransactionObject } from "./TransactionObject.js";
import {
import type {
AggregatorDefinition,
BufferRelayerDefinition,
CrankDefinition,
@ -53,12 +55,8 @@ import {
} from "./types.js";
import * as anchor from "@coral-xyz/anchor";
import {
AccountInfo,
Keypair,
PublicKey,
TransactionSignature,
} from "@solana/web3.js";
import type { AccountInfo, TransactionSignature } from "@solana/web3.js";
import { Keypair, PublicKey } from "@solana/web3.js";
import { OracleJob } from "@switchboard-xyz/common";
import fs from "fs";
import path from "path";
@ -331,7 +329,10 @@ export class SwitchboardNetwork implements ISwitchboardNetwork {
const [queueAccount, queueInit] = await QueueAccount.createInstructions(
program,
payer,
{ ...params, authority: queueAuthorityPubkey }
{
...params,
authority: queueAuthorityPubkey,
}
);
txns.push(queueInit);

View File

@ -1,3 +1,7 @@
import type {
SwitchboardAccountData,
SwitchboardAccountType,
} from "./accounts/index.js";
import {
AttestationProgramStateAccount,
BUFFER_DISCRIMINATOR,
@ -6,8 +10,6 @@ import {
JobAccount,
ProgramStateAccount,
QueueAccount,
SwitchboardAccountData,
SwitchboardAccountType,
} from "./accounts/index.js";
import {
AggregatorAccountData,
@ -36,33 +38,31 @@ import {
} from "./const.js";
import * as errors from "./errors.js";
import { NativeMint } from "./mint.js";
import { SwitchboardEvents } from "./SwitchboardEvents.js";
import { TransactionObject, TransactionOptions } from "./TransactionObject.js";
import { LoadedJobDefinition } from "./types.js";
import type { SwitchboardEvents } from "./SwitchboardEvents.js";
import type { TransactionOptions } from "./TransactionObject.js";
import { TransactionObject } from "./TransactionObject.js";
import type { LoadedJobDefinition } from "./types.js";
import type { AccountNamespace, Idl, Wallet } from "@coral-xyz/anchor";
import {
ACCOUNT_DISCRIMINATOR_SIZE,
AccountNamespace,
AnchorProvider,
BorshAccountsCoder,
Idl,
Program,
utils as AnchorUtils,
Wallet,
} from "@coral-xyz/anchor";
import {
import type {
AccountInfo,
Cluster,
ConfirmOptions,
Connection,
GetProgramAccountsResponse,
Keypair,
PublicKey,
SendOptions,
Transaction,
TransactionSignature,
VersionedTransaction,
} from "@solana/web3.js";
import { Keypair, PublicKey } from "@solana/web3.js";
import { OracleJob } from "@switchboard-xyz/common";
export type SendTransactionOptions = (ConfirmOptions | SendOptions) & {

View File

@ -1,21 +1,21 @@
import {
AggregatorAccount,
type CreateQueueFeedParams,
type CreateQueueOracleParams,
OracleAccount,
QueueAccount,
import type { AggregatorAccount, OracleAccount } from "./accounts/index.js";
import type {
CreateQueueFeedParams,
CreateQueueOracleParams,
} from "./accounts/index.js";
import { AggregatorAccountData } from "./generated/index.js";
import {
import { QueueAccount } from "./accounts/index.js";
import type { AggregatorAccountData } from "./generated/index.js";
import type {
LoadedSwitchboardNetwork,
type NetworkInitParams,
SwitchboardNetwork,
NetworkInitParams,
} from "./SwitchboardNetwork.js";
import { SwitchboardNetwork } from "./SwitchboardNetwork.js";
import { SwitchboardProgram } from "./SwitchboardProgram.js";
import { createStaticFeed, loadKeypair, updateStaticFeed } from "./utils.js";
import { AnchorProvider } from "@coral-xyz/anchor";
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
import type { AnchorProvider } from "@coral-xyz/anchor";
import type { Connection, PublicKey } from "@solana/web3.js";
import { Keypair } from "@solana/web3.js";
import fs from "fs";
import _ from "lodash";
import os from "os";

View File

@ -2,23 +2,25 @@ import * as attestationTypes from "./generated/attestation-program/index.js";
import { fromTxError } from "./generated/oracle-program/errors/index.js";
import { isBrowser } from "./browser.js";
import * as errors from "./errors.js";
import {
import type {
AnchorWallet,
DEFAULT_SEND_TRANSACTION_OPTIONS,
SendTransactionOptions,
} from "./SwitchboardProgram.js";
import { DEFAULT_SEND_TRANSACTION_OPTIONS } from "./SwitchboardProgram.js";
import { AnchorProvider } from "@coral-xyz/anchor";
import {
ComputeBudgetProgram,
import type { AnchorProvider } from "@coral-xyz/anchor";
import type {
Keypair,
NonceInformation,
TransactionInstruction,
TransactionSignature,
} from "@solana/web3.js";
import {
ComputeBudgetProgram,
PACKET_DATA_SIZE,
PublicKey,
Transaction,
TransactionInstruction,
TransactionMessage,
TransactionSignature,
VersionedTransaction,
} from "@solana/web3.js";
import { sleep } from "@switchboard-xyz/common";

View File

@ -11,21 +11,21 @@ import {
SlidingResultAccountData,
VrfAccountData,
} from "../generated/oracle-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import { AggregatorAccount } from "./aggregatorAccount.js";
import { AggregatorHistoryBuffer } from "./aggregatorHistoryBuffer.js";
import { BufferRelayerAccount } from "./bufferRelayAccount.js";
import { CrankAccount } from "./crankAccount.js";
import { CrankDataBuffer } from "./crankDataBuffer.js";
import { JobAccount } from "./jobAccount.js";
import { LeaseAccount } from "./leaseAccount.js";
import { OracleAccount } from "./oracleAccount.js";
import { PermissionAccount } from "./permissionAccount.js";
import { ProgramStateAccount } from "./programStateAccount.js";
import { QueueAccount } from "./queueAccount.js";
import { QueueDataBuffer } from "./queueDataBuffer.js";
import { VrfAccount } from "./vrfAccount.js";
import type { AggregatorAccount } from "./aggregatorAccount.js";
import type { AggregatorHistoryBuffer } from "./aggregatorHistoryBuffer.js";
import type { BufferRelayerAccount } from "./bufferRelayAccount.js";
import type { CrankAccount } from "./crankAccount.js";
import type { CrankDataBuffer } from "./crankDataBuffer.js";
import type { JobAccount } from "./jobAccount.js";
import type { LeaseAccount } from "./leaseAccount.js";
import type { OracleAccount } from "./oracleAccount.js";
import type { PermissionAccount } from "./permissionAccount.js";
import type { ProgramStateAccount } from "./programStateAccount.js";
import type { QueueAccount } from "./queueAccount.js";
import type { QueueDataBuffer } from "./queueDataBuffer.js";
import type { VrfAccount } from "./vrfAccount.js";
import * as anchor from "@coral-xyz/anchor";

View File

@ -1,48 +1,46 @@
import * as errors from "../errors.js";
import {
AggregatorAccountData,
import type {
AggregatorAccountDataFields,
AggregatorAccountDataJSON,
} from "../generated/oracle-program/accounts/AggregatorAccountData.js";
import {
JobAccountData,
JobAccountDataJSON,
} from "../generated/oracle-program/accounts/JobAccountData.js";
import {
LeaseAccountData,
LeaseAccountDataJSON,
} from "../generated/oracle-program/accounts/LeaseAccountData.js";
import { OracleAccountData } from "../generated/oracle-program/accounts/OracleAccountData.js";
import {
import { AggregatorAccountData } from "../generated/oracle-program/accounts/AggregatorAccountData.js";
import type { JobAccountDataJSON } from "../generated/oracle-program/accounts/JobAccountData.js";
import { JobAccountData } from "../generated/oracle-program/accounts/JobAccountData.js";
import type { LeaseAccountDataJSON } from "../generated/oracle-program/accounts/LeaseAccountData.js";
import { LeaseAccountData } from "../generated/oracle-program/accounts/LeaseAccountData.js";
import type { OracleAccountData } from "../generated/oracle-program/accounts/OracleAccountData.js";
import type {
OracleQueueAccountData,
OracleQueueAccountDataJSON,
} from "../generated/oracle-program/accounts/OracleQueueAccountData.js";
import {
PermissionAccountData,
PermissionAccountDataJSON,
} from "../generated/oracle-program/accounts/PermissionAccountData.js";
import type { PermissionAccountDataJSON } from "../generated/oracle-program/accounts/PermissionAccountData.js";
import { PermissionAccountData } from "../generated/oracle-program/accounts/PermissionAccountData.js";
import * as ix from "../generated/oracle-program/instructions/index.js";
import {
import type {
AggregatorHistoryRow,
AggregatorResolutionMode,
AggregatorResolutionModeKind,
} from "../generated/oracle-program/types/index.js";
import {
AggregatorResolutionMode,
BorshDecimal,
} from "../generated/oracle-program/types/index.js";
import { SwitchboardDecimal } from "../generated/oracle-program/types/SwitchboardDecimal.js";
import { PermitOracleQueueUsage } from "../generated/oracle-program/types/SwitchboardPermission.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
TransactionPackOptions,
} from "../TransactionObject.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account, OnAccountChangeCallback } from "./account.js";
import type { OnAccountChangeCallback } from "./account.js";
import { Account } from "./account.js";
import { AggregatorHistoryBuffer } from "./aggregatorHistoryBuffer.js";
import { CrankAccount } from "./crankAccount.js";
import { JobAccount } from "./jobAccount.js";
import { LeaseAccount, LeaseExtendParams } from "./leaseAccount.js";
import type { LeaseExtendParams } from "./leaseAccount.js";
import { LeaseAccount } from "./leaseAccount.js";
import { OracleAccount } from "./oracleAccount.js";
import { PermissionAccount } from "./permissionAccount.js";
import { QueueAccount } from "./queueAccount.js";
@ -50,16 +48,18 @@ import { QueueAccount } from "./queueAccount.js";
import * as anchor from "@coral-xyz/anchor";
import * as spl from "@solana/spl-token";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import {
import type {
AccountInfo,
AccountMeta,
Commitment,
TransactionInstruction,
TransactionSignature,
} from "@solana/web3.js";
import {
Keypair,
LAMPORTS_PER_SOL,
PublicKey,
SystemProgram,
TransactionInstruction,
TransactionSignature,
} from "@solana/web3.js";
import {
Big,

View File

@ -1,27 +1,22 @@
import * as errors from "../errors.js";
import * as types from "../generated/oracle-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { TransactionObject } from "../TransactionObject.js";
import {
Account,
BUFFER_DISCRIMINATOR,
OnAccountChangeCallback,
} from "./account.js";
import { AggregatorAccount } from "./aggregatorAccount.js";
import type { OnAccountChangeCallback } from "./account.js";
import { Account, BUFFER_DISCRIMINATOR } from "./account.js";
import type { AggregatorAccount } from "./aggregatorAccount.js";
import {
import type {
Commitment,
Keypair,
PublicKey,
SystemProgram,
TransactionInstruction,
TransactionSignature,
} from "@solana/web3.js";
import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js";
import { Big, BN } from "@switchboard-xyz/common";
export interface AggregatorHistoryInit {

View File

@ -1,20 +1,16 @@
import * as errors from "../errors.js";
import * as types from "../generated/attestation-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account } from "./account.js";
import {
Keypair,
PublicKey,
SystemProgram,
TransactionSignature,
} from "@solana/web3.js";
import type { Keypair, TransactionSignature } from "@solana/web3.js";
import { PublicKey, SystemProgram } from "@solana/web3.js";
/**
* Parameters for initializing an {@linkcode AttestationPermissionAccount}
@ -201,7 +197,7 @@ export class AttestationPermissionAccount extends Account<types.AttestationPermi
? params.queueAuthority.publicKey
: payer,
attestationQueue: params.queue,
enclave: params.enclave,
grantee: params.enclave,
}
),
],

View File

@ -1,16 +1,16 @@
import * as errors from "../errors.js";
import * as types from "../generated/attestation-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account } from "./account.js";
import type { TransactionSignature } from "@solana/web3.js";
import {
AccountInfo,
LAMPORTS_PER_SOL,
PublicKey,
SystemProgram,
TransactionSignature,
} from "@solana/web3.js";
/**

View File

@ -1,36 +1,30 @@
import * as errors from "../errors.js";
import * as types from "../generated/attestation-program/index.js";
import {
SB_ATTESTATION_PID,
SwitchboardProgram,
} from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import { SB_ATTESTATION_PID } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { RawBuffer } from "../types.js";
import { TransactionObject } from "../TransactionObject.js";
import type { RawBuffer } from "../types.js";
import { parseMrEnclave, parseRawBuffer } from "../utils.js";
import { Account } from "./account.js";
import {
AttestationPermissionAccount,
AttestationPermissionSetParams,
} from "./attestationPermissionAccount.js";
import { EnclaveAccount, EnclaveAccountInitParams } from "./enclaveAccount.js";
import {
FunctionAccount,
FunctionAccountInitParams,
} from "./functionAccount.js";
import { SwitchboardWallet } from "./switchboardWallet.js";
import type { AttestationPermissionSetParams } from "./attestationPermissionAccount.js";
import { AttestationPermissionAccount } from "./attestationPermissionAccount.js";
import type { FunctionAccountInitParams } from "./functionAccount.js";
import { FunctionAccount } from "./functionAccount.js";
import type { SwitchboardWallet } from "./switchboardWallet.js";
import type { VerifierAccountInitParams } from "./verifierAccount.js";
import { VerifierAccount } from "./verifierAccount.js";
import {
Keypair,
import type {
PublicKey,
SystemProgram,
TransactionInstruction,
TransactionSignature,
} from "@solana/web3.js";
import { Keypair, SystemProgram } from "@solana/web3.js";
/**
* Parameters for initializing an {@linkcode QueueAccount}
*/
@ -94,7 +88,7 @@ export interface AttestationQueueRemoveMrEnclaveParams {
}
export type CreateQueueQuoteParams = Omit<
EnclaveAccountInitParams,
VerifierAccountInitParams,
"queueAccount"
> &
Partial<AttestationPermissionSetParams> & {
@ -208,11 +202,11 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
return [account, await program.signAndSend(txnObject, options)];
}
public async createQuoteInstruction(
public async createVerifierInstruction(
payer: PublicKey,
params: CreateQueueQuoteParams,
options?: TransactionObjectOptions
): Promise<[EnclaveAccount, TransactionObject]> {
): Promise<[VerifierAccount, TransactionObject]> {
this.program.verifyAttestation();
const authority = params.authority ?? payer;
@ -220,15 +214,16 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
const queueAuthority =
params.queueAuthorityPubkey ?? (await this.loadData()).authority;
const [enclaveAccount, quoteInit] = await EnclaveAccount.createInstruction(
this.program,
payer,
{ ...params, queueAccount: this, authority },
options
);
const [verifierAccount, quoteInit] =
await VerifierAccount.createInstruction(
this.program,
payer,
{ ...params, queueAccount: this, authority },
options
);
if (!params.createPermissions && !params.enable) {
return [enclaveAccount, quoteInit];
return [verifierAccount, quoteInit];
}
const [permissionAccount, permissionInit] =
@ -237,7 +232,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
payer,
{
granter: this.publicKey,
grantee: enclaveAccount.publicKey,
grantee: verifierAccount.publicKey,
authority: queueAuthority,
},
options
@ -249,19 +244,19 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
permission:
new types.SwitchboardAttestationPermission.PermitNodeheartbeat(),
queue: this.publicKey,
enclave: enclaveAccount.publicKey,
enclave: verifierAccount.publicKey,
});
permissionInit.combine(permissionSet);
}
return [enclaveAccount, quoteInit.combine(permissionInit)];
return [verifierAccount, quoteInit.combine(permissionInit)];
}
public async createQuote(
public async createVerifier(
params: CreateQueueQuoteParams,
options?: SendTransactionObjectOptions
): Promise<[EnclaveAccount, TransactionSignature]> {
const [account, txnObject] = await this.createQuoteInstruction(
): Promise<[VerifierAccount, TransactionSignature]> {
const [account, txnObject] = await this.createVerifierInstruction(
this.program.walletPubkey,
params,
options
@ -304,7 +299,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
permission: SB_ATTESTATION_PID, // optional
authority: queueAuthority,
attestationQueue: this.publicKey,
enclave: functionAccount.getEnclaveAccount().publicKey,
grantee: functionAccount.publicKey,
}
);
@ -416,15 +411,15 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
const authority: Keypair = params?.authority ?? program.wallet.payer;
const attestationQueueKeypair = params?.keypair ?? Keypair.generate();
const verifierQuoteKeypair1 = Keypair.generate();
const verifierQuoteSigner1 = params?.securedSigner ?? Keypair.generate();
const verifierKeypair1 = Keypair.generate();
const verifierSigner1 = params?.enclaveSigner ?? Keypair.generate();
const ixns: Array<TransactionInstruction> = [];
const signers: Array<Keypair> = [
authority,
attestationQueueKeypair,
verifierQuoteKeypair1,
verifierQuoteSigner1,
verifierKeypair1,
verifierSigner1,
];
// create attestation queue
@ -459,7 +454,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
{
params: {
mrEnclave: Array.from(
parseMrEnclave(params?.quoteVerifierMrEnclave ?? "")
parseMrEnclave(params?.verifierrEnclave ?? "")
),
},
},
@ -472,7 +467,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
// create quote #1
ixns.push(
types.quoteInit(
types.verifierInit(
program,
{
params: {
@ -480,7 +475,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
},
},
{
quote: verifierQuoteKeypair1.publicKey,
verifier: verifierKeypair1.publicKey,
attestationQueue: attestationQueueKeypair.publicKey,
queueAuthority: authority.publicKey,
authority: authority.publicKey,
@ -494,7 +489,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
program,
authority.publicKey,
attestationQueueKeypair.publicKey,
verifierQuoteKeypair1.publicKey
verifierKeypair1.publicKey
);
ixns.push(
types.attestationPermissionInit(
@ -503,7 +498,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
{
permission: verifierQuotePermissions1.publicKey,
attestationQueue: attestationQueueKeypair.publicKey,
node: verifierQuoteKeypair1.publicKey,
node: verifierKeypair1.publicKey,
authority: authority.publicKey,
payer: authority.publicKey,
systemProgram: SystemProgram.programId,
@ -523,14 +518,14 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
permission: verifierQuotePermissions1.publicKey,
authority: authority.publicKey,
attestationQueue: attestationQueueKeypair.publicKey,
enclave: verifierQuoteKeypair1.publicKey,
grantee: verifierKeypair1.publicKey,
}
)
);
// set quote #1 securedSigner
ixns.push(
types.quoteRotate(
types.verifierQuoteRotate(
program,
{
params: {
@ -540,9 +535,9 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
},
},
{
quote: verifierQuoteKeypair1.publicKey,
verifier: verifierKeypair1.publicKey,
authority: authority.publicKey,
enclaveSigner: verifierQuoteSigner1.publicKey,
enclaveSigner: verifierSigner1.publicKey,
attestationQueue: attestationQueueKeypair.publicKey,
}
)
@ -550,15 +545,15 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
// quote #1 heartbeat
ixns.push(
types.quoteHeartbeat(
types.verifierHeartbeat(
program,
{ params: {} },
{
quote: verifierQuoteKeypair1.publicKey,
enclaveSigner: verifierQuoteSigner1.publicKey,
verifier: verifierKeypair1.publicKey,
verifierSigner: verifierSigner1.publicKey,
attestationQueue: attestationQueueKeypair.publicKey,
queueAuthority: authority.publicKey,
gcNode: verifierQuoteKeypair1.publicKey,
gcNode: verifierKeypair1.publicKey,
permission: verifierQuotePermissions1.publicKey,
}
)
@ -579,31 +574,40 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
);
return {
attestationQueueAccount,
signatures,
verifier: {
quoteAccount: new EnclaveAccount(
program,
verifierQuoteKeypair1.publicKey
),
permissionAccount: verifierQuotePermissions1,
signer: verifierQuoteSigner1,
program: program,
attestationQueue: {
account: attestationQueueAccount,
publicKey: attestationQueueAccount.publicKey,
authority: authority.publicKey,
},
verifier: {
account: new VerifierAccount(program, verifierKeypair1.publicKey),
publicKey: verifierKeypair1.publicKey,
permissionAccount: verifierQuotePermissions1,
signer: verifierSigner1,
},
signatures,
};
}
}
export type CreateBootstrappedQueueParams =
AttestationQueueAccountInitParams & {
quoteVerifierMrEnclave: RawBuffer;
registryKey: RawBuffer;
securedSigner?: Keypair;
verifierrEnclave: RawBuffer;
registryKey?: RawBuffer;
enclaveSigner?: Keypair;
};
export type BootstrappedAttestationQueue = {
attestationQueueAccount: AttestationQueueAccount;
program: SwitchboardProgram;
attestationQueue: {
account: AttestationQueueAccount;
publicKey: PublicKey;
authority: PublicKey;
};
verifier: {
quoteAccount: EnclaveAccount;
account: VerifierAccount;
publicKey: PublicKey;
permissionAccount: AttestationPermissionAccount;
signer: Keypair;
};

View File

@ -1,14 +1,13 @@
import * as errors from "../errors.js";
import { bufferRelayerSaveResult } from "../generated/oracle-program/index.js";
import * as types from "../generated/oracle-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type { TransactionObjectOptions } from "../TransactionObject.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account, OnAccountChangeCallback } from "./account.js";
import { JobAccount } from "./jobAccount.js";
import type { OnAccountChangeCallback } from "./account.js";
import { Account } from "./account.js";
import type { JobAccount } from "./jobAccount.js";
import { OracleAccount } from "./oracleAccount.js";
import { PermissionAccount } from "./permissionAccount.js";
import { QueueAccount } from "./queueAccount.js";
@ -20,14 +19,16 @@ import {
getAccount,
TOKEN_PROGRAM_ID,
} from "@solana/spl-token";
import {
import type {
Commitment,
TransactionInstruction,
TransactionSignature,
} from "@solana/web3.js";
import {
Keypair,
PublicKey,
SystemProgram,
SYSVAR_RENT_PUBKEY,
TransactionInstruction,
TransactionSignature,
} from "@solana/web3.js";
import { BN, promiseWithTimeout } from "@switchboard-xyz/common";

View File

@ -1,30 +1,27 @@
import * as errors from "../errors.js";
import * as types from "../generated/oracle-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account, OnAccountChangeCallback } from "./account.js";
import {
AggregatorAccount,
AggregatorPdaAccounts,
} from "./aggregatorAccount.js";
import type { OnAccountChangeCallback } from "./account.js";
import { Account } from "./account.js";
import type { AggregatorPdaAccounts } from "./aggregatorAccount.js";
import { AggregatorAccount } from "./aggregatorAccount.js";
import { CrankDataBuffer } from "./crankDataBuffer.js";
import { QueueAccount } from "./queueAccount.js";
import * as anchor from "@coral-xyz/anchor";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import {
import type {
AccountMeta,
Commitment,
Keypair,
PublicKey,
SystemProgram,
TransactionSignature,
} from "@solana/web3.js";
import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js";
/**
* Account holding a priority queue of aggregators and their next available update time. This is a scheduling mechanism to ensure {@linkcode AggregatorAccount}'s are updated as close as possible to their specified update interval.

View File

@ -1,14 +1,12 @@
import * as errors from "../errors.js";
import * as types from "../generated/oracle-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
Account,
BUFFER_DISCRIMINATOR,
OnAccountChangeCallback,
} from "./account.js";
import type { OnAccountChangeCallback } from "./account.js";
import { Account, BUFFER_DISCRIMINATOR } from "./account.js";
import { AccountInfo, Commitment, PublicKey } from "@solana/web3.js";
import type { AccountInfo, Commitment } from "@solana/web3.js";
import { PublicKey } from "@solana/web3.js";
import { BN } from "@switchboard-xyz/common";
/**

View File

@ -1,32 +1,32 @@
import { Account } from "../accounts/account.js";
import * as errors from "../errors.js";
import * as types from "../generated/attestation-program/index.js";
import {
SB_ATTESTATION_PID,
SB_V2_PID,
SwitchboardProgram,
} from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import { SB_ATTESTATION_PID, SB_V2_PID } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { RawBuffer } from "../types.js";
import { TransactionObject } from "../TransactionObject.js";
import type { RawBuffer } from "../types.js";
import {
handleOptionalPubkeys,
numToBN,
parseCronSchedule,
parseMrEnclave,
parseRawBuffer,
} from "../utils.js";
import type {
FunctionRequestAccountInitParams,
SwitchboardWalletFundParams,
VerifierAccount,
} from "./index.js";
import {
AttestationPermissionAccount,
AttestationQueueAccount,
EnclaveAccount,
FunctionRequestAccount,
FunctionRequestAccountInitParams,
SwitchboardWallet,
SwitchboardWalletFundParams,
} from "./index.js";
import * as anchor from "@coral-xyz/anchor";
@ -35,20 +35,24 @@ import {
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
} from "@solana/spl-token";
import {
import type {
AccountInfo,
AddressLookupTableAccount,
ComputeBudgetProgram,
Keypair,
PublicKey,
SendOptions,
SystemProgram,
TransactionInstruction,
TransactionSignature,
} from "@solana/web3.js";
import {
ComputeBudgetProgram,
PublicKey,
SystemProgram,
} from "@solana/web3.js";
import { BN, toUtf8 } from "@switchboard-xyz/common";
import assert from "assert";
export type ContainerRegistryType = "dockerhub" | "ipfs";
export type FunctionAccountInitSeeds = {
recentSlot?: number;
creatorSeed?: RawBuffer; // defaults to payer pubkey bytes
@ -61,9 +65,9 @@ export type FunctionAccountInitParams = FunctionAccountInitSeeds & {
name?: string;
metadata?: string;
container: string;
version: string;
containerRegistry?: string;
schedule: string;
version?: string;
containerRegistry?: ContainerRegistryType;
schedule?: string;
mrEnclave: Buffer | Uint8Array | number[];
attestationQueue: AttestationQueueAccount;
@ -88,7 +92,7 @@ export interface FunctionSetConfigParams {
name?: string;
metadata?: string;
container?: string;
containerRegistry?: string;
containerRegistry?: ContainerRegistryType;
version?: string;
schedule?: string;
mrEnclaves?: Array<RawBuffer>;
@ -100,6 +104,24 @@ export interface FunctionSetConfigParams {
authority?: Keypair;
}
/**
* Parameters for setting a {@linkcode FunctionAccount} escrow
*/
export interface FunctionSetEscrowParams {
authority?: Keypair;
newEscrow: SwitchboardWallet;
newEscrowAuthority?: Keypair;
}
/**
* Parameters for setting a {@linkcode FunctionAccount} authority
*/
export interface FunctionSetAuthorityParams {
authority?: Keypair;
newAuthority: PublicKey;
walletAuthority?: Keypair;
}
/**
* Parameters for an {@linkcode types.functionVerify} instruction.
*/
@ -111,8 +133,6 @@ export interface FunctionVerifySyncParams {
mrEnclave: Uint8Array;
escrowWallet: PublicKey;
functionAuthority: PublicKey;
functionEnclaveSigner: PublicKey;
attestationQueue: PublicKey;
@ -133,7 +153,7 @@ export interface FunctionVerifyParams {
nextAllowedTimestamp: anchor.BN;
isFailure: boolean;
mrEnclave: Uint8Array;
verifier: EnclaveAccount;
verifier: VerifierAccount;
verifierEnclaveSigner: PublicKey;
functionEnclaveSigner: PublicKey;
receiver: PublicKey;
@ -170,14 +190,14 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
/**
* Returns the functions's name buffer in a stringified format.
*/
public static getName = (functionData: types.FunctionAccountData) =>
toUtf8(functionData.name);
public static getName = (functionState: types.FunctionAccountData) =>
toUtf8(functionState.name);
/**
* Returns the functions's metadata buffer in a stringified format.
*/
public static getMetadata = (functionData: types.FunctionAccountData) =>
toUtf8(functionData.metadata);
public static getMetadata = (functionState: types.FunctionAccountData) =>
toUtf8(functionState.metadata);
/**
* Load an existing {@linkcode FunctionAccount} with its current on-chain state
@ -302,7 +322,9 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
const authorityPubkey = params.authority ?? payer;
const cronSchedule = parseCronSchedule(params.schedule);
const cronSchedule: Buffer = params.schedule
? Buffer.from(parseCronSchedule(params.schedule), "utf-8")
: Buffer.from(Array(64).fill(0));
const attestationQueueAccount = params.attestationQueue;
@ -360,8 +382,6 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
escrowWalletAuthority = authorityPubkey;
}
const enclaveAccount = functionAccount.getEnclaveAccount();
const instruction = types.functionInit(
program,
{
@ -370,10 +390,12 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
metadata: new Uint8Array(Buffer.from(params.metadata ?? "", "utf8")),
container: new Uint8Array(Buffer.from(params.container, "utf8")),
containerRegistry: new Uint8Array(
Buffer.from(params.containerRegistry ?? "", "utf8")
Buffer.from(params.containerRegistry ?? "dockerhub", "utf8")
),
version: new Uint8Array(Buffer.from(params.version, "utf8")),
schedule: new Uint8Array(Buffer.from(cronSchedule, "utf8")),
version: new Uint8Array(
Buffer.from(params.version ?? "latest", "utf8")
),
schedule: new Uint8Array(cronSchedule),
mrEnclave: Array.from(parseMrEnclave(params.mrEnclave)),
recentSlot: recentSlot,
requestsDisabled: params.requestsDisabled ?? false,
@ -391,13 +413,11 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
function: functionAccount.publicKey,
addressLookupTable: addressLookupTable,
authority: authorityPubkey,
quote: enclaveAccount.publicKey,
attestationQueue: attestationQueueAccount.publicKey,
payer,
wallet: escrowWallet.publicKey,
walletAuthority: escrowWalletAuthority,
tokenWallet: escrowWallet.tokenWallet,
state: program.attestationProgramState.publicKey,
mint: program.mint.address,
tokenProgram: TOKEN_PROGRAM_ID,
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
@ -442,10 +462,6 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
return [account, txSignature];
}
public getEnclaveAccount(): EnclaveAccount {
return EnclaveAccount.fromSeed(this.program, this.publicKey);
}
public async createRequestInstruction(
payer: PublicKey,
params: CreateFunctionRequestParams,
@ -484,18 +500,18 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
params: FunctionSetConfigParams,
options?: TransactionObjectOptions
): Promise<TransactionObject> {
const functionData = await this.loadData();
const functionState = await this.loadData();
if (params.authority) {
if (!params.authority.publicKey.equals(functionData.authority)) {
if (!params.authority.publicKey.equals(functionState.authority)) {
throw new errors.IncorrectAuthority(
functionData.authority,
functionState.authority,
params.authority.publicKey
);
}
} else {
if (!payer.equals(functionData.authority)) {
throw new errors.IncorrectAuthority(functionData.authority, payer);
if (!payer.equals(functionState.authority)) {
throw new errors.IncorrectAuthority(functionState.authority, payer);
}
}
@ -521,17 +537,17 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
requestsDisabled: params.requestsDisabled ?? null,
requestsRequireAuthorization:
params.requestsRequireAuthorization ?? null,
requestsDefaultSlotsUntilExpiration:
requestsDefaultSlotsUntilExpiration: Number.isFinite(
params.requestsDefaultSlotsUntilExpiration
? new BN(params.requestsDefaultSlotsUntilExpiration)
: null,
)
? new BN(params.requestsDefaultSlotsUntilExpiration)
: null,
requestsFee: params.requestsFee ? new BN(params.requestsFee) : null,
},
},
{
function: this.publicKey,
quote: this.getEnclaveAccount().publicKey,
authority: functionData.authority,
authority: functionState.authority,
}
);
@ -554,6 +570,112 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
).then((txn) => this.program.signAndSend(txn, options));
}
public async setEscrowInstruction(
payer: PublicKey,
params: FunctionSetEscrowParams,
options?: TransactionObjectOptions
): Promise<TransactionObject> {
const signers: Keypair[] = [];
if (params.authority) {
signers.push(params.authority);
}
if (params.newEscrowAuthority) {
signers.push(params.newEscrowAuthority);
}
const functionState = await this.loadData();
const currentWallet = await this.wallet;
const currentWalletState = await currentWallet.loadData();
const newWallet = params.newEscrow;
const newWalletState = await newWallet.loadData();
const functionSetEscrowIxn = types.functionSetEscrow(
this.program,
{ params: {} },
{
function: this.publicKey,
authority: functionState.authority,
attestationQueue: functionState.attestationQueue,
escrowWallet: currentWallet.publicKey,
escrowAuthority: currentWalletState.authority,
newEscrow: newWallet.publicKey,
newEscrowAuthority: newWalletState.authority,
newEscrowTokenWallet: newWallet.tokenWallet,
}
);
return new TransactionObject(
payer,
[functionSetEscrowIxn],
signers,
options
);
}
public async setEscrow(
params: FunctionSetEscrowParams,
options?: SendTransactionObjectOptions
): Promise<TransactionSignature> {
return await this.setEscrowInstruction(
this.program.walletPubkey,
params,
options
).then((txn) => this.program.signAndSend(txn, options));
}
public async setAuthorityInstruction(
payer: PublicKey,
params: FunctionSetAuthorityParams,
options?: TransactionObjectOptions
): Promise<TransactionObject> {
const signers: Keypair[] = [];
if (params.authority) {
signers.push(params.authority);
}
if (params.walletAuthority) {
signers.push(params.walletAuthority);
}
const functionState = await this.loadData();
const wallet = await this.wallet;
const walletState = await wallet.loadData();
const functionSetAuthorityIxn = types.functionSetAuthority(
this.program,
{ params: {} },
{
function: this.publicKey,
authority: functionState.authority,
attestationQueue: functionState.attestationQueue,
escrowWallet: wallet.publicKey,
escrowAuthority: walletState.authority,
newAuthority: params.newAuthority,
walletAuthority: params.walletAuthority
? params.walletAuthority.publicKey
: SB_ATTESTATION_PID,
}
);
return new TransactionObject(
payer,
[handleOptionalPubkeys(functionSetAuthorityIxn)],
signers,
options
);
}
public async setAuthority(
params: FunctionSetAuthorityParams,
options?: SendTransactionObjectOptions
): Promise<TransactionSignature> {
return await this.setAuthorityInstruction(
this.program.walletPubkey,
params,
options
).then((txn) => this.program.signAndSend(txn, options));
}
public async resetEscrowInstruction(
payer: PublicKey,
authority?: Keypair,
@ -582,7 +704,6 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
defaultWallet: defaultWallet.publicKey,
tokenWallet: defaultWallet.tokenWallet,
payer: payer,
state: this.program.attestationProgramState.publicKey,
tokenProgram: anchor.utils.token.TOKEN_PROGRAM_ID,
associatedTokenProgram: anchor.utils.token.ASSOCIATED_PROGRAM_ID,
systemProgram: anchor.web3.SystemProgram.programId,
@ -693,7 +814,6 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
public verifyInstructionSync(
params: FunctionVerifySyncParams
): TransactionInstruction {
const fnEnclaveAccount = this.getEnclaveAccount();
const wallet = new SwitchboardWallet(this.program, params.escrowWallet);
const escrowTokenWallet = wallet.tokenWallet;
@ -710,12 +830,10 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
{
// fn accounts
function: this.publicKey,
authority: params.functionAuthority,
functionEnclaveSigner: params.functionEnclaveSigner,
fnQuote: fnEnclaveAccount.publicKey,
// verifier accounts
verifierQuote: params.quoteVerifier,
verifierEnclaveSigner: params.quoteVerifierEnclaveSigner,
verifier: params.quoteVerifier,
verifierSigner: params.quoteVerifierEnclaveSigner,
verifierPermission: AttestationPermissionAccount.fromSeed(
this.program,
params.attestationQueueAuthority,
@ -727,7 +845,6 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
escrowTokenWallet: escrowTokenWallet,
receiver: params.receiver,
// others
state: this.program.attestationProgramState.publicKey,
attestationQueue: params.attestationQueue,
tokenProgram: spl.TOKEN_PROGRAM_ID,
}
@ -739,7 +856,7 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
): Promise<TransactionInstruction> {
this.program.verifyAttestation();
const functionData = params.fnState ?? (await this.loadData());
const functionState = params.fnState ?? (await this.loadData());
const wallet = await this.wallet;
@ -747,7 +864,7 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
if (!attestationQueueAuthority) {
const attestationQueueAccount = new AttestationQueueAccount(
this.program,
functionData.attestationQueue
functionState.attestationQueue
);
attestationQueueAuthority = (await attestationQueueAccount.loadData())
.authority;
@ -762,14 +879,13 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
mrEnclave: params.mrEnclave,
escrowWallet: wallet.publicKey,
functionAuthority: functionData.authority,
functionEnclaveSigner: params.functionEnclaveSigner,
attestationQueue: functionData.attestationQueue,
attestationQueue: functionState.attestationQueue,
attestationQueueAuthority: attestationQueueAuthority,
quoteVerifier: params.verifier.publicKey,
quoteVerifierEnclaveSigner: quoteVerifier.enclaveSigner,
quoteVerifierEnclaveSigner: quoteVerifier.enclave.enclaveSigner,
receiver: params.receiver,
});
@ -803,7 +919,7 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
isFailure: boolean;
mrEnclave: Uint8Array;
verifier: EnclaveAccount;
verifier: VerifierAccount;
verifierEnclaveSigner: Keypair;
functionEnclaveSigner: Keypair;
@ -836,19 +952,19 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
params?: FunctionTriggerParams,
options?: TransactionObjectOptions
): Promise<TransactionObject> {
const functionData = await this.loadData();
const functionState = await this.loadData();
// verify authority is correct
if (params && params?.authority) {
if (!params.authority.publicKey.equals(functionData.authority)) {
if (!params.authority.publicKey.equals(functionState.authority)) {
throw new errors.IncorrectAuthority(
functionData.authority,
functionState.authority,
params.authority.publicKey
);
}
} else {
if (!payer.equals(functionData.authority)) {
throw new errors.IncorrectAuthority(functionData.authority, payer);
if (!payer.equals(functionState.authority)) {
throw new errors.IncorrectAuthority(functionState.authority, payer);
}
}
@ -857,15 +973,16 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
{ params: {} },
{
function: this.publicKey,
authority: functionData.authority,
attestationQueue: functionData.attestationQueue,
authority: functionState.authority,
attestationQueue: functionState.attestationQueue,
}
);
return new TransactionObject(
payer,
[functionTrigger],
params?.authority ? [params.authority] : []
params?.authority ? [params.authority] : [],
options
);
}
@ -882,7 +999,7 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
public static decodeAddressLookup(lookupTable: AddressLookupTableAccount) {
const addresses = lookupTable.state.addresses;
if (addresses.length < 18) {
if (addresses.length < 16) {
throw new Error(`Failed to decode address lookup table`);
}
@ -943,14 +1060,12 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
}
// switchboard accounts, not worth the network calls
const statePubkey = addresses[10]!;
const attestationQueuePubkey = addresses[11]!;
const functionPubkey = addresses[12]!;
const functionAuthorityPubkey = addresses[13]!;
const fnQuote = addresses[14]!;
const mintPubkey = addresses[15]!;
const walletPubkey = addresses[16]!;
const escrowPubkey = addresses[17]!;
const attestationQueuePubkey = addresses[10]!;
const functionPubkey = addresses[11]!;
const functionAuthorityPubkey = addresses[12]!;
const mintPubkey = addresses[13]!;
const walletPubkey = addresses[14]!;
const escrowPubkey = addresses[15]!;
return {
systemProgram, // 1
@ -963,14 +1078,33 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
sysVarSlotHistory,
switchboardProgram,
attestationProgram, // 10
statePubkey,
attestationQueuePubkey,
functionPubkey,
functionAuthorityPubkey,
fnQuote, // 15
mintPubkey,
walletPubkey,
escrowPubkey, // 18
walletPubkey, // 15
escrowPubkey, // 16
};
}
public static getVerificationStatus(
state: types.FunctionAccountData
): types.VerificationStatusKind {
switch (state.enclave.verificationStatus) {
case types.VerificationStatus.None.discriminator:
return new types.VerificationStatus.None();
case types.VerificationStatus.VerificationPending.discriminator:
return new types.VerificationStatus.VerificationPending();
case types.VerificationStatus.VerificationFailure.discriminator:
return new types.VerificationStatus.VerificationFailure();
case types.VerificationStatus.VerificationSuccess.discriminator:
return new types.VerificationStatus.VerificationSuccess();
case types.VerificationStatus.VerificationOverride.discriminator:
return new types.VerificationStatus.VerificationOverride();
}
throw new Error(
`Failed to get the verification status, expected [${types.VerificationStatus.None.discriminator}, ${types.VerificationStatus.VerificationPending.discriminator}, ${types.VerificationStatus.VerificationFailure.discriminator}, ${types.VerificationStatus.VerificationSuccess.discriminator}], or ${types.VerificationStatus.VerificationOverride.discriminator}], received ${state.enclave.verificationStatus}`
);
}
}

View File

@ -1,13 +1,13 @@
import { Account } from "../accounts/account.js";
import * as errors from "../errors.js";
import * as types from "../generated/attestation-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { RawBuffer } from "../types.js";
import { TransactionObject } from "../TransactionObject.js";
import type { RawBuffer } from "../types.js";
import { parseMrEnclave } from "../utils.js";
import { FunctionAccount } from "./index.js";
@ -16,13 +16,12 @@ import {
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_PROGRAM_ID,
} from "@solana/spl-token";
import {
Keypair,
import type {
PublicKey,
SystemProgram,
TransactionInstruction,
TransactionSignature,
} from "@solana/web3.js";
import { Keypair, SystemProgram } from "@solana/web3.js";
import { BN } from "@switchboard-xyz/common";
/**

View File

@ -7,7 +7,6 @@ export * from "./attestationQueueAccount.js";
export * from "./bufferRelayAccount.js";
export * from "./crankAccount.js";
export * from "./crankDataBuffer.js";
export * from "./enclaveAccount.js";
export * from "./functionAccount.js";
export * from "./functionRequestAccount.js";
export * from "./jobAccount.js";
@ -18,6 +17,7 @@ export * from "./programStateAccount.js";
export * from "./queueAccount.js";
export * from "./queueDataBuffer.js";
export * from "./switchboardWallet.js";
export * from "./verifierAccount.js";
export * from "./vrfAccount.js";
export * from "./vrfLiteAccount.js";
export * from "./vrfPoolAccount.js";

View File

@ -1,23 +1,25 @@
import * as errors from "../errors.js";
import * as types from "../generated/oracle-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account } from "./account.js";
import * as anchor from "@coral-xyz/anchor";
import {
import type {
AccountInfo,
Commitment,
TransactionSignature,
} from "@solana/web3.js";
import {
Keypair,
LAMPORTS_PER_SOL,
PublicKey,
SystemProgram,
TransactionSignature,
} from "@solana/web3.js";
import { BN, OracleJob, toUtf8 } from "@switchboard-xyz/common";

View File

@ -1,28 +1,31 @@
import * as errors from "../errors.js";
import * as types from "../generated/oracle-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account } from "./account.js";
import { AggregatorAccount } from "./aggregatorAccount.js";
import { JobAccount } from "./jobAccount.js";
import type { JobAccount } from "./jobAccount.js";
import { QueueAccount } from "./queueAccount.js";
import * as spl from "@solana/spl-token";
import {
import type {
AccountInfo,
AccountMeta,
TransactionSignature,
} from "@solana/web3.js";
import {
Keypair,
LAMPORTS_PER_SOL,
PublicKey,
SystemProgram,
TransactionSignature,
} from "@solana/web3.js";
import { BN, OracleJob } from "@switchboard-xyz/common";
import type { OracleJob } from "@switchboard-xyz/common";
import { BN } from "@switchboard-xyz/common";
/**
* Account type representing an {@linkcode AggregatorAccount}'s pre-funded escrow used to reward {@linkcode OracleAccount}'s for responding to open round requests.

View File

@ -1,29 +1,32 @@
import * as errors from "../errors.js";
import * as types from "../generated/oracle-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account, OnAccountChangeCallback } from "./account.js";
import type { OnAccountChangeCallback } from "./account.js";
import { Account } from "./account.js";
import { PermissionAccount } from "./permissionAccount.js";
import { QueueAccount } from "./queueAccount.js";
import * as anchor from "@coral-xyz/anchor";
import * as spl from "@solana/spl-token";
import {
import type {
AccountInfo,
Commitment,
TransactionInstruction,
TransactionSignature,
} from "@solana/web3.js";
import {
Keypair,
LAMPORTS_PER_SOL,
PublicKey,
SystemProgram,
TransactionInstruction,
TransactionSignature,
} from "@solana/web3.js";
import { BN } from "@switchboard-xyz/common";
import type { BN } from "@switchboard-xyz/common";
/**
* Account type holding an oracle's configuration including the authority and the reward/slashing wallet along with a set of metrics tracking its reliability.

View File

@ -6,24 +6,22 @@ import {
PermitOracleQueueUsage,
PermitVrfRequests,
} from "../generated/oracle-program/types/SwitchboardPermission.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account } from "./account.js";
import { ACCOUNT_DISCRIMINATOR_SIZE } from "@coral-xyz/anchor";
import {
import type {
AccountInfo,
Keypair,
LAMPORTS_PER_SOL,
PublicKey,
SystemProgram,
TransactionSignature,
} from "@solana/web3.js";
import { LAMPORTS_PER_SOL, PublicKey, SystemProgram } from "@solana/web3.js";
/**
* Parameters for initializing an {@linkcode PermissionAccount}

View File

@ -1,21 +1,19 @@
import * as errors from "../errors.js";
import * as types from "../generated/oracle-program/index.js";
import { Mint } from "../mint.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account } from "./account.js";
import * as anchor from "@coral-xyz/anchor";
import type * as anchor from "@coral-xyz/anchor";
import * as spl from "@solana/spl-token";
import {
Keypair,
PublicKey,
SystemProgram,
import type {
TransactionInstruction,
TransactionSignature,
} from "@solana/web3.js";
import { BN } from "@switchboard-xyz/common";
import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js";
import type { BN } from "@switchboard-xyz/common";
/**
* Account type representing Switchboard global program state.

View File

@ -6,45 +6,40 @@ import {
PermitVrfRequests,
} from "../generated/oracle-program/types/SwitchboardPermission.js";
import { SolanaClock } from "../SolanaClock.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account, OnAccountChangeCallback } from "./account.js";
import {
AggregatorAccount,
AggregatorInitParams,
} from "./aggregatorAccount.js";
import type { OnAccountChangeCallback } from "./account.js";
import { Account } from "./account.js";
import type { AggregatorInitParams } from "./aggregatorAccount.js";
import { AggregatorAccount } from "./aggregatorAccount.js";
import { AggregatorHistoryBuffer } from "./aggregatorHistoryBuffer.js";
import {
BufferRelayerAccount,
BufferRelayerInit,
} from "./bufferRelayAccount.js";
import { CrankAccount, CrankInitParams } from "./crankAccount.js";
import { JobAccount, JobInitParams } from "./jobAccount.js";
import { LeaseAccount, LeaseInitParams } from "./leaseAccount.js";
import {
OracleAccount,
OracleInitParams,
OracleStakeParams,
} from "./oracleAccount.js";
import { PermissionAccount, PermissionSetParams } from "./permissionAccount.js";
import type { BufferRelayerInit } from "./bufferRelayAccount.js";
import { BufferRelayerAccount } from "./bufferRelayAccount.js";
import type { CrankInitParams } from "./crankAccount.js";
import { CrankAccount } from "./crankAccount.js";
import type { JobInitParams } from "./jobAccount.js";
import { JobAccount } from "./jobAccount.js";
import type { LeaseInitParams } from "./leaseAccount.js";
import { LeaseAccount } from "./leaseAccount.js";
import type { OracleInitParams, OracleStakeParams } from "./oracleAccount.js";
import { OracleAccount } from "./oracleAccount.js";
import type { PermissionSetParams } from "./permissionAccount.js";
import { PermissionAccount } from "./permissionAccount.js";
import { QueueDataBuffer } from "./queueDataBuffer.js";
import { VrfAccount, VrfInitParams } from "./vrfAccount.js";
import { VrfLiteAccount, VrfLiteInitParams } from "./vrfLiteAccount.js";
import type { VrfInitParams } from "./vrfAccount.js";
import { VrfAccount } from "./vrfAccount.js";
import type { VrfLiteInitParams } from "./vrfLiteAccount.js";
import { VrfLiteAccount } from "./vrfLiteAccount.js";
import * as anchor from "@coral-xyz/anchor";
import * as spl from "@solana/spl-token";
import {
Commitment,
Keypair,
PublicKey,
SystemProgram,
TransactionSignature,
} from "@solana/web3.js";
import type * as anchor from "@coral-xyz/anchor";
import type * as spl from "@solana/spl-token";
import type { Commitment, TransactionSignature } from "@solana/web3.js";
import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js";
import { Big, BN, SwitchboardDecimal, toUtf8 } from "@switchboard-xyz/common";
/**
@ -917,18 +912,20 @@ export class QueueAccount extends Account<types.OracleQueueAccountData> {
options
);
// eslint-disable-next-line prefer-const
let [permissionAccount, permissionInit] =
PermissionAccount.createInstruction(
this.program,
payer,
{
granter: this.publicKey,
grantee: vrfAccount.publicKey,
authority: queueAuthorityPubkey,
},
options
);
let [
// eslint-disable-next-line prefer-const
permissionAccount,
permissionInit,
] = PermissionAccount.createInstruction(
this.program,
payer,
{
granter: this.publicKey,
grantee: vrfAccount.publicKey,
authority: queueAuthorityPubkey,
},
options
);
if (
params.enable &&
@ -1059,13 +1056,15 @@ export class QueueAccount extends Account<types.OracleQueueAccountData> {
txns.push(bufferInit);
// eslint-disable-next-line prefer-const
let [permissionAccount, permissionInit] =
PermissionAccount.createInstruction(this.program, payer, {
granter: this.publicKey,
grantee: bufferAccount.publicKey,
authority: queueAuthorityPubkey,
});
let [
// eslint-disable-next-line prefer-const
permissionAccount,
permissionInit,
] = PermissionAccount.createInstruction(this.program, payer, {
granter: this.publicKey,
grantee: bufferAccount.publicKey,
authority: queueAuthorityPubkey,
});
if (
params.enable &&

View File

@ -1,19 +1,12 @@
import * as errors from "../errors.js";
import * as types from "../generated/oracle-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import type * as types from "../generated/oracle-program/index.js";
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
Account,
BUFFER_DISCRIMINATOR,
OnAccountChangeCallback,
} from "./account.js";
import type { OnAccountChangeCallback } from "./account.js";
import { Account, BUFFER_DISCRIMINATOR } from "./account.js";
import {
AccountInfo,
Commitment,
LAMPORTS_PER_SOL,
PublicKey,
} from "@solana/web3.js";
import type { AccountInfo, Commitment } from "@solana/web3.js";
import { LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";
import assert from "assert";
/**

View File

@ -1,24 +1,23 @@
import * as errors from "../errors.js";
import * as types from "../generated/attestation-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { TransactionObject } from "../TransactionObject.js";
import { parseRawBuffer } from "../utils.js";
import { Account } from "./account.js";
import * as spl from "@solana/spl-token";
import {
import type {
AccountMeta,
Keypair,
PublicKey,
SystemProgram,
TransactionSignature,
} from "@solana/web3.js";
import { BN } from "@switchboard-xyz/common";
import { PublicKey, SystemProgram } from "@solana/web3.js";
import type { BN } from "@switchboard-xyz/common";
import assert from "assert";
export interface SwitchboardWalletTransferParams {

View File

@ -1,12 +1,12 @@
import * as errors from "../errors.js";
import * as types from "../generated/attestation-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { RawBuffer } from "../types.js";
import { TransactionObject } from "../TransactionObject.js";
import type { RawBuffer } from "../types.js";
import { parseMrEnclave, parseRawBuffer } from "../utils.js";
import { Account } from "./account.js";
@ -15,21 +15,19 @@ import {
AttestationQueueAccount,
} from "./index.js";
import * as anchor from "@coral-xyz/anchor";
import {
Keypair,
PublicKey,
SystemProgram,
import type * as anchor from "@coral-xyz/anchor";
import type {
TransactionInstruction,
TransactionSignature,
} from "@solana/web3.js";
import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js";
export const QUOTE_SEED: string = "QuoteAccountData";
/**
* Parameters for initializing an {@linkcode EnclaveAccount}
* Parameters for initializing an {@linkcode VerifierAccount}
*/
export interface EnclaveAccountInitParams {
export interface VerifierAccountInitParams {
/**
* Key to lookup the buffer data on IPFS or an alternative decentralized storage solution.
*/
@ -55,7 +53,7 @@ export interface EnclaveAccountInitParams {
/**
* Parameters for an {@linkcode types.quoteHeartbeat} instruction.
*/
export interface EnclaveHeartbeatSyncParams {
export interface VerifierHeartbeatSyncParams {
gcOracle: PublicKey;
attestationQueue: PublicKey;
permission: AttestationPermissionAccount;
@ -65,17 +63,17 @@ export interface EnclaveHeartbeatSyncParams {
/**
* Parameters for an {@linkcode types.quoteHeartbeat} instruction.
*/
export type EnclaveHeartbeatParams = Partial<EnclaveHeartbeatSyncParams> & {
export type VerifierHeartbeatParams = Partial<VerifierHeartbeatSyncParams> & {
enclaveSigner: Keypair;
} & Partial<{
quote: types.EnclaveAccountData;
quote: types.VerifierAccountData;
queue: types.AttestationQueueAccountData;
}>;
/**
* Parameters for an {@linkcode types.quoteVerify} instruction.
*/
export interface EnclaveVerifyParams {
export interface QuoteVerifyParams {
/**
* @TODO: Docs for timestamp
*/
@ -86,16 +84,18 @@ export interface EnclaveVerifyParams {
mrEnclave: RawBuffer;
/**
* Keypair of the secured signer generated in the verifiers secure enclave
* Keypair of the enclave signer generated in the verifiers secure enclave
*/
verifierSecuredSigner: Keypair;
verifier: PublicKey;
enclaveSigner?: Keypair;
quote: VerifierAccount;
quoteState?: types.VerifierAccountData;
}
/**
* Parameters for an {@linkcode types.quoteRotate} instruction.
*/
export interface EnclaveRotateParams {
export interface VerifierRotateParams {
authority?: Keypair;
enclaveSigner: Keypair;
registryKey: string | Buffer | Uint8Array;
@ -104,41 +104,41 @@ export interface EnclaveRotateParams {
/**
* Account type representing a Switchboard Attestation quote.
*
* Data: {@linkcode types.EnclaveAccountData}
* Data: {@linkcode types.VerifierAccountData}
*/
export class EnclaveAccount extends Account<types.EnclaveAccountData> {
static accountName = "EnclaveAccountData";
export class VerifierAccount extends Account<types.VerifierAccountData> {
static accountName = "VerifierAccountData";
/**
* Load an existing {@linkcode EnclaveAccount} with its current on-chain state
* Load an existing {@linkcode VerifierAccount} with its current on-chain state
*/
public static async load(
program: SwitchboardProgram,
address: PublicKey | string
): Promise<[EnclaveAccount, types.EnclaveAccountData]> {
): Promise<[VerifierAccount, types.VerifierAccountData]> {
program.verifyAttestation();
const enclaveAccount = new EnclaveAccount(program, address);
const state = await enclaveAccount.loadData();
return [enclaveAccount, state];
const verifierAccount = new VerifierAccount(program, address);
const state = await verifierAccount.loadData();
return [verifierAccount, state];
}
/**
* Finds the {@linkcode EnclaveAccount} from the seed from which it was generated.
* Finds the {@linkcode VerifierAccount} from the seed from which it was generated.
*
* Only applicable for EnclaveAccounts tied to a {@linkcode FunctionAccount}. Enclaves can also be generated from a keypair.
* Only applicable for VerifierAccounts tied to a {@linkcode FunctionAccount}. Enclaves can also be generated from a keypair.
*
* @return EnclaveAccount and PDA bump tuple.
* @return VerifierAccount and PDA bump tuple.
*/
public static fromSeed(
program: SwitchboardProgram,
functionPubkey: PublicKey
): EnclaveAccount {
): VerifierAccount {
const [publicKey, bump] = PublicKey.findProgramAddressSync(
[Buffer.from(QUOTE_SEED), functionPubkey.toBytes()],
program.attestationProgramId
);
return new EnclaveAccount(program, publicKey);
return new VerifierAccount(program, publicKey);
}
/**
@ -147,13 +147,13 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
public static async createInstruction(
program: SwitchboardProgram,
payer: PublicKey,
params: EnclaveAccountInitParams,
params: VerifierAccountInitParams,
options?: TransactionObjectOptions
): Promise<[EnclaveAccount, TransactionObject]> {
): Promise<[VerifierAccount, TransactionObject]> {
program.verifyAttestation();
const quoteKeypair = params.keypair ?? Keypair.generate();
program.verifyNewKeypair(quoteKeypair);
const verifierKeypair = params.keypair ?? Keypair.generate();
program.verifyNewKeypair(verifierKeypair);
const queueData = await params.queueAccount.loadData();
@ -161,11 +161,11 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
.concat(Array(64).fill(0))
.slice(0, 64);
const instruction = types.quoteInit(
const instruction = types.verifierInit(
program,
{ params: { registryKey } },
{
quote: quoteKeypair.publicKey,
verifier: verifierKeypair.publicKey,
attestationQueue: params.queueAccount.publicKey,
queueAuthority: queueData.authority,
authority: params.authority ?? payer,
@ -174,16 +174,16 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
}
);
return [
new EnclaveAccount(program, quoteKeypair.publicKey),
new TransactionObject(payer, [instruction], [quoteKeypair], options),
new VerifierAccount(program, verifierKeypair.publicKey),
new TransactionObject(payer, [instruction], [verifierKeypair], options),
];
}
public static async create(
program: SwitchboardProgram,
params: EnclaveAccountInitParams,
params: VerifierAccountInitParams,
options?: SendTransactionObjectOptions
): Promise<[EnclaveAccount, TransactionSignature]> {
): Promise<[VerifierAccount, TransactionSignature]> {
const [account, txnObject] = await this.createInstruction(
program,
program.walletPubkey,
@ -208,9 +208,9 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
}
static getVerificationStatus(
state: types.EnclaveAccountData
state: types.VerifierAccountData
): types.VerificationStatusKind {
switch (state.verificationStatus) {
switch (state.enclave.verificationStatus) {
case types.VerificationStatus.None.discriminator:
return new types.VerificationStatus.None();
case types.VerificationStatus.VerificationPending.discriminator:
@ -224,27 +224,27 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
}
throw new Error(
`Failed to get the verification status, expected [${types.VerificationStatus.None.discriminator}, ${types.VerificationStatus.VerificationPending.discriminator}, ${types.VerificationStatus.VerificationFailure.discriminator}, ${types.VerificationStatus.VerificationSuccess.discriminator}], or ${types.VerificationStatus.VerificationOverride.discriminator}], received ${state.verificationStatus}`
`Failed to get the verification status, expected [${types.VerificationStatus.None.discriminator}, ${types.VerificationStatus.VerificationPending.discriminator}, ${types.VerificationStatus.VerificationFailure.discriminator}, ${types.VerificationStatus.VerificationSuccess.discriminator}], or ${types.VerificationStatus.VerificationOverride.discriminator}], received ${state.enclave.verificationStatus}`
);
}
/**
* Get the size of an {@linkcode EnclaveAccount} on-chain.
* Get the size of an {@linkcode VerifierAccount} on-chain.
*/
public readonly size =
this.program.attestationAccount.enclaveAccountData.size;
this.program.attestationAccount.verifierAccountData.size;
/**
* Retrieve and decode the {@linkcode types.EnclaveAccountData} stored in this account.
* Retrieve and decode the {@linkcode types.VerifierAccountData} stored in this account.
*/
public async loadData(): Promise<types.EnclaveAccountData> {
public async loadData(): Promise<types.VerifierAccountData> {
this.program.verifyAttestation();
const data = await types.EnclaveAccountData.fetch(
const data = await types.VerifierAccountData.fetch(
this.program,
this.publicKey
);
if (data) return data;
throw new errors.AccountNotFoundError("Enclave", this.publicKey);
throw new errors.AccountNotFoundError("Verifier", this.publicKey);
}
public heartbeatInstruction(params: {
@ -256,12 +256,12 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
}): TransactionInstruction {
this.program.verifyAttestation();
const instruction = types.quoteHeartbeat(
const instruction = types.verifierHeartbeat(
this.program,
{ params: {} },
{
quote: this.publicKey,
enclaveSigner: params.enclaveSigner,
verifier: this.publicKey,
verifierSigner: params.enclaveSigner,
attestationQueue: params.attestationQueue,
queueAuthority: params.queueAuthority,
gcNode: params.gcOracle,
@ -272,7 +272,7 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
}
public async heartbeat(
params: EnclaveHeartbeatParams,
params: VerifierHeartbeatParams,
options?: SendTransactionObjectOptions
): Promise<TransactionSignature> {
const quote = params.quote ?? (await this.loadData());
@ -317,7 +317,7 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
public async rotateInstruction(
payer: PublicKey,
params: EnclaveRotateParams,
params: VerifierRotateParams,
options?: TransactionObjectOptions
): Promise<TransactionObject> {
this.program.verifyAttestation();
@ -331,13 +331,13 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
throw new errors.IncorrectAuthority(quoteData.authority, authority);
}
const rotateIxn = types.quoteRotate(
const rotateIxn = types.verifierQuoteRotate(
this.program,
{
params: { registryKey: [...registryKey].slice(0, 64) },
},
{
quote: this.publicKey,
verifier: this.publicKey,
authority: authority,
enclaveSigner: params.enclaveSigner.publicKey,
attestationQueue: quoteData.attestationQueue,
@ -356,7 +356,7 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
}
public async rotate(
params: EnclaveRotateParams,
params: VerifierRotateParams,
options?: SendTransactionObjectOptions
): Promise<TransactionSignature> {
return await this.rotateInstruction(
@ -368,26 +368,41 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
public async verifyInstruction(
payer: PublicKey,
params: EnclaveVerifyParams,
params: QuoteVerifyParams,
options?: TransactionObjectOptions
): Promise<TransactionObject> {
this.program.verifyAttestation();
const quoteData = await this.loadData();
const verifierState = await this.loadData();
const signers: Keypair[] = [];
if (params.enclaveSigner) {
if (
!params.enclaveSigner.publicKey.equals(
verifierState.enclave.enclaveSigner
)
) {
throw new Error(
`SignerMismatch, expected ${verifierState.enclave.enclaveSigner}, received ${params.enclaveSigner.publicKey}`
);
}
signers.push(params.enclaveSigner);
}
const attestationQueueAccount = new AttestationQueueAccount(
this.program,
quoteData.attestationQueue
verifierState.attestationQueue
);
const attestationQueue = await attestationQueueAccount.loadData();
const verifierIdx = attestationQueue.data
.slice(0, attestationQueue.dataLen)
.findIndex((pubkey) => pubkey.equals(params.verifier));
.findIndex((pubkey) => pubkey.equals(this.publicKey));
if (verifierIdx === -1) {
throw new Error(`Verifier not found on the attestation queue`);
}
const instruction = types.quoteVerify(
const instruction = types.verifierQuoteVerify(
this.program,
{
params: {
@ -397,23 +412,17 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
},
},
{
quote: this.publicKey,
quoteSigner: quoteData.enclaveSigner,
enclaveSigner: params.verifierSecuredSigner.publicKey,
verifier: params.verifier,
attestationQueue: quoteData.attestationQueue,
quote: params.quote.publicKey,
enclaveSigner: verifierState.enclave.enclaveSigner,
verifier: this.publicKey,
attestationQueue: verifierState.attestationQueue,
}
);
return new TransactionObject(
payer,
[instruction],
[params.verifierSecuredSigner],
options
);
return new TransactionObject(payer, [instruction], signers, options);
}
public async verify(
params: EnclaveVerifyParams,
params: QuoteVerifyParams,
options?: SendTransactionObjectOptions
): Promise<TransactionSignature> {
return await this.verifyInstruction(

View File

@ -1,30 +1,33 @@
import * as errors from "../errors.js";
import * as types from "../generated/oracle-program/index.js";
import { vrfCloseAction } from "../generated/oracle-program/index.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type {
SendTransactionObjectOptions,
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account, OnAccountChangeCallback } from "./account.js";
import type { OnAccountChangeCallback } from "./account.js";
import { Account } from "./account.js";
import { OracleAccount } from "./oracleAccount.js";
import { PermissionAccount } from "./permissionAccount.js";
import { QueueAccount } from "./queueAccount.js";
import * as anchor from "@coral-xyz/anchor";
import type * as anchor from "@coral-xyz/anchor";
import * as spl from "@solana/spl-token";
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
import {
import type {
Commitment,
Keypair,
ParsedTransactionWithMeta,
TransactionSignature,
} from "@solana/web3.js";
import {
Keypair,
PublicKey,
SystemProgram,
SYSVAR_INSTRUCTIONS_PUBKEY,
SYSVAR_RECENT_BLOCKHASHES_PUBKEY,
TransactionSignature,
} from "@solana/web3.js";
import { BN, promiseWithTimeout } from "@switchboard-xyz/common";

View File

@ -2,32 +2,33 @@ import * as errors from "../errors.js";
import { vrfLiteInit } from "../generated/oracle-program/index.js";
import * as types from "../generated/oracle-program/index.js";
import { vrfLiteCloseAction } from "../generated/oracle-program/instructions/vrfLiteCloseAction.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import {
TransactionObject,
TransactionObjectOptions,
} from "../TransactionObject.js";
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import type { TransactionObjectOptions } from "../TransactionObject.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account, OnAccountChangeCallback } from "./account.js";
import type { OnAccountChangeCallback } from "./account.js";
import { Account } from "./account.js";
import { OracleAccount } from "./oracleAccount.js";
import { PermissionAccount } from "./permissionAccount.js";
import { QueueAccount } from "./queueAccount.js";
import { Callback, VrfResult } from "./vrfAccount.js";
import type { Callback, VrfResult } from "./vrfAccount.js";
import {
ASSOCIATED_TOKEN_PROGRAM_ID,
createTransferInstruction,
TOKEN_PROGRAM_ID,
} from "@solana/spl-token";
import {
import type {
Commitment,
Keypair,
ParsedTransactionWithMeta,
PublicKey,
TransactionSignature,
} from "@solana/web3.js";
import {
Keypair,
SystemProgram,
SYSVAR_INSTRUCTIONS_PUBKEY,
SYSVAR_RENT_PUBKEY,
TransactionSignature,
} from "@solana/web3.js";
import { BN, promiseWithTimeout } from "@switchboard-xyz/common";

View File

@ -1,14 +1,16 @@
import { VRF_POOL_REQUEST_AMOUNT } from "../const.js";
import { AccountNotFoundError, InsufficientFundsError } from "../errors.js";
import * as types from "../generated/oracle-program/index.js";
import { VrfPoolRequestEvent } from "../SwitchboardEvents.js";
import { SwitchboardProgram } from "../SwitchboardProgram.js";
import type { VrfPoolRequestEvent } from "../SwitchboardEvents.js";
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
import { TransactionObject } from "../TransactionObject.js";
import { Account, OnAccountChangeCallback } from "./account.js";
import type { OnAccountChangeCallback } from "./account.js";
import { Account } from "./account.js";
import { PermissionAccount } from "./permissionAccount.js";
import { CreateVrfLiteParams, QueueAccount } from "./queueAccount.js";
import { Callback } from "./vrfAccount.js";
import type { CreateVrfLiteParams } from "./queueAccount.js";
import { QueueAccount } from "./queueAccount.js";
import type { Callback } from "./vrfAccount.js";
import { VrfLiteAccount } from "./vrfLiteAccount.js";
import {
@ -16,15 +18,17 @@ import {
createTransferInstruction,
TOKEN_PROGRAM_ID,
} from "@solana/spl-token";
import {
import type {
AccountMeta,
Commitment,
TransactionSignature,
} from "@solana/web3.js";
import {
Keypair,
PublicKey,
SystemProgram,
SYSVAR_RECENT_BLOCKHASHES_PUBKEY,
SYSVAR_RENT_PUBKEY,
TransactionSignature,
} from "@solana/web3.js";
import { promiseWithTimeout } from "@switchboard-xyz/common";
import _ from "lodash";

View File

@ -1,5 +1,5 @@
import * as anchor from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";
import type * as anchor from "@coral-xyz/anchor";
import type { PublicKey } from "@solana/web3.js";
export class SwitchboardProgramIsBrowserError extends Error {
constructor() {

View File

@ -1,4 +1,4 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
@ -60,14 +60,15 @@ export class AttestationPermissionAccountData {
static async fetch(
program: SwitchboardProgram,
address: PublicKey
address: PublicKey,
programId: PublicKey = program.attestationProgramId
): Promise<AttestationPermissionAccountData | null> {
const info = await program.connection.getAccountInfo(address);
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}
@ -76,7 +77,8 @@ export class AttestationPermissionAccountData {
static async fetchMultiple(
program: SwitchboardProgram,
addresses: PublicKey[]
addresses: PublicKey[],
programId: PublicKey = program.attestationProgramId
): Promise<Array<AttestationPermissionAccountData | null>> {
const infos = await program.connection.getMultipleAccountsInfo(addresses);
@ -84,7 +86,7 @@ export class AttestationPermissionAccountData {
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}

View File

@ -1,8 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { Connection, PublicKey } from "@solana/web3.js";
import type { PublicKey } from "@solana/web3.js";
import { Connection } from "@solana/web3.js";
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface AttestationProgramStateFields {
@ -35,14 +36,15 @@ export class AttestationProgramState {
static async fetch(
program: SwitchboardProgram,
address: PublicKey
address: PublicKey,
programId: PublicKey = program.attestationProgramId
): Promise<AttestationProgramState | null> {
const info = await program.connection.getAccountInfo(address);
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}
@ -51,7 +53,8 @@ export class AttestationProgramState {
static async fetchMultiple(
program: SwitchboardProgram,
addresses: PublicKey[]
addresses: PublicKey[],
programId: PublicKey = program.attestationProgramId
): Promise<Array<AttestationProgramState | null>> {
const infos = await program.connection.getMultipleAccountsInfo(addresses);
@ -59,7 +62,7 @@ export class AttestationProgramState {
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}

View File

@ -1,4 +1,4 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
@ -177,14 +177,15 @@ export class AttestationQueueAccountData {
static async fetch(
program: SwitchboardProgram,
address: PublicKey
address: PublicKey,
programId: PublicKey = program.attestationProgramId
): Promise<AttestationQueueAccountData | null> {
const info = await program.connection.getAccountInfo(address);
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}
@ -193,7 +194,8 @@ export class AttestationQueueAccountData {
static async fetchMultiple(
program: SwitchboardProgram,
addresses: PublicKey[]
addresses: PublicKey[],
programId: PublicKey = program.attestationProgramId
): Promise<Array<AttestationQueueAccountData | null>> {
const infos = await program.connection.getMultipleAccountsInfo(addresses);
@ -201,7 +203,7 @@ export class AttestationQueueAccountData {
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}

View File

@ -1,4 +1,4 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
@ -13,20 +13,34 @@ export interface FunctionAccountDataFields {
/** The function permissions granted by the attestation_queue.authority */
permissions: number;
status: types.FunctionStatusKind;
/** PDA bump. */
bump: number;
/** The payer who originally created the function. Cannot change, used to derive PDA. */
creatorSeed: Array<number>;
/** The name of the function for easier identification. */
name: Array<number>;
/** The metadata of the function for easier identification. */
metadata: Array<number>;
/** The Solana slot when the function was created. (PDA) */
createdAtSlot: BN;
/** The unix timestamp when the function was created. */
createdAt: BN;
/** The unix timestamp when the function config (container, registry, version, or schedule) was changed. */
updatedAt: BN;
/** The enclave quote */
enclave: types.QuoteFields;
/** An array of permitted mr_enclave measurements for the function. */
mrEnclaves: Array<Array<number>>;
/** The off-chain registry to fetch the function container from. */
containerRegistry: Array<number>;
/** The identifier of the container in the given container_registry. */
container: Array<number>;
/** The version tag of the container to pull. */
version: Array<number>;
/** The expected schema for the container params. */
paramsSchema: Array<number>;
/** The default params passed to the container during scheduled execution. */
defaultContainerParams: Array<number>;
/** The authority of the function which is authorized to make account changes. */
authority: PublicKey;
/** The address of the AttestationQueueAccountData that will be processing function requests and verifying the function measurements. */
@ -43,6 +57,8 @@ export interface FunctionAccountDataFields {
nextAllowedTimestamp: BN;
/** The number of times to trigger the function upon the next invocation. */
triggerCount: BN;
/** Time this function has been sitting in an explicitly triggered state */
triggeredSince: BN;
/** UNUSED. The unix timestamp when the current permissions expire. */
permissionExpiration: BN;
/** Number of requests created for this function. Used to prevent closing when there are live requests. */
@ -61,12 +77,6 @@ export interface FunctionAccountDataFields {
requestsDefaultSlotsUntilExpiration: BN;
/** The lamports paid to the FunctionAccount escrow on each successful update request. */
requestsFee: BN;
/** An array of permitted mr_enclave measurements for the function. */
mrEnclaves: Array<Array<number>>;
/** PDA bump. */
bump: number;
/** The payer who originally created the function. Cannot change, used to derive PDA. */
creatorSeed: Array<number>;
/** The SwitchboardWallet that will handle pre-funding rewards paid out to function runners. */
escrowWallet: PublicKey;
/** The escrow_wallet TokenAccount that handles pre-funding rewards paid out to function runners. */
@ -78,8 +88,6 @@ export interface FunctionAccountDataFields {
rewardEscrowWallet: PublicKey;
/** The reward_escrow_wallet TokenAccount used to acrue rewards from requests made with custom parameters. */
rewardEscrowTokenWallet: PublicKey;
/** The unix timestamp when the function was created. */
createdAt: BN;
/** Reserved. */
ebuf: Array<number>;
}
@ -92,20 +100,34 @@ export interface FunctionAccountDataJSON {
/** The function permissions granted by the attestation_queue.authority */
permissions: number;
status: types.FunctionStatusJSON;
/** PDA bump. */
bump: number;
/** The payer who originally created the function. Cannot change, used to derive PDA. */
creatorSeed: Array<number>;
/** The name of the function for easier identification. */
name: Array<number>;
/** The metadata of the function for easier identification. */
metadata: Array<number>;
/** The Solana slot when the function was created. (PDA) */
createdAtSlot: string;
/** The unix timestamp when the function was created. */
createdAt: string;
/** The unix timestamp when the function config (container, registry, version, or schedule) was changed. */
updatedAt: string;
/** The enclave quote */
enclave: types.QuoteJSON;
/** An array of permitted mr_enclave measurements for the function. */
mrEnclaves: Array<Array<number>>;
/** The off-chain registry to fetch the function container from. */
containerRegistry: Array<number>;
/** The identifier of the container in the given container_registry. */
container: Array<number>;
/** The version tag of the container to pull. */
version: Array<number>;
/** The expected schema for the container params. */
paramsSchema: Array<number>;
/** The default params passed to the container during scheduled execution. */
defaultContainerParams: Array<number>;
/** The authority of the function which is authorized to make account changes. */
authority: string;
/** The address of the AttestationQueueAccountData that will be processing function requests and verifying the function measurements. */
@ -122,6 +144,8 @@ export interface FunctionAccountDataJSON {
nextAllowedTimestamp: string;
/** The number of times to trigger the function upon the next invocation. */
triggerCount: string;
/** Time this function has been sitting in an explicitly triggered state */
triggeredSince: string;
/** UNUSED. The unix timestamp when the current permissions expire. */
permissionExpiration: string;
/** Number of requests created for this function. Used to prevent closing when there are live requests. */
@ -140,12 +164,6 @@ export interface FunctionAccountDataJSON {
requestsDefaultSlotsUntilExpiration: string;
/** The lamports paid to the FunctionAccount escrow on each successful update request. */
requestsFee: string;
/** An array of permitted mr_enclave measurements for the function. */
mrEnclaves: Array<Array<number>>;
/** PDA bump. */
bump: number;
/** The payer who originally created the function. Cannot change, used to derive PDA. */
creatorSeed: Array<number>;
/** The SwitchboardWallet that will handle pre-funding rewards paid out to function runners. */
escrowWallet: string;
/** The escrow_wallet TokenAccount that handles pre-funding rewards paid out to function runners. */
@ -157,8 +175,6 @@ export interface FunctionAccountDataJSON {
rewardEscrowWallet: string;
/** The reward_escrow_wallet TokenAccount used to acrue rewards from requests made with custom parameters. */
rewardEscrowTokenWallet: string;
/** The unix timestamp when the function was created. */
createdAt: string;
/** Reserved. */
ebuf: Array<number>;
}
@ -171,20 +187,34 @@ export class FunctionAccountData {
/** The function permissions granted by the attestation_queue.authority */
readonly permissions: number;
readonly status: types.FunctionStatusKind;
/** PDA bump. */
readonly bump: number;
/** The payer who originally created the function. Cannot change, used to derive PDA. */
readonly creatorSeed: Array<number>;
/** The name of the function for easier identification. */
readonly name: Array<number>;
/** The metadata of the function for easier identification. */
readonly metadata: Array<number>;
/** The Solana slot when the function was created. (PDA) */
readonly createdAtSlot: BN;
/** The unix timestamp when the function was created. */
readonly createdAt: BN;
/** The unix timestamp when the function config (container, registry, version, or schedule) was changed. */
readonly updatedAt: BN;
/** The enclave quote */
readonly enclave: types.Quote;
/** An array of permitted mr_enclave measurements for the function. */
readonly mrEnclaves: Array<Array<number>>;
/** The off-chain registry to fetch the function container from. */
readonly containerRegistry: Array<number>;
/** The identifier of the container in the given container_registry. */
readonly container: Array<number>;
/** The version tag of the container to pull. */
readonly version: Array<number>;
/** The expected schema for the container params. */
readonly paramsSchema: Array<number>;
/** The default params passed to the container during scheduled execution. */
readonly defaultContainerParams: Array<number>;
/** The authority of the function which is authorized to make account changes. */
readonly authority: PublicKey;
/** The address of the AttestationQueueAccountData that will be processing function requests and verifying the function measurements. */
@ -201,6 +231,8 @@ export class FunctionAccountData {
readonly nextAllowedTimestamp: BN;
/** The number of times to trigger the function upon the next invocation. */
readonly triggerCount: BN;
/** Time this function has been sitting in an explicitly triggered state */
readonly triggeredSince: BN;
/** UNUSED. The unix timestamp when the current permissions expire. */
readonly permissionExpiration: BN;
/** Number of requests created for this function. Used to prevent closing when there are live requests. */
@ -219,12 +251,6 @@ export class FunctionAccountData {
readonly requestsDefaultSlotsUntilExpiration: BN;
/** The lamports paid to the FunctionAccount escrow on each successful update request. */
readonly requestsFee: BN;
/** An array of permitted mr_enclave measurements for the function. */
readonly mrEnclaves: Array<Array<number>>;
/** PDA bump. */
readonly bump: number;
/** The payer who originally created the function. Cannot change, used to derive PDA. */
readonly creatorSeed: Array<number>;
/** The SwitchboardWallet that will handle pre-funding rewards paid out to function runners. */
readonly escrowWallet: PublicKey;
/** The escrow_wallet TokenAccount that handles pre-funding rewards paid out to function runners. */
@ -236,8 +262,6 @@ export class FunctionAccountData {
readonly rewardEscrowWallet: PublicKey;
/** The reward_escrow_wallet TokenAccount used to acrue rewards from requests made with custom parameters. */
readonly rewardEscrowTokenWallet: PublicKey;
/** The unix timestamp when the function was created. */
readonly createdAt: BN;
/** Reserved. */
readonly ebuf: Array<number>;
@ -250,13 +274,20 @@ export class FunctionAccountData {
borsh.u8("isTriggered"),
borsh.u32("permissions"),
types.FunctionStatus.layout("status"),
borsh.u8("bump"),
borsh.array(borsh.u8(), 32, "creatorSeed"),
borsh.array(borsh.u8(), 64, "name"),
borsh.array(borsh.u8(), 256, "metadata"),
borsh.u64("createdAtSlot"),
borsh.i64("createdAt"),
borsh.i64("updatedAt"),
types.Quote.layout("enclave"),
borsh.array(borsh.array(borsh.u8(), 32), 32, "mrEnclaves"),
borsh.array(borsh.u8(), 64, "containerRegistry"),
borsh.array(borsh.u8(), 64, "container"),
borsh.array(borsh.u8(), 32, "version"),
borsh.array(borsh.u8(), 256, "paramsSchema"),
borsh.array(borsh.u8(), 256, "defaultContainerParams"),
borsh.publicKey("authority"),
borsh.publicKey("attestationQueue"),
borsh.u32("queueIdx"),
@ -265,21 +296,18 @@ export class FunctionAccountData {
borsh.i64("lastExecutionTimestamp"),
borsh.i64("nextAllowedTimestamp"),
borsh.u64("triggerCount"),
borsh.i64("triggeredSince"),
borsh.i64("permissionExpiration"),
borsh.u64("numRequests"),
borsh.bool("requestsDisabled"),
borsh.bool("requestsRequireAuthorization"),
borsh.u64("requestsDefaultSlotsUntilExpiration"),
borsh.u64("requestsFee"),
borsh.array(borsh.array(borsh.u8(), 32), 32, "mrEnclaves"),
borsh.u8("bump"),
borsh.array(borsh.u8(), 32, "creatorSeed"),
borsh.publicKey("escrowWallet"),
borsh.publicKey("escrowTokenWallet"),
borsh.publicKey("rewardEscrowWallet"),
borsh.publicKey("rewardEscrowTokenWallet"),
borsh.i64("createdAt"),
borsh.array(borsh.u8(), 871, "ebuf"),
borsh.array(borsh.u8(), 1024, "ebuf"),
]);
constructor(fields: FunctionAccountDataFields) {
@ -287,13 +315,20 @@ export class FunctionAccountData {
this.isTriggered = fields.isTriggered;
this.permissions = fields.permissions;
this.status = fields.status;
this.bump = fields.bump;
this.creatorSeed = fields.creatorSeed;
this.name = fields.name;
this.metadata = fields.metadata;
this.createdAtSlot = fields.createdAtSlot;
this.createdAt = fields.createdAt;
this.updatedAt = fields.updatedAt;
this.enclave = new types.Quote({ ...fields.enclave });
this.mrEnclaves = fields.mrEnclaves;
this.containerRegistry = fields.containerRegistry;
this.container = fields.container;
this.version = fields.version;
this.paramsSchema = fields.paramsSchema;
this.defaultContainerParams = fields.defaultContainerParams;
this.authority = fields.authority;
this.attestationQueue = fields.attestationQueue;
this.queueIdx = fields.queueIdx;
@ -302,6 +337,7 @@ export class FunctionAccountData {
this.lastExecutionTimestamp = fields.lastExecutionTimestamp;
this.nextAllowedTimestamp = fields.nextAllowedTimestamp;
this.triggerCount = fields.triggerCount;
this.triggeredSince = fields.triggeredSince;
this.permissionExpiration = fields.permissionExpiration;
this.numRequests = fields.numRequests;
this.requestsDisabled = fields.requestsDisabled;
@ -309,27 +345,24 @@ export class FunctionAccountData {
this.requestsDefaultSlotsUntilExpiration =
fields.requestsDefaultSlotsUntilExpiration;
this.requestsFee = fields.requestsFee;
this.mrEnclaves = fields.mrEnclaves;
this.bump = fields.bump;
this.creatorSeed = fields.creatorSeed;
this.escrowWallet = fields.escrowWallet;
this.escrowTokenWallet = fields.escrowTokenWallet;
this.rewardEscrowWallet = fields.rewardEscrowWallet;
this.rewardEscrowTokenWallet = fields.rewardEscrowTokenWallet;
this.createdAt = fields.createdAt;
this.ebuf = fields.ebuf;
}
static async fetch(
program: SwitchboardProgram,
address: PublicKey
address: PublicKey,
programId: PublicKey = program.attestationProgramId
): Promise<FunctionAccountData | null> {
const info = await program.connection.getAccountInfo(address);
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}
@ -338,7 +371,8 @@ export class FunctionAccountData {
static async fetchMultiple(
program: SwitchboardProgram,
addresses: PublicKey[]
addresses: PublicKey[],
programId: PublicKey = program.attestationProgramId
): Promise<Array<FunctionAccountData | null>> {
const infos = await program.connection.getMultipleAccountsInfo(addresses);
@ -346,7 +380,7 @@ export class FunctionAccountData {
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}
@ -366,13 +400,20 @@ export class FunctionAccountData {
isTriggered: dec.isTriggered,
permissions: dec.permissions,
status: types.FunctionStatus.fromDecoded(dec.status),
bump: dec.bump,
creatorSeed: dec.creatorSeed,
name: dec.name,
metadata: dec.metadata,
createdAtSlot: dec.createdAtSlot,
createdAt: dec.createdAt,
updatedAt: dec.updatedAt,
enclave: types.Quote.fromDecoded(dec.enclave),
mrEnclaves: dec.mrEnclaves,
containerRegistry: dec.containerRegistry,
container: dec.container,
version: dec.version,
paramsSchema: dec.paramsSchema,
defaultContainerParams: dec.defaultContainerParams,
authority: dec.authority,
attestationQueue: dec.attestationQueue,
queueIdx: dec.queueIdx,
@ -381,6 +422,7 @@ export class FunctionAccountData {
lastExecutionTimestamp: dec.lastExecutionTimestamp,
nextAllowedTimestamp: dec.nextAllowedTimestamp,
triggerCount: dec.triggerCount,
triggeredSince: dec.triggeredSince,
permissionExpiration: dec.permissionExpiration,
numRequests: dec.numRequests,
requestsDisabled: dec.requestsDisabled,
@ -388,14 +430,10 @@ export class FunctionAccountData {
requestsDefaultSlotsUntilExpiration:
dec.requestsDefaultSlotsUntilExpiration,
requestsFee: dec.requestsFee,
mrEnclaves: dec.mrEnclaves,
bump: dec.bump,
creatorSeed: dec.creatorSeed,
escrowWallet: dec.escrowWallet,
escrowTokenWallet: dec.escrowTokenWallet,
rewardEscrowWallet: dec.rewardEscrowWallet,
rewardEscrowTokenWallet: dec.rewardEscrowTokenWallet,
createdAt: dec.createdAt,
ebuf: dec.ebuf,
});
}
@ -406,13 +444,20 @@ export class FunctionAccountData {
isTriggered: this.isTriggered,
permissions: this.permissions,
status: this.status.toJSON(),
bump: this.bump,
creatorSeed: this.creatorSeed,
name: this.name,
metadata: this.metadata,
createdAtSlot: this.createdAtSlot.toString(),
createdAt: this.createdAt.toString(),
updatedAt: this.updatedAt.toString(),
enclave: this.enclave.toJSON(),
mrEnclaves: this.mrEnclaves,
containerRegistry: this.containerRegistry,
container: this.container,
version: this.version,
paramsSchema: this.paramsSchema,
defaultContainerParams: this.defaultContainerParams,
authority: this.authority.toString(),
attestationQueue: this.attestationQueue.toString(),
queueIdx: this.queueIdx,
@ -421,6 +466,7 @@ export class FunctionAccountData {
lastExecutionTimestamp: this.lastExecutionTimestamp.toString(),
nextAllowedTimestamp: this.nextAllowedTimestamp.toString(),
triggerCount: this.triggerCount.toString(),
triggeredSince: this.triggeredSince.toString(),
permissionExpiration: this.permissionExpiration.toString(),
numRequests: this.numRequests.toString(),
requestsDisabled: this.requestsDisabled,
@ -428,14 +474,10 @@ export class FunctionAccountData {
requestsDefaultSlotsUntilExpiration:
this.requestsDefaultSlotsUntilExpiration.toString(),
requestsFee: this.requestsFee.toString(),
mrEnclaves: this.mrEnclaves,
bump: this.bump,
creatorSeed: this.creatorSeed,
escrowWallet: this.escrowWallet.toString(),
escrowTokenWallet: this.escrowTokenWallet.toString(),
rewardEscrowWallet: this.rewardEscrowWallet.toString(),
rewardEscrowTokenWallet: this.rewardEscrowTokenWallet.toString(),
createdAt: this.createdAt.toString(),
ebuf: this.ebuf,
};
}
@ -446,13 +488,20 @@ export class FunctionAccountData {
isTriggered: obj.isTriggered,
permissions: obj.permissions,
status: types.FunctionStatus.fromJSON(obj.status),
bump: obj.bump,
creatorSeed: obj.creatorSeed,
name: obj.name,
metadata: obj.metadata,
createdAtSlot: new BN(obj.createdAtSlot),
createdAt: new BN(obj.createdAt),
updatedAt: new BN(obj.updatedAt),
enclave: types.Quote.fromJSON(obj.enclave),
mrEnclaves: obj.mrEnclaves,
containerRegistry: obj.containerRegistry,
container: obj.container,
version: obj.version,
paramsSchema: obj.paramsSchema,
defaultContainerParams: obj.defaultContainerParams,
authority: new PublicKey(obj.authority),
attestationQueue: new PublicKey(obj.attestationQueue),
queueIdx: obj.queueIdx,
@ -461,6 +510,7 @@ export class FunctionAccountData {
lastExecutionTimestamp: new BN(obj.lastExecutionTimestamp),
nextAllowedTimestamp: new BN(obj.nextAllowedTimestamp),
triggerCount: new BN(obj.triggerCount),
triggeredSince: new BN(obj.triggeredSince),
permissionExpiration: new BN(obj.permissionExpiration),
numRequests: new BN(obj.numRequests),
requestsDisabled: obj.requestsDisabled,
@ -469,14 +519,10 @@ export class FunctionAccountData {
obj.requestsDefaultSlotsUntilExpiration
),
requestsFee: new BN(obj.requestsFee),
mrEnclaves: obj.mrEnclaves,
bump: obj.bump,
creatorSeed: obj.creatorSeed,
escrowWallet: new PublicKey(obj.escrowWallet),
escrowTokenWallet: new PublicKey(obj.escrowTokenWallet),
rewardEscrowWallet: new PublicKey(obj.rewardEscrowWallet),
rewardEscrowTokenWallet: new PublicKey(obj.rewardEscrowTokenWallet),
createdAt: new BN(obj.createdAt),
ebuf: obj.ebuf,
});
}

View File

@ -1,4 +1,4 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
@ -158,14 +158,15 @@ export class FunctionRequestAccountData {
static async fetch(
program: SwitchboardProgram,
address: PublicKey
address: PublicKey,
programId: PublicKey = program.attestationProgramId
): Promise<FunctionRequestAccountData | null> {
const info = await program.connection.getAccountInfo(address);
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}
@ -174,7 +175,8 @@ export class FunctionRequestAccountData {
static async fetchMultiple(
program: SwitchboardProgram,
addresses: PublicKey[]
addresses: PublicKey[],
programId: PublicKey = program.attestationProgramId
): Promise<Array<FunctionRequestAccountData | null>> {
const infos = await program.connection.getMultipleAccountsInfo(addresses);
@ -182,7 +184,7 @@ export class FunctionRequestAccountData {
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}

View File

@ -1,4 +1,4 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
@ -86,14 +86,15 @@ export class SwitchboardWallet {
static async fetch(
program: SwitchboardProgram,
address: PublicKey
address: PublicKey,
programId: PublicKey = program.attestationProgramId
): Promise<SwitchboardWallet | null> {
const info = await program.connection.getAccountInfo(address);
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}
@ -102,7 +103,8 @@ export class SwitchboardWallet {
static async fetchMultiple(
program: SwitchboardProgram,
addresses: PublicKey[]
addresses: PublicKey[],
programId: PublicKey = program.attestationProgramId
): Promise<Array<SwitchboardWallet | null>> {
const infos = await program.connection.getMultipleAccountsInfo(addresses);
@ -110,7 +112,7 @@ export class SwitchboardWallet {
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}

View File

@ -1,37 +1,23 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { Connection, PublicKey } from "@solana/web3.js";
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface EnclaveAccountDataFields {
/** The address of the signer generated within an enclave. */
enclaveSigner: PublicKey;
export interface VerifierAccountDataFields {
/** Represents the state of the quote verifiers enclave. */
enclave: types.QuoteFields;
/** The authority of the EnclaveAccount which is permitted to make account changes. */
authority: PublicKey;
/** Queue used for attestation to verify a MRENCLAVE measurement. */
attestationQueue: PublicKey;
/** The quotes MRENCLAVE measurement dictating the contents of the secure enclave. */
mrEnclave: Array<number>;
/** The VerificationStatus of the quote. */
verificationStatus: number;
/** The unix timestamp when the quote was last verified. */
verificationTimestamp: BN;
/** The unix timestamp when the quotes verification status expires. */
validUntil: BN;
/** The unix timestamp when the quote was created. */
createdAt: BN;
/** The off-chain registry where the verifiers quote can be located. */
quoteRegistry: Array<number>;
/** Key to lookup the buffer data on IPFS or an alternative decentralized storage solution. */
registryKey: Array<number>;
/** Whether the quote is located on the AttestationQueues buffer. */
isOnQueue: boolean;
/** The last time the quote heartbeated on-chain. */
lastHeartbeat: BN;
/** The PDA bump. Only set for FunctionAccount quotes. */
bump: number;
/**
* The SwitchboardWallet account containing the reward escrow for verifying quotes on-chain.
* We should set this whenever the operator changes so we dont need to pass another account and can verify with has_one.
@ -46,33 +32,19 @@ export interface EnclaveAccountDataFields {
ebuf: Array<number>;
}
export interface EnclaveAccountDataJSON {
/** The address of the signer generated within an enclave. */
enclaveSigner: string;
export interface VerifierAccountDataJSON {
/** Represents the state of the quote verifiers enclave. */
enclave: types.QuoteJSON;
/** The authority of the EnclaveAccount which is permitted to make account changes. */
authority: string;
/** Queue used for attestation to verify a MRENCLAVE measurement. */
attestationQueue: string;
/** The quotes MRENCLAVE measurement dictating the contents of the secure enclave. */
mrEnclave: Array<number>;
/** The VerificationStatus of the quote. */
verificationStatus: number;
/** The unix timestamp when the quote was last verified. */
verificationTimestamp: string;
/** The unix timestamp when the quotes verification status expires. */
validUntil: string;
/** The unix timestamp when the quote was created. */
createdAt: string;
/** The off-chain registry where the verifiers quote can be located. */
quoteRegistry: Array<number>;
/** Key to lookup the buffer data on IPFS or an alternative decentralized storage solution. */
registryKey: Array<number>;
/** Whether the quote is located on the AttestationQueues buffer. */
isOnQueue: boolean;
/** The last time the quote heartbeated on-chain. */
lastHeartbeat: string;
/** The PDA bump. Only set for FunctionAccount quotes. */
bump: number;
/**
* The SwitchboardWallet account containing the reward escrow for verifying quotes on-chain.
* We should set this whenever the operator changes so we dont need to pass another account and can verify with has_one.
@ -87,33 +59,19 @@ export interface EnclaveAccountDataJSON {
ebuf: Array<number>;
}
export class EnclaveAccountData {
/** The address of the signer generated within an enclave. */
readonly enclaveSigner: PublicKey;
export class VerifierAccountData {
/** Represents the state of the quote verifiers enclave. */
readonly enclave: types.Quote;
/** The authority of the EnclaveAccount which is permitted to make account changes. */
readonly authority: PublicKey;
/** Queue used for attestation to verify a MRENCLAVE measurement. */
readonly attestationQueue: PublicKey;
/** The quotes MRENCLAVE measurement dictating the contents of the secure enclave. */
readonly mrEnclave: Array<number>;
/** The VerificationStatus of the quote. */
readonly verificationStatus: number;
/** The unix timestamp when the quote was last verified. */
readonly verificationTimestamp: BN;
/** The unix timestamp when the quotes verification status expires. */
readonly validUntil: BN;
/** The unix timestamp when the quote was created. */
readonly createdAt: BN;
/** The off-chain registry where the verifiers quote can be located. */
readonly quoteRegistry: Array<number>;
/** Key to lookup the buffer data on IPFS or an alternative decentralized storage solution. */
readonly registryKey: Array<number>;
/** Whether the quote is located on the AttestationQueues buffer. */
readonly isOnQueue: boolean;
/** The last time the quote heartbeated on-chain. */
readonly lastHeartbeat: BN;
/** The PDA bump. Only set for FunctionAccount quotes. */
readonly bump: number;
/**
* The SwitchboardWallet account containing the reward escrow for verifying quotes on-chain.
* We should set this whenever the operator changes so we dont need to pass another account and can verify with has_one.
@ -128,42 +86,28 @@ export class EnclaveAccountData {
readonly ebuf: Array<number>;
static readonly discriminator = Buffer.from([
90, 162, 39, 88, 77, 157, 156, 165,
106, 146, 60, 232, 231, 52, 189, 253,
]);
static readonly layout = borsh.struct([
borsh.publicKey("enclaveSigner"),
types.Quote.layout("enclave"),
borsh.publicKey("authority"),
borsh.publicKey("attestationQueue"),
borsh.array(borsh.u8(), 32, "mrEnclave"),
borsh.u8("verificationStatus"),
borsh.i64("verificationTimestamp"),
borsh.i64("validUntil"),
borsh.i64("createdAt"),
borsh.array(borsh.u8(), 32, "quoteRegistry"),
borsh.array(borsh.u8(), 64, "registryKey"),
borsh.bool("isOnQueue"),
borsh.i64("lastHeartbeat"),
borsh.u8("bump"),
borsh.publicKey("rewardEscrow"),
borsh.publicKey("stakeWallet"),
borsh.array(borsh.u8(), 928, "ebuf"),
borsh.array(borsh.u8(), 1024, "ebuf"),
]);
constructor(fields: EnclaveAccountDataFields) {
this.enclaveSigner = fields.enclaveSigner;
constructor(fields: VerifierAccountDataFields) {
this.enclave = new types.Quote({ ...fields.enclave });
this.authority = fields.authority;
this.attestationQueue = fields.attestationQueue;
this.mrEnclave = fields.mrEnclave;
this.verificationStatus = fields.verificationStatus;
this.verificationTimestamp = fields.verificationTimestamp;
this.validUntil = fields.validUntil;
this.createdAt = fields.createdAt;
this.quoteRegistry = fields.quoteRegistry;
this.registryKey = fields.registryKey;
this.isOnQueue = fields.isOnQueue;
this.lastHeartbeat = fields.lastHeartbeat;
this.bump = fields.bump;
this.rewardEscrow = fields.rewardEscrow;
this.stakeWallet = fields.stakeWallet;
this.ebuf = fields.ebuf;
@ -171,14 +115,15 @@ export class EnclaveAccountData {
static async fetch(
program: SwitchboardProgram,
address: PublicKey
): Promise<EnclaveAccountData | null> {
address: PublicKey,
programId: PublicKey = program.attestationProgramId
): Promise<VerifierAccountData | null> {
const info = await program.connection.getAccountInfo(address);
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}
@ -187,15 +132,16 @@ export class EnclaveAccountData {
static async fetchMultiple(
program: SwitchboardProgram,
addresses: PublicKey[]
): Promise<Array<EnclaveAccountData | null>> {
addresses: PublicKey[],
programId: PublicKey = program.attestationProgramId
): Promise<Array<VerifierAccountData | null>> {
const infos = await program.connection.getMultipleAccountsInfo(addresses);
return infos.map((info) => {
if (info === null) {
return null;
}
if (!info.owner.equals(program.attestationProgramId)) {
if (!info.owner.equals(programId)) {
throw new Error("account doesn't belong to this program");
}
@ -203,69 +149,48 @@ export class EnclaveAccountData {
});
}
static decode(data: Buffer): EnclaveAccountData {
if (!data.slice(0, 8).equals(EnclaveAccountData.discriminator)) {
static decode(data: Buffer): VerifierAccountData {
if (!data.slice(0, 8).equals(VerifierAccountData.discriminator)) {
throw new Error("invalid account discriminator");
}
const dec = EnclaveAccountData.layout.decode(data.slice(8));
const dec = VerifierAccountData.layout.decode(data.slice(8));
return new EnclaveAccountData({
enclaveSigner: dec.enclaveSigner,
return new VerifierAccountData({
enclave: types.Quote.fromDecoded(dec.enclave),
authority: dec.authority,
attestationQueue: dec.attestationQueue,
mrEnclave: dec.mrEnclave,
verificationStatus: dec.verificationStatus,
verificationTimestamp: dec.verificationTimestamp,
validUntil: dec.validUntil,
createdAt: dec.createdAt,
quoteRegistry: dec.quoteRegistry,
registryKey: dec.registryKey,
isOnQueue: dec.isOnQueue,
lastHeartbeat: dec.lastHeartbeat,
bump: dec.bump,
rewardEscrow: dec.rewardEscrow,
stakeWallet: dec.stakeWallet,
ebuf: dec.ebuf,
});
}
toJSON(): EnclaveAccountDataJSON {
toJSON(): VerifierAccountDataJSON {
return {
enclaveSigner: this.enclaveSigner.toString(),
enclave: this.enclave.toJSON(),
authority: this.authority.toString(),
attestationQueue: this.attestationQueue.toString(),
mrEnclave: this.mrEnclave,
verificationStatus: this.verificationStatus,
verificationTimestamp: this.verificationTimestamp.toString(),
validUntil: this.validUntil.toString(),
createdAt: this.createdAt.toString(),
quoteRegistry: this.quoteRegistry,
registryKey: this.registryKey,
isOnQueue: this.isOnQueue,
lastHeartbeat: this.lastHeartbeat.toString(),
bump: this.bump,
rewardEscrow: this.rewardEscrow.toString(),
stakeWallet: this.stakeWallet.toString(),
ebuf: this.ebuf,
};
}
static fromJSON(obj: EnclaveAccountDataJSON): EnclaveAccountData {
return new EnclaveAccountData({
enclaveSigner: new PublicKey(obj.enclaveSigner),
static fromJSON(obj: VerifierAccountDataJSON): VerifierAccountData {
return new VerifierAccountData({
enclave: types.Quote.fromJSON(obj.enclave),
authority: new PublicKey(obj.authority),
attestationQueue: new PublicKey(obj.attestationQueue),
mrEnclave: obj.mrEnclave,
verificationStatus: obj.verificationStatus,
verificationTimestamp: new BN(obj.verificationTimestamp),
validUntil: new BN(obj.validUntil),
createdAt: new BN(obj.createdAt),
quoteRegistry: obj.quoteRegistry,
registryKey: obj.registryKey,
isOnQueue: obj.isOnQueue,
lastHeartbeat: new BN(obj.lastHeartbeat),
bump: obj.bump,
rewardEscrow: new PublicKey(obj.rewardEscrow),
stakeWallet: new PublicKey(obj.stakeWallet),
ebuf: obj.ebuf,

View File

@ -13,11 +13,6 @@ export type {
AttestationQueueAccountDataJSON,
} from "./AttestationQueueAccountData.js";
export { AttestationQueueAccountData } from "./AttestationQueueAccountData.js";
export type {
EnclaveAccountDataFields,
EnclaveAccountDataJSON,
} from "./EnclaveAccountData.js";
export { EnclaveAccountData } from "./EnclaveAccountData.js";
export type {
FunctionAccountDataFields,
FunctionAccountDataJSON,
@ -33,3 +28,8 @@ export type {
SwitchboardWalletJSON,
} from "./SwitchboardWallet.js";
export { SwitchboardWallet } from "./SwitchboardWallet.js";
export type {
VerifierAccountDataFields,
VerifierAccountDataJSON,
} from "./VerifierAccountData.js";
export { VerifierAccountData } from "./VerifierAccountData.js";

View File

@ -26,6 +26,7 @@ export type AnchorError =
| ConstraintMintFreezeAuthority
| ConstraintMintDecimals
| ConstraintSpace
| ConstraintAccountIsNone
| RequireViolated
| RequireEqViolated
| RequireKeysEqViolated
@ -51,7 +52,6 @@ export type AnchorError =
| AccountSysvarMismatch
| AccountReallocExceedsLimit
| AccountDuplicateReallocs
| StateInvalidAddress
| DeclaredProgramIdMismatch
| Deprecated;
@ -139,10 +139,10 @@ export class ConstraintHasOne extends Error {
static readonly code = 2001;
readonly code = 2001;
readonly name = "ConstraintHasOne";
readonly msg = "A has_one constraint was violated";
readonly msg = "A has one constraint was violated";
constructor(readonly logs?: string[]) {
super("2001: A has_one constraint was violated");
super("2001: A has one constraint was violated");
}
}
@ -216,10 +216,10 @@ export class ConstraintState extends Error {
static readonly code = 2008;
readonly code = 2008;
readonly name = "ConstraintState";
readonly msg = "A state constraint was violated";
readonly msg = "Deprecated Error, feel free to replace with something else";
constructor(readonly logs?: string[]) {
super("2008: A state constraint was violated");
super("2008: Deprecated Error, feel free to replace with something else");
}
}
@ -344,6 +344,17 @@ export class ConstraintSpace extends Error {
}
}
export class ConstraintAccountIsNone extends Error {
static readonly code = 2020;
readonly code = 2020;
readonly name = "ConstraintAccountIsNone";
readonly msg = "A required account for the constraint is None";
constructor(readonly logs?: string[]) {
super("2020: A required account for the constraint is None");
}
}
export class RequireViolated extends Error {
static readonly code = 2500;
readonly code = 2500;
@ -625,17 +636,6 @@ export class AccountDuplicateReallocs extends Error {
}
}
export class StateInvalidAddress extends Error {
static readonly code = 4000;
readonly code = 4000;
readonly name = "StateInvalidAddress";
readonly msg = "The given state account does not have the correct address";
constructor(readonly logs?: string[]) {
super("4000: The given state account does not have the correct address");
}
}
export class DeclaredProgramIdMismatch extends Error {
static readonly code = 4100;
readonly code = 4100;
@ -715,6 +715,8 @@ export function fromCode(code: number, logs?: string[]): AnchorError | null {
return new ConstraintMintDecimals(logs);
case 2019:
return new ConstraintSpace(logs);
case 2020:
return new ConstraintAccountIsNone(logs);
case 2500:
return new RequireViolated(logs);
case 2501:
@ -765,8 +767,6 @@ export function fromCode(code: number, logs?: string[]): AnchorError | null {
return new AccountReallocExceedsLimit(logs);
case 3017:
return new AccountDuplicateReallocs(logs);
case 4000:
return new StateInvalidAddress(logs);
case 4100:
return new DeclaredProgramIdMismatch(logs);
case 5000:

View File

@ -56,9 +56,10 @@ export class InvalidQuote extends Error {
static readonly code = 6001;
readonly code = 6001;
readonly name = "InvalidQuote";
readonly msg = "The provided enclave quote is invalid";
constructor(readonly logs?: string[]) {
super("6001: ");
super("6001: The provided enclave quote is invalid");
}
}

View File

@ -1,30 +1,29 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionOverrideCloseAccounts {
export interface AccountCloseOverrideAccounts {
enclave: PublicKey;
function: PublicKey;
solDest: PublicKey;
systemProgram: PublicKey;
}
export function functionOverrideClose(
export function accountCloseOverride(
program: SwitchboardProgram,
accounts: FunctionOverrideCloseAccounts
accounts: AccountCloseOverrideAccounts
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.enclave, isSigner: false, isWritable: true },
{ pubkey: accounts.function, isSigner: false, isWritable: true },
{ pubkey: accounts.solDest, isSigner: false, isWritable: false },
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
];
const identifier = Buffer.from([42, 133, 154, 32, 207, 168, 89, 45]);
const identifier = Buffer.from([65, 72, 78, 213, 38, 245, 58, 189]);
const data = identifier;
const ix = new TransactionInstruction({
keys,

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface AttestationPermissionInitArgs {
@ -29,7 +26,8 @@ export const layout = borsh.struct([
export function attestationPermissionInit(
program: SwitchboardProgram,
args: AttestationPermissionInitArgs,
accounts: AttestationPermissionInitAccounts
accounts: AttestationPermissionInitAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.permission, isSigner: false, isWritable: true },
@ -48,10 +46,6 @@ export function attestationPermissionInit(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface AttestationPermissionSetArgs {
@ -17,7 +14,7 @@ export interface AttestationPermissionSetAccounts {
permission: PublicKey;
authority: PublicKey;
attestationQueue: PublicKey;
enclave: PublicKey;
grantee: PublicKey;
}
export const layout = borsh.struct([
@ -27,13 +24,14 @@ export const layout = borsh.struct([
export function attestationPermissionSet(
program: SwitchboardProgram,
args: AttestationPermissionSetArgs,
accounts: AttestationPermissionSetAccounts
accounts: AttestationPermissionSetAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.permission, isSigner: false, isWritable: true },
{ pubkey: accounts.authority, isSigner: true, isWritable: false },
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: false },
{ pubkey: accounts.enclave, isSigner: false, isWritable: false },
{ pubkey: accounts.grantee, isSigner: false, isWritable: false },
];
const identifier = Buffer.from([56, 253, 255, 201, 100, 153, 10, 76]);
const buffer = Buffer.alloc(1000);
@ -44,10 +42,6 @@ export function attestationPermissionSet(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface AttestationQueueAddMrEnclaveArgs {
@ -25,7 +22,8 @@ export const layout = borsh.struct([
export function attestationQueueAddMrEnclave(
program: SwitchboardProgram,
args: AttestationQueueAddMrEnclaveArgs,
accounts: AttestationQueueAddMrEnclaveAccounts
accounts: AttestationQueueAddMrEnclaveAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.queue, isSigner: false, isWritable: true },
@ -40,10 +38,6 @@ export function attestationQueueAddMrEnclave(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface AttestationQueueInitArgs {
@ -27,7 +24,8 @@ export const layout = borsh.struct([
export function attestationQueueInit(
program: SwitchboardProgram,
args: AttestationQueueInitArgs,
accounts: AttestationQueueInitAccounts
accounts: AttestationQueueInitAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.queue, isSigner: true, isWritable: true },
@ -44,10 +42,6 @@ export function attestationQueueInit(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface AttestationQueueRemoveMrEnclaveArgs {
@ -25,7 +22,8 @@ export const layout = borsh.struct([
export function attestationQueueRemoveMrEnclave(
program: SwitchboardProgram,
args: AttestationQueueRemoveMrEnclaveArgs,
accounts: AttestationQueueRemoveMrEnclaveAccounts
accounts: AttestationQueueRemoveMrEnclaveAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.queue, isSigner: false, isWritable: true },
@ -42,10 +40,6 @@ export function attestationQueueRemoveMrEnclave(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionCloseArgs {
@ -20,7 +17,6 @@ export interface FunctionCloseAccounts {
escrowWallet: PublicKey;
solDest: PublicKey;
escrowDest: PublicKey;
state: PublicKey;
tokenProgram: PublicKey;
systemProgram: PublicKey;
addressLookupProgram: PublicKey;
@ -33,7 +29,8 @@ export const layout = borsh.struct([
export function functionClose(
program: SwitchboardProgram,
args: FunctionCloseArgs,
accounts: FunctionCloseAccounts
accounts: FunctionCloseAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.function, isSigner: false, isWritable: true },
@ -42,7 +39,6 @@ export function functionClose(
{ pubkey: accounts.escrowWallet, isSigner: false, isWritable: true },
{ pubkey: accounts.solDest, isSigner: false, isWritable: false },
{ pubkey: accounts.escrowDest, isSigner: false, isWritable: true },
{ pubkey: accounts.state, isSigner: false, isWritable: false },
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
{
@ -60,10 +56,6 @@ export function functionClose(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionDeactivateLookupAccounts {

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionExtendLookupArgs {
@ -29,7 +26,8 @@ export const layout = borsh.struct([
export function functionExtendLookup(
program: SwitchboardProgram,
args: FunctionExtendLookupArgs,
accounts: FunctionExtendLookupAccounts
accounts: FunctionExtendLookupAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.function, isSigner: false, isWritable: true },
@ -52,10 +50,6 @@ export function functionExtendLookup(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionInitArgs {
@ -17,13 +14,11 @@ export interface FunctionInitAccounts {
function: PublicKey;
addressLookupTable: PublicKey;
authority: PublicKey;
quote: PublicKey;
attestationQueue: PublicKey;
payer: PublicKey;
wallet: PublicKey;
walletAuthority: PublicKey;
tokenWallet: PublicKey;
state: PublicKey;
mint: PublicKey;
tokenProgram: PublicKey;
associatedTokenProgram: PublicKey;
@ -36,19 +31,18 @@ export const layout = borsh.struct([types.FunctionInitParams.layout("params")]);
export function functionInit(
program: SwitchboardProgram,
args: FunctionInitArgs,
accounts: FunctionInitAccounts
accounts: FunctionInitAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.function, isSigner: false, isWritable: true },
{ pubkey: accounts.addressLookupTable, isSigner: false, isWritable: true },
{ pubkey: accounts.authority, isSigner: false, isWritable: false },
{ pubkey: accounts.quote, isSigner: false, isWritable: true },
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: false },
{ pubkey: accounts.payer, isSigner: true, isWritable: true },
{ pubkey: accounts.wallet, isSigner: false, isWritable: true },
{ pubkey: accounts.walletAuthority, isSigner: true, isWritable: false },
{ pubkey: accounts.tokenWallet, isSigner: false, isWritable: true },
{ pubkey: accounts.state, isSigner: false, isWritable: false },
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
{
@ -72,10 +66,6 @@ export function functionInit(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionRequestCloseArgs {
@ -32,7 +29,8 @@ export const layout = borsh.struct([
export function functionRequestClose(
program: SwitchboardProgram,
args: FunctionRequestCloseArgs,
accounts: FunctionRequestCloseAccounts
accounts: FunctionRequestCloseAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.request, isSigner: false, isWritable: true },
@ -54,10 +52,6 @@ export function functionRequestClose(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionRequestInitArgs {
@ -35,7 +32,8 @@ export const layout = borsh.struct([
export function functionRequestInit(
program: SwitchboardProgram,
args: FunctionRequestInitArgs,
accounts: FunctionRequestInitAccounts
accounts: FunctionRequestInitAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.request, isSigner: true, isWritable: true },
@ -64,10 +62,6 @@ export function functionRequestInit(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionRequestInitAndTriggerArgs {
@ -33,7 +30,8 @@ export const layout = borsh.struct([
export function functionRequestInitAndTrigger(
program: SwitchboardProgram,
args: FunctionRequestInitAndTriggerArgs,
accounts: FunctionRequestInitAndTriggerAccounts
accounts: FunctionRequestInitAndTriggerAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.request, isSigner: true, isWritable: true },
@ -62,10 +60,6 @@ export function functionRequestInitAndTrigger(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionRequestSetConfigArgs {
@ -25,7 +22,8 @@ export const layout = borsh.struct([
export function functionRequestSetConfig(
program: SwitchboardProgram,
args: FunctionRequestSetConfigArgs,
accounts: FunctionRequestSetConfigAccounts
accounts: FunctionRequestSetConfigAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.request, isSigner: false, isWritable: true },
@ -40,10 +38,6 @@ export function functionRequestSetConfig(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionRequestTriggerArgs {
@ -32,7 +29,8 @@ export const layout = borsh.struct([
export function functionRequestTrigger(
program: SwitchboardProgram,
args: FunctionRequestTriggerArgs,
accounts: FunctionRequestTriggerAccounts
accounts: FunctionRequestTriggerAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.request, isSigner: false, isWritable: true },
@ -54,10 +52,6 @@ export function functionRequestTrigger(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionRequestVerifyArgs {
@ -35,7 +32,8 @@ export const layout = borsh.struct([
export function functionRequestVerify(
program: SwitchboardProgram,
args: FunctionRequestVerifyArgs,
accounts: FunctionRequestVerifyAccounts
accounts: FunctionRequestVerifyAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.request, isSigner: false, isWritable: true },
@ -68,10 +66,6 @@ export function functionRequestVerify(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionResetEscrowArgs {
@ -22,7 +19,6 @@ export interface FunctionResetEscrowAccounts {
defaultWallet: PublicKey;
tokenWallet: PublicKey;
payer: PublicKey;
state: PublicKey;
tokenProgram: PublicKey;
associatedTokenProgram: PublicKey;
systemProgram: PublicKey;
@ -35,7 +31,8 @@ export const layout = borsh.struct([
export function functionResetEscrow(
program: SwitchboardProgram,
args: FunctionResetEscrowArgs,
accounts: FunctionResetEscrowAccounts
accounts: FunctionResetEscrowAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.function, isSigner: false, isWritable: true },
@ -46,7 +43,6 @@ export function functionResetEscrow(
{ pubkey: accounts.defaultWallet, isSigner: false, isWritable: true },
{ pubkey: accounts.tokenWallet, isSigner: false, isWritable: true },
{ pubkey: accounts.payer, isSigner: true, isWritable: true },
{ pubkey: accounts.state, isSigner: false, isWritable: false },
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
{
pubkey: accounts.associatedTokenProgram,
@ -64,10 +60,6 @@ export function functionResetEscrow(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionSetAuthorityArgs {
@ -30,7 +27,8 @@ export const layout = borsh.struct([
export function functionSetAuthority(
program: SwitchboardProgram,
args: FunctionSetAuthorityArgs,
accounts: FunctionSetAuthorityAccounts
accounts: FunctionSetAuthorityAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.function, isSigner: false, isWritable: true },
@ -50,10 +48,6 @@ export function functionSetAuthority(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionSetConfigArgs {
@ -15,7 +12,6 @@ export interface FunctionSetConfigArgs {
export interface FunctionSetConfigAccounts {
function: PublicKey;
quote: PublicKey;
authority: PublicKey;
}
@ -26,11 +22,11 @@ export const layout = borsh.struct([
export function functionSetConfig(
program: SwitchboardProgram,
args: FunctionSetConfigArgs,
accounts: FunctionSetConfigAccounts
accounts: FunctionSetConfigAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.function, isSigner: false, isWritable: true },
{ pubkey: accounts.quote, isSigner: false, isWritable: true },
{ pubkey: accounts.authority, isSigner: true, isWritable: false },
];
const identifier = Buffer.from([232, 132, 21, 251, 253, 189, 96, 94]);
@ -42,10 +38,6 @@ export function functionSetConfig(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionSetEscrowArgs {
@ -31,7 +28,8 @@ export const layout = borsh.struct([
export function functionSetEscrow(
program: SwitchboardProgram,
args: FunctionSetEscrowArgs,
accounts: FunctionSetEscrowAccounts
accounts: FunctionSetEscrowAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.function, isSigner: false, isWritable: true },
@ -56,10 +54,6 @@ export function functionSetEscrow(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionTriggerArgs {
@ -26,7 +23,8 @@ export const layout = borsh.struct([
export function functionTrigger(
program: SwitchboardProgram,
args: FunctionTriggerArgs,
accounts: FunctionTriggerAccounts
accounts: FunctionTriggerAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.function, isSigner: false, isWritable: true },
@ -42,10 +40,6 @@ export function functionTrigger(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface FunctionVerifyArgs {
@ -15,16 +12,13 @@ export interface FunctionVerifyArgs {
export interface FunctionVerifyAccounts {
function: PublicKey;
authority: PublicKey;
functionEnclaveSigner: PublicKey;
fnQuote: PublicKey;
verifierQuote: PublicKey;
verifierEnclaveSigner: PublicKey;
verifier: PublicKey;
verifierSigner: PublicKey;
verifierPermission: PublicKey;
escrowWallet: PublicKey;
escrowTokenWallet: PublicKey;
receiver: PublicKey;
state: PublicKey;
attestationQueue: PublicKey;
tokenProgram: PublicKey;
}
@ -36,28 +30,22 @@ export const layout = borsh.struct([
export function functionVerify(
program: SwitchboardProgram,
args: FunctionVerifyArgs,
accounts: FunctionVerifyAccounts
accounts: FunctionVerifyAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.function, isSigner: false, isWritable: true },
{ pubkey: accounts.authority, isSigner: false, isWritable: false },
{
pubkey: accounts.functionEnclaveSigner,
isSigner: true,
isWritable: false,
},
{ pubkey: accounts.fnQuote, isSigner: false, isWritable: true },
{ pubkey: accounts.verifierQuote, isSigner: false, isWritable: false },
{
pubkey: accounts.verifierEnclaveSigner,
isSigner: true,
isWritable: false,
},
{ pubkey: accounts.verifier, isSigner: false, isWritable: false },
{ pubkey: accounts.verifierSigner, isSigner: true, isWritable: false },
{ pubkey: accounts.verifierPermission, isSigner: false, isWritable: false },
{ pubkey: accounts.escrowWallet, isSigner: false, isWritable: false },
{ pubkey: accounts.escrowTokenWallet, isSigner: false, isWritable: true },
{ pubkey: accounts.receiver, isSigner: false, isWritable: true },
{ pubkey: accounts.state, isSigner: false, isWritable: false },
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: false },
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
];
@ -70,10 +58,6 @@ export function functionVerify(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -97,19 +97,25 @@ export type {
FunctionVerifyArgs,
} from "./functionVerify.js";
export { functionVerify } from "./functionVerify.js";
export type {
QuoteHeartbeatAccounts,
QuoteHeartbeatArgs,
} from "./quoteHeartbeat.js";
export { quoteHeartbeat } from "./quoteHeartbeat.js";
export type { QuoteInitAccounts, QuoteInitArgs } from "./quoteInit.js";
export { quoteInit } from "./quoteInit.js";
export type { QuoteRotateAccounts, QuoteRotateArgs } from "./quoteRotate.js";
export { quoteRotate } from "./quoteRotate.js";
export type { QuoteVerifyAccounts, QuoteVerifyArgs } from "./quoteVerify.js";
export { quoteVerify } from "./quoteVerify.js";
export type { StateInitAccounts, StateInitArgs } from "./stateInit.js";
export { stateInit } from "./stateInit.js";
export type {
VerifierHeartbeatAccounts,
VerifierHeartbeatArgs,
} from "./verifierHeartbeat.js";
export { verifierHeartbeat } from "./verifierHeartbeat.js";
export type { VerifierInitAccounts, VerifierInitArgs } from "./verifierInit.js";
export { verifierInit } from "./verifierInit.js";
export type {
VerifierQuoteRotateAccounts,
VerifierQuoteRotateArgs,
} from "./verifierQuoteRotate.js";
export { verifierQuoteRotate } from "./verifierQuoteRotate.js";
export type {
VerifierQuoteVerifyAccounts,
VerifierQuoteVerifyArgs,
} from "./verifierQuoteVerify.js";
export { verifierQuoteVerify } from "./verifierQuoteVerify.js";
export type { WalletCloseAccounts, WalletCloseArgs } from "./walletClose.js";
export { walletClose } from "./walletClose.js";
export type { WalletFundAccounts, WalletFundArgs } from "./walletFund.js";

View File

@ -1,51 +0,0 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface QuoteRotateArgs {
params: types.QuoteRotateParamsFields;
}
export interface QuoteRotateAccounts {
quote: PublicKey;
authority: PublicKey;
enclaveSigner: PublicKey;
attestationQueue: PublicKey;
}
export const layout = borsh.struct([types.QuoteRotateParams.layout("params")]);
export function quoteRotate(
program: SwitchboardProgram,
args: QuoteRotateArgs,
accounts: QuoteRotateAccounts
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.quote, isSigner: false, isWritable: true },
{ pubkey: accounts.authority, isSigner: true, isWritable: false },
{ pubkey: accounts.enclaveSigner, isSigner: false, isWritable: false },
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: true },
];
const identifier = Buffer.from([153, 94, 246, 7, 7, 124, 62, 7]);
const buffer = Buffer.alloc(1000);
const len = layout.encode(
{
params: types.QuoteRotateParams.toEncodable(args.params),
},
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface StateInitArgs {
@ -24,7 +21,8 @@ export const layout = borsh.struct([types.StateInitParams.layout("params")]);
export function stateInit(
program: SwitchboardProgram,
args: StateInitArgs,
accounts: StateInitAccounts
accounts: StateInitAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.state, isSigner: false, isWritable: true },
@ -40,10 +38,6 @@ export function stateInit(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,21 +1,18 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface QuoteHeartbeatArgs {
params: types.QuoteHeartbeatParamsFields;
export interface VerifierHeartbeatArgs {
params: types.VerifierHeartbeatParamsFields;
}
export interface QuoteHeartbeatAccounts {
quote: PublicKey;
enclaveSigner: PublicKey;
export interface VerifierHeartbeatAccounts {
verifier: PublicKey;
verifierSigner: PublicKey;
attestationQueue: PublicKey;
queueAuthority: PublicKey;
gcNode: PublicKey;
@ -23,35 +20,32 @@ export interface QuoteHeartbeatAccounts {
}
export const layout = borsh.struct([
types.QuoteHeartbeatParams.layout("params"),
types.VerifierHeartbeatParams.layout("params"),
]);
export function quoteHeartbeat(
export function verifierHeartbeat(
program: SwitchboardProgram,
args: QuoteHeartbeatArgs,
accounts: QuoteHeartbeatAccounts
args: VerifierHeartbeatArgs,
accounts: VerifierHeartbeatAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.quote, isSigner: false, isWritable: true },
{ pubkey: accounts.enclaveSigner, isSigner: true, isWritable: false },
{ pubkey: accounts.verifier, isSigner: false, isWritable: true },
{ pubkey: accounts.verifierSigner, isSigner: true, isWritable: false },
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: true },
{ pubkey: accounts.queueAuthority, isSigner: false, isWritable: false },
{ pubkey: accounts.gcNode, isSigner: false, isWritable: true },
{ pubkey: accounts.permission, isSigner: false, isWritable: false },
];
const identifier = Buffer.from([202, 24, 19, 240, 75, 39, 154, 110]);
const identifier = Buffer.from([25, 238, 221, 14, 250, 148, 0, 140]);
const buffer = Buffer.alloc(1000);
const len = layout.encode(
{
params: types.QuoteHeartbeatParams.toEncodable(args.params),
params: types.VerifierHeartbeatParams.toEncodable(args.params),
},
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,20 +1,17 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface QuoteInitArgs {
params: types.QuoteInitParamsFields;
export interface VerifierInitArgs {
params: types.VerifierInitParamsFields;
}
export interface QuoteInitAccounts {
quote: PublicKey;
export interface VerifierInitAccounts {
verifier: PublicKey;
attestationQueue: PublicKey;
queueAuthority: PublicKey;
authority: PublicKey;
@ -22,34 +19,31 @@ export interface QuoteInitAccounts {
systemProgram: PublicKey;
}
export const layout = borsh.struct([types.QuoteInitParams.layout("params")]);
export const layout = borsh.struct([types.VerifierInitParams.layout("params")]);
export function quoteInit(
export function verifierInit(
program: SwitchboardProgram,
args: QuoteInitArgs,
accounts: QuoteInitAccounts
args: VerifierInitArgs,
accounts: VerifierInitAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.quote, isSigner: true, isWritable: true },
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: true },
{ pubkey: accounts.verifier, isSigner: true, isWritable: true },
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: false },
{ pubkey: accounts.queueAuthority, isSigner: false, isWritable: false },
{ pubkey: accounts.authority, isSigner: false, isWritable: false },
{ pubkey: accounts.payer, isSigner: true, isWritable: true },
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
];
const identifier = Buffer.from([124, 251, 28, 247, 136, 141, 198, 116]);
const identifier = Buffer.from([197, 138, 116, 14, 24, 81, 9, 245]);
const buffer = Buffer.alloc(1000);
const len = layout.encode(
{
params: types.QuoteInitParams.toEncodable(args.params),
params: types.VerifierInitParams.toEncodable(args.params),
},
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -0,0 +1,47 @@
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface VerifierQuoteRotateArgs {
params: types.VerifierQuoteRotateParamsFields;
}
export interface VerifierQuoteRotateAccounts {
verifier: PublicKey;
authority: PublicKey;
enclaveSigner: PublicKey;
attestationQueue: PublicKey;
}
export const layout = borsh.struct([
types.VerifierQuoteRotateParams.layout("params"),
]);
export function verifierQuoteRotate(
program: SwitchboardProgram,
args: VerifierQuoteRotateArgs,
accounts: VerifierQuoteRotateAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.verifier, isSigner: false, isWritable: true },
{ pubkey: accounts.authority, isSigner: true, isWritable: false },
{ pubkey: accounts.enclaveSigner, isSigner: false, isWritable: false },
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: true },
];
const identifier = Buffer.from([52, 93, 191, 90, 182, 82, 65, 197]);
const buffer = Buffer.alloc(1000);
const len = layout.encode(
{
params: types.VerifierQuoteRotateParams.toEncodable(args.params),
},
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,53 +1,47 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface QuoteVerifyArgs {
params: types.QuoteVerifyParamsFields;
export interface VerifierQuoteVerifyArgs {
params: types.VerifierQuoteVerifyParamsFields;
}
export interface QuoteVerifyAccounts {
export interface VerifierQuoteVerifyAccounts {
quote: PublicKey;
quoteSigner: PublicKey;
verifier: PublicKey;
enclaveSigner: PublicKey;
attestationQueue: PublicKey;
}
export const layout = borsh.struct([types.QuoteVerifyParams.layout("params")]);
export const layout = borsh.struct([
types.VerifierQuoteVerifyParams.layout("params"),
]);
export function quoteVerify(
export function verifierQuoteVerify(
program: SwitchboardProgram,
args: QuoteVerifyArgs,
accounts: QuoteVerifyAccounts
args: VerifierQuoteVerifyArgs,
accounts: VerifierQuoteVerifyAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.quote, isSigner: false, isWritable: true },
{ pubkey: accounts.quoteSigner, isSigner: false, isWritable: false },
{ pubkey: accounts.verifier, isSigner: false, isWritable: false },
{ pubkey: accounts.enclaveSigner, isSigner: true, isWritable: false },
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: false },
];
const identifier = Buffer.from([158, 203, 69, 10, 212, 218, 45, 184]);
const identifier = Buffer.from([73, 38, 235, 197, 78, 209, 141, 253]);
const buffer = Buffer.alloc(1000);
const len = layout.encode(
{
params: types.QuoteVerifyParams.toEncodable(args.params),
params: types.VerifierQuoteVerifyParams.toEncodable(args.params),
},
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface WalletCloseArgs {
@ -32,7 +29,8 @@ export const layout = borsh.struct([types.WalletCloseParams.layout("params")]);
export function walletClose(
program: SwitchboardProgram,
args: WalletCloseArgs,
accounts: WalletCloseAccounts
accounts: WalletCloseAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.wallet, isSigner: false, isWritable: true },
@ -56,10 +54,6 @@ export function walletClose(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

View File

@ -1,12 +1,9 @@
import { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import type { SwitchboardProgram } from "../../../SwitchboardProgram.js";
import * as types from "../types/index.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
import {
AccountMeta,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
export interface WalletFundArgs {
@ -31,7 +28,8 @@ export const layout = borsh.struct([types.WalletFundParams.layout("params")]);
export function walletFund(
program: SwitchboardProgram,
args: WalletFundArgs,
accounts: WalletFundAccounts
accounts: WalletFundAccounts,
programId: PublicKey = program.attestationProgramId
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.wallet, isSigner: false, isWritable: true },
@ -54,10 +52,6 @@ export function walletFund(
buffer
);
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
const ix = new TransactionInstruction({
keys,
programId: program.attestationProgramId,
data,
});
const ix = new TransactionInstruction({ keys, programId, data });
return ix;
}

Some files were not shown because too many files have changed in this diff Show More