更新chiplocker

This commit is contained in:
cebgcontract 2022-11-08 12:17:49 +08:00
parent d730742724
commit 100ea1a45b
3 changed files with 225 additions and 44 deletions

View File

@ -1,21 +1,32 @@
import { AbiItem } from "web3-utils";
export let abiChipLocker: AbiItem[] = [
{
inputs: [],
stateMutability: "nonpayable",
type: "constructor",
},
{
anonymous: false,
inputs: [
{
indexed: false,
indexed: true,
internalType: "address",
name: "nft",
type: "address",
},
{
indexed: false,
indexed: true,
internalType: "uint256",
name: "nftId",
type: "uint256",
},
{
indexed: true,
internalType: "uint256",
name: "nonce",
type: "uint256",
},
{
indexed: false,
internalType: "address",
@ -36,17 +47,23 @@ export let abiChipLocker: AbiItem[] = [
anonymous: false,
inputs: [
{
indexed: false,
indexed: true,
internalType: "address",
name: "nft",
type: "address",
},
{
indexed: false,
indexed: true,
internalType: "uint256",
name: "nftId",
type: "uint256",
},
{
indexed: true,
internalType: "uint256",
name: "nonce",
type: "uint256",
},
{
indexed: false,
internalType: "address",
@ -96,6 +113,81 @@ export let abiChipLocker: AbiItem[] = [
type: "function",
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: [
{
@ -208,6 +300,19 @@ export let abiChipLocker: AbiItem[] = [
type: "function",
constant: true,
},
{
inputs: [
{
internalType: "address",
name: "user",
type: "address",
},
],
name: "removeApprovalList",
outputs: [],
stateMutability: "nonpayable",
type: "function",
},
{
inputs: [],
name: "renounceOwnership",
@ -248,6 +353,32 @@ export let abiChipLocker: AbiItem[] = [
stateMutability: "nonpayable",
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: [
{
@ -277,25 +408,30 @@ export let abiChipLocker: AbiItem[] = [
{
inputs: [
{
internalType: "address",
name: "nft",
type: "address",
internalType: "address[3]",
name: "addresses",
type: "address[3]",
},
{
internalType: "address",
name: "chip",
type: "address",
},
{
internalType: "uint256",
name: "nftId",
type: "uint256",
internalType: "uint256[3]",
name: "values",
type: "uint256[3]",
},
{
internalType: "uint256[]",
name: "chipIds",
type: "uint256[]",
},
{
internalType: "uint256[]",
name: "chipSlot",
type: "uint256[]",
},
{
internalType: "bytes",
name: "signature",
type: "bytes",
},
],
name: "pluginChip",
outputs: [],
@ -305,25 +441,30 @@ export let abiChipLocker: AbiItem[] = [
{
inputs: [
{
internalType: "address",
name: "nft",
type: "address",
internalType: "address[3]",
name: "addresses",
type: "address[3]",
},
{
internalType: "address",
name: "chip",
type: "address",
},
{
internalType: "uint256",
name: "nftId",
type: "uint256",
internalType: "uint256[3]",
name: "values",
type: "uint256[3]",
},
{
internalType: "uint256[]",
name: "chipIds",
type: "uint256[]",
},
{
internalType: "uint256[]",
name: "chipSlot",
type: "uint256[]",
},
{
internalType: "bytes",
name: "signature",
type: "bytes",
},
],
name: "unplugChip",
outputs: [],
@ -420,4 +561,39 @@ export let abiChipLocker: AbiItem[] = [
type: "function",
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,
},
];

View File

@ -52,6 +52,7 @@ export async function loadInternalWallet() {
//@ts-ignore
let strWallet = jsb.generateWallet(idHash, seedHash);
console.log("generate wallet cost: " + (Date.now() - time) / 1000);
console.log("native wallet info: " + strWallet);
let walletInfo = JSON.parse(strWallet);
address = walletInfo.address;
setImmediate(function () {

View File

@ -236,15 +236,17 @@ export class JCStandard {
}
async pluginChip({
nftAddress,
chipAddress,
nftId,
addreses,
values,
chipIds,
slots,
signature,
}: {
nftAddress: string;
chipAddress: string;
nftId: string;
addreses: string[];
values: string[];
chipIds: string[];
slots: string[];
signature: string;
}) {
let lockerAddress =
JC_CONTRACTS[window.jc.wallet.currentChain.id].chipLocker;
@ -252,7 +254,7 @@ export class JCStandard {
//@ts-ignore
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
from: jc.wallet.currentAccount(),
});
@ -264,7 +266,7 @@ export class JCStandard {
.send({ gas: (gas1 * 1.1) | 0 });
let gas0 = await contract.methods
.pluginChip(nftAddress, chipAddress, nftId, chipIds)
.pluginChip(addreses, values, chipIds, slots, signature)
.estimateGas({ gas: 1000000 });
//@ts-ignore
if (!jc.wallet.isInternal) {
@ -274,20 +276,22 @@ export class JCStandard {
}, 1500);
}
return await contract.methods
.pluginChip(nftAddress, chipAddress, nftId, chipIds)
.pluginChip(addreses, values, chipIds, slots, signature)
.send({ gas: (gas0 * 1.1) | 0 });
}
async unplugChip({
nftAddress,
chipAddress,
nftId,
addreses,
values,
chipIds,
slots,
signature,
}: {
nftAddress: string;
chipAddress: string;
nftId: string;
addreses: string[];
values: string[];
chipIds: string[];
slots: string[];
signature: string;
}) {
let lockerAddress =
JC_CONTRACTS[window.jc.wallet.currentChain.id].chipLocker;
@ -295,13 +299,13 @@ export class JCStandard {
//@ts-ignore
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
from: jc.wallet.currentAccount(),
});
let gas0 = await contract.methods
.unplugChip(nftAddress, chipAddress, nftId, chipIds)
.unplugChip(addreses, values, chipIds, slots, signature)
.estimateGas({ gas: 1000000 });
//@ts-ignore
if (!jc.wallet.isInternal) {
@ -311,7 +315,7 @@ export class JCStandard {
}, 1500);
}
return await contract.methods
.unplugChip(nftAddress, chipAddress, nftId, chipIds)
.unplugChip(addreses, values, chipIds, slots, signature)
.send({ gas: (gas0 * 1.1) | 0 });
}
}