Co-authored-by: okwme <964052+okwme@users.noreply.github.com>pull/237/head^2
parent
b8cdf308c0
commit
c9a030e495
@ -0,0 +1 @@
|
|||||||
|
qrcodegen-demo.o: qrcodegen-demo.c qrcodegen.h
|
||||||
@ -0,0 +1 @@
|
|||||||
|
qrcodegen.o: qrcodegen.c qrcodegen.h
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,4 @@
|
|||||||
|
node_modules/
|
||||||
|
artifacts/
|
||||||
|
cache/
|
||||||
|
typechain-types/
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,25 @@
|
|||||||
|
import "@nomicfoundation/hardhat-toolbox";
|
||||||
|
|
||||||
|
/** @type import('hardhat/config').HardhatUserConfig */
|
||||||
|
const config = {
|
||||||
|
solidity: {
|
||||||
|
version: "0.8.34",
|
||||||
|
settings: {
|
||||||
|
viaIR: true,
|
||||||
|
optimizer: {
|
||||||
|
enabled: true,
|
||||||
|
runs: 200,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
networks: {
|
||||||
|
hardhat: {
|
||||||
|
// QR Code generation requires significant gas.
|
||||||
|
// blockGasLimit increases the cap for calls; gas is the default per-tx limit.
|
||||||
|
blockGasLimit: 30_000_000,
|
||||||
|
allowUnlimitedContractSize: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"name": "qrcodegen-solidity",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "QR Code generator library — Solidity port",
|
||||||
|
"main": "index.js",
|
||||||
|
"directories": {
|
||||||
|
"test": "test"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "hardhat test",
|
||||||
|
"compile": "node scripts/compile.js"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"type": "module",
|
||||||
|
"devDependencies": {
|
||||||
|
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
|
||||||
|
"ethers": "^6.16.0",
|
||||||
|
"hardhat": "^2.28.6",
|
||||||
|
"solc": "^0.8.34"
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* Compile script — uses the bundled solc npm package (no internet required).
|
||||||
|
* Outputs compiled JSON artifacts to the artifacts/ directory.
|
||||||
|
*
|
||||||
|
* Usage: node scripts/compile.js
|
||||||
|
* or: npm run compile
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { readFileSync, writeFileSync, mkdirSync } from "fs";
|
||||||
|
import { createRequire } from "module";
|
||||||
|
import { resolve, dirname } from "path";
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const solc = require("solc");
|
||||||
|
|
||||||
|
const contractsDir = resolve(__dirname, "../contracts");
|
||||||
|
const artifactsDir = resolve(__dirname, "../artifacts");
|
||||||
|
mkdirSync(artifactsDir, { recursive: true });
|
||||||
|
|
||||||
|
const input = {
|
||||||
|
language: "Solidity",
|
||||||
|
sources: {
|
||||||
|
"QRCode.sol": { content: readFileSync(`${contractsDir}/QRCode.sol`, "utf8") },
|
||||||
|
"QRCodeDemo.sol": { content: readFileSync(`${contractsDir}/QRCodeDemo.sol`, "utf8") },
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
viaIR: true,
|
||||||
|
optimizer: { enabled: true, runs: 200 },
|
||||||
|
outputSelection: {
|
||||||
|
"*": { "*": ["abi", "evm.bytecode.object", "evm.deployedBytecode.object"] },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(`Compiling with solc ${solc.version()} …`);
|
||||||
|
const output = JSON.parse(solc.compile(JSON.stringify(input)));
|
||||||
|
|
||||||
|
let hasError = false;
|
||||||
|
for (const e of output.errors || []) {
|
||||||
|
const msg = `[${e.severity.toUpperCase()}] ${e.formattedMessage}`;
|
||||||
|
if (e.severity === "error") { console.error(msg); hasError = true; }
|
||||||
|
else { console.warn(msg); }
|
||||||
|
}
|
||||||
|
if (hasError) process.exit(1);
|
||||||
|
|
||||||
|
for (const [, contracts] of Object.entries(output.contracts || {})) {
|
||||||
|
for (const [name, data] of Object.entries(contracts)) {
|
||||||
|
const artifact = {
|
||||||
|
contractName: name,
|
||||||
|
abi: data.abi,
|
||||||
|
bytecode: "0x" + data.evm.bytecode.object,
|
||||||
|
deployedBytecode: "0x" + data.evm.deployedBytecode.object,
|
||||||
|
};
|
||||||
|
const outPath = `${artifactsDir}/${name}.json`;
|
||||||
|
writeFileSync(outPath, JSON.stringify(artifact, null, 2));
|
||||||
|
console.log(` ✓ ${name} → artifacts/${name}.json`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("Compilation successful.");
|
||||||
Loading…
Reference in new issue