Price account v2 for remote clusters (#1040)
This commit is contained in:
parent
0559b45936
commit
cfdfb9d2fb
|
@ -10,6 +10,7 @@ import {
|
||||||
TransactionInstruction,
|
TransactionInstruction,
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import { PRICE_FEED_OPS_KEY } from "./multisig";
|
import { PRICE_FEED_OPS_KEY } from "./multisig";
|
||||||
|
import { isRemoteCluster } from "./cluster";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get seed for deterministic creation of a price/product account
|
* Get seed for deterministic creation of a price/product account
|
||||||
|
@ -33,10 +34,17 @@ function getSeed(accountType: AccountType, symbol: string): string {
|
||||||
* @param accountType Type of the account
|
* @param accountType Type of the account
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function getAccountTypeSize(accountType: AccountType): number {
|
function getAccountTypeSize(
|
||||||
|
accountType: AccountType,
|
||||||
|
cluster: PythCluster
|
||||||
|
): number {
|
||||||
switch (accountType) {
|
switch (accountType) {
|
||||||
case AccountType.Price:
|
case AccountType.Price:
|
||||||
|
if (isRemoteCluster(cluster)) {
|
||||||
|
return 12576;
|
||||||
|
} else {
|
||||||
return 3312;
|
return 3312;
|
||||||
|
}
|
||||||
case AccountType.Product:
|
case AccountType.Product:
|
||||||
return 512;
|
return 512;
|
||||||
default:
|
default:
|
||||||
|
@ -88,9 +96,9 @@ export async function getCreateAccountWithSeedInstruction(
|
||||||
basePubkey: base,
|
basePubkey: base,
|
||||||
newAccountPubkey: address,
|
newAccountPubkey: address,
|
||||||
seed: seed,
|
seed: seed,
|
||||||
space: getAccountTypeSize(accountType),
|
space: getAccountTypeSize(accountType, cluster),
|
||||||
lamports: await connection.getMinimumBalanceForRentExemption(
|
lamports: await connection.getMinimumBalanceForRentExemption(
|
||||||
getAccountTypeSize(accountType)
|
getAccountTypeSize(accountType, cluster)
|
||||||
),
|
),
|
||||||
programId: getPythProgramKeyForCluster(cluster),
|
programId: getPythProgramKeyForCluster(cluster),
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue