Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #22

Merged
merged 3 commits into from Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2,892 changes: 1,772 additions & 1,120 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@finbook/duo-contract-wrapper",
"version": "1.1.2",
"version": "1.1.3",
"description": "DUO Contract Wrapper",
"author": "FinBook Pte Ltd",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/DualClassWrapper.ts
Expand Up @@ -162,7 +162,7 @@ export class DualClassWrapper extends BaseContractWrapper {
if (this.web3Wrapper.isReadOnly()) return this.web3Wrapper.readOnlyReject();
return this.contract.methods
.setValue(index, newValue)
.send(await this.web3Wrapper.getTransactionOption(account, CST.SET_VALUE_GAS, option));
.send(await this.web3Wrapper.getTransactionOption(account, CST.DUAL_CLASS_SET_VALUE_GAS, option));
}

public static convertCustodianState(rawState: string) {
Expand Down
6 changes: 3 additions & 3 deletions src/MagiWrapper.ts
Expand Up @@ -43,7 +43,7 @@ export class MagiWrapper extends BaseContractWrapper {
priceUpdateCoolDown: (await this.contract.methods.priceUpdateCoolDown().call()) * 1000,
numOfPrices: Number(await this.contract.methods.numOfPrices().call()),
lastOperationTime: (await this.contract.methods.lastOperationTime().call()) * 1000,
operationCoolDown: (await this.contract.methods.lastOperationTime().call()) * 1000
operationCoolDown: (await this.contract.methods.operationCoolDown().call()) * 1000
};
}

Expand Down Expand Up @@ -111,7 +111,7 @@ export class MagiWrapper extends BaseContractWrapper {
if (this.web3Wrapper.isReadOnly()) return this.web3Wrapper.readOnlyReject();
return this.contract.methods
.setValue(index, newValue)
.send(await this.web3Wrapper.getTransactionOption(account, CST.SET_VALUE_GAS, option));
.send(await this.web3Wrapper.getTransactionOption(account, CST.MAGI_SET_VALUE_GAS, option));
}

public async updateRoleManager(
Expand All @@ -138,7 +138,7 @@ export class MagiWrapper extends BaseContractWrapper {
.send(
await this.web3Wrapper.getTransactionOption(
account,
CST.UPDATE_ROLE_MANAGER_GAS,
CST.UPDATE_OPERATOR,
option
)
);
Expand Down
4 changes: 2 additions & 2 deletions src/Web3Wrapper.test.ts
Expand Up @@ -310,7 +310,7 @@ test('isReadOnly', () => {

test('getTransactionOption, no option', async () => {
const web3Wrapper = new Web3Wrapper({ ethereum: {} }, '', '', true);
web3Wrapper.getGasPrice = jest.fn(() => Promise.resolve(1000000000));
web3Wrapper.getGasPrice = jest.fn(() => Promise.resolve('1000000000'));
web3Wrapper.getTransactionCount = jest.fn(() => Promise.resolve(10));
expect(await web3Wrapper.getTransactionOption('account', 100000)).toMatchSnapshot();
expect((web3Wrapper.getTransactionCount as jest.Mock).mock.calls).toMatchSnapshot();
Expand All @@ -319,7 +319,7 @@ test('getTransactionOption, no option', async () => {

test('getTransactionOption, with option', async () => {
const web3Wrapper = new Web3Wrapper({ ethereum: {} }, '', '', true);
web3Wrapper.getGasPrice = jest.fn(() => Promise.resolve(1000000000));
web3Wrapper.getGasPrice = jest.fn(() => Promise.resolve('1000000000'));
web3Wrapper.getTransactionCount = jest.fn(() => Promise.resolve(10));
expect(
await web3Wrapper.getTransactionOption('account', 100000, {
Expand Down
14 changes: 7 additions & 7 deletions src/__snapshots__/MagiWrapper.test.ts.snap
Expand Up @@ -77,7 +77,7 @@ Object {
"isStarted": false,
"lastOperationTime": 1234567890000,
"numOfPrices": 0,
"operationCoolDown": 1234567890000,
"operationCoolDown": 1000000,
"priceFeedTimeTolerance": 60000,
"priceFeedTolerance": 0.01,
"priceTolerance": 0.05,
Expand Down Expand Up @@ -109,12 +109,12 @@ exports[`setValue 3`] = `
Array [
Array [
"account",
50000,
100000,
Object {},
],
Array [
"account",
50000,
100000,
Object {
"gasLimit": 200000,
"gasPrice": 2000000000,
Expand Down Expand Up @@ -178,12 +178,12 @@ exports[`updateOperator 2`] = `
Array [
Array [
"account",
1000000,
100000,
Object {},
],
Array [
"account",
1000000,
100000,
Object {
"gasLimit": 200000,
"gasPrice": 2000000000,
Expand All @@ -210,12 +210,12 @@ exports[`updatePriceFeed 3`] = `
Array [
Array [
"account",
120000,
100000,
Object {},
],
Array [
"account",
120000,
100000,
Object {
"gasLimit": 200000,
"gasPrice": 2000000000,
Expand Down
2 changes: 1 addition & 1 deletion src/__snapshots__/Web3Wrapper.test.ts.snap
Expand Up @@ -8,7 +8,7 @@ exports[`getTransactionOption, no option 1`] = `
Object {
"from": "account",
"gas": 100000,
"gasPrice": 1000000000,
"gasPrice": "1000000000",
"nonce": 10,
}
`;
Expand Down
6 changes: 4 additions & 2 deletions src/constants.ts
Expand Up @@ -81,7 +81,8 @@ export const PROVIDER_MYETHER_MAIN = 'https://api.myetherapi.com/eth';
export const PROVIDER_INFURA_MAIN = 'https://mainnet.infura.io';
export const PROVIDER_INFURA_KOVAN = 'https://kovan.infura.io';
export const TRANSFER_TOKEN_GAS = 120000;
export const SET_VALUE_GAS = 50000;
export const MAGI_SET_VALUE_GAS = 100000;
export const DUAL_CLASS_SET_VALUE_GAS = 50000;
export const COLLECT_FEE_GAS = 40000;
export const ADD_ADDR_GAS = 40000;
export const REMOVE_ADDR_GAS = 40000;
Expand All @@ -94,7 +95,8 @@ export const RESET_GAS_LIMIT = 4000000;
export const START_CUSTODIAN_GAS = 1000000;
export const FETCH_PRICE_GAS = 150000;
export const START_MAGI_GAS = 120000;
export const UPDATE_PRICE_FEED = 120000;
export const UPDATE_PRICE_FEED = 100000;
export const UPDATE_OPERATOR = 100000;
export const COMMIT_PRICE_GAS = 80000;
export const UPDATE_ROLE_MANAGER_GAS = 1000000;
export const DEFAULT_TX_GAS_LIMIT = 30000;
Expand Down