Compare commits
9 Commits
dce54761a6
...
addresses/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96a18d3c5c
|
||
|
|
b3dabb41e1
|
||
| 1c097f37a6 | |||
|
|
d3fb1010d5
|
||
| f390b5dff5 | |||
|
|
1e4f7be5cf
|
||
|
|
258c1cc755
|
||
|
|
f29054bc0b
|
||
| fd012d5359 |
@@ -18,7 +18,11 @@ contract Token is Initializable, ERC20Upgradeable {
|
||||
event KreditsMinted(address indexed recipient, uint256 amount);
|
||||
|
||||
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 {
|
||||
@@ -31,8 +35,7 @@ contract Token is Initializable, ERC20Upgradeable {
|
||||
require(contributorContractAddress == msg.sender, "Only Contributor");
|
||||
require(amount > 0, "INVALID_AMOUNT");
|
||||
|
||||
uint256 amountInWei = amount.mul(1 ether);
|
||||
_mint(contributorAccount, amountInWei);
|
||||
_mint(contributorAccount, amount);
|
||||
emit KreditsMinted(contributorAccount, amount);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,10 @@
|
||||
{
|
||||
"31": {
|
||||
"Contributor": "0x9C66a36fa6296EBb81d8F5D4642B05dF2CE85a8D",
|
||||
"Contribution": "0xa12630a995337e45bDD746B6baedc1Ce2a1DCC9D",
|
||||
"Token": "0x12Eb86338076450f86E5B552556028c7D21eaf1F",
|
||||
"Reimbursement": "0xe2FE7cb00e2f94b8bA0AE526dfbe313f34c66E3C"
|
||||
},
|
||||
"1337": {
|
||||
"Contributor": "0xCc66f9A3cA2670972938FAD91d0865c4a62DFB25",
|
||||
"Contribution": "0x8999CaBc43E28202c5A2257f2a95A45b1F8A62BD",
|
||||
|
||||
@@ -7,7 +7,7 @@ async function main() {
|
||||
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
||||
|
||||
const count = await kredits.Contribution.count;
|
||||
const currentBlockHeight = await XMLHttpRequest.ethers.provider.getBlockNumber();
|
||||
const currentBlockHeight = await hre.ethers.provider.getBlockNumber();
|
||||
|
||||
const backup = {};
|
||||
const promises = [];
|
||||
|
||||
62
scripts/import/contributions.js
Normal file
62
scripts/import/contributions.js
Normal file
@@ -0,0 +1,62 @@
|
||||
const fs = require('fs');
|
||||
const Kredits = require('../../lib/kredits');
|
||||
|
||||
const PARALLEL_TXS = 5;
|
||||
|
||||
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;
|
||||
|
||||
const txBundlesAmount = Math.ceil(ids.length / PARALLEL_TXS);
|
||||
let txBundles = [];
|
||||
|
||||
for (let i = 0; i < txBundlesAmount; i++) {
|
||||
txBundles.push(ids.slice((i * PARALLEL_TXS), (i * PARALLEL_TXS) + PARALLEL_TXS));
|
||||
}
|
||||
|
||||
for (const txBundle of txBundles) {
|
||||
console.log(`Adding contributions #${txBundle[0]} to #${txBundle[txBundle.length - 1]}`)
|
||||
|
||||
let resultPromises = [];
|
||||
|
||||
for (const contributionId of txBundle) {
|
||||
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
|
||||
);
|
||||
|
||||
resultPromises.push(result.wait());
|
||||
|
||||
console.log(`Added contribution #${contributionId}: ${result.hash}`);
|
||||
}
|
||||
|
||||
console.log(`Waiting for confirmations...`);
|
||||
|
||||
await Promise.all(resultPromises);
|
||||
|
||||
console.log('Transactions confirmed');
|
||||
}
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
@@ -95,7 +95,7 @@ describe("Contributor contract", async function () {
|
||||
expect(c['balance']).to.equal(0);
|
||||
await Contributor.connect(addr1).withdraw();
|
||||
c = await Contributor.getContributorById(2);
|
||||
expect(c['balance'].toString()).to.equal("6500000000000000000000");
|
||||
expect(c['balance']).to.equal(6500);
|
||||
expect(c['kreditsWithdrawn']).to.equal(6500);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user