Skip to content

Commit

Permalink
more dapp interaction flows (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrodyHughes authored Apr 26, 2023
1 parent b010bd7 commit b37feaf
Show file tree
Hide file tree
Showing 4 changed files with 735 additions and 252 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
- name: Run e2e (Chrome)
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
timeout_minutes: 16
max_attempts: 3
command: |
export BROWSER=chrome
Expand Down Expand Up @@ -173,7 +173,7 @@ jobs:
- name: Run e2e (Brave)
uses: nick-fields/retry@v2
with:
timeout_minutes: 10
timeout_minutes: 16
max_attempts: 3
command: |
export BROWSER=brave
Expand Down
22 changes: 22 additions & 0 deletions e2e/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable no-promise-executor-return */
/* eslint-disable @typescript-eslint/no-var-requires */
import { ethers } from 'ethers';
import { Builder, By, WebDriver, until } from 'selenium-webdriver';
import chrome from 'selenium-webdriver/chrome';
import { erc20ABI } from 'wagmi';

const waitUntilTime = 20000;

Expand Down Expand Up @@ -64,6 +66,26 @@ export async function getExtensionIdByName(driver, extensionName) {
`);
}

export async function getOnchainBalance(addy, contract) {
const provider = ethers.getDefaultProvider('http://127.0.0.1:8545');
const testContract = new ethers.Contract(contract, erc20ABI, provider);
const balance = await testContract.balanceOf(addy);

return balance;
}

export async function transactionStatus() {
const provider = ethers.getDefaultProvider('http://127.0.0.1:8545');
const blockData = await provider.getBlock('latest');
const txn = await provider.getTransaction(blockData.transactions[0]);
const txnData = txn.wait();

// transactionResponse.wait.status returns '1' if the txn was sent successfully and '0' if its a failure
const txnStatus = (await txnData).status === 1 ? 'success' : 'failure';

return txnStatus;
}

export async function delay(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
Expand Down
Loading

0 comments on commit b37feaf

Please sign in to comment.