O pacote @solana/surfpool expõe uma classe, Surfnet, além dos tipos de
suporte necessários para chamar seus métodos com segurança de tipos. Esta página
lista todos os símbolos exportados; para uso narrativo, consulte os guias a
partir de Visão Geral.
Exportações do Pacote
| Símbolo | Tipo | Notas |
|---|---|---|
Surfnet | classe | Instância em execução do Surfnet com métodos cheatcode |
SurfnetConfig | tipo | Argumento para Surfnet.startWithConfig |
DeployOptions | tipo | Argumento para Surfnet.deploy |
SetTokenAccountUpdate | tipo | Argumento para Surfnet.setTokenAccount |
ResetAccountOptions | tipo | Argumento para Surfnet.resetAccount |
StreamAccountOptions | tipo | Argumento para Surfnet.streamAccount |
SolAccountFunding | tipo | Elemento do array passado para Surfnet.fundSolMany |
SimnetEventValue | tipo | Elemento retornado por Surfnet.drainEvents |
KeypairInfo | tipo | Retornado por Surfnet.newKeypair |
ClockValue | tipo | Campo em SimnetEventValue |
EpochInfoValue | tipo | Retornado pelos auxiliares de viagem no tempo |
ByteArrayLike | tipo | Uint8Array | number[] — entrada de bytes flexível |
Classe Surfnet
Métodos Estáticos
class Surfnet {static start(): Surfnet;static startWithConfig(config: SurfnetConfig): Surfnet;static newKeypair(): KeypairInfo;}
Propriedades da Instância
class Surfnet {readonly rpcUrl: string; // http://127.0.0.1:<port>readonly wsUrl: string; // ws://127.0.0.1:<port>readonly payer: string; // base58 public keyreadonly payerSecretKey: Uint8Array; // 64-byte private keyreadonly instanceId: string;}
Ciclo de Vida
class Surfnet {stop(): void; // idempotent; safe to call from `finally` / test teardown}
Cheatcodes de SOL
class Surfnet {fundSol(address: string, lamports: number): void;fundSolMany(accounts: SolAccountFunding[]): void;setAccount(address: string,lamports: number,data: Uint8Array,owner: string): void;resetAccount(address: string, options?: ResetAccountOptions): void;}
Cheatcodes de Token
class Surfnet {fundToken(owner: string,mint: string,amount: number,tokenProgram?: string): void;fundTokenMany(owners: string[],mint: string,amount: number,tokenProgram?: string): void;setTokenBalance(owner: string,mint: string,amount: number,tokenProgram?: string): void;setTokenAccount(owner: string,mint: string,update: SetTokenAccountUpdate,tokenProgram?: string): void;getAta(owner: string, mint: string, tokenProgram?: string): string;}
Viagem no Tempo
class Surfnet {timeTravelToSlot(slot: number): EpochInfoValue;timeTravelToEpoch(epoch: number): EpochInfoValue;timeTravelToTimestamp(timestampMs: number): EpochInfoValue;}
Deploy de Programa
class Surfnet {deployProgram(programName: string): string; // returns program iddeploy(options: DeployOptions): string; // returns program id}
Streaming e Eventos
class Surfnet {streamAccount(address: string, options?: StreamAccountOptions): void;drainEvents(): SimnetEventValue[];}
Tipos de Configuração
SurfnetConfig
interface SurfnetConfig {offline?: boolean; // default: trueremoteRpcUrl?: string; // setting this implies offline=falseblockProductionMode?: "manual" | "clock" | "transaction"; // default: "transaction"slotTimeMs?: number; // default: 1airdropSol?: number; // lamports; default: 10_000_000_000airdropAddresses?: string[];payerSecretKey?: ByteArrayLike;enableFeatures?: string[]; // feature IDs (base58 or kebab name)disableFeatures?: string[];allFeatures?: boolean;}
DeployOptions
interface DeployOptions {programId: string; // base58 addresssoPath?: string; // mutually exclusive with soBytessoBytes?: ByteArrayLike;idlPath?: string; // optional Anchor IDL JSON}
SetTokenAccountUpdate
interface SetTokenAccountUpdate {amount?: number;delegate?: string; // base58 pubkeyclearDelegate?: boolean;state?: string; // e.g. "initialized", "frozen"delegatedAmount?: number;closeAuthority?: string;clearCloseAuthority?: boolean;}
ResetAccountOptions
interface ResetAccountOptions {includeOwnedAccounts?: boolean;}
StreamAccountOptions
interface StreamAccountOptions {includeOwnedAccounts?: boolean;}
SolAccountFunding
interface SolAccountFunding {address: string;lamports: number;}
KeypairInfo
interface KeypairInfo {publicKey: string; // base58secretKey: number[]; // 64 bytes}
ByteArrayLike
type ByteArrayLike = Uint8Array | number[];
Quando um método aceita ByteArrayLike, você pode passar um Uint8Array ou um
array de números simples. O wrapper normaliza ambos no formato que o binding
nativo espera.
Tipos de Eventos
SimnetEventValue
Um objeto simples com um discriminador kind e campos opcionais. Consulte
Eventos para o catálogo de variantes.
interface SimnetEventValue {kind: string;message?: string;timestamp?: string;initialTransactionCount?: number;clock?: ClockValue;epochInfo?: EpochInfoValue;accountPubkey?: string;clockCommand?: string;slotIntervalMs?: number;transactionSignature?: string;logs?: string[];computeUnitsConsumed?: number;fee?: number;errorMessage?: string;tag?: string;profileKey?: string;profileSlot?: number;runbookId?: string;runbookErrors?: string[];}
ClockValue
interface ClockValue {slot: number;epoch: number;leaderScheduleEpoch: number;unixTimestamp: number;epochStartTimestamp: number;}
EpochInfoValue
interface EpochInfoValue {absoluteSlot: number;slotIndex: number;slotsInEpoch: number;epoch: number;blockHeight: number;transactionCount?: number;}
Erros
Todo método lança um Error padrão cuja mensagem encapsula o SurfnetError
Rust subjacente. Inspecione error.message para discriminar entre os casos.
try {surfnet.deploy({ programId, soPath: "missing.so" });} catch (err) {// err.message starts with "Cheatcode:" / "Startup:" / etc.console.error(err);}
Pegada do Módulo Nativo
O pacote depende de binários nativos específicos de plataforma publicados como
optionalDependencies:
| Triple | Pacote |
|---|---|
aarch64-apple-darwin | @solana/surfpool-darwin-arm64 |
x86_64-apple-darwin | @solana/surfpool-darwin-x64 |
x86_64-unknown-linux-gnu | @solana/surfpool-linux-x64-gnu |
Se nenhum dos pacotes de plataforma for instalado em sua máquina,
Surfnet.start() lança um erro claro de "módulo nativo não encontrado" na
primeira chamada. Consulte Instalação
para a matriz de suporte e solução de problemas.
Is this page helpful?