Skip to content

Commit

Permalink
Updates 2 (#6)
Browse files Browse the repository at this point in the history
* Update paseo RPC wss://sys.dotters.network/paseo (paritytech#398)

* Prettier write

* Make properties public. Remove try catches. Lint

* remove console.log

* Increase test timeout

* try installing playwright with yarn

---------

Co-authored-by: Maksym H <1177472+mordamax@users.noreply.github.com>
  • Loading branch information
forgetso and mordamax authored Apr 30, 2024
1 parent 1054692 commit 944685c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- run: yarn install --frozen-lockfile
- run: yarn run check
- name: Install Playwright
run: npx playwright install
run: yarn playwright install --with-deps
- run: yarn run test
- run: yarn run build
env:
Expand Down
5 changes: 1 addition & 4 deletions client/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ body {
background-repeat: no-repeat;
position: absolute;
background-position-y: 10%, 73%, 50%;
background-position-x:
25%,
-13%,
115%;
background-position-x: 25%, -13%, 115%;
background-size: 20%, 20%, 30%;
bottom: 0px;
right: 0px;
Expand Down
2 changes: 1 addition & 1 deletion client/src/app.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down
4 changes: 3 additions & 1 deletion client/tests/faucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,9 @@ export class FaucetTests {
});

test.describe("form interaction", () => {
test("submit form becomes valid on data entry", async ({ page }, { config }) => {
test("submit form becomes valid on data entry", async ({ page }, testInfo) => {
const config = testInfo.config;
testInfo.setTimeout(testInfo.timeout * 2);
await page.goto(this.url);
const { address, captcha, submit } = await getFormElements(page, this.getCaptchaProvider(config), true);
await expect(submit).toBeDisabled();
Expand Down
2 changes: 1 addition & 1 deletion src/networkData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const paseo: NetworkData = {
dripAmount: "100",
explorer: null,
networkName: "Paseo",
rpcEndpoint: "wss://paseo.rpc.amforc.com/",
rpcEndpoint: "wss://sys.dotters.network/paseo",
matrixWhitelistPatterns: [
/^@erin:parity\.io$/,
/^@mak:parity\.io$/,
Expand Down
49 changes: 11 additions & 38 deletions src/test/setupE2EProcaptcha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,15 @@ export type ProcaptchaTestSetup = {
const GAS_INCREASE_FACTOR = 2

export class ProcaptchaSetup {
private _api: ApiPromise;
private _siteKey: string;
private _port: number;
public api: ApiPromise;
public siteKey: string;
public port: number;
private _transactionQueue: TransactionQueue | undefined;

constructor(api: ApiPromise, siteKey: string, port: number) {
this._api = api;
this._siteKey = siteKey;
this._port = port;
}

get api(): ApiPromise {
return this._api
}

get port(): number {
return this._port
}

get siteKey(): string {
return this._siteKey
this.api = api;
this.siteKey = siteKey;
this.port = port;
}

get transactionQueue(): TransactionQueue {
Expand All @@ -56,7 +44,6 @@ export class ProcaptchaSetup {
}

async isReady() {
try {
await this.api.isReady;
const alicePair = await getPairAsync(undefined, '//Alice', undefined, 'sr25519', 42)
const contract = await this.deployProcaptchaContract(alicePair);
Expand All @@ -74,9 +61,7 @@ export class ProcaptchaSetup {
await this.procaptchaAppRegister(contract, this.siteKey);

return {contract, contractAddress: contract.address, testAccount: alicePair.address, siteKey: this.siteKey}
} catch (e) {
throw new Error(`Failed to setup Procaptcha: ${JSON.stringify(e, null, 4)}`)
}

}


Expand Down Expand Up @@ -105,7 +90,6 @@ export class ProcaptchaSetup {
}

async procaptchaProviderRegister(contract: ProsopoCaptchaContract, port: number): Promise<void> {
try {
console.log("Registering Procaptcha provider")
const value = (await contract.query.getProviderStakeThreshold()).value.unwrap().toNumber()
const providerRegisterArgs: Parameters<typeof contract.query.providerRegister> = [
Expand All @@ -114,16 +98,13 @@ export class ProcaptchaSetup {
Payee.dapp
]
await this.submitTx(contract, contract.query.providerRegister.name, providerRegisterArgs, value, contract.pair)
} catch (e) {
throw new Error(`Failed to register Procaptcha provider: ${JSON.stringify(e, null, 4)}`)
}

}

async procaptchaProviderSetDataset(contract: ProsopoCaptchaContract): Promise<{
datasetId: Hash,
datasetContentId: Hash
}> {
try {
console.log("Setting Procaptcha provider dataset")
const providerSetDatasetArgs: Parameters<typeof contract.query.providerSetDataset> = [
"0x28c1ba9d21c00f2e29c9ace8c46fd7dbfbb6f5a5f516771278635ac3ab88c267" as Hash, // hashed value of "TESTDATASET"
Expand All @@ -135,23 +116,18 @@ export class ProcaptchaSetup {
datasetId: providerSetDatasetArgs[0],
datasetContentId: providerSetDatasetArgs[1]
}
} catch (e) {
throw new Error(`Failed to set Procaptcha provider dataset: ${JSON.stringify(e, null, 4)}`)
}

}

async procaptchaAppRegister(contract: ProsopoCaptchaContract, siteKey: string): Promise<void> {
try {
console.log("Registering Procaptcha app")
const value = (await contract.query.getDappStakeThreshold()).value.unwrap().toNumber()
const appRegisterArgs: Parameters<typeof contract.query.dappRegister> = [
siteKey,
DappPayee.dapp
]
await this.submitTx(contract, contract.query.dappRegister.name, appRegisterArgs, value)
} catch (e) {
throw new Error(`Failed to register Procaptcha app: ${JSON.stringify(e, null, 4)}`)
}

}

private async submitTx(
Expand All @@ -168,7 +144,6 @@ export class ProcaptchaSetup {
contract.nativeContract.tx[methodName] !== undefined
) {

try {
const weight = await getWeight(this.api)
const txPair = pair ? pair : contract.pair

Expand Down Expand Up @@ -217,9 +192,7 @@ export class ProcaptchaSetup {
reject(err)
})
})
} catch (e) {
throw new Error(`Failed to submit Procaptcha transaction: ${JSON.stringify(e, null, 4)}`)
}


} else {
throw new Error('CONTRACT.INVALID_METHOD')
Expand Down
1 change: 0 additions & 1 deletion src/test/webhookHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export async function drip(webEndpoint: string, address: string, parachainId?: s
provider: "5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM",
blockNumber: blockNumber
})
console.log("Captcha response", captchaResponse)
const body: { address: string, captchaResponse: string, parachain_id?: string } = {
address: address,
captchaResponse
Expand Down

0 comments on commit 944685c

Please sign in to comment.