From 7dff9dc67ee17623c780d93616061b4044bc644c Mon Sep 17 00:00:00 2001 From: tjjfvi Date: Wed, 23 Nov 2022 10:05:01 -0500 Subject: [PATCH] simplify import mapping --- .vscode/settings.json | 1 - deno.jsonc | 7 ++++--- examples/balance.ts | 6 +++--- examples/batch.ts | 13 ++++++++----- examples/derived.ts | 4 ++-- examples/fee_estimate.ts | 6 +++--- examples/first_ten_keys.ts | 4 ++-- examples/metadata.ts | 6 +++--- examples/multisig_transfer.ts | 14 +++++++++----- examples/polkadot_js_signer.ts | 6 +++--- examples/raw_rpc_client_call.ts | 2 +- examples/raw_rpc_client_subscription.ts | 4 ++-- examples/read_block.ts | 6 +++--- examples/read_bonded.ts | 6 +++--- examples/read_era_rewards.ts | 4 ++-- examples/read_events.ts | 4 ++-- examples/rpc_call.ts | 4 ++-- examples/rpc_subscription.ts | 6 +++--- examples/ticker.ts | 6 +++--- examples/transfer.ts | 10 +++++----- examples/watch_blocks.ts | 4 ++-- examples/watch_events.ts | 4 ++-- import_map.json | 8 ++++++++ import_map_cache.json | 11 ----------- import_map_localhost.json | 7 ------- 25 files changed, 75 insertions(+), 78 deletions(-) create mode 100644 import_map.json delete mode 100644 import_map_cache.json delete mode 100644 import_map_localhost.json diff --git a/.vscode/settings.json b/.vscode/settings.json index b4a3c7251..20f131e78 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -10,7 +10,6 @@ }, "deno.codeLens.testArgs": ["--no-check=remote", "-A", "-L=info"], "deno.config": "./deno.jsonc", - "deno.importMap": "./import_map_cache.json", "deno.suggest.imports.hosts": { "https://deno.land": true, "https://x.nest.land": true, diff --git a/deno.jsonc b/deno.jsonc index 0ffcd8b6a..f92a5e8c8 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -7,6 +7,7 @@ "noUncheckedIndexedAccess": true, "useUnknownInCatchVariables": true }, + "importMap": "import_map.json", "lint": { "files": { "exclude": ["target", "codegen/_output"], @@ -27,15 +28,15 @@ }, "include": ["."], "tasks": { - "run": "deno run -A --no-lock --import-map=import_map_cache.json", + "run": "deno run -A --no-lock", "run:browser": "deno task run test_util/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/udd@0.5.0/main.ts target/star.ts", "dnt": "deno task run _tasks/dnt.ts", - "star": "deno task run _tasks/star.ts && deno cache --check --no-lock --import-map=import_map_cache.json target/star.ts", + "star": "deno task run _tasks/star.ts && deno cache --check --no-lock target/star.ts", "lint": "deno lint", - "codegen": "deno task run cache.ts --no-lock --import-map=import_map_localhost.json examples/mod.ts", + "codegen": "deno task run cache.ts --no-lock examples/mod.ts", "test": "deno task run test_util/ctx.ts -- deno test -A --no-lock -L=info --ignore=target --parallel", "test:update": "deno task test -- -- --update", "mdbook:watch": "mdbook watch -o", diff --git a/examples/balance.ts b/examples/balance.ts index d44904ddc..fc1c556ee 100644 --- a/examples/balance.ts +++ b/examples/balance.ts @@ -1,7 +1,7 @@ -import * as T from "#capi/test_util/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as T from "http://localhost:5646/@local/test_util/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" -import { System } from "#capi/proxy/dev:polkadot/@v0.9.31/pallets/mod.ts" +import { System } from "http://localhost:5646/@local/proxy/dev:polkadot/@v0.9.31/pallets/mod.ts" const root = System.Account.entry(T.alice.publicKey).read() diff --git a/examples/batch.ts b/examples/batch.ts index 87f565cee..a5f01dd7e 100644 --- a/examples/batch.ts +++ b/examples/batch.ts @@ -1,9 +1,12 @@ -import * as C from "#capi/mod.ts" -import * as T from "#capi/test_util/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as T from "http://localhost:5646/@local/test_util/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" -import { extrinsic } from "#capi/proxy/dev:westend/@v0.9.31/mod.ts" -import { Balances, Utility } from "#capi/proxy/dev:westend/@v0.9.31/pallets/mod.ts" +import { extrinsic } from "http://localhost:5646/@local/proxy/dev:westend/@v0.9.31/mod.ts" +import { + Balances, + Utility, +} from "http://localhost:5646/@local/proxy/dev:westend/@v0.9.31/pallets/mod.ts" // TODO: uncomment these lines / use env upon solving `count` in zones // const getBalances = C.Z.ls( diff --git a/examples/derived.ts b/examples/derived.ts index e5746e21d..a3724df28 100644 --- a/examples/derived.ts +++ b/examples/derived.ts @@ -1,5 +1,5 @@ -import * as C from "#capi/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" const ids = C.entryRead(C.polkadot)("Paras", "Parachains", []) .access("value") diff --git a/examples/fee_estimate.ts b/examples/fee_estimate.ts index b5778b1eb..ce61d1e37 100644 --- a/examples/fee_estimate.ts +++ b/examples/fee_estimate.ts @@ -1,7 +1,7 @@ -import * as T from "#capi/test_util/mod.ts" +import * as T from "http://localhost:5646/@local/test_util/mod.ts" -import { extrinsic } from "#capi/proxy/dev:westend/@v0.9.31/mod.ts" -import { Balances } from "#capi/proxy/dev:westend/@v0.9.31/pallets/mod.ts" +import { extrinsic } from "http://localhost:5646/@local/proxy/dev:westend/@v0.9.31/mod.ts" +import { Balances } from "http://localhost:5646/@local/proxy/dev:westend/@v0.9.31/pallets/mod.ts" const tx = extrinsic({ sender: T.alice.address, diff --git a/examples/first_ten_keys.ts b/examples/first_ten_keys.ts index 68f53f22f..e1d779224 100644 --- a/examples/first_ten_keys.ts +++ b/examples/first_ten_keys.ts @@ -1,6 +1,6 @@ -import * as U from "#capi/util/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" -import { System } from "#capi/proxy/dev:polkadot/@v0.9.31/pallets/mod.ts" +import { System } from "http://localhost:5646/@local/proxy/dev:polkadot/@v0.9.31/pallets/mod.ts" const root = System.Account.keys().readPage(10) diff --git a/examples/metadata.ts b/examples/metadata.ts index 1ce5f38ce..7b787615a 100644 --- a/examples/metadata.ts +++ b/examples/metadata.ts @@ -1,6 +1,6 @@ -import * as C from "#capi/mod.ts" -import * as T from "#capi/test_util/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as T from "http://localhost:5646/@local/test_util/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" const root = C.metadata(T.polkadot)() diff --git a/examples/multisig_transfer.ts b/examples/multisig_transfer.ts index 27fdf3abb..00314ac2b 100644 --- a/examples/multisig_transfer.ts +++ b/examples/multisig_transfer.ts @@ -1,9 +1,13 @@ -import * as C from "#capi/mod.ts" -import * as T from "#capi/test_util/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as T from "http://localhost:5646/@local/test_util/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" -import { extrinsic } from "#capi/proxy/dev:polkadot/@v0.9.31/mod.ts" -import { Balances, Multisig, System } from "#capi/proxy/dev:polkadot/@v0.9.31/pallets/mod.ts" +import { extrinsic } from "http://localhost:5646/@local/proxy/dev:polkadot/@v0.9.31/mod.ts" +import { + Balances, + Multisig, + System, +} from "http://localhost:5646/@local/proxy/dev:polkadot/@v0.9.31/pallets/mod.ts" // FIXME: remove this check once the Zones .bind(env) fix is merged const hostname = Deno.env.get("TEST_CTX_HOSTNAME") diff --git a/examples/polkadot_js_signer.ts b/examples/polkadot_js_signer.ts index bbf67c711..04e076e60 100644 --- a/examples/polkadot_js_signer.ts +++ b/examples/polkadot_js_signer.ts @@ -1,9 +1,9 @@ import { createTestPairs } from "https://deno.land/x/polkadot@0.0.8/keyring/mod.ts" import { TypeRegistry } from "https://deno.land/x/polkadot@0.0.8/types/mod.ts" -import * as C from "#capi/mod.ts" -import * as T from "#capi/test_util/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as T from "http://localhost:5646/@local/test_util/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" const root = C.extrinsic(T.westend)({ sender: T.alice.address, diff --git a/examples/raw_rpc_client_call.ts b/examples/raw_rpc_client_call.ts index f871ad02b..3a4bd660e 100755 --- a/examples/raw_rpc_client_call.ts +++ b/examples/raw_rpc_client_call.ts @@ -1,4 +1,4 @@ -import * as T from "#capi/test_util/mod.ts" +import * as T from "http://localhost:5646/@local/test_util/mod.ts" const client = await T.westend.client diff --git a/examples/raw_rpc_client_subscription.ts b/examples/raw_rpc_client_subscription.ts index 6be02bfe6..255f4e749 100755 --- a/examples/raw_rpc_client_subscription.ts +++ b/examples/raw_rpc_client_subscription.ts @@ -1,5 +1,5 @@ -import { assertNotInstanceOf } from "#capi/deps/std/testing/asserts.ts" -import * as T from "#capi/test_util/mod.ts" +import { assertNotInstanceOf } from "http://localhost:5646/@local/deps/std/testing/asserts.ts" +import * as T from "http://localhost:5646/@local/test_util/mod.ts" const client = await T.polkadot.client diff --git a/examples/read_block.ts b/examples/read_block.ts index 7f5d2113a..4f90f1b56 100644 --- a/examples/read_block.ts +++ b/examples/read_block.ts @@ -1,6 +1,6 @@ -import * as C from "#capi/mod.ts" -import * as T from "#capi/test_util/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as T from "http://localhost:5646/@local/test_util/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" const extrinsicsRaw = C.chain.getBlock(C.polkadot)() .access("block") diff --git a/examples/read_bonded.ts b/examples/read_bonded.ts index 5a7dd1c60..f2f227057 100644 --- a/examples/read_bonded.ts +++ b/examples/read_bonded.ts @@ -1,6 +1,6 @@ -import * as C from "#capi/mod.ts" -import * as T from "#capi/test_util/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as T from "http://localhost:5646/@local/test_util/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" const aliceBonded = C.entryRead(T.polkadot)("Staking", "Bonded", [T.aliceStash.publicKey]) diff --git a/examples/read_era_rewards.ts b/examples/read_era_rewards.ts index e849f622c..8547861c3 100644 --- a/examples/read_era_rewards.ts +++ b/examples/read_era_rewards.ts @@ -1,5 +1,5 @@ -import * as C from "#capi/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" const idx = C.entryRead(C.westend)("Staking", "ActiveEra", []) .access("value") diff --git a/examples/read_events.ts b/examples/read_events.ts index 0a93f595f..642308528 100644 --- a/examples/read_events.ts +++ b/examples/read_events.ts @@ -1,5 +1,5 @@ -import * as C from "#capi/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" const root = C.entryRead(C.polkadot)("System", "Events", []) diff --git a/examples/rpc_call.ts b/examples/rpc_call.ts index 75aac673c..723583032 100644 --- a/examples/rpc_call.ts +++ b/examples/rpc_call.ts @@ -1,5 +1,5 @@ -import * as C from "#capi/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" const root = C.rpcCall<[], string[]>("rpc_methods")(C.polkadot)() diff --git a/examples/rpc_subscription.ts b/examples/rpc_subscription.ts index 25e7a74e8..ddca43aa8 100644 --- a/examples/rpc_subscription.ts +++ b/examples/rpc_subscription.ts @@ -1,6 +1,6 @@ -import * as C from "#capi/mod.ts" -import * as T from "#capi/test_util/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as T from "http://localhost:5646/@local/test_util/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" const root = C.chain.subscribeNewHeads(T.polkadot)([], (ctx) => { let i = 0 diff --git a/examples/ticker.ts b/examples/ticker.ts index 19fab2bc1..39ae42ffa 100644 --- a/examples/ticker.ts +++ b/examples/ticker.ts @@ -1,6 +1,6 @@ -import * as C from "#capi/mod.ts" -import * as T from "#capi/test_util/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as T from "http://localhost:5646/@local/test_util/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" const root = C.entryWatch(T.polkadot)("Timestamp", "Now", [], (ctx) => { let i = 0 diff --git a/examples/transfer.ts b/examples/transfer.ts index 79c241136..3fc3c539c 100644 --- a/examples/transfer.ts +++ b/examples/transfer.ts @@ -1,9 +1,9 @@ -import * as C from "#capi/mod.ts" -import * as T from "#capi/test_util/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as T from "http://localhost:5646/@local/test_util/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" -import { extrinsic } from "#capi/proxy/dev:westend/@v0.9.31/mod.ts" -import { Balances } from "#capi/proxy/dev:westend/@v0.9.31/pallets/mod.ts" +import { extrinsic } from "http://localhost:5646/@local/proxy/dev:westend/@v0.9.31/mod.ts" +import { Balances } from "http://localhost:5646/@local/proxy/dev:westend/@v0.9.31/pallets/mod.ts" const tx = extrinsic({ sender: T.alice.address, diff --git a/examples/watch_blocks.ts b/examples/watch_blocks.ts index 19a243c99..d831849d8 100644 --- a/examples/watch_blocks.ts +++ b/examples/watch_blocks.ts @@ -1,5 +1,5 @@ -import * as C from "#capi/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" const extrinsicsDecoded = C.extrinsicsDecoded(C.polkadot) diff --git a/examples/watch_events.ts b/examples/watch_events.ts index 0c0e12bcd..e0f4c4582 100644 --- a/examples/watch_events.ts +++ b/examples/watch_events.ts @@ -1,5 +1,5 @@ -import * as C from "#capi/mod.ts" -import * as U from "#capi/util/mod.ts" +import * as C from "http://localhost:5646/@local/mod.ts" +import * as U from "http://localhost:5646/@local/util/mod.ts" const root = C.entryWatch(C.rococo)("System", "Events", [], (ctx) => { let i = 0 diff --git a/import_map.json b/import_map.json new file mode 100644 index 000000000..68a966109 --- /dev/null +++ b/import_map.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "examples/": { + "http://localhost:5646/@local/": "./", + "http://localhost:5646/@local/proxy/": "http://localhost:5646/@local/proxy/" + } + } +} diff --git a/import_map_cache.json b/import_map_cache.json deleted file mode 100644 index 7b8624543..000000000 --- a/import_map_cache.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "scopes": { - "examples/": { - "#capi/": "./", - "#capi/proxy/": "./target/codegen/generated/@local/" - }, - "target/codegen/generated/": { - "/@local/": "./" - } - } -} diff --git a/import_map_localhost.json b/import_map_localhost.json deleted file mode 100644 index e89366df4..000000000 --- a/import_map_localhost.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "scopes": { - "examples/": { - "#capi/": "http://localhost:5646/@local/" - } - } -}