Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client config - unique maps #1613

Merged
merged 26 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
798a22e
CoreClientConfig - use unique map instead of array for config.envs
pileks Feb 16, 2023
2a7004f
Merge branch 'pileks/feat/workflow-manifest-0.2.0' into pileks/feat/j…
pileks Feb 16, 2023
0d8b3d8
Merge remote-tracking branch 'origin/pileks/feat/workflow-manifest-0.…
pileks Feb 21, 2023
97485f3
fix env tests
pileks Feb 22, 2023
b7413de
ClientConfig - change interfaces into a map instead of array
pileks Feb 22, 2023
833102c
fix up plugin tests
pileks Feb 23, 2023
4589517
fix core tests & lint
pileks Feb 23, 2023
9ba79b2
Merge remote-tracking branch 'origin/origin-dev' into pileks/feat/js-…
pileks Feb 23, 2023
0a4c409
remove commented/old code
pileks Feb 23, 2023
6fa5c1e
chore: rename types & lint
pileks Feb 23, 2023
f2a7286
Merge remote-tracking branch 'origin/origin-dev' into pileks/feat/js-…
pileks Feb 23, 2023
ea82090
Merge branch 'pileks/feat/workflow-manifest-0.2.0' into pileks/feat/j…
pileks Feb 24, 2023
3e2ea0a
Merge remote-tracking branch 'origin/origin-dev' into pileks/feat/js-…
pileks Feb 24, 2023
7bc49b9
Merge remote-tracking branch 'origin/origin-dev' into pileks/feat/js-…
pileks Mar 2, 2023
642057b
add urimap type
pileks Mar 7, 2023
0e67c7c
CoreClientConfig - refactor Envs into ReadonlyUriMap<WrapperEnv>
pileks Mar 8, 2023
d5bbfd5
fix env tests
pileks Mar 8, 2023
8d2e26e
Rewrite CoreClientConfig.interfaces as ReadonlyUriMap<Uri[]>
pileks Mar 8, 2023
6851568
adjust get-implementations algorithm to new CoreClientConfig structure
pileks Mar 8, 2023
e462c80
chore: lint
pileks Mar 8, 2023
7ac870d
chore: fix example quickstart
pileks Mar 8, 2023
25af064
Merge remote-tracking branch 'origin/origin-dev' into pileks/feat/js-…
pileks Mar 8, 2023
8d77dae
Remove InterfaceImplementations file
pileks Mar 8, 2023
b5dc785
Merge remote-tracking branch 'origin/origin-dev' into pileks/feat/js-…
pileks Mar 14, 2023
b461dc4
chore: uncomment test cases
dOrgJelli Mar 16, 2023
d7fe7fb
merge origin-dev
dOrgJelli Mar 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { parseWrapperEnvsOption } from "../../../lib";
describe("unit tests for option-parsers", () => {
describe("wrapper-envs", () => {
const sampleFileEnvs = {
"ens/wraps.eth:ethereum@1.0.0": {
"wrap://ens/wraps.eth:ethereum@1.0.0": {
connection: {
networkNameOrChainId: "mainnet",
node: "https://mainnet.infura.io/v3/some_api_key",
},
},
"ens/hello-world.polywrap.eth": { foo: "bar" },
"wrap://ens/hello-world.polywrap.eth": { foo: "bar" },
};

it("Should return undefined when undefined is provided for wrapperEnvsPath", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ export abstract class BaseClientConfigBuilder implements IClientConfigBuilder {
delete this.config.interfaces[this.sanitizeUri(interfaceUri)];
}

if (existingInterface.size == 0) {
delete this._config.interfaces[interfaceUri];
}

return this;
}

Expand Down
36 changes: 16 additions & 20 deletions packages/js/client-config-builder/src/ClientConfigBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { BuildOptions, IClientConfigBuilder, BuilderConfig } from "./types";

import {
CoreClientConfig,
Env,
InterfaceImplementations,
IUriPackage,
IUriRedirect,
IUriWrapper,
Uri,
WrapperEnv,
ReadonlyUriMap,
UriMap,
} from "@polywrap/core-js";
import {
RecursiveResolver,
Expand Down Expand Up @@ -66,32 +67,27 @@ export class ClientConfigBuilder extends BaseClientConfigBuilder {
return this._config;
}

private buildEnvs(): Env[] {
const envs: Env[] = [];
private buildEnvs(): ReadonlyUriMap<WrapperEnv> {
const envs = new UriMap<WrapperEnv>();

for (const [uri, env] of Object.entries(this._config.envs)) {
envs.push({ uri: Uri.from(uri), env });
for (const uri in this._config.envs) {
envs.set(Uri.from(uri), this._config.envs[uri]);
}

return envs;
}

private buildInterfaces(): InterfaceImplementations[] {
const interfaces: InterfaceImplementations[] = [];

for (const [interfaceUri, implementations] of Object.entries(
this._config.interfaces
)) {
if (implementations.size === 0) continue;
interfaces.push({
interface: Uri.from(interfaceUri),
implementations: Array.from(implementations).map((uri) =>
Uri.from(uri)
),
});
private buildInterfaces(): ReadonlyUriMap<readonly Uri[]> {
const interfaceImplementations = new UriMap<readonly Uri[]>();

for (const uri in this._config.interfaces) {
const uriImpls = [...this._config.interfaces[uri]].map((x) =>
Uri.from(x)
);
interfaceImplementations.set(Uri.from(uri), uriImpls);
}

return interfaces;
return interfaceImplementations;
}

private buildRedirects(): IUriRedirect[] {
Expand Down
Loading