Refactor contract interaction in its own module #42

Merged
bumi merged 11 commits from kredits-module into master 2018-04-10 13:46:58 +00:00
3 changed files with 0 additions and 36 deletions
Showing only changes of commit 0e330a6529 - Show all commits
-1
View File
3
@@ -3,7 +3,6 @@ import RSVP from 'rsvp';
import Kredits from '../kredits';
import ContributorSerializer from '../serializers/contributor';
import { toBytes32 } from '../utils/multihash';
import Base from './base';
-2
View File
@@ -1,10 +1,8 @@
import ethers from 'npm:ethers';
fsmanuel commented 2018-04-10 12:18:33 +00:00 (Migrated from github.com)
Review

We can use this.functions

We can use `this.functions`
fsmanuel commented 2018-04-10 12:18:40 +00:00 (Migrated from github.com)
Review

We can use this.functions

We can use `this.functions`
fsmanuel commented 2018-04-10 12:18:55 +00:00 (Migrated from github.com)
Review

We can use this.functions

We can use `this.functions`
import RSVP from 'rsvp';
import multihashes from 'npm:multihashes';
import Kredits from '../kredits';
import ContributionSerializer from '../serializers/contribution';
import { toBytes32 } from '../utils/multihash';
import Base from './base';
-33
View File
@@ -1,33 +0,0 @@
import bs58 from 'npm:bs58';
import NpmBuffer from 'npm:buffer';
const Buffer = NpmBuffer.Buffer;
function fromBytes32({ digest, hashFunction, hashSize }) {
if (hashSize === 0) {
return;
}
const hashBytes = Buffer.from(digest.slice(2), 'hex');
const multiHashBytes = new (hashBytes.constructor)(2 + hashBytes.length);
multiHashBytes[0] = hashFunction;
multiHashBytes[1] = hashSize;
multiHashBytes.set(hashBytes, 2);
return bs58.encode(multiHashBytes);
}
function toBytes32(string) {
const decoded = bs58.decode(string);
return {
digest: `0x${decoded.slice(2).toString('hex')}`,
hashFunction: decoded[0],
hashSize: decoded[1],
};
}
export {
fromBytes32,
toBytes32
};