Merge branch 'spl-token-alias' into main

This commit is contained in:
Conner Gallagher 2022-08-03 16:04:46 -06:00
commit add1e9fab4
25 changed files with 73 additions and 62 deletions

View File

@ -31,7 +31,7 @@
"@oclif/plugin-version": "^1.0.4",
"@oclif/plugin-warn-if-update-available": "^2.0.4",
"@project-serum/anchor": "^0.24.2",
"@solana/spl-token": "^0.2.0",
"@solana/spl-token-v2": "npm:@solana/spl-token@^0.2.0",
"@solana/web3.js": "^1.43.5",
"@switchboard-xyz/sbv2-utils": "^0.1.39",
"@switchboard-xyz/switchboard-v2": "^0.0.126",

View File

@ -1,7 +1,7 @@
/* eslint-disable unicorn/no-array-push-push */
import { Flags } from "@oclif/core";
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import {
AccountInfo,
Keypair,

View File

@ -1,6 +1,6 @@
import { Flags } from "@oclif/core";
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import {
AccountInfo,
Keypair,

View File

@ -1,6 +1,6 @@
import { Flags } from "@oclif/core";
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import {
Keypair,
PublicKey,

View File

@ -1,6 +1,6 @@
import { Flags } from "@oclif/core";
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import { PublicKey } from "@solana/web3.js";
import {
chalkString,

View File

@ -2,7 +2,7 @@
/* eslint-disable unicorn/new-for-builtins */
import { Flags } from "@oclif/core";
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import {
AccountInfo,
Keypair,

View File

@ -1,5 +1,5 @@
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import {
LAMPORTS_PER_SOL,
NONCE_ACCOUNT_LENGTH,

View File

@ -1,6 +1,6 @@
import { Flags } from "@oclif/core";
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import {
Keypair,
PublicKey,

View File

@ -1,6 +1,6 @@
import { Flags } from "@oclif/core";
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import {
Keypair,
PublicKey,

View File

@ -1,5 +1,5 @@
import { Flags } from "@oclif/core";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import { PublicKey, SYSVAR_RECENT_BLOCKHASHES_PUBKEY } from "@solana/web3.js";
import { getOrCreateSwitchboardTokenAccount } from "@switchboard-xyz/sbv2-utils";
import {

View File

@ -18,7 +18,7 @@
},
"dependencies": {
"@project-serum/anchor": "^0.24.2",
"@solana/spl-token": "^0.2.0",
"@solana/spl-token-v2": "npm:@solana/spl-token@^0.2.0",
"@solana/web3.js": "^1.37.1",
"@switchboard-xyz/switchboard-v2": "^0.0.126",
"chalk": "^4.1.2",

View File

@ -1,5 +1,5 @@
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import { clusterApiUrl, Connection, Keypair } from "@solana/web3.js";
import {
AggregatorAccount,

View File

@ -17,6 +17,6 @@ default = []
[dependencies]
# switchboard-v2 = { path = "../../../libraries/rs", features = ["devnet"] }
switchboard-v2 = { version = "^0.1.13", features = ["devnet"] }
switchboard-v2 = { version = "^0.1.14", features = ["devnet"] }
anchor-lang = "^0.25.0"
solana-program = "~1.10.29"

View File

@ -17,7 +17,7 @@ default = []
[dependencies]
# switchboard-v2 = { path = "../../../libraries/rs", features = ["devnet"] }
switchboard-v2 = { version = "^0.1.13", features = ["devnet"] }
switchboard-v2 = { version = "^0.1.14", features = ["devnet"] }
anchor-lang = "^0.25.0"
solana-program = "~1.10.29"
bytemuck = "1.7.2"

View File

@ -17,7 +17,7 @@ default = []
[dependencies]
# switchboard-v2 = { path = "../../../libraries/rs", features = ["devnet"] }
switchboard-v2 = { version = "^0.1.13", features = ["devnet"] }
switchboard-v2 = { version = "^0.1.14", features = ["devnet"] }
anchor-lang = "^0.25.0"
anchor-spl = "^0.25.0"
solana-program = "~1.10.29"

View File

@ -17,7 +17,7 @@
"dependencies": {
"@project-serum/anchor": "^0.24.2",
"@project-serum/borsh": "^0.2.5",
"@solana/spl-token": "^0.2.0",
"@solana/spl-token-v2": "npm:@solana/spl-token@^0.2.0",
"@solana/web3.js": "^1.42.0",
"@switchboard-xyz/sbv2-utils": "^0.1.39",
"@switchboard-xyz/switchboard-v2": "^0.0.126",

View File

@ -1,6 +1,6 @@
import * as anchor from "@project-serum/anchor";
import { AnchorProvider } from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import {
SystemProgram,
SYSVAR_RECENT_BLOCKHASHES_PUBKEY,

View File

@ -36,7 +36,7 @@
"@orca-so/sdk": "^1.2.24",
"@project-serum/anchor": "^0.24.2",
"@saberhq/token-utils": "^1.13.32",
"@solana/spl-token": "^0.2.0",
"@solana/spl-token-v2": "npm:@solana/spl-token@^0.2.0",
"@solana/web3.js": "^1.43.5",
"@switchboard-xyz/switchboard-v2": "^0.0.126",
"big.js": "^6.1.1",

View File

@ -1,5 +1,5 @@
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import {
PublicKey,
sendAndConfirmTransaction,

View File

@ -1,5 +1,5 @@
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import {
Keypair,
PublicKey,

View File

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-shadow */
/* eslint-disable @typescript-eslint/no-var-requires */
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import { Keypair, PublicKey } from "@solana/web3.js";
import * as sbv2 from "@switchboard-xyz/switchboard-v2";
import Big from "big.js";

View File

@ -1,5 +1,5 @@
import type * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import {
Connection,
Keypair,

View File

@ -45,13 +45,12 @@
},
"peerDependencies": {
"@solana/spl-governance": "^0.0.34",
"@solana/spl-token": "^0.2.0",
"@solana/web3.js": "^1.44.3"
},
"dependencies": {
"@project-serum/anchor": "^0.24.2",
"@solana/spl-governance": "^0.0.34",
"@solana/spl-token": "^0.2.0",
"@solana/spl-token-v2": "npm:@solana/spl-token@^0.2.0",
"@solana/web3.js": "^1.44.3",
"@types/big.js": "^6.1.4",
"assert": "^2.0.0",

View File

@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
import * as anchor from "@project-serum/anchor";
import * as spl from "@solana/spl-token";
import * as spl from "@solana/spl-token-v2";
import {
AccountInfo,
AccountMeta,
@ -25,6 +25,8 @@ import * as crypto from "crypto";
/*eslint-disable import/extensions */
import protos from "./protos/index.js";
export type SwitchboardProgram = anchor.Program;
/**
* Switchboard Devnet Program ID
* 2TfB33aLaneQb5TNVwyDz3jSZXS6jdW2ARw1Dgf84XCG
@ -78,7 +80,7 @@ export async function loadSwitchboardProgram(
confirmOptions: ConfirmOptions = {
commitment: "confirmed",
}
): Promise<anchor.Program> {
): Promise<SwitchboardProgram> {
const DEFAULT_KEYPAIR = Keypair.fromSeed(new Uint8Array(32).fill(1));
const programId = getSwitchboardPid(cluster);
const wallet: AnchorWallet = payerKeypair
@ -100,7 +102,7 @@ export async function loadSwitchboardProgram(
// should also check if pubkey is a token account
export const findAccountName = (
program: anchor.Program,
program: SwitchboardProgram,
accountInfo: AccountInfo<Buffer>
): string => {
const accountDiscriminator = accountInfo.data.slice(
@ -124,7 +126,7 @@ export const findAccountName = (
export type OnAccountChangeCallback = (accountData: any) => void;
export function watchSwitchboardAccount(
program: anchor.Program,
program: SwitchboardProgram,
publicKey: PublicKey,
accountName: string,
callback: OnAccountChangeCallback
@ -255,7 +257,7 @@ export interface AccountParams {
/**
* program referencing the Switchboard program and IDL.
*/
program: anchor.Program;
program: SwitchboardProgram;
/**
* Public key of the account being referenced. This will always be populated
* within the account wrapper.
@ -292,7 +294,7 @@ export interface VaultTransferParams {
export class ProgramStateAccount {
static accountName = "SbState";
program: anchor.Program;
program: SwitchboardProgram;
publicKey: PublicKey;
@ -324,7 +326,7 @@ export class ProgramStateAccount {
* Constructs ProgramStateAccount from the static seed from which it was generated.
* @return ProgramStateAccount and PDA bump tuple.
*/
static fromSeed(program: anchor.Program): [ProgramStateAccount, number] {
static fromSeed(program: SwitchboardProgram): [ProgramStateAccount, number] {
const [statePubkey, stateBump] =
anchor.utils.publicKey.findProgramAddressSync(
[Buffer.from("STATE")],
@ -368,7 +370,7 @@ export class ProgramStateAccount {
}
static async getOrCreate(
program: anchor.Program,
program: SwitchboardProgram,
params: ProgramInitParams
): Promise<[ProgramStateAccount, number]> {
const [account, seed] = ProgramStateAccount.fromSeed(program);
@ -389,7 +391,7 @@ export class ProgramStateAccount {
* @return newly generated ProgramStateAccount.
*/
static async create(
program: anchor.Program,
program: SwitchboardProgram,
params: ProgramInitParams
): Promise<ProgramStateAccount> {
const payerKeypair = programWallet(program);
@ -638,7 +640,7 @@ export class SwitchboardError {
/**
* The program containing the Switchboard IDL specifying error codes.
*/
program: anchor.Program;
program: SwitchboardProgram;
/**
* Stringified name of the error type.
@ -662,7 +664,7 @@ export class SwitchboardError {
* @param code Error code to convert to a SwitchboardError object.
* @return SwitchboardError
*/
static fromCode(program: anchor.Program, code: number): SwitchboardError {
static fromCode(program: SwitchboardProgram, code: number): SwitchboardError {
for (const e of program.idl.errors ?? []) {
if (code === e.code) {
const r = new SwitchboardError();
@ -735,7 +737,7 @@ export interface AggregatorSetUpdateIntervalParams {
export class AggregatorAccount {
static accountName = "AggregatorAccountData";
program: anchor.Program;
program: SwitchboardProgram;
publicKey: PublicKey;
@ -764,7 +766,7 @@ export class AggregatorAccount {
}
static decode(
program: anchor.Program,
program: SwitchboardProgram,
accountInfo: AccountInfo<Buffer>
): any {
const coder = new anchor.BorshAccountsCoder(program.idl);
@ -1094,7 +1096,7 @@ export class AggregatorAccount {
* @return newly generated AggregatorAccount.
*/
static async create(
program: anchor.Program,
program: SwitchboardProgram,
params: AggregatorInitParams
): Promise<AggregatorAccount> {
const payerKeypair = programWallet(program);
@ -1594,7 +1596,7 @@ export interface JobInitParams {
export class JobAccount {
static accountName = "JobAccountData";
program: anchor.Program;
program: SwitchboardProgram;
publicKey: PublicKey;
@ -1648,7 +1650,7 @@ export class JobAccount {
* @return newly generated JobAccount.
*/
static async create(
program: anchor.Program,
program: SwitchboardProgram,
params: JobInitParams
): Promise<JobAccount> {
const payerKeypair = programWallet(program);
@ -1694,7 +1696,7 @@ export class JobAccount {
}
static decode(
program: anchor.Program,
program: SwitchboardProgram,
accountInfo: AccountInfo<Buffer>
): any {
const coder = new anchor.BorshAccountsCoder(program.idl);
@ -1703,7 +1705,7 @@ export class JobAccount {
}
static decodeJob(
program: anchor.Program,
program: SwitchboardProgram,
accountInfo: AccountInfo<Buffer>
): protos.OracleJob {
return protos.OracleJob.decodeDelimited(
@ -1752,7 +1754,7 @@ export interface PermissionSetParams {
export interface PermissionSetVoterWeightParams {
govProgram: PublicKey;
pubkeySigner?: PublicKey;
addinProgram: anchor.Program;
addinProgram: SwitchboardProgram;
realm: PublicKey;
}
@ -1776,7 +1778,7 @@ export enum SwitchboardPermissionValue {
export class PermissionAccount {
static accountName = "PermissionAccountData";
program: anchor.Program;
program: SwitchboardProgram;
publicKey: PublicKey;
@ -1841,7 +1843,7 @@ export class PermissionAccount {
* @return newly generated PermissionAccount.
*/
static async create(
program: anchor.Program,
program: SwitchboardProgram,
params: PermissionInitParams
): Promise<PermissionAccount> {
const authorityInfo = await program.provider.connection.getAccountInfo(
@ -1882,7 +1884,7 @@ export class PermissionAccount {
* @return PermissionAccount and PDA bump.
*/
static fromSeed(
program: anchor.Program,
program: SwitchboardProgram,
authority: PublicKey,
granter: PublicKey,
grantee: PublicKey
@ -2129,7 +2131,7 @@ export interface OracleQueueSetVrfSettingsParams {
export class OracleQueueAccount {
static accountName = "OracleQueueAccountData";
program: anchor.Program;
program: SwitchboardProgram;
publicKey: PublicKey;
@ -2212,7 +2214,7 @@ export class OracleQueueAccount {
* @return newly generated OracleQueueAccount.
*/
static async create(
program: anchor.Program,
program: SwitchboardProgram,
params: OracleQueueInitParams
): Promise<OracleQueueAccount> {
const payerKeypair = programWallet(program);
@ -2376,7 +2378,7 @@ export interface LeaseWithdrawParams {
* for fulfilling feed updates.
*/
export class LeaseAccount {
program: anchor.Program;
program: SwitchboardProgram;
publicKey: PublicKey;
@ -2411,7 +2413,7 @@ export class LeaseAccount {
* @return LeaseAccount and PDA bump.
*/
static fromSeed(
program: anchor.Program,
program: SwitchboardProgram,
queueAccount: OracleQueueAccount,
aggregatorAccount: AggregatorAccount
): [LeaseAccount, number] {
@ -2454,7 +2456,7 @@ export class LeaseAccount {
* @return newly generated LeaseAccount.
*/
static async create(
program: anchor.Program,
program: SwitchboardProgram,
params: LeaseInitParams
): Promise<LeaseAccount> {
const payerKeypair = programWallet(program);
@ -2780,7 +2782,7 @@ export class CrankRow {
export class CrankAccount {
static accountName = "CrankAccountData";
program: anchor.Program;
program: SwitchboardProgram;
publicKey: PublicKey;
@ -2850,7 +2852,7 @@ export class CrankAccount {
* @return newly generated CrankAccount.
*/
static async create(
program: anchor.Program,
program: SwitchboardProgram,
params: CrankInitParams
): Promise<CrankAccount> {
const payerKeypair = programWallet(program);
@ -3160,7 +3162,7 @@ export interface OracleWithdrawParams {
export class OracleAccount {
static accountName = "OracleAccountData";
program: anchor.Program;
program: SwitchboardProgram;
publicKey: PublicKey;
@ -3216,7 +3218,7 @@ export class OracleAccount {
* @return newly generated OracleAccount.
*/
static async create(
program: anchor.Program,
program: SwitchboardProgram,
params: OracleInitParams
): Promise<OracleAccount> {
const payerKeypair = programWallet(program);
@ -3274,7 +3276,7 @@ export class OracleAccount {
}
static decode(
program: anchor.Program,
program: SwitchboardProgram,
accountInfo: AccountInfo<Buffer>
): any {
const coder = new anchor.BorshAccountsCoder(program.idl);
@ -3288,7 +3290,7 @@ export class OracleAccount {
* @return OracleAccount and PDA bump tuple.
*/
static fromSeed(
program: anchor.Program,
program: SwitchboardProgram,
queueAccount: OracleQueueAccount,
wallet: PublicKey
): [OracleAccount, number] {
@ -3521,7 +3523,7 @@ export interface VrfProveParams {
export class VrfAccount {
static accountName = "VrfAccountData";
program: anchor.Program;
program: SwitchboardProgram;
publicKey: PublicKey;
@ -3589,7 +3591,7 @@ export class VrfAccount {
* @return newly generated VrfAccount.
*/
static async create(
program: anchor.Program,
program: SwitchboardProgram,
params: VrfInitParams
): Promise<VrfAccount> {
const payerKeypair = programWallet(program);
@ -3869,7 +3871,7 @@ export class VrfAccount {
}
export class BufferRelayerAccount {
program: anchor.Program;
program: SwitchboardProgram;
publicKey: PublicKey;
@ -3915,7 +3917,7 @@ export class BufferRelayerAccount {
}
static async create(
program: anchor.Program,
program: SwitchboardProgram,
params: {
name: Buffer;
minUpdateDelaySeconds: number;
@ -4297,7 +4299,7 @@ export function signTransactions(
return transactions;
}
export function programWallet(program: anchor.Program): Keypair {
export function programWallet(program: SwitchboardProgram): Keypair {
return ((program.provider as anchor.AnchorProvider).wallet as AnchorWallet)
.payer;
}

View File

@ -3834,6 +3834,16 @@
"@solana/web3.js" "^1.42.0"
bn.js "^5.1.3"
"@solana/spl-token-v2@npm:@solana/spl-token@^0.2.0":
version "0.2.0"
resolved "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.2.0.tgz#329bb6babb5de0f9c40035ddb1657f01a8347acd"
integrity sha512-RWcn31OXtdqIxmkzQfB2R+WpsJOVS6rKuvpxJFjvik2LyODd+WN58ZP3Rpjpro03fscGAkzlFuP3r42doRJgyQ==
dependencies:
"@solana/buffer-layout" "^4.0.0"
"@solana/buffer-layout-utils" "^0.2.0"
"@solana/web3.js" "^1.32.0"
start-server-and-test "^1.14.0"
"@solana/spl-token@^0.0.13":
version "0.0.13"
resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.0.13.tgz#5e0b235b1f8b34643280401dbfddeb34d13d1acd"