Skip to content

Commit

Permalink
Merge pull request #36 from Synthetixio/dev
Browse files Browse the repository at this point in the history
promote dev to master
  • Loading branch information
drptbl authored Dec 12, 2020
2 parents 21dcdea + 97d4c80 commit b83a8af
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
7 changes: 5 additions & 2 deletions commands/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {
permissionsPageElements,
confirmPageElements,
} = require('../pages/metamask/notification-page');
const { setNetwork } = require('../helpers');
const { setNetwork, getNetwork } = require('../helpers');

let walletAddress;

Expand Down Expand Up @@ -126,13 +126,16 @@ module.exports = {
return true;
},
confirmTransaction: async () => {
const isTestnet = getNetwork().isTestnet;
await puppeteer.metamaskWindow().waitForTimeout(3000);
const notificationPage = await puppeteer.switchToMetamaskNotification();
const currentGasFee = await puppeteer.waitAndGetValue(
confirmPageElements.gasFeeInput,
notificationPage,
);
const newGasFee = (Number(currentGasFee) + 10).toString();
const newGasFee = isTestnet
? '10'
: (Number(currentGasFee) + 10).toString();
await puppeteer.waitAndSetValue(
newGasFee,
confirmPageElements.gasFeeInput,
Expand Down
14 changes: 7 additions & 7 deletions commands/synthetix.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const { SynthetixJs } = require('synthetix-js');
const { getNetwork } = require('../helpers');
const bytes32 = require('bytes32');

module.exports = {
settle: async ({ asset, privateKey }) => {
const assetAsBytes32 = bytes32({ input: asset });
if (privateKey === undefined && process.env.PRIVATE_KEY) {
privateKey = process.env.PRIVATE_KEY;
}
const network = getNetwork().networkId;
const networkId = getNetwork().networkId;
const signer = new SynthetixJs.signers.PrivateKey(
// eslint-disable-next-line unicorn/no-null
null,
network,
undefined,
networkId,
`0x${privateKey}`,
);
const snxjs = new SynthetixJs({ signer, network });
const { toUtf8Bytes32 } = snxjs.utils;
const txn = await snxjs.Synthetix.settle(toUtf8Bytes32(asset));
const snxjs = new SynthetixJs({ signer, networkId });
const txn = await snxjs.Synthetix.settle(assetAsBytes32);
console.log(`Settle executed: ${txn.hash}`);
await txn.wait();
return true;
Expand Down
8 changes: 7 additions & 1 deletion helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@ const path = require('path');

let networkName = 'mainnet';
let networkId = 1;
let isTestnet = false;

module.exports = {
setNetwork: network => {
if (network === 'main' || network === 'mainnet' || network === 1) {
networkName = 'mainnet';
networkId = 1;
isTestnet = false;
} else if (network === 'ropsten') {
networkName = 'ropsten';
networkId = 3;
isTestnet = true;
} else if (network === 'kovan') {
networkName = 'kovan';
networkId = 42;
isTestnet = true;
} else if (network === 'rinkeby') {
networkName = 'rinkeby';
networkId = 4;
isTestnet = true;
} else if (network === 'goerli') {
networkName = 'goerli';
networkId = 5;
isTestnet = true;
}
},
getNetwork: () => {
return { networkName, networkId };
return { networkName, networkId, isTestnet };
},
getSynpressPath: () => {
return 'node_modules/@synthetixio/synpress';
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"babel-plugin-react-remove-properties": "0.3.0",
"babel-plugin-transform-react-qa-classes": "1.6.0",
"babel-plugin-transform-react-styled-components-qa": "2.0.1",
"bytes32": "0.0.3",
"commander": "6.2.0",
"cypress": "6.1.0",
"cypress-wait-until": "1.7.1",
Expand Down

0 comments on commit b83a8af

Please sign in to comment.