Compare commits
23 Commits
ipfs-defau
...
v7.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b49d1130a9
|
||
|
|
657cdc8afa
|
||
|
|
ae9aa7aaaf
|
||
|
|
708515ba4b
|
||
| 7eceea5d57 | |||
|
|
089ffd42fe
|
||
|
|
43d9bc0a07
|
||
|
|
6113e456af
|
||
| 8ef6fc06ce | |||
|
|
093273f15b
|
||
|
|
1dc54eccea
|
||
|
|
bb662e377c
|
||
|
|
d6bbc441f8
|
||
|
|
46090b3740
|
||
|
|
828f831c52
|
||
|
|
500180c6da
|
||
|
|
b63c68cd1c
|
||
| c875e775b6 | |||
|
|
6e0ec8741e
|
||
|
|
a1a68092f6
|
||
| c6168e59e8 | |||
| e810424163 | |||
| f71ff4ce9a |
14
.gitea/release-drafter.yml
Normal file
14
.gitea/release-drafter.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
name-template: 'v$RESOLVED_VERSION'
|
||||||
|
tag-template: 'v$RESOLVED_VERSION'
|
||||||
|
version-resolver:
|
||||||
|
major:
|
||||||
|
labels:
|
||||||
|
- release/major
|
||||||
|
minor:
|
||||||
|
labels:
|
||||||
|
- release/minor
|
||||||
|
- feature
|
||||||
|
patch:
|
||||||
|
labels:
|
||||||
|
- release/patch
|
||||||
|
default: patch
|
||||||
11
.gitea/workflows/release_drafter.yml
Normal file
11
.gitea/workflows/release_drafter.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
name: Release Drafter
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [closed]
|
||||||
|
jobs:
|
||||||
|
release_drafter_job:
|
||||||
|
name: Update release notes draft
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Release Drafter
|
||||||
|
uses: https://github.com/raucao/gitea-release-drafter@dev
|
||||||
32
README.md
32
README.md
@@ -1,4 +1,5 @@
|
|||||||
[](https://www.npmjs.com/package/kredits-contracts)
|
[](https://www.npmjs.com/package/@kredits/contracts)
|
||||||
|
[](https://drone.kosmos.org/kredits/contracts)
|
||||||
|
|
||||||
# Kredits Contracts
|
# Kredits Contracts
|
||||||
|
|
||||||
@@ -26,27 +27,27 @@ To run a local development chain run:
|
|||||||
|
|
||||||
### Bootstrap
|
### Bootstrap
|
||||||
|
|
||||||
1. Run an Ethereum node and ipfs
|
1. Run an EVM 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
|
||||||
|
|
||||||
@@ -56,6 +57,16 @@ 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
|
||||||
@@ -145,12 +156,3 @@ 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: 'skddc',
|
github_username: 'raucao',
|
||||||
github_uid: 842,
|
github_uid: 842,
|
||||||
gitea_username: 'raucao',
|
gitea_username: 'raucao',
|
||||||
wiki_username: 'Basti',
|
wiki_username: 'Basti',
|
||||||
@@ -33,7 +33,7 @@ const contractCalls = [
|
|||||||
|
|
||||||
['Contribution', 'add', [{ contributorId: 1, contributorIpfsHash: 'QmWKCYGr2rSf6abUPaTYqf98urvoZxGrb7dbspFZA6oyVF', date: '2019-04-11', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Test this thing', url: '' }, { gasLimit: 350000 }]],
|
['Contribution', 'add', [{ contributorId: 1, contributorIpfsHash: 'QmWKCYGr2rSf6abUPaTYqf98urvoZxGrb7dbspFZA6oyVF', date: '2019-04-11', amount: 500, kind: 'dev', description: '[67P/kredits-contracts] Test this thing', url: '' }, { gasLimit: 350000 }]],
|
||||||
['Contribution', 'add', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-11', amount: 1500, kind: 'dev', description: '[67P/kredits-web] Reviewed stuff', url: '' }, { gasLimit: 350000 }]],
|
['Contribution', 'add', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-11', amount: 1500, kind: 'dev', description: '[67P/kredits-web] Reviewed stuff', url: '' }, { gasLimit: 350000 }]],
|
||||||
['Contribution', 'add', [{ contributorId: 1, contributorIpfsHash: 'QmWKCYGr2rSf6abUPaTYqf98urvoZxGrb7dbspFZA6oyVF', date: '2019-04-11', amount: 1500, kind: 'dev', description: '[67P/kredits-contracts] Add tests', url: '' }, { gasLimit: 350000 }]],
|
['Contribution', 'add', [{ contributorId: 1, contributorIpfsHash: 'QmWKCYGr2rSf6abUPaTYqf98urvoZxGrb7dbspFZA6oyVF', date: '2019-04-11', amount: 5000, kind: 'dev', description: '[67P/kredits-contracts] Add tests', url: '' }, { gasLimit: 350000 }]],
|
||||||
['Contribution', 'add', [{ contributorId: 1, contributorIpfsHash: 'QmWKCYGr2rSf6abUPaTYqf98urvoZxGrb7dbspFZA6oyVF', date: '2019-04-11', amount: 1500, kind: 'dev', description: '[67P/kredits-contracts] Introduce contribution token', url: '' }, { gasLimit: 350000 }]],
|
['Contribution', 'add', [{ contributorId: 1, contributorIpfsHash: 'QmWKCYGr2rSf6abUPaTYqf98urvoZxGrb7dbspFZA6oyVF', date: '2019-04-11', amount: 1500, kind: 'dev', description: '[67P/kredits-contracts] Introduce contribution token', url: '' }, { gasLimit: 350000 }]],
|
||||||
['Contribution', 'add', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-11', amount: 5000, kind: 'dev', description: '[67P/kredits-web] Expense UI, first draft', url: '' }, { gasLimit: 350000 }]],
|
['Contribution', 'add', [{ contributorId: 2, contributorIpfsHash: 'QmcHzEeAM26HV2zHTf5HnZrCtCtGdEccL5kUtDakAB7ozB', date: '2019-04-11', amount: 5000, kind: 'dev', description: '[67P/kredits-web] Expense UI, first draft', url: '' }, { gasLimit: 350000 }]],
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ interface IContributionBalance {
|
|||||||
|
|
||||||
contract Contributor is Initializable {
|
contract Contributor is Initializable {
|
||||||
address public deployer;
|
address public deployer;
|
||||||
|
address public profileManager;
|
||||||
IContributionBalance public contributionContract;
|
IContributionBalance public contributionContract;
|
||||||
IToken public tokenContract;
|
IToken public tokenContract;
|
||||||
|
|
||||||
@@ -43,8 +44,9 @@ contract Contributor is Initializable {
|
|||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
function initialize() public initializer {
|
function initialize(address profileManagerAddress) public initializer {
|
||||||
deployer = msg.sender;
|
deployer = msg.sender;
|
||||||
|
profileManager = profileManagerAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setContributionContract(address contribution) public onlyCore {
|
function setContributionContract(address contribution) public onlyCore {
|
||||||
@@ -84,11 +86,12 @@ contract Contributor is Initializable {
|
|||||||
c.hashFunction = hashFunction;
|
c.hashFunction = hashFunction;
|
||||||
c.hashSize = hashSize;
|
c.hashSize = hashSize;
|
||||||
|
|
||||||
ContributorProfileUpdated(id, oldHashDigest, c.hashDigest);
|
emit ContributorProfileUpdated(id, oldHashDigest, c.hashDigest);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addContributor(address account, bytes32 hashDigest, uint8 hashFunction, uint8 hashSize) public onlyCore {
|
function addContributor(address account, bytes32 hashDigest, uint8 hashFunction, uint8 hashSize) public {
|
||||||
require(!addressExists(account), "Address already in use");
|
require(!addressExists(account), "Address already in use");
|
||||||
|
require((msg.sender == profileManager) || addressIsCore(msg.sender), "Only core and profile manager");
|
||||||
uint32 _id = contributorsCount + 1;
|
uint32 _id = contributorsCount + 1;
|
||||||
assert(!contributors[_id].exists); // this can not be acually
|
assert(!contributors[_id].exists); // this can not be acually
|
||||||
Contributor storage c = contributors[_id];
|
Contributor storage c = contributors[_id];
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ 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;
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,10 @@
|
|||||||
{
|
{
|
||||||
|
"31": {
|
||||||
|
"Contributor": "0xf1073Dab6e305583F95e451Cba449bB867a6e3Fd",
|
||||||
|
"Contribution": "0x1C531F824e339cD37D75B7F391cB8E42e0E0d4bd",
|
||||||
|
"Token": "0x56F64C3BB45e6a248F4C783f5a1633E53D6A2371",
|
||||||
|
"Reimbursement": "0x9C5fFBFba2570A9b31D60338453C5480Ce74B342"
|
||||||
|
},
|
||||||
"1337": {
|
"1337": {
|
||||||
"Contributor": "0xCc66f9A3cA2670972938FAD91d0865c4a62DFB25",
|
"Contributor": "0xCc66f9A3cA2670972938FAD91d0865c4a62DFB25",
|
||||||
"Contribution": "0x8999CaBc43E28202c5A2257f2a95A45b1F8A62BD",
|
"Contribution": "0x8999CaBc43E28202c5A2257f2a95A45b1F8A62BD",
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class Reimbursement extends Record {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getData (id) {
|
getData (id) {
|
||||||
return this.contract.getReimbursement(id);
|
return this.contract.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
async add (attrs, callOptions = {}) {
|
async add (attrs, callOptions = {}) {
|
||||||
|
|||||||
@@ -69,7 +69,10 @@ class Kredits {
|
|||||||
if (wallet) {
|
if (wallet) {
|
||||||
signer = wallet.connect(ethProvider);
|
signer = wallet.connect(ethProvider);
|
||||||
} else if (ethProvider.getSigner) {
|
} else if (ethProvider.getSigner) {
|
||||||
signer = ethProvider.getSigner();
|
// Only useful for reading data, not writing. The (unused) address is
|
||||||
|
// 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: 'ipfs.kosmos.org', port: '5444', protocol: 'https' };
|
config = { host: 'localhost', port: '5001', protocol: 'http' };
|
||||||
}
|
}
|
||||||
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.0-beta.0",
|
"version": "7.1.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "kredits-contracts",
|
"name": "@kredits/contracts",
|
||||||
"version": "7.0.0-beta.0",
|
"version": "7.1.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.0-beta.0",
|
"version": "7.1.0",
|
||||||
"description": "Ethereum contracts and npm wrapper for Kredits",
|
"description": "Smart contracts and JavaScript API for Kredits",
|
||||||
"main": "./lib/kredits.js",
|
"main": "./lib/kredits.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test"
|
"test": "test"
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ async function main() {
|
|||||||
|
|
||||||
const blocksVetoPeriod = 40320; // 7 days; 15 seconds block time
|
const blocksVetoPeriod = 40320; // 7 days; 15 seconds block time
|
||||||
|
|
||||||
await deployContractProxy('Contributor');
|
await deployContractProxy('Contributor', [ '0x0000000000000000000000000000000000000000' ] );
|
||||||
await deployContractProxy('Contribution', [ blocksVetoPeriod ]);
|
await deployContractProxy('Contribution', [ blocksVetoPeriod ]);
|
||||||
await deployContractProxy('Token');
|
await deployContractProxy('Token');
|
||||||
await deployContractProxy('Reimbursement');
|
await deployContractProxy('Reimbursement');
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ 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");
|
||||||
@@ -28,11 +30,11 @@ async function main() {
|
|||||||
c.hashDigest, c.hashFunction, c.hashSize,
|
c.hashDigest, c.hashFunction, c.hashSize,
|
||||||
confirmedAtBlock, c.vetoed
|
confirmedAtBlock, c.vetoed
|
||||||
);
|
);
|
||||||
// await result.wait();
|
console.log(`Adding contribution #${contributionId}: ${result.hash}`);
|
||||||
console.log(`Added contribution #${contributionId}: ${result.hash}`);
|
await result.wait();
|
||||||
};
|
};
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ 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);
|
||||||
@@ -22,11 +23,11 @@ async function main() {
|
|||||||
contributor.hashFunction,
|
contributor.hashFunction,
|
||||||
contributor.hashSize,
|
contributor.hashSize,
|
||||||
);
|
);
|
||||||
// await result.wait();
|
console.log(`Adding contributor #${contributorId}: ${result.hash}`);
|
||||||
console.log(`Added contributor #${contributorId}: ${result.hash}`);
|
await result.wait();
|
||||||
};
|
};
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ 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']
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ describe("Contribution contract", async function () {
|
|||||||
[owner, addr1, addr2, addr3, addr4, addr5, addr6, addr7] = await ethers.getSigners();
|
[owner, addr1, addr2, addr3, addr4, addr5, addr6, addr7] = await ethers.getSigners();
|
||||||
let accounts = [owner, addr1, addr2, addr3, addr4, addr5, addr6, addr7];
|
let accounts = [owner, addr1, addr2, addr3, addr4, addr5, addr6, addr7];
|
||||||
const contributorFactory = await ethers.getContractFactory("Contributor");
|
const contributorFactory = await ethers.getContractFactory("Contributor");
|
||||||
Contributor = await upgrades.deployProxy(contributorFactory);
|
Contributor = await upgrades.deployProxy(contributorFactory, ["0x2946fFfd31096435cb0fc927D306E1C006C5D1aF"]);
|
||||||
for (const account of accounts) {
|
for (const account of accounts) {
|
||||||
await Contributor.addContributor(account.address, "0x99b8afd7b266e19990924a8be9099e81054b70c36b20937228a77a5cf75723b8", 18, 32);
|
await Contributor.addContributor(account.address, "0x99b8afd7b266e19990924a8be9099e81054b70c36b20937228a77a5cf75723b8", 18, 32);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
const { expect } = require("chai");
|
const { expect } = require("chai");
|
||||||
const { ethers, upgrades } = require("hardhat");
|
const { ethers, upgrades } = require("hardhat");
|
||||||
let owner, addr1, addr2, addr3, addr4, addr5, addr6, addr7;
|
let owner, addr1, addr2, addr3, addr4, addr5, addr6, addr7, addr8;
|
||||||
let Contribution, Contributor, Token;
|
let Contribution, Contributor, Token;
|
||||||
|
|
||||||
describe("Contributor contract", async function () {
|
describe("Contributor contract", async function () {
|
||||||
before(async function () {
|
before(async function () {
|
||||||
[owner, addr1, addr2, addr3, addr4, addr5, addr6, addr7] = await ethers.getSigners();
|
[owner, addr1, addr2, addr3, addr4, addr5, addr6, addr7, addr8] = await ethers.getSigners();
|
||||||
|
|
||||||
const contributorFactory = await ethers.getContractFactory("Contributor");
|
const contributorFactory = await ethers.getContractFactory("Contributor");
|
||||||
Contributor = await upgrades.deployProxy(contributorFactory);
|
Contributor = await upgrades.deployProxy(contributorFactory, [addr8.address]);
|
||||||
const contributionFactory = await ethers.getContractFactory("Contribution");
|
const contributionFactory = await ethers.getContractFactory("Contribution");
|
||||||
Contribution = await upgrades.deployProxy(contributionFactory, [40321]);
|
Contribution = await upgrades.deployProxy(contributionFactory, [40321]);
|
||||||
const tokenFactory = await ethers.getContractFactory("Token");
|
const tokenFactory = await ethers.getContractFactory("Token");
|
||||||
@@ -30,6 +30,10 @@ describe("Contributor contract", async function () {
|
|||||||
expect(await Contributor.deployer()).to.equal(owner.address);
|
expect(await Contributor.deployer()).to.equal(owner.address);
|
||||||
expect(await Contributor.deployer()).to.not.equal(addr1.address);
|
expect(await Contributor.deployer()).to.not.equal(addr1.address);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("sets a profile manager address", async function () {
|
||||||
|
expect(await Contributor.profileManager()).to.equal(addr8.address);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("add()", function () {
|
describe("add()", function () {
|
||||||
@@ -38,7 +42,7 @@ describe("Contributor contract", async function () {
|
|||||||
"0x608FD4b95116Ea616990Aaeb1d4f1ce07612f261",
|
"0x608FD4b95116Ea616990Aaeb1d4f1ce07612f261",
|
||||||
"0x1d9de6de5c72eedca6d7a5e8a9159e2f5fe676506aece3000acefcc821723429",
|
"0x1d9de6de5c72eedca6d7a5e8a9159e2f5fe676506aece3000acefcc821723429",
|
||||||
18, 32
|
18, 32
|
||||||
)).to.be.revertedWith("Core only");
|
)).to.be.revertedWith("Only core and profile manager");
|
||||||
expect(await Contributor.contributorsCount()).to.equal(8);
|
expect(await Contributor.contributorsCount()).to.equal(8);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -70,6 +74,18 @@ describe("Contributor contract", async function () {
|
|||||||
18, 32
|
18, 32
|
||||||
)).to.emit(Contributor, "ContributorAdded").withArgs(10, "0x765E88b4F9a59C3a3b300C6eFF9E6E9fDDf9FbD9");
|
)).to.emit(Contributor, "ContributorAdded").withArgs(10, "0x765E88b4F9a59C3a3b300C6eFF9E6E9fDDf9FbD9");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("allows the profile manager account to create a contributor profile", async function () {
|
||||||
|
await Contributor.connect(addr8).addContributor(
|
||||||
|
"0x954712B8703Df5255A219B139ba7BFC256E72a15",
|
||||||
|
"0x1d9de6de5c72eedca6d7a5e8a9159e2f5fe676506aece3000acefcc821723429",
|
||||||
|
18, 32
|
||||||
|
);
|
||||||
|
expect(await Contributor.contributorsCount()).to.equal(11);
|
||||||
|
const c = await Contributor.getContributorById(11);
|
||||||
|
expect(c['account']).to.equal("0x954712B8703Df5255A219B139ba7BFC256E72a15");
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("withdraw()", function () {
|
describe("withdraw()", function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user