@magiceden/magiceden-sdk
Version:
A TypeScript SDK for interacting with Magic Eden's API across multiple chains.
96 lines (95 loc) • 2.92 kB
TypeScript
import { TransactionRequest, ReadContractParameters, ReadContractReturnType, Abi, ContractFunctionName, ContractFunctionArgs } from 'viem';
import { EvmWalletProvider } from './evmWalletProvider';
import { WalletTxReceipt } from '../provider';
import { EvmBlockchain } from '../../types';
/**
* Options for the ViewWalletProvider
*/
export type ViemWalletProviderOptions = {
/**
* Gas configuration options
*/
gas?: {
/**
* Multiplier for estimated gas limit (default: 1.2)
*/
limitMultiplier?: number;
/**
* Multiplier for estimated gas fees (default: 1.0)
*/
feeMultiplier?: number;
};
};
/**
* Configuration for the ViemWalletProvider
*/
export type ViemWalletProviderConfig = {
/**
* The private key to use for the wallet
*/
privateKey: `0x${string}`;
/**
* The blockchain to use for the wallet
*/
blockchain: EvmBlockchain;
/**
* Options for the ViemWalletProvider
*/
options?: ViemWalletProviderOptions;
};
/**
* Implementation of EvmWalletProvider using Viem library
*/
export declare class ViemWalletProvider extends EvmWalletProvider {
private readonly wallet;
private readonly rpcClient;
private readonly gasOptions;
/**
* Creates a new Ethereum wallet adapter using Viem
*/
constructor(config: ViemWalletProviderConfig);
/**
* Gets the current wallet address
*/
getAddress(): string;
/**
* Retrieves the wallet's native token balance
*/
getBalance(): Promise<bigint>;
/**
* Signs a message with the wallet's private key
*/
signMessage(message: string): Promise<`0x${string}`>;
/**
* Signs EIP-712 typed data
*/
signTypedData(data: any): Promise<`0x${string}`>;
/**
* Signs a transaction without broadcasting it
*/
signTransaction(tx: TransactionRequest): Promise<`0x${string}`>;
/**
* Signs and broadcasts a transaction
*/
signAndSendTransaction(tx: TransactionRequest): Promise<`0x${string}`>;
/**
* Waits for transaction confirmation and returns receipt
*/
waitForTransactionConfirmation(txHash: `0x${string}`): Promise<WalletTxReceipt>;
/**
* Calls a read-only contract method
*/
readContract<const abi extends Abi | readonly unknown[], functionName extends ContractFunctionName<abi, 'pure' | 'view'>, const args extends ContractFunctionArgs<abi, 'pure' | 'view', functionName>>(params: ReadContractParameters<abi, functionName, args>): Promise<ReadContractReturnType<abi, functionName, args>>;
/**
* Helper to ensure account is available
*/
private validateAccount;
/**
* Helper to ensure chain is available
*/
private validateChain;
/**
* Calculate gas parameters with configured multipliers
*/
private calculateGasParameters;
}