gaas-js-sdk
v0.1.0
Published
gaas web app js sdk
Readme
gaas-js-sdk
Introduction
This is a javascript SDK for gaas platform.
Install
npm i gaas-js-sdk
Usage
import { GaasJsSdk } from 'gaas-js-sdk';
const gaasJsSdk = new GaasJsSdk({
clientAppId: 'your app id',
});
// use gaas login
gaasJsSdk.login({
onLoginSuccess: (r) => {
const { code, data } = r;
if (code === '000000') {
const code = data.n;
// todo : use code to get userInfo from your server
}
},
});API
- const gaasJsSdk = new GaasJsSdk(options:GaasOptions)
enum LoginMethods {
google = 'Google',
metamask = 'MetaMask',
okx = 'OKx',
}
interface GaasOptions {
clientAppId: string;
gameName?: string;
loginMethods?: Array<LoginMethods>;
locale?: string;
isNeedBindWallet?: boolean;
}- gaasJsSdk.login(params: LoginParams)
interface LoginParams {
hasClose?: boolean;
channel?: string;
inviteCode?: string;
hasGuest?: boolean;
onLoginSuccess?: (params: SuccessProps) => void;
}
interface SuccessProps {
success: boolean;
n?: string;
nickName?: string;
loginSymbol?: string;
isRegister?: boolean;
type?: string;
}- gaasJsSdk.wallet(params: WalletProps)
interface WalletProps {
hasWallet: boolean;
userNumber?: string;
tabKey?: string;
onLoginSuccess?: (params: SuccessProps) => void;
}- gaasJsSdk.market(params: MarketProps)
interface MarketProps {
hasWallet: boolean;
userNumber?: string;
tabKey?: string;
batchListing?: { assetId: number, assetTokenId: string }[];
assetId?: number;
assetType?: string;
categoryName?: string;
onLoginSuccess?: (params: SuccessProps) => void;
}- gaasJsSdk.pay(params: PayProps)
interface PayProps {
hasWallet: boolean;
userNumber?: string;
orderNumber: string;
onPaySuccess?: () => void;
onLoginSuccess?: (params: SuccessProps) => void;
}- gaasJsSdk.transfer(params: TransferType)
interface TransferType {
hasWallet: boolean;
userNumber?: string;
onTransferSuccess?: (res: { success: boolean, error?: string }) => void;
onLoginSuccess?: (params: SuccessProps) => void;
assetChainId: number;
assetId?: number;
assetTokenId?: string;
}LICENSE
MIT
