Skip to content

Commit

Permalink
Merge pull request #146 from Moonsong-Labs/fix-zombie-run
Browse files Browse the repository at this point in the history
fixed grep weirdness
  • Loading branch information
timbrinded authored Jun 9, 2023
2 parents fd1d9da + 7085c51 commit 989af1d
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 12 deletions.
6 changes: 6 additions & 0 deletions .changeset/kind-crabs-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@moonwall/cli": patch
---

Fix GrepTest for Running networks
- [#144](https://github.com/Moonsong-Labs/moonwall/issues/144)
7 changes: 7 additions & 0 deletions .changeset/red-rice-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@moonwall/types": patch
"@moonwall/cli": patch
---

Tansii Changes
- [#145](https://github.com/Moonsong-Labs/moonwall/issues/145)
4 changes: 3 additions & 1 deletion packages/cli/src/cmds/runNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ export async function runNetwork(args) {

case 5:
await resolveGrepChoice(env);

break;

case 6:
const quit = await inquirer.prompt(questions.find(({ name }) => name == "Quit"));
if (quit.Quit === true) {
Expand Down Expand Up @@ -313,6 +314,7 @@ const resolveGrepChoice = async (env: Environment) => {
message: `What pattern would you like to filter for (ID/Title): `,
default: "D01T01",
});
process.env.MOON_RECYCLE = "true";
return await executeTests(env, { testNamePattern: choice.grep });
};

Expand Down
25 changes: 14 additions & 11 deletions packages/cli/src/internal/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ import { createPublicClient, createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { deriveViemChain } from "@moonwall/util";
import { ApiOptions } from "@polkadot/api/types/index.js";
import { OverrideBundleType } from "@polkadot/types/types/registry";
const debug = Debug("global:providers");

//TODO: Make Generic /w function overloads
export function prepareProviders(providerConfigs: ProviderConfig[]): MoonwallProvider[] {
return providerConfigs.map(({ name, endpoints, type, rpc }) => {
return providerConfigs.map(({ name, endpoints, type, rpc, additionalTypes }) => {
const url = endpoints.includes("ENV_VAR") ? process.env.WSS_URL! : endpoints[0];
const privateKey = process.env.MOON_PRIV_KEY || ALITH_PRIVATE_KEY;

Expand All @@ -32,17 +33,23 @@ export function prepareProviders(providerConfigs: ProviderConfig[]): MoonwallPro
name,
type,
connect: async () => {
const options = {
const options: ApiOptions = {
provider: new WsProvider(url),
initWasm: false,
noInitWarn: true,
rpc: !!rpc ? { ...rpcDefinitions, ...rpc } : rpcDefinitions,
typesBundle: !!additionalTypes ? additionalTypes : undefined,
};

if (!!rpc) {
options["rpc"] = rpc;
}

const api = await ApiPromise.create(options as ApiOptions);
if (!!additionalTypes) {
options["typesBundle"] = { ...additionalTypes };
}

const api = await ApiPromise.create(options);
await api.isReady;
return api;
},
Expand All @@ -55,20 +62,16 @@ export function prepareProviders(providerConfigs: ProviderConfig[]): MoonwallPro
name,
type,
connect: async () => {
const options = {
const options: ApiOptions = {
provider: new WsProvider(url),
initWasm: false,
isPedantic: false,
rpc: rpcDefinitions,
typesBundle: types,
rpc: !!rpc ? { ...rpcDefinitions, ...rpc } : rpcDefinitions,
typesBundle: types as OverrideBundleType,
noInitWarn: true,
};

if (!!rpc) {
options["rpc"] = { ...rpc };
}

const moonApi = await ApiPromise.create(options as ApiOptions);
const moonApi = await ApiPromise.create(options);
await moonApi.isReady;
return moonApi;
},
Expand Down
10 changes: 10 additions & 0 deletions packages/types/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@
"ProviderConfig": {
"description": "The configuration object for a provider.",
"properties": {
"additionalTypes": {
"additionalProperties": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"description": "Represents a collection of GenericData.\nIt's an object where each key is a string and the corresponding value is a GenericData object.",
"type": "object"
},
"endpoints": {
"items": {
"type": "string"
Expand Down
22 changes: 22 additions & 0 deletions packages/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export interface ProviderConfig {
type: ProviderType;
endpoints: string[];
rpc?: IRpcBundle;
additionalTypes?: TypesBundle;
}

// TODO: Make Provider Sub-types (for viem and polkadot.js)
Expand Down Expand Up @@ -226,3 +227,24 @@ export interface IRpcModule {
export interface IRpcBundle {
[moduleName: string]: IRpcModule;
}

/**
* Represents a collection of GenericData.
* It's an object where each key is a string and the corresponding value is a GenericData object.
*
* @example
* ```typescript
* const example: TypesBundle = {
* ContainerChainGenesisData: {
* id: "Vec<u8>"
* }
* };
* ```
*/
export type TypesBundle = {
[key: string]: GenericData;
};

export type GenericData = {
[key: string]: string;
};

0 comments on commit 989af1d

Please sign in to comment.