更新chiplocker
This commit is contained in:
parent
d730742724
commit
100ea1a45b
@ -1,21 +1,32 @@
|
|||||||
import { AbiItem } from "web3-utils";
|
import { AbiItem } from "web3-utils";
|
||||||
|
|
||||||
export let abiChipLocker: AbiItem[] = [
|
export let abiChipLocker: AbiItem[] = [
|
||||||
|
{
|
||||||
|
inputs: [],
|
||||||
|
stateMutability: "nonpayable",
|
||||||
|
type: "constructor",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
anonymous: false,
|
anonymous: false,
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: true,
|
||||||
internalType: "address",
|
internalType: "address",
|
||||||
name: "nft",
|
name: "nft",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: true,
|
||||||
internalType: "uint256",
|
internalType: "uint256",
|
||||||
name: "nftId",
|
name: "nftId",
|
||||||
type: "uint256",
|
type: "uint256",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
indexed: true,
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "nonce",
|
||||||
|
type: "uint256",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: false,
|
||||||
internalType: "address",
|
internalType: "address",
|
||||||
@ -36,17 +47,23 @@ export let abiChipLocker: AbiItem[] = [
|
|||||||
anonymous: false,
|
anonymous: false,
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: true,
|
||||||
internalType: "address",
|
internalType: "address",
|
||||||
name: "nft",
|
name: "nft",
|
||||||
type: "address",
|
type: "address",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: true,
|
||||||
internalType: "uint256",
|
internalType: "uint256",
|
||||||
name: "nftId",
|
name: "nftId",
|
||||||
type: "uint256",
|
type: "uint256",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
indexed: true,
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "nonce",
|
||||||
|
type: "uint256",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
indexed: false,
|
indexed: false,
|
||||||
internalType: "address",
|
internalType: "address",
|
||||||
@ -96,6 +113,81 @@ export let abiChipLocker: AbiItem[] = [
|
|||||||
type: "function",
|
type: "function",
|
||||||
constant: true,
|
constant: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
internalType: "address",
|
||||||
|
name: "user",
|
||||||
|
type: "address",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
name: "addApprovalList",
|
||||||
|
outputs: [],
|
||||||
|
stateMutability: "nonpayable",
|
||||||
|
type: "function",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
internalType: "address",
|
||||||
|
name: "signer",
|
||||||
|
type: "address",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "bytes32",
|
||||||
|
name: "hash",
|
||||||
|
type: "bytes32",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "bytes",
|
||||||
|
name: "signature",
|
||||||
|
type: "bytes",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
name: "checkSigner",
|
||||||
|
outputs: [],
|
||||||
|
stateMutability: "pure",
|
||||||
|
type: "function",
|
||||||
|
constant: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
internalType: "address",
|
||||||
|
name: "signer",
|
||||||
|
type: "address",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "bytes32",
|
||||||
|
name: "structHash",
|
||||||
|
type: "bytes32",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "bytes",
|
||||||
|
name: "signature",
|
||||||
|
type: "bytes",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
name: "checkSigner712",
|
||||||
|
outputs: [],
|
||||||
|
stateMutability: "view",
|
||||||
|
type: "function",
|
||||||
|
constant: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
inputs: [],
|
||||||
|
name: "getDuration",
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "duration",
|
||||||
|
type: "uint256",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
stateMutability: "view",
|
||||||
|
type: "function",
|
||||||
|
constant: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
@ -208,6 +300,19 @@ export let abiChipLocker: AbiItem[] = [
|
|||||||
type: "function",
|
type: "function",
|
||||||
constant: true,
|
constant: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
internalType: "address",
|
||||||
|
name: "user",
|
||||||
|
type: "address",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
name: "removeApprovalList",
|
||||||
|
outputs: [],
|
||||||
|
stateMutability: "nonpayable",
|
||||||
|
type: "function",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
inputs: [],
|
inputs: [],
|
||||||
name: "renounceOwnership",
|
name: "renounceOwnership",
|
||||||
@ -248,6 +353,32 @@ export let abiChipLocker: AbiItem[] = [
|
|||||||
stateMutability: "nonpayable",
|
stateMutability: "nonpayable",
|
||||||
type: "function",
|
type: "function",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
internalType: "uint256",
|
||||||
|
name: "valNew",
|
||||||
|
type: "uint256",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
name: "updateDuation",
|
||||||
|
outputs: [],
|
||||||
|
stateMutability: "nonpayable",
|
||||||
|
type: "function",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
internalType: "bytes",
|
||||||
|
name: "signature",
|
||||||
|
type: "bytes",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
name: "useSignature",
|
||||||
|
outputs: [],
|
||||||
|
stateMutability: "nonpayable",
|
||||||
|
type: "function",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
@ -277,25 +408,30 @@ export let abiChipLocker: AbiItem[] = [
|
|||||||
{
|
{
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
internalType: "address",
|
internalType: "address[3]",
|
||||||
name: "nft",
|
name: "addresses",
|
||||||
type: "address",
|
type: "address[3]",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
internalType: "address",
|
internalType: "uint256[3]",
|
||||||
name: "chip",
|
name: "values",
|
||||||
type: "address",
|
type: "uint256[3]",
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "uint256",
|
|
||||||
name: "nftId",
|
|
||||||
type: "uint256",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
internalType: "uint256[]",
|
internalType: "uint256[]",
|
||||||
name: "chipIds",
|
name: "chipIds",
|
||||||
type: "uint256[]",
|
type: "uint256[]",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
internalType: "uint256[]",
|
||||||
|
name: "chipSlot",
|
||||||
|
type: "uint256[]",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "bytes",
|
||||||
|
name: "signature",
|
||||||
|
type: "bytes",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
name: "pluginChip",
|
name: "pluginChip",
|
||||||
outputs: [],
|
outputs: [],
|
||||||
@ -305,25 +441,30 @@ export let abiChipLocker: AbiItem[] = [
|
|||||||
{
|
{
|
||||||
inputs: [
|
inputs: [
|
||||||
{
|
{
|
||||||
internalType: "address",
|
internalType: "address[3]",
|
||||||
name: "nft",
|
name: "addresses",
|
||||||
type: "address",
|
type: "address[3]",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
internalType: "address",
|
internalType: "uint256[3]",
|
||||||
name: "chip",
|
name: "values",
|
||||||
type: "address",
|
type: "uint256[3]",
|
||||||
},
|
|
||||||
{
|
|
||||||
internalType: "uint256",
|
|
||||||
name: "nftId",
|
|
||||||
type: "uint256",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
internalType: "uint256[]",
|
internalType: "uint256[]",
|
||||||
name: "chipIds",
|
name: "chipIds",
|
||||||
type: "uint256[]",
|
type: "uint256[]",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
internalType: "uint256[]",
|
||||||
|
name: "chipSlot",
|
||||||
|
type: "uint256[]",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "bytes",
|
||||||
|
name: "signature",
|
||||||
|
type: "bytes",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
name: "unplugChip",
|
name: "unplugChip",
|
||||||
outputs: [],
|
outputs: [],
|
||||||
@ -420,4 +561,39 @@ export let abiChipLocker: AbiItem[] = [
|
|||||||
type: "function",
|
type: "function",
|
||||||
constant: true,
|
constant: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
inputs: [
|
||||||
|
{
|
||||||
|
internalType: "address",
|
||||||
|
name: "_nftAddress",
|
||||||
|
type: "address",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "address",
|
||||||
|
name: "_chipAddress",
|
||||||
|
type: "address",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "address",
|
||||||
|
name: "_userAddress",
|
||||||
|
type: "address",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
internalType: "uint256[]",
|
||||||
|
name: "_datas",
|
||||||
|
type: "uint256[]",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
name: "getMessageHash",
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
internalType: "bytes32",
|
||||||
|
name: "",
|
||||||
|
type: "bytes32",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
stateMutability: "pure",
|
||||||
|
type: "function",
|
||||||
|
constant: true,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
@ -52,6 +52,7 @@ export async function loadInternalWallet() {
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
let strWallet = jsb.generateWallet(idHash, seedHash);
|
let strWallet = jsb.generateWallet(idHash, seedHash);
|
||||||
console.log("generate wallet cost: " + (Date.now() - time) / 1000);
|
console.log("generate wallet cost: " + (Date.now() - time) / 1000);
|
||||||
|
console.log("native wallet info: " + strWallet);
|
||||||
let walletInfo = JSON.parse(strWallet);
|
let walletInfo = JSON.parse(strWallet);
|
||||||
address = walletInfo.address;
|
address = walletInfo.address;
|
||||||
setImmediate(function () {
|
setImmediate(function () {
|
||||||
|
@ -236,15 +236,17 @@ export class JCStandard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async pluginChip({
|
async pluginChip({
|
||||||
nftAddress,
|
addreses,
|
||||||
chipAddress,
|
values,
|
||||||
nftId,
|
|
||||||
chipIds,
|
chipIds,
|
||||||
|
slots,
|
||||||
|
signature,
|
||||||
}: {
|
}: {
|
||||||
nftAddress: string;
|
addreses: string[];
|
||||||
chipAddress: string;
|
values: string[];
|
||||||
nftId: string;
|
|
||||||
chipIds: string[];
|
chipIds: string[];
|
||||||
|
slots: string[];
|
||||||
|
signature: string;
|
||||||
}) {
|
}) {
|
||||||
let lockerAddress =
|
let lockerAddress =
|
||||||
JC_CONTRACTS[window.jc.wallet.currentChain.id].chipLocker;
|
JC_CONTRACTS[window.jc.wallet.currentChain.id].chipLocker;
|
||||||
@ -252,7 +254,7 @@ export class JCStandard {
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
from: jc.wallet.currentAccount(),
|
from: jc.wallet.currentAccount(),
|
||||||
});
|
});
|
||||||
let chipInstance = new this.web3.eth.Contract(abiERC1155, chipAddress, {
|
let chipInstance = new this.web3.eth.Contract(abiERC1155, addreses[1], {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
from: jc.wallet.currentAccount(),
|
from: jc.wallet.currentAccount(),
|
||||||
});
|
});
|
||||||
@ -264,7 +266,7 @@ export class JCStandard {
|
|||||||
.send({ gas: (gas1 * 1.1) | 0 });
|
.send({ gas: (gas1 * 1.1) | 0 });
|
||||||
|
|
||||||
let gas0 = await contract.methods
|
let gas0 = await contract.methods
|
||||||
.pluginChip(nftAddress, chipAddress, nftId, chipIds)
|
.pluginChip(addreses, values, chipIds, slots, signature)
|
||||||
.estimateGas({ gas: 1000000 });
|
.estimateGas({ gas: 1000000 });
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
if (!jc.wallet.isInternal) {
|
if (!jc.wallet.isInternal) {
|
||||||
@ -274,20 +276,22 @@ export class JCStandard {
|
|||||||
}, 1500);
|
}, 1500);
|
||||||
}
|
}
|
||||||
return await contract.methods
|
return await contract.methods
|
||||||
.pluginChip(nftAddress, chipAddress, nftId, chipIds)
|
.pluginChip(addreses, values, chipIds, slots, signature)
|
||||||
.send({ gas: (gas0 * 1.1) | 0 });
|
.send({ gas: (gas0 * 1.1) | 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
async unplugChip({
|
async unplugChip({
|
||||||
nftAddress,
|
addreses,
|
||||||
chipAddress,
|
values,
|
||||||
nftId,
|
|
||||||
chipIds,
|
chipIds,
|
||||||
|
slots,
|
||||||
|
signature,
|
||||||
}: {
|
}: {
|
||||||
nftAddress: string;
|
addreses: string[];
|
||||||
chipAddress: string;
|
values: string[];
|
||||||
nftId: string;
|
|
||||||
chipIds: string[];
|
chipIds: string[];
|
||||||
|
slots: string[];
|
||||||
|
signature: string;
|
||||||
}) {
|
}) {
|
||||||
let lockerAddress =
|
let lockerAddress =
|
||||||
JC_CONTRACTS[window.jc.wallet.currentChain.id].chipLocker;
|
JC_CONTRACTS[window.jc.wallet.currentChain.id].chipLocker;
|
||||||
@ -295,13 +299,13 @@ export class JCStandard {
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
from: jc.wallet.currentAccount(),
|
from: jc.wallet.currentAccount(),
|
||||||
});
|
});
|
||||||
let chipInstance = new this.web3.eth.Contract(abiERC1155, chipAddress, {
|
let chipInstance = new this.web3.eth.Contract(abiERC1155, addreses[1], {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
from: jc.wallet.currentAccount(),
|
from: jc.wallet.currentAccount(),
|
||||||
});
|
});
|
||||||
|
|
||||||
let gas0 = await contract.methods
|
let gas0 = await contract.methods
|
||||||
.unplugChip(nftAddress, chipAddress, nftId, chipIds)
|
.unplugChip(addreses, values, chipIds, slots, signature)
|
||||||
.estimateGas({ gas: 1000000 });
|
.estimateGas({ gas: 1000000 });
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
if (!jc.wallet.isInternal) {
|
if (!jc.wallet.isInternal) {
|
||||||
@ -311,7 +315,7 @@ export class JCStandard {
|
|||||||
}, 1500);
|
}, 1500);
|
||||||
}
|
}
|
||||||
return await contract.methods
|
return await contract.methods
|
||||||
.unplugChip(nftAddress, chipAddress, nftId, chipIds)
|
.unplugChip(addreses, values, chipIds, slots, signature)
|
||||||
.send({ gas: (gas0 * 1.1) | 0 });
|
.send({ gas: (gas0 * 1.1) | 0 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user