@zebec-network/exchange-card-sdk
Version:
An sdk for purchasing silver card in zebec
128 lines (127 loc) • 3.58 kB
TypeScript
import { Provider } from "@near-js/providers";
import { FinalExecutionOutcome } from "@near-js/types";
import { APIConfig } from "../helpers/apiHelpers";
import { Quote } from "../types";
export interface CreateAccountAction {
type: "CreateAccount";
}
export interface DeployContractAction {
type: "DeployContract";
params: {
code: Uint8Array;
};
}
export interface FunctionCallAction {
type: "FunctionCall";
params: {
methodName: string;
args: object;
gas: string;
deposit: string;
};
}
export interface TransferAction {
type: "Transfer";
params: {
deposit: string;
};
}
export interface StakeAction {
type: "Stake";
params: {
stake: string;
publicKey: string;
};
}
export type AddKeyPermission = "FullAccess" | {
receiverId: string;
methodNames: Array<string>;
allowance?: string;
};
export interface AddKeyAction {
type: "AddKey";
params: {
publicKey: string;
accessKey: {
nonce?: number;
permission: AddKeyPermission;
};
};
}
export interface DeleteKeyAction {
type: "DeleteKey";
params: {
publicKey: string;
};
}
export interface DeleteAccountAction {
type: "DeleteAccount";
params: {
beneficiaryId: string;
};
}
export type Action = CreateAccountAction | DeployContractAction | FunctionCallAction | TransferAction | StakeAction | AddKeyAction | DeleteKeyAction | DeleteAccountAction;
export type ActionType = Action["type"];
/**
* Makes action payload for function call in near contract
* @param methodName method name
* @param args an object that will be passed as argument to method
* @param gas gas fee
* @param deposit deposit amount
*/
export declare function createFunctionCall(methodName: string, args: object, gas: string, deposit: string): FunctionCallAction;
export interface Transaction {
signerId: string;
receiverId: string;
actions: Array<Action>;
}
export interface NearWallet {
signerId: string;
signAndSendTransaction: (transaction: Transaction) => Promise<FinalExecutionOutcome>;
}
export declare class NearService {
readonly wallet: NearWallet;
private apiService;
readonly provider: Provider;
constructor(wallet: NearWallet, apiConfig: APIConfig, options?: {
sandbox?: boolean;
});
/**
* Fetches a quote for Bitcoin transfer.
*
* @returns {Promise<Quote>} A promise that resolves to a Quote object.
*/
fetchQuote(symbol?: string): Promise<Quote>;
/**
* Fetches the Bitcoin vault address.
*
* @returns {Promise<{ address: string }>} A promise that resolves to the vault address.
*/
fetchVault(symbol?: string): Promise<{
address: string;
tag?: string;
}>;
transferNear(params: {
signerId?: string;
amount: string;
}): Promise<FinalExecutionOutcome>;
registerAccountInTokenContract(params: {
signerId?: string;
tokenContractId: string;
}): Promise<FinalExecutionOutcome | null>;
transferTokens(params: {
signerId?: string;
amount: string;
tokenContractId: string;
}): Promise<FinalExecutionOutcome>;
getNearBalance(params: {
signerId?: string;
}): Promise<{
block_height: import("@near-js/types").BlockHeight;
block_hash: import("@near-js/types").BlockHash;
}>;
getTokenBalance(params: {
tokenContractId: string;
signerId?: string;
}): Promise<string>;
}