This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as anchor from "@coral-xyz/anchor"; | |
import type { Commitment } from "@solana/web3.js"; | |
import { Connection, Keypair } from "@solana/web3.js"; | |
import * as fs from "fs"; | |
import yaml from 'js-yaml'; | |
import path from 'path'; | |
import os from 'os'; | |
type SolanaConfig = { | |
rpcUrl: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
which base58 > /dev/null || (brew install pipx && pipx install base58) | |
# Function to detect if the input is hex | |
is_hex() { | |
[[ $1 =~ ^[0-9a-fA-F]+$ ]] && return 0 || return 1 | |
} | |
# Function to detect if the input is base64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const coder = new BorshAccountsCoder(program.idl); | |
const oracles = await queue.fetchOracleKeys(); | |
const oracleAccounts = await utils.rpc.getMultipleAccounts( | |
program.provider.connection, | |
oracles | |
); | |
const oracleDatas = oracleAccounts | |
.map((x: any) => coder.decode("OracleAccountData", x.account.data)); | |
// TODO: now filter out all oracles that keys are not currently verified and keys expire in more than an hour |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
TransactionInstruction, | |
Connection, | |
PublicKey, | |
Keypair, | |
Transaction, | |
SystemProgram, | |
LAMPORTS_PER_SOL, | |
} from "@solana/web3.js"; | |
import { Program } from "@coral-xyz/anchor"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use switchboard_solana::AggregatorHistoryBuffer; | |
use std::convert::TryInto; | |
let history_buffer = AggregatorHistoryBuffer::new(history_account_info)?; | |
let current_timestamp = Clock::get()?.unix_timestamp; | |
let one_hour_ago: f64 = history_buffer.lower_bound(current_timestamp - 3600).unwrap().try_into()?; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async sendRestTransaction( | |
serializedTx: Uint8Array | Buffer | Array<number>, | |
retries, | |
rpcEndpoint = this.defaultConnection.rpcEndpoint, | |
skipPreFlight = true | |
): Promise<TransactionSignature> { | |
const res = await fetch(rpcEndpoint, { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const NONCE_RENT: u64 = 1_447_680; | |
pub struct NonceManager { | |
pub rpc_client: Arc<RpcClient>, | |
pub authority: Pubkey, | |
pub capacity: u64, | |
pub idx: u64, | |
} | |
impl NonceManager { | |
pub fn new(rpc_client: Arc<RpcClient>, authority: Pubkey, capacity: u64) -> Self { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static async asV0TxWithComputeIxs( | |
program: anchor.Program, | |
ixs: Array<TransactionInstruction>, | |
computeUnitLimitMultiple: number, | |
computeUnitPrice: number, | |
lookupTables?: Array<AddressLookupTableAccount> | |
): Promise<VersionedTransaction> { | |
lookupTables = lookupTables ?? []; | |
const priorityFeeIx = ComputeBudgetProgram.setComputeUnitPrice({ | |
microLamports: computeUnitPrice, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use base64::{engine::general_purpose::STANDARD as base64, Engine as _}; | |
use wormhole_vaas::GuardianSetSig; | |
use wormhole_vaas::Vaa; | |
use libsecp256k1; | |
use hex; | |
use sha2::{Sha256, Digest}; | |
use wormhole_vaas::Readable; | |
pub const DUMMY_VAA: &str = "UE5BVQEAAAADuAEAAAADDQH2RWm2Z8mKR0pI+MW+n7QQz/rfif2tRO/L6b+eVhIR9GHc2MwpL+NYVcsBhkhAg0hx18C5eVD+dCYLwey5EHYlAAJfsE584lX5cPZ2Of9IE2xaMMD88L70IOlTB2XkFbbrcR4PTS7+OeSJvHubUrzggYK3lhyEwJ00wtfZcdUmHMwoAAOjCCNZSw/UDoT7Xvcb9dfQy9BnnvFlnfih0qlQuSErc3kKrGkGLpYaaErVPNHZ3R4BY605Bsvp2kBKammsPwKrAQQJEzvF0E1gpLPn97YnZdyL+yDao4osiMlGS2YDYQFg5XLBuhbFcscSY9nj2PN54KR7OzkDafNBNHMN0Xl7aydcAAZlE4aG6Zf1Pf4lPx2gbQgPCc9wyICVXFhvbYdOvIafDnlN+MmKBuQUCt3YWZybtA4CTKlbKGjG3BkXVPvxTQu8AQdGn1M5uWJwNMoqg842mEWy7XeU6ZAfZVPo3Q0gGhHtahWMfOHZ0TnXmhrJjGw6oO7pDGKqSUEr3Gm+rIO0e/fZAQiVdsBtWxfKhhZKZKCAtrZZHonKTHu91bYm9RvoJRY93gEUFgSzKbyUJpYEb7DO6aBHwclVtYYlr5M2L7l/ufshAAqasa+PaMyZLLSbCkbgSaATkxVe1y2Ze8TdtMpRaCwcQyTCEFUDmo6LUc5088ykvCrB50l7VDsslautlgrr+TUfAQvDQiBFP6NKV/g38NivyNAXzIcoCAVLUn6H1IlgCyVQBhIIjehwad5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Connection, PublicKey } from "@solana/web3.js"; | |
import { | |
BorshCoder, | |
BorshEventCoder, | |
EventParser, | |
Program, | |
web3, | |
} from "@coral-xyz/anchor"; | |
import { IDL } from "./idl"; |
NewerOlder