frakt-client
Version:
Client library for interacting with FRAKT solana program
163 lines (162 loc) • 9.29 kB
TypeScript
import { Connection, Keypair, Transaction, TransactionInstruction, PublicKey } from '@solana/web3.js';
import { u64 } from '@solana/spl-token';
import { Data, Creator } from './metadata2';
declare const BN: any;
declare function readKeypairFromPath(path: string): Keypair;
interface ApiDependencies {
connection: Connection;
}
declare function createTokenMetadata(data: Data, updateAuthority: PublicKey, mintKey: PublicKey, mintAuthorityKey: PublicKey, payer: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>): Promise<void>;
declare function updateMintAuthority(mintPubkey: PublicKey, newAuthority: PublicKey, oldAuthority: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>): Promise<void>;
declare function createAndMintSomeTokens(amountToMint: number | u64, decimals: number, userPublicKey: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>, { connection }: ApiDependencies): Promise<{
mintAddress: string;
tokenAccAddress: string;
mintSeed: string;
}>;
declare function mintArt({ shape, color, art_hash, // Hash of figure+color combination in ranges
circles_amount, fractial_iterations, min_rad_low_limit, min_rad_high_limit, max_rad_low_limit, max_rad_high_limit, shape_rarity, color_rarity, image_url, }: ArtAttributes, adminPubKey: PublicKey, userPublicKey: PublicKey, artPubKey: PublicKey, programPubKey: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>, { connection }: ApiDependencies): Promise<void>;
declare function getLargestTokenAccountOwnerByMint(mintPubKey: PublicKey, { connection }: {
connection: any;
}): Promise<String>;
declare function migrateArtsToNewTokens(frakts: ArtView[], userPublicKey: PublicKey, programPubKey: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>, { connection }: ApiDependencies): Promise<void>;
declare function createInsertNewTokenInstructions(frakt: ArtView, adminPubKey: PublicKey, programPubKey: PublicKey, { connection }: ApiDependencies): Promise<{
mintAddress: string;
instructions: TransactionInstruction[];
}>;
declare function buyArt(userPublicKey: PublicKey, programPubKey: PublicKey, adminPubKey: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>, { connection }: ApiDependencies): Promise<{
artAddress: PublicKey;
counterAddress: PublicKey;
}>;
declare function stakeBulkFrakts(artsAndMints: ArtAndMint[], userPublicKey: PublicKey, programPubKey: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>, { connection }: ApiDependencies): Promise<void>;
declare function unstakeBulkFraktsNoHarvest(fraktsAndStakes: UnstakeParams[], userPublicKey: PublicKey, programPubKey: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>, { connection }: ApiDependencies): Promise<void>;
declare function unstakeBulkFrakts(fraktsAndStakes: UnstakeParams[], farmingMintPubKey: PublicKey, userPublicKey: PublicKey, programPubKey: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>, { connection }: ApiDependencies): Promise<void>;
declare function updateStakeBulkFrakts(fraktsAndStakes: UnstakeParams[], userPublicKey: PublicKey, programPubKey: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>, { connection }: ApiDependencies): Promise<void>;
declare function harvestBulkStakes(stakesPubkeys: PublicKey[], userPublicKey: PublicKey, farmingMintPubKey: PublicKey, programPubKey: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>, { connection }: ApiDependencies): Promise<void>;
declare function topupStakingPool(topup_amount: number, adminPublicKey: PublicKey, farmingMintPubKey: PublicKey, programPubkey: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>): Promise<void>;
declare function initializePoolConfig(farmingTokensPerSecondPerPoint: Number, harvest_unlock_at: Number, farmingMintPubkey: PublicKey, adminPubkey: PublicKey, programPubkey: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>, { connection }: {
connection: any;
}): Promise<void>;
declare function updatePoolConfig(farmingTokensPerSecondPerPoint: Number, harvest_unlock_at: Number, adminPubkey: PublicKey, programPubkey: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>, { connection }: {
connection: any;
}): Promise<void>;
declare function getTokenAddressFromMintAndUser(userAddress: String, mintAddress: String): Promise<PublicKey>;
declare function getArtTokensFromTokens(arts: ArtView[], tokens: TokenView[]): ArtView[];
declare function getArts(fraktProgramId: PublicKey, { connection }: ApiDependencies): Promise<ArtView[]>;
declare function getAllProgramAccounts(launchpdProgramPubKey: any, { connection }: ApiDependencies): Promise<AllAccounts>;
declare function getStakes(fraktProgramId: PublicKey, { connection }: ApiDependencies): Promise<StakeView[]>;
declare function getCounter(fraktProgramId: any, { connection }: ApiDependencies): Promise<CounterView>;
declare function decodedCounterBuffersToUI(decodedCounterState: any, counterAddress: any): CounterView;
declare function decodedArtBuffersToUI(decodedArtState: any, artAddress: PublicKey): ArtView;
declare function decodedTokenBuffersToUI(decodedTokenState: any, tokenAddress: PublicKey): TokenView;
declare function getAllUserTokens(userPublicKey: PublicKey, { connection }: ApiDependencies): Promise<TokenView[]>;
declare function createSee(receiver: PublicKey, adminAddress: PublicKey, sendTxn: (transaction: Transaction) => Promise<void>, { connection }: ApiDependencies): Promise<void>;
declare function getCreatorsMetadataTokens(creatorPubKey: PublicKey, { connection }: ApiDependencies): Promise<any[]>;
declare function findAssociatedTokenAddress(walletAddress: PublicKey, tokenMintAddress: PublicKey): Promise<PublicKey>;
interface AllAccounts {
counterAccount: CounterView;
stakeAccounts: StakeView[];
artAccounts: ArtView[];
poolConfigAccount: PoolConfigView;
}
interface PoolConfigLayout {
is_initialized: number;
farming_vault_owner_pda: Uint8Array;
farming_token_mint: Uint8Array;
farming_vault_token_account: Uint8Array;
farming_pool_vault_balance: Uint8Array;
farming_tokens_per_second_per_point: Uint8Array;
version: Uint8Array;
harvest_unlock_at: Uint8Array;
}
interface TokenView {
tokenAccountPubkey: String;
mint: String;
owner: String;
amount: Number;
amountBN: typeof BN;
delegateOption: boolean;
delegate: String;
state: boolean;
isNativeOption: boolean;
isNative: Number;
delegatedAmount: Number;
closeAuthorityOption: boolean;
closeAuthority: String;
}
interface CounterView {
counterAccountPubkey: String;
isInitialized: boolean;
count: Number;
}
interface ArtView {
metadata: {
artAccountPubkey: String;
is_old_version: boolean;
isInitialized: boolean;
id: Number;
first_owner_pubkey: String;
minted_token_pubkey: String;
is_minted: boolean;
created_at: Number;
};
attributes: ArtAttributes;
}
interface StakeView {
stakeAccountPubkey: String;
stake_owner: String;
art_pubkey: String;
mint_pubkey: String;
points: Number;
color: Number;
shape: Number;
staked_at: Number;
stake_end_at: Number;
version: Number;
is_initialized: boolean;
token_vault_pubkey: String;
is_staked: boolean;
last_harvested_at: Number;
}
interface PoolConfigView {
poolConfigAccountPubkey: String;
is_initialized: boolean;
farming_vault_owner_pda: String;
farming_token_mint: String;
farming_vault_token_account: String;
farming_pool_vault_balance: Number;
farming_tokens_per_second_per_point: Number;
version: Number;
harvest_unlock_at: Number;
}
interface MetadataOptions {
files: ArweaveFile[];
externalUrl: String;
}
interface ArweaveFile {
content: String | Uint8Array | ArrayBuffer;
type: String;
}
interface ArtAndMint {
artPubKey: PublicKey;
mintPubKey: PublicKey;
}
interface UnstakeParams {
artPubKey: PublicKey;
mintPubKey: PublicKey;
stakePubkey: PublicKey;
}
interface ArtAttributes {
shape: Number;
color: Number;
art_hash: Number;
circles_amount: Number;
fractial_iterations: Number;
min_rad_low_limit: Number;
min_rad_high_limit: Number;
max_rad_low_limit: Number;
max_rad_high_limit: Number;
shape_rarity: Number;
color_rarity: Number;
image_url: String;
}
export { getArts, getAllUserTokens, buyArt, mintArt, getCounter, getArtTokensFromTokens, getTokenAddressFromMintAndUser, readKeypairFromPath, getLargestTokenAccountOwnerByMint, decodedArtBuffersToUI, decodedCounterBuffersToUI, decodedTokenBuffersToUI, createTokenMetadata, findAssociatedTokenAddress, migrateArtsToNewTokens, createInsertNewTokenInstructions, getCreatorsMetadataTokens, stakeBulkFrakts, unstakeBulkFrakts, getStakes, getAllProgramAccounts, updateStakeBulkFrakts, initializePoolConfig, updatePoolConfig, createAndMintSomeTokens, topupStakingPool, harvestBulkStakes, updateMintAuthority, unstakeBulkFraktsNoHarvest, createSee, PoolConfigView, PoolConfigLayout, StakeView, ArtView, ArtAttributes, CounterView, TokenView, ApiDependencies, MetadataOptions, ArweaveFile, Data, Creator, ArtAndMint, UnstakeParams, };