Compare commits
3 Commits
reimbursem
...
dce54761a6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dce54761a6
|
||
|
|
62af06c3f8
|
||
|
|
b5c0dd5ae0
|
@@ -18,7 +18,11 @@ contract Token is Initializable, ERC20Upgradeable {
|
|||||||
event KreditsMinted(address indexed recipient, uint256 amount);
|
event KreditsMinted(address indexed recipient, uint256 amount);
|
||||||
|
|
||||||
function initialize() public virtual initializer {
|
function initialize() public virtual initializer {
|
||||||
__ERC20_init('Kredits', 'KS');
|
__ERC20_init("Kredits", "KS");
|
||||||
|
}
|
||||||
|
|
||||||
|
function decimals() public view virtual override returns (uint8) {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setContributorContract(address contributor) public {
|
function setContributorContract(address contributor) public {
|
||||||
@@ -31,8 +35,7 @@ contract Token is Initializable, ERC20Upgradeable {
|
|||||||
require(contributorContractAddress == msg.sender, "Only Contributor");
|
require(contributorContractAddress == msg.sender, "Only Contributor");
|
||||||
require(amount > 0, "INVALID_AMOUNT");
|
require(amount > 0, "INVALID_AMOUNT");
|
||||||
|
|
||||||
uint256 amountInWei = amount.mul(1 ether);
|
_mint(contributorAccount, amount);
|
||||||
_mint(contributorAccount, amountInWei);
|
|
||||||
emit KreditsMinted(contributorAccount, amount);
|
emit KreditsMinted(contributorAccount, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ async function main() {
|
|||||||
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
||||||
|
|
||||||
const count = await kredits.Contribution.count;
|
const count = await kredits.Contribution.count;
|
||||||
const currentBlockHeight = await XMLHttpRequest.ethers.provider.getBlockNumber();
|
const currentBlockHeight = await hre.ethers.provider.getBlockNumber();
|
||||||
|
|
||||||
const backup = {};
|
const backup = {};
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|||||||
39
scripts/import/contributions.js
Normal file
39
scripts/import/contributions.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const Kredits = require('../../lib/kredits');
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
kredits = new Kredits(hre.ethers.provider, hre.ethers.provider.getSigner())
|
||||||
|
await kredits.init();
|
||||||
|
|
||||||
|
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = fs.readFileSync("./data/contributions.json");
|
||||||
|
const contributions = JSON.parse(data);
|
||||||
|
const ids = Object.keys(contributions)
|
||||||
|
.map(k => parseInt(k))
|
||||||
|
.sort(function(a, b){return a-b});
|
||||||
|
|
||||||
|
const currentBlockHeight = await kredits.provider.getBlockNumber();
|
||||||
|
const confirmationPeriod = 40320 // blocks
|
||||||
|
const unconfirmedHeight = currentBlockHeight + confirmationPeriod;
|
||||||
|
|
||||||
|
for (const contributionId of ids) {
|
||||||
|
const c = contributions[contributionId.toString()];
|
||||||
|
|
||||||
|
const confirmedAtBlock = c.confirmed ? currentBlockHeight : unconfirmedHeight;
|
||||||
|
|
||||||
|
const result = await kredits.Contribution.contract.add(
|
||||||
|
c.amount, c.contributorId,
|
||||||
|
c.hashDigest, c.hashFunction, c.hashSize,
|
||||||
|
confirmedAtBlock, c.vetoed
|
||||||
|
);
|
||||||
|
// await result.wait();
|
||||||
|
console.log(`Added contribution #${contributionId}: ${result.hash}`);
|
||||||
|
};
|
||||||
|
} catch(e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main();
|
||||||
Reference in New Issue
Block a user