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.
Co-authored-by: Matias Volpe <[email protected]>
- Loading branch information
1 parent
a04e83d
commit 0c3a36b
Showing
30 changed files
with
276 additions
and
245 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ import { contentType } from "https://deno.land/x/[email protected]/mod.ts"; | |
import { Application, send } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import { babel, babelPresetTypeScript } from "https://escad.dev/deps/babel.ts"; | ||
import * as path from "../deps/std/path.ts"; | ||
import * as t from "../test_util/mod.ts"; | ||
|
||
const dirname = path.dirname(path.fromFileUrl(import.meta.url)); | ||
|
||
|
@@ -59,8 +58,6 @@ app.use(async (ctx) => { | |
}); | ||
}); | ||
|
||
await t.config({ port: 9944 }); | ||
|
||
const rootFilePath = getTranspiledPath(transformUrl(rootFile)); | ||
await Deno.writeTextFile( | ||
path.join(transpiledDir, "index.html"), | ||
|
File renamed without changes.
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,19 +1,28 @@ | ||
import * as rpc from "../rpc/mod.ts"; | ||
|
||
/** We represent as a class, not a branded type, because we want to extend into a pretty signature. */ | ||
export class Config< | ||
DiscoveryValue = any, | ||
RpcCallMethods extends rpc.ProviderMethods = rpc.ProviderMethods, | ||
RpcSubscriptionMethods extends rpc.ProviderMethods = rpc.ProviderMethods, | ||
RpcErrorDetails extends rpc.ErrorDetails = rpc.ErrorDetails, | ||
> { | ||
// TODO: get rid of this gunk | ||
RpcMethods!: RpcCallMethods & RpcSubscriptionMethods; | ||
RpcCallMethods!: RpcCallMethods; | ||
RpcSubscriptionMethods!: RpcSubscriptionMethods; | ||
RpcErrorDetails!: RpcErrorDetails; | ||
|
||
#discoveryValue?: DiscoveryValue | Promise<DiscoveryValue>; | ||
|
||
constructor( | ||
readonly discoveryValue: DiscoveryValue, | ||
readonly initDiscoveryValue: () => DiscoveryValue | Promise<DiscoveryValue>, | ||
readonly addressPrefix: number, | ||
) {} | ||
|
||
get discoveryValue() { | ||
if (!this.#discoveryValue) { | ||
this.#discoveryValue = this.initDiscoveryValue(); | ||
} | ||
return this.#discoveryValue; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -25,17 +25,16 @@ | |
"include": ["."], | ||
"tasks": { | ||
"run": "deno run -A --no-check=remote", | ||
"run:browser": "deno task run _tasks/run_browser.ts", | ||
"run:browser": "deno task run test_ctx.ts deno task run _tasks/run_browser.ts", | ||
"debug": "deno task run --inspect-brk", | ||
"download:frame_metadata": "deno task run _tasks/download_frame_metadata.ts", | ||
"udd": "deno task star && deno task run https://deno.land/x/[email protected]/main.ts _star.ts", | ||
"dnt": "deno task run _tasks/dnt.ts", | ||
"star": "deno task run _tasks/star.ts && deno cache --no-check=remote _star.ts", | ||
"lock": "deno task star --lock=lock.json --lock-write", | ||
"lint": "deno lint", | ||
"test": "deno test -A --no-check=remote -L=info --ignore=target", | ||
"test": "deno task run test_ctx.ts deno test -A --no-check=remote -L=info --ignore=target --parallel", | ||
"test:update": "deno task test -- -- --update", | ||
"bench": "deno bench -A --no-check=remote --unstable", | ||
"codegen": "deno task run main.ts" | ||
"bench": "deno bench -A --no-check=remote --unstable" | ||
} | ||
} |
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 @@ | ||
export * from "https://deno.land/x/[email protected]/util-crypto/mod.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,27 @@ | ||
import type { KeyringPair } from "https://deno.land/x/[email protected]/keyring/types.ts"; | ||
import { assertEquals, assertObjectMatch } from "../deps/std/testing/asserts.ts"; | ||
import * as C from "../mod.ts"; | ||
import * as t from "../test_util/mod.ts"; | ||
import * as T from "../test_util/mod.ts"; | ||
import * as U from "../util/mod.ts"; | ||
|
||
Deno.test({ | ||
name: "Balances.transfer", | ||
fn: async (ctx) => { | ||
const config = await t.config({ altRuntime: "westend" }); | ||
|
||
await ctx.step("extrinsic events", async () => { | ||
const extrinsicEvents: string[] = await collectExtrinsicEvents( | ||
{ | ||
config, | ||
config: T.westend, | ||
palletName: "Balances", | ||
methodName: "transfer", | ||
args: { | ||
value: 12345n, | ||
dest: { | ||
type: "Id", | ||
value: t.bob.publicKey, | ||
value: T.bob.publicKey, | ||
}, | ||
}, | ||
}, | ||
t.alice, | ||
T.alice, | ||
); | ||
|
||
assertEquals(extrinsicEvents, ["ready", "inBlock", "finalized"]); | ||
|
@@ -32,56 +30,48 @@ Deno.test({ | |
await ctx.step({ | ||
name: "account balance updated", | ||
fn: async () => { | ||
const root = C.readEntry(config, "System", "Account", [t.bob.publicKey]); | ||
const root = C.readEntry(T.westend, "System", "Account", [T.bob.publicKey]); | ||
|
||
const state = await root.run(); | ||
|
||
assertObjectMatch(state, { value: { data: { free: 10000000000012345n } } }); | ||
}, | ||
}); | ||
|
||
config.close(); | ||
}, | ||
}); | ||
|
||
Deno.test({ | ||
name: "Treasury.propose_spend", | ||
fn: async (ctx) => { | ||
const config = await t.config({ altRuntime: "westend" }); | ||
|
||
await ctx.step("extrinsic events", async () => { | ||
const extrinsicEvents: string[] = await collectExtrinsicEvents( | ||
{ | ||
config, | ||
config: T.westend, | ||
palletName: "Treasury", | ||
methodName: "propose_spend", | ||
args: { | ||
value: 200n, | ||
beneficiary: { | ||
type: "Id", | ||
value: t.bob.publicKey, | ||
value: T.bob.publicKey, | ||
}, | ||
}, | ||
}, | ||
t.alice, | ||
T.alice, | ||
); | ||
|
||
assertEquals(extrinsicEvents, ["ready", "inBlock", "finalized"]); | ||
}); | ||
|
||
config.close(); | ||
}, | ||
}); | ||
|
||
Deno.test({ | ||
name: "Democracy.propose", | ||
fn: async (ctx) => { | ||
const config = await t.config({ altRuntime: "westend" }); | ||
|
||
await ctx.step("extrinsic events", async () => { | ||
const extrinsicEvents: string[] = await collectExtrinsicEvents( | ||
{ | ||
config, | ||
config: T.westend, | ||
palletName: "Democracy", | ||
methodName: "propose", | ||
args: { | ||
|
@@ -91,13 +81,11 @@ Deno.test({ | |
value: 2000000000000n, | ||
}, | ||
}, | ||
t.alice, | ||
T.alice, | ||
); | ||
|
||
assertEquals(extrinsicEvents, ["ready", "inBlock", "finalized"]); | ||
}); | ||
|
||
config.close(); | ||
}, | ||
}); | ||
|
||
|
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,11 +1,7 @@ | ||
import * as C from "../mod.ts"; | ||
import * as t from "../test_util/mod.ts"; | ||
import * as T from "../test_util/mod.ts"; | ||
import * as U from "../util/mod.ts"; | ||
|
||
const config = await t.config(); | ||
|
||
const root = C.readEntry(config, "System", "Account", [t.alice.publicKey]); | ||
const root = C.readEntry(T.polkadot, "System", "Account", [T.alice.publicKey]); | ||
|
||
console.log(U.throwIfError(await root.run())); | ||
|
||
config.close(); |
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,11 +1,7 @@ | ||
import * as C from "../mod.ts"; | ||
import * as t from "../test_util/mod.ts"; | ||
import * as T from "../test_util/mod.ts"; | ||
import * as U from "../util/mod.ts"; | ||
|
||
const config = await t.config(); | ||
|
||
const root = C.readKeyPage(config, "System", "Account", 10); | ||
const root = C.readKeyPage(T.polkadot, "System", "Account", 10); | ||
|
||
console.log(U.throwIfError(await root.run()).keys); | ||
|
||
config.close(); |
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,11 +1,7 @@ | ||
import * as C from "../mod.ts"; | ||
import * as t from "../test_util/mod.ts"; | ||
import * as T from "../test_util/mod.ts"; | ||
import * as U from "../util/mod.ts"; | ||
|
||
const config = await t.config(); | ||
|
||
const root = C.metadata(config); | ||
const root = C.metadata(T.polkadot); | ||
|
||
console.log(U.throwIfError(await root.run())); | ||
|
||
config.close(); |
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,13 +1,9 @@ | ||
import * as C from "../../mod.ts"; | ||
import * as t from "../../test_util/mod.ts"; | ||
import * as T from "../../test_util/mod.ts"; | ||
import * as U from "../../util/mod.ts"; | ||
|
||
const config = await t.config(); | ||
const aliceStash = T.alice.derive("//stash"); | ||
|
||
const aliceStash = t.alice.derive("//stash"); | ||
|
||
const aliceBonded = C.readEntry(config, "Staking", "Bonded", [aliceStash.publicKey]); | ||
const aliceBonded = C.readEntry(T.polkadot, "Staking", "Bonded", [aliceStash.publicKey]); | ||
|
||
console.log(U.throwIfError(await aliceBonded.run())); | ||
|
||
config.close(); |
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
Oops, something went wrong.