add commet for some method
This commit is contained in:
parent
0809699333
commit
3e0111f5e8
@ -13,9 +13,21 @@ function promiseCb(funId, promiseFun, dataParser) {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* oauth login before init internal wallet
|
* oauth login before init internal wallet
|
||||||
* @param {*} channel 0: google, 1: apple, 2: tiktok, 3: facebook, 4: twitter 5: tg, 6: email, 7: discord 10: client
|
* @param {string} channel:
|
||||||
* @param env: dev release
|
* 0: google,
|
||||||
* @param account guest account to bind
|
* 1: apple,
|
||||||
|
* 2: tiktok,
|
||||||
|
* 3: facebook,
|
||||||
|
* 4: twitter
|
||||||
|
* 5: tg,
|
||||||
|
* 6: email,
|
||||||
|
* 7: discord
|
||||||
|
* 10: client
|
||||||
|
* @param {string} env: dev release
|
||||||
|
* @param {string} account: guest account to bind
|
||||||
|
* @return {string} {token: string, address: string | null}
|
||||||
|
* token: token for wallet services
|
||||||
|
* address: address of wallet if already created (optional)
|
||||||
*/
|
*/
|
||||||
function walletLogin(funId, channel, env, account) {
|
function walletLogin(funId, channel, env, account) {
|
||||||
channel = parseInt(channel);
|
channel = parseInt(channel);
|
||||||
@ -26,8 +38,11 @@ function walletLogin(funId, channel, env, account) {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* init internal wallet with password
|
* init internal wallet with password
|
||||||
* @param {number | string} chain chain id
|
* @param {string} chain: chain id
|
||||||
* @param {string} pass
|
* @param {string} pass: password for wallet
|
||||||
|
* @param {string} env: dev release
|
||||||
|
* @return {string} address
|
||||||
|
* @throws {Error} if password is wrong
|
||||||
*/
|
*/
|
||||||
function initInternalWallet(funId, chain, pass, env) {
|
function initInternalWallet(funId, chain, pass, env) {
|
||||||
chain = parseInt(chain);
|
chain = parseInt(chain);
|
||||||
@ -45,6 +60,7 @@ function verifyPassword(funId, pass) {
|
|||||||
promiseCb(funId, jc.wallet.verifyLocalPass(pass));
|
promiseCb(funId, jc.wallet.verifyLocalPass(pass));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
* @Deprecated
|
||||||
* init third party wallet
|
* init third party wallet
|
||||||
* @param {number | string} chain chain id
|
* @param {number | string} chain chain id
|
||||||
*/
|
*/
|
||||||
@ -58,6 +74,16 @@ function initThirdPartyWallet(funId, chain, env) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* all chain list we supported
|
* all chain list we supported
|
||||||
|
* @return {string} JSON string of
|
||||||
|
* [{ name: string
|
||||||
|
* type: string
|
||||||
|
* rpc: string
|
||||||
|
* id: number
|
||||||
|
* network?: string
|
||||||
|
* symbol?: string
|
||||||
|
* explorerurl?: string
|
||||||
|
* decimals?: number
|
||||||
|
* }]
|
||||||
*/
|
*/
|
||||||
function chainList(funId) {
|
function chainList(funId) {
|
||||||
try {
|
try {
|
||||||
@ -68,7 +94,17 @@ function chainList(funId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* chain active
|
* current actived chain info
|
||||||
|
* @return {string} JSON string of
|
||||||
|
* { name: string
|
||||||
|
* type: string
|
||||||
|
* rpc: string
|
||||||
|
* id: number
|
||||||
|
* network?: string
|
||||||
|
* symbol?: string
|
||||||
|
* explorerurl?: string
|
||||||
|
* decimals?: number
|
||||||
|
* }
|
||||||
*/
|
*/
|
||||||
function currentChain(funId) {
|
function currentChain(funId) {
|
||||||
try {
|
try {
|
||||||
@ -79,7 +115,7 @@ function currentChain(funId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* [BOTH]change chain
|
* change current actived chain
|
||||||
*/
|
*/
|
||||||
function changeChain(funId, chainId) {
|
function changeChain(funId, chainId) {
|
||||||
chainId = parseInt(chainId);
|
chainId = parseInt(chainId);
|
||||||
@ -107,7 +143,7 @@ function getEthBalance(funId, account) {
|
|||||||
* send ETH from current account
|
* send ETH from current account
|
||||||
* @param {string} to: target account
|
* @param {string} to: target account
|
||||||
* @param {string} amount:
|
* @param {string} amount:
|
||||||
* @param {number} estimate: 1: only estimate gas price
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
*/
|
*/
|
||||||
function sendEth(funId, to, amount, estimate) {
|
function sendEth(funId, to, amount, estimate) {
|
||||||
estimate = (estimate || '0') | 0;
|
estimate = (estimate || '0') | 0;
|
||||||
@ -146,6 +182,10 @@ function erc20Balance(funId, address, account) {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* send ERC20 token to to
|
* send ERC20 token to to
|
||||||
|
* @param {string} address: contract address of ERC20
|
||||||
|
* @param {string} to: target account
|
||||||
|
* @param {string} amount: amount of token to send
|
||||||
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
*/
|
*/
|
||||||
function sendErc20(funId, address, to, amount, estimate) {
|
function sendErc20(funId, address, to, amount, estimate) {
|
||||||
estimate = (estimate || '0') | 0;
|
estimate = (estimate || '0') | 0;
|
||||||
@ -154,6 +194,10 @@ function sendErc20(funId, address, to, amount, estimate) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* send ERC721 NFT to to
|
* send ERC721 NFT to to
|
||||||
|
* @param {string} address: contract address of NFT
|
||||||
|
* @param {string} to: target account
|
||||||
|
* @param {string} tokenId: nft id of NFT
|
||||||
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
*/
|
*/
|
||||||
function sendErc721(funId, address, to, tokenId, estimate) {
|
function sendErc721(funId, address, to, tokenId, estimate) {
|
||||||
estimate = (estimate || '0') | 0;
|
estimate = (estimate || '0') | 0;
|
||||||
@ -172,9 +216,9 @@ function erc721Balance(funId, address, account, chainId) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* get balance of ERC1155
|
* get balance of ERC1155
|
||||||
* @param {string} address:
|
* @param {string} address: contract address of NFT
|
||||||
* @param {string} account:
|
* @param {string} account: wallet address
|
||||||
* @param {string} tokenId:
|
* @param {string} tokenId: nft id of NFT
|
||||||
*/
|
*/
|
||||||
function erc1155Balance(funId, address, account, tokenId) {
|
function erc1155Balance(funId, address, account, tokenId) {
|
||||||
promiseCb(funId, jc.wallet.erc1155Balance(address, account, tokenId));
|
promiseCb(funId, jc.wallet.erc1155Balance(address, account, tokenId));
|
||||||
@ -182,6 +226,11 @@ function erc1155Balance(funId, address, account, tokenId) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* send ERC1155 to to
|
* send ERC1155 to to
|
||||||
|
* @param {string} address: contract address of NFT
|
||||||
|
* @param {string} to: target account
|
||||||
|
* @param {string} tokenIds: nft id of NFT, json string of array
|
||||||
|
* @param {string} amounts: amount of token to send, json string of array
|
||||||
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
*/
|
*/
|
||||||
function sendErc1155(funId, address, to, tokenIds, amounts, estimate) {
|
function sendErc1155(funId, address, to, tokenIds, amounts, estimate) {
|
||||||
tokenIds = JSON.parse(tokenIds);
|
tokenIds = JSON.parse(tokenIds);
|
||||||
@ -190,6 +239,10 @@ function sendErc1155(funId, address, to, tokenIds, amounts, estimate) {
|
|||||||
promiseCb(funId, jc.wallet.sendErc1155(address, to, tokenIds, amounts, estimate));
|
promiseCb(funId, jc.wallet.sendErc1155(address, to, tokenIds, amounts, estimate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show QRCode for content
|
||||||
|
* @param {string} content: content to show
|
||||||
|
*/
|
||||||
function showQRCode(funId, content) {
|
function showQRCode(funId, content) {
|
||||||
try {
|
try {
|
||||||
jsb.showQRCode(funId, content);
|
jsb.showQRCode(funId, content);
|
||||||
@ -198,7 +251,11 @@ function showQRCode(funId, content) {
|
|||||||
return JSON.stringify({ errcode: 1, errmsg: err.message || err });
|
return JSON.stringify({ errcode: 1, errmsg: err.message || err });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* show webpage
|
||||||
|
* don't call this when in web page
|
||||||
|
* @param {string} url: url to show
|
||||||
|
*/
|
||||||
function showWebPage(funId, url) {
|
function showWebPage(funId, url) {
|
||||||
try {
|
try {
|
||||||
jsb.showWebPage(funId, url);
|
jsb.showWebPage(funId, url);
|
||||||
@ -209,11 +266,19 @@ function showWebPage(funId, url) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show QRCode scaner
|
||||||
|
* @param {string} title: title of scaner
|
||||||
|
*/
|
||||||
function scanQRCode(funId, title) {
|
function scanQRCode(funId, title) {
|
||||||
console.log('scanQRCode: ' + title);
|
console.log('scanQRCode: ' + title);
|
||||||
promiseCb(funId, jc.wallet.nativeSvr.scanQRCode(title));
|
promiseCb(funId, jc.wallet.nativeSvr.scanQRCode(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* export wallet private key
|
||||||
|
* @param {string} pass: password of wallet
|
||||||
|
*/
|
||||||
function exportWalletSecKey(funId, pass) {
|
function exportWalletSecKey(funId, pass) {
|
||||||
try {
|
try {
|
||||||
let key = jc.wallet.exportPrivateKey(pass);
|
let key = jc.wallet.exportPrivateKey(pass);
|
||||||
@ -224,8 +289,18 @@ function exportWalletSecKey(funId, pass) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ======= begin of interact with contract =======
|
// ======= begin of interact with contract =======
|
||||||
|
/**
|
||||||
|
* mint NFT
|
||||||
|
* @param {string} address: contract address of NFT
|
||||||
|
* @param {string} tokenIds: token id of NFT, JSON string of string array
|
||||||
|
* @parsm {string} startTime: time of signature generation
|
||||||
|
* @param {string} saltNonce: nonce of signature
|
||||||
|
* @param {string} signature: signature
|
||||||
|
* @param {string} estimate: 1: only estimate gas price
|
||||||
|
*/
|
||||||
function mintNFT(funId, address, tokenIds, startTime, saltNonce, signature, estimate) {
|
function mintNFT(funId, address, tokenIds, startTime, saltNonce, signature, estimate) {
|
||||||
tokenIds = JSON.parse(tokenIds);
|
tokenIds = JSON.parse(tokenIds);
|
||||||
|
estimate = (estimate || '0') | 0;
|
||||||
promiseCb(
|
promiseCb(
|
||||||
funId,
|
funId,
|
||||||
jc.wallet.jcStandard.mintNFT({
|
jc.wallet.jcStandard.mintNFT({
|
||||||
@ -242,8 +317,10 @@ function mintNFT(funId, address, tokenIds, startTime, saltNonce, signature, esti
|
|||||||
// ======= end of interact with contract =======
|
// ======= end of interact with contract =======
|
||||||
// ======= begin of pay =======
|
// ======= begin of pay =======
|
||||||
/**
|
/**
|
||||||
* crypto: 'CEC' or 'CEG', 'ETH'
|
* begin buy crypto with alchemy
|
||||||
* address: wallet address of user
|
* @param {string} network: 'mainnet' or 'testnet'
|
||||||
|
* @param {string} crypto: 'CEC' or 'CEG', 'ETH'
|
||||||
|
* @param {string} address: wallet address of user
|
||||||
* fiat: 'USD' or 'CNY'
|
* fiat: 'USD' or 'CNY'
|
||||||
* fiatAmount: '100'
|
* fiatAmount: '100'
|
||||||
* payWayCode: '10001'
|
* payWayCode: '10001'
|
||||||
@ -287,17 +364,23 @@ function beginPay(
|
|||||||
// ======= end of pay =======
|
// ======= end of pay =======
|
||||||
// ======= begin of transaction history =======
|
// ======= begin of transaction history =======
|
||||||
/**
|
/**
|
||||||
*
|
* query eth transaction history
|
||||||
* @param {*} funId
|
* @param {string} start
|
||||||
* @param {*} start
|
* @param {string} limit
|
||||||
* @param {*} limit
|
* @param {JSON string} moreParam e.g. {timeBegin: 1655716867832, timeEnd: 1655716867832}
|
||||||
* @param {*} moreParam e.g. {timeBegin: 1655716867832, timeEnd: 1655716867832}
|
|
||||||
*/
|
*/
|
||||||
function ethHistory(funId, start, limit, moreParam) {
|
function ethHistory(funId, start, limit, moreParam) {
|
||||||
moreParam = moreParam ? JSON.parse(moreParam) : {};
|
moreParam = moreParam ? JSON.parse(moreParam) : {};
|
||||||
promiseCb(funId, jc.wallet.historySvr.ethRecords(start, limit, moreParam));
|
promiseCb(funId, jc.wallet.historySvr.ethRecords(start, limit, moreParam));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* query token transaction history
|
||||||
|
* @param {string} start
|
||||||
|
* @param {string} limit
|
||||||
|
* @param {string} address
|
||||||
|
* @param {string} tokenId
|
||||||
|
* @param {JSON string} moreParam e.g. {timeBegin: 1655716867832, timeEnd: 1655716867832}
|
||||||
|
*/
|
||||||
function tokenHistory(funId, start, limit, address, tokenId, moreParam) {
|
function tokenHistory(funId, start, limit, address, tokenId, moreParam) {
|
||||||
moreParam = moreParam ? JSON.parse(moreParam) : {};
|
moreParam = moreParam ? JSON.parse(moreParam) : {};
|
||||||
var data = { start, limit, address, tokenId };
|
var data = { start, limit, address, tokenId };
|
||||||
@ -313,8 +396,8 @@ function emailInfo(funId) {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* send code with email
|
* send code with email
|
||||||
* @param {*} email
|
* @param {string} email
|
||||||
* @param {*} type
|
* @param {string} type
|
||||||
*/
|
*/
|
||||||
function sendEmailCode(funId, email, type) {
|
function sendEmailCode(funId, email, type) {
|
||||||
const wallet = !window.jc || !jc.wallet ? new jcwallet.default({ type: 0 }) : jc.wallet;
|
const wallet = !window.jc || !jc.wallet ? new jcwallet.default({ type: 0 }) : jc.wallet;
|
||||||
@ -322,8 +405,8 @@ function sendEmailCode(funId, email, type) {
|
|||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* verify email with code, and update email
|
* verify email with code, and update email
|
||||||
* @param {*} email
|
* @param {string} email
|
||||||
* @param {*} code
|
* @param {string} code
|
||||||
*/
|
*/
|
||||||
function verifyEmail(funId, email, code) {
|
function verifyEmail(funId, email, code) {
|
||||||
promiseCb(funId, jc.wallet.emailVerifySvr.updateEmailVerify(email, code));
|
promiseCb(funId, jc.wallet.emailVerifySvr.updateEmailVerify(email, code));
|
||||||
@ -331,7 +414,7 @@ function verifyEmail(funId, email, code) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* check if email had already been registed
|
* check if email had already been registed
|
||||||
* @param {*} email
|
* @param {string} email
|
||||||
*/
|
*/
|
||||||
function checkEmailExists(funId, email) {
|
function checkEmailExists(funId, email) {
|
||||||
const wallet = !window.jc || !jc.wallet ? new jcwallet.default({ type: 0 }) : jc.wallet;
|
const wallet = !window.jc || !jc.wallet ? new jcwallet.default({ type: 0 }) : jc.wallet;
|
||||||
@ -402,6 +485,9 @@ function getCryptoPriceOfUSD(funId, crypto, chain) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* format price
|
* format price
|
||||||
|
* @param {string} value
|
||||||
|
* @param {string} decimal: decimal of price
|
||||||
|
* @param {string} fixed: fixed of price
|
||||||
*/
|
*/
|
||||||
function formatPrice(funId, value, decimal, fixed) {
|
function formatPrice(funId, value, decimal, fixed) {
|
||||||
try {
|
try {
|
||||||
@ -414,7 +500,17 @@ function formatPrice(funId, value, decimal, fixed) {
|
|||||||
|
|
||||||
// begin of market
|
// begin of market
|
||||||
// begin sell nft with market
|
// begin sell nft with market
|
||||||
|
/**
|
||||||
|
* sell nft with market
|
||||||
|
* @param {string} nftToken: address of nft token to sell
|
||||||
|
* @param {string} currency: address of currency
|
||||||
|
* @param {string} tokenId: token id of nft to sell
|
||||||
|
* @param {string} price: price of nft
|
||||||
|
* @param {string} amount: amount of nft to sell, must be 1 for ERC721
|
||||||
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
|
*/
|
||||||
function marketSellNFT(funId, nftToken, currency, tokenId, price, amount, estimate) {
|
function marketSellNFT(funId, nftToken, currency, tokenId, price, amount, estimate) {
|
||||||
|
estimate = (estimate || '0') | 0;
|
||||||
promiseCb(
|
promiseCb(
|
||||||
funId,
|
funId,
|
||||||
jc.wallet.jcStandard.marketSellNFT({
|
jc.wallet.jcStandard.marketSellNFT({
|
||||||
@ -428,8 +524,14 @@ function marketSellNFT(funId, nftToken, currency, tokenId, price, amount, estima
|
|||||||
(v) => JSON.stringify(v)
|
(v) => JSON.stringify(v)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// update price of order
|
/**
|
||||||
|
* update price of existed order
|
||||||
|
* @param {string} orderId: order id
|
||||||
|
* @param {string} price: new price
|
||||||
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
|
*/
|
||||||
function marketUpdatePrice(funId, orderId, price, estimate) {
|
function marketUpdatePrice(funId, orderId, price, estimate) {
|
||||||
|
estimate = (estimate || '0') | 0;
|
||||||
promiseCb(
|
promiseCb(
|
||||||
funId,
|
funId,
|
||||||
jc.wallet.jcStandard.marketUpdatePrice({
|
jc.wallet.jcStandard.marketUpdatePrice({
|
||||||
@ -440,8 +542,13 @@ function marketUpdatePrice(funId, orderId, price, estimate) {
|
|||||||
(v) => JSON.stringify(v)
|
(v) => JSON.stringify(v)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// cancel order
|
/**
|
||||||
|
* cancel order
|
||||||
|
* @param {string} orderId: order id
|
||||||
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
|
*/
|
||||||
function marketCancelOrder(funId, orderId, estimate) {
|
function marketCancelOrder(funId, orderId, estimate) {
|
||||||
|
estimate = (estimate || '0') | 0;
|
||||||
promiseCb(
|
promiseCb(
|
||||||
funId,
|
funId,
|
||||||
jc.wallet.jcStandard.marketCancelOrder({
|
jc.wallet.jcStandard.marketCancelOrder({
|
||||||
@ -451,8 +558,14 @@ function marketCancelOrder(funId, orderId, estimate) {
|
|||||||
(v) => JSON.stringify(v)
|
(v) => JSON.stringify(v)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// buy order
|
/**
|
||||||
|
* buy order
|
||||||
|
* @param {string} orderId: order id
|
||||||
|
* @param {string} price: price of order
|
||||||
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
|
*/
|
||||||
function marketBuy(funId, orderId, price, estimate) {
|
function marketBuy(funId, orderId, price, estimate) {
|
||||||
|
estimate = (estimate || '0') | 0;
|
||||||
promiseCb(
|
promiseCb(
|
||||||
funId,
|
funId,
|
||||||
jc.wallet.jcStandard.marketBuy({
|
jc.wallet.jcStandard.marketBuy({
|
||||||
@ -463,8 +576,26 @@ function marketBuy(funId, orderId, price, estimate) {
|
|||||||
(v) => JSON.stringify(v)
|
(v) => JSON.stringify(v)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// buy item of game from market
|
/**
|
||||||
|
* get order info from chain
|
||||||
|
* @param {string} orderId: order id
|
||||||
|
*/
|
||||||
|
function marketOrderInfo(funId, orderId) {
|
||||||
|
promiseCb(funId, jc.wallet.jcStandard.marketOrderInfo(orderId));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* buy item of game from market
|
||||||
|
* @param {string} orderId: order id
|
||||||
|
* @param {string} seller: seller address
|
||||||
|
* @param {string} currency: address of currency
|
||||||
|
* @param {string} price: price of order
|
||||||
|
* @param {string} startTime: time for signature
|
||||||
|
* @param {string} saltNonce: nonce for signature
|
||||||
|
* @param {string} signature: signature
|
||||||
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
|
*/
|
||||||
function gameMarketBuy(funId, orderId, seller, currency, price, startTime, saltNonce, signature, estimate) {
|
function gameMarketBuy(funId, orderId, seller, currency, price, startTime, saltNonce, signature, estimate) {
|
||||||
|
estimate = (estimate || '0') | 0;
|
||||||
promiseCb(
|
promiseCb(
|
||||||
funId,
|
funId,
|
||||||
jc.wallet.jcStandard.gameMarketBuy({
|
jc.wallet.jcStandard.gameMarketBuy({
|
||||||
@ -480,15 +611,21 @@ function gameMarketBuy(funId, orderId, seller, currency, price, startTime, saltN
|
|||||||
(v) => JSON.stringify(v)
|
(v) => JSON.stringify(v)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// get order info from chain
|
|
||||||
function marketOrderInfo(funId, orderId) {
|
|
||||||
promiseCb(funId, jc.wallet.jcStandard.marketOrderInfo(orderId));
|
|
||||||
}
|
|
||||||
// end of market
|
// end of market
|
||||||
|
|
||||||
// begin of mall
|
// begin of mall
|
||||||
// buy item of game from mall
|
/**
|
||||||
|
* buy item of game from mall
|
||||||
|
* @param {string} orderId: order id
|
||||||
|
* @param {string} currency: address of currency
|
||||||
|
* @param {string} price: price of order
|
||||||
|
* @param {string} startTime: time for signature
|
||||||
|
* @param {string} saltNonce: nonce for signature
|
||||||
|
* @param {string} signature: signature
|
||||||
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
|
*/
|
||||||
function gameMallBuy(funId, orderId, currency, price, startTime, saltNonce, signature, estimate) {
|
function gameMallBuy(funId, orderId, currency, price, startTime, saltNonce, signature, estimate) {
|
||||||
|
estimate = (estimate || '0') | 0;
|
||||||
promiseCb(
|
promiseCb(
|
||||||
funId,
|
funId,
|
||||||
jc.wallet.jcStandard.gameMallBuy({
|
jc.wallet.jcStandard.gameMallBuy({
|
||||||
@ -503,10 +640,24 @@ function gameMallBuy(funId, orderId, currency, price, startTime, saltNonce, sign
|
|||||||
(v) => JSON.stringify(v)
|
(v) => JSON.stringify(v)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// end of mall
|
|
||||||
|
|
||||||
// begin of NFT mall
|
/**
|
||||||
|
* buy nft from mall
|
||||||
|
* @param {string} currency: address of currency
|
||||||
|
* @param {string} addresses: address of nft token, JSON string of array
|
||||||
|
* @param {string} ids: token id of nft, JSON string of array
|
||||||
|
* @param {string} amounts: amount of nft, JSON string of array
|
||||||
|
* @param {string} values: JSON string, e.g. [orderId, price, startTime, saltNonce]
|
||||||
|
* orderId: order id
|
||||||
|
* price: price of order
|
||||||
|
* startTime: time for signature
|
||||||
|
* saltNonce: nonce for signature
|
||||||
|
* @param {string} signature: signature
|
||||||
|
* @param {string} gas: gas price
|
||||||
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
|
*/
|
||||||
function nftMallBuy(funId, currency, addresses, ids, amounts, values, signature, gas, estimate) {
|
function nftMallBuy(funId, currency, addresses, ids, amounts, values, signature, gas, estimate) {
|
||||||
|
estimate = (estimate || '0') | 0;
|
||||||
addresses = JSON.parse(addresses);
|
addresses = JSON.parse(addresses);
|
||||||
ids = JSON.parse(ids);
|
ids = JSON.parse(ids);
|
||||||
amounts = JSON.parse(amounts);
|
amounts = JSON.parse(amounts);
|
||||||
@ -527,11 +678,15 @@ function nftMallBuy(funId, currency, addresses, ids, amounts, values, signature,
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// end of NFT mall
|
/**
|
||||||
|
* buy ceg with usdt, usdc
|
||||||
// begin of token mall
|
* @param {string} currency: address of currency
|
||||||
// buy ceg with usdt, usdc
|
* @param {string} amount: amount of currency
|
||||||
|
* @param {string} gas: gas price
|
||||||
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
|
*/
|
||||||
function buyTokenWithErc20(funId, currency, amount, gas, estimate) {
|
function buyTokenWithErc20(funId, currency, amount, gas, estimate) {
|
||||||
|
estimate = (estimate || '0') | 0;
|
||||||
promiseCb(
|
promiseCb(
|
||||||
funId,
|
funId,
|
||||||
jc.wallet.jcStandard.buyTokenWithErc20({
|
jc.wallet.jcStandard.buyTokenWithErc20({
|
||||||
@ -542,9 +697,13 @@ function buyTokenWithErc20(funId, currency, amount, gas, estimate) {
|
|||||||
(v) => JSON.stringify(v)
|
(v) => JSON.stringify(v)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// begin of token mall
|
// end of mall
|
||||||
|
|
||||||
// begin of in-app pay
|
// begin of in-app pay
|
||||||
|
/**
|
||||||
|
* query google or ios products with product ids
|
||||||
|
* @param {string} productIds: product id for query, JSON string of array
|
||||||
|
*/
|
||||||
function queryGoogleProducts(funId, productIds) {
|
function queryGoogleProducts(funId, productIds) {
|
||||||
let ids = JSON.parse(productIds);
|
let ids = JSON.parse(productIds);
|
||||||
console.log('queryGoogleProducts:: ' + productIds);
|
console.log('queryGoogleProducts:: ' + productIds);
|
||||||
@ -554,7 +713,9 @@ function queryGoogleProducts(funId, productIds) {
|
|||||||
promiseCb(funId, jc.wallet.paySvr.queryIOSProducts(ids));
|
promiseCb(funId, jc.wallet.paySvr.queryIOSProducts(ids));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* query google or ios purchases unfinished
|
||||||
|
*/
|
||||||
function queryGooglePurchases(funId) {
|
function queryGooglePurchases(funId) {
|
||||||
if (window.JavascriptJavaBridge) {
|
if (window.JavascriptJavaBridge) {
|
||||||
promiseCb(funId, jc.wallet.paySvr.queryGooglePurchases());
|
promiseCb(funId, jc.wallet.paySvr.queryGooglePurchases());
|
||||||
@ -562,7 +723,11 @@ function queryGooglePurchases(funId) {
|
|||||||
promiseCb(funId, jc.wallet.paySvr.queryIOSPurchases());
|
promiseCb(funId, jc.wallet.paySvr.queryIOSPurchases());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* begin google or ios pay
|
||||||
|
* @param {string} productId: product id
|
||||||
|
* @param {string} orderId: order id
|
||||||
|
*/
|
||||||
function beginGoogleBuy(funId, productId, orderId) {
|
function beginGoogleBuy(funId, productId, orderId) {
|
||||||
if (window.JavascriptJavaBridge) {
|
if (window.JavascriptJavaBridge) {
|
||||||
promiseCb(funId, jc.wallet.paySvr.buyGoogleProduct(productId, orderId));
|
promiseCb(funId, jc.wallet.paySvr.buyGoogleProduct(productId, orderId));
|
||||||
@ -573,7 +738,16 @@ function beginGoogleBuy(funId, productId, orderId) {
|
|||||||
// end of in-app pay
|
// end of in-app pay
|
||||||
|
|
||||||
// begin of staking
|
// begin of staking
|
||||||
|
/**
|
||||||
|
* stake nft
|
||||||
|
* @param {string} nfts: address of nft token, JSON string of array
|
||||||
|
* @param {string} tokenIds: token id of nft, JSON string of array
|
||||||
|
* @param {string} staketimes: staking time of nft, JSON string of array
|
||||||
|
* @param {string} gas: gas price
|
||||||
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
|
*/
|
||||||
function stakeNfts(funId, nfts, tokenIds, staketimes, gas, estimate) {
|
function stakeNfts(funId, nfts, tokenIds, staketimes, gas, estimate) {
|
||||||
|
estimate = (estimate || '0') | 0;
|
||||||
nfts = JSON.parse(nfts);
|
nfts = JSON.parse(nfts);
|
||||||
tokenIds = JSON.parse(tokenIds);
|
tokenIds = JSON.parse(tokenIds);
|
||||||
staketimes = JSON.parse(staketimes);
|
staketimes = JSON.parse(staketimes);
|
||||||
@ -581,30 +755,56 @@ function stakeNfts(funId, nfts, tokenIds, staketimes, gas, estimate) {
|
|||||||
JSON.stringify(v)
|
JSON.stringify(v)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* redeem nft
|
||||||
|
* @param {string} nfts: address of nft token, JSON string of array
|
||||||
|
* @param {string} tokenIds: token id of nft, JSON string of array
|
||||||
|
* @param {string} gas: gas price
|
||||||
|
* @param {string} estimate: 0: execute; 1: only estimate gas price; default: 0
|
||||||
|
*/
|
||||||
function redeemNfts(funId, nfts, tokenIds, gas, estimate) {
|
function redeemNfts(funId, nfts, tokenIds, gas, estimate) {
|
||||||
|
estimate = (estimate || '0') | 0;
|
||||||
nfts = JSON.parse(nfts);
|
nfts = JSON.parse(nfts);
|
||||||
tokenIds = JSON.parse(tokenIds);
|
tokenIds = JSON.parse(tokenIds);
|
||||||
promiseCb(funId, jc.wallet.jcStandard.redeemNfts({ nfts, tokenIds, gas, estimate }), (v) => JSON.stringify(v));
|
promiseCb(funId, jc.wallet.jcStandard.redeemNfts({ nfts, tokenIds, gas, estimate }), (v) => JSON.stringify(v));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* query nft stake info
|
||||||
|
* @param {string} nft: address of nft token
|
||||||
|
* @param {string} tokenId: token id of nft
|
||||||
|
*/
|
||||||
function nftStakeInfo(funId, nft, tokenId) {
|
function nftStakeInfo(funId, nft, tokenId) {
|
||||||
promiseCb(funId, jc.wallet.jcStandard.nftStakeInfo({ nft, tokenId }));
|
promiseCb(funId, jc.wallet.jcStandard.nftStakeInfo({ nft, tokenId }));
|
||||||
}
|
}
|
||||||
// end of staking
|
// end of staking
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete account
|
||||||
|
* delete account will delete game data for current account
|
||||||
|
* wallet for current account will be remained
|
||||||
|
*/
|
||||||
function deleteAccount(funId) {
|
function deleteAccount(funId) {
|
||||||
promiseCb(funId, jc.wallet.deleteAccount());
|
promiseCb(funId, jc.wallet.deleteAccount());
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* reset wallet address for current account
|
||||||
|
*/
|
||||||
function resetWalletAddress(funId) {
|
function resetWalletAddress(funId) {
|
||||||
promiseCb(funId, jc.wallet.resetWalletAddress());
|
promiseCb(funId, jc.wallet.resetWalletAddress());
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* storage pass with google drive
|
||||||
|
* @param {string} key: current account address
|
||||||
|
* @param {string} val: pass for current account
|
||||||
|
*/
|
||||||
function storePassLocal(funId, key, val) {
|
function storePassLocal(funId, key, val) {
|
||||||
promiseCb(funId, jc.wallet.nativeSvr.storagePass(key, val));
|
promiseCb(funId, jc.wallet.nativeSvr.storagePass(key, val));
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* restore pass from google drive
|
||||||
|
* @param {string} key: current account address
|
||||||
|
*/
|
||||||
function restorePassLocal(funId, key) {
|
function restorePassLocal(funId, key) {
|
||||||
promiseCb(funId, jc.wallet.nativeSvr.authGetStoragePass(key));
|
promiseCb(funId, jc.wallet.nativeSvr.authGetStoragePass(key));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user