与链交互的几个方法增加估算gas消耗的功能

This commit is contained in:
cebgcontract 2022-12-16 15:33:17 +08:00
parent df35252185
commit e420db4c16
2 changed files with 39 additions and 22 deletions

File diff suppressed because one or more lines are too long

View File

@ -275,14 +275,16 @@ function exportWalletSecKey(funId) {
} }
// ======= begin of interact with contract ======= // ======= begin of interact with contract =======
function buyNft721(funId, addresses, values, signature) { function buyNft721(funId, addresses, values, signature, estimate) {
addresses = JSON.parse(addresses); addresses = JSON.parse(addresses);
values = JSON.parse(values); values = JSON.parse(values);
estimate = (estimate || '0') | 0
jc.wallet.jcStandard jc.wallet.jcStandard
.buyNft721({ .buyNft721({
addresses, addresses,
values, values,
signature, signature,
estimate
}) })
.then((result) => { .then((result) => {
jsb.jcCallback( jsb.jcCallback(
@ -298,11 +300,12 @@ function buyNft721(funId, addresses, values, signature) {
}); });
} }
function buyNft1155(funId, addresses, values, ids, amounts, signature) { function buyNft1155(funId, addresses, values, ids, amounts, signature, estimate) {
addresses = JSON.parse(addresses); addresses = JSON.parse(addresses);
values = JSON.parse(values); values = JSON.parse(values);
ids = JSON.parse(ids); ids = JSON.parse(ids);
amounts = JSON.parse(amounts); amounts = JSON.parse(amounts);
estimate = (estimate || '0') | 0
jc.wallet.jcStandard jc.wallet.jcStandard
.buyNft1155({ .buyNft1155({
@ -311,6 +314,7 @@ function buyNft1155(funId, addresses, values, ids, amounts, signature) {
ids, ids,
amounts, amounts,
signature, signature,
estimate
}) })
.then((result) => { .then((result) => {
jsb.jcCallback( jsb.jcCallback(
@ -332,9 +336,11 @@ function evolveNft721(
tokenIds, tokenIds,
startTime, startTime,
nonce, nonce,
signature signature,
estimate
) { ) {
tokenIds = JSON.parse(tokenIds); tokenIds = JSON.parse(tokenIds);
estimate = (estimate || '0') | 0
jc.wallet.jcStandard jc.wallet.jcStandard
.evolve721NFT({ .evolve721NFT({
nftAddress, nftAddress,
@ -342,6 +348,7 @@ function evolveNft721(
startTime, startTime,
nonce, nonce,
signature, signature,
estimate
}) })
.then((result) => { .then((result) => {
jsb.jcCallback( jsb.jcCallback(
@ -357,14 +364,16 @@ function evolveNft721(
}); });
} }
function evolveChip(funId, tokenIds, startTime, nonce, signature) { function evolveChip(funId, tokenIds, startTime, nonce, signature, estimate) {
tokenIds = JSON.parse(tokenIds); tokenIds = JSON.parse(tokenIds);
estimate = (estimate || '0') | 0
jc.wallet.jcStandard jc.wallet.jcStandard
.evolveChip({ .evolveChip({
tokenIds, tokenIds,
startTime, startTime,
nonce, nonce,
signature, signature,
estimate
}) })
.then((result) => { .then((result) => {
jsb.jcCallback( jsb.jcCallback(
@ -387,10 +396,11 @@ function mintShardBatchUser(
startTime, startTime,
nonce, nonce,
signature signature
estimate
) { ) {
tokenIds = JSON.parse(tokenIds); tokenIds = JSON.parse(tokenIds);
amounts = JSON.parse(amounts); amounts = JSON.parse(amounts);
estimate = (estimate || '0') | 0
jc.wallet.jcStandard jc.wallet.jcStandard
.mintShardBatchUser({ .mintShardBatchUser({
tokenIds, tokenIds,
@ -398,6 +408,7 @@ function mintShardBatchUser(
startTime, startTime,
nonce, nonce,
signature, signature,
estimate
}) })
.then((result) => { .then((result) => {
jsb.jcCallback( jsb.jcCallback(
@ -423,11 +434,12 @@ function shardMixByUser(
amounts, amounts,
startTime, startTime,
nonce, nonce,
signature signature,
estimate
) { ) {
ids = JSON.parse(ids); ids = JSON.parse(ids);
amounts = JSON.parse(amounts); amounts = JSON.parse(amounts);
estimate = (estimate || '0') | 0
jc.wallet.jcStandard jc.wallet.jcStandard
.shardMixByUser({ .shardMixByUser({
tokenId, tokenId,
@ -439,6 +451,7 @@ function shardMixByUser(
startTime, startTime,
nonce, nonce,
signature, signature,
estimate
}) })
.then((result) => { .then((result) => {
jsb.jcCallback( jsb.jcCallback(
@ -457,12 +470,13 @@ function shardMixByUser(
// addresses: [nftId, chip, sign_address] // addresses: [nftId, chip, sign_address]
// values: [token_id,salt_nonce,startTime] // values: [token_id,salt_nonce,startTime]
// chipIds: [...chipIds] // chipIds: [...chipIds]
function pluginChip(funId, addresses, values, chipIds, slots, signature) { function pluginChip(funId, addresses, values, chipIds, slots, signature, estimate) {
console.log("addresses:" + addresses); console.log("addresses:" + addresses);
console.log("values:" + values); console.log("values:" + values);
console.log("chipIds:" + chipIds); console.log("chipIds:" + chipIds);
console.log("slots:" + slots); console.log("slots:" + slots);
console.log("signature:" + signature); console.log("signature:" + signature);
estimate = (estimate || '0') | 0
addresses = JSON.parse(addresses); addresses = JSON.parse(addresses);
values = JSON.parse(values); values = JSON.parse(values);
@ -475,6 +489,7 @@ function pluginChip(funId, addresses, values, chipIds, slots, signature) {
chipIds, chipIds,
slots, slots,
signature, signature,
estimate
}) })
.then((result) => { .then((result) => {
jsb.jcCallback( jsb.jcCallback(
@ -490,11 +505,12 @@ function pluginChip(funId, addresses, values, chipIds, slots, signature) {
// addresses: [nftId, chip, sign_address] // addresses: [nftId, chip, sign_address]
// values: [token_id,salt_nonce,startTime] // values: [token_id,salt_nonce,startTime]
// chipIds: [...chipIds] // chipIds: [...chipIds]
function unplugChip(funId, addresses, values, chipIds, slots, signature) { function unplugChip(funId, addresses, values, chipIds, slots, signature, estimate) {
addresses = JSON.parse(addresses); addresses = JSON.parse(addresses);
values = JSON.parse(values); values = JSON.parse(values);
chipIds = JSON.parse(chipIds); chipIds = JSON.parse(chipIds);
slots = JSON.parse(slots); slots = JSON.parse(slots);
estimate = (estimate || '0') | 0
jc.wallet.jcStandard jc.wallet.jcStandard
.unplugChip({ .unplugChip({
@ -503,6 +519,7 @@ function unplugChip(funId, addresses, values, chipIds, slots, signature) {
chipIds, chipIds,
slots, slots,
signature, signature,
estimate
}) })
.then((result) => { .then((result) => {
jsb.jcCallback( jsb.jcCallback(