Skip to content

Commit dab425d

Browse files
committed
build succeeds
1 parent 985d0ec commit dab425d

4 files changed

Lines changed: 64 additions & 27 deletions

File tree

packages/js/client/scripts/extractPluginConfigs.ts

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import path from "path";
55
interface PluginConfigSource {
66
name: string;
77
module: string;
8-
file: string;
98
uri: string;
109
config: string;
11-
interfaces?: string[];
12-
types?: string[];
10+
files: {
11+
name: string;
12+
interfaces?: string[];
13+
types?: string[];
14+
}[];
1315
externals?: {
1416
type: string;
1517
module: string;
@@ -20,19 +22,29 @@ const plugins: PluginConfigSource[] = [
2022
{
2123
name: "Ipfs",
2224
module: "@web3api/ipfs-plugin-js",
23-
file: "build/index.d.ts",
2425
uri: "w3://ens/ipfs.web3api.eth",
2526
config: "IpfsConfig",
26-
interfaces: ["IpfsConfig"]
27+
files: [{
28+
name: "build/index.d.ts",
29+
interfaces: ["IpfsConfig"]
30+
}]
2731
},
2832
{
2933
name: "Ethereum",
3034
module: "@web3api/ethereum-plugin-js",
31-
file: "build/index.d.ts",
3235
uri: "w3://ens/ethereum.web3api.eth",
3336
config: "EthereumConfig",
34-
interfaces: ["ConnectionConfig", "ConnectionConfigs"],
35-
types: ["EthereumConfig", "EthereumProvider", "EthereumSigner", "AccountIndex", "Address"],
37+
files: [
38+
{
39+
name: "build/index.d.ts",
40+
types: ["EthereumConfig"],
41+
},
42+
{
43+
name: "build/Connection.d.ts",
44+
interfaces: ["ConnectionConfig", "ConnectionConfigs"],
45+
types: ["EthereumProvider", "EthereumSigner", "AccountIndex", "Address"],
46+
},
47+
],
3648
externals: [
3749
{
3850
type: "Signer",
@@ -51,11 +63,13 @@ const plugins: PluginConfigSource[] = [
5163
{
5264
name: "Ens",
5365
module: "@web3api/ens-plugin-js",
54-
file: "build/index.d.ts",
5566
uri: "w3://ens/ens.web3api.eth",
5667
config: "EnsConfig",
57-
interfaces: ["EnsConfig", "Addresses"],
58-
types: ["Address"]
68+
files: [{
69+
name: "build/index.d.ts",
70+
interfaces: ["EnsConfig", "Addresses"],
71+
types: ["Address"]
72+
}]
5973
}
6074
];
6175

@@ -71,20 +85,25 @@ function main(): void {
7185
for (const plugin of plugins) {
7286
let output = header;
7387

74-
output += `\n\n/// Types generated from ${plugin.file}`
88+
output += `\n\n/// Types generated from ${plugin.module} build files:\n/// ${
89+
plugin.files.map(({ name }) => name).join(', ')
90+
}`
7591

7692
const project = new TsProject();
77-
const filePath = require.resolve(path.join(plugin.module, plugin.file));
78-
const sourceFile = project.addSourceFileAtPath(filePath);
7993

80-
for (const pluginInterface of plugin.interfaces || []) {
81-
const int = sourceFile.getInterfaceOrThrow(pluginInterface);
82-
output += `\n\n${int.print().replace(/ /g, " ")}`;
83-
}
94+
for (const file of plugin.files) {
95+
const filePath = require.resolve(path.join(plugin.module, file.name));
96+
const sourceFile = project.addSourceFileAtPath(filePath);
97+
98+
for (const pluginInterface of file.interfaces || []) {
99+
const int = sourceFile.getInterfaceOrThrow(pluginInterface);
100+
output += `\n\n${int.print().replace(/ /g, " ")}`;
101+
}
84102

85-
for (const pluginType of plugin.types || []) {
86-
const typ = sourceFile.getTypeAliasOrThrow(pluginType);
87-
output += `\n\n${typ.print().replace("declare ", "")}`;
103+
for (const pluginType of file.types || []) {
104+
const typ = sourceFile.getTypeAliasOrThrow(pluginType);
105+
output += `\n\n${typ.print().replace("declare ", "")}`;
106+
}
88107
}
89108

90109
for (const pluginExternal of plugin.externals || []) {
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
/// NOTE: This is an auto-generated file. See scripts/extractPluginConfigs.ts
22
/* eslint-disable @typescript-eslint/no-explicit-any */
33

4-
/// Types generated from build/index.d.ts
4+
/// Types generated from @web3api/ens-plugin-js build files:
5+
/// build/index.d.ts
56

67
export interface EnsConfig {
7-
address?: Address;
8+
addresses?: Addresses;
9+
}
10+
11+
export interface Addresses {
12+
[network: string]: Address;
813
}
914

1015
export type Address = string;

packages/js/client/src/pluginConfigs/Ethereum.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
/// NOTE: This is an auto-generated file. See scripts/extractPluginConfigs.ts
22
/* eslint-disable @typescript-eslint/no-explicit-any */
33

4-
/// Types generated from build/index.d.ts
4+
/// Types generated from @web3api/ethereum-plugin-js build files:
5+
/// build/index.d.ts, build/Connection.d.ts
56

6-
export interface EthereumConfig {
7+
export type EthereumConfig = ConnectionConfigs & {
8+
defaultNetwork?: string;
9+
};
10+
11+
export interface ConnectionConfig {
712
provider: EthereumProvider;
813
signer?: EthereumSigner;
914
}
1015

11-
export type EthereumProvider = string | ExternalProvider;
16+
export interface ConnectionConfigs {
17+
[network: string]: ConnectionConfig;
18+
}
19+
20+
export type EthereumProvider = string | ExternalProvider | JsonRpcProvider;
1221

1322
export type EthereumSigner = Signer | Address | AccountIndex;
1423

@@ -21,3 +30,6 @@ export type Signer = any;
2130

2231
// import { ExternalProvider } from "@ethersproject/providers"
2332
export type ExternalProvider = any;
33+
34+
// import { JsonRpcProvider } from "@ethersproject/providers"
35+
export type JsonRpcProvider = any;

packages/js/client/src/pluginConfigs/Ipfs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/// NOTE: This is an auto-generated file. See scripts/extractPluginConfigs.ts
22
/* eslint-disable @typescript-eslint/no-explicit-any */
33

4-
/// Types generated from build/index.d.ts
4+
/// Types generated from @web3api/ipfs-plugin-js build files:
5+
/// build/index.d.ts
56

67
export interface IpfsConfig {
78
provider: string;

0 commit comments

Comments
 (0)