smart-contract-interaction
Version:
Interact with the Nexlabs smart contracts
93 lines (87 loc) • 2.75 kB
TypeScript
import { ethers } from 'ethers';
import { TransactionReceipt } from 'viem';
import React from 'react';
interface Config {
wallet: {
address: string;
privateKey: string;
};
rpc: {
local: string;
mainnet: string;
wallet: object | {};
};
env: 0 | 1 | 2;
[key: string]: any;
}
interface ProviderResult {
provider: ethers.providers.Provider;
signer: ethers.Signer;
}
type allowedMintSymbolProps = 'USDT' | 'USDC';
type allowedIndexSymbolProps = 'ANFI' | 'CRYPTO5' | 'MAG7' | 'ARBEI';
type modeType = 'dark' | 'light';
interface nexTokenDataType {
symbol: string;
shortName: string;
decimals: number;
address: string;
logo: string;
totalToken?: number;
totalTokenUsd?: number;
percentage?: number;
indexDayChange?: number;
}
interface Coin {
logo: string;
name: string;
Symbol: string;
address: string;
isNexlabToken?: boolean;
indexType?: string;
factoryAddress: string;
decimals: number;
}
interface SwapResult {
success: boolean;
message: string;
error?: Error;
receipt?: TransactionReceipt;
}
interface SwapPropsObjectType {
connectionConfig: Config;
mode: modeType;
swapFromCurrSymbol?: allowedIndexSymbolProps | allowedMintSymbolProps;
swapToCurrSymbol?: allowedIndexSymbolProps | allowedMintSymbolProps;
onCompletion: (data: SwapResult) => void;
}
interface SwapProps {
configs: SwapPropsObjectType;
}
declare class NexIndex {
indexName: allowedIndexSymbolProps;
indexType: string;
tokenAddress: string;
factoryAddress: string;
config: Config;
provider: ethers.providers.Provider;
signer: ethers.Signer;
index_tokenContract: ethers.Contract;
index_factoryContract: ethers.Contract;
constructor(indexName: allowedIndexSymbolProps, config: Config);
getAddress(): Promise<string>;
getBalance(): Promise<number>;
getFeeRate(): Promise<number>;
getTotalSupply(): Promise<number>;
getAllowance(): Promise<number>;
approve(fromSymbol: allowedMintSymbolProps, amount: number): Promise<ethers.providers.TransactionReceipt>;
mint(fromSymbol: allowedMintSymbolProps, amount: number): Promise<ethers.providers.TransactionReceipt | Error>;
burn(amount: number): Promise<ethers.providers.TransactionReceipt>;
}
declare const Swap: React.FC<SwapProps>;
declare const Environment: {
readonly LOCAL: 0;
readonly MAINNET: 1;
readonly WALLET_EXTENSION: 2;
};
export { type Coin, type Config, Environment, NexIndex, type ProviderResult, Swap, type SwapProps, type SwapPropsObjectType, type SwapResult, type allowedIndexSymbolProps, type allowedMintSymbolProps, type modeType, type nexTokenDataType };