Skip to content

Commit 806a812

Browse files
committed
fix: update runtime metadata
1 parent e2cdf24 commit 806a812

File tree

11 files changed

+160
-35
lines changed

11 files changed

+160
-35
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ jobs:
2626
- name: Install Rust
2727
uses: dtolnay/rust-toolchain@stable
2828
with:
29+
toolchain: 1.83.0
2930
targets: wasm32-unknown-unknown
3031

3132
- name: Install wasm-pack
32-
run: cargo install wasm-pack
33+
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
3334

3435
# Need to build the WASM before type-checking
3536
# otherwise we're missing code and tsc will fail
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Deploy Runtime Upgrade to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [paseo-runtime-upgrade]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages-paseo-runtime-upgrade"
15+
cancel-in-progress: true
16+
17+
jobs:
18+
deploy:
19+
environment:
20+
name: github-pages
21+
url: ${{ steps.deployment.outputs.page_url }}
22+
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
27+
- name: Set up Node.js 22.x
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: 22.x
31+
32+
- name: Install Rust
33+
uses: dtolnay/rust-toolchain@stable
34+
with:
35+
toolchain: 1.83.0
36+
targets: wasm32-unknown-unknown
37+
38+
- name: Install wasm-pack
39+
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
40+
41+
- name: Install pnpm
42+
uses: pnpm/action-setup@v2
43+
with:
44+
version: latest
45+
46+
- name: Install dependencies
47+
run: pnpm install --frozen-lockfile
48+
49+
- name: Build
50+
run: pnpm build
51+
52+
- name: Upload artifact
53+
uses: actions/upload-pages-artifact@v3
54+
with:
55+
path: dist
56+
57+
- name: Deploy to GitHub Pages
58+
id: deployment
59+
uses: actions/deploy-pages@v4

.github/workflows/deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
- name: Install Rust
3535
uses: dtolnay/rust-toolchain@stable
3636
with:
37+
toolchain: 1.83.0
3738
targets: wasm32-unknown-unknown
3839

3940
- name: Install wasm-pack

.papi/metadata/polkaStorage.scale

0 Bytes
Binary file not shown.

.papi/polkadot-api.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"descriptorPath": ".papi/descriptors",
44
"entries": {
55
"polkaStorage": {
6-
"wsUrl": "ws://localhost:42069",
6+
"wsUrl": "ws:/localhost:8000",
77
"metadata": ".papi/metadata/polkaStorage.scale",
8-
"genesis": "0x4545454545454545454545454545454545454545454545454545454545454545",
9-
"codeHash": "0xb84fe515e735f6a2ca1032f6d1ff7befc5a29c5c48ea56bd90eebb0d509533ee"
8+
"genesis": "0xa6f9a4facafa6157734b6a52503070304d34919a8299f46e6c7bde2ee000ccd6",
9+
"codeHash": "0x164f37eaf7ceb43de9b9a79dd6105105931269478212669e2c99a0801378c92e"
1010
}
1111
}
1212
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"dev": "pnpm run papi:generate && pnpm run build:wasm && vite",
99
"build:wasm": "wasm-pack build --target web ./wasm-commp",
10-
"build": "pnpm run build:wasm && tsc -b && vite build",
10+
"build": "pnpm install --frozen-lockfile && pnpm run build:wasm && tsc -b && vite build",
1111
"preview": "vite preview",
1212
"lint": "biome lint ./src && biome format ./src && tsc",
1313
"fmt": "biome format --write ./src",

pnpm-lock.yaml

Lines changed: 44 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/conversion.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { Multiaddr, NodeAddress } from "@multiformats/multiaddr";
12
import { BLOCK_TIME } from "./consts";
23

34
export function blockToTime(
@@ -60,3 +61,26 @@ export function formatDuration(duration: {
6061
}
6162
return `${result.join(", ")}`;
6263
}
64+
65+
export function baseURLFromP2pMultiaddr(nodeAddress: NodeAddress): string {
66+
const { address, port } = nodeAddress;
67+
68+
// address can be an IP or a hostname depending on the multiaddr
69+
// We only rewrite when it's our p2p DNS name.
70+
const uploadHost =
71+
typeof address === "string" && address.startsWith("p2p.")
72+
? address.replace(/^p2p\./, "upload.")
73+
: address;
74+
75+
// If the p2p multiaddr is tcp/443/wss, upload should be https on 443
76+
// If you're on some other port locally, keep it consistent.
77+
const isStandardHttps = port === 443 || port === 0 || port == null;
78+
79+
return isStandardHttps ? `https://${uploadHost}` : `https://${uploadHost}:${port}`;
80+
}
81+
82+
export type ProviderInfo = {
83+
accountId: string;
84+
multiaddr: Multiaddr;
85+
pricePerBlock: number;
86+
};

src/lib/download.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ import { type Multiaddr, multiaddr } from "@multiformats/multiaddr";
22
import { fileTypeFromBuffer } from "file-type";
33
import { CID } from "multiformats";
44
import type { PolkaStorageApi } from "../GlobalCtx";
5+
import { baseURLFromP2pMultiaddr } from "./conversion";
56
import type { Deal } from "./deals";
67

78
export async function downloadDeal(api: PolkaStorageApi | null, deal: Deal) {
89
if (!api) throw new Error("API not ready");
910

1011
// look up provider addr
1112
const maddr = await getProviderMultiaddr(api, deal.value.provider);
12-
const { address, port } = maddr.nodeAddress();
13+
const baseUrl = baseURLFromP2pMultiaddr(maddr.nodeAddress());
1314

1415
// fetch the raw piece
1516
const pieceCid = CID.decode(deal.value.piece_cid.asBytes()).toString();
16-
const res = await fetch(`http://${address}:${port}/api/v0/download/${pieceCid}`);
17+
const res = await fetch(`${baseUrl}/api/v0/download/${pieceCid}`);
1718
if (!res.ok) throw new Error(res.statusText);
1819
const blob = await res.blob();
1920

src/lib/fileUpload.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export async function uploadFile(
1515
body.append("file", file);
1616

1717
const addr = secure_addr ? secure_addr : `http://${address.ip}:${address.port}`;
18-
18+
console.log(`Uploading to: ${addr}`);
1919
return await fetch(`${addr}/api/v0/upload/${dealCid}`, {
2020
method: "PUT",
2121
body,
@@ -32,6 +32,7 @@ export async function proposeDeal(
3232
}
3333

3434
const addr = secure_addr ? secure_addr : `http://${address.ip}:${address.port}`;
35+
console.log(`Proposing to: ${addr}`);
3536
const response = await fetch(`${addr}/api/v0/propose_deal`, {
3637
method: "POST",
3738
headers: { "Content-Type": "application/json" },

0 commit comments

Comments
 (0)