Skip to content

Commit

Permalink
Papi upgrade (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
mutantcornholio authored Aug 19, 2024
1 parent 06040bf commit 5850380
Show file tree
Hide file tree
Showing 17 changed files with 722 additions and 490 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/E2E.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
- run: yarn install --immutable
- name: Download Polkadot and parachain binaries
run: |
wget --no-verbose https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot
wget --no-verbose https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot-parachain
wget --no-verbose https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot-prepare-worker
wget --no-verbose https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot-execute-worker
wget --no-verbose https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-stable2407-1/polkadot
wget --no-verbose https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-stable2407-1/polkadot-parachain
wget --no-verbose https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-stable2407-1/polkadot-prepare-worker
wget --no-verbose https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-stable2407-1/polkadot-execute-worker
chmod +x ./polkadot*
working-directory: e2e
- name: Run a local relaychain with a parachain using zombienet
Expand Down
3 changes: 3 additions & 0 deletions .papi/descriptors/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.gitignore
!package.json
24 changes: 24 additions & 0 deletions .papi/descriptors/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "0.1.0-autogenerated.13128332760513449832",
"name": "@polkadot-api/descriptors",
"files": [
"dist"
],
"exports": {
".": {
"module": "./dist/index.mjs",
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"default": "./dist/index.js"
},
"./package.json": "./package.json"
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"browser": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"sideEffects": false,
"peerDependencies": {
"polkadot-api": "*"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions .papi/polkadot-api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"version": 0,
"descriptorPath": ".papi/descriptors",
"entries": {
"rococo": {
"chain": "rococo_v2_2",
"metadata": ".papi/metadata/rococo.scale"
},
"westend": {
"chain": "westend2",
"metadata": ".papi/metadata/westend.scale"
},
"e2e_relaychain": {
"wsUrl": "ws://127.0.0.1:9933",
"metadata": ".papi/metadata/e2e_relaychain.scale"
},
"e2e_parachain": {
"wsUrl": "ws://127.0.0.1:9934",
"metadata": ".papi/metadata/e2e_parachain.scale"
},
"versi": {
"wsUrl": "wss://versi-rpc-node-0.parity-versi.parity.io",
"metadata": ".papi/metadata/versi.scale"
},
"paseo": {
"wsUrl": "wss://sys.dotters.network/paseo",
"metadata": ".papi/metadata/paseo.scale"
}
}
}
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
FROM docker.io/library/node:22-alpine3.20

RUN apk add --no-cache python3 make g++
FROM docker.io/library/node:22.6-alpine3.20

ARG VCS_REF=master
ARG BUILD_DATE=""
Expand All @@ -19,11 +17,12 @@ LABEL io.parity.image.authors="[email protected]" \
WORKDIR /faucet

COPY .yarn/ ./.yarn/
COPY src/papi/chains/data ./src/papi/chains/data
COPY package.json env.faucet.config.json yarn.lock polkadot-api.json .yarnrc.yml ./
COPY .papi/ ./.papi/
COPY package.json env.faucet.config.json yarn.lock .yarnrc.yml ./
RUN yarn --immutable

COPY . .
RUN yarn papi
RUN yarn build

CMD yarn migrations:run && yarn start
10 changes: 5 additions & 5 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ For example, to download a `v1.8.0` release of `polkadot` and a corresponding ve

```bash
cd <bin_path>
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot-prepare-worker
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot-execute-worker
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-v1.8.0/polkadot-parachain
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-stable2407-1/polkadot
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-stable2407-1/polkadot-prepare-worker
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-stable2407-1/polkadot-execute-worker
wget https://github.com/paritytech/polkadot-sdk/releases/download/polkadot-stable2407-1/polkadot-parachain
chmod +x ./polkadot*
```

Expand All @@ -56,7 +56,7 @@ There are no pre-built binaries, so we need to build the binaries from source:

```bash
git clone https://github.com/paritytech/polkadot-sdk.git
git checkout polkadot-v1.8.0
git checkout polkadot-stable2407-1

cd polkadot-sdk/polkadot
cargo build --release --locked
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
},
"dependencies": {
"@eng-automation/js": "^2.1.0",
"@polkadot-api/descriptors": "portal:.papi/descriptors",
"@polkadot-labs/hdkd": "^0.0.6",
"@polkadot-labs/hdkd-helpers": "^0.0.6",
"@types/cors": "^2.8.13",
Expand All @@ -64,7 +65,7 @@
"express": "4.19.2",
"matrix-js-sdk": "^26.1.0",
"pg": "^8.11.2",
"polkadot-api": "^0.8.0",
"polkadot-api": "^1.0.1",
"prom-client": "^14.2.0",
"reflect-metadata": "^0.1.13",
"request": "^2.88.2",
Expand Down
26 changes: 0 additions & 26 deletions polkadot-api.json

This file was deleted.

12 changes: 6 additions & 6 deletions src/faucet.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { drip } from "#src/test/webhookHelpers";
import crypto from "crypto";
import Joi from "joi";
import { AccountId, createClient } from "polkadot-api";
import { WebSocketProvider } from "polkadot-api/ws-provider/node";
import { getWsProvider } from "polkadot-api/ws-provider/node";
import { filter, firstValueFrom, mergeMap, pairwise, race, skip, throwError } from "rxjs";
import { Repository } from "typeorm";

Expand All @@ -26,10 +26,10 @@ describe("Faucet E2E", () => {
let e2eSetup: E2ESetup;
let dripRepository: Repository<Drip>;

const relaychainClient = createClient(WebSocketProvider("ws://127.0.0.1:9933"));
const relaychainClient = createClient(getWsProvider("ws://127.0.0.1:9933"));
const relayChainApi = relaychainClient.getTypedApi(e2e_relaychain);

const parachainClient = createClient(WebSocketProvider("ws://127.0.0.1:9934"));
const parachainClient = createClient(getWsProvider("ws://127.0.0.1:9934"));
const parachainApi = parachainClient.getTypedApi(e2e_parachain);

type SomeApi = typeof relayChainApi | typeof parachainApi;
Expand Down Expand Up @@ -63,14 +63,14 @@ describe("Faucet E2E", () => {
}, 100_000);

afterAll(async () => {
relaychainClient.destroy();
parachainClient.destroy();
relaychainClient?.destroy();
parachainClient?.destroy();
await destroyDataSource();
if (e2eSetup) teardown(e2eSetup);
});

afterEach(async () => {
await dripRepository.clear();
await dripRepository?.clear();
});

test("The bot responds to the !balance message", async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/papi/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { config } from "#src/config";
import fs from "fs";
import { createClient, PolkadotClient } from "polkadot-api";
import { withLogsRecorder } from "polkadot-api/logs-provider";
import { JsonRpcProvider, WebSocketProvider } from "polkadot-api/ws-provider/node";
import { getWsProvider, JsonRpcProvider } from "polkadot-api/ws-provider/node";

import { getNetworkData } from "./chains";

const networkName = config.Get("NETWORK");
const networkData = getNetworkData(networkName);

let provider: JsonRpcProvider = WebSocketProvider(networkData.data.rpcEndpoint);
let provider: JsonRpcProvider = getWsProvider(networkData.data.rpcEndpoint);

if (process.env.PAPI_DEBUG) {
// Sync appends aren't ideal, but otherwise, we wouldn't be able to export client,
Expand Down
Loading

0 comments on commit 5850380

Please sign in to comment.