From ea99fc54e24d7b78c1bc7588849ff8e606a37c8b Mon Sep 17 00:00:00 2001 From: cebgcontract <99630598+cebgcontract@users.noreply.github.com> Date: Fri, 4 Nov 2022 15:31:03 +0800 Subject: [PATCH] update js lib --- js/main.js | 104 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 82 insertions(+), 22 deletions(-) diff --git a/js/main.js b/js/main.js index 9d98258..dbae2be 100644 --- a/js/main.js +++ b/js/main.js @@ -6,7 +6,9 @@ console.log(">>begin load wallet main file"); */ function initWallet(funId, type, chain) { - chain = chain || 80001 + // chain = chain || 80001 + type = 0 + chain = 1338 try { var wallet; if (!window.jc || !jc.wallet) { @@ -161,28 +163,40 @@ function createAccount(funId) { * @return {string} account actived */ function importAccount(funId, privateKey) { - try { - let address = jc.wallet.importAccount(privateKey); - return JSON.stringify({ - errcode: 0, - data: address, + // try { + // let address = jc.wallet.importAccount(privateKey); + // return JSON.stringify({ + // errcode: 0, + // 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 @@ -386,6 +400,9 @@ function signOutGoogle(funId) { //} function buyNft721(funId, addresses, values, signature) { + addresses = ["0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1","0xCd36bFD6f5c9685A5b1DD953E8279eeC7d41e1E1","0xb3212b66C337F83D277172D891Daf31776FF9D79"] + values = ["1024168356010499","0","110241683560010039000000000000000134390000000000000003020000000000000000000000","1667381156"] + signature = '0x4278d777d25fa96bb9733dd6c924adf9a79a88de60c684894f29f02c739ff79231d62ecd10d9a07121d88f6719f6b49814fc2e9438a03a46e6bf0def5c1e3ad71b' jc.wallet.jcStandard .buyNft721({ addresses, @@ -549,4 +566,47 @@ function shardMixByUser( .catch((err) => { jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err})); }); + +function pluginChip( + funId, + nftAddress, + chipAddress, + nftId, + chipIds +) { + jc.wallet.jcStandard + .pluginChip({ + nftAddress, + chipAddress, + nftId, + chipIds + }) + .then((result) => { + jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: result})); + }) + .catch((err) => { + jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err})); + }); +} + +function unplugChip( + funId, + nftAddress, + chipAddress, + nftId, + chipIds +) { + jc.wallet.jcStandard + .unplugChip({ + nftAddress, + chipAddress, + nftId, + chipIds + }) + .then((result) => { + jsb.jcCallback(funId,JSON.stringify({errcode: 0,data: result})); + }) + .catch((err) => { + jsb.jcCallback(funId,JSON.stringify({errcode: 1,errmsg: err})); + }); }