chore: release
This commit is contained in:
parent
3169759a49
commit
dc8d155b62
|
@ -4227,9 +4227,9 @@ checksum = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "switchboard-common"
|
name = "switchboard-common"
|
||||||
version = "0.8.1"
|
version = "0.8.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ba2cc1d6055e0989756adc4f54fa1e27d684ce08d6164da23900e93ac0b13b6"
|
checksum = "c5a03303674fb73b1dbe6cfc83aa8faa0e99264472a47177a1803f7475b318d1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.2.10",
|
"getrandom 0.2.10",
|
||||||
"hex",
|
"hex",
|
||||||
|
@ -4249,7 +4249,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "switchboard-solana"
|
name = "switchboard-solana"
|
||||||
version = "0.8.4"
|
version = "0.9.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anchor-client",
|
"anchor-client",
|
||||||
"anchor-lang",
|
"anchor-lang",
|
||||||
|
@ -4258,6 +4258,7 @@ dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"chrono",
|
"chrono",
|
||||||
"cron",
|
"cron",
|
||||||
|
"hex",
|
||||||
"rust_decimal",
|
"rust_decimal",
|
||||||
"sgx-quote",
|
"sgx-quote",
|
||||||
"solana-address-lookup-table-program",
|
"solana-address-lookup-table-program",
|
||||||
|
@ -4265,6 +4266,7 @@ dependencies = [
|
||||||
"solana-program",
|
"solana-program",
|
||||||
"superslice",
|
"superslice",
|
||||||
"switchboard-common",
|
"switchboard-common",
|
||||||
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -17,5 +17,5 @@ cpi = ["no-entrypoint"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# switchboard-solana = "0.8.4"
|
# 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"
|
bytemuck = "1.13.1"
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
"prettier": "^2.4.1",
|
"prettier": "^2.4.1",
|
||||||
"prettier-plugin-organize-imports": "^2.3.4",
|
"prettier-plugin-organize-imports": "^2.3.4",
|
||||||
"shx": "^0.3.4",
|
"shx": "^0.3.4",
|
||||||
"switchboard-solana": "workspace:*",
|
|
||||||
"ts-mocha": "^9.0.2",
|
"ts-mocha": "^9.0.2",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
"typescript": "^4.9.3"
|
"typescript": "^4.9.3"
|
||||||
|
|
|
@ -12,4 +12,4 @@ no-entrypoint = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
# switchboard-solana = "0.8.4"
|
# 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" }
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
"@types/node": "^17.0.45",
|
"@types/node": "^17.0.45",
|
||||||
"chai": "^4.3.6",
|
"chai": "^4.3.6",
|
||||||
"mocha": "^9.0.3",
|
"mocha": "^9.0.3",
|
||||||
"switchboard-solana": "workspace:*",
|
|
||||||
"ts-mocha": "^9.0.2",
|
"ts-mocha": "^9.0.2",
|
||||||
"ts-node": "^10.4.0",
|
"ts-node": "^10.4.0",
|
||||||
"typescript": "^4.7"
|
"typescript": "^4.7"
|
||||||
|
|
|
@ -6,9 +6,11 @@ seeds = false
|
||||||
skip-lint = false
|
skip-lint = false
|
||||||
|
|
||||||
[programs.localnet]
|
[programs.localnet]
|
||||||
basic_oracle = "CE1HrS25FhvPjcAH4Zjka6uJBbYrDRY7uZ8PPSkiUwAh"
|
basic_oracle = "8GHcguBXZEfKaLxRrBvis7LqPcFjBszv4ZYBgKwCUipS"
|
||||||
|
|
||||||
[provider]
|
[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"
|
cluster = "Localnet"
|
||||||
wallet = "~/.config/solana/id.json"
|
wallet = "~/.config/solana/id.json"
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -17,6 +17,10 @@ cpi = ["no-entrypoint"]
|
||||||
default = []
|
default = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
switchboard-solana = "0.8.4"
|
switchboard-solana = { version = "=0.9.1" }
|
||||||
# switchboard-solana = { version = "0.8.4", path = "../../../rust/switchboard-solana" }
|
# switchboard-solana = { version = "0.9.1", path = "../../../../../rust/switchboard-solana" }
|
||||||
bytemuck = "^1"
|
bytemuck = "^1"
|
||||||
|
anchor-lang = { version = "0.28.0", features = [
|
||||||
|
"init-if-needed",
|
||||||
|
"allow-missing-optionals"
|
||||||
|
] }
|
|
@ -7,27 +7,24 @@
|
||||||
"directory": "examples/functions/01_basic_oracle"
|
"directory": "examples/functions/01_basic_oracle"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "anchor build",
|
"build:anchor": "anchor build",
|
||||||
"lint:fix": "prettier */*.js \"*/**/*{.js,.ts}\" -w",
|
"clean": "pnpm exec rimraf node_modules .anchor lib .turbo"
|
||||||
"lint": "prettier */*.js \"*/**/*{.js,.ts}\" --check"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@coral-xyz/anchor": "^0.28.0",
|
"@coral-xyz/anchor": "^0.28.0",
|
||||||
"@solana/spl-token": "^0.3.6",
|
"@solana/spl-token": "^0.3.6",
|
||||||
"@solana/web3.js": "^1.77.3",
|
"@solana/web3.js": "^1.78.0",
|
||||||
"@switchboard-xyz/common": "^2.2.4",
|
"@switchboard-xyz/common": "*",
|
||||||
"@switchboard-xyz/oracle": "^2.1.13",
|
"@switchboard-xyz/oracle": "*",
|
||||||
"@switchboard-xyz/solana.js": "workspace:*"
|
"@switchboard-xyz/solana.js": "workspace:*"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^4.3.4",
|
|
||||||
"mocha": "^9.0.3",
|
|
||||||
"ts-mocha": "^10.0.0",
|
|
||||||
"@types/bn.js": "^5.1.0",
|
"@types/bn.js": "^5.1.0",
|
||||||
"@types/chai": "^4.3.0",
|
"@types/chai": "^4.3.0",
|
||||||
"@types/mocha": "^9.0.0",
|
"@types/mocha": "^9.0.0",
|
||||||
"typescript": "^4.3.5",
|
"@types/node": "^20.4.0",
|
||||||
"prettier": "^2.6.2",
|
"chai": "^4.3.4",
|
||||||
"switchboard-solana": "workspace:*"
|
"mocha": "^9.0.3",
|
||||||
|
"ts-mocha": "^10.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -13,7 +13,5 @@ tokio = "^1"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
serde = "^1"
|
serde = "^1"
|
||||||
serde_json = "^1"
|
serde_json = "^1"
|
||||||
switchboard-utils = "0.8.0"
|
switchboard-utils = { version = "0.8.0" }
|
||||||
# switchboard-utils = { version = "0.8.1", path = "../../../../../sbv2-core/rust/switchboard-utils" }
|
switchboard-solana = { version = "=0.9.1" }
|
||||||
switchboard-solana = "0.8.4"
|
|
||||||
# switchboard-solana = { version = "0.8.4", path = "../../../../rust/switchboard-solana" }
|
|
|
@ -22,4 +22,7 @@ COPY --from=builder /sgx/app /sgx
|
||||||
# Get the measurement from the enclave
|
# Get the measurement from the enclave
|
||||||
RUN /get_measurement.sh
|
RUN /get_measurement.sh
|
||||||
|
|
||||||
|
RUN cp /app.manifest.sgx /sgx/app.manifest.sgx
|
||||||
|
RUN cp /app.sig /sgx/app.sig
|
||||||
|
|
||||||
ENTRYPOINT ["bash", "/boot.sh"]
|
ENTRYPOINT ["bash", "/boot.sh"]
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
"build:function": "make"
|
"build:function": "make"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"switchboard-solana": "workspace:*",
|
|
||||||
"basic-oracle": "workspace:*"
|
"basic-oracle": "workspace:*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,11 +173,6 @@ impl Binance {
|
||||||
let ixn = Instruction {
|
let ixn = Instruction {
|
||||||
program_id: basic_oracle::ID,
|
program_id: basic_oracle::ID,
|
||||||
accounts: vec![
|
accounts: vec![
|
||||||
AccountMeta {
|
|
||||||
pubkey: program_state_pubkey,
|
|
||||||
is_signer: false,
|
|
||||||
is_writable: false,
|
|
||||||
},
|
|
||||||
AccountMeta {
|
AccountMeta {
|
||||||
pubkey: oracle_pubkey,
|
pubkey: oracle_pubkey,
|
||||||
is_signer: false,
|
is_signer: false,
|
||||||
|
@ -188,11 +183,6 @@ impl Binance {
|
||||||
is_signer: false,
|
is_signer: false,
|
||||||
is_writable: false,
|
is_writable: false,
|
||||||
},
|
},
|
||||||
AccountMeta {
|
|
||||||
pubkey: runner.quote,
|
|
||||||
is_signer: false,
|
|
||||||
is_writable: false,
|
|
||||||
},
|
|
||||||
AccountMeta {
|
AccountMeta {
|
||||||
pubkey: runner.signer,
|
pubkey: runner.signer,
|
||||||
is_signer: true,
|
is_signer: true,
|
||||||
|
@ -211,4 +201,4 @@ pub fn parse_string_value(value: &str) -> i128 {
|
||||||
let f64_value = value.parse::<f64>().unwrap();
|
let f64_value = value.parse::<f64>().unwrap();
|
||||||
let sb_decimal = SwitchboardDecimal::from_f64(f64_value);
|
let sb_decimal = SwitchboardDecimal::from_f64(f64_value);
|
||||||
sb_decimal.scale_to(9)
|
sb_decimal.scale_to(9)
|
||||||
}
|
}
|
|
@ -21,18 +21,11 @@ pub struct Initialize<'info> {
|
||||||
)]
|
)]
|
||||||
pub oracle: AccountLoader<'info, MyOracleState>,
|
pub oracle: AccountLoader<'info, MyOracleState>,
|
||||||
|
|
||||||
#[account(
|
|
||||||
constraint = function.load()?.authority == program.key()
|
|
||||||
)]
|
|
||||||
pub function: AccountLoader<'info, FunctionAccountData>,
|
|
||||||
|
|
||||||
/// CHECK:
|
|
||||||
pub authority: Signer<'info>,
|
pub authority: Signer<'info>,
|
||||||
|
|
||||||
#[account(mut)]
|
#[account(mut)]
|
||||||
pub payer: Signer<'info>,
|
pub payer: Signer<'info>,
|
||||||
|
|
||||||
// SYSTEM ACCOUNTS
|
|
||||||
pub system_program: Program<'info, System>,
|
pub system_program: Program<'info, System>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,19 +36,18 @@ impl Initialize<'_> {
|
||||||
pub fn validate(
|
pub fn validate(
|
||||||
&self,
|
&self,
|
||||||
_ctx: &Context<Self>,
|
_ctx: &Context<Self>,
|
||||||
params: &InitializeParams,
|
_params: &InitializeParams,
|
||||||
) -> anchor_lang::Result<()> {
|
) -> anchor_lang::Result<()> {
|
||||||
Ok(())
|
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()?;
|
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.authority = ctx.accounts.authority.key();
|
||||||
program.function = ctx.accounts.function.key();
|
|
||||||
|
|
||||||
let oracle = &mut ctx.accounts.oracle.load_init()?;
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,3 +6,6 @@ pub use refresh_prices::*;
|
||||||
|
|
||||||
pub mod set_function;
|
pub mod set_function;
|
||||||
pub use set_function::*;
|
pub use set_function::*;
|
||||||
|
|
||||||
|
pub mod trigger_function;
|
||||||
|
pub use trigger_function::*;
|
|
@ -2,13 +2,6 @@ use crate::*;
|
||||||
|
|
||||||
#[derive(Accounts)]
|
#[derive(Accounts)]
|
||||||
pub struct RefreshPrices<'info> {
|
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(
|
#[account(
|
||||||
mut,
|
mut,
|
||||||
seeds = [ORACLE_SEED],
|
seeds = [ORACLE_SEED],
|
||||||
|
@ -16,22 +9,21 @@ pub struct RefreshPrices<'info> {
|
||||||
)]
|
)]
|
||||||
pub oracle: AccountLoader<'info, MyOracleState>,
|
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(
|
#[account(
|
||||||
constraint =
|
constraint =
|
||||||
FunctionAccountData::validate_enclave(
|
function.load()?.validate(
|
||||||
&function.to_account_info(),
|
&enclave_signer.to_account_info()
|
||||||
&enclave.to_account_info(),
|
)? @ BasicOracleError::FunctionValidationFailed
|
||||||
&enclave_signer.to_account_info()
|
// FunctionAccountData::validate(
|
||||||
)?
|
// &function.to_account_info(),
|
||||||
|
// &enclave_signer.to_account_info()
|
||||||
|
// )? @ BasicOracleError::FunctionValidationFailed
|
||||||
)]
|
)]
|
||||||
pub function: AccountLoader<'info, FunctionAccountData>,
|
pub function: AccountLoader<'info, FunctionAccountData>,
|
||||||
pub enclave: AccountLoader<'info, EnclaveAccountData>,
|
|
||||||
pub enclave_signer: Signer<'info>,
|
pub enclave_signer: Signer<'info>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
|
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
|
||||||
pub struct RefreshPricesParams {
|
pub struct RefreshPricesParams {
|
||||||
pub rows: Vec<OracleDataWithTradingSymbol>,
|
pub rows: Vec<OracleDataWithTradingSymbol>,
|
||||||
|
@ -48,8 +40,9 @@ impl RefreshPrices<'_> {
|
||||||
|
|
||||||
pub fn actuate(ctx: &Context<Self>, params: &RefreshPricesParams) -> anchor_lang::Result<()> {
|
pub fn actuate(ctx: &Context<Self>, params: &RefreshPricesParams) -> anchor_lang::Result<()> {
|
||||||
let oracle = &mut ctx.accounts.oracle.load_mut()?;
|
let oracle = &mut ctx.accounts.oracle.load_mut()?;
|
||||||
|
msg!("saving oracle data");
|
||||||
oracle.save_rows(¶ms.rows)?;
|
oracle.save_rows(¶ms.rows)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -18,22 +18,20 @@ pub struct SetFunction<'info> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
|
#[derive(Clone, AnchorSerialize, AnchorDeserialize)]
|
||||||
pub struct SetFunctionParams {
|
pub struct SetFunctionParams { }
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SetFunction<'_> {
|
impl SetFunction<'_> {
|
||||||
pub fn validate(
|
pub fn validate(
|
||||||
&self,
|
&self,
|
||||||
_ctx: &Context<Self>,
|
_ctx: &Context<Self>,
|
||||||
params: &SetFunctionParams,
|
_params: &SetFunctionParams,
|
||||||
) -> anchor_lang::Result<()> {
|
) -> anchor_lang::Result<()> {
|
||||||
Ok(())
|
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()?;
|
let program = &mut ctx.accounts.program.load_init()?;
|
||||||
program.function = ctx.accounts.function.key();
|
program.function = ctx.accounts.function.key();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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(())
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,12 +13,12 @@ pub enum BasicOracleError {
|
||||||
InvalidTrustedSigner,
|
InvalidTrustedSigner,
|
||||||
#[msg("Invalid MRENCLAVE")]
|
#[msg("Invalid MRENCLAVE")]
|
||||||
InvalidMrEnclave,
|
InvalidMrEnclave,
|
||||||
#[msg("Switchboard QuoteAccount has an empty MrEnclave (invalid)")]
|
|
||||||
EmptySwitchboardQuote,
|
|
||||||
#[msg("Failed to find a valid trading symbol for this price")]
|
#[msg("Failed to find a valid trading symbol for this price")]
|
||||||
InvalidSymbol,
|
InvalidSymbol,
|
||||||
#[msg("FunctionAccount pubkey did not match program_state.function")]
|
#[msg("FunctionAccount pubkey did not match program_state.function")]
|
||||||
IncorrectSwitchboardFunction,
|
IncorrectSwitchboardFunction,
|
||||||
#[msg("FunctionAccount pubkey did not match program_state.function")]
|
#[msg("FunctionAccount pubkey did not match program_state.function")]
|
||||||
InvalidSwitchboardFunction,
|
InvalidSwitchboardFunction,
|
||||||
|
#[msg("FunctionAccount was not validated successfully")]
|
||||||
|
FunctionValidationFailed,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
pub mod actions;
|
||||||
|
pub use actions::*;
|
||||||
pub use switchboard_solana::prelude::*;
|
pub use switchboard_solana::prelude::*;
|
||||||
|
declare_id!("EF68PJkRqQu2VthTSy19kg6TWynMtRmLpxcMDKEdLC8t");
|
||||||
|
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub use error::*;
|
pub use error::*;
|
||||||
|
@ -9,10 +12,7 @@ pub use model::*;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
pub use utils::*;
|
pub use utils::*;
|
||||||
|
|
||||||
pub mod actions;
|
|
||||||
pub use actions::*;
|
|
||||||
|
|
||||||
declare_id!("CE1HrS25FhvPjcAH4Zjka6uJBbYrDRY7uZ8PPSkiUwAh");
|
|
||||||
|
|
||||||
pub const PROGRAM_SEED: &[u8] = b"BASICORACLE";
|
pub const PROGRAM_SEED: &[u8] = b"BASICORACLE";
|
||||||
|
|
||||||
|
@ -45,4 +45,12 @@ pub mod basic_oracle {
|
||||||
) -> anchor_lang::Result<()> {
|
) -> anchor_lang::Result<()> {
|
||||||
SetFunction::actuate(&ctx, ¶ms)
|
SetFunction::actuate(&ctx, ¶ms)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
#[access_control(ctx.accounts.validate(&ctx, ¶ms))]
|
||||||
|
pub fn trigger_function(
|
||||||
|
ctx: Context<TriggerFunction>,
|
||||||
|
params: TriggerFunctionParams,
|
||||||
|
) -> anchor_lang::Result<()> {
|
||||||
|
TriggerFunction::actuate(&ctx, ¶ms)
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 * 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 { 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);
|
const unixTimestamp = () => Math.floor(Date.now() / 1000);
|
||||||
|
|
||||||
|
@ -49,28 +53,47 @@ describe("basic_oracle", () => {
|
||||||
)[0];
|
)[0];
|
||||||
|
|
||||||
let switchboard: BootstrappedAttestationQueue;
|
let switchboard: BootstrappedAttestationQueue;
|
||||||
|
let wallet: SwitchboardWallet;
|
||||||
let functionAccount: FunctionAccount;
|
let functionAccount: FunctionAccount;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
const switchboardProgram = await SwitchboardProgram.fromProvider(
|
const switchboardProgram = await SwitchboardProgram.fromProvider(
|
||||||
program.provider as anchor.AnchorProvider
|
program.provider as anchor.AnchorProvider
|
||||||
);
|
);
|
||||||
|
|
||||||
await AttestationProgramStateAccount.getOrCreate(switchboardProgram);
|
await AttestationProgramStateAccount.getOrCreate(switchboardProgram);
|
||||||
|
|
||||||
switchboard = await AttestationQueueAccount.bootstrapNewQueue(
|
switchboard = await AttestationQueueAccount.bootstrapNewQueue(
|
||||||
switchboardProgram
|
switchboardProgram
|
||||||
);
|
);
|
||||||
|
|
||||||
[functionAccount] = await FunctionAccount.create(
|
console.log(`programStatePubkey: ${programStatePubkey}`);
|
||||||
switchboard.attestationQueueAccount.program,
|
|
||||||
{
|
[wallet] = await SwitchboardWallet.create(
|
||||||
container: "switchboardlabs/basic-oracle-function",
|
switchboard.program,
|
||||||
version: "latest",
|
switchboard.attestationQueue.publicKey,
|
||||||
schedule: "15 * * * * *",
|
payer,
|
||||||
mrEnclave: MRENCLAVE,
|
"MySharedWallet",
|
||||||
attestationQueue: switchboard.attestationQueueAccount,
|
16
|
||||||
authority: programStatePubkey,
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
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 () => {
|
it("Is initialized!", async () => {
|
||||||
|
@ -81,7 +104,8 @@ describe("basic_oracle", () => {
|
||||||
program: programStatePubkey,
|
program: programStatePubkey,
|
||||||
oracle: oraclePubkey,
|
oracle: oraclePubkey,
|
||||||
authority: payer,
|
authority: payer,
|
||||||
function: functionAccount.publicKey,
|
payer: payer,
|
||||||
|
// function: functionAccount.publicKey,
|
||||||
})
|
})
|
||||||
.rpc()
|
.rpc()
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
@ -114,13 +138,13 @@ describe("basic_oracle", () => {
|
||||||
const securedSigner = anchor.web3.Keypair.generate();
|
const securedSigner = anchor.web3.Keypair.generate();
|
||||||
|
|
||||||
const rewardAddress =
|
const rewardAddress =
|
||||||
await switchboard.attestationQueueAccount.program.mint.getOrCreateAssociatedUser(
|
await switchboard.program.mint.getOrCreateAssociatedUser(payer);
|
||||||
payer
|
|
||||||
);
|
const functionState = await functionAccount.loadData();
|
||||||
|
|
||||||
// TODO: generate function verify ixn
|
// TODO: generate function verify ixn
|
||||||
const functionVerifyIxn = attestationTypes.functionVerify(
|
const functionVerifyIxn = attestationTypes.functionVerify(
|
||||||
switchboard.attestationQueueAccount.program,
|
switchboard.program,
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
observedTime: new anchor.BN(unixTimestamp()),
|
observedTime: new anchor.BN(unixTimestamp()),
|
||||||
|
@ -132,16 +156,13 @@ describe("basic_oracle", () => {
|
||||||
{
|
{
|
||||||
function: functionAccount.publicKey,
|
function: functionAccount.publicKey,
|
||||||
functionEnclaveSigner: securedSigner.publicKey,
|
functionEnclaveSigner: securedSigner.publicKey,
|
||||||
verifierEnclaveSigner: switchboard.verifier.signer.publicKey,
|
verifier: switchboard.verifier.publicKey,
|
||||||
verifierQuote: switchboard.verifier.quoteAccount.publicKey,
|
verifierSigner: switchboard.verifier.signer.publicKey,
|
||||||
attestationQueue: switchboard.attestationQueueAccount.publicKey,
|
attestationQueue: switchboard.attestationQueue.publicKey,
|
||||||
escrow: functionAccount.getEscrow(),
|
escrowWallet: functionState.escrowWallet,
|
||||||
|
escrowTokenWallet: functionState.escrowTokenWallet,
|
||||||
receiver: rewardAddress,
|
receiver: rewardAddress,
|
||||||
verifierPermission: switchboard.verifier.permissionAccount.publicKey,
|
verifierPermission: switchboard.verifier.permissionAccount.publicKey,
|
||||||
state:
|
|
||||||
switchboard.attestationQueueAccount.program.attestationProgramState
|
|
||||||
.publicKey,
|
|
||||||
fnQuote: functionAccount.getEnclaveAccount()[0].publicKey,
|
|
||||||
tokenProgram: anchor.utils.token.TOKEN_PROGRAM_ID,
|
tokenProgram: anchor.utils.token.TOKEN_PROGRAM_ID,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -175,22 +196,18 @@ describe("basic_oracle", () => {
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
.accounts({
|
.accounts({
|
||||||
programState: programStatePubkey,
|
|
||||||
oracle: oraclePubkey,
|
oracle: oraclePubkey,
|
||||||
function: functionAccount.publicKey,
|
function: functionAccount.publicKey,
|
||||||
enclave: functionAccount.getEnclaveAccount()[0].publicKey,
|
|
||||||
enclaveSigner: securedSigner.publicKey,
|
enclaveSigner: securedSigner.publicKey,
|
||||||
})
|
})
|
||||||
.preInstructions([functionVerifyIxn])
|
.preInstructions([functionVerifyIxn])
|
||||||
.signers([switchboard.verifier.signer, securedSigner])
|
.signers([switchboard.verifier.signer, securedSigner])
|
||||||
.rpc()
|
.rpc({ skipPreflight: true });
|
||||||
.catch((err) => {
|
|
||||||
console.error(err);
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log("Your transaction signature", tx);
|
console.log("Your transaction signature", tx);
|
||||||
|
|
||||||
|
await printLogs(switchboard.program.connection, tx ? tx : "");
|
||||||
|
|
||||||
await sleep(5000);
|
await sleep(5000);
|
||||||
|
|
||||||
const oracleState = await program.account.myOracleState.fetch(oraclePubkey);
|
const oracleState = await program.account.myOracleState.fetch(oraclePubkey);
|
||||||
|
|
|
@ -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"));
|
||||||
|
}
|
|
@ -5,14 +5,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"types": [
|
"types": ["mocha", "chai", "node"],
|
||||||
"mocha",
|
"typeRoots": ["./node_modules/@types"],
|
||||||
"chai",
|
|
||||||
"node"
|
|
||||||
],
|
|
||||||
"typeRoots": [
|
|
||||||
"./node_modules/@types"
|
|
||||||
],
|
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
|
@ -20,23 +14,14 @@
|
||||||
"strictNullChecks": false,
|
"strictNullChecks": false,
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@switchboard-xyz/solana.js": [
|
"@switchboard-xyz/solana.js": ["../../../javascript/solana.js"]
|
||||||
"../../../javascript/solana.js"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"include": [
|
"include": ["tests/**/*", "target/types/*.ts"],
|
||||||
"tests/**/*",
|
"exclude": ["target", "lib"],
|
||||||
"./cli.ts",
|
|
||||||
"./client/**/*"
|
|
||||||
],
|
|
||||||
"exclude": [
|
|
||||||
"target",
|
|
||||||
"lib"
|
|
||||||
],
|
|
||||||
"references": [
|
"references": [
|
||||||
{
|
{
|
||||||
"path": "../../../javascript/solana.js"
|
"path": "../../../../../javascript/solana.js"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -4235,9 +4235,9 @@ checksum = "ab16ced94dbd8a46c82fd81e3ed9a8727dac2977ea869d217bcc4ea1f122e81f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "switchboard-common"
|
name = "switchboard-common"
|
||||||
version = "0.8.1"
|
version = "0.8.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ba2cc1d6055e0989756adc4f54fa1e27d684ce08d6164da23900e93ac0b13b6"
|
checksum = "c5a03303674fb73b1dbe6cfc83aa8faa0e99264472a47177a1803f7475b318d1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.2.10",
|
"getrandom 0.2.10",
|
||||||
"hex",
|
"hex",
|
||||||
|
@ -4249,7 +4249,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "switchboard-solana"
|
name = "switchboard-solana"
|
||||||
version = "0.8.4"
|
version = "0.9.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anchor-client",
|
"anchor-client",
|
||||||
"anchor-lang",
|
"anchor-lang",
|
||||||
|
@ -4258,6 +4258,7 @@ dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"chrono",
|
"chrono",
|
||||||
"cron",
|
"cron",
|
||||||
|
"hex",
|
||||||
"rust_decimal",
|
"rust_decimal",
|
||||||
"sgx-quote",
|
"sgx-quote",
|
||||||
"solana-address-lookup-table-program",
|
"solana-address-lookup-table-program",
|
||||||
|
@ -4265,6 +4266,7 @@ dependencies = [
|
||||||
"solana-program",
|
"solana-program",
|
||||||
"superslice",
|
"superslice",
|
||||||
"switchboard-common",
|
"switchboard-common",
|
||||||
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -17,5 +17,4 @@ cpi = ["no-entrypoint"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bytemuck = "1.13.1"
|
bytemuck = "1.13.1"
|
||||||
switchboard-solana = { path = "../../../rust/switchboard-solana", version = "0.8.4" }
|
switchboard-solana = { version = "^0.9.1", path = "../../../rust/switchboard-solana" }
|
||||||
# switchboard-solana = { version = "^0.8.4", path = "../../../rust/switchboard-solana" }
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@switchboard-xyz/solana.js",
|
"name": "@switchboard-xyz/solana.js",
|
||||||
"version": "2.3.3",
|
"version": "2.4.1",
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"description": "A Typescript client to interact with Switchboard on Solana.",
|
"description": "A Typescript client to interact with Switchboard on Solana.",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import * as borsh from "@coral-xyz/borsh";
|
import * as borsh from "@coral-xyz/borsh";
|
||||||
import { Connection, SYSVAR_CLOCK_PUBKEY } from "@solana/web3.js";
|
import type { Connection } from "@solana/web3.js";
|
||||||
import { BN } from "@switchboard-xyz/common";
|
import { SYSVAR_CLOCK_PUBKEY } from "@solana/web3.js";
|
||||||
|
import type { BN } from "@switchboard-xyz/common";
|
||||||
|
|
||||||
export interface SolanaClockDataFields {
|
export interface SolanaClockDataFields {
|
||||||
slot: BN;
|
slot: BN;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { SwitchboardProgram } from "./SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "./SwitchboardProgram.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switchboard wrapper for anchor program errors.
|
* Switchboard wrapper for anchor program errors.
|
||||||
|
|
|
@ -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 type * as anchor from "@coral-xyz/anchor";
|
||||||
import { BN } from "@switchboard-xyz/common";
|
import type { BN } from "@switchboard-xyz/common";
|
||||||
|
|
||||||
export type AggregatorAddJobEvent = {
|
export type AggregatorAddJobEvent = {
|
||||||
feedPubkey: anchor.web3.PublicKey;
|
feedPubkey: anchor.web3.PublicKey;
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
import {
|
import type {
|
||||||
AggregatorAccount,
|
|
||||||
BufferRelayerAccount,
|
|
||||||
CrankAccount,
|
|
||||||
CreateQueueBufferRelayerParams,
|
CreateQueueBufferRelayerParams,
|
||||||
CreateQueueCrankParams,
|
CreateQueueCrankParams,
|
||||||
CreateQueueFeedParams,
|
CreateQueueFeedParams,
|
||||||
CreateQueueOracleParams,
|
CreateQueueOracleParams,
|
||||||
CreateQueueVrfParams,
|
CreateQueueVrfParams,
|
||||||
|
QueueInitParams,
|
||||||
|
} from "./accounts/index.js";
|
||||||
|
import {
|
||||||
|
AggregatorAccount,
|
||||||
|
BufferRelayerAccount,
|
||||||
|
CrankAccount,
|
||||||
JobAccount,
|
JobAccount,
|
||||||
LeaseAccount,
|
LeaseAccount,
|
||||||
OracleAccount,
|
OracleAccount,
|
||||||
PermissionAccount,
|
PermissionAccount,
|
||||||
ProgramStateAccount,
|
ProgramStateAccount,
|
||||||
QueueAccount,
|
QueueAccount,
|
||||||
QueueInitParams,
|
|
||||||
VrfAccount,
|
VrfAccount,
|
||||||
} from "./accounts/index.js";
|
} from "./accounts/index.js";
|
||||||
import {
|
import {
|
||||||
|
@ -28,12 +30,12 @@ import {
|
||||||
SbState,
|
SbState,
|
||||||
VrfAccountData,
|
VrfAccountData,
|
||||||
} from "./generated/index.js";
|
} from "./generated/index.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionOptions,
|
SendTransactionOptions,
|
||||||
SwitchboardProgram,
|
SwitchboardProgram,
|
||||||
} from "./SwitchboardProgram.js";
|
} from "./SwitchboardProgram.js";
|
||||||
import { TransactionObject } from "./TransactionObject.js";
|
import { TransactionObject } from "./TransactionObject.js";
|
||||||
import {
|
import type {
|
||||||
AggregatorDefinition,
|
AggregatorDefinition,
|
||||||
BufferRelayerDefinition,
|
BufferRelayerDefinition,
|
||||||
CrankDefinition,
|
CrankDefinition,
|
||||||
|
@ -53,12 +55,8 @@ import {
|
||||||
} from "./types.js";
|
} from "./types.js";
|
||||||
|
|
||||||
import * as anchor from "@coral-xyz/anchor";
|
import * as anchor from "@coral-xyz/anchor";
|
||||||
import {
|
import type { AccountInfo, TransactionSignature } from "@solana/web3.js";
|
||||||
AccountInfo,
|
import { Keypair, PublicKey } from "@solana/web3.js";
|
||||||
Keypair,
|
|
||||||
PublicKey,
|
|
||||||
TransactionSignature,
|
|
||||||
} from "@solana/web3.js";
|
|
||||||
import { OracleJob } from "@switchboard-xyz/common";
|
import { OracleJob } from "@switchboard-xyz/common";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
@ -331,7 +329,10 @@ export class SwitchboardNetwork implements ISwitchboardNetwork {
|
||||||
const [queueAccount, queueInit] = await QueueAccount.createInstructions(
|
const [queueAccount, queueInit] = await QueueAccount.createInstructions(
|
||||||
program,
|
program,
|
||||||
payer,
|
payer,
|
||||||
{ ...params, authority: queueAuthorityPubkey }
|
{
|
||||||
|
...params,
|
||||||
|
authority: queueAuthorityPubkey,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
txns.push(queueInit);
|
txns.push(queueInit);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
import type {
|
||||||
|
SwitchboardAccountData,
|
||||||
|
SwitchboardAccountType,
|
||||||
|
} from "./accounts/index.js";
|
||||||
import {
|
import {
|
||||||
AttestationProgramStateAccount,
|
AttestationProgramStateAccount,
|
||||||
BUFFER_DISCRIMINATOR,
|
BUFFER_DISCRIMINATOR,
|
||||||
|
@ -6,8 +10,6 @@ import {
|
||||||
JobAccount,
|
JobAccount,
|
||||||
ProgramStateAccount,
|
ProgramStateAccount,
|
||||||
QueueAccount,
|
QueueAccount,
|
||||||
SwitchboardAccountData,
|
|
||||||
SwitchboardAccountType,
|
|
||||||
} from "./accounts/index.js";
|
} from "./accounts/index.js";
|
||||||
import {
|
import {
|
||||||
AggregatorAccountData,
|
AggregatorAccountData,
|
||||||
|
@ -36,33 +38,31 @@ import {
|
||||||
} from "./const.js";
|
} from "./const.js";
|
||||||
import * as errors from "./errors.js";
|
import * as errors from "./errors.js";
|
||||||
import { NativeMint } from "./mint.js";
|
import { NativeMint } from "./mint.js";
|
||||||
import { SwitchboardEvents } from "./SwitchboardEvents.js";
|
import type { SwitchboardEvents } from "./SwitchboardEvents.js";
|
||||||
import { TransactionObject, TransactionOptions } from "./TransactionObject.js";
|
import type { TransactionOptions } from "./TransactionObject.js";
|
||||||
import { LoadedJobDefinition } from "./types.js";
|
import { TransactionObject } from "./TransactionObject.js";
|
||||||
|
import type { LoadedJobDefinition } from "./types.js";
|
||||||
|
|
||||||
|
import type { AccountNamespace, Idl, Wallet } from "@coral-xyz/anchor";
|
||||||
import {
|
import {
|
||||||
ACCOUNT_DISCRIMINATOR_SIZE,
|
ACCOUNT_DISCRIMINATOR_SIZE,
|
||||||
AccountNamespace,
|
|
||||||
AnchorProvider,
|
AnchorProvider,
|
||||||
BorshAccountsCoder,
|
BorshAccountsCoder,
|
||||||
Idl,
|
|
||||||
Program,
|
Program,
|
||||||
utils as AnchorUtils,
|
utils as AnchorUtils,
|
||||||
Wallet,
|
|
||||||
} from "@coral-xyz/anchor";
|
} from "@coral-xyz/anchor";
|
||||||
import {
|
import type {
|
||||||
AccountInfo,
|
AccountInfo,
|
||||||
Cluster,
|
Cluster,
|
||||||
ConfirmOptions,
|
ConfirmOptions,
|
||||||
Connection,
|
Connection,
|
||||||
GetProgramAccountsResponse,
|
GetProgramAccountsResponse,
|
||||||
Keypair,
|
|
||||||
PublicKey,
|
|
||||||
SendOptions,
|
SendOptions,
|
||||||
Transaction,
|
Transaction,
|
||||||
TransactionSignature,
|
TransactionSignature,
|
||||||
VersionedTransaction,
|
VersionedTransaction,
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
|
import { Keypair, PublicKey } from "@solana/web3.js";
|
||||||
import { OracleJob } from "@switchboard-xyz/common";
|
import { OracleJob } from "@switchboard-xyz/common";
|
||||||
|
|
||||||
export type SendTransactionOptions = (ConfirmOptions | SendOptions) & {
|
export type SendTransactionOptions = (ConfirmOptions | SendOptions) & {
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
import {
|
import type { AggregatorAccount, OracleAccount } from "./accounts/index.js";
|
||||||
AggregatorAccount,
|
import type {
|
||||||
type CreateQueueFeedParams,
|
CreateQueueFeedParams,
|
||||||
type CreateQueueOracleParams,
|
CreateQueueOracleParams,
|
||||||
OracleAccount,
|
|
||||||
QueueAccount,
|
|
||||||
} from "./accounts/index.js";
|
} from "./accounts/index.js";
|
||||||
import { AggregatorAccountData } from "./generated/index.js";
|
import { QueueAccount } from "./accounts/index.js";
|
||||||
import {
|
import type { AggregatorAccountData } from "./generated/index.js";
|
||||||
|
import type {
|
||||||
LoadedSwitchboardNetwork,
|
LoadedSwitchboardNetwork,
|
||||||
type NetworkInitParams,
|
NetworkInitParams,
|
||||||
SwitchboardNetwork,
|
|
||||||
} from "./SwitchboardNetwork.js";
|
} from "./SwitchboardNetwork.js";
|
||||||
|
import { SwitchboardNetwork } from "./SwitchboardNetwork.js";
|
||||||
import { SwitchboardProgram } from "./SwitchboardProgram.js";
|
import { SwitchboardProgram } from "./SwitchboardProgram.js";
|
||||||
import { createStaticFeed, loadKeypair, updateStaticFeed } from "./utils.js";
|
import { createStaticFeed, loadKeypair, updateStaticFeed } from "./utils.js";
|
||||||
|
|
||||||
import { AnchorProvider } from "@coral-xyz/anchor";
|
import type { AnchorProvider } from "@coral-xyz/anchor";
|
||||||
import { Connection, Keypair, PublicKey } from "@solana/web3.js";
|
import type { Connection, PublicKey } from "@solana/web3.js";
|
||||||
|
import { Keypair } from "@solana/web3.js";
|
||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import os from "os";
|
import os from "os";
|
||||||
|
|
|
@ -2,23 +2,25 @@ import * as attestationTypes from "./generated/attestation-program/index.js";
|
||||||
import { fromTxError } from "./generated/oracle-program/errors/index.js";
|
import { fromTxError } from "./generated/oracle-program/errors/index.js";
|
||||||
import { isBrowser } from "./browser.js";
|
import { isBrowser } from "./browser.js";
|
||||||
import * as errors from "./errors.js";
|
import * as errors from "./errors.js";
|
||||||
import {
|
import type {
|
||||||
AnchorWallet,
|
AnchorWallet,
|
||||||
DEFAULT_SEND_TRANSACTION_OPTIONS,
|
|
||||||
SendTransactionOptions,
|
SendTransactionOptions,
|
||||||
} from "./SwitchboardProgram.js";
|
} from "./SwitchboardProgram.js";
|
||||||
|
import { DEFAULT_SEND_TRANSACTION_OPTIONS } from "./SwitchboardProgram.js";
|
||||||
|
|
||||||
import { AnchorProvider } from "@coral-xyz/anchor";
|
import type { AnchorProvider } from "@coral-xyz/anchor";
|
||||||
import {
|
import type {
|
||||||
ComputeBudgetProgram,
|
|
||||||
Keypair,
|
Keypair,
|
||||||
NonceInformation,
|
NonceInformation,
|
||||||
|
TransactionInstruction,
|
||||||
|
TransactionSignature,
|
||||||
|
} from "@solana/web3.js";
|
||||||
|
import {
|
||||||
|
ComputeBudgetProgram,
|
||||||
PACKET_DATA_SIZE,
|
PACKET_DATA_SIZE,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
Transaction,
|
Transaction,
|
||||||
TransactionInstruction,
|
|
||||||
TransactionMessage,
|
TransactionMessage,
|
||||||
TransactionSignature,
|
|
||||||
VersionedTransaction,
|
VersionedTransaction,
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { sleep } from "@switchboard-xyz/common";
|
import { sleep } from "@switchboard-xyz/common";
|
||||||
|
|
|
@ -11,21 +11,21 @@ import {
|
||||||
SlidingResultAccountData,
|
SlidingResultAccountData,
|
||||||
VrfAccountData,
|
VrfAccountData,
|
||||||
} from "../generated/oracle-program/index.js";
|
} from "../generated/oracle-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
|
|
||||||
import { AggregatorAccount } from "./aggregatorAccount.js";
|
import type { AggregatorAccount } from "./aggregatorAccount.js";
|
||||||
import { AggregatorHistoryBuffer } from "./aggregatorHistoryBuffer.js";
|
import type { AggregatorHistoryBuffer } from "./aggregatorHistoryBuffer.js";
|
||||||
import { BufferRelayerAccount } from "./bufferRelayAccount.js";
|
import type { BufferRelayerAccount } from "./bufferRelayAccount.js";
|
||||||
import { CrankAccount } from "./crankAccount.js";
|
import type { CrankAccount } from "./crankAccount.js";
|
||||||
import { CrankDataBuffer } from "./crankDataBuffer.js";
|
import type { CrankDataBuffer } from "./crankDataBuffer.js";
|
||||||
import { JobAccount } from "./jobAccount.js";
|
import type { JobAccount } from "./jobAccount.js";
|
||||||
import { LeaseAccount } from "./leaseAccount.js";
|
import type { LeaseAccount } from "./leaseAccount.js";
|
||||||
import { OracleAccount } from "./oracleAccount.js";
|
import type { OracleAccount } from "./oracleAccount.js";
|
||||||
import { PermissionAccount } from "./permissionAccount.js";
|
import type { PermissionAccount } from "./permissionAccount.js";
|
||||||
import { ProgramStateAccount } from "./programStateAccount.js";
|
import type { ProgramStateAccount } from "./programStateAccount.js";
|
||||||
import { QueueAccount } from "./queueAccount.js";
|
import type { QueueAccount } from "./queueAccount.js";
|
||||||
import { QueueDataBuffer } from "./queueDataBuffer.js";
|
import type { QueueDataBuffer } from "./queueDataBuffer.js";
|
||||||
import { VrfAccount } from "./vrfAccount.js";
|
import type { VrfAccount } from "./vrfAccount.js";
|
||||||
|
|
||||||
import * as anchor from "@coral-xyz/anchor";
|
import * as anchor from "@coral-xyz/anchor";
|
||||||
|
|
||||||
|
|
|
@ -1,48 +1,46 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import {
|
import type {
|
||||||
AggregatorAccountData,
|
|
||||||
AggregatorAccountDataFields,
|
AggregatorAccountDataFields,
|
||||||
AggregatorAccountDataJSON,
|
AggregatorAccountDataJSON,
|
||||||
} from "../generated/oracle-program/accounts/AggregatorAccountData.js";
|
} from "../generated/oracle-program/accounts/AggregatorAccountData.js";
|
||||||
import {
|
import { AggregatorAccountData } from "../generated/oracle-program/accounts/AggregatorAccountData.js";
|
||||||
JobAccountData,
|
import type { JobAccountDataJSON } from "../generated/oracle-program/accounts/JobAccountData.js";
|
||||||
JobAccountDataJSON,
|
import { JobAccountData } from "../generated/oracle-program/accounts/JobAccountData.js";
|
||||||
} from "../generated/oracle-program/accounts/JobAccountData.js";
|
import type { LeaseAccountDataJSON } from "../generated/oracle-program/accounts/LeaseAccountData.js";
|
||||||
import {
|
import { LeaseAccountData } from "../generated/oracle-program/accounts/LeaseAccountData.js";
|
||||||
LeaseAccountData,
|
import type { OracleAccountData } from "../generated/oracle-program/accounts/OracleAccountData.js";
|
||||||
LeaseAccountDataJSON,
|
import type {
|
||||||
} from "../generated/oracle-program/accounts/LeaseAccountData.js";
|
|
||||||
import { OracleAccountData } from "../generated/oracle-program/accounts/OracleAccountData.js";
|
|
||||||
import {
|
|
||||||
OracleQueueAccountData,
|
OracleQueueAccountData,
|
||||||
OracleQueueAccountDataJSON,
|
OracleQueueAccountDataJSON,
|
||||||
} from "../generated/oracle-program/accounts/OracleQueueAccountData.js";
|
} from "../generated/oracle-program/accounts/OracleQueueAccountData.js";
|
||||||
import {
|
import type { PermissionAccountDataJSON } from "../generated/oracle-program/accounts/PermissionAccountData.js";
|
||||||
PermissionAccountData,
|
import { PermissionAccountData } from "../generated/oracle-program/accounts/PermissionAccountData.js";
|
||||||
PermissionAccountDataJSON,
|
|
||||||
} from "../generated/oracle-program/accounts/PermissionAccountData.js";
|
|
||||||
import * as ix from "../generated/oracle-program/instructions/index.js";
|
import * as ix from "../generated/oracle-program/instructions/index.js";
|
||||||
import {
|
import type {
|
||||||
AggregatorHistoryRow,
|
AggregatorHistoryRow,
|
||||||
AggregatorResolutionMode,
|
|
||||||
AggregatorResolutionModeKind,
|
AggregatorResolutionModeKind,
|
||||||
|
} from "../generated/oracle-program/types/index.js";
|
||||||
|
import {
|
||||||
|
AggregatorResolutionMode,
|
||||||
BorshDecimal,
|
BorshDecimal,
|
||||||
} from "../generated/oracle-program/types/index.js";
|
} from "../generated/oracle-program/types/index.js";
|
||||||
import { SwitchboardDecimal } from "../generated/oracle-program/types/SwitchboardDecimal.js";
|
import { SwitchboardDecimal } from "../generated/oracle-program/types/SwitchboardDecimal.js";
|
||||||
import { PermitOracleQueueUsage } from "../generated/oracle-program/types/SwitchboardPermission.js";
|
import { PermitOracleQueueUsage } from "../generated/oracle-program/types/SwitchboardPermission.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
TransactionPackOptions,
|
TransactionPackOptions,
|
||||||
} from "../TransactionObject.js";
|
} 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 { AggregatorHistoryBuffer } from "./aggregatorHistoryBuffer.js";
|
||||||
import { CrankAccount } from "./crankAccount.js";
|
import { CrankAccount } from "./crankAccount.js";
|
||||||
import { JobAccount } from "./jobAccount.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 { OracleAccount } from "./oracleAccount.js";
|
||||||
import { PermissionAccount } from "./permissionAccount.js";
|
import { PermissionAccount } from "./permissionAccount.js";
|
||||||
import { QueueAccount } from "./queueAccount.js";
|
import { QueueAccount } from "./queueAccount.js";
|
||||||
|
@ -50,16 +48,18 @@ import { QueueAccount } from "./queueAccount.js";
|
||||||
import * as anchor from "@coral-xyz/anchor";
|
import * as anchor from "@coral-xyz/anchor";
|
||||||
import * as spl from "@solana/spl-token";
|
import * as spl from "@solana/spl-token";
|
||||||
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
|
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
|
||||||
import {
|
import type {
|
||||||
AccountInfo,
|
AccountInfo,
|
||||||
AccountMeta,
|
AccountMeta,
|
||||||
Commitment,
|
Commitment,
|
||||||
|
TransactionInstruction,
|
||||||
|
TransactionSignature,
|
||||||
|
} from "@solana/web3.js";
|
||||||
|
import {
|
||||||
Keypair,
|
Keypair,
|
||||||
LAMPORTS_PER_SOL,
|
LAMPORTS_PER_SOL,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
SystemProgram,
|
SystemProgram,
|
||||||
TransactionInstruction,
|
|
||||||
TransactionSignature,
|
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import {
|
import {
|
||||||
Big,
|
Big,
|
||||||
|
|
|
@ -1,27 +1,22 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/oracle-program/index.js";
|
import * as types from "../generated/oracle-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} from "../TransactionObject.js";
|
||||||
|
import { TransactionObject } from "../TransactionObject.js";
|
||||||
|
|
||||||
import {
|
import type { OnAccountChangeCallback } from "./account.js";
|
||||||
Account,
|
import { Account, BUFFER_DISCRIMINATOR } from "./account.js";
|
||||||
BUFFER_DISCRIMINATOR,
|
import type { AggregatorAccount } from "./aggregatorAccount.js";
|
||||||
OnAccountChangeCallback,
|
|
||||||
} from "./account.js";
|
|
||||||
import { AggregatorAccount } from "./aggregatorAccount.js";
|
|
||||||
|
|
||||||
import {
|
import type {
|
||||||
Commitment,
|
Commitment,
|
||||||
Keypair,
|
|
||||||
PublicKey,
|
|
||||||
SystemProgram,
|
|
||||||
TransactionInstruction,
|
TransactionInstruction,
|
||||||
TransactionSignature,
|
TransactionSignature,
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
|
import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js";
|
||||||
import { Big, BN } from "@switchboard-xyz/common";
|
import { Big, BN } from "@switchboard-xyz/common";
|
||||||
|
|
||||||
export interface AggregatorHistoryInit {
|
export interface AggregatorHistoryInit {
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/attestation-program/index.js";
|
import * as types from "../generated/attestation-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} from "../TransactionObject.js";
|
||||||
|
import { TransactionObject } from "../TransactionObject.js";
|
||||||
|
|
||||||
import { Account } from "./account.js";
|
import { Account } from "./account.js";
|
||||||
|
|
||||||
import {
|
import type { Keypair, TransactionSignature } from "@solana/web3.js";
|
||||||
Keypair,
|
import { PublicKey, SystemProgram } from "@solana/web3.js";
|
||||||
PublicKey,
|
|
||||||
SystemProgram,
|
|
||||||
TransactionSignature,
|
|
||||||
} from "@solana/web3.js";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameters for initializing an {@linkcode AttestationPermissionAccount}
|
* Parameters for initializing an {@linkcode AttestationPermissionAccount}
|
||||||
|
@ -201,7 +197,7 @@ export class AttestationPermissionAccount extends Account<types.AttestationPermi
|
||||||
? params.queueAuthority.publicKey
|
? params.queueAuthority.publicKey
|
||||||
: payer,
|
: payer,
|
||||||
attestationQueue: params.queue,
|
attestationQueue: params.queue,
|
||||||
enclave: params.enclave,
|
grantee: params.enclave,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/attestation-program/index.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 { TransactionObject } from "../TransactionObject.js";
|
||||||
|
|
||||||
import { Account } from "./account.js";
|
import { Account } from "./account.js";
|
||||||
|
|
||||||
|
import type { TransactionSignature } from "@solana/web3.js";
|
||||||
import {
|
import {
|
||||||
AccountInfo,
|
AccountInfo,
|
||||||
LAMPORTS_PER_SOL,
|
LAMPORTS_PER_SOL,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
SystemProgram,
|
SystemProgram,
|
||||||
TransactionSignature,
|
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,36 +1,30 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/attestation-program/index.js";
|
import * as types from "../generated/attestation-program/index.js";
|
||||||
import {
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
SB_ATTESTATION_PID,
|
import { SB_ATTESTATION_PID } from "../SwitchboardProgram.js";
|
||||||
SwitchboardProgram,
|
import type {
|
||||||
} from "../SwitchboardProgram.js";
|
|
||||||
import {
|
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} 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 { parseMrEnclave, parseRawBuffer } from "../utils.js";
|
||||||
|
|
||||||
import { Account } from "./account.js";
|
import { Account } from "./account.js";
|
||||||
import {
|
import type { AttestationPermissionSetParams } from "./attestationPermissionAccount.js";
|
||||||
AttestationPermissionAccount,
|
import { AttestationPermissionAccount } from "./attestationPermissionAccount.js";
|
||||||
AttestationPermissionSetParams,
|
import type { FunctionAccountInitParams } from "./functionAccount.js";
|
||||||
} from "./attestationPermissionAccount.js";
|
import { FunctionAccount } from "./functionAccount.js";
|
||||||
import { EnclaveAccount, EnclaveAccountInitParams } from "./enclaveAccount.js";
|
import type { SwitchboardWallet } from "./switchboardWallet.js";
|
||||||
import {
|
import type { VerifierAccountInitParams } from "./verifierAccount.js";
|
||||||
FunctionAccount,
|
import { VerifierAccount } from "./verifierAccount.js";
|
||||||
FunctionAccountInitParams,
|
|
||||||
} from "./functionAccount.js";
|
|
||||||
import { SwitchboardWallet } from "./switchboardWallet.js";
|
|
||||||
|
|
||||||
import {
|
import type {
|
||||||
Keypair,
|
|
||||||
PublicKey,
|
PublicKey,
|
||||||
SystemProgram,
|
|
||||||
TransactionInstruction,
|
TransactionInstruction,
|
||||||
TransactionSignature,
|
TransactionSignature,
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
|
import { Keypair, SystemProgram } from "@solana/web3.js";
|
||||||
/**
|
/**
|
||||||
* Parameters for initializing an {@linkcode QueueAccount}
|
* Parameters for initializing an {@linkcode QueueAccount}
|
||||||
*/
|
*/
|
||||||
|
@ -94,7 +88,7 @@ export interface AttestationQueueRemoveMrEnclaveParams {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CreateQueueQuoteParams = Omit<
|
export type CreateQueueQuoteParams = Omit<
|
||||||
EnclaveAccountInitParams,
|
VerifierAccountInitParams,
|
||||||
"queueAccount"
|
"queueAccount"
|
||||||
> &
|
> &
|
||||||
Partial<AttestationPermissionSetParams> & {
|
Partial<AttestationPermissionSetParams> & {
|
||||||
|
@ -208,11 +202,11 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
return [account, await program.signAndSend(txnObject, options)];
|
return [account, await program.signAndSend(txnObject, options)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createQuoteInstruction(
|
public async createVerifierInstruction(
|
||||||
payer: PublicKey,
|
payer: PublicKey,
|
||||||
params: CreateQueueQuoteParams,
|
params: CreateQueueQuoteParams,
|
||||||
options?: TransactionObjectOptions
|
options?: TransactionObjectOptions
|
||||||
): Promise<[EnclaveAccount, TransactionObject]> {
|
): Promise<[VerifierAccount, TransactionObject]> {
|
||||||
this.program.verifyAttestation();
|
this.program.verifyAttestation();
|
||||||
|
|
||||||
const authority = params.authority ?? payer;
|
const authority = params.authority ?? payer;
|
||||||
|
@ -220,15 +214,16 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
const queueAuthority =
|
const queueAuthority =
|
||||||
params.queueAuthorityPubkey ?? (await this.loadData()).authority;
|
params.queueAuthorityPubkey ?? (await this.loadData()).authority;
|
||||||
|
|
||||||
const [enclaveAccount, quoteInit] = await EnclaveAccount.createInstruction(
|
const [verifierAccount, quoteInit] =
|
||||||
this.program,
|
await VerifierAccount.createInstruction(
|
||||||
payer,
|
this.program,
|
||||||
{ ...params, queueAccount: this, authority },
|
payer,
|
||||||
options
|
{ ...params, queueAccount: this, authority },
|
||||||
);
|
options
|
||||||
|
);
|
||||||
|
|
||||||
if (!params.createPermissions && !params.enable) {
|
if (!params.createPermissions && !params.enable) {
|
||||||
return [enclaveAccount, quoteInit];
|
return [verifierAccount, quoteInit];
|
||||||
}
|
}
|
||||||
|
|
||||||
const [permissionAccount, permissionInit] =
|
const [permissionAccount, permissionInit] =
|
||||||
|
@ -237,7 +232,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
payer,
|
payer,
|
||||||
{
|
{
|
||||||
granter: this.publicKey,
|
granter: this.publicKey,
|
||||||
grantee: enclaveAccount.publicKey,
|
grantee: verifierAccount.publicKey,
|
||||||
authority: queueAuthority,
|
authority: queueAuthority,
|
||||||
},
|
},
|
||||||
options
|
options
|
||||||
|
@ -249,19 +244,19 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
permission:
|
permission:
|
||||||
new types.SwitchboardAttestationPermission.PermitNodeheartbeat(),
|
new types.SwitchboardAttestationPermission.PermitNodeheartbeat(),
|
||||||
queue: this.publicKey,
|
queue: this.publicKey,
|
||||||
enclave: enclaveAccount.publicKey,
|
enclave: verifierAccount.publicKey,
|
||||||
});
|
});
|
||||||
permissionInit.combine(permissionSet);
|
permissionInit.combine(permissionSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [enclaveAccount, quoteInit.combine(permissionInit)];
|
return [verifierAccount, quoteInit.combine(permissionInit)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public async createQuote(
|
public async createVerifier(
|
||||||
params: CreateQueueQuoteParams,
|
params: CreateQueueQuoteParams,
|
||||||
options?: SendTransactionObjectOptions
|
options?: SendTransactionObjectOptions
|
||||||
): Promise<[EnclaveAccount, TransactionSignature]> {
|
): Promise<[VerifierAccount, TransactionSignature]> {
|
||||||
const [account, txnObject] = await this.createQuoteInstruction(
|
const [account, txnObject] = await this.createVerifierInstruction(
|
||||||
this.program.walletPubkey,
|
this.program.walletPubkey,
|
||||||
params,
|
params,
|
||||||
options
|
options
|
||||||
|
@ -304,7 +299,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
permission: SB_ATTESTATION_PID, // optional
|
permission: SB_ATTESTATION_PID, // optional
|
||||||
authority: queueAuthority,
|
authority: queueAuthority,
|
||||||
attestationQueue: this.publicKey,
|
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 authority: Keypair = params?.authority ?? program.wallet.payer;
|
||||||
|
|
||||||
const attestationQueueKeypair = params?.keypair ?? Keypair.generate();
|
const attestationQueueKeypair = params?.keypair ?? Keypair.generate();
|
||||||
const verifierQuoteKeypair1 = Keypair.generate();
|
const verifierKeypair1 = Keypair.generate();
|
||||||
const verifierQuoteSigner1 = params?.securedSigner ?? Keypair.generate();
|
const verifierSigner1 = params?.enclaveSigner ?? Keypair.generate();
|
||||||
|
|
||||||
const ixns: Array<TransactionInstruction> = [];
|
const ixns: Array<TransactionInstruction> = [];
|
||||||
const signers: Array<Keypair> = [
|
const signers: Array<Keypair> = [
|
||||||
authority,
|
authority,
|
||||||
attestationQueueKeypair,
|
attestationQueueKeypair,
|
||||||
verifierQuoteKeypair1,
|
verifierKeypair1,
|
||||||
verifierQuoteSigner1,
|
verifierSigner1,
|
||||||
];
|
];
|
||||||
|
|
||||||
// create attestation queue
|
// create attestation queue
|
||||||
|
@ -459,7 +454,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
mrEnclave: Array.from(
|
mrEnclave: Array.from(
|
||||||
parseMrEnclave(params?.quoteVerifierMrEnclave ?? "")
|
parseMrEnclave(params?.verifierrEnclave ?? "")
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -472,7 +467,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
|
|
||||||
// create quote #1
|
// create quote #1
|
||||||
ixns.push(
|
ixns.push(
|
||||||
types.quoteInit(
|
types.verifierInit(
|
||||||
program,
|
program,
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
|
@ -480,7 +475,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
quote: verifierQuoteKeypair1.publicKey,
|
verifier: verifierKeypair1.publicKey,
|
||||||
attestationQueue: attestationQueueKeypair.publicKey,
|
attestationQueue: attestationQueueKeypair.publicKey,
|
||||||
queueAuthority: authority.publicKey,
|
queueAuthority: authority.publicKey,
|
||||||
authority: authority.publicKey,
|
authority: authority.publicKey,
|
||||||
|
@ -494,7 +489,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
program,
|
program,
|
||||||
authority.publicKey,
|
authority.publicKey,
|
||||||
attestationQueueKeypair.publicKey,
|
attestationQueueKeypair.publicKey,
|
||||||
verifierQuoteKeypair1.publicKey
|
verifierKeypair1.publicKey
|
||||||
);
|
);
|
||||||
ixns.push(
|
ixns.push(
|
||||||
types.attestationPermissionInit(
|
types.attestationPermissionInit(
|
||||||
|
@ -503,7 +498,7 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
{
|
{
|
||||||
permission: verifierQuotePermissions1.publicKey,
|
permission: verifierQuotePermissions1.publicKey,
|
||||||
attestationQueue: attestationQueueKeypair.publicKey,
|
attestationQueue: attestationQueueKeypair.publicKey,
|
||||||
node: verifierQuoteKeypair1.publicKey,
|
node: verifierKeypair1.publicKey,
|
||||||
authority: authority.publicKey,
|
authority: authority.publicKey,
|
||||||
payer: authority.publicKey,
|
payer: authority.publicKey,
|
||||||
systemProgram: SystemProgram.programId,
|
systemProgram: SystemProgram.programId,
|
||||||
|
@ -523,14 +518,14 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
permission: verifierQuotePermissions1.publicKey,
|
permission: verifierQuotePermissions1.publicKey,
|
||||||
authority: authority.publicKey,
|
authority: authority.publicKey,
|
||||||
attestationQueue: attestationQueueKeypair.publicKey,
|
attestationQueue: attestationQueueKeypair.publicKey,
|
||||||
enclave: verifierQuoteKeypair1.publicKey,
|
grantee: verifierKeypair1.publicKey,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// set quote #1 securedSigner
|
// set quote #1 securedSigner
|
||||||
ixns.push(
|
ixns.push(
|
||||||
types.quoteRotate(
|
types.verifierQuoteRotate(
|
||||||
program,
|
program,
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
|
@ -540,9 +535,9 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
quote: verifierQuoteKeypair1.publicKey,
|
verifier: verifierKeypair1.publicKey,
|
||||||
authority: authority.publicKey,
|
authority: authority.publicKey,
|
||||||
enclaveSigner: verifierQuoteSigner1.publicKey,
|
enclaveSigner: verifierSigner1.publicKey,
|
||||||
attestationQueue: attestationQueueKeypair.publicKey,
|
attestationQueue: attestationQueueKeypair.publicKey,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -550,15 +545,15 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
|
|
||||||
// quote #1 heartbeat
|
// quote #1 heartbeat
|
||||||
ixns.push(
|
ixns.push(
|
||||||
types.quoteHeartbeat(
|
types.verifierHeartbeat(
|
||||||
program,
|
program,
|
||||||
{ params: {} },
|
{ params: {} },
|
||||||
{
|
{
|
||||||
quote: verifierQuoteKeypair1.publicKey,
|
verifier: verifierKeypair1.publicKey,
|
||||||
enclaveSigner: verifierQuoteSigner1.publicKey,
|
verifierSigner: verifierSigner1.publicKey,
|
||||||
attestationQueue: attestationQueueKeypair.publicKey,
|
attestationQueue: attestationQueueKeypair.publicKey,
|
||||||
queueAuthority: authority.publicKey,
|
queueAuthority: authority.publicKey,
|
||||||
gcNode: verifierQuoteKeypair1.publicKey,
|
gcNode: verifierKeypair1.publicKey,
|
||||||
permission: verifierQuotePermissions1.publicKey,
|
permission: verifierQuotePermissions1.publicKey,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -579,31 +574,40 @@ export class AttestationQueueAccount extends Account<types.AttestationQueueAccou
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
attestationQueueAccount,
|
program: program,
|
||||||
signatures,
|
attestationQueue: {
|
||||||
verifier: {
|
account: attestationQueueAccount,
|
||||||
quoteAccount: new EnclaveAccount(
|
publicKey: attestationQueueAccount.publicKey,
|
||||||
program,
|
authority: authority.publicKey,
|
||||||
verifierQuoteKeypair1.publicKey
|
|
||||||
),
|
|
||||||
permissionAccount: verifierQuotePermissions1,
|
|
||||||
signer: verifierQuoteSigner1,
|
|
||||||
},
|
},
|
||||||
|
verifier: {
|
||||||
|
account: new VerifierAccount(program, verifierKeypair1.publicKey),
|
||||||
|
publicKey: verifierKeypair1.publicKey,
|
||||||
|
permissionAccount: verifierQuotePermissions1,
|
||||||
|
signer: verifierSigner1,
|
||||||
|
},
|
||||||
|
signatures,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CreateBootstrappedQueueParams =
|
export type CreateBootstrappedQueueParams =
|
||||||
AttestationQueueAccountInitParams & {
|
AttestationQueueAccountInitParams & {
|
||||||
quoteVerifierMrEnclave: RawBuffer;
|
verifierrEnclave: RawBuffer;
|
||||||
registryKey: RawBuffer;
|
registryKey?: RawBuffer;
|
||||||
securedSigner?: Keypair;
|
enclaveSigner?: Keypair;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BootstrappedAttestationQueue = {
|
export type BootstrappedAttestationQueue = {
|
||||||
attestationQueueAccount: AttestationQueueAccount;
|
program: SwitchboardProgram;
|
||||||
|
attestationQueue: {
|
||||||
|
account: AttestationQueueAccount;
|
||||||
|
publicKey: PublicKey;
|
||||||
|
authority: PublicKey;
|
||||||
|
};
|
||||||
verifier: {
|
verifier: {
|
||||||
quoteAccount: EnclaveAccount;
|
account: VerifierAccount;
|
||||||
|
publicKey: PublicKey;
|
||||||
permissionAccount: AttestationPermissionAccount;
|
permissionAccount: AttestationPermissionAccount;
|
||||||
signer: Keypair;
|
signer: Keypair;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import { bufferRelayerSaveResult } from "../generated/oracle-program/index.js";
|
import { bufferRelayerSaveResult } from "../generated/oracle-program/index.js";
|
||||||
import * as types from "../generated/oracle-program/index.js";
|
import * as types from "../generated/oracle-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type { TransactionObjectOptions } from "../TransactionObject.js";
|
||||||
TransactionObject,
|
import { TransactionObject } from "../TransactionObject.js";
|
||||||
TransactionObjectOptions,
|
|
||||||
} from "../TransactionObject.js";
|
|
||||||
|
|
||||||
import { Account, OnAccountChangeCallback } from "./account.js";
|
import type { OnAccountChangeCallback } from "./account.js";
|
||||||
import { JobAccount } from "./jobAccount.js";
|
import { Account } from "./account.js";
|
||||||
|
import type { JobAccount } from "./jobAccount.js";
|
||||||
import { OracleAccount } from "./oracleAccount.js";
|
import { OracleAccount } from "./oracleAccount.js";
|
||||||
import { PermissionAccount } from "./permissionAccount.js";
|
import { PermissionAccount } from "./permissionAccount.js";
|
||||||
import { QueueAccount } from "./queueAccount.js";
|
import { QueueAccount } from "./queueAccount.js";
|
||||||
|
@ -20,14 +19,16 @@ import {
|
||||||
getAccount,
|
getAccount,
|
||||||
TOKEN_PROGRAM_ID,
|
TOKEN_PROGRAM_ID,
|
||||||
} from "@solana/spl-token";
|
} from "@solana/spl-token";
|
||||||
import {
|
import type {
|
||||||
Commitment,
|
Commitment,
|
||||||
|
TransactionInstruction,
|
||||||
|
TransactionSignature,
|
||||||
|
} from "@solana/web3.js";
|
||||||
|
import {
|
||||||
Keypair,
|
Keypair,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
SystemProgram,
|
SystemProgram,
|
||||||
SYSVAR_RENT_PUBKEY,
|
SYSVAR_RENT_PUBKEY,
|
||||||
TransactionInstruction,
|
|
||||||
TransactionSignature,
|
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { BN, promiseWithTimeout } from "@switchboard-xyz/common";
|
import { BN, promiseWithTimeout } from "@switchboard-xyz/common";
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,27 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/oracle-program/index.js";
|
import * as types from "../generated/oracle-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} from "../TransactionObject.js";
|
||||||
|
import { TransactionObject } from "../TransactionObject.js";
|
||||||
|
|
||||||
import { Account, OnAccountChangeCallback } from "./account.js";
|
import type { OnAccountChangeCallback } from "./account.js";
|
||||||
import {
|
import { Account } from "./account.js";
|
||||||
AggregatorAccount,
|
import type { AggregatorPdaAccounts } from "./aggregatorAccount.js";
|
||||||
AggregatorPdaAccounts,
|
import { AggregatorAccount } from "./aggregatorAccount.js";
|
||||||
} from "./aggregatorAccount.js";
|
|
||||||
import { CrankDataBuffer } from "./crankDataBuffer.js";
|
import { CrankDataBuffer } from "./crankDataBuffer.js";
|
||||||
import { QueueAccount } from "./queueAccount.js";
|
import { QueueAccount } from "./queueAccount.js";
|
||||||
|
|
||||||
import * as anchor from "@coral-xyz/anchor";
|
import * as anchor from "@coral-xyz/anchor";
|
||||||
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
|
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
|
||||||
import {
|
import type {
|
||||||
AccountMeta,
|
AccountMeta,
|
||||||
Commitment,
|
Commitment,
|
||||||
Keypair,
|
|
||||||
PublicKey,
|
|
||||||
SystemProgram,
|
|
||||||
TransactionSignature,
|
TransactionSignature,
|
||||||
} from "@solana/web3.js";
|
} 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.
|
* 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.
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/oracle-program/index.js";
|
import * as types from "../generated/oracle-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
|
|
||||||
import {
|
import type { OnAccountChangeCallback } from "./account.js";
|
||||||
Account,
|
import { Account, BUFFER_DISCRIMINATOR } from "./account.js";
|
||||||
BUFFER_DISCRIMINATOR,
|
|
||||||
OnAccountChangeCallback,
|
|
||||||
} 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";
|
import { BN } from "@switchboard-xyz/common";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,32 +1,32 @@
|
||||||
import { Account } from "../accounts/account.js";
|
import { Account } from "../accounts/account.js";
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/attestation-program/index.js";
|
import * as types from "../generated/attestation-program/index.js";
|
||||||
import {
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
SB_ATTESTATION_PID,
|
import { SB_ATTESTATION_PID, SB_V2_PID } from "../SwitchboardProgram.js";
|
||||||
SB_V2_PID,
|
import type {
|
||||||
SwitchboardProgram,
|
|
||||||
} from "../SwitchboardProgram.js";
|
|
||||||
import {
|
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} from "../TransactionObject.js";
|
||||||
import { RawBuffer } from "../types.js";
|
import { TransactionObject } from "../TransactionObject.js";
|
||||||
|
import type { RawBuffer } from "../types.js";
|
||||||
import {
|
import {
|
||||||
|
handleOptionalPubkeys,
|
||||||
numToBN,
|
numToBN,
|
||||||
parseCronSchedule,
|
parseCronSchedule,
|
||||||
parseMrEnclave,
|
parseMrEnclave,
|
||||||
parseRawBuffer,
|
parseRawBuffer,
|
||||||
} from "../utils.js";
|
} from "../utils.js";
|
||||||
|
|
||||||
|
import type {
|
||||||
|
FunctionRequestAccountInitParams,
|
||||||
|
SwitchboardWalletFundParams,
|
||||||
|
VerifierAccount,
|
||||||
|
} from "./index.js";
|
||||||
import {
|
import {
|
||||||
AttestationPermissionAccount,
|
AttestationPermissionAccount,
|
||||||
AttestationQueueAccount,
|
AttestationQueueAccount,
|
||||||
EnclaveAccount,
|
|
||||||
FunctionRequestAccount,
|
FunctionRequestAccount,
|
||||||
FunctionRequestAccountInitParams,
|
|
||||||
SwitchboardWallet,
|
SwitchboardWallet,
|
||||||
SwitchboardWalletFundParams,
|
|
||||||
} from "./index.js";
|
} from "./index.js";
|
||||||
|
|
||||||
import * as anchor from "@coral-xyz/anchor";
|
import * as anchor from "@coral-xyz/anchor";
|
||||||
|
@ -35,20 +35,24 @@ import {
|
||||||
ASSOCIATED_TOKEN_PROGRAM_ID,
|
ASSOCIATED_TOKEN_PROGRAM_ID,
|
||||||
TOKEN_PROGRAM_ID,
|
TOKEN_PROGRAM_ID,
|
||||||
} from "@solana/spl-token";
|
} from "@solana/spl-token";
|
||||||
import {
|
import type {
|
||||||
AccountInfo,
|
AccountInfo,
|
||||||
AddressLookupTableAccount,
|
AddressLookupTableAccount,
|
||||||
ComputeBudgetProgram,
|
|
||||||
Keypair,
|
Keypair,
|
||||||
PublicKey,
|
|
||||||
SendOptions,
|
SendOptions,
|
||||||
SystemProgram,
|
|
||||||
TransactionInstruction,
|
TransactionInstruction,
|
||||||
TransactionSignature,
|
TransactionSignature,
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
|
import {
|
||||||
|
ComputeBudgetProgram,
|
||||||
|
PublicKey,
|
||||||
|
SystemProgram,
|
||||||
|
} from "@solana/web3.js";
|
||||||
import { BN, toUtf8 } from "@switchboard-xyz/common";
|
import { BN, toUtf8 } from "@switchboard-xyz/common";
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
|
|
||||||
|
export type ContainerRegistryType = "dockerhub" | "ipfs";
|
||||||
|
|
||||||
export type FunctionAccountInitSeeds = {
|
export type FunctionAccountInitSeeds = {
|
||||||
recentSlot?: number;
|
recentSlot?: number;
|
||||||
creatorSeed?: RawBuffer; // defaults to payer pubkey bytes
|
creatorSeed?: RawBuffer; // defaults to payer pubkey bytes
|
||||||
|
@ -61,9 +65,9 @@ export type FunctionAccountInitParams = FunctionAccountInitSeeds & {
|
||||||
name?: string;
|
name?: string;
|
||||||
metadata?: string;
|
metadata?: string;
|
||||||
container: string;
|
container: string;
|
||||||
version: string;
|
version?: string;
|
||||||
containerRegistry?: string;
|
containerRegistry?: ContainerRegistryType;
|
||||||
schedule: string;
|
schedule?: string;
|
||||||
|
|
||||||
mrEnclave: Buffer | Uint8Array | number[];
|
mrEnclave: Buffer | Uint8Array | number[];
|
||||||
attestationQueue: AttestationQueueAccount;
|
attestationQueue: AttestationQueueAccount;
|
||||||
|
@ -88,7 +92,7 @@ export interface FunctionSetConfigParams {
|
||||||
name?: string;
|
name?: string;
|
||||||
metadata?: string;
|
metadata?: string;
|
||||||
container?: string;
|
container?: string;
|
||||||
containerRegistry?: string;
|
containerRegistry?: ContainerRegistryType;
|
||||||
version?: string;
|
version?: string;
|
||||||
schedule?: string;
|
schedule?: string;
|
||||||
mrEnclaves?: Array<RawBuffer>;
|
mrEnclaves?: Array<RawBuffer>;
|
||||||
|
@ -100,6 +104,24 @@ export interface FunctionSetConfigParams {
|
||||||
authority?: Keypair;
|
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.
|
* Parameters for an {@linkcode types.functionVerify} instruction.
|
||||||
*/
|
*/
|
||||||
|
@ -111,8 +133,6 @@ export interface FunctionVerifySyncParams {
|
||||||
mrEnclave: Uint8Array;
|
mrEnclave: Uint8Array;
|
||||||
|
|
||||||
escrowWallet: PublicKey;
|
escrowWallet: PublicKey;
|
||||||
|
|
||||||
functionAuthority: PublicKey;
|
|
||||||
functionEnclaveSigner: PublicKey;
|
functionEnclaveSigner: PublicKey;
|
||||||
|
|
||||||
attestationQueue: PublicKey;
|
attestationQueue: PublicKey;
|
||||||
|
@ -133,7 +153,7 @@ export interface FunctionVerifyParams {
|
||||||
nextAllowedTimestamp: anchor.BN;
|
nextAllowedTimestamp: anchor.BN;
|
||||||
isFailure: boolean;
|
isFailure: boolean;
|
||||||
mrEnclave: Uint8Array;
|
mrEnclave: Uint8Array;
|
||||||
verifier: EnclaveAccount;
|
verifier: VerifierAccount;
|
||||||
verifierEnclaveSigner: PublicKey;
|
verifierEnclaveSigner: PublicKey;
|
||||||
functionEnclaveSigner: PublicKey;
|
functionEnclaveSigner: PublicKey;
|
||||||
receiver: PublicKey;
|
receiver: PublicKey;
|
||||||
|
@ -170,14 +190,14 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
/**
|
/**
|
||||||
* Returns the functions's name buffer in a stringified format.
|
* Returns the functions's name buffer in a stringified format.
|
||||||
*/
|
*/
|
||||||
public static getName = (functionData: types.FunctionAccountData) =>
|
public static getName = (functionState: types.FunctionAccountData) =>
|
||||||
toUtf8(functionData.name);
|
toUtf8(functionState.name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the functions's metadata buffer in a stringified format.
|
* Returns the functions's metadata buffer in a stringified format.
|
||||||
*/
|
*/
|
||||||
public static getMetadata = (functionData: types.FunctionAccountData) =>
|
public static getMetadata = (functionState: types.FunctionAccountData) =>
|
||||||
toUtf8(functionData.metadata);
|
toUtf8(functionState.metadata);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load an existing {@linkcode FunctionAccount} with its current on-chain state
|
* 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 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;
|
const attestationQueueAccount = params.attestationQueue;
|
||||||
|
|
||||||
|
@ -360,8 +382,6 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
escrowWalletAuthority = authorityPubkey;
|
escrowWalletAuthority = authorityPubkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
const enclaveAccount = functionAccount.getEnclaveAccount();
|
|
||||||
|
|
||||||
const instruction = types.functionInit(
|
const instruction = types.functionInit(
|
||||||
program,
|
program,
|
||||||
{
|
{
|
||||||
|
@ -370,10 +390,12 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
metadata: new Uint8Array(Buffer.from(params.metadata ?? "", "utf8")),
|
metadata: new Uint8Array(Buffer.from(params.metadata ?? "", "utf8")),
|
||||||
container: new Uint8Array(Buffer.from(params.container, "utf8")),
|
container: new Uint8Array(Buffer.from(params.container, "utf8")),
|
||||||
containerRegistry: new Uint8Array(
|
containerRegistry: new Uint8Array(
|
||||||
Buffer.from(params.containerRegistry ?? "", "utf8")
|
Buffer.from(params.containerRegistry ?? "dockerhub", "utf8")
|
||||||
),
|
),
|
||||||
version: new Uint8Array(Buffer.from(params.version, "utf8")),
|
version: new Uint8Array(
|
||||||
schedule: new Uint8Array(Buffer.from(cronSchedule, "utf8")),
|
Buffer.from(params.version ?? "latest", "utf8")
|
||||||
|
),
|
||||||
|
schedule: new Uint8Array(cronSchedule),
|
||||||
mrEnclave: Array.from(parseMrEnclave(params.mrEnclave)),
|
mrEnclave: Array.from(parseMrEnclave(params.mrEnclave)),
|
||||||
recentSlot: recentSlot,
|
recentSlot: recentSlot,
|
||||||
requestsDisabled: params.requestsDisabled ?? false,
|
requestsDisabled: params.requestsDisabled ?? false,
|
||||||
|
@ -391,13 +413,11 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
function: functionAccount.publicKey,
|
function: functionAccount.publicKey,
|
||||||
addressLookupTable: addressLookupTable,
|
addressLookupTable: addressLookupTable,
|
||||||
authority: authorityPubkey,
|
authority: authorityPubkey,
|
||||||
quote: enclaveAccount.publicKey,
|
|
||||||
attestationQueue: attestationQueueAccount.publicKey,
|
attestationQueue: attestationQueueAccount.publicKey,
|
||||||
payer,
|
payer,
|
||||||
wallet: escrowWallet.publicKey,
|
wallet: escrowWallet.publicKey,
|
||||||
walletAuthority: escrowWalletAuthority,
|
walletAuthority: escrowWalletAuthority,
|
||||||
tokenWallet: escrowWallet.tokenWallet,
|
tokenWallet: escrowWallet.tokenWallet,
|
||||||
state: program.attestationProgramState.publicKey,
|
|
||||||
mint: program.mint.address,
|
mint: program.mint.address,
|
||||||
tokenProgram: TOKEN_PROGRAM_ID,
|
tokenProgram: TOKEN_PROGRAM_ID,
|
||||||
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
|
||||||
|
@ -442,10 +462,6 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
return [account, txSignature];
|
return [account, txSignature];
|
||||||
}
|
}
|
||||||
|
|
||||||
public getEnclaveAccount(): EnclaveAccount {
|
|
||||||
return EnclaveAccount.fromSeed(this.program, this.publicKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async createRequestInstruction(
|
public async createRequestInstruction(
|
||||||
payer: PublicKey,
|
payer: PublicKey,
|
||||||
params: CreateFunctionRequestParams,
|
params: CreateFunctionRequestParams,
|
||||||
|
@ -484,18 +500,18 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
params: FunctionSetConfigParams,
|
params: FunctionSetConfigParams,
|
||||||
options?: TransactionObjectOptions
|
options?: TransactionObjectOptions
|
||||||
): Promise<TransactionObject> {
|
): Promise<TransactionObject> {
|
||||||
const functionData = await this.loadData();
|
const functionState = await this.loadData();
|
||||||
|
|
||||||
if (params.authority) {
|
if (params.authority) {
|
||||||
if (!params.authority.publicKey.equals(functionData.authority)) {
|
if (!params.authority.publicKey.equals(functionState.authority)) {
|
||||||
throw new errors.IncorrectAuthority(
|
throw new errors.IncorrectAuthority(
|
||||||
functionData.authority,
|
functionState.authority,
|
||||||
params.authority.publicKey
|
params.authority.publicKey
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!payer.equals(functionData.authority)) {
|
if (!payer.equals(functionState.authority)) {
|
||||||
throw new errors.IncorrectAuthority(functionData.authority, payer);
|
throw new errors.IncorrectAuthority(functionState.authority, payer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,17 +537,17 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
requestsDisabled: params.requestsDisabled ?? null,
|
requestsDisabled: params.requestsDisabled ?? null,
|
||||||
requestsRequireAuthorization:
|
requestsRequireAuthorization:
|
||||||
params.requestsRequireAuthorization ?? null,
|
params.requestsRequireAuthorization ?? null,
|
||||||
requestsDefaultSlotsUntilExpiration:
|
requestsDefaultSlotsUntilExpiration: Number.isFinite(
|
||||||
params.requestsDefaultSlotsUntilExpiration
|
params.requestsDefaultSlotsUntilExpiration
|
||||||
? new BN(params.requestsDefaultSlotsUntilExpiration)
|
)
|
||||||
: null,
|
? new BN(params.requestsDefaultSlotsUntilExpiration)
|
||||||
|
: null,
|
||||||
requestsFee: params.requestsFee ? new BN(params.requestsFee) : null,
|
requestsFee: params.requestsFee ? new BN(params.requestsFee) : null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
function: this.publicKey,
|
function: this.publicKey,
|
||||||
quote: this.getEnclaveAccount().publicKey,
|
authority: functionState.authority,
|
||||||
authority: functionData.authority,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -554,6 +570,112 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
).then((txn) => this.program.signAndSend(txn, options));
|
).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(
|
public async resetEscrowInstruction(
|
||||||
payer: PublicKey,
|
payer: PublicKey,
|
||||||
authority?: Keypair,
|
authority?: Keypair,
|
||||||
|
@ -582,7 +704,6 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
defaultWallet: defaultWallet.publicKey,
|
defaultWallet: defaultWallet.publicKey,
|
||||||
tokenWallet: defaultWallet.tokenWallet,
|
tokenWallet: defaultWallet.tokenWallet,
|
||||||
payer: payer,
|
payer: payer,
|
||||||
state: this.program.attestationProgramState.publicKey,
|
|
||||||
tokenProgram: anchor.utils.token.TOKEN_PROGRAM_ID,
|
tokenProgram: anchor.utils.token.TOKEN_PROGRAM_ID,
|
||||||
associatedTokenProgram: anchor.utils.token.ASSOCIATED_PROGRAM_ID,
|
associatedTokenProgram: anchor.utils.token.ASSOCIATED_PROGRAM_ID,
|
||||||
systemProgram: anchor.web3.SystemProgram.programId,
|
systemProgram: anchor.web3.SystemProgram.programId,
|
||||||
|
@ -693,7 +814,6 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
public verifyInstructionSync(
|
public verifyInstructionSync(
|
||||||
params: FunctionVerifySyncParams
|
params: FunctionVerifySyncParams
|
||||||
): TransactionInstruction {
|
): TransactionInstruction {
|
||||||
const fnEnclaveAccount = this.getEnclaveAccount();
|
|
||||||
const wallet = new SwitchboardWallet(this.program, params.escrowWallet);
|
const wallet = new SwitchboardWallet(this.program, params.escrowWallet);
|
||||||
const escrowTokenWallet = wallet.tokenWallet;
|
const escrowTokenWallet = wallet.tokenWallet;
|
||||||
|
|
||||||
|
@ -710,12 +830,10 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
{
|
{
|
||||||
// fn accounts
|
// fn accounts
|
||||||
function: this.publicKey,
|
function: this.publicKey,
|
||||||
authority: params.functionAuthority,
|
|
||||||
functionEnclaveSigner: params.functionEnclaveSigner,
|
functionEnclaveSigner: params.functionEnclaveSigner,
|
||||||
fnQuote: fnEnclaveAccount.publicKey,
|
|
||||||
// verifier accounts
|
// verifier accounts
|
||||||
verifierQuote: params.quoteVerifier,
|
verifier: params.quoteVerifier,
|
||||||
verifierEnclaveSigner: params.quoteVerifierEnclaveSigner,
|
verifierSigner: params.quoteVerifierEnclaveSigner,
|
||||||
verifierPermission: AttestationPermissionAccount.fromSeed(
|
verifierPermission: AttestationPermissionAccount.fromSeed(
|
||||||
this.program,
|
this.program,
|
||||||
params.attestationQueueAuthority,
|
params.attestationQueueAuthority,
|
||||||
|
@ -727,7 +845,6 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
escrowTokenWallet: escrowTokenWallet,
|
escrowTokenWallet: escrowTokenWallet,
|
||||||
receiver: params.receiver,
|
receiver: params.receiver,
|
||||||
// others
|
// others
|
||||||
state: this.program.attestationProgramState.publicKey,
|
|
||||||
attestationQueue: params.attestationQueue,
|
attestationQueue: params.attestationQueue,
|
||||||
tokenProgram: spl.TOKEN_PROGRAM_ID,
|
tokenProgram: spl.TOKEN_PROGRAM_ID,
|
||||||
}
|
}
|
||||||
|
@ -739,7 +856,7 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
): Promise<TransactionInstruction> {
|
): Promise<TransactionInstruction> {
|
||||||
this.program.verifyAttestation();
|
this.program.verifyAttestation();
|
||||||
|
|
||||||
const functionData = params.fnState ?? (await this.loadData());
|
const functionState = params.fnState ?? (await this.loadData());
|
||||||
|
|
||||||
const wallet = await this.wallet;
|
const wallet = await this.wallet;
|
||||||
|
|
||||||
|
@ -747,7 +864,7 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
if (!attestationQueueAuthority) {
|
if (!attestationQueueAuthority) {
|
||||||
const attestationQueueAccount = new AttestationQueueAccount(
|
const attestationQueueAccount = new AttestationQueueAccount(
|
||||||
this.program,
|
this.program,
|
||||||
functionData.attestationQueue
|
functionState.attestationQueue
|
||||||
);
|
);
|
||||||
attestationQueueAuthority = (await attestationQueueAccount.loadData())
|
attestationQueueAuthority = (await attestationQueueAccount.loadData())
|
||||||
.authority;
|
.authority;
|
||||||
|
@ -762,14 +879,13 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
mrEnclave: params.mrEnclave,
|
mrEnclave: params.mrEnclave,
|
||||||
|
|
||||||
escrowWallet: wallet.publicKey,
|
escrowWallet: wallet.publicKey,
|
||||||
functionAuthority: functionData.authority,
|
|
||||||
functionEnclaveSigner: params.functionEnclaveSigner,
|
functionEnclaveSigner: params.functionEnclaveSigner,
|
||||||
|
|
||||||
attestationQueue: functionData.attestationQueue,
|
attestationQueue: functionState.attestationQueue,
|
||||||
attestationQueueAuthority: attestationQueueAuthority,
|
attestationQueueAuthority: attestationQueueAuthority,
|
||||||
|
|
||||||
quoteVerifier: params.verifier.publicKey,
|
quoteVerifier: params.verifier.publicKey,
|
||||||
quoteVerifierEnclaveSigner: quoteVerifier.enclaveSigner,
|
quoteVerifierEnclaveSigner: quoteVerifier.enclave.enclaveSigner,
|
||||||
|
|
||||||
receiver: params.receiver,
|
receiver: params.receiver,
|
||||||
});
|
});
|
||||||
|
@ -803,7 +919,7 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
isFailure: boolean;
|
isFailure: boolean;
|
||||||
mrEnclave: Uint8Array;
|
mrEnclave: Uint8Array;
|
||||||
|
|
||||||
verifier: EnclaveAccount;
|
verifier: VerifierAccount;
|
||||||
verifierEnclaveSigner: Keypair;
|
verifierEnclaveSigner: Keypair;
|
||||||
|
|
||||||
functionEnclaveSigner: Keypair;
|
functionEnclaveSigner: Keypair;
|
||||||
|
@ -836,19 +952,19 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
params?: FunctionTriggerParams,
|
params?: FunctionTriggerParams,
|
||||||
options?: TransactionObjectOptions
|
options?: TransactionObjectOptions
|
||||||
): Promise<TransactionObject> {
|
): Promise<TransactionObject> {
|
||||||
const functionData = await this.loadData();
|
const functionState = await this.loadData();
|
||||||
|
|
||||||
// verify authority is correct
|
// verify authority is correct
|
||||||
if (params && params?.authority) {
|
if (params && params?.authority) {
|
||||||
if (!params.authority.publicKey.equals(functionData.authority)) {
|
if (!params.authority.publicKey.equals(functionState.authority)) {
|
||||||
throw new errors.IncorrectAuthority(
|
throw new errors.IncorrectAuthority(
|
||||||
functionData.authority,
|
functionState.authority,
|
||||||
params.authority.publicKey
|
params.authority.publicKey
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!payer.equals(functionData.authority)) {
|
if (!payer.equals(functionState.authority)) {
|
||||||
throw new errors.IncorrectAuthority(functionData.authority, payer);
|
throw new errors.IncorrectAuthority(functionState.authority, payer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -857,15 +973,16 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
{ params: {} },
|
{ params: {} },
|
||||||
{
|
{
|
||||||
function: this.publicKey,
|
function: this.publicKey,
|
||||||
authority: functionData.authority,
|
authority: functionState.authority,
|
||||||
attestationQueue: functionData.attestationQueue,
|
attestationQueue: functionState.attestationQueue,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
return new TransactionObject(
|
return new TransactionObject(
|
||||||
payer,
|
payer,
|
||||||
[functionTrigger],
|
[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) {
|
public static decodeAddressLookup(lookupTable: AddressLookupTableAccount) {
|
||||||
const addresses = lookupTable.state.addresses;
|
const addresses = lookupTable.state.addresses;
|
||||||
if (addresses.length < 18) {
|
if (addresses.length < 16) {
|
||||||
throw new Error(`Failed to decode address lookup table`);
|
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
|
// switchboard accounts, not worth the network calls
|
||||||
const statePubkey = addresses[10]!;
|
const attestationQueuePubkey = addresses[10]!;
|
||||||
const attestationQueuePubkey = addresses[11]!;
|
const functionPubkey = addresses[11]!;
|
||||||
const functionPubkey = addresses[12]!;
|
const functionAuthorityPubkey = addresses[12]!;
|
||||||
const functionAuthorityPubkey = addresses[13]!;
|
const mintPubkey = addresses[13]!;
|
||||||
const fnQuote = addresses[14]!;
|
const walletPubkey = addresses[14]!;
|
||||||
const mintPubkey = addresses[15]!;
|
const escrowPubkey = addresses[15]!;
|
||||||
const walletPubkey = addresses[16]!;
|
|
||||||
const escrowPubkey = addresses[17]!;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
systemProgram, // 1
|
systemProgram, // 1
|
||||||
|
@ -963,14 +1078,33 @@ export class FunctionAccount extends Account<types.FunctionAccountData> {
|
||||||
sysVarSlotHistory,
|
sysVarSlotHistory,
|
||||||
switchboardProgram,
|
switchboardProgram,
|
||||||
attestationProgram, // 10
|
attestationProgram, // 10
|
||||||
statePubkey,
|
|
||||||
attestationQueuePubkey,
|
attestationQueuePubkey,
|
||||||
functionPubkey,
|
functionPubkey,
|
||||||
functionAuthorityPubkey,
|
functionAuthorityPubkey,
|
||||||
fnQuote, // 15
|
|
||||||
mintPubkey,
|
mintPubkey,
|
||||||
walletPubkey,
|
walletPubkey, // 15
|
||||||
escrowPubkey, // 18
|
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}`
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
import { Account } from "../accounts/account.js";
|
import { Account } from "../accounts/account.js";
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/attestation-program/index.js";
|
import * as types from "../generated/attestation-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} 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 { parseMrEnclave } from "../utils.js";
|
||||||
|
|
||||||
import { FunctionAccount } from "./index.js";
|
import { FunctionAccount } from "./index.js";
|
||||||
|
@ -16,13 +16,12 @@ import {
|
||||||
ASSOCIATED_TOKEN_PROGRAM_ID,
|
ASSOCIATED_TOKEN_PROGRAM_ID,
|
||||||
TOKEN_PROGRAM_ID,
|
TOKEN_PROGRAM_ID,
|
||||||
} from "@solana/spl-token";
|
} from "@solana/spl-token";
|
||||||
import {
|
import type {
|
||||||
Keypair,
|
|
||||||
PublicKey,
|
PublicKey,
|
||||||
SystemProgram,
|
|
||||||
TransactionInstruction,
|
TransactionInstruction,
|
||||||
TransactionSignature,
|
TransactionSignature,
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
|
import { Keypair, SystemProgram } from "@solana/web3.js";
|
||||||
import { BN } from "@switchboard-xyz/common";
|
import { BN } from "@switchboard-xyz/common";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,7 +7,6 @@ export * from "./attestationQueueAccount.js";
|
||||||
export * from "./bufferRelayAccount.js";
|
export * from "./bufferRelayAccount.js";
|
||||||
export * from "./crankAccount.js";
|
export * from "./crankAccount.js";
|
||||||
export * from "./crankDataBuffer.js";
|
export * from "./crankDataBuffer.js";
|
||||||
export * from "./enclaveAccount.js";
|
|
||||||
export * from "./functionAccount.js";
|
export * from "./functionAccount.js";
|
||||||
export * from "./functionRequestAccount.js";
|
export * from "./functionRequestAccount.js";
|
||||||
export * from "./jobAccount.js";
|
export * from "./jobAccount.js";
|
||||||
|
@ -18,6 +17,7 @@ export * from "./programStateAccount.js";
|
||||||
export * from "./queueAccount.js";
|
export * from "./queueAccount.js";
|
||||||
export * from "./queueDataBuffer.js";
|
export * from "./queueDataBuffer.js";
|
||||||
export * from "./switchboardWallet.js";
|
export * from "./switchboardWallet.js";
|
||||||
|
export * from "./verifierAccount.js";
|
||||||
export * from "./vrfAccount.js";
|
export * from "./vrfAccount.js";
|
||||||
export * from "./vrfLiteAccount.js";
|
export * from "./vrfLiteAccount.js";
|
||||||
export * from "./vrfPoolAccount.js";
|
export * from "./vrfPoolAccount.js";
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/oracle-program/index.js";
|
import * as types from "../generated/oracle-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} from "../TransactionObject.js";
|
||||||
|
import { TransactionObject } from "../TransactionObject.js";
|
||||||
|
|
||||||
import { Account } from "./account.js";
|
import { Account } from "./account.js";
|
||||||
|
|
||||||
import * as anchor from "@coral-xyz/anchor";
|
import * as anchor from "@coral-xyz/anchor";
|
||||||
import {
|
import type {
|
||||||
AccountInfo,
|
AccountInfo,
|
||||||
Commitment,
|
Commitment,
|
||||||
|
TransactionSignature,
|
||||||
|
} from "@solana/web3.js";
|
||||||
|
import {
|
||||||
Keypair,
|
Keypair,
|
||||||
LAMPORTS_PER_SOL,
|
LAMPORTS_PER_SOL,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
SystemProgram,
|
SystemProgram,
|
||||||
TransactionSignature,
|
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { BN, OracleJob, toUtf8 } from "@switchboard-xyz/common";
|
import { BN, OracleJob, toUtf8 } from "@switchboard-xyz/common";
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,31 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/oracle-program/index.js";
|
import * as types from "../generated/oracle-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} from "../TransactionObject.js";
|
||||||
|
import { TransactionObject } from "../TransactionObject.js";
|
||||||
|
|
||||||
import { Account } from "./account.js";
|
import { Account } from "./account.js";
|
||||||
import { AggregatorAccount } from "./aggregatorAccount.js";
|
import { AggregatorAccount } from "./aggregatorAccount.js";
|
||||||
import { JobAccount } from "./jobAccount.js";
|
import type { JobAccount } from "./jobAccount.js";
|
||||||
import { QueueAccount } from "./queueAccount.js";
|
import { QueueAccount } from "./queueAccount.js";
|
||||||
|
|
||||||
import * as spl from "@solana/spl-token";
|
import * as spl from "@solana/spl-token";
|
||||||
import {
|
import type {
|
||||||
AccountInfo,
|
AccountInfo,
|
||||||
AccountMeta,
|
AccountMeta,
|
||||||
|
TransactionSignature,
|
||||||
|
} from "@solana/web3.js";
|
||||||
|
import {
|
||||||
Keypair,
|
Keypair,
|
||||||
LAMPORTS_PER_SOL,
|
LAMPORTS_PER_SOL,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
SystemProgram,
|
SystemProgram,
|
||||||
TransactionSignature,
|
|
||||||
} from "@solana/web3.js";
|
} 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.
|
* Account type representing an {@linkcode AggregatorAccount}'s pre-funded escrow used to reward {@linkcode OracleAccount}'s for responding to open round requests.
|
||||||
|
|
|
@ -1,29 +1,32 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/oracle-program/index.js";
|
import * as types from "../generated/oracle-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} 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 { PermissionAccount } from "./permissionAccount.js";
|
||||||
import { QueueAccount } from "./queueAccount.js";
|
import { QueueAccount } from "./queueAccount.js";
|
||||||
|
|
||||||
import * as anchor from "@coral-xyz/anchor";
|
import * as anchor from "@coral-xyz/anchor";
|
||||||
import * as spl from "@solana/spl-token";
|
import * as spl from "@solana/spl-token";
|
||||||
import {
|
import type {
|
||||||
AccountInfo,
|
AccountInfo,
|
||||||
Commitment,
|
Commitment,
|
||||||
|
TransactionInstruction,
|
||||||
|
TransactionSignature,
|
||||||
|
} from "@solana/web3.js";
|
||||||
|
import {
|
||||||
Keypair,
|
Keypair,
|
||||||
LAMPORTS_PER_SOL,
|
LAMPORTS_PER_SOL,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
SystemProgram,
|
SystemProgram,
|
||||||
TransactionInstruction,
|
|
||||||
TransactionSignature,
|
|
||||||
} from "@solana/web3.js";
|
} 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.
|
* Account type holding an oracle's configuration including the authority and the reward/slashing wallet along with a set of metrics tracking its reliability.
|
||||||
|
|
|
@ -6,24 +6,22 @@ import {
|
||||||
PermitOracleQueueUsage,
|
PermitOracleQueueUsage,
|
||||||
PermitVrfRequests,
|
PermitVrfRequests,
|
||||||
} from "../generated/oracle-program/types/SwitchboardPermission.js";
|
} from "../generated/oracle-program/types/SwitchboardPermission.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} from "../TransactionObject.js";
|
||||||
|
import { TransactionObject } from "../TransactionObject.js";
|
||||||
|
|
||||||
import { Account } from "./account.js";
|
import { Account } from "./account.js";
|
||||||
|
|
||||||
import { ACCOUNT_DISCRIMINATOR_SIZE } from "@coral-xyz/anchor";
|
import { ACCOUNT_DISCRIMINATOR_SIZE } from "@coral-xyz/anchor";
|
||||||
import {
|
import type {
|
||||||
AccountInfo,
|
AccountInfo,
|
||||||
Keypair,
|
Keypair,
|
||||||
LAMPORTS_PER_SOL,
|
|
||||||
PublicKey,
|
|
||||||
SystemProgram,
|
|
||||||
TransactionSignature,
|
TransactionSignature,
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
|
import { LAMPORTS_PER_SOL, PublicKey, SystemProgram } from "@solana/web3.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameters for initializing an {@linkcode PermissionAccount}
|
* Parameters for initializing an {@linkcode PermissionAccount}
|
||||||
|
|
|
@ -1,21 +1,19 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/oracle-program/index.js";
|
import * as types from "../generated/oracle-program/index.js";
|
||||||
import { Mint } from "../mint.js";
|
import { Mint } from "../mint.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import { TransactionObject } from "../TransactionObject.js";
|
import { TransactionObject } from "../TransactionObject.js";
|
||||||
|
|
||||||
import { Account } from "./account.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 * as spl from "@solana/spl-token";
|
||||||
import {
|
import type {
|
||||||
Keypair,
|
|
||||||
PublicKey,
|
|
||||||
SystemProgram,
|
|
||||||
TransactionInstruction,
|
TransactionInstruction,
|
||||||
TransactionSignature,
|
TransactionSignature,
|
||||||
} from "@solana/web3.js";
|
} 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.
|
* Account type representing Switchboard global program state.
|
||||||
|
|
|
@ -6,45 +6,40 @@ import {
|
||||||
PermitVrfRequests,
|
PermitVrfRequests,
|
||||||
} from "../generated/oracle-program/types/SwitchboardPermission.js";
|
} from "../generated/oracle-program/types/SwitchboardPermission.js";
|
||||||
import { SolanaClock } from "../SolanaClock.js";
|
import { SolanaClock } from "../SolanaClock.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} from "../TransactionObject.js";
|
||||||
|
import { TransactionObject } from "../TransactionObject.js";
|
||||||
|
|
||||||
import { Account, OnAccountChangeCallback } from "./account.js";
|
import type { OnAccountChangeCallback } from "./account.js";
|
||||||
import {
|
import { Account } from "./account.js";
|
||||||
AggregatorAccount,
|
import type { AggregatorInitParams } from "./aggregatorAccount.js";
|
||||||
AggregatorInitParams,
|
import { AggregatorAccount } from "./aggregatorAccount.js";
|
||||||
} from "./aggregatorAccount.js";
|
|
||||||
import { AggregatorHistoryBuffer } from "./aggregatorHistoryBuffer.js";
|
import { AggregatorHistoryBuffer } from "./aggregatorHistoryBuffer.js";
|
||||||
import {
|
import type { BufferRelayerInit } from "./bufferRelayAccount.js";
|
||||||
BufferRelayerAccount,
|
import { BufferRelayerAccount } from "./bufferRelayAccount.js";
|
||||||
BufferRelayerInit,
|
import type { CrankInitParams } from "./crankAccount.js";
|
||||||
} from "./bufferRelayAccount.js";
|
import { CrankAccount } from "./crankAccount.js";
|
||||||
import { CrankAccount, CrankInitParams } from "./crankAccount.js";
|
import type { JobInitParams } from "./jobAccount.js";
|
||||||
import { JobAccount, JobInitParams } from "./jobAccount.js";
|
import { JobAccount } from "./jobAccount.js";
|
||||||
import { LeaseAccount, LeaseInitParams } from "./leaseAccount.js";
|
import type { LeaseInitParams } from "./leaseAccount.js";
|
||||||
import {
|
import { LeaseAccount } from "./leaseAccount.js";
|
||||||
OracleAccount,
|
import type { OracleInitParams, OracleStakeParams } from "./oracleAccount.js";
|
||||||
OracleInitParams,
|
import { OracleAccount } from "./oracleAccount.js";
|
||||||
OracleStakeParams,
|
import type { PermissionSetParams } from "./permissionAccount.js";
|
||||||
} from "./oracleAccount.js";
|
import { PermissionAccount } from "./permissionAccount.js";
|
||||||
import { PermissionAccount, PermissionSetParams } from "./permissionAccount.js";
|
|
||||||
import { QueueDataBuffer } from "./queueDataBuffer.js";
|
import { QueueDataBuffer } from "./queueDataBuffer.js";
|
||||||
import { VrfAccount, VrfInitParams } from "./vrfAccount.js";
|
import type { VrfInitParams } from "./vrfAccount.js";
|
||||||
import { VrfLiteAccount, VrfLiteInitParams } from "./vrfLiteAccount.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 type * as anchor from "@coral-xyz/anchor";
|
||||||
import * as spl from "@solana/spl-token";
|
import type * as spl from "@solana/spl-token";
|
||||||
import {
|
import type { Commitment, TransactionSignature } from "@solana/web3.js";
|
||||||
Commitment,
|
import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js";
|
||||||
Keypair,
|
|
||||||
PublicKey,
|
|
||||||
SystemProgram,
|
|
||||||
TransactionSignature,
|
|
||||||
} from "@solana/web3.js";
|
|
||||||
import { Big, BN, SwitchboardDecimal, toUtf8 } from "@switchboard-xyz/common";
|
import { Big, BN, SwitchboardDecimal, toUtf8 } from "@switchboard-xyz/common";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -917,18 +912,20 @@ export class QueueAccount extends Account<types.OracleQueueAccountData> {
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
|
|
||||||
// eslint-disable-next-line prefer-const
|
let [
|
||||||
let [permissionAccount, permissionInit] =
|
// eslint-disable-next-line prefer-const
|
||||||
PermissionAccount.createInstruction(
|
permissionAccount,
|
||||||
this.program,
|
permissionInit,
|
||||||
payer,
|
] = PermissionAccount.createInstruction(
|
||||||
{
|
this.program,
|
||||||
granter: this.publicKey,
|
payer,
|
||||||
grantee: vrfAccount.publicKey,
|
{
|
||||||
authority: queueAuthorityPubkey,
|
granter: this.publicKey,
|
||||||
},
|
grantee: vrfAccount.publicKey,
|
||||||
options
|
authority: queueAuthorityPubkey,
|
||||||
);
|
},
|
||||||
|
options
|
||||||
|
);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
params.enable &&
|
params.enable &&
|
||||||
|
@ -1059,13 +1056,15 @@ export class QueueAccount extends Account<types.OracleQueueAccountData> {
|
||||||
|
|
||||||
txns.push(bufferInit);
|
txns.push(bufferInit);
|
||||||
|
|
||||||
// eslint-disable-next-line prefer-const
|
let [
|
||||||
let [permissionAccount, permissionInit] =
|
// eslint-disable-next-line prefer-const
|
||||||
PermissionAccount.createInstruction(this.program, payer, {
|
permissionAccount,
|
||||||
granter: this.publicKey,
|
permissionInit,
|
||||||
grantee: bufferAccount.publicKey,
|
] = PermissionAccount.createInstruction(this.program, payer, {
|
||||||
authority: queueAuthorityPubkey,
|
granter: this.publicKey,
|
||||||
});
|
grantee: bufferAccount.publicKey,
|
||||||
|
authority: queueAuthorityPubkey,
|
||||||
|
});
|
||||||
|
|
||||||
if (
|
if (
|
||||||
params.enable &&
|
params.enable &&
|
||||||
|
|
|
@ -1,19 +1,12 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/oracle-program/index.js";
|
import type * as types from "../generated/oracle-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
|
|
||||||
import {
|
import type { OnAccountChangeCallback } from "./account.js";
|
||||||
Account,
|
import { Account, BUFFER_DISCRIMINATOR } from "./account.js";
|
||||||
BUFFER_DISCRIMINATOR,
|
|
||||||
OnAccountChangeCallback,
|
|
||||||
} from "./account.js";
|
|
||||||
|
|
||||||
import {
|
import type { AccountInfo, Commitment } from "@solana/web3.js";
|
||||||
AccountInfo,
|
import { LAMPORTS_PER_SOL, PublicKey } from "@solana/web3.js";
|
||||||
Commitment,
|
|
||||||
LAMPORTS_PER_SOL,
|
|
||||||
PublicKey,
|
|
||||||
} from "@solana/web3.js";
|
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,24 +1,23 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/attestation-program/index.js";
|
import * as types from "../generated/attestation-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} from "../TransactionObject.js";
|
||||||
|
import { TransactionObject } from "../TransactionObject.js";
|
||||||
import { parseRawBuffer } from "../utils.js";
|
import { parseRawBuffer } from "../utils.js";
|
||||||
|
|
||||||
import { Account } from "./account.js";
|
import { Account } from "./account.js";
|
||||||
|
|
||||||
import * as spl from "@solana/spl-token";
|
import * as spl from "@solana/spl-token";
|
||||||
import {
|
import type {
|
||||||
AccountMeta,
|
AccountMeta,
|
||||||
Keypair,
|
Keypair,
|
||||||
PublicKey,
|
|
||||||
SystemProgram,
|
|
||||||
TransactionSignature,
|
TransactionSignature,
|
||||||
} from "@solana/web3.js";
|
} 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";
|
import assert from "assert";
|
||||||
|
|
||||||
export interface SwitchboardWalletTransferParams {
|
export interface SwitchboardWalletTransferParams {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/attestation-program/index.js";
|
import * as types from "../generated/attestation-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} 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 { parseMrEnclave, parseRawBuffer } from "../utils.js";
|
||||||
|
|
||||||
import { Account } from "./account.js";
|
import { Account } from "./account.js";
|
||||||
|
@ -15,21 +15,19 @@ import {
|
||||||
AttestationQueueAccount,
|
AttestationQueueAccount,
|
||||||
} from "./index.js";
|
} from "./index.js";
|
||||||
|
|
||||||
import * as anchor from "@coral-xyz/anchor";
|
import type * as anchor from "@coral-xyz/anchor";
|
||||||
import {
|
import type {
|
||||||
Keypair,
|
|
||||||
PublicKey,
|
|
||||||
SystemProgram,
|
|
||||||
TransactionInstruction,
|
TransactionInstruction,
|
||||||
TransactionSignature,
|
TransactionSignature,
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
|
import { Keypair, PublicKey, SystemProgram } from "@solana/web3.js";
|
||||||
|
|
||||||
export const QUOTE_SEED: string = "QuoteAccountData";
|
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.
|
* 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.
|
* Parameters for an {@linkcode types.quoteHeartbeat} instruction.
|
||||||
*/
|
*/
|
||||||
export interface EnclaveHeartbeatSyncParams {
|
export interface VerifierHeartbeatSyncParams {
|
||||||
gcOracle: PublicKey;
|
gcOracle: PublicKey;
|
||||||
attestationQueue: PublicKey;
|
attestationQueue: PublicKey;
|
||||||
permission: AttestationPermissionAccount;
|
permission: AttestationPermissionAccount;
|
||||||
|
@ -65,17 +63,17 @@ export interface EnclaveHeartbeatSyncParams {
|
||||||
/**
|
/**
|
||||||
* Parameters for an {@linkcode types.quoteHeartbeat} instruction.
|
* Parameters for an {@linkcode types.quoteHeartbeat} instruction.
|
||||||
*/
|
*/
|
||||||
export type EnclaveHeartbeatParams = Partial<EnclaveHeartbeatSyncParams> & {
|
export type VerifierHeartbeatParams = Partial<VerifierHeartbeatSyncParams> & {
|
||||||
enclaveSigner: Keypair;
|
enclaveSigner: Keypair;
|
||||||
} & Partial<{
|
} & Partial<{
|
||||||
quote: types.EnclaveAccountData;
|
quote: types.VerifierAccountData;
|
||||||
queue: types.AttestationQueueAccountData;
|
queue: types.AttestationQueueAccountData;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameters for an {@linkcode types.quoteVerify} instruction.
|
* Parameters for an {@linkcode types.quoteVerify} instruction.
|
||||||
*/
|
*/
|
||||||
export interface EnclaveVerifyParams {
|
export interface QuoteVerifyParams {
|
||||||
/**
|
/**
|
||||||
* @TODO: Docs for timestamp
|
* @TODO: Docs for timestamp
|
||||||
*/
|
*/
|
||||||
|
@ -86,16 +84,18 @@ export interface EnclaveVerifyParams {
|
||||||
mrEnclave: RawBuffer;
|
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;
|
enclaveSigner?: Keypair;
|
||||||
verifier: PublicKey;
|
|
||||||
|
quote: VerifierAccount;
|
||||||
|
quoteState?: types.VerifierAccountData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameters for an {@linkcode types.quoteRotate} instruction.
|
* Parameters for an {@linkcode types.quoteRotate} instruction.
|
||||||
*/
|
*/
|
||||||
export interface EnclaveRotateParams {
|
export interface VerifierRotateParams {
|
||||||
authority?: Keypair;
|
authority?: Keypair;
|
||||||
enclaveSigner: Keypair;
|
enclaveSigner: Keypair;
|
||||||
registryKey: string | Buffer | Uint8Array;
|
registryKey: string | Buffer | Uint8Array;
|
||||||
|
@ -104,41 +104,41 @@ export interface EnclaveRotateParams {
|
||||||
/**
|
/**
|
||||||
* Account type representing a Switchboard Attestation quote.
|
* Account type representing a Switchboard Attestation quote.
|
||||||
*
|
*
|
||||||
* Data: {@linkcode types.EnclaveAccountData}
|
* Data: {@linkcode types.VerifierAccountData}
|
||||||
*/
|
*/
|
||||||
export class EnclaveAccount extends Account<types.EnclaveAccountData> {
|
export class VerifierAccount extends Account<types.VerifierAccountData> {
|
||||||
static accountName = "EnclaveAccountData";
|
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(
|
public static async load(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
address: PublicKey | string
|
address: PublicKey | string
|
||||||
): Promise<[EnclaveAccount, types.EnclaveAccountData]> {
|
): Promise<[VerifierAccount, types.VerifierAccountData]> {
|
||||||
program.verifyAttestation();
|
program.verifyAttestation();
|
||||||
|
|
||||||
const enclaveAccount = new EnclaveAccount(program, address);
|
const verifierAccount = new VerifierAccount(program, address);
|
||||||
const state = await enclaveAccount.loadData();
|
const state = await verifierAccount.loadData();
|
||||||
return [enclaveAccount, state];
|
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(
|
public static fromSeed(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
functionPubkey: PublicKey
|
functionPubkey: PublicKey
|
||||||
): EnclaveAccount {
|
): VerifierAccount {
|
||||||
const [publicKey, bump] = PublicKey.findProgramAddressSync(
|
const [publicKey, bump] = PublicKey.findProgramAddressSync(
|
||||||
[Buffer.from(QUOTE_SEED), functionPubkey.toBytes()],
|
[Buffer.from(QUOTE_SEED), functionPubkey.toBytes()],
|
||||||
program.attestationProgramId
|
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(
|
public static async createInstruction(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
payer: PublicKey,
|
payer: PublicKey,
|
||||||
params: EnclaveAccountInitParams,
|
params: VerifierAccountInitParams,
|
||||||
options?: TransactionObjectOptions
|
options?: TransactionObjectOptions
|
||||||
): Promise<[EnclaveAccount, TransactionObject]> {
|
): Promise<[VerifierAccount, TransactionObject]> {
|
||||||
program.verifyAttestation();
|
program.verifyAttestation();
|
||||||
|
|
||||||
const quoteKeypair = params.keypair ?? Keypair.generate();
|
const verifierKeypair = params.keypair ?? Keypair.generate();
|
||||||
program.verifyNewKeypair(quoteKeypair);
|
program.verifyNewKeypair(verifierKeypair);
|
||||||
|
|
||||||
const queueData = await params.queueAccount.loadData();
|
const queueData = await params.queueAccount.loadData();
|
||||||
|
|
||||||
|
@ -161,11 +161,11 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
|
||||||
.concat(Array(64).fill(0))
|
.concat(Array(64).fill(0))
|
||||||
.slice(0, 64);
|
.slice(0, 64);
|
||||||
|
|
||||||
const instruction = types.quoteInit(
|
const instruction = types.verifierInit(
|
||||||
program,
|
program,
|
||||||
{ params: { registryKey } },
|
{ params: { registryKey } },
|
||||||
{
|
{
|
||||||
quote: quoteKeypair.publicKey,
|
verifier: verifierKeypair.publicKey,
|
||||||
attestationQueue: params.queueAccount.publicKey,
|
attestationQueue: params.queueAccount.publicKey,
|
||||||
queueAuthority: queueData.authority,
|
queueAuthority: queueData.authority,
|
||||||
authority: params.authority ?? payer,
|
authority: params.authority ?? payer,
|
||||||
|
@ -174,16 +174,16 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return [
|
return [
|
||||||
new EnclaveAccount(program, quoteKeypair.publicKey),
|
new VerifierAccount(program, verifierKeypair.publicKey),
|
||||||
new TransactionObject(payer, [instruction], [quoteKeypair], options),
|
new TransactionObject(payer, [instruction], [verifierKeypair], options),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async create(
|
public static async create(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
params: EnclaveAccountInitParams,
|
params: VerifierAccountInitParams,
|
||||||
options?: SendTransactionObjectOptions
|
options?: SendTransactionObjectOptions
|
||||||
): Promise<[EnclaveAccount, TransactionSignature]> {
|
): Promise<[VerifierAccount, TransactionSignature]> {
|
||||||
const [account, txnObject] = await this.createInstruction(
|
const [account, txnObject] = await this.createInstruction(
|
||||||
program,
|
program,
|
||||||
program.walletPubkey,
|
program.walletPubkey,
|
||||||
|
@ -208,9 +208,9 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
static getVerificationStatus(
|
static getVerificationStatus(
|
||||||
state: types.EnclaveAccountData
|
state: types.VerifierAccountData
|
||||||
): types.VerificationStatusKind {
|
): types.VerificationStatusKind {
|
||||||
switch (state.verificationStatus) {
|
switch (state.enclave.verificationStatus) {
|
||||||
case types.VerificationStatus.None.discriminator:
|
case types.VerificationStatus.None.discriminator:
|
||||||
return new types.VerificationStatus.None();
|
return new types.VerificationStatus.None();
|
||||||
case types.VerificationStatus.VerificationPending.discriminator:
|
case types.VerificationStatus.VerificationPending.discriminator:
|
||||||
|
@ -224,27 +224,27 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error(
|
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 =
|
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();
|
this.program.verifyAttestation();
|
||||||
const data = await types.EnclaveAccountData.fetch(
|
const data = await types.VerifierAccountData.fetch(
|
||||||
this.program,
|
this.program,
|
||||||
this.publicKey
|
this.publicKey
|
||||||
);
|
);
|
||||||
if (data) return data;
|
if (data) return data;
|
||||||
throw new errors.AccountNotFoundError("Enclave", this.publicKey);
|
throw new errors.AccountNotFoundError("Verifier", this.publicKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public heartbeatInstruction(params: {
|
public heartbeatInstruction(params: {
|
||||||
|
@ -256,12 +256,12 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
|
||||||
}): TransactionInstruction {
|
}): TransactionInstruction {
|
||||||
this.program.verifyAttestation();
|
this.program.verifyAttestation();
|
||||||
|
|
||||||
const instruction = types.quoteHeartbeat(
|
const instruction = types.verifierHeartbeat(
|
||||||
this.program,
|
this.program,
|
||||||
{ params: {} },
|
{ params: {} },
|
||||||
{
|
{
|
||||||
quote: this.publicKey,
|
verifier: this.publicKey,
|
||||||
enclaveSigner: params.enclaveSigner,
|
verifierSigner: params.enclaveSigner,
|
||||||
attestationQueue: params.attestationQueue,
|
attestationQueue: params.attestationQueue,
|
||||||
queueAuthority: params.queueAuthority,
|
queueAuthority: params.queueAuthority,
|
||||||
gcNode: params.gcOracle,
|
gcNode: params.gcOracle,
|
||||||
|
@ -272,7 +272,7 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async heartbeat(
|
public async heartbeat(
|
||||||
params: EnclaveHeartbeatParams,
|
params: VerifierHeartbeatParams,
|
||||||
options?: SendTransactionObjectOptions
|
options?: SendTransactionObjectOptions
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
const quote = params.quote ?? (await this.loadData());
|
const quote = params.quote ?? (await this.loadData());
|
||||||
|
@ -317,7 +317,7 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
|
||||||
|
|
||||||
public async rotateInstruction(
|
public async rotateInstruction(
|
||||||
payer: PublicKey,
|
payer: PublicKey,
|
||||||
params: EnclaveRotateParams,
|
params: VerifierRotateParams,
|
||||||
options?: TransactionObjectOptions
|
options?: TransactionObjectOptions
|
||||||
): Promise<TransactionObject> {
|
): Promise<TransactionObject> {
|
||||||
this.program.verifyAttestation();
|
this.program.verifyAttestation();
|
||||||
|
@ -331,13 +331,13 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
|
||||||
throw new errors.IncorrectAuthority(quoteData.authority, authority);
|
throw new errors.IncorrectAuthority(quoteData.authority, authority);
|
||||||
}
|
}
|
||||||
|
|
||||||
const rotateIxn = types.quoteRotate(
|
const rotateIxn = types.verifierQuoteRotate(
|
||||||
this.program,
|
this.program,
|
||||||
{
|
{
|
||||||
params: { registryKey: [...registryKey].slice(0, 64) },
|
params: { registryKey: [...registryKey].slice(0, 64) },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
quote: this.publicKey,
|
verifier: this.publicKey,
|
||||||
authority: authority,
|
authority: authority,
|
||||||
enclaveSigner: params.enclaveSigner.publicKey,
|
enclaveSigner: params.enclaveSigner.publicKey,
|
||||||
attestationQueue: quoteData.attestationQueue,
|
attestationQueue: quoteData.attestationQueue,
|
||||||
|
@ -356,7 +356,7 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async rotate(
|
public async rotate(
|
||||||
params: EnclaveRotateParams,
|
params: VerifierRotateParams,
|
||||||
options?: SendTransactionObjectOptions
|
options?: SendTransactionObjectOptions
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
return await this.rotateInstruction(
|
return await this.rotateInstruction(
|
||||||
|
@ -368,26 +368,41 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
|
||||||
|
|
||||||
public async verifyInstruction(
|
public async verifyInstruction(
|
||||||
payer: PublicKey,
|
payer: PublicKey,
|
||||||
params: EnclaveVerifyParams,
|
params: QuoteVerifyParams,
|
||||||
options?: TransactionObjectOptions
|
options?: TransactionObjectOptions
|
||||||
): Promise<TransactionObject> {
|
): Promise<TransactionObject> {
|
||||||
this.program.verifyAttestation();
|
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(
|
const attestationQueueAccount = new AttestationQueueAccount(
|
||||||
this.program,
|
this.program,
|
||||||
quoteData.attestationQueue
|
verifierState.attestationQueue
|
||||||
);
|
);
|
||||||
|
|
||||||
const attestationQueue = await attestationQueueAccount.loadData();
|
const attestationQueue = await attestationQueueAccount.loadData();
|
||||||
const verifierIdx = attestationQueue.data
|
const verifierIdx = attestationQueue.data
|
||||||
.slice(0, attestationQueue.dataLen)
|
.slice(0, attestationQueue.dataLen)
|
||||||
.findIndex((pubkey) => pubkey.equals(params.verifier));
|
.findIndex((pubkey) => pubkey.equals(this.publicKey));
|
||||||
if (verifierIdx === -1) {
|
if (verifierIdx === -1) {
|
||||||
throw new Error(`Verifier not found on the attestation queue`);
|
throw new Error(`Verifier not found on the attestation queue`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const instruction = types.quoteVerify(
|
const instruction = types.verifierQuoteVerify(
|
||||||
this.program,
|
this.program,
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
|
@ -397,23 +412,17 @@ export class EnclaveAccount extends Account<types.EnclaveAccountData> {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
quote: this.publicKey,
|
quote: params.quote.publicKey,
|
||||||
quoteSigner: quoteData.enclaveSigner,
|
enclaveSigner: verifierState.enclave.enclaveSigner,
|
||||||
enclaveSigner: params.verifierSecuredSigner.publicKey,
|
verifier: this.publicKey,
|
||||||
verifier: params.verifier,
|
attestationQueue: verifierState.attestationQueue,
|
||||||
attestationQueue: quoteData.attestationQueue,
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return new TransactionObject(
|
return new TransactionObject(payer, [instruction], signers, options);
|
||||||
payer,
|
|
||||||
[instruction],
|
|
||||||
[params.verifierSecuredSigner],
|
|
||||||
options
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async verify(
|
public async verify(
|
||||||
params: EnclaveVerifyParams,
|
params: QuoteVerifyParams,
|
||||||
options?: SendTransactionObjectOptions
|
options?: SendTransactionObjectOptions
|
||||||
): Promise<TransactionSignature> {
|
): Promise<TransactionSignature> {
|
||||||
return await this.verifyInstruction(
|
return await this.verifyInstruction(
|
|
@ -1,30 +1,33 @@
|
||||||
import * as errors from "../errors.js";
|
import * as errors from "../errors.js";
|
||||||
import * as types from "../generated/oracle-program/index.js";
|
import * as types from "../generated/oracle-program/index.js";
|
||||||
import { vrfCloseAction } from "../generated/oracle-program/index.js";
|
import { vrfCloseAction } from "../generated/oracle-program/index.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type {
|
||||||
SendTransactionObjectOptions,
|
SendTransactionObjectOptions,
|
||||||
TransactionObject,
|
|
||||||
TransactionObjectOptions,
|
TransactionObjectOptions,
|
||||||
} from "../TransactionObject.js";
|
} 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 { OracleAccount } from "./oracleAccount.js";
|
||||||
import { PermissionAccount } from "./permissionAccount.js";
|
import { PermissionAccount } from "./permissionAccount.js";
|
||||||
import { QueueAccount } from "./queueAccount.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 * as spl from "@solana/spl-token";
|
||||||
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
|
import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
|
||||||
import {
|
import type {
|
||||||
Commitment,
|
Commitment,
|
||||||
Keypair,
|
|
||||||
ParsedTransactionWithMeta,
|
ParsedTransactionWithMeta,
|
||||||
|
TransactionSignature,
|
||||||
|
} from "@solana/web3.js";
|
||||||
|
import {
|
||||||
|
Keypair,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
SystemProgram,
|
SystemProgram,
|
||||||
SYSVAR_INSTRUCTIONS_PUBKEY,
|
SYSVAR_INSTRUCTIONS_PUBKEY,
|
||||||
SYSVAR_RECENT_BLOCKHASHES_PUBKEY,
|
SYSVAR_RECENT_BLOCKHASHES_PUBKEY,
|
||||||
TransactionSignature,
|
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { BN, promiseWithTimeout } from "@switchboard-xyz/common";
|
import { BN, promiseWithTimeout } from "@switchboard-xyz/common";
|
||||||
|
|
||||||
|
|
|
@ -2,32 +2,33 @@ import * as errors from "../errors.js";
|
||||||
import { vrfLiteInit } from "../generated/oracle-program/index.js";
|
import { vrfLiteInit } from "../generated/oracle-program/index.js";
|
||||||
import * as types 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 { vrfLiteCloseAction } from "../generated/oracle-program/instructions/vrfLiteCloseAction.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import {
|
import type { TransactionObjectOptions } from "../TransactionObject.js";
|
||||||
TransactionObject,
|
import { TransactionObject } from "../TransactionObject.js";
|
||||||
TransactionObjectOptions,
|
|
||||||
} 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 { OracleAccount } from "./oracleAccount.js";
|
||||||
import { PermissionAccount } from "./permissionAccount.js";
|
import { PermissionAccount } from "./permissionAccount.js";
|
||||||
import { QueueAccount } from "./queueAccount.js";
|
import { QueueAccount } from "./queueAccount.js";
|
||||||
import { Callback, VrfResult } from "./vrfAccount.js";
|
import type { Callback, VrfResult } from "./vrfAccount.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ASSOCIATED_TOKEN_PROGRAM_ID,
|
ASSOCIATED_TOKEN_PROGRAM_ID,
|
||||||
createTransferInstruction,
|
createTransferInstruction,
|
||||||
TOKEN_PROGRAM_ID,
|
TOKEN_PROGRAM_ID,
|
||||||
} from "@solana/spl-token";
|
} from "@solana/spl-token";
|
||||||
import {
|
import type {
|
||||||
Commitment,
|
Commitment,
|
||||||
Keypair,
|
|
||||||
ParsedTransactionWithMeta,
|
ParsedTransactionWithMeta,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
|
TransactionSignature,
|
||||||
|
} from "@solana/web3.js";
|
||||||
|
import {
|
||||||
|
Keypair,
|
||||||
SystemProgram,
|
SystemProgram,
|
||||||
SYSVAR_INSTRUCTIONS_PUBKEY,
|
SYSVAR_INSTRUCTIONS_PUBKEY,
|
||||||
SYSVAR_RENT_PUBKEY,
|
SYSVAR_RENT_PUBKEY,
|
||||||
TransactionSignature,
|
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { BN, promiseWithTimeout } from "@switchboard-xyz/common";
|
import { BN, promiseWithTimeout } from "@switchboard-xyz/common";
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
import { VRF_POOL_REQUEST_AMOUNT } from "../const.js";
|
import { VRF_POOL_REQUEST_AMOUNT } from "../const.js";
|
||||||
import { AccountNotFoundError, InsufficientFundsError } from "../errors.js";
|
import { AccountNotFoundError, InsufficientFundsError } from "../errors.js";
|
||||||
import * as types from "../generated/oracle-program/index.js";
|
import * as types from "../generated/oracle-program/index.js";
|
||||||
import { VrfPoolRequestEvent } from "../SwitchboardEvents.js";
|
import type { VrfPoolRequestEvent } from "../SwitchboardEvents.js";
|
||||||
import { SwitchboardProgram } from "../SwitchboardProgram.js";
|
import type { SwitchboardProgram } from "../SwitchboardProgram.js";
|
||||||
import { TransactionObject } 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 { PermissionAccount } from "./permissionAccount.js";
|
||||||
import { CreateVrfLiteParams, QueueAccount } from "./queueAccount.js";
|
import type { CreateVrfLiteParams } from "./queueAccount.js";
|
||||||
import { Callback } from "./vrfAccount.js";
|
import { QueueAccount } from "./queueAccount.js";
|
||||||
|
import type { Callback } from "./vrfAccount.js";
|
||||||
import { VrfLiteAccount } from "./vrfLiteAccount.js";
|
import { VrfLiteAccount } from "./vrfLiteAccount.js";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -16,15 +18,17 @@ import {
|
||||||
createTransferInstruction,
|
createTransferInstruction,
|
||||||
TOKEN_PROGRAM_ID,
|
TOKEN_PROGRAM_ID,
|
||||||
} from "@solana/spl-token";
|
} from "@solana/spl-token";
|
||||||
import {
|
import type {
|
||||||
AccountMeta,
|
AccountMeta,
|
||||||
Commitment,
|
Commitment,
|
||||||
|
TransactionSignature,
|
||||||
|
} from "@solana/web3.js";
|
||||||
|
import {
|
||||||
Keypair,
|
Keypair,
|
||||||
PublicKey,
|
PublicKey,
|
||||||
SystemProgram,
|
SystemProgram,
|
||||||
SYSVAR_RECENT_BLOCKHASHES_PUBKEY,
|
SYSVAR_RECENT_BLOCKHASHES_PUBKEY,
|
||||||
SYSVAR_RENT_PUBKEY,
|
SYSVAR_RENT_PUBKEY,
|
||||||
TransactionSignature,
|
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { promiseWithTimeout } from "@switchboard-xyz/common";
|
import { promiseWithTimeout } from "@switchboard-xyz/common";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as anchor from "@coral-xyz/anchor";
|
import type * as anchor from "@coral-xyz/anchor";
|
||||||
import { PublicKey } from "@solana/web3.js";
|
import type { PublicKey } from "@solana/web3.js";
|
||||||
|
|
||||||
export class SwitchboardProgramIsBrowserError extends Error {
|
export class SwitchboardProgramIsBrowserError extends Error {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
@ -60,14 +60,15 @@ export class AttestationPermissionAccountData {
|
||||||
|
|
||||||
static async fetch(
|
static async fetch(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
address: PublicKey
|
address: PublicKey,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
): Promise<AttestationPermissionAccountData | null> {
|
): Promise<AttestationPermissionAccountData | null> {
|
||||||
const info = await program.connection.getAccountInfo(address);
|
const info = await program.connection.getAccountInfo(address);
|
||||||
|
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +77,8 @@ export class AttestationPermissionAccountData {
|
||||||
|
|
||||||
static async fetchMultiple(
|
static async fetchMultiple(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
addresses: PublicKey[]
|
addresses: PublicKey[],
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
): Promise<Array<AttestationPermissionAccountData | null>> {
|
): Promise<Array<AttestationPermissionAccountData | null>> {
|
||||||
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
||||||
|
|
||||||
|
@ -84,7 +86,7 @@ export class AttestationPermissionAccountData {
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 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 * 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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface AttestationProgramStateFields {
|
export interface AttestationProgramStateFields {
|
||||||
|
@ -35,14 +36,15 @@ export class AttestationProgramState {
|
||||||
|
|
||||||
static async fetch(
|
static async fetch(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
address: PublicKey
|
address: PublicKey,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
): Promise<AttestationProgramState | null> {
|
): Promise<AttestationProgramState | null> {
|
||||||
const info = await program.connection.getAccountInfo(address);
|
const info = await program.connection.getAccountInfo(address);
|
||||||
|
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +53,8 @@ export class AttestationProgramState {
|
||||||
|
|
||||||
static async fetchMultiple(
|
static async fetchMultiple(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
addresses: PublicKey[]
|
addresses: PublicKey[],
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
): Promise<Array<AttestationProgramState | null>> {
|
): Promise<Array<AttestationProgramState | null>> {
|
||||||
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
||||||
|
|
||||||
|
@ -59,7 +62,7 @@ export class AttestationProgramState {
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
@ -177,14 +177,15 @@ export class AttestationQueueAccountData {
|
||||||
|
|
||||||
static async fetch(
|
static async fetch(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
address: PublicKey
|
address: PublicKey,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
): Promise<AttestationQueueAccountData | null> {
|
): Promise<AttestationQueueAccountData | null> {
|
||||||
const info = await program.connection.getAccountInfo(address);
|
const info = await program.connection.getAccountInfo(address);
|
||||||
|
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +194,8 @@ export class AttestationQueueAccountData {
|
||||||
|
|
||||||
static async fetchMultiple(
|
static async fetchMultiple(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
addresses: PublicKey[]
|
addresses: PublicKey[],
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
): Promise<Array<AttestationQueueAccountData | null>> {
|
): Promise<Array<AttestationQueueAccountData | null>> {
|
||||||
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
||||||
|
|
||||||
|
@ -201,7 +203,7 @@ export class AttestationQueueAccountData {
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 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 * 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 */
|
/** The function permissions granted by the attestation_queue.authority */
|
||||||
permissions: number;
|
permissions: number;
|
||||||
status: types.FunctionStatusKind;
|
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. */
|
/** The name of the function for easier identification. */
|
||||||
name: Array<number>;
|
name: Array<number>;
|
||||||
/** The metadata of the function for easier identification. */
|
/** The metadata of the function for easier identification. */
|
||||||
metadata: Array<number>;
|
metadata: Array<number>;
|
||||||
/** The Solana slot when the function was created. (PDA) */
|
/** The Solana slot when the function was created. (PDA) */
|
||||||
createdAtSlot: BN;
|
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. */
|
/** The unix timestamp when the function config (container, registry, version, or schedule) was changed. */
|
||||||
updatedAt: BN;
|
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. */
|
/** The off-chain registry to fetch the function container from. */
|
||||||
containerRegistry: Array<number>;
|
containerRegistry: Array<number>;
|
||||||
/** The identifier of the container in the given container_registry. */
|
/** The identifier of the container in the given container_registry. */
|
||||||
container: Array<number>;
|
container: Array<number>;
|
||||||
/** The version tag of the container to pull. */
|
/** The version tag of the container to pull. */
|
||||||
version: Array<number>;
|
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. */
|
/** The authority of the function which is authorized to make account changes. */
|
||||||
authority: PublicKey;
|
authority: PublicKey;
|
||||||
/** The address of the AttestationQueueAccountData that will be processing function requests and verifying the function measurements. */
|
/** 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;
|
nextAllowedTimestamp: BN;
|
||||||
/** The number of times to trigger the function upon the next invocation. */
|
/** The number of times to trigger the function upon the next invocation. */
|
||||||
triggerCount: BN;
|
triggerCount: BN;
|
||||||
|
/** Time this function has been sitting in an explicitly triggered state */
|
||||||
|
triggeredSince: BN;
|
||||||
/** UNUSED. The unix timestamp when the current permissions expire. */
|
/** UNUSED. The unix timestamp when the current permissions expire. */
|
||||||
permissionExpiration: BN;
|
permissionExpiration: BN;
|
||||||
/** Number of requests created for this function. Used to prevent closing when there are live requests. */
|
/** 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;
|
requestsDefaultSlotsUntilExpiration: BN;
|
||||||
/** The lamports paid to the FunctionAccount escrow on each successful update request. */
|
/** The lamports paid to the FunctionAccount escrow on each successful update request. */
|
||||||
requestsFee: BN;
|
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. */
|
/** The SwitchboardWallet that will handle pre-funding rewards paid out to function runners. */
|
||||||
escrowWallet: PublicKey;
|
escrowWallet: PublicKey;
|
||||||
/** The escrow_wallet TokenAccount that handles pre-funding rewards paid out to function runners. */
|
/** The escrow_wallet TokenAccount that handles pre-funding rewards paid out to function runners. */
|
||||||
|
@ -78,8 +88,6 @@ export interface FunctionAccountDataFields {
|
||||||
rewardEscrowWallet: PublicKey;
|
rewardEscrowWallet: PublicKey;
|
||||||
/** The reward_escrow_wallet TokenAccount used to acrue rewards from requests made with custom parameters. */
|
/** The reward_escrow_wallet TokenAccount used to acrue rewards from requests made with custom parameters. */
|
||||||
rewardEscrowTokenWallet: PublicKey;
|
rewardEscrowTokenWallet: PublicKey;
|
||||||
/** The unix timestamp when the function was created. */
|
|
||||||
createdAt: BN;
|
|
||||||
/** Reserved. */
|
/** Reserved. */
|
||||||
ebuf: Array<number>;
|
ebuf: Array<number>;
|
||||||
}
|
}
|
||||||
|
@ -92,20 +100,34 @@ export interface FunctionAccountDataJSON {
|
||||||
/** The function permissions granted by the attestation_queue.authority */
|
/** The function permissions granted by the attestation_queue.authority */
|
||||||
permissions: number;
|
permissions: number;
|
||||||
status: types.FunctionStatusJSON;
|
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. */
|
/** The name of the function for easier identification. */
|
||||||
name: Array<number>;
|
name: Array<number>;
|
||||||
/** The metadata of the function for easier identification. */
|
/** The metadata of the function for easier identification. */
|
||||||
metadata: Array<number>;
|
metadata: Array<number>;
|
||||||
/** The Solana slot when the function was created. (PDA) */
|
/** The Solana slot when the function was created. (PDA) */
|
||||||
createdAtSlot: string;
|
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. */
|
/** The unix timestamp when the function config (container, registry, version, or schedule) was changed. */
|
||||||
updatedAt: string;
|
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. */
|
/** The off-chain registry to fetch the function container from. */
|
||||||
containerRegistry: Array<number>;
|
containerRegistry: Array<number>;
|
||||||
/** The identifier of the container in the given container_registry. */
|
/** The identifier of the container in the given container_registry. */
|
||||||
container: Array<number>;
|
container: Array<number>;
|
||||||
/** The version tag of the container to pull. */
|
/** The version tag of the container to pull. */
|
||||||
version: Array<number>;
|
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. */
|
/** The authority of the function which is authorized to make account changes. */
|
||||||
authority: string;
|
authority: string;
|
||||||
/** The address of the AttestationQueueAccountData that will be processing function requests and verifying the function measurements. */
|
/** 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;
|
nextAllowedTimestamp: string;
|
||||||
/** The number of times to trigger the function upon the next invocation. */
|
/** The number of times to trigger the function upon the next invocation. */
|
||||||
triggerCount: string;
|
triggerCount: string;
|
||||||
|
/** Time this function has been sitting in an explicitly triggered state */
|
||||||
|
triggeredSince: string;
|
||||||
/** UNUSED. The unix timestamp when the current permissions expire. */
|
/** UNUSED. The unix timestamp when the current permissions expire. */
|
||||||
permissionExpiration: string;
|
permissionExpiration: string;
|
||||||
/** Number of requests created for this function. Used to prevent closing when there are live requests. */
|
/** 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;
|
requestsDefaultSlotsUntilExpiration: string;
|
||||||
/** The lamports paid to the FunctionAccount escrow on each successful update request. */
|
/** The lamports paid to the FunctionAccount escrow on each successful update request. */
|
||||||
requestsFee: string;
|
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. */
|
/** The SwitchboardWallet that will handle pre-funding rewards paid out to function runners. */
|
||||||
escrowWallet: string;
|
escrowWallet: string;
|
||||||
/** The escrow_wallet TokenAccount that handles pre-funding rewards paid out to function runners. */
|
/** The escrow_wallet TokenAccount that handles pre-funding rewards paid out to function runners. */
|
||||||
|
@ -157,8 +175,6 @@ export interface FunctionAccountDataJSON {
|
||||||
rewardEscrowWallet: string;
|
rewardEscrowWallet: string;
|
||||||
/** The reward_escrow_wallet TokenAccount used to acrue rewards from requests made with custom parameters. */
|
/** The reward_escrow_wallet TokenAccount used to acrue rewards from requests made with custom parameters. */
|
||||||
rewardEscrowTokenWallet: string;
|
rewardEscrowTokenWallet: string;
|
||||||
/** The unix timestamp when the function was created. */
|
|
||||||
createdAt: string;
|
|
||||||
/** Reserved. */
|
/** Reserved. */
|
||||||
ebuf: Array<number>;
|
ebuf: Array<number>;
|
||||||
}
|
}
|
||||||
|
@ -171,20 +187,34 @@ export class FunctionAccountData {
|
||||||
/** The function permissions granted by the attestation_queue.authority */
|
/** The function permissions granted by the attestation_queue.authority */
|
||||||
readonly permissions: number;
|
readonly permissions: number;
|
||||||
readonly status: types.FunctionStatusKind;
|
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. */
|
/** The name of the function for easier identification. */
|
||||||
readonly name: Array<number>;
|
readonly name: Array<number>;
|
||||||
/** The metadata of the function for easier identification. */
|
/** The metadata of the function for easier identification. */
|
||||||
readonly metadata: Array<number>;
|
readonly metadata: Array<number>;
|
||||||
/** The Solana slot when the function was created. (PDA) */
|
/** The Solana slot when the function was created. (PDA) */
|
||||||
readonly createdAtSlot: BN;
|
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. */
|
/** The unix timestamp when the function config (container, registry, version, or schedule) was changed. */
|
||||||
readonly updatedAt: BN;
|
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. */
|
/** The off-chain registry to fetch the function container from. */
|
||||||
readonly containerRegistry: Array<number>;
|
readonly containerRegistry: Array<number>;
|
||||||
/** The identifier of the container in the given container_registry. */
|
/** The identifier of the container in the given container_registry. */
|
||||||
readonly container: Array<number>;
|
readonly container: Array<number>;
|
||||||
/** The version tag of the container to pull. */
|
/** The version tag of the container to pull. */
|
||||||
readonly version: Array<number>;
|
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. */
|
/** The authority of the function which is authorized to make account changes. */
|
||||||
readonly authority: PublicKey;
|
readonly authority: PublicKey;
|
||||||
/** The address of the AttestationQueueAccountData that will be processing function requests and verifying the function measurements. */
|
/** 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;
|
readonly nextAllowedTimestamp: BN;
|
||||||
/** The number of times to trigger the function upon the next invocation. */
|
/** The number of times to trigger the function upon the next invocation. */
|
||||||
readonly triggerCount: BN;
|
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. */
|
/** UNUSED. The unix timestamp when the current permissions expire. */
|
||||||
readonly permissionExpiration: BN;
|
readonly permissionExpiration: BN;
|
||||||
/** Number of requests created for this function. Used to prevent closing when there are live requests. */
|
/** 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;
|
readonly requestsDefaultSlotsUntilExpiration: BN;
|
||||||
/** The lamports paid to the FunctionAccount escrow on each successful update request. */
|
/** The lamports paid to the FunctionAccount escrow on each successful update request. */
|
||||||
readonly requestsFee: BN;
|
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. */
|
/** The SwitchboardWallet that will handle pre-funding rewards paid out to function runners. */
|
||||||
readonly escrowWallet: PublicKey;
|
readonly escrowWallet: PublicKey;
|
||||||
/** The escrow_wallet TokenAccount that handles pre-funding rewards paid out to function runners. */
|
/** The escrow_wallet TokenAccount that handles pre-funding rewards paid out to function runners. */
|
||||||
|
@ -236,8 +262,6 @@ export class FunctionAccountData {
|
||||||
readonly rewardEscrowWallet: PublicKey;
|
readonly rewardEscrowWallet: PublicKey;
|
||||||
/** The reward_escrow_wallet TokenAccount used to acrue rewards from requests made with custom parameters. */
|
/** The reward_escrow_wallet TokenAccount used to acrue rewards from requests made with custom parameters. */
|
||||||
readonly rewardEscrowTokenWallet: PublicKey;
|
readonly rewardEscrowTokenWallet: PublicKey;
|
||||||
/** The unix timestamp when the function was created. */
|
|
||||||
readonly createdAt: BN;
|
|
||||||
/** Reserved. */
|
/** Reserved. */
|
||||||
readonly ebuf: Array<number>;
|
readonly ebuf: Array<number>;
|
||||||
|
|
||||||
|
@ -250,13 +274,20 @@ export class FunctionAccountData {
|
||||||
borsh.u8("isTriggered"),
|
borsh.u8("isTriggered"),
|
||||||
borsh.u32("permissions"),
|
borsh.u32("permissions"),
|
||||||
types.FunctionStatus.layout("status"),
|
types.FunctionStatus.layout("status"),
|
||||||
|
borsh.u8("bump"),
|
||||||
|
borsh.array(borsh.u8(), 32, "creatorSeed"),
|
||||||
borsh.array(borsh.u8(), 64, "name"),
|
borsh.array(borsh.u8(), 64, "name"),
|
||||||
borsh.array(borsh.u8(), 256, "metadata"),
|
borsh.array(borsh.u8(), 256, "metadata"),
|
||||||
borsh.u64("createdAtSlot"),
|
borsh.u64("createdAtSlot"),
|
||||||
|
borsh.i64("createdAt"),
|
||||||
borsh.i64("updatedAt"),
|
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, "containerRegistry"),
|
||||||
borsh.array(borsh.u8(), 64, "container"),
|
borsh.array(borsh.u8(), 64, "container"),
|
||||||
borsh.array(borsh.u8(), 32, "version"),
|
borsh.array(borsh.u8(), 32, "version"),
|
||||||
|
borsh.array(borsh.u8(), 256, "paramsSchema"),
|
||||||
|
borsh.array(borsh.u8(), 256, "defaultContainerParams"),
|
||||||
borsh.publicKey("authority"),
|
borsh.publicKey("authority"),
|
||||||
borsh.publicKey("attestationQueue"),
|
borsh.publicKey("attestationQueue"),
|
||||||
borsh.u32("queueIdx"),
|
borsh.u32("queueIdx"),
|
||||||
|
@ -265,21 +296,18 @@ export class FunctionAccountData {
|
||||||
borsh.i64("lastExecutionTimestamp"),
|
borsh.i64("lastExecutionTimestamp"),
|
||||||
borsh.i64("nextAllowedTimestamp"),
|
borsh.i64("nextAllowedTimestamp"),
|
||||||
borsh.u64("triggerCount"),
|
borsh.u64("triggerCount"),
|
||||||
|
borsh.i64("triggeredSince"),
|
||||||
borsh.i64("permissionExpiration"),
|
borsh.i64("permissionExpiration"),
|
||||||
borsh.u64("numRequests"),
|
borsh.u64("numRequests"),
|
||||||
borsh.bool("requestsDisabled"),
|
borsh.bool("requestsDisabled"),
|
||||||
borsh.bool("requestsRequireAuthorization"),
|
borsh.bool("requestsRequireAuthorization"),
|
||||||
borsh.u64("requestsDefaultSlotsUntilExpiration"),
|
borsh.u64("requestsDefaultSlotsUntilExpiration"),
|
||||||
borsh.u64("requestsFee"),
|
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("escrowWallet"),
|
||||||
borsh.publicKey("escrowTokenWallet"),
|
borsh.publicKey("escrowTokenWallet"),
|
||||||
borsh.publicKey("rewardEscrowWallet"),
|
borsh.publicKey("rewardEscrowWallet"),
|
||||||
borsh.publicKey("rewardEscrowTokenWallet"),
|
borsh.publicKey("rewardEscrowTokenWallet"),
|
||||||
borsh.i64("createdAt"),
|
borsh.array(borsh.u8(), 1024, "ebuf"),
|
||||||
borsh.array(borsh.u8(), 871, "ebuf"),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
constructor(fields: FunctionAccountDataFields) {
|
constructor(fields: FunctionAccountDataFields) {
|
||||||
|
@ -287,13 +315,20 @@ export class FunctionAccountData {
|
||||||
this.isTriggered = fields.isTriggered;
|
this.isTriggered = fields.isTriggered;
|
||||||
this.permissions = fields.permissions;
|
this.permissions = fields.permissions;
|
||||||
this.status = fields.status;
|
this.status = fields.status;
|
||||||
|
this.bump = fields.bump;
|
||||||
|
this.creatorSeed = fields.creatorSeed;
|
||||||
this.name = fields.name;
|
this.name = fields.name;
|
||||||
this.metadata = fields.metadata;
|
this.metadata = fields.metadata;
|
||||||
this.createdAtSlot = fields.createdAtSlot;
|
this.createdAtSlot = fields.createdAtSlot;
|
||||||
|
this.createdAt = fields.createdAt;
|
||||||
this.updatedAt = fields.updatedAt;
|
this.updatedAt = fields.updatedAt;
|
||||||
|
this.enclave = new types.Quote({ ...fields.enclave });
|
||||||
|
this.mrEnclaves = fields.mrEnclaves;
|
||||||
this.containerRegistry = fields.containerRegistry;
|
this.containerRegistry = fields.containerRegistry;
|
||||||
this.container = fields.container;
|
this.container = fields.container;
|
||||||
this.version = fields.version;
|
this.version = fields.version;
|
||||||
|
this.paramsSchema = fields.paramsSchema;
|
||||||
|
this.defaultContainerParams = fields.defaultContainerParams;
|
||||||
this.authority = fields.authority;
|
this.authority = fields.authority;
|
||||||
this.attestationQueue = fields.attestationQueue;
|
this.attestationQueue = fields.attestationQueue;
|
||||||
this.queueIdx = fields.queueIdx;
|
this.queueIdx = fields.queueIdx;
|
||||||
|
@ -302,6 +337,7 @@ export class FunctionAccountData {
|
||||||
this.lastExecutionTimestamp = fields.lastExecutionTimestamp;
|
this.lastExecutionTimestamp = fields.lastExecutionTimestamp;
|
||||||
this.nextAllowedTimestamp = fields.nextAllowedTimestamp;
|
this.nextAllowedTimestamp = fields.nextAllowedTimestamp;
|
||||||
this.triggerCount = fields.triggerCount;
|
this.triggerCount = fields.triggerCount;
|
||||||
|
this.triggeredSince = fields.triggeredSince;
|
||||||
this.permissionExpiration = fields.permissionExpiration;
|
this.permissionExpiration = fields.permissionExpiration;
|
||||||
this.numRequests = fields.numRequests;
|
this.numRequests = fields.numRequests;
|
||||||
this.requestsDisabled = fields.requestsDisabled;
|
this.requestsDisabled = fields.requestsDisabled;
|
||||||
|
@ -309,27 +345,24 @@ export class FunctionAccountData {
|
||||||
this.requestsDefaultSlotsUntilExpiration =
|
this.requestsDefaultSlotsUntilExpiration =
|
||||||
fields.requestsDefaultSlotsUntilExpiration;
|
fields.requestsDefaultSlotsUntilExpiration;
|
||||||
this.requestsFee = fields.requestsFee;
|
this.requestsFee = fields.requestsFee;
|
||||||
this.mrEnclaves = fields.mrEnclaves;
|
|
||||||
this.bump = fields.bump;
|
|
||||||
this.creatorSeed = fields.creatorSeed;
|
|
||||||
this.escrowWallet = fields.escrowWallet;
|
this.escrowWallet = fields.escrowWallet;
|
||||||
this.escrowTokenWallet = fields.escrowTokenWallet;
|
this.escrowTokenWallet = fields.escrowTokenWallet;
|
||||||
this.rewardEscrowWallet = fields.rewardEscrowWallet;
|
this.rewardEscrowWallet = fields.rewardEscrowWallet;
|
||||||
this.rewardEscrowTokenWallet = fields.rewardEscrowTokenWallet;
|
this.rewardEscrowTokenWallet = fields.rewardEscrowTokenWallet;
|
||||||
this.createdAt = fields.createdAt;
|
|
||||||
this.ebuf = fields.ebuf;
|
this.ebuf = fields.ebuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async fetch(
|
static async fetch(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
address: PublicKey
|
address: PublicKey,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
): Promise<FunctionAccountData | null> {
|
): Promise<FunctionAccountData | null> {
|
||||||
const info = await program.connection.getAccountInfo(address);
|
const info = await program.connection.getAccountInfo(address);
|
||||||
|
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +371,8 @@ export class FunctionAccountData {
|
||||||
|
|
||||||
static async fetchMultiple(
|
static async fetchMultiple(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
addresses: PublicKey[]
|
addresses: PublicKey[],
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
): Promise<Array<FunctionAccountData | null>> {
|
): Promise<Array<FunctionAccountData | null>> {
|
||||||
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
||||||
|
|
||||||
|
@ -346,7 +380,7 @@ export class FunctionAccountData {
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,13 +400,20 @@ export class FunctionAccountData {
|
||||||
isTriggered: dec.isTriggered,
|
isTriggered: dec.isTriggered,
|
||||||
permissions: dec.permissions,
|
permissions: dec.permissions,
|
||||||
status: types.FunctionStatus.fromDecoded(dec.status),
|
status: types.FunctionStatus.fromDecoded(dec.status),
|
||||||
|
bump: dec.bump,
|
||||||
|
creatorSeed: dec.creatorSeed,
|
||||||
name: dec.name,
|
name: dec.name,
|
||||||
metadata: dec.metadata,
|
metadata: dec.metadata,
|
||||||
createdAtSlot: dec.createdAtSlot,
|
createdAtSlot: dec.createdAtSlot,
|
||||||
|
createdAt: dec.createdAt,
|
||||||
updatedAt: dec.updatedAt,
|
updatedAt: dec.updatedAt,
|
||||||
|
enclave: types.Quote.fromDecoded(dec.enclave),
|
||||||
|
mrEnclaves: dec.mrEnclaves,
|
||||||
containerRegistry: dec.containerRegistry,
|
containerRegistry: dec.containerRegistry,
|
||||||
container: dec.container,
|
container: dec.container,
|
||||||
version: dec.version,
|
version: dec.version,
|
||||||
|
paramsSchema: dec.paramsSchema,
|
||||||
|
defaultContainerParams: dec.defaultContainerParams,
|
||||||
authority: dec.authority,
|
authority: dec.authority,
|
||||||
attestationQueue: dec.attestationQueue,
|
attestationQueue: dec.attestationQueue,
|
||||||
queueIdx: dec.queueIdx,
|
queueIdx: dec.queueIdx,
|
||||||
|
@ -381,6 +422,7 @@ export class FunctionAccountData {
|
||||||
lastExecutionTimestamp: dec.lastExecutionTimestamp,
|
lastExecutionTimestamp: dec.lastExecutionTimestamp,
|
||||||
nextAllowedTimestamp: dec.nextAllowedTimestamp,
|
nextAllowedTimestamp: dec.nextAllowedTimestamp,
|
||||||
triggerCount: dec.triggerCount,
|
triggerCount: dec.triggerCount,
|
||||||
|
triggeredSince: dec.triggeredSince,
|
||||||
permissionExpiration: dec.permissionExpiration,
|
permissionExpiration: dec.permissionExpiration,
|
||||||
numRequests: dec.numRequests,
|
numRequests: dec.numRequests,
|
||||||
requestsDisabled: dec.requestsDisabled,
|
requestsDisabled: dec.requestsDisabled,
|
||||||
|
@ -388,14 +430,10 @@ export class FunctionAccountData {
|
||||||
requestsDefaultSlotsUntilExpiration:
|
requestsDefaultSlotsUntilExpiration:
|
||||||
dec.requestsDefaultSlotsUntilExpiration,
|
dec.requestsDefaultSlotsUntilExpiration,
|
||||||
requestsFee: dec.requestsFee,
|
requestsFee: dec.requestsFee,
|
||||||
mrEnclaves: dec.mrEnclaves,
|
|
||||||
bump: dec.bump,
|
|
||||||
creatorSeed: dec.creatorSeed,
|
|
||||||
escrowWallet: dec.escrowWallet,
|
escrowWallet: dec.escrowWallet,
|
||||||
escrowTokenWallet: dec.escrowTokenWallet,
|
escrowTokenWallet: dec.escrowTokenWallet,
|
||||||
rewardEscrowWallet: dec.rewardEscrowWallet,
|
rewardEscrowWallet: dec.rewardEscrowWallet,
|
||||||
rewardEscrowTokenWallet: dec.rewardEscrowTokenWallet,
|
rewardEscrowTokenWallet: dec.rewardEscrowTokenWallet,
|
||||||
createdAt: dec.createdAt,
|
|
||||||
ebuf: dec.ebuf,
|
ebuf: dec.ebuf,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -406,13 +444,20 @@ export class FunctionAccountData {
|
||||||
isTriggered: this.isTriggered,
|
isTriggered: this.isTriggered,
|
||||||
permissions: this.permissions,
|
permissions: this.permissions,
|
||||||
status: this.status.toJSON(),
|
status: this.status.toJSON(),
|
||||||
|
bump: this.bump,
|
||||||
|
creatorSeed: this.creatorSeed,
|
||||||
name: this.name,
|
name: this.name,
|
||||||
metadata: this.metadata,
|
metadata: this.metadata,
|
||||||
createdAtSlot: this.createdAtSlot.toString(),
|
createdAtSlot: this.createdAtSlot.toString(),
|
||||||
|
createdAt: this.createdAt.toString(),
|
||||||
updatedAt: this.updatedAt.toString(),
|
updatedAt: this.updatedAt.toString(),
|
||||||
|
enclave: this.enclave.toJSON(),
|
||||||
|
mrEnclaves: this.mrEnclaves,
|
||||||
containerRegistry: this.containerRegistry,
|
containerRegistry: this.containerRegistry,
|
||||||
container: this.container,
|
container: this.container,
|
||||||
version: this.version,
|
version: this.version,
|
||||||
|
paramsSchema: this.paramsSchema,
|
||||||
|
defaultContainerParams: this.defaultContainerParams,
|
||||||
authority: this.authority.toString(),
|
authority: this.authority.toString(),
|
||||||
attestationQueue: this.attestationQueue.toString(),
|
attestationQueue: this.attestationQueue.toString(),
|
||||||
queueIdx: this.queueIdx,
|
queueIdx: this.queueIdx,
|
||||||
|
@ -421,6 +466,7 @@ export class FunctionAccountData {
|
||||||
lastExecutionTimestamp: this.lastExecutionTimestamp.toString(),
|
lastExecutionTimestamp: this.lastExecutionTimestamp.toString(),
|
||||||
nextAllowedTimestamp: this.nextAllowedTimestamp.toString(),
|
nextAllowedTimestamp: this.nextAllowedTimestamp.toString(),
|
||||||
triggerCount: this.triggerCount.toString(),
|
triggerCount: this.triggerCount.toString(),
|
||||||
|
triggeredSince: this.triggeredSince.toString(),
|
||||||
permissionExpiration: this.permissionExpiration.toString(),
|
permissionExpiration: this.permissionExpiration.toString(),
|
||||||
numRequests: this.numRequests.toString(),
|
numRequests: this.numRequests.toString(),
|
||||||
requestsDisabled: this.requestsDisabled,
|
requestsDisabled: this.requestsDisabled,
|
||||||
|
@ -428,14 +474,10 @@ export class FunctionAccountData {
|
||||||
requestsDefaultSlotsUntilExpiration:
|
requestsDefaultSlotsUntilExpiration:
|
||||||
this.requestsDefaultSlotsUntilExpiration.toString(),
|
this.requestsDefaultSlotsUntilExpiration.toString(),
|
||||||
requestsFee: this.requestsFee.toString(),
|
requestsFee: this.requestsFee.toString(),
|
||||||
mrEnclaves: this.mrEnclaves,
|
|
||||||
bump: this.bump,
|
|
||||||
creatorSeed: this.creatorSeed,
|
|
||||||
escrowWallet: this.escrowWallet.toString(),
|
escrowWallet: this.escrowWallet.toString(),
|
||||||
escrowTokenWallet: this.escrowTokenWallet.toString(),
|
escrowTokenWallet: this.escrowTokenWallet.toString(),
|
||||||
rewardEscrowWallet: this.rewardEscrowWallet.toString(),
|
rewardEscrowWallet: this.rewardEscrowWallet.toString(),
|
||||||
rewardEscrowTokenWallet: this.rewardEscrowTokenWallet.toString(),
|
rewardEscrowTokenWallet: this.rewardEscrowTokenWallet.toString(),
|
||||||
createdAt: this.createdAt.toString(),
|
|
||||||
ebuf: this.ebuf,
|
ebuf: this.ebuf,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -446,13 +488,20 @@ export class FunctionAccountData {
|
||||||
isTriggered: obj.isTriggered,
|
isTriggered: obj.isTriggered,
|
||||||
permissions: obj.permissions,
|
permissions: obj.permissions,
|
||||||
status: types.FunctionStatus.fromJSON(obj.status),
|
status: types.FunctionStatus.fromJSON(obj.status),
|
||||||
|
bump: obj.bump,
|
||||||
|
creatorSeed: obj.creatorSeed,
|
||||||
name: obj.name,
|
name: obj.name,
|
||||||
metadata: obj.metadata,
|
metadata: obj.metadata,
|
||||||
createdAtSlot: new BN(obj.createdAtSlot),
|
createdAtSlot: new BN(obj.createdAtSlot),
|
||||||
|
createdAt: new BN(obj.createdAt),
|
||||||
updatedAt: new BN(obj.updatedAt),
|
updatedAt: new BN(obj.updatedAt),
|
||||||
|
enclave: types.Quote.fromJSON(obj.enclave),
|
||||||
|
mrEnclaves: obj.mrEnclaves,
|
||||||
containerRegistry: obj.containerRegistry,
|
containerRegistry: obj.containerRegistry,
|
||||||
container: obj.container,
|
container: obj.container,
|
||||||
version: obj.version,
|
version: obj.version,
|
||||||
|
paramsSchema: obj.paramsSchema,
|
||||||
|
defaultContainerParams: obj.defaultContainerParams,
|
||||||
authority: new PublicKey(obj.authority),
|
authority: new PublicKey(obj.authority),
|
||||||
attestationQueue: new PublicKey(obj.attestationQueue),
|
attestationQueue: new PublicKey(obj.attestationQueue),
|
||||||
queueIdx: obj.queueIdx,
|
queueIdx: obj.queueIdx,
|
||||||
|
@ -461,6 +510,7 @@ export class FunctionAccountData {
|
||||||
lastExecutionTimestamp: new BN(obj.lastExecutionTimestamp),
|
lastExecutionTimestamp: new BN(obj.lastExecutionTimestamp),
|
||||||
nextAllowedTimestamp: new BN(obj.nextAllowedTimestamp),
|
nextAllowedTimestamp: new BN(obj.nextAllowedTimestamp),
|
||||||
triggerCount: new BN(obj.triggerCount),
|
triggerCount: new BN(obj.triggerCount),
|
||||||
|
triggeredSince: new BN(obj.triggeredSince),
|
||||||
permissionExpiration: new BN(obj.permissionExpiration),
|
permissionExpiration: new BN(obj.permissionExpiration),
|
||||||
numRequests: new BN(obj.numRequests),
|
numRequests: new BN(obj.numRequests),
|
||||||
requestsDisabled: obj.requestsDisabled,
|
requestsDisabled: obj.requestsDisabled,
|
||||||
|
@ -469,14 +519,10 @@ export class FunctionAccountData {
|
||||||
obj.requestsDefaultSlotsUntilExpiration
|
obj.requestsDefaultSlotsUntilExpiration
|
||||||
),
|
),
|
||||||
requestsFee: new BN(obj.requestsFee),
|
requestsFee: new BN(obj.requestsFee),
|
||||||
mrEnclaves: obj.mrEnclaves,
|
|
||||||
bump: obj.bump,
|
|
||||||
creatorSeed: obj.creatorSeed,
|
|
||||||
escrowWallet: new PublicKey(obj.escrowWallet),
|
escrowWallet: new PublicKey(obj.escrowWallet),
|
||||||
escrowTokenWallet: new PublicKey(obj.escrowTokenWallet),
|
escrowTokenWallet: new PublicKey(obj.escrowTokenWallet),
|
||||||
rewardEscrowWallet: new PublicKey(obj.rewardEscrowWallet),
|
rewardEscrowWallet: new PublicKey(obj.rewardEscrowWallet),
|
||||||
rewardEscrowTokenWallet: new PublicKey(obj.rewardEscrowTokenWallet),
|
rewardEscrowTokenWallet: new PublicKey(obj.rewardEscrowTokenWallet),
|
||||||
createdAt: new BN(obj.createdAt),
|
|
||||||
ebuf: obj.ebuf,
|
ebuf: obj.ebuf,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
@ -158,14 +158,15 @@ export class FunctionRequestAccountData {
|
||||||
|
|
||||||
static async fetch(
|
static async fetch(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
address: PublicKey
|
address: PublicKey,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
): Promise<FunctionRequestAccountData | null> {
|
): Promise<FunctionRequestAccountData | null> {
|
||||||
const info = await program.connection.getAccountInfo(address);
|
const info = await program.connection.getAccountInfo(address);
|
||||||
|
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +175,8 @@ export class FunctionRequestAccountData {
|
||||||
|
|
||||||
static async fetchMultiple(
|
static async fetchMultiple(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
addresses: PublicKey[]
|
addresses: PublicKey[],
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
): Promise<Array<FunctionRequestAccountData | null>> {
|
): Promise<Array<FunctionRequestAccountData | null>> {
|
||||||
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
||||||
|
|
||||||
|
@ -182,7 +184,7 @@ export class FunctionRequestAccountData {
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
@ -86,14 +86,15 @@ export class SwitchboardWallet {
|
||||||
|
|
||||||
static async fetch(
|
static async fetch(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
address: PublicKey
|
address: PublicKey,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
): Promise<SwitchboardWallet | null> {
|
): Promise<SwitchboardWallet | null> {
|
||||||
const info = await program.connection.getAccountInfo(address);
|
const info = await program.connection.getAccountInfo(address);
|
||||||
|
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +103,8 @@ export class SwitchboardWallet {
|
||||||
|
|
||||||
static async fetchMultiple(
|
static async fetchMultiple(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
addresses: PublicKey[]
|
addresses: PublicKey[],
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
): Promise<Array<SwitchboardWallet | null>> {
|
): Promise<Array<SwitchboardWallet | null>> {
|
||||||
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
||||||
|
|
||||||
|
@ -110,7 +112,7 @@ export class SwitchboardWallet {
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import { Connection, PublicKey } from "@solana/web3.js";
|
import { Connection, PublicKey } from "@solana/web3.js";
|
||||||
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface EnclaveAccountDataFields {
|
export interface VerifierAccountDataFields {
|
||||||
/** The address of the signer generated within an enclave. */
|
/** Represents the state of the quote verifiers enclave. */
|
||||||
enclaveSigner: PublicKey;
|
enclave: types.QuoteFields;
|
||||||
/** The authority of the EnclaveAccount which is permitted to make account changes. */
|
/** The authority of the EnclaveAccount which is permitted to make account changes. */
|
||||||
authority: PublicKey;
|
authority: PublicKey;
|
||||||
/** Queue used for attestation to verify a MRENCLAVE measurement. */
|
/** Queue used for attestation to verify a MRENCLAVE measurement. */
|
||||||
attestationQueue: PublicKey;
|
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. */
|
/** The unix timestamp when the quote was created. */
|
||||||
createdAt: BN;
|
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. */
|
/** Whether the quote is located on the AttestationQueues buffer. */
|
||||||
isOnQueue: boolean;
|
isOnQueue: boolean;
|
||||||
/** The last time the quote heartbeated on-chain. */
|
/** The last time the quote heartbeated on-chain. */
|
||||||
lastHeartbeat: BN;
|
lastHeartbeat: BN;
|
||||||
/** The PDA bump. Only set for FunctionAccount quotes. */
|
|
||||||
bump: number;
|
|
||||||
/**
|
/**
|
||||||
* The SwitchboardWallet account containing the reward escrow for verifying quotes on-chain.
|
* 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.
|
* 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>;
|
ebuf: Array<number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EnclaveAccountDataJSON {
|
export interface VerifierAccountDataJSON {
|
||||||
/** The address of the signer generated within an enclave. */
|
/** Represents the state of the quote verifiers enclave. */
|
||||||
enclaveSigner: string;
|
enclave: types.QuoteJSON;
|
||||||
/** The authority of the EnclaveAccount which is permitted to make account changes. */
|
/** The authority of the EnclaveAccount which is permitted to make account changes. */
|
||||||
authority: string;
|
authority: string;
|
||||||
/** Queue used for attestation to verify a MRENCLAVE measurement. */
|
/** Queue used for attestation to verify a MRENCLAVE measurement. */
|
||||||
attestationQueue: string;
|
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. */
|
/** The unix timestamp when the quote was created. */
|
||||||
createdAt: string;
|
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. */
|
/** Whether the quote is located on the AttestationQueues buffer. */
|
||||||
isOnQueue: boolean;
|
isOnQueue: boolean;
|
||||||
/** The last time the quote heartbeated on-chain. */
|
/** The last time the quote heartbeated on-chain. */
|
||||||
lastHeartbeat: string;
|
lastHeartbeat: string;
|
||||||
/** The PDA bump. Only set for FunctionAccount quotes. */
|
|
||||||
bump: number;
|
|
||||||
/**
|
/**
|
||||||
* The SwitchboardWallet account containing the reward escrow for verifying quotes on-chain.
|
* 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.
|
* 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>;
|
ebuf: Array<number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class EnclaveAccountData {
|
export class VerifierAccountData {
|
||||||
/** The address of the signer generated within an enclave. */
|
/** Represents the state of the quote verifiers enclave. */
|
||||||
readonly enclaveSigner: PublicKey;
|
readonly enclave: types.Quote;
|
||||||
/** The authority of the EnclaveAccount which is permitted to make account changes. */
|
/** The authority of the EnclaveAccount which is permitted to make account changes. */
|
||||||
readonly authority: PublicKey;
|
readonly authority: PublicKey;
|
||||||
/** Queue used for attestation to verify a MRENCLAVE measurement. */
|
/** Queue used for attestation to verify a MRENCLAVE measurement. */
|
||||||
readonly attestationQueue: PublicKey;
|
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. */
|
/** The unix timestamp when the quote was created. */
|
||||||
readonly createdAt: BN;
|
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. */
|
/** Whether the quote is located on the AttestationQueues buffer. */
|
||||||
readonly isOnQueue: boolean;
|
readonly isOnQueue: boolean;
|
||||||
/** The last time the quote heartbeated on-chain. */
|
/** The last time the quote heartbeated on-chain. */
|
||||||
readonly lastHeartbeat: BN;
|
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.
|
* 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.
|
* 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>;
|
readonly ebuf: Array<number>;
|
||||||
|
|
||||||
static readonly discriminator = Buffer.from([
|
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([
|
static readonly layout = borsh.struct([
|
||||||
borsh.publicKey("enclaveSigner"),
|
types.Quote.layout("enclave"),
|
||||||
borsh.publicKey("authority"),
|
borsh.publicKey("authority"),
|
||||||
borsh.publicKey("attestationQueue"),
|
borsh.publicKey("attestationQueue"),
|
||||||
borsh.array(borsh.u8(), 32, "mrEnclave"),
|
|
||||||
borsh.u8("verificationStatus"),
|
|
||||||
borsh.i64("verificationTimestamp"),
|
|
||||||
borsh.i64("validUntil"),
|
|
||||||
borsh.i64("createdAt"),
|
borsh.i64("createdAt"),
|
||||||
borsh.array(borsh.u8(), 32, "quoteRegistry"),
|
|
||||||
borsh.array(borsh.u8(), 64, "registryKey"),
|
|
||||||
borsh.bool("isOnQueue"),
|
borsh.bool("isOnQueue"),
|
||||||
borsh.i64("lastHeartbeat"),
|
borsh.i64("lastHeartbeat"),
|
||||||
borsh.u8("bump"),
|
|
||||||
borsh.publicKey("rewardEscrow"),
|
borsh.publicKey("rewardEscrow"),
|
||||||
borsh.publicKey("stakeWallet"),
|
borsh.publicKey("stakeWallet"),
|
||||||
borsh.array(borsh.u8(), 928, "ebuf"),
|
borsh.array(borsh.u8(), 1024, "ebuf"),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
constructor(fields: EnclaveAccountDataFields) {
|
constructor(fields: VerifierAccountDataFields) {
|
||||||
this.enclaveSigner = fields.enclaveSigner;
|
this.enclave = new types.Quote({ ...fields.enclave });
|
||||||
this.authority = fields.authority;
|
this.authority = fields.authority;
|
||||||
this.attestationQueue = fields.attestationQueue;
|
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.createdAt = fields.createdAt;
|
||||||
this.quoteRegistry = fields.quoteRegistry;
|
|
||||||
this.registryKey = fields.registryKey;
|
|
||||||
this.isOnQueue = fields.isOnQueue;
|
this.isOnQueue = fields.isOnQueue;
|
||||||
this.lastHeartbeat = fields.lastHeartbeat;
|
this.lastHeartbeat = fields.lastHeartbeat;
|
||||||
this.bump = fields.bump;
|
|
||||||
this.rewardEscrow = fields.rewardEscrow;
|
this.rewardEscrow = fields.rewardEscrow;
|
||||||
this.stakeWallet = fields.stakeWallet;
|
this.stakeWallet = fields.stakeWallet;
|
||||||
this.ebuf = fields.ebuf;
|
this.ebuf = fields.ebuf;
|
||||||
|
@ -171,14 +115,15 @@ export class EnclaveAccountData {
|
||||||
|
|
||||||
static async fetch(
|
static async fetch(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
address: PublicKey
|
address: PublicKey,
|
||||||
): Promise<EnclaveAccountData | null> {
|
programId: PublicKey = program.attestationProgramId
|
||||||
|
): Promise<VerifierAccountData | null> {
|
||||||
const info = await program.connection.getAccountInfo(address);
|
const info = await program.connection.getAccountInfo(address);
|
||||||
|
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,15 +132,16 @@ export class EnclaveAccountData {
|
||||||
|
|
||||||
static async fetchMultiple(
|
static async fetchMultiple(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
addresses: PublicKey[]
|
addresses: PublicKey[],
|
||||||
): Promise<Array<EnclaveAccountData | null>> {
|
programId: PublicKey = program.attestationProgramId
|
||||||
|
): Promise<Array<VerifierAccountData | null>> {
|
||||||
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
const infos = await program.connection.getMultipleAccountsInfo(addresses);
|
||||||
|
|
||||||
return infos.map((info) => {
|
return infos.map((info) => {
|
||||||
if (info === null) {
|
if (info === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!info.owner.equals(program.attestationProgramId)) {
|
if (!info.owner.equals(programId)) {
|
||||||
throw new Error("account doesn't belong to this program");
|
throw new Error("account doesn't belong to this program");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,69 +149,48 @@ export class EnclaveAccountData {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static decode(data: Buffer): EnclaveAccountData {
|
static decode(data: Buffer): VerifierAccountData {
|
||||||
if (!data.slice(0, 8).equals(EnclaveAccountData.discriminator)) {
|
if (!data.slice(0, 8).equals(VerifierAccountData.discriminator)) {
|
||||||
throw new Error("invalid account 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({
|
return new VerifierAccountData({
|
||||||
enclaveSigner: dec.enclaveSigner,
|
enclave: types.Quote.fromDecoded(dec.enclave),
|
||||||
authority: dec.authority,
|
authority: dec.authority,
|
||||||
attestationQueue: dec.attestationQueue,
|
attestationQueue: dec.attestationQueue,
|
||||||
mrEnclave: dec.mrEnclave,
|
|
||||||
verificationStatus: dec.verificationStatus,
|
|
||||||
verificationTimestamp: dec.verificationTimestamp,
|
|
||||||
validUntil: dec.validUntil,
|
|
||||||
createdAt: dec.createdAt,
|
createdAt: dec.createdAt,
|
||||||
quoteRegistry: dec.quoteRegistry,
|
|
||||||
registryKey: dec.registryKey,
|
|
||||||
isOnQueue: dec.isOnQueue,
|
isOnQueue: dec.isOnQueue,
|
||||||
lastHeartbeat: dec.lastHeartbeat,
|
lastHeartbeat: dec.lastHeartbeat,
|
||||||
bump: dec.bump,
|
|
||||||
rewardEscrow: dec.rewardEscrow,
|
rewardEscrow: dec.rewardEscrow,
|
||||||
stakeWallet: dec.stakeWallet,
|
stakeWallet: dec.stakeWallet,
|
||||||
ebuf: dec.ebuf,
|
ebuf: dec.ebuf,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
toJSON(): EnclaveAccountDataJSON {
|
toJSON(): VerifierAccountDataJSON {
|
||||||
return {
|
return {
|
||||||
enclaveSigner: this.enclaveSigner.toString(),
|
enclave: this.enclave.toJSON(),
|
||||||
authority: this.authority.toString(),
|
authority: this.authority.toString(),
|
||||||
attestationQueue: this.attestationQueue.toString(),
|
attestationQueue: this.attestationQueue.toString(),
|
||||||
mrEnclave: this.mrEnclave,
|
|
||||||
verificationStatus: this.verificationStatus,
|
|
||||||
verificationTimestamp: this.verificationTimestamp.toString(),
|
|
||||||
validUntil: this.validUntil.toString(),
|
|
||||||
createdAt: this.createdAt.toString(),
|
createdAt: this.createdAt.toString(),
|
||||||
quoteRegistry: this.quoteRegistry,
|
|
||||||
registryKey: this.registryKey,
|
|
||||||
isOnQueue: this.isOnQueue,
|
isOnQueue: this.isOnQueue,
|
||||||
lastHeartbeat: this.lastHeartbeat.toString(),
|
lastHeartbeat: this.lastHeartbeat.toString(),
|
||||||
bump: this.bump,
|
|
||||||
rewardEscrow: this.rewardEscrow.toString(),
|
rewardEscrow: this.rewardEscrow.toString(),
|
||||||
stakeWallet: this.stakeWallet.toString(),
|
stakeWallet: this.stakeWallet.toString(),
|
||||||
ebuf: this.ebuf,
|
ebuf: this.ebuf,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromJSON(obj: EnclaveAccountDataJSON): EnclaveAccountData {
|
static fromJSON(obj: VerifierAccountDataJSON): VerifierAccountData {
|
||||||
return new EnclaveAccountData({
|
return new VerifierAccountData({
|
||||||
enclaveSigner: new PublicKey(obj.enclaveSigner),
|
enclave: types.Quote.fromJSON(obj.enclave),
|
||||||
authority: new PublicKey(obj.authority),
|
authority: new PublicKey(obj.authority),
|
||||||
attestationQueue: new PublicKey(obj.attestationQueue),
|
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),
|
createdAt: new BN(obj.createdAt),
|
||||||
quoteRegistry: obj.quoteRegistry,
|
|
||||||
registryKey: obj.registryKey,
|
|
||||||
isOnQueue: obj.isOnQueue,
|
isOnQueue: obj.isOnQueue,
|
||||||
lastHeartbeat: new BN(obj.lastHeartbeat),
|
lastHeartbeat: new BN(obj.lastHeartbeat),
|
||||||
bump: obj.bump,
|
|
||||||
rewardEscrow: new PublicKey(obj.rewardEscrow),
|
rewardEscrow: new PublicKey(obj.rewardEscrow),
|
||||||
stakeWallet: new PublicKey(obj.stakeWallet),
|
stakeWallet: new PublicKey(obj.stakeWallet),
|
||||||
ebuf: obj.ebuf,
|
ebuf: obj.ebuf,
|
|
@ -13,11 +13,6 @@ export type {
|
||||||
AttestationQueueAccountDataJSON,
|
AttestationQueueAccountDataJSON,
|
||||||
} from "./AttestationQueueAccountData.js";
|
} from "./AttestationQueueAccountData.js";
|
||||||
export { AttestationQueueAccountData } from "./AttestationQueueAccountData.js";
|
export { AttestationQueueAccountData } from "./AttestationQueueAccountData.js";
|
||||||
export type {
|
|
||||||
EnclaveAccountDataFields,
|
|
||||||
EnclaveAccountDataJSON,
|
|
||||||
} from "./EnclaveAccountData.js";
|
|
||||||
export { EnclaveAccountData } from "./EnclaveAccountData.js";
|
|
||||||
export type {
|
export type {
|
||||||
FunctionAccountDataFields,
|
FunctionAccountDataFields,
|
||||||
FunctionAccountDataJSON,
|
FunctionAccountDataJSON,
|
||||||
|
@ -33,3 +28,8 @@ export type {
|
||||||
SwitchboardWalletJSON,
|
SwitchboardWalletJSON,
|
||||||
} from "./SwitchboardWallet.js";
|
} from "./SwitchboardWallet.js";
|
||||||
export { SwitchboardWallet } from "./SwitchboardWallet.js";
|
export { SwitchboardWallet } from "./SwitchboardWallet.js";
|
||||||
|
export type {
|
||||||
|
VerifierAccountDataFields,
|
||||||
|
VerifierAccountDataJSON,
|
||||||
|
} from "./VerifierAccountData.js";
|
||||||
|
export { VerifierAccountData } from "./VerifierAccountData.js";
|
||||||
|
|
|
@ -26,6 +26,7 @@ export type AnchorError =
|
||||||
| ConstraintMintFreezeAuthority
|
| ConstraintMintFreezeAuthority
|
||||||
| ConstraintMintDecimals
|
| ConstraintMintDecimals
|
||||||
| ConstraintSpace
|
| ConstraintSpace
|
||||||
|
| ConstraintAccountIsNone
|
||||||
| RequireViolated
|
| RequireViolated
|
||||||
| RequireEqViolated
|
| RequireEqViolated
|
||||||
| RequireKeysEqViolated
|
| RequireKeysEqViolated
|
||||||
|
@ -51,7 +52,6 @@ export type AnchorError =
|
||||||
| AccountSysvarMismatch
|
| AccountSysvarMismatch
|
||||||
| AccountReallocExceedsLimit
|
| AccountReallocExceedsLimit
|
||||||
| AccountDuplicateReallocs
|
| AccountDuplicateReallocs
|
||||||
| StateInvalidAddress
|
|
||||||
| DeclaredProgramIdMismatch
|
| DeclaredProgramIdMismatch
|
||||||
| Deprecated;
|
| Deprecated;
|
||||||
|
|
||||||
|
@ -139,10 +139,10 @@ export class ConstraintHasOne extends Error {
|
||||||
static readonly code = 2001;
|
static readonly code = 2001;
|
||||||
readonly code = 2001;
|
readonly code = 2001;
|
||||||
readonly name = "ConstraintHasOne";
|
readonly name = "ConstraintHasOne";
|
||||||
readonly msg = "A has_one constraint was violated";
|
readonly msg = "A has one constraint was violated";
|
||||||
|
|
||||||
constructor(readonly logs?: string[]) {
|
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;
|
static readonly code = 2008;
|
||||||
readonly code = 2008;
|
readonly code = 2008;
|
||||||
readonly name = "ConstraintState";
|
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[]) {
|
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 {
|
export class RequireViolated extends Error {
|
||||||
static readonly code = 2500;
|
static readonly code = 2500;
|
||||||
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 {
|
export class DeclaredProgramIdMismatch extends Error {
|
||||||
static readonly code = 4100;
|
static readonly code = 4100;
|
||||||
readonly code = 4100;
|
readonly code = 4100;
|
||||||
|
@ -715,6 +715,8 @@ export function fromCode(code: number, logs?: string[]): AnchorError | null {
|
||||||
return new ConstraintMintDecimals(logs);
|
return new ConstraintMintDecimals(logs);
|
||||||
case 2019:
|
case 2019:
|
||||||
return new ConstraintSpace(logs);
|
return new ConstraintSpace(logs);
|
||||||
|
case 2020:
|
||||||
|
return new ConstraintAccountIsNone(logs);
|
||||||
case 2500:
|
case 2500:
|
||||||
return new RequireViolated(logs);
|
return new RequireViolated(logs);
|
||||||
case 2501:
|
case 2501:
|
||||||
|
@ -765,8 +767,6 @@ export function fromCode(code: number, logs?: string[]): AnchorError | null {
|
||||||
return new AccountReallocExceedsLimit(logs);
|
return new AccountReallocExceedsLimit(logs);
|
||||||
case 3017:
|
case 3017:
|
||||||
return new AccountDuplicateReallocs(logs);
|
return new AccountDuplicateReallocs(logs);
|
||||||
case 4000:
|
|
||||||
return new StateInvalidAddress(logs);
|
|
||||||
case 4100:
|
case 4100:
|
||||||
return new DeclaredProgramIdMismatch(logs);
|
return new DeclaredProgramIdMismatch(logs);
|
||||||
case 5000:
|
case 5000:
|
||||||
|
|
|
@ -56,9 +56,10 @@ export class InvalidQuote extends Error {
|
||||||
static readonly code = 6001;
|
static readonly code = 6001;
|
||||||
readonly code = 6001;
|
readonly code = 6001;
|
||||||
readonly name = "InvalidQuote";
|
readonly name = "InvalidQuote";
|
||||||
|
readonly msg = "The provided enclave quote is invalid";
|
||||||
|
|
||||||
constructor(readonly logs?: string[]) {
|
constructor(readonly logs?: string[]) {
|
||||||
super("6001: ");
|
super("6001: The provided enclave quote is invalid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionOverrideCloseAccounts {
|
export interface AccountCloseOverrideAccounts {
|
||||||
|
enclave: PublicKey;
|
||||||
function: PublicKey;
|
function: PublicKey;
|
||||||
solDest: PublicKey;
|
solDest: PublicKey;
|
||||||
systemProgram: PublicKey;
|
systemProgram: PublicKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function functionOverrideClose(
|
export function accountCloseOverride(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
accounts: FunctionOverrideCloseAccounts
|
accounts: AccountCloseOverrideAccounts
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
|
{ pubkey: accounts.enclave, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.solDest, isSigner: false, isWritable: false },
|
{ pubkey: accounts.solDest, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.systemProgram, 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 data = identifier;
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({
|
||||||
keys,
|
keys,
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface AttestationPermissionInitArgs {
|
export interface AttestationPermissionInitArgs {
|
||||||
|
@ -29,7 +26,8 @@ export const layout = borsh.struct([
|
||||||
export function attestationPermissionInit(
|
export function attestationPermissionInit(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: AttestationPermissionInitArgs,
|
args: AttestationPermissionInitArgs,
|
||||||
accounts: AttestationPermissionInitAccounts
|
accounts: AttestationPermissionInitAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.permission, isSigner: false, isWritable: true },
|
{ pubkey: accounts.permission, isSigner: false, isWritable: true },
|
||||||
|
@ -48,10 +46,6 @@ export function attestationPermissionInit(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface AttestationPermissionSetArgs {
|
export interface AttestationPermissionSetArgs {
|
||||||
|
@ -17,7 +14,7 @@ export interface AttestationPermissionSetAccounts {
|
||||||
permission: PublicKey;
|
permission: PublicKey;
|
||||||
authority: PublicKey;
|
authority: PublicKey;
|
||||||
attestationQueue: PublicKey;
|
attestationQueue: PublicKey;
|
||||||
enclave: PublicKey;
|
grantee: PublicKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const layout = borsh.struct([
|
export const layout = borsh.struct([
|
||||||
|
@ -27,13 +24,14 @@ export const layout = borsh.struct([
|
||||||
export function attestationPermissionSet(
|
export function attestationPermissionSet(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: AttestationPermissionSetArgs,
|
args: AttestationPermissionSetArgs,
|
||||||
accounts: AttestationPermissionSetAccounts
|
accounts: AttestationPermissionSetAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.permission, isSigner: false, isWritable: true },
|
{ pubkey: accounts.permission, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.authority, isSigner: true, isWritable: false },
|
{ pubkey: accounts.authority, isSigner: true, isWritable: false },
|
||||||
{ pubkey: accounts.attestationQueue, isSigner: false, 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 identifier = Buffer.from([56, 253, 255, 201, 100, 153, 10, 76]);
|
||||||
const buffer = Buffer.alloc(1000);
|
const buffer = Buffer.alloc(1000);
|
||||||
|
@ -44,10 +42,6 @@ export function attestationPermissionSet(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface AttestationQueueAddMrEnclaveArgs {
|
export interface AttestationQueueAddMrEnclaveArgs {
|
||||||
|
@ -25,7 +22,8 @@ export const layout = borsh.struct([
|
||||||
export function attestationQueueAddMrEnclave(
|
export function attestationQueueAddMrEnclave(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: AttestationQueueAddMrEnclaveArgs,
|
args: AttestationQueueAddMrEnclaveArgs,
|
||||||
accounts: AttestationQueueAddMrEnclaveAccounts
|
accounts: AttestationQueueAddMrEnclaveAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.queue, isSigner: false, isWritable: true },
|
{ pubkey: accounts.queue, isSigner: false, isWritable: true },
|
||||||
|
@ -40,10 +38,6 @@ export function attestationQueueAddMrEnclave(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface AttestationQueueInitArgs {
|
export interface AttestationQueueInitArgs {
|
||||||
|
@ -27,7 +24,8 @@ export const layout = borsh.struct([
|
||||||
export function attestationQueueInit(
|
export function attestationQueueInit(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: AttestationQueueInitArgs,
|
args: AttestationQueueInitArgs,
|
||||||
accounts: AttestationQueueInitAccounts
|
accounts: AttestationQueueInitAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.queue, isSigner: true, isWritable: true },
|
{ pubkey: accounts.queue, isSigner: true, isWritable: true },
|
||||||
|
@ -44,10 +42,6 @@ export function attestationQueueInit(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface AttestationQueueRemoveMrEnclaveArgs {
|
export interface AttestationQueueRemoveMrEnclaveArgs {
|
||||||
|
@ -25,7 +22,8 @@ export const layout = borsh.struct([
|
||||||
export function attestationQueueRemoveMrEnclave(
|
export function attestationQueueRemoveMrEnclave(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: AttestationQueueRemoveMrEnclaveArgs,
|
args: AttestationQueueRemoveMrEnclaveArgs,
|
||||||
accounts: AttestationQueueRemoveMrEnclaveAccounts
|
accounts: AttestationQueueRemoveMrEnclaveAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.queue, isSigner: false, isWritable: true },
|
{ pubkey: accounts.queue, isSigner: false, isWritable: true },
|
||||||
|
@ -42,10 +40,6 @@ export function attestationQueueRemoveMrEnclave(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionCloseArgs {
|
export interface FunctionCloseArgs {
|
||||||
|
@ -20,7 +17,6 @@ export interface FunctionCloseAccounts {
|
||||||
escrowWallet: PublicKey;
|
escrowWallet: PublicKey;
|
||||||
solDest: PublicKey;
|
solDest: PublicKey;
|
||||||
escrowDest: PublicKey;
|
escrowDest: PublicKey;
|
||||||
state: PublicKey;
|
|
||||||
tokenProgram: PublicKey;
|
tokenProgram: PublicKey;
|
||||||
systemProgram: PublicKey;
|
systemProgram: PublicKey;
|
||||||
addressLookupProgram: PublicKey;
|
addressLookupProgram: PublicKey;
|
||||||
|
@ -33,7 +29,8 @@ export const layout = borsh.struct([
|
||||||
export function functionClose(
|
export function functionClose(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionCloseArgs,
|
args: FunctionCloseArgs,
|
||||||
accounts: FunctionCloseAccounts
|
accounts: FunctionCloseAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
||||||
|
@ -42,7 +39,6 @@ export function functionClose(
|
||||||
{ pubkey: accounts.escrowWallet, isSigner: false, isWritable: true },
|
{ pubkey: accounts.escrowWallet, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.solDest, isSigner: false, isWritable: false },
|
{ pubkey: accounts.solDest, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.escrowDest, isSigner: false, isWritable: true },
|
{ pubkey: accounts.escrowDest, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.state, isSigner: false, isWritable: false },
|
|
||||||
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
||||||
{
|
{
|
||||||
|
@ -60,10 +56,6 @@ export function functionClose(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionDeactivateLookupAccounts {
|
export interface FunctionDeactivateLookupAccounts {
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionExtendLookupArgs {
|
export interface FunctionExtendLookupArgs {
|
||||||
|
@ -29,7 +26,8 @@ export const layout = borsh.struct([
|
||||||
export function functionExtendLookup(
|
export function functionExtendLookup(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionExtendLookupArgs,
|
args: FunctionExtendLookupArgs,
|
||||||
accounts: FunctionExtendLookupAccounts
|
accounts: FunctionExtendLookupAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
||||||
|
@ -52,10 +50,6 @@ export function functionExtendLookup(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionInitArgs {
|
export interface FunctionInitArgs {
|
||||||
|
@ -17,13 +14,11 @@ export interface FunctionInitAccounts {
|
||||||
function: PublicKey;
|
function: PublicKey;
|
||||||
addressLookupTable: PublicKey;
|
addressLookupTable: PublicKey;
|
||||||
authority: PublicKey;
|
authority: PublicKey;
|
||||||
quote: PublicKey;
|
|
||||||
attestationQueue: PublicKey;
|
attestationQueue: PublicKey;
|
||||||
payer: PublicKey;
|
payer: PublicKey;
|
||||||
wallet: PublicKey;
|
wallet: PublicKey;
|
||||||
walletAuthority: PublicKey;
|
walletAuthority: PublicKey;
|
||||||
tokenWallet: PublicKey;
|
tokenWallet: PublicKey;
|
||||||
state: PublicKey;
|
|
||||||
mint: PublicKey;
|
mint: PublicKey;
|
||||||
tokenProgram: PublicKey;
|
tokenProgram: PublicKey;
|
||||||
associatedTokenProgram: PublicKey;
|
associatedTokenProgram: PublicKey;
|
||||||
|
@ -36,19 +31,18 @@ export const layout = borsh.struct([types.FunctionInitParams.layout("params")]);
|
||||||
export function functionInit(
|
export function functionInit(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionInitArgs,
|
args: FunctionInitArgs,
|
||||||
accounts: FunctionInitAccounts
|
accounts: FunctionInitAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.addressLookupTable, isSigner: false, isWritable: true },
|
{ pubkey: accounts.addressLookupTable, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.authority, isSigner: false, isWritable: false },
|
{ pubkey: accounts.authority, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.quote, isSigner: false, isWritable: true },
|
|
||||||
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: false },
|
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.payer, isSigner: true, isWritable: true },
|
{ pubkey: accounts.payer, isSigner: true, isWritable: true },
|
||||||
{ pubkey: accounts.wallet, isSigner: false, isWritable: true },
|
{ pubkey: accounts.wallet, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.walletAuthority, isSigner: true, isWritable: false },
|
{ pubkey: accounts.walletAuthority, isSigner: true, isWritable: false },
|
||||||
{ pubkey: accounts.tokenWallet, isSigner: false, isWritable: true },
|
{ pubkey: accounts.tokenWallet, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.state, isSigner: false, isWritable: false },
|
|
||||||
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
{ pubkey: accounts.mint, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
||||||
{
|
{
|
||||||
|
@ -72,10 +66,6 @@ export function functionInit(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionRequestCloseArgs {
|
export interface FunctionRequestCloseArgs {
|
||||||
|
@ -32,7 +29,8 @@ export const layout = borsh.struct([
|
||||||
export function functionRequestClose(
|
export function functionRequestClose(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionRequestCloseArgs,
|
args: FunctionRequestCloseArgs,
|
||||||
accounts: FunctionRequestCloseAccounts
|
accounts: FunctionRequestCloseAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.request, isSigner: false, isWritable: true },
|
{ pubkey: accounts.request, isSigner: false, isWritable: true },
|
||||||
|
@ -54,10 +52,6 @@ export function functionRequestClose(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionRequestInitArgs {
|
export interface FunctionRequestInitArgs {
|
||||||
|
@ -35,7 +32,8 @@ export const layout = borsh.struct([
|
||||||
export function functionRequestInit(
|
export function functionRequestInit(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionRequestInitArgs,
|
args: FunctionRequestInitArgs,
|
||||||
accounts: FunctionRequestInitAccounts
|
accounts: FunctionRequestInitAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.request, isSigner: true, isWritable: true },
|
{ pubkey: accounts.request, isSigner: true, isWritable: true },
|
||||||
|
@ -64,10 +62,6 @@ export function functionRequestInit(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionRequestInitAndTriggerArgs {
|
export interface FunctionRequestInitAndTriggerArgs {
|
||||||
|
@ -33,7 +30,8 @@ export const layout = borsh.struct([
|
||||||
export function functionRequestInitAndTrigger(
|
export function functionRequestInitAndTrigger(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionRequestInitAndTriggerArgs,
|
args: FunctionRequestInitAndTriggerArgs,
|
||||||
accounts: FunctionRequestInitAndTriggerAccounts
|
accounts: FunctionRequestInitAndTriggerAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.request, isSigner: true, isWritable: true },
|
{ pubkey: accounts.request, isSigner: true, isWritable: true },
|
||||||
|
@ -62,10 +60,6 @@ export function functionRequestInitAndTrigger(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionRequestSetConfigArgs {
|
export interface FunctionRequestSetConfigArgs {
|
||||||
|
@ -25,7 +22,8 @@ export const layout = borsh.struct([
|
||||||
export function functionRequestSetConfig(
|
export function functionRequestSetConfig(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionRequestSetConfigArgs,
|
args: FunctionRequestSetConfigArgs,
|
||||||
accounts: FunctionRequestSetConfigAccounts
|
accounts: FunctionRequestSetConfigAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.request, isSigner: false, isWritable: true },
|
{ pubkey: accounts.request, isSigner: false, isWritable: true },
|
||||||
|
@ -40,10 +38,6 @@ export function functionRequestSetConfig(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionRequestTriggerArgs {
|
export interface FunctionRequestTriggerArgs {
|
||||||
|
@ -32,7 +29,8 @@ export const layout = borsh.struct([
|
||||||
export function functionRequestTrigger(
|
export function functionRequestTrigger(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionRequestTriggerArgs,
|
args: FunctionRequestTriggerArgs,
|
||||||
accounts: FunctionRequestTriggerAccounts
|
accounts: FunctionRequestTriggerAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.request, isSigner: false, isWritable: true },
|
{ pubkey: accounts.request, isSigner: false, isWritable: true },
|
||||||
|
@ -54,10 +52,6 @@ export function functionRequestTrigger(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionRequestVerifyArgs {
|
export interface FunctionRequestVerifyArgs {
|
||||||
|
@ -35,7 +32,8 @@ export const layout = borsh.struct([
|
||||||
export function functionRequestVerify(
|
export function functionRequestVerify(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionRequestVerifyArgs,
|
args: FunctionRequestVerifyArgs,
|
||||||
accounts: FunctionRequestVerifyAccounts
|
accounts: FunctionRequestVerifyAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.request, isSigner: false, isWritable: true },
|
{ pubkey: accounts.request, isSigner: false, isWritable: true },
|
||||||
|
@ -68,10 +66,6 @@ export function functionRequestVerify(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionResetEscrowArgs {
|
export interface FunctionResetEscrowArgs {
|
||||||
|
@ -22,7 +19,6 @@ export interface FunctionResetEscrowAccounts {
|
||||||
defaultWallet: PublicKey;
|
defaultWallet: PublicKey;
|
||||||
tokenWallet: PublicKey;
|
tokenWallet: PublicKey;
|
||||||
payer: PublicKey;
|
payer: PublicKey;
|
||||||
state: PublicKey;
|
|
||||||
tokenProgram: PublicKey;
|
tokenProgram: PublicKey;
|
||||||
associatedTokenProgram: PublicKey;
|
associatedTokenProgram: PublicKey;
|
||||||
systemProgram: PublicKey;
|
systemProgram: PublicKey;
|
||||||
|
@ -35,7 +31,8 @@ export const layout = borsh.struct([
|
||||||
export function functionResetEscrow(
|
export function functionResetEscrow(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionResetEscrowArgs,
|
args: FunctionResetEscrowArgs,
|
||||||
accounts: FunctionResetEscrowAccounts
|
accounts: FunctionResetEscrowAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
||||||
|
@ -46,7 +43,6 @@ export function functionResetEscrow(
|
||||||
{ pubkey: accounts.defaultWallet, isSigner: false, isWritable: true },
|
{ pubkey: accounts.defaultWallet, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.tokenWallet, isSigner: false, isWritable: true },
|
{ pubkey: accounts.tokenWallet, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.payer, isSigner: true, 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.tokenProgram, isSigner: false, isWritable: false },
|
||||||
{
|
{
|
||||||
pubkey: accounts.associatedTokenProgram,
|
pubkey: accounts.associatedTokenProgram,
|
||||||
|
@ -64,10 +60,6 @@ export function functionResetEscrow(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionSetAuthorityArgs {
|
export interface FunctionSetAuthorityArgs {
|
||||||
|
@ -30,7 +27,8 @@ export const layout = borsh.struct([
|
||||||
export function functionSetAuthority(
|
export function functionSetAuthority(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionSetAuthorityArgs,
|
args: FunctionSetAuthorityArgs,
|
||||||
accounts: FunctionSetAuthorityAccounts
|
accounts: FunctionSetAuthorityAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
||||||
|
@ -50,10 +48,6 @@ export function functionSetAuthority(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionSetConfigArgs {
|
export interface FunctionSetConfigArgs {
|
||||||
|
@ -15,7 +12,6 @@ export interface FunctionSetConfigArgs {
|
||||||
|
|
||||||
export interface FunctionSetConfigAccounts {
|
export interface FunctionSetConfigAccounts {
|
||||||
function: PublicKey;
|
function: PublicKey;
|
||||||
quote: PublicKey;
|
|
||||||
authority: PublicKey;
|
authority: PublicKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,11 +22,11 @@ export const layout = borsh.struct([
|
||||||
export function functionSetConfig(
|
export function functionSetConfig(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionSetConfigArgs,
|
args: FunctionSetConfigArgs,
|
||||||
accounts: FunctionSetConfigAccounts
|
accounts: FunctionSetConfigAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.quote, isSigner: false, isWritable: true },
|
|
||||||
{ pubkey: accounts.authority, isSigner: true, isWritable: false },
|
{ pubkey: accounts.authority, isSigner: true, isWritable: false },
|
||||||
];
|
];
|
||||||
const identifier = Buffer.from([232, 132, 21, 251, 253, 189, 96, 94]);
|
const identifier = Buffer.from([232, 132, 21, 251, 253, 189, 96, 94]);
|
||||||
|
@ -42,10 +38,6 @@ export function functionSetConfig(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionSetEscrowArgs {
|
export interface FunctionSetEscrowArgs {
|
||||||
|
@ -31,7 +28,8 @@ export const layout = borsh.struct([
|
||||||
export function functionSetEscrow(
|
export function functionSetEscrow(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionSetEscrowArgs,
|
args: FunctionSetEscrowArgs,
|
||||||
accounts: FunctionSetEscrowAccounts
|
accounts: FunctionSetEscrowAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
||||||
|
@ -56,10 +54,6 @@ export function functionSetEscrow(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionTriggerArgs {
|
export interface FunctionTriggerArgs {
|
||||||
|
@ -26,7 +23,8 @@ export const layout = borsh.struct([
|
||||||
export function functionTrigger(
|
export function functionTrigger(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionTriggerArgs,
|
args: FunctionTriggerArgs,
|
||||||
accounts: FunctionTriggerAccounts
|
accounts: FunctionTriggerAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
||||||
|
@ -42,10 +40,6 @@ export function functionTrigger(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface FunctionVerifyArgs {
|
export interface FunctionVerifyArgs {
|
||||||
|
@ -15,16 +12,13 @@ export interface FunctionVerifyArgs {
|
||||||
|
|
||||||
export interface FunctionVerifyAccounts {
|
export interface FunctionVerifyAccounts {
|
||||||
function: PublicKey;
|
function: PublicKey;
|
||||||
authority: PublicKey;
|
|
||||||
functionEnclaveSigner: PublicKey;
|
functionEnclaveSigner: PublicKey;
|
||||||
fnQuote: PublicKey;
|
verifier: PublicKey;
|
||||||
verifierQuote: PublicKey;
|
verifierSigner: PublicKey;
|
||||||
verifierEnclaveSigner: PublicKey;
|
|
||||||
verifierPermission: PublicKey;
|
verifierPermission: PublicKey;
|
||||||
escrowWallet: PublicKey;
|
escrowWallet: PublicKey;
|
||||||
escrowTokenWallet: PublicKey;
|
escrowTokenWallet: PublicKey;
|
||||||
receiver: PublicKey;
|
receiver: PublicKey;
|
||||||
state: PublicKey;
|
|
||||||
attestationQueue: PublicKey;
|
attestationQueue: PublicKey;
|
||||||
tokenProgram: PublicKey;
|
tokenProgram: PublicKey;
|
||||||
}
|
}
|
||||||
|
@ -36,28 +30,22 @@ export const layout = borsh.struct([
|
||||||
export function functionVerify(
|
export function functionVerify(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: FunctionVerifyArgs,
|
args: FunctionVerifyArgs,
|
||||||
accounts: FunctionVerifyAccounts
|
accounts: FunctionVerifyAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
{ pubkey: accounts.function, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.authority, isSigner: false, isWritable: false },
|
|
||||||
{
|
{
|
||||||
pubkey: accounts.functionEnclaveSigner,
|
pubkey: accounts.functionEnclaveSigner,
|
||||||
isSigner: true,
|
isSigner: true,
|
||||||
isWritable: false,
|
isWritable: false,
|
||||||
},
|
},
|
||||||
{ pubkey: accounts.fnQuote, isSigner: false, isWritable: true },
|
{ pubkey: accounts.verifier, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.verifierQuote, isSigner: false, isWritable: false },
|
{ pubkey: accounts.verifierSigner, isSigner: true, isWritable: false },
|
||||||
{
|
|
||||||
pubkey: accounts.verifierEnclaveSigner,
|
|
||||||
isSigner: true,
|
|
||||||
isWritable: false,
|
|
||||||
},
|
|
||||||
{ pubkey: accounts.verifierPermission, isSigner: false, isWritable: false },
|
{ pubkey: accounts.verifierPermission, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.escrowWallet, isSigner: false, isWritable: false },
|
{ pubkey: accounts.escrowWallet, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.escrowTokenWallet, isSigner: false, isWritable: true },
|
{ pubkey: accounts.escrowTokenWallet, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.receiver, 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.attestationQueue, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
|
||||||
];
|
];
|
||||||
|
@ -70,10 +58,6 @@ export function functionVerify(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,19 +97,25 @@ export type {
|
||||||
FunctionVerifyArgs,
|
FunctionVerifyArgs,
|
||||||
} from "./functionVerify.js";
|
} from "./functionVerify.js";
|
||||||
export { functionVerify } 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 type { StateInitAccounts, StateInitArgs } from "./stateInit.js";
|
||||||
export { stateInit } 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 type { WalletCloseAccounts, WalletCloseArgs } from "./walletClose.js";
|
||||||
export { walletClose } from "./walletClose.js";
|
export { walletClose } from "./walletClose.js";
|
||||||
export type { WalletFundAccounts, WalletFundArgs } from "./walletFund.js";
|
export type { WalletFundAccounts, WalletFundArgs } from "./walletFund.js";
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface StateInitArgs {
|
export interface StateInitArgs {
|
||||||
|
@ -24,7 +21,8 @@ export const layout = borsh.struct([types.StateInitParams.layout("params")]);
|
||||||
export function stateInit(
|
export function stateInit(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: StateInitArgs,
|
args: StateInitArgs,
|
||||||
accounts: StateInitAccounts
|
accounts: StateInitAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.state, isSigner: false, isWritable: true },
|
{ pubkey: accounts.state, isSigner: false, isWritable: true },
|
||||||
|
@ -40,10 +38,6 @@ export function stateInit(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface QuoteHeartbeatArgs {
|
export interface VerifierHeartbeatArgs {
|
||||||
params: types.QuoteHeartbeatParamsFields;
|
params: types.VerifierHeartbeatParamsFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QuoteHeartbeatAccounts {
|
export interface VerifierHeartbeatAccounts {
|
||||||
quote: PublicKey;
|
verifier: PublicKey;
|
||||||
enclaveSigner: PublicKey;
|
verifierSigner: PublicKey;
|
||||||
attestationQueue: PublicKey;
|
attestationQueue: PublicKey;
|
||||||
queueAuthority: PublicKey;
|
queueAuthority: PublicKey;
|
||||||
gcNode: PublicKey;
|
gcNode: PublicKey;
|
||||||
|
@ -23,35 +20,32 @@ export interface QuoteHeartbeatAccounts {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const layout = borsh.struct([
|
export const layout = borsh.struct([
|
||||||
types.QuoteHeartbeatParams.layout("params"),
|
types.VerifierHeartbeatParams.layout("params"),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export function quoteHeartbeat(
|
export function verifierHeartbeat(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: QuoteHeartbeatArgs,
|
args: VerifierHeartbeatArgs,
|
||||||
accounts: QuoteHeartbeatAccounts
|
accounts: VerifierHeartbeatAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.quote, isSigner: false, isWritable: true },
|
{ pubkey: accounts.verifier, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.enclaveSigner, isSigner: true, isWritable: false },
|
{ pubkey: accounts.verifierSigner, isSigner: true, isWritable: false },
|
||||||
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: true },
|
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.queueAuthority, isSigner: false, isWritable: false },
|
{ pubkey: accounts.queueAuthority, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.gcNode, isSigner: false, isWritable: true },
|
{ pubkey: accounts.gcNode, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.permission, isSigner: false, isWritable: false },
|
{ 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 buffer = Buffer.alloc(1000);
|
||||||
const len = layout.encode(
|
const len = layout.encode(
|
||||||
{
|
{
|
||||||
params: types.QuoteHeartbeatParams.toEncodable(args.params),
|
params: types.VerifierHeartbeatParams.toEncodable(args.params),
|
||||||
},
|
},
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface QuoteInitArgs {
|
export interface VerifierInitArgs {
|
||||||
params: types.QuoteInitParamsFields;
|
params: types.VerifierInitParamsFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QuoteInitAccounts {
|
export interface VerifierInitAccounts {
|
||||||
quote: PublicKey;
|
verifier: PublicKey;
|
||||||
attestationQueue: PublicKey;
|
attestationQueue: PublicKey;
|
||||||
queueAuthority: PublicKey;
|
queueAuthority: PublicKey;
|
||||||
authority: PublicKey;
|
authority: PublicKey;
|
||||||
|
@ -22,34 +19,31 @@ export interface QuoteInitAccounts {
|
||||||
systemProgram: PublicKey;
|
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,
|
program: SwitchboardProgram,
|
||||||
args: QuoteInitArgs,
|
args: VerifierInitArgs,
|
||||||
accounts: QuoteInitAccounts
|
accounts: VerifierInitAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.quote, isSigner: true, isWritable: true },
|
{ pubkey: accounts.verifier, isSigner: true, isWritable: true },
|
||||||
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: true },
|
{ pubkey: accounts.attestationQueue, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.queueAuthority, isSigner: false, isWritable: false },
|
{ pubkey: accounts.queueAuthority, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.authority, isSigner: false, isWritable: false },
|
{ pubkey: accounts.authority, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.payer, isSigner: true, isWritable: true },
|
{ pubkey: accounts.payer, isSigner: true, isWritable: true },
|
||||||
{ pubkey: accounts.systemProgram, isSigner: false, isWritable: false },
|
{ 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 buffer = Buffer.alloc(1000);
|
||||||
const len = layout.encode(
|
const len = layout.encode(
|
||||||
{
|
{
|
||||||
params: types.QuoteInitParams.toEncodable(args.params),
|
params: types.VerifierInitParams.toEncodable(args.params),
|
||||||
},
|
},
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
|
@ -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;
|
||||||
|
}
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface QuoteVerifyArgs {
|
export interface VerifierQuoteVerifyArgs {
|
||||||
params: types.QuoteVerifyParamsFields;
|
params: types.VerifierQuoteVerifyParamsFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QuoteVerifyAccounts {
|
export interface VerifierQuoteVerifyAccounts {
|
||||||
quote: PublicKey;
|
quote: PublicKey;
|
||||||
quoteSigner: PublicKey;
|
|
||||||
verifier: PublicKey;
|
verifier: PublicKey;
|
||||||
enclaveSigner: PublicKey;
|
enclaveSigner: PublicKey;
|
||||||
attestationQueue: 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,
|
program: SwitchboardProgram,
|
||||||
args: QuoteVerifyArgs,
|
args: VerifierQuoteVerifyArgs,
|
||||||
accounts: QuoteVerifyAccounts
|
accounts: VerifierQuoteVerifyAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.quote, isSigner: false, isWritable: true },
|
{ pubkey: accounts.quote, isSigner: false, isWritable: true },
|
||||||
{ pubkey: accounts.quoteSigner, isSigner: false, isWritable: false },
|
|
||||||
{ pubkey: accounts.verifier, isSigner: false, isWritable: false },
|
{ pubkey: accounts.verifier, isSigner: false, isWritable: false },
|
||||||
{ pubkey: accounts.enclaveSigner, isSigner: true, isWritable: false },
|
{ pubkey: accounts.enclaveSigner, isSigner: true, isWritable: false },
|
||||||
{ pubkey: accounts.attestationQueue, isSigner: false, 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 buffer = Buffer.alloc(1000);
|
||||||
const len = layout.encode(
|
const len = layout.encode(
|
||||||
{
|
{
|
||||||
params: types.QuoteVerifyParams.toEncodable(args.params),
|
params: types.VerifierQuoteVerifyParams.toEncodable(args.params),
|
||||||
},
|
},
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface WalletCloseArgs {
|
export interface WalletCloseArgs {
|
||||||
|
@ -32,7 +29,8 @@ export const layout = borsh.struct([types.WalletCloseParams.layout("params")]);
|
||||||
export function walletClose(
|
export function walletClose(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: WalletCloseArgs,
|
args: WalletCloseArgs,
|
||||||
accounts: WalletCloseAccounts
|
accounts: WalletCloseAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.wallet, isSigner: false, isWritable: true },
|
{ pubkey: accounts.wallet, isSigner: false, isWritable: true },
|
||||||
|
@ -56,10 +54,6 @@ export function walletClose(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 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 * as borsh from "@coral-xyz/borsh"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
import {
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
|
||||||
AccountMeta,
|
import { TransactionInstruction } from "@solana/web3.js"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
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
|
import { BN } from "@switchboard-xyz/common"; // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||||
|
|
||||||
export interface WalletFundArgs {
|
export interface WalletFundArgs {
|
||||||
|
@ -31,7 +28,8 @@ export const layout = borsh.struct([types.WalletFundParams.layout("params")]);
|
||||||
export function walletFund(
|
export function walletFund(
|
||||||
program: SwitchboardProgram,
|
program: SwitchboardProgram,
|
||||||
args: WalletFundArgs,
|
args: WalletFundArgs,
|
||||||
accounts: WalletFundAccounts
|
accounts: WalletFundAccounts,
|
||||||
|
programId: PublicKey = program.attestationProgramId
|
||||||
) {
|
) {
|
||||||
const keys: Array<AccountMeta> = [
|
const keys: Array<AccountMeta> = [
|
||||||
{ pubkey: accounts.wallet, isSigner: false, isWritable: true },
|
{ pubkey: accounts.wallet, isSigner: false, isWritable: true },
|
||||||
|
@ -54,10 +52,6 @@ export function walletFund(
|
||||||
buffer
|
buffer
|
||||||
);
|
);
|
||||||
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len);
|
||||||
const ix = new TransactionInstruction({
|
const ix = new TransactionInstruction({ keys, programId, data });
|
||||||
keys,
|
|
||||||
programId: program.attestationProgramId,
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
return ix;
|
return ix;
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue