Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
aa3eb25
connect with EthereumConnection (given provider)
szerintedmi Apr 26, 2019
5ddb5c0
Merge branch 'staging' into use_augmint_js
szerintedmi Apr 26, 2019
30c3508
use augmint-js for matchMultipleOrders tx
szerintedmi Apr 26, 2019
43c4de2
Merge branch 'staging' into use_augmint_js
phraktle Apr 26, 2019
908a47f
revert accidental .yarnrc commit
szerintedmi Apr 26, 2019
5c6d3e5
Merge branch 'use_augmint_js' of https://github.com/Augmint/augmint-w…
szerintedmi Apr 26, 2019
42e7f51
adjust ethereum connection to new way
szerintedmi Apr 27, 2019
96c85f1
fix when user rejects tx signature
szerintedmi Apr 28, 2019
50bb8bf
remove console.log
szerintedmi Apr 30, 2019
a48d1d9
use shiny new Augmint.create()
szerintedmi Apr 30, 2019
aacd727
Merge branch 'staging' into use_augmint_js
phraktle May 1, 2019
0e18cbb
Use augmint-js to get legacy exchanges & orders from them
szerintedmi May 1, 2019
4edf6a9
cleanup: no need for single match orders
szerintedmi May 1, 2019
004045f
use augmint-js getOrder
szerintedmi May 1, 2019
4491fc0
Merge branch 'staging' into use_augmint_js
szerintedmi May 1, 2019
ed75106
set augmint-js version
szerintedmi May 1, 2019
c420288
remove unused
szerintedmi May 1, 2019
b5075f5
augmint-js to 0.1.1
szerintedmi May 1, 2019
972ae9d
tests: fix issueTo cypress commamd
szerintedmi May 1, 2019
016e70e
use wss for local web3 connection
szerintedmi May 2, 2019
5b08008
use web3 events: rates
szerintedmi May 2, 2019
5ea0462
user web3 events for user transfers
szerintedmi May 2, 2019
eaaa8e2
use web3 event: exchange orders & trades
szerintedmi May 2, 2019
a7c2a68
use web3 events: legacyBalancesProvider
szerintedmi May 2, 2019
a2b1c28
use web3 events: loanManagerProvider
szerintedmi May 2, 2019
01afe5b
handle loanproduct change events
szerintedmi May 2, 2019
8484b75
use web3 events: lockManagerProvider
szerintedmi May 2, 2019
caeee52
use web3 events: preTokenProvider
szerintedmi May 2, 2019
80d5a7e
use web3 events: stabilityBoardProxyProvider
szerintedmi May 2, 2019
a9284b1
fix travis commands.js
szerintedmi May 2, 2019
16d6913
augmint-js to v0.1.2
szerintedmi May 2, 2019
c7b5edb
launch ganache with automine + relaunch with ganache:run
szerintedmi May 2, 2019
407e4b8
remove ethers package
szerintedmi May 2, 2019
f62de8d
increase connection timeout
szerintedmi May 3, 2019
dae117d
new sendAndProcessTx
szerintedmi May 3, 2019
4af1119
test: remove reserve sales placeholder test
szerintedmi May 3, 2019
b2b2d15
Merge branch 'staging' into use_augmint_js
szerintedmi May 3, 2019
b93c4c2
add bn.js
szerintedmi May 6, 2019
dfd9ad1
adjust to new Augmint.deployedEnvironments
szerintedmi May 7, 2019
251e8ec
use Augmint.exchange.placeSell/BuyOrder
szerintedmi May 7, 2019
b2a0f00
update to augmint-js v0.2.0
szerintedmi May 8, 2019
23aa211
Merge branch 'staging' into use_augmint_js
szerintedmi May 8, 2019
a23bc68
Merge branch 'staging' into use_augmint_js
phraktle May 8, 2019
ca47d4a
yarn.lock again
szerintedmi May 8, 2019
15f582f
remove unused var
szerintedmi May 8, 2019
5cf5c29
Merge branch 'staging' into use_augmint_js
szerintedmi May 8, 2019
a51a53e
pin babel-jest to 24.7.1
szerintedmi May 8, 2019
9196e91
process new transfer event refactor + test fix
szerintedmi May 8, 2019
a381282
rename processTransferLogs to processTransferEvents
szerintedmi May 8, 2019
275161b
fix buy order submitamount calculation
szerintedmi May 8, 2019
7a7d25a
comment fix
szerintedmi May 8, 2019
4225ab8
diff readbility ++
szerintedmi May 8, 2019
e4d128a
Merge branch 'staging' into use_augmint_js
szerintedmi May 8, 2019
3df1f65
fix reverted tx notification
szerintedmi May 8, 2019
ffa7399
test: wait 1sec before lock release + close confirm noti
szerintedmi May 8, 2019
acb6bc8
mindor semantic pedantic
szerintedmi May 9, 2019
2f64795
test: video rec off to speed up cypress test
szerintedmi May 9, 2019
160800c
test: increase sleep before trying to release lock
szerintedmi May 9, 2019
4b597e9
test: lock release timing fix monkey patch
szerintedmi May 9, 2019
464a71f
test: currenttime +1 for isReleaseable
szerintedmi May 9, 2019
6b00ec5
comment fix
szerintedmi May 9, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .yarnrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
--install.frozen-lockfile true
save-prefix ""
save-prefix ""
3 changes: 2 additions & 1 deletion cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"chromeWebSecurity": false,
"defaultCommandTimeout": 20000,
"projectId": "jvuuf8",
"viewport": "macbook-15"
"viewport": "macbook-15",
"video": false
}
8 changes: 5 additions & 3 deletions cypress/integration/locks.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ describe("Locks", function() {

it("Should release locked A-EUR", function() {
getLock(9, 50).then(() => {
cy.wait(1000); // to make sure the lock is releasable
cy.get("[data-testid=lockMenuLink]")
.click()
.then(() => {
cy.get("[data-testid=lockCard] [data-testid=releaseLockButton]")
.first()
.click();
cy.get("[data-testid=EthSubmissionSuccessPanel] > [data-testid=msgPanelOkButton]", {
timeout: 20000
});
cy.get("[data-testid=EthSubmissionSuccessPanel] > [data-testid=msgPanelOkButton]");

cy.get("[data-testid=EthConfirmationReceivedPanel]").contains("confirmation");
cy.get("[data-testid=EthConfirmationReceivedPanel] > [data-testid=msgPanelClose]").click();
});
});
});
Expand Down
9 changes: 0 additions & 9 deletions cypress/integration/reserveSales.js

This file was deleted.

18 changes: 10 additions & 8 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,17 @@ Cypress.Commands.add("issueTo", (tokenAmount, to, options = {}) => {
to = accounts[0];
}

monetarySupervisorInstance.methods
.issueToReserve(tokenAmount)
.send({
from: accounts[0],
gas: 400000
const MONETARY_SUPERVISOR_PERMISSION = web3.utils.asciiToHex("MonetarySupervisor");
augmintTokenInstance.methods
.grantPermission(accounts[0], MONETARY_SUPERVISOR_PERMISSION)
.send({ from: accounts[0] })
.then(res => {
return augmintTokenInstance.methods.issueTo(to, tokenAmount).send({ from: accounts[0], gas: 500000 });
})
.then(res => {
augmintReservesInstance.methods
.withdraw(augmintTokenInstance._address, to, tokenAmount, 0, "token withdrawal for tests")
.send({ from: accounts[0], gas: 200000 });
return augmintTokenInstance.methods.revokePermission(
accounts[0],
web3.utils.asciiToHex("MonetarySupervisor")
);
});
});
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"yarn": "1.15.2"
},
"dependencies": {
"@augmint/js": "0.0.3",
"@augmint/js": "0.2.0",
"bignumber.js": "5.0.0",
"bn.js": "4.11.8",
"chart.js": "2.8.0",
"ethereumjs-util": "6.1.0",
"ethers": "4.0.27",
"moment": "2.24.0",
"parse": "2.2.1",
"react": "16.8.6",
Expand Down Expand Up @@ -44,8 +44,9 @@
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"cypress:runrecord": "$(yarn bin)/cypress run --record --key 42b3c18f-e1cf-4c27-85ed-c223e420bd4a",
"ganache:start": "yarn augmint-cli ganache start",
"ganache:stop": "yarn augmint-cli ganache stop"
"ganache:start": "yarn augmint-cli ganache start --blockTime 1",
"ganache:stop": "yarn augmint-cli ganache stop",
"ganache:run": "yarn augmint-cli ganache run --blockTime 1"
},
"devDependencies": {
"cypress": "3.2.0",
Expand All @@ -55,6 +56,9 @@
"pretty-quick": "1.10.0",
"wait-on": "3.2.0"
},
"resolutions": {
"babel-jest": "24.7.1"
},
"greenkeeper": {
"ignore": [
"bignumber.js"
Expand Down
6 changes: 3 additions & 3 deletions src/components/transaction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class TxInfo extends React.Component {
FROM_TRANSFER: "Incoming transfer",
TO_TRANSFER: "Outgoing transfer"
};
const type = this.getAddressType(tx.direction > 0 ? tx.args.from : tx.args.to);
const type = this.getAddressType(tx.direction > 0 ? tx.from : tx.to);
return map[`${tx.direction > 0 ? "FROM" : "TO"}_${type}`];
}

Expand All @@ -84,13 +84,13 @@ class TxInfo extends React.Component {
</div>
<TxDetails data-testid="txDetails">
<AccountAddress
address={tx.direction < 0 ? tx.args.to : tx.args.from}
address={tx.direction < 0 ? tx.to : tx.from}
title={tx.direction < 0 ? "To: " : "From: "}
shortAddress={true}
showCopyIcon={false}
/>
<br />
{tx.args.narrative}
{tx.narrative}
</TxDetails>
</div>
);
Expand Down
90 changes: 0 additions & 90 deletions src/containers/exchange/components/MatchOrdersButton.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/containers/exchange/components/MyOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default class OrderBook extends React.Component {
const myOrders = [...buyOrders, ...sellOrders].sort((o1, o2) => o2.id - o1.id);

const totalBuyAmount = orders
? parseFloat(buyOrders.reduce((sum, order) => order.bn_ethAmount.add(sum), 0).toFixed(6))
? parseFloat(buyOrders.reduce((sum, order) => order.bnEthAmount.add(sum), 0).toFixed(6))
: "?";
const totalSellAmount = orders ? sellOrders.reduce((sum, order) => order.amount + sum, 0).toFixed(2) : "?";

Expand Down
8 changes: 3 additions & 5 deletions src/containers/exchange/components/OrderBook.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import BigNumber from "bignumber.js";
import styled from "styled-components";

import { TOKEN_SELL, TOKEN_BUY } from "modules/reducers/orders";
import { DECIMALS, DECIMALS_DIV, ETHEUR } from "utils/constants";
import { DECIMALS, ETHEUR } from "utils/constants";
import { floatNumberConverter } from "utils/converter";
import { AEUR, ETH } from "components/augmint-ui/currencies";

Expand Down Expand Up @@ -113,14 +113,12 @@ const OrderItem = props => {
const OrderList = props => {
const { sellOrders, buyOrders, userAccountAddress, ethFiatRate, orderDirection } = props;

const totalEthBuyAmount = parseFloat(buyOrders.reduce((sum, order) => order.bn_ethAmount.add(sum), 0));
const totalEthBuyAmount = parseFloat(buyOrders.reduce((sum, order) => order.bnEthAmount.add(sum), 0));
const totalEthSellAmount = sellOrders.reduce(
(sum, order) => new BigNumber(((order.amount * order.price) / ethFiatRate).toFixed(5)).add(sum),
0
);
const totalAeurSellAmount = new BigNumber(sellOrders.reduce((sum, order) => order.bn_amount.add(sum), 0)).div(
DECIMALS_DIV
);
const totalAeurSellAmount = sellOrders.reduce((sum, order) => order.amount + sum, 0);
const totalAeurBuyAmount = buyOrders.reduce(
(sum, order) => new BigNumber(((ethFiatRate / order.price) * order.amount).toFixed(2)).add(sum),
0
Expand Down
45 changes: 25 additions & 20 deletions src/modules/augmintTokenProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { fetchLatestTransfers, processNewTransfer } from "modules/reducers/userT
import { fetchUserBalance } from "modules/reducers/userBalances";

let isWatchSetup = false;
let processedContractEvents; //** map of eventIds processed: Workaround for bug that web3 beta 36 fires events 2x with MetaMask */

export default () => {
const augmintToken = store.getState().contracts.latest.augmintToken;
Expand All @@ -18,7 +19,7 @@ export default () => {
);

refresh();
setupListeners();
setupContractEventListeners();
}

if (!isWatchSetup) {
Expand All @@ -30,11 +31,29 @@ export default () => {
return;
};

const setupListeners = () => {
const augmintToken = store.getState().contracts.latest.augmintToken.ethersInstance;
const setupContractEventListeners = async () => {
processedContractEvents = {};

augmintToken.on("AugmintTransfer", (...args) => {
onAugmintTransfer(...args);
const augmintToken = await store.getState().web3Connect.augmint.token;
augmintToken.instance.events.AugmintTransfer({}, (error, event) => {
// Workaround for bug that web3 beta 36 fires events 2x with MetaMask TODO: check with newer web3 versions if fixed
if (!processedContractEvents[event.id]) {
processedContractEvents[event.id] = true;
// event AugmintTransfer(address indexed from, address indexed to, uint amount, string narrative, uint fee);
console.debug("augmintTokenProvider.onAugmintTransfer: Dispatching refreshAugmintToken()");
store.dispatch(refreshAugmintToken());
const userAccount = store.getState().web3Connect.userAccount;
if (
event.returnValues.from.toLowerCase() === userAccount.toLowerCase() ||
event.returnValues.to.toLowerCase() === userAccount.toLowerCase()
) {
console.debug(
"augmintTokenProvider.onAugmintTransfer: Transfer to or from for current userAccount. Dispatching processTransfer & fetchUserBalance"
);
store.dispatch(fetchUserBalance(userAccount));
store.dispatch(processNewTransfer(event, userAccount));
}
}
});

// TODO: monetarySupervisor events: ParamsChanged, AcceptedLegacyAugmintTokenChanged,
Expand Down Expand Up @@ -64,7 +83,7 @@ const onAugmintTokenContractChange = (newVal, oldVal, objectPath) => {
);

refresh();
setupListeners();
setupContractEventListeners();
}
};

Expand All @@ -79,17 +98,3 @@ const onUserAccountChange = (newVal, oldVal, objectPath) => {
store.dispatch(fetchLatestTransfers(newVal));
}
};

const onAugmintTransfer = function(from, to, amount, narrative, fee, eventObject) {
// event AugmintTransfer(address indexed from, address indexed to, uint amount, string narrative, uint fee);
console.debug("augmintTokenProvider.onAugmintTransfer: Dispatching refreshAugmintToken()");
store.dispatch(refreshAugmintToken());
const userAccount = store.getState().web3Connect.userAccount;
if (from.toLowerCase() === userAccount.toLowerCase() || to.toLowerCase() === userAccount.toLowerCase()) {
console.debug(
"augmintTokenProvider.onAugmintTransfer: Transfer to or from for current userAccount. Dispatching processTransfer & fetchUserBalance"
);
store.dispatch(fetchUserBalance(userAccount));
store.dispatch(processNewTransfer(userAccount, eventObject));
}
};
15 changes: 4 additions & 11 deletions src/modules/ethereum/SolidityContract.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import { ethers } from "ethers";

/* using a mix of 2 different contract abstractions: web3.Contract and ethers.
It's a temporary workaround for some issues with web3 1.0 (e.g. getLogs, subscribe etc. )
TODO: consolidate to use one library (likely web3 will be enough once websocket works with Metamask) */
export default class SolidityContract {
constructor(connection, contractAddress, abiFile) {
const web3 = connection.web3Instance;
// TODO: web3.eth.Contract is async now. catch errors
// to find source of "Uncaught (in promise) Error: Couldn't decode uint256 from ABI: 0x"
// error in console when incorrect contract address is passed
this.web3ContractInstance = new connection.web3Instance.eth.Contract(abiFile.abi, contractAddress);

const provider = connection.ethers.provider;
this.ethersInstance = new ethers.Contract(contractAddress, abiFile.abi, provider);
this.web3ContractInstance = new web3.eth.Contract(abiFile.abi, contractAddress);

this.address = ethers.utils.getAddress(contractAddress); // format it checksummed
this.address = web3.utils.toChecksumAddress(contractAddress); // format it checksummed
this.abiVersionHash = abiFile && abiFile.abiHash;
this.abiFile = abiFile;
this.abi = abiFile.abi; // storing this to be ethereum js lib independent
Expand All @@ -35,7 +28,7 @@ export default class SolidityContract {
default:
startBlock = 0;
}
this.deployedAtBlock = ethers.utils.bigNumberify(startBlock).toHexString();
this.deployedAtBlock = web3.utils.toHex(startBlock);
this.connection = connection;
}

Expand Down
Loading