update main.js
This commit is contained in:
parent
5de9f17494
commit
5222536fbd
149
js/main.js
149
js/main.js
@ -6,9 +6,8 @@ console.log(">>begin load wallet main file");
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
function initWallet(funId, type, chain) {
|
function initWallet(funId, type, chain) {
|
||||||
// chain = chain || 80001
|
type = parseInt(type)
|
||||||
type = 0
|
chain = parseInt(chain)
|
||||||
chain = 1338
|
|
||||||
try {
|
try {
|
||||||
var wallet;
|
var wallet;
|
||||||
if (!window.jc || !jc.wallet) {
|
if (!window.jc || !jc.wallet) {
|
||||||
@ -163,40 +162,28 @@ function createAccount(funId) {
|
|||||||
* @return {string} account actived
|
* @return {string} account actived
|
||||||
*/
|
*/
|
||||||
function importAccount(funId, privateKey) {
|
function importAccount(funId, privateKey) {
|
||||||
// try {
|
try {
|
||||||
// let address = jc.wallet.importAccount(privateKey);
|
let address = jc.wallet.importAccount(privateKey);
|
||||||
// return JSON.stringify({
|
return JSON.stringify({
|
||||||
// errcode: 0,
|
errcode: 0,
|
||||||
// data: address,
|
data: address,
|
||||||
// });
|
|
||||||
// } catch (err) {
|
|
||||||
// return JSON.stringify({
|
|
||||||
// errcode: 1,
|
|
||||||
// errmsg: err,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
let addresses = ["0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1","0xCd36bFD6f5c9685A5b1DD953E8279eeC7d41e1E1","0xb3212b66C337F83D277172D891Daf31776FF9D79"]
|
|
||||||
let values = ["1024168356010420","0","110241683560010039000000000000000134390000000000000003020000000000000000000000","1667381156"]
|
|
||||||
let signature = '0x5788bc2812b31165aff7c344321076b55d61f84ee1cb064f12fac3cea7cfbbd03f180a2228b4cce665a00d52fd08c10e3e09d1bf22a008c999bd72dcb372f6fb1b'
|
|
||||||
jc.wallet.jcStandard
|
|
||||||
.buyNft721({
|
|
||||||
addresses,
|
|
||||||
values,
|
|
||||||
signature,
|
|
||||||
})
|
|
||||||
.then((result) => {
|
|
||||||
jsb.jcCallback(
|
|
||||||
funId,
|
|
||||||
JSON.stringify({
|
|
||||||
errcode: 0,
|
|
||||||
data: result,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(JSON.stringify(err))
|
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
|
||||||
});
|
});
|
||||||
|
} catch (err) {
|
||||||
|
return JSON.stringify({
|
||||||
|
errcode: 1,
|
||||||
|
errmsg: err,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// jc.wallet.erc20Standard.transfer({
|
||||||
|
// address: '0xC76c692450d6221A8B1E035CB8bdB639bC60658D',
|
||||||
|
// from: '0x50A8e60041A206AcaA5F844a1104896224be6F39',
|
||||||
|
// to: '0x746338765a8FbDD1c5aB61bfb92CD6D960C3C662',
|
||||||
|
// amount: 101
|
||||||
|
// }).then((res) => {
|
||||||
|
// console.log(JSON.stringify(res))
|
||||||
|
// }).catch(err => {
|
||||||
|
// console.log(JSON.stringify(err))
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* active one account
|
* active one account
|
||||||
@ -400,9 +387,8 @@ function signOutGoogle(funId) {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
function buyNft721(funId, addresses, values, signature) {
|
function buyNft721(funId, addresses, values, signature) {
|
||||||
addresses = ["0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1","0xCd36bFD6f5c9685A5b1DD953E8279eeC7d41e1E1","0xb3212b66C337F83D277172D891Daf31776FF9D79"]
|
addresses = JSON.parse(addresses)
|
||||||
values = ["1024168356010499","0","110241683560010039000000000000000134390000000000000003020000000000000000000000","1667381156"]
|
values = JSON.parse(values)
|
||||||
signature = '0x4278d777d25fa96bb9733dd6c924adf9a79a88de60c684894f29f02c739ff79231d62ecd10d9a07121d88f6719f6b49814fc2e9438a03a46e6bf0def5c1e3ad71b'
|
|
||||||
jc.wallet.jcStandard
|
jc.wallet.jcStandard
|
||||||
.buyNft721({
|
.buyNft721({
|
||||||
addresses,
|
addresses,
|
||||||
@ -414,7 +400,7 @@ function buyNft721(funId, addresses, values, signature) {
|
|||||||
funId,
|
funId,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
errcode: 0,
|
errcode: 0,
|
||||||
data: result,
|
data: JSON.stringify(result),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@ -424,6 +410,11 @@ function buyNft721(funId, addresses, values, signature) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buyNft1155(funId, addresses, values, ids, amounts, signature) {
|
function buyNft1155(funId, addresses, values, ids, amounts, signature) {
|
||||||
|
addresses = JSON.parse(addresses)
|
||||||
|
values = JSON.parse(values)
|
||||||
|
ids = JSON.parse(ids)
|
||||||
|
amounts = JSON.parse(amounts)
|
||||||
|
|
||||||
jc.wallet.jcStandard
|
jc.wallet.jcStandard
|
||||||
.buyNft1155({
|
.buyNft1155({
|
||||||
addresses,
|
addresses,
|
||||||
@ -437,7 +428,7 @@ function buyNft1155(funId, addresses, values, ids, amounts, signature) {
|
|||||||
funId,
|
funId,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
errcode: 0,
|
errcode: 0,
|
||||||
data: result,
|
data: JSON.stringify(result),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@ -454,7 +445,7 @@ function evolveNft721(
|
|||||||
nonce,
|
nonce,
|
||||||
signature
|
signature
|
||||||
) {
|
) {
|
||||||
{
|
tokenIds = JSON.parse(tokenIds)
|
||||||
jc.wallet.jcStandard
|
jc.wallet.jcStandard
|
||||||
.evolve721NFT({
|
.evolve721NFT({
|
||||||
nftAddress,
|
nftAddress,
|
||||||
@ -468,17 +459,17 @@ function evolveNft721(
|
|||||||
funId,
|
funId,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
errcode: 0,
|
errcode: 0,
|
||||||
data: result,
|
data: JSON.stringify(result),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function evolveChip(funId, tokenIds, startTime, nonce, signature) {
|
function evolveChip(funId, tokenIds, startTime, nonce, signature) {
|
||||||
|
tokenIds = JSON.parse(tokenIds)
|
||||||
jc.wallet.jcStandard
|
jc.wallet.jcStandard
|
||||||
.evolveChip({
|
.evolveChip({
|
||||||
tokenIds,
|
tokenIds,
|
||||||
@ -491,7 +482,7 @@ function evolveChip(funId, tokenIds, startTime, nonce, signature) {
|
|||||||
funId,
|
funId,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
errcode: 0,
|
errcode: 0,
|
||||||
data: result,
|
data: JSON.stringify(result),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@ -508,6 +499,9 @@ function mintShardBatchUser(
|
|||||||
nonce,
|
nonce,
|
||||||
signature
|
signature
|
||||||
) {
|
) {
|
||||||
|
tokenIds = JSON.parse(tokenIds)
|
||||||
|
amounts = JSON.parse(amounts)
|
||||||
|
|
||||||
jc.wallet.jcStandard
|
jc.wallet.jcStandard
|
||||||
.mintShardBatchUser({
|
.mintShardBatchUser({
|
||||||
tokenIds,
|
tokenIds,
|
||||||
@ -521,7 +515,7 @@ function mintShardBatchUser(
|
|||||||
funId,
|
funId,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
errcode: 0,
|
errcode: 0,
|
||||||
data: result,
|
data: JSON.stringify(result),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
@ -542,6 +536,9 @@ function shardMixByUser(
|
|||||||
nonce,
|
nonce,
|
||||||
signature
|
signature
|
||||||
) {
|
) {
|
||||||
|
ids = JSON.parse(ids)
|
||||||
|
amounts = JSON.parse(amounts)
|
||||||
|
|
||||||
jc.wallet.jcStandard
|
jc.wallet.jcStandard
|
||||||
.shardMixByUser({
|
.shardMixByUser({
|
||||||
tokenId,
|
tokenId,
|
||||||
@ -559,52 +556,74 @@ function shardMixByUser(
|
|||||||
funId,
|
funId,
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
errcode: 0,
|
errcode: 0,
|
||||||
data: result,
|
data: JSON.stringify(result),
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// addresses: [nftId, chip, sign_address]
|
||||||
|
// values: [token_id,salt_nonce,startTime]
|
||||||
|
// chipIds: [...chipIds]
|
||||||
function pluginChip(
|
function pluginChip(
|
||||||
funId,
|
funId,
|
||||||
nftAddress,
|
addresses,
|
||||||
chipAddress,
|
values,
|
||||||
nftId,
|
chipIds,
|
||||||
chipIds
|
slots,
|
||||||
|
signature
|
||||||
) {
|
) {
|
||||||
|
addresses = JSON.parse(addresses)
|
||||||
|
values = JSON.parse(values)
|
||||||
|
chipIds = JSON.parse(chipIds)
|
||||||
|
slots = JSON.parse(slots)
|
||||||
|
|
||||||
jc.wallet.jcStandard
|
jc.wallet.jcStandard
|
||||||
.pluginChip({
|
.pluginChip({
|
||||||
nftAddress,
|
addresses,
|
||||||
chipAddress,
|
values,
|
||||||
nftId,
|
chipIds,
|
||||||
chipIds
|
slots,
|
||||||
|
signature
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: result}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: JSON.stringify(result)}));
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// addresses: [nftId, chip, sign_address]
|
||||||
|
// values: [token_id,salt_nonce,startTime]
|
||||||
|
// chipIds: [...chipIds]
|
||||||
function unplugChip(
|
function unplugChip(
|
||||||
funId,
|
funId,
|
||||||
nftAddress,
|
addresses,
|
||||||
chipAddress,
|
values,
|
||||||
nftId,
|
chipIds,
|
||||||
chipIds
|
slots,
|
||||||
|
signature
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
addresses = JSON.parse(addresses)
|
||||||
|
values = JSON.parse(values)
|
||||||
|
chipIds = JSON.parse(chipIds)
|
||||||
|
slots = JSON.parse(slots)
|
||||||
|
|
||||||
jc.wallet.jcStandard
|
jc.wallet.jcStandard
|
||||||
.unplugChip({
|
.unplugChip({
|
||||||
nftAddress,
|
addresses,
|
||||||
chipAddress,
|
values,
|
||||||
nftId,
|
chipIds,
|
||||||
chipIds
|
slots,
|
||||||
|
signature
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: result}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: JSON.stringify(result)}));
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user