Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
[SER-25_compatibilityWithRest] exported default and minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanooj0902 committed Apr 5, 2019
1 parent 61ca53e commit cdd7912
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 19 deletions.
2 changes: 1 addition & 1 deletion lib/auth/permission/permissionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ async function listEvents(admin, contract, args) {
return eventsJson
}

export {
export default {
bind,
bindAddress,
uploadContract,
Expand Down
2 changes: 1 addition & 1 deletion lib/auth/permission/permissionedHashmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async function remove(admin, contract, args) {
await call(admin, callArgs, options)
}

export {
export default {
bind,
bindAddress,
uploadContract,
Expand Down
2 changes: 1 addition & 1 deletion lib/auth/user/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async function authenticate(admin, contract, pwHash) {
}


export {
export default {
uploadContract,
bind,
// constants
Expand Down
4 changes: 2 additions & 2 deletions lib/auth/user/userManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const contractFilename = `${util.cwd}/${config.libPath}/auth/user/contracts/User
const options = { config };

// TODO: (remove if not in use) const RestStatus = rest.getFields(`${config.libPath}/rest/contracts/RestStatus.sol`);
import * as userJs from './user';
import userJs from './user';

async function uploadContract(admin) {
// NOTE: in production, the contract is created and owned by the AdminInterface
Expand Down Expand Up @@ -126,7 +126,7 @@ async function authenticate(admin, contract, args) {
return isOK;
}

export {
export default {
uploadContract,
contractName,
bind
Expand Down
2 changes: 1 addition & 1 deletion lib/collections/hashmap/hashmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async function getOwner(admin, contract, args) {
return result[0];
}

export {
export default {
bind,
uploadContract,
put,
Expand Down
2 changes: 1 addition & 1 deletion lib/collections/hashmap/unsafeHashmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async function remove(admin, contract, args) {
await call(admin, callArgs, options)
}

export {
export default {
bind,
uploadContract,
}
15 changes: 15 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import permissionManager from './auth/permission/permissionManager';
import permissionedHashmap from './auth/permission/permissionedHashmap';
import user from './auth/user/user';
import userManager from './auth/user/userManager';
import hashmap from './collections/hashmap/hashmap';
import unsafeHashmap from './collections/hashmap/unsafeHashmap';

export {
permissionManager,
permissionedHashmap,
user,
userManager,
hashmap,
unsafeHashmap
}
2 changes: 1 addition & 1 deletion test/hashmap/hashmap.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { rest, util } from 'blockapps-rest';
import { getYamlFile } from '../../lib/util/config';
import * as hashmapJs from '../../lib/collections/hashmap/hashmap';
import hashmapJs from '../../lib/collections/hashmap/hashmap';
import { getCredentialArgs } from '../../lib/util/util';

const { createUser } = rest;
Expand Down
2 changes: 1 addition & 1 deletion test/hashmap/unsafeHashmap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { assert } from 'chai';
import { rest, util } from 'blockapps-rest';
import { getYamlFile } from '../../lib/util/config';
import { getCredentialArgs } from '../../lib/util/util';
import * as unsafeHashmapJs from '../../lib/collections/hashmap/unsafeHashmap';
import unsafeHashmapJs from '../../lib/collections/hashmap/unsafeHashmap';

const { createUser } = rest;
const config = getYamlFile('config.yaml');
Expand Down
2 changes: 1 addition & 1 deletion test/permission/permissionManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { createUser, call } = rest;

import { getYamlFile } from '../../lib/util/config';
import { getCredentialArgs } from '../../lib/util/util';
import * as permissionManagerJs from '../../lib/auth/permission/permissionManager';
import permissionManagerJs from '../../lib/auth/permission/permissionManager';

const config = getYamlFile('config.yaml');

Expand Down
2 changes: 1 addition & 1 deletion test/permission/permissionedHashmap.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { createUser, call, createContract } = rest;

import { getYamlFile } from '../../lib/util/config';
import { getCredentialArgs } from '../../lib/util/util';
import * as permissionedHashmapJs from '../../lib/auth/permission/permissionedHashmap';
import permissionedHashmapJs from '../../lib/auth/permission/permissionedHashmap';

const config = getYamlFile('config.yaml');

Expand Down
8 changes: 4 additions & 4 deletions test/user/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { createUser } = rest;
import { getYamlFile } from '../../lib/util/config';
const config = getYamlFile('config.yaml');

import { uploadContract, getUser } from '../../lib/auth/user/user';
import userJs from '../../lib/auth/user/user';
import { createUserArgs } from './user.factory';
import { getCredentialArgs } from '../../lib/util/util';

Expand All @@ -25,7 +25,7 @@ describe('User tests', function () {
const uid = util.uid();
// create the user with constructor args
const args = createUserArgs(admin.address, uid);
const contract = await uploadContract(admin, args);
const contract = await userJs.uploadContract(admin, args);
const user = await contract.getState();
assert.equal(user.account, args.account, 'account');
assert.equal(user.username, args.username, 'username');
Expand All @@ -36,9 +36,9 @@ describe('User tests', function () {
const uid = util.uid();
// create the user with constructor args
const args = createUserArgs(admin.address, uid);
const contract = await uploadContract(admin, args);
const contract = await userJs.uploadContract(admin, args);
// search
const user = await getUser(args.username);
const user = await userJs.getUser(args.username);
assert.equal(user.account, args.account, 'account');
assert.equal(user.username, args.username, 'username');
assert.equal(user.role, args.role, 'role');
Expand Down
4 changes: 2 additions & 2 deletions test/user/userManager-load.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { createUser } = rest;

import { getYamlFile } from '../../lib/util/config';
const config = getYamlFile('config.yaml');
import { uploadContract } from '../../lib/auth/user/userManager';
import userManagerJs from '../../lib/auth/user/userManager';
import { createUserArgs } from './user.factory';
import { getCredentialArgs } from '../../lib/util/util';

Expand All @@ -22,7 +22,7 @@ describe('UserManager LOAD tests', function () {
// get ready: admin-user and manager-contract
before(async function () {
admin = await createUser(adminArgs, options);
contract = await uploadContract(admin);
contract = await userManagerJs.uploadContract(admin);
});

it('User address leading zeros - load test - count:' + count, async function () {
Expand Down
4 changes: 2 additions & 2 deletions test/user/userManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { createUser, call } = rest;
import { getYamlFile } from '../../lib/util/config';
const config = getYamlFile('config.yaml');

import { uploadContract } from '../../lib/auth/user/userManager';
import userManagerJs from '../../lib/auth/user/userManager';
import { createUserArgs } from './user.factory';
import { getCredentialArgs } from '../../lib/util/util';

Expand All @@ -29,7 +29,7 @@ describe('UserManager tests', function () {
RestStatus = await parser.parseFields(restStatusSource);

admin = await createUser(adminArgs, options);
contract = await uploadContract(admin);
contract = await userManagerJs.uploadContract(admin);
// bloc account must be created separately
account = await createUser(blocArgs, options);
});
Expand Down

0 comments on commit cdd7912

Please sign in to comment.