mirror of
https://github.com/status-im/keycard-redeem.git
synced 2025-01-13 21:54:39 +00:00
support utf-8 codes, perform kekkac256 automatically
This commit is contained in:
parent
0ab131a198
commit
ea6b4c00cf
@ -3,6 +3,7 @@
|
||||
import Web3 from 'web3';
|
||||
import parseArgs from 'minimist';
|
||||
import fs from 'fs';
|
||||
import { keccak256 } from 'js-sha3';
|
||||
|
||||
const argv = parseArgs(process.argv.slice(2), {boolean: ["nft", "deploy-factory", "deploy-bucket"], string: ["sender", "factory", "bucket", "token"], default: {"endpoint": "ws://127.0.0.1:8546", "start-in-days": 0, "validity-days": 365, "max-tx-delay-blocks": 10}});
|
||||
|
||||
@ -115,9 +116,17 @@ async function transferNFT(sender, token, bucket, keycard) {
|
||||
}
|
||||
}
|
||||
|
||||
function processCode(code) {
|
||||
if (!code.startsWith("0x")) {
|
||||
code = "0x" + Buffer.from(code, 'utf8').toString('hex');
|
||||
}
|
||||
|
||||
return "0x" + keccak256(code);
|
||||
}
|
||||
|
||||
function processLine(line) {
|
||||
let c = line.split(",").map((e) => e.toLowerCase().trim());
|
||||
return {keycard: c[0], amount: parseInt(c[1]), code: c[2]};
|
||||
return {keycard: c[0], amount: parseInt(c[1]), code: processCode(c[2])};
|
||||
}
|
||||
|
||||
async function run() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user