This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27086ec
commit 4306269
Showing
9 changed files
with
162 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,44 @@ | ||
import { Ext, File } from "../../codegen/mod.ts" | ||
import { extname } from "../../deps/std/path.ts" | ||
import { outdent } from "../../deps/outdent.ts" | ||
import * as path from "../../deps/std/path.ts" | ||
import { Client, proxyProvider } from "../../rpc/mod.ts" | ||
import { FrameProvider, FrameProviderPathInfo } from "./common/mod.ts" | ||
import { FramePathInfo, FrameProvider } from "./common/mod.ts" | ||
|
||
export type WssPathInfo = FrameProviderPathInfo<string> | ||
export interface WssPathInfo extends FramePathInfo { | ||
protocolTrailing: string | ||
} | ||
|
||
export class WssProvider extends FrameProvider<string> { | ||
export class WssProvider extends FrameProvider { | ||
parsePathInfo = parseWssPathInfo | ||
|
||
client({ discoveryValue }: WssPathInfo) { | ||
return new Client(proxyProvider, `wss://${discoveryValue}`) | ||
url({ protocolTrailing }: WssPathInfo) { | ||
return `wss://${protocolTrailing}` | ||
} | ||
|
||
client(pathInfo: WssPathInfo) { | ||
return new Client(proxyProvider, this.url(pathInfo)) | ||
} | ||
|
||
clientFile() { | ||
clientFile(pathInfo: WssPathInfo) { | ||
const clientFile = new File() | ||
clientFile.code = `export const client = null!` | ||
clientFile.code = outdent` | ||
import * as C from "../capi.ts" | ||
export const client = new C.Client(C.rpc.proxyProvider, "${this.url(pathInfo)}") | ||
` | ||
return clientFile | ||
} | ||
} | ||
|
||
export function parseWssPathInfo(path: string): FrameProviderPathInfo<string> { | ||
const atI = path.search("@") | ||
if (atI == -1) throw new Error(`Expected "@" character and version to appear in URL`) | ||
const discoveryValue = path.slice(0, atI) | ||
const atTrailing = path.slice(atI + 1) | ||
export function parseWssPathInfo(path_: string): WssPathInfo { | ||
const atI = path_.search("@") | ||
if (atI == -1) throw new Error(`Expected "@" character to appear in URL`) | ||
const protocolTrailing = path_.slice(0, atI) | ||
const atTrailing = path_.slice(atI + 1) | ||
const slashI = atTrailing.search("/") | ||
const version = atTrailing.slice(0, slashI) | ||
const filePath = atTrailing.slice(slashI + 1) | ||
const key = path.slice(0, atI + 1 + slashI) | ||
const ext = extname(filePath) as Ext | ||
return { key, discoveryValue, version, filePath, ext } | ||
const chainKey = path_.slice(0, atI + 1 + slashI) | ||
const ext = path.extname(filePath) as Ext | ||
return { chainKey, protocolTrailing, version, filePath, ext } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { assertEquals } from "../../deps/std/testing/asserts.ts" | ||
import { parseZombienetPathInfo } from "./Zombienet.ts" | ||
|
||
Deno.test("Zombienet Path Info Parsing", () => { | ||
assertEquals(parseZombienetPathInfo("examples/xcm_teleport_assets.toml#alice@version/mod.ts"), { | ||
chainKey: "examples/xcm_teleport_assets.toml#alice@version", | ||
configPath: "examples/xcm_teleport_assets.toml", | ||
chainId: "alice", | ||
version: "version", | ||
filePath: "mod.ts", | ||
ext: ".ts", | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters