Skip to content

Commit

Permalink
linter and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
galekseev committed Jan 27, 2025
1 parent 4a520b7 commit 0740315
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 25 deletions.
32 changes: 20 additions & 12 deletions src/gen_qr_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@ class DropSettings {
pathZip = './src/gendata';

constructor (
flagSaveQr, // Saves QR codes with encoded links to files
flagSaveLink, // Saves generated links to json file
codeCounts, // Number of codes to generate for each amount
codeAmounts, // Amounts to generate codes
testCount, // Number of test codes to generate
version, // Version of the drop (can be included in the link)
chainId, // The chain to use the QR code on (can be included in the link)
flagNoVersionUpdate = false, // If true, the version file will not be updated (used for testing)
// Saves QR codes with encoded links to files
flagSaveQr,
// Saves generated links to json file
flagSaveLink,
// Number of codes to generate for each amount
codeCounts,
// Amounts to generate codes
codeAmounts,
// Number of test codes to generate
testCount,
// Version of the drop (can be included in the link)
version,
// The chain to use the QR code on (can be included in the link)
chainId,
// If true, the version file will not be updated (used for testing)
flagNoVersionUpdate = false,
) {
this.flagSaveQr = flagSaveQr;
this.flagSaveLink = flagSaveLink;
Expand All @@ -34,9 +42,9 @@ class DropSettings {
this.version = version;
this.chainId = chainId;
this.fileLinks = `./src/gendata/${version}-qr-links.json`;
this.testLinks = `./src/gendata/${version}-qr-links-test.json`
this.testLinks = `./src/gendata/${version}-qr-links-test.json`;
this.prefix = `https://app.1inch.io/#/${chainId}/qr?`;
this.enc_prefix = "https://wallet.1inch.io/app/w3browser?link=";
this.encPrefix = 'https://wallet.1inch.io/app/w3browser?link=';
}
}

Expand Down Expand Up @@ -172,14 +180,14 @@ async function main (settings) {
if (i < settings.testCount) {
test.push({
url: urls[i],
encUrl: settings.enc_prefix ? (settings.enc_prefix + encodeURIComponent(urls[i])) : undefined,
encUrl: settings.encPrefix ? (settings.encPrefix + encodeURIComponent(urls[i])) : undefined,
amount: amounts[i].toString(),
index: indices[i],
});
} else {
info.push({
url: urls[i],
encUrl: settings.enc_prefix ? (settings.enc_prefix + encodeURIComponent(urls[i])) : undefined,
encUrl: settings.encPrefix ? (settings.encPrefix + encodeURIComponent(urls[i])) : undefined,
amount: amounts[i].toString(),
index: indices[i],
});
Expand Down
26 changes: 13 additions & 13 deletions src/qrdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ const commander = require('commander');
const { exit } = require('process');
const program = new commander.Command();

//https://basescan.org/address/0x475757f2FbFD3e344d6E63A6Fe7C8971028b091a
// Example usage: node ./src/qrdrop.js -gqlczv 33 -a 5,10,20,30,40,50 -n 40,70,80,100,70,40
// Example usage: node ./src/qrdrop.js -gqlv 28 -a 10,20,30,40,50 -n 140,140,210,140,70
// Example usage: node ./src/qrdrop.js -x -u "https://app.1inch.io/#/1/qr?d=IgA..." -r "0x347b0605206ea9851b1172ad9c2a935f"
// Example usage: node ./src/qrdrop.js -c
// scripts
// "qr:create": "node ./src/qrdrop.js -gqlczv",
// "qr:deploy": "hardhat deploy:qr --network",
// "qr:check": "node ./src/qrdrop.js -x",
// scripts examples
// yarn qr:create 44 -a 5,10,20,30,40,50 -n 25,30,40,50,30,25 --chainid 8453
// # Usage examples
// Create drop (QRs+links) : node ./src/qrdrop.js -gqlczv 33 -a 5,10,20,30,40,50 -n 40,70,80,100,70,40
// Create drop (links only): node ./src/qrdrop.js -gqlv 28 -a 10,20,30,40,50 -n 140,140,210,140,70
// Verify links : node ./src/qrdrop.js -x -u "https://app.1inch.io/#/1/qr?d=IgA..." -r "0x347b0605206ea9851b1172ad9c2a935f"
// Clean directories : node ./src/qrdrop.js -c

// # Yarn scripts
// "lk:deploy": "hardhat deploy:qr --network",
// "lk:create": "node ./src/qrdrop.js -glcv",
// "lk:check": "node ./src/qrdrop.js -x",

// # Yarn scripts examples
// yarn lk:create 44 -a 5,10,20,30,40,50 -n 25,30,40,50,30,25 --chainid 8453
// yarn lk:create 51 -a 5,10,20,30,40,50 -n 30,30,40,50,30,20 --chainid 8453 -s
// yarn lk:deploy hardhat --v 35 --r 0xc8f9f70ceaa4d05d893e74c933eed42b --h 9
// yarn lk:check -u "https://app..." -r 0x347b0605206ea9851b1172ad9c2a935f --chainid 8453
Expand Down Expand Up @@ -71,8 +73,6 @@ execute();

async function execute () {
if (flagGenerateCodes) {


const settings = qrdrop.createNewDropSettings(flagSaveQr, flagSaveLink, COUNTS, AMOUNTS, Number(testCode[0]), VERSION, chainId, flagNoDeploy);

if (!flagNoDeploy) {
Expand Down

0 comments on commit 0740315

Please sign in to comment.