diff --git a/config/seeds.js b/config/seeds.js index 751b8da..bb6afcb 100644 --- a/config/seeds.js +++ b/config/seeds.js @@ -70,16 +70,16 @@ const contractCalls = [ }, { gasLimit: 350000 }]], ['Reimbursement', 'add', [{ amount: 346800, recipientId: 2, token: '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599', expenses: [ - { title: 'Domain kosmos.social', description: 'Yearly registration fee for domain kosmos.social', amount: 69.00, currency: 'EUR', date: '2020-04-30' }, + { title: 'Domain kosmos.social', description: 'Yearly registration fee for domain kosmos.social', amount: 69.00, currency: 'EUR', amountSats: 69216, date: '2020-04-30' }, ], confirmedAtBlock: 1 }, { gasLimit: 300000 }]], ['Reimbursement', 'add', [{ amount: 1116000, recipientId: 1, token: '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599', expenses: [ - { title: 'Server rent', description: 'Dedicated server: andromeda.kosmos.org, April 2020', amount: 61, currency: 'EUR', date: '2020-05-28' }, - { title: 'Server rent', description: 'Dedicated server: centaurus.kosmos.org, April 2020', amount: 32, currency: 'EUR', date: '2020-05-28' }, + { title: 'Server rent', description: 'Dedicated server: andromeda.kosmos.org, April 2020', amount: 61, currency: 'EUR', amountSats: 61191, date: '2020-05-28' }, + { title: 'Server rent', description: 'Dedicated server: centaurus.kosmos.org, April 2020', amount: 32, currency: 'EUR', amountSats: 32201, date: '2020-05-28' }, ], confirmedAtBlock: 1 }, { gasLimit: 300000 }]], ['Reimbursement', 'add', [{ amount: 166800, recipientId: 2, token: '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599', expenses: [ - { title: 'Domain kosmos.chat', description: 'Yearly registration fee for domain kosmos.chat', amount: 13.90, currency: 'EUR', date: '2020-05-30' }, + { title: 'Domain kosmos.chat', description: 'Yearly registration fee for domain kosmos.chat', amount: 13.90, currency: 'EUR', amountSats: 13944, date: '2020-05-30' }, ]}, { gasLimit: 300000 }]], ]; diff --git a/lib/contracts/contributor.js b/lib/contracts/contributor.js index 5edbfa9..05e3abc 100644 --- a/lib/contracts/contributor.js +++ b/lib/contracts/contributor.js @@ -52,6 +52,7 @@ class Contributor extends Record { const jsonStr = contributor.serialize(); + // console.log('Adding IPFS doc for', contributorAttr.account); return this.ipfs .add(jsonStr) .then((ipfsHashAttr) => { @@ -62,7 +63,11 @@ class Contributor extends Record { ipfsHashAttr.hashSize, ]; + // console.log('Adding onchain record for', contributorAttr.account); return this.contract.addContributor(...contributor, callOptions); + }).catch(err => { + console.log('Failed to add IPFS document:', err.message); + throw(err); }); } diff --git a/lib/serializers/expense.js b/lib/serializers/expense.js index 9c1dbf9..85e39b0 100644 --- a/lib/serializers/expense.js +++ b/lib/serializers/expense.js @@ -29,6 +29,7 @@ class ExpenseSerializer { description, currency, amount, + amountSats, date, url, tags, @@ -42,6 +43,7 @@ class ExpenseSerializer { description, currency, amount, + amountSats, date, 'tags': tags || [], 'details': details || {}, @@ -76,6 +78,7 @@ class ExpenseSerializer { description, currency, amount, + amountSats, date, url, tags, @@ -87,6 +90,7 @@ class ExpenseSerializer { description, currency, amount, + amountSats, date, url, tags, diff --git a/lib/utils/ipfs.js b/lib/utils/ipfs.js index 3b4ee17..7382bda 100644 --- a/lib/utils/ipfs.js +++ b/lib/utils/ipfs.js @@ -9,6 +9,13 @@ class IPFS { } this._config = config; this._ipfsAPI = ipfsClient.create(config); + + this._ipfsAPI.id().then(res => { + console.debug('IPFS ID:', res.id); + }).catch(e => { + console.debug('IPFS config:', config); + console.warn('Failed to initialize IPFS:', e.message); + }); } async catAndMerge (contractData, deserialize) { diff --git a/package-lock.json b/package-lock.json index 81bf169..6d5afae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "7.4.0", "license": "MIT", "dependencies": { - "@kosmos/schemas": "^3.1.0", + "@kosmos/schemas": "^3.2.0", "ethers": "^5.4.7", "ipfs-http-client": "^56.0.3", "multihashes": "^4.0.3", @@ -1022,9 +1022,9 @@ } }, "node_modules/@kosmos/schemas": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@kosmos/schemas/-/schemas-3.1.0.tgz", - "integrity": "sha512-yOTK5WiXFDNAitPByMabE365aEEzFHgSUSgAssbJWt7BZ80HQSVu8XWrQiTbFbCkoIBmXwPP/RoxgXJQVgZTFQ==" + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@kosmos/schemas/-/schemas-3.2.0.tgz", + "integrity": "sha512-GyWXmWcATcakmEdPOpafdckBgWFqcpSh+tB8nm11VGgtgA94pfoFhKZ3t88WELItKfuP/GFHgMiZmdMB3bSkdQ==" }, "node_modules/@metamask/eth-sig-util": { "version": "4.0.1", @@ -20786,9 +20786,9 @@ } }, "@kosmos/schemas": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@kosmos/schemas/-/schemas-3.1.0.tgz", - "integrity": "sha512-yOTK5WiXFDNAitPByMabE365aEEzFHgSUSgAssbJWt7BZ80HQSVu8XWrQiTbFbCkoIBmXwPP/RoxgXJQVgZTFQ==" + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@kosmos/schemas/-/schemas-3.2.0.tgz", + "integrity": "sha512-GyWXmWcATcakmEdPOpafdckBgWFqcpSh+tB8nm11VGgtgA94pfoFhKZ3t88WELItKfuP/GFHgMiZmdMB3bSkdQ==" }, "@metamask/eth-sig-util": { "version": "4.0.1", diff --git a/package.json b/package.json index 5feac8d..bc7f840 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "yargs": "^15.0.0" }, "dependencies": { - "@kosmos/schemas": "^3.1.0", + "@kosmos/schemas": "^3.2.0", "ethers": "^5.4.7", "ipfs-http-client": "^56.0.3", "multihashes": "^4.0.3", diff --git a/scripts/seeds.js b/scripts/seeds.js index a684328..772d49e 100644 --- a/scripts/seeds.js +++ b/scripts/seeds.js @@ -39,7 +39,7 @@ async function main() { contractWrapper.contract[method]; try { - // console.log('trying', func); + // console.log('trying', contractName, method, args); const result = await func.apply(contractWrapper, args); // console.log('result:', result); await result.wait();