1
This commit is contained in:
parent
675b520d66
commit
aa9013ab55
@ -4,13 +4,13 @@ const sigUtil = require('@metamask/eth-sig-util');
|
|||||||
const app = require('j7/app');
|
const app = require('j7/app');
|
||||||
const utils = require('j7/utils');
|
const utils = require('j7/utils');
|
||||||
const bcutils = require('j7/bcutils');
|
const bcutils = require('j7/bcutils');
|
||||||
const bc = require('../blockchain');
|
|
||||||
const metaFactory = require('../metadata/factory');
|
const metaFactory = require('../metadata/factory');
|
||||||
|
|
||||||
async function claim(session) {
|
async function claim(session) {
|
||||||
try {
|
try {
|
||||||
const account = session.request('account');
|
const account = session.request('account');
|
||||||
const netId = session.request('net_id');
|
const netId = session.request('net_id');
|
||||||
|
const bc = null;
|
||||||
|
|
||||||
const nftAddress = bc.getNftAddress(bcutils.CLAIM_BOX_TYPE);
|
const nftAddress = bc.getNftAddress(bcutils.CLAIM_BOX_TYPE);
|
||||||
|
|
||||||
@ -37,22 +37,15 @@ async function claim(session) {
|
|||||||
['trans_id', transId]
|
['trans_id', transId]
|
||||||
]);
|
]);
|
||||||
const nonce = transId;
|
const nonce = transId;
|
||||||
const tokenIds = [tokenId];
|
const signature = await bc.soliditySha3Sign(
|
||||||
utils.arrayToStrings(tokenIds);
|
|
||||||
let signStr = await bc.web3.utils.soliditySha3
|
|
||||||
(
|
|
||||||
account,
|
account,
|
||||||
nftAddress,
|
nftAddress,
|
||||||
nowTime,
|
nowTime,
|
||||||
nonce,
|
nonce
|
||||||
...tokenIds
|
|
||||||
);
|
);
|
||||||
let signature = await bc.web3.eth.sign(signStr, userAddress);
|
|
||||||
signature = signature.replace(/00$/, "1b").replace(/01$/, "1c");
|
|
||||||
|
|
||||||
const rspParams = [
|
const rspParams = [
|
||||||
nftAddress,
|
nftAddress,
|
||||||
utils.jsonEncode(tokenIds),
|
|
||||||
nowTime,
|
nowTime,
|
||||||
nonce,
|
nonce,
|
||||||
signature
|
signature
|
||||||
|
@ -34,7 +34,7 @@ class BlockChain extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async soliditySha3Sign(...args) {
|
async soliditySha3Sign(...args) {
|
||||||
let signStr = await this.#bc.web3.utils.soliditySha3(...args);
|
const signStr = await this.#bc.web3.utils.soliditySha3(...args);
|
||||||
let signature = await this.#bc.web3.eth.sign(signStr, this.getUserAddress());
|
let signature = await this.#bc.web3.eth.sign(signStr, this.getUserAddress());
|
||||||
signature = signature.replace(/00$/, "1b").replace(/01$/, "1c");
|
signature = signature.replace(/00$/, "1b").replace(/01$/, "1c");
|
||||||
return signature;
|
return signature;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user