Compare commits
1 Commits
1dc54eccea
...
ipfs-defau
| Author | SHA1 | Date | |
|---|---|---|---|
| 077b6fb1c1 |
32
README.md
32
README.md
@@ -1,5 +1,4 @@
|
|||||||
[](https://www.npmjs.com/package/@kredits/contracts)
|
[](https://www.npmjs.com/package/kredits-contracts)
|
||||||
[](https://drone.kosmos.org/kredits/contracts)
|
|
||||||
|
|
||||||
# Kredits Contracts
|
# Kredits Contracts
|
||||||
|
|
||||||
@@ -27,27 +26,27 @@ To run a local development chain run:
|
|||||||
|
|
||||||
### Bootstrap
|
### Bootstrap
|
||||||
|
|
||||||
1. Run an EVM node and ipfs
|
1. Run an Ethereum node and ipfs
|
||||||
|
|
||||||
$ npm run devchain
|
$ npm run devchain
|
||||||
$ ipfs daemon
|
$ ipfs daemon
|
||||||
|
|
||||||
2. Compile contracts and build ABIs
|
2. Compile contracts and build ABIs
|
||||||
|
|
||||||
(compiled artifacts will be in `/artifacts`)
|
(compiled artifacts will be in `/artifacts`)
|
||||||
$ npm run build
|
$ npm run build
|
||||||
|
|
||||||
3. Deploy new upgradable contract proxies
|
3. Deploy new upgradable contract proxies
|
||||||
|
|
||||||
$ npm run deploy:dao
|
$ npm run deploy:dao
|
||||||
|
|
||||||
4. Execute seeds to create demo contributors, contributions, etc. (optional)
|
4. Execute seeds to create demo contributors, contributions, etc. (optional)
|
||||||
|
|
||||||
$ npm run seeds
|
$ npm run seeds
|
||||||
|
|
||||||
**Step 2-4 is also summarized in `npm run bootstrap`**
|
**Step 2-4 is also summarized in `npm run bootstrap`**
|
||||||
|
|
||||||
5. Show contract addresses
|
5. Show contract addresses
|
||||||
|
|
||||||
$ cat lib/addresses.json
|
$ cat lib/addresses.json
|
||||||
|
|
||||||
@@ -57,16 +56,6 @@ If you need to fund development accounts with devchain coins:
|
|||||||
|
|
||||||
$ npm run fund # or hardhat fund --network localhost
|
$ npm run fund # or hardhat fund --network localhost
|
||||||
|
|
||||||
## Specs / Testing
|
|
||||||
|
|
||||||
With a local development chain running:
|
|
||||||
|
|
||||||
$ hardhat test
|
|
||||||
|
|
||||||
If you add or change contract code, please make sure to add and/or adapt tests
|
|
||||||
accordingly. Don't worry, it's easy! You can use existing tests as a template
|
|
||||||
for new ones.
|
|
||||||
|
|
||||||
## Contract architecture
|
## Contract architecture
|
||||||
|
|
||||||
We use the [OpenZeppelin hardhat
|
We use the [OpenZeppelin hardhat
|
||||||
@@ -156,3 +145,12 @@ To run the console on one of the non localhost networks you can also just pass
|
|||||||
on the --network argument.
|
on the --network argument.
|
||||||
|
|
||||||
$ hardhat console --network rsk
|
$ hardhat console --network rsk
|
||||||
|
|
||||||
|
|
||||||
|
## Known Issues
|
||||||
|
|
||||||
|
When resetting ganache Metamask might have an invalid transaction nonce and
|
||||||
|
transactions get rejected. Nonces in Ethereum must be incrementing and have no
|
||||||
|
gap.
|
||||||
|
|
||||||
|
To solve this reset the metamask account (Account -> Settings -> Reset Account)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const contractCalls = [
|
|||||||
name: 'raucao',
|
name: 'raucao',
|
||||||
kind: 'person',
|
kind: 'person',
|
||||||
url: '',
|
url: '',
|
||||||
github_username: 'raucao',
|
github_username: 'skddc',
|
||||||
github_uid: 842,
|
github_uid: 842,
|
||||||
gitea_username: 'raucao',
|
gitea_username: 'raucao',
|
||||||
wiki_username: 'Basti',
|
wiki_username: 'Basti',
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ contract Reimbursement is Initializable {
|
|||||||
struct ReimbursementData {
|
struct ReimbursementData {
|
||||||
uint32 recipientId;
|
uint32 recipientId;
|
||||||
uint256 amount;
|
uint256 amount;
|
||||||
// TODO remove token entirely
|
|
||||||
address token;
|
address token;
|
||||||
bytes32 hashDigest;
|
bytes32 hashDigest;
|
||||||
uint8 hashFunction;
|
uint8 hashFunction;
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
{
|
{
|
||||||
"31": {
|
|
||||||
"Contributor": "0xf1073Dab6e305583F95e451Cba449bB867a6e3Fd",
|
|
||||||
"Contribution": "0x1C531F824e339cD37D75B7F391cB8E42e0E0d4bd",
|
|
||||||
"Token": "0x56F64C3BB45e6a248F4C783f5a1633E53D6A2371",
|
|
||||||
"Reimbursement": "0x9C5fFBFba2570A9b31D60338453C5480Ce74B342"
|
|
||||||
},
|
|
||||||
"1337": {
|
"1337": {
|
||||||
"Contributor": "0xCc66f9A3cA2670972938FAD91d0865c4a62DFB25",
|
"Contributor": "0xCc66f9A3cA2670972938FAD91d0865c4a62DFB25",
|
||||||
"Contribution": "0x8999CaBc43E28202c5A2257f2a95A45b1F8A62BD",
|
"Contribution": "0x8999CaBc43E28202c5A2257f2a95A45b1F8A62BD",
|
||||||
|
|||||||
@@ -69,10 +69,7 @@ class Kredits {
|
|||||||
if (wallet) {
|
if (wallet) {
|
||||||
signer = wallet.connect(ethProvider);
|
signer = wallet.connect(ethProvider);
|
||||||
} else if (ethProvider.getSigner) {
|
} else if (ethProvider.getSigner) {
|
||||||
// Only useful for reading data, not writing. The (unused) address is
|
signer = ethProvider.getSigner();
|
||||||
// necessary because without an address, ethers.js will try to look up
|
|
||||||
// the provider's account 0, which doesn't work on our public RSK nodes.
|
|
||||||
signer = ethProvider.getSigner('0xfa77675540E550b911a6AABF3805ac17C6641ec1');
|
|
||||||
}
|
}
|
||||||
return new Kredits(ethProvider, signer, kreditsOptions);
|
return new Kredits(ethProvider, signer, kreditsOptions);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const fetch = require('node-fetch');
|
|||||||
class IPFS {
|
class IPFS {
|
||||||
constructor (config) {
|
constructor (config) {
|
||||||
if (!config) {
|
if (!config) {
|
||||||
config = { host: 'localhost', port: '5001', protocol: 'http' };
|
config = { host: 'ipfs.kosmos.org', port: '5444', protocol: 'https' };
|
||||||
}
|
}
|
||||||
this._config = config;
|
this._config = config;
|
||||||
this._ipfsAPI = ipfsClient.create(config);
|
this._ipfsAPI = ipfsClient.create(config);
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@kredits/contracts",
|
"name": "kredits-contracts",
|
||||||
"version": "7.0.1",
|
"version": "7.0.0-beta.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@kredits/contracts",
|
"name": "kredits-contracts",
|
||||||
"version": "7.0.1",
|
"version": "7.0.0-beta.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@kosmos/schemas": "^3.1.0",
|
"@kosmos/schemas": "^3.1.0",
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@kredits/contracts",
|
"name": "kredits-contracts",
|
||||||
"version": "7.0.1",
|
"version": "7.0.0-beta.0",
|
||||||
"description": "Smart contracts and JavaScript API for Kredits",
|
"description": "Ethereum contracts and npm wrapper for Kredits",
|
||||||
"main": "./lib/kredits.js",
|
"main": "./lib/kredits.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test"
|
"test": "test"
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ async function main() {
|
|||||||
await kredits.init();
|
await kredits.init();
|
||||||
|
|
||||||
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
console.log(`Using Contribution at: ${kredits.Contribution.contract.address}`);
|
||||||
const count = await kredits.Contribution.count;
|
|
||||||
console.log(`Currently ${count} entries`);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const data = fs.readFileSync("./data/contributions.json");
|
const data = fs.readFileSync("./data/contributions.json");
|
||||||
@@ -30,11 +28,11 @@ async function main() {
|
|||||||
c.hashDigest, c.hashFunction, c.hashSize,
|
c.hashDigest, c.hashFunction, c.hashSize,
|
||||||
confirmedAtBlock, c.vetoed
|
confirmedAtBlock, c.vetoed
|
||||||
);
|
);
|
||||||
console.log(`Adding contribution #${contributionId}: ${result.hash}`);
|
// await result.wait();
|
||||||
await result.wait();
|
console.log(`Added contribution #${contributionId}: ${result.hash}`);
|
||||||
};
|
};
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ async function main() {
|
|||||||
await kredits.init();
|
await kredits.init();
|
||||||
|
|
||||||
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
|
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
|
||||||
const count = await kredits.Contributor.count;
|
|
||||||
console.log(`Currently ${count} entries`);
|
|
||||||
try {
|
try {
|
||||||
const data = fs.readFileSync("./data/contributors.json");
|
const data = fs.readFileSync("./data/contributors.json");
|
||||||
const contributors = JSON.parse(data);
|
const contributors = JSON.parse(data);
|
||||||
@@ -23,11 +22,11 @@ async function main() {
|
|||||||
contributor.hashFunction,
|
contributor.hashFunction,
|
||||||
contributor.hashSize,
|
contributor.hashSize,
|
||||||
);
|
);
|
||||||
console.log(`Adding contributor #${contributorId}: ${result.hash}`);
|
// await result.wait();
|
||||||
await result.wait();
|
console.log(`Added contributor #${contributorId}: ${result.hash}`);
|
||||||
};
|
};
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.error(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ async function main() {
|
|||||||
await kredits.init();
|
await kredits.init();
|
||||||
|
|
||||||
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
|
console.log(`Using Contributor at: ${kredits.Contributor.contract.address}`);
|
||||||
const count = await kredits.Contributors.count;
|
|
||||||
console.log(`Currently ${count} entries`);
|
|
||||||
|
|
||||||
const table = new Table({
|
const table = new Table({
|
||||||
head: ['ID', 'Account', 'Name', 'Core?', 'Balance', 'Kredits earned', 'Contributions count', 'IPFS']
|
head: ['ID', 'Account', 'Name', 'Core?', 'Balance', 'Kredits earned', 'Contributions count', 'IPFS']
|
||||||
|
|||||||
Reference in New Issue
Block a user