Skip to content

Commit 4fa5a48

Browse files
authored
feat(refactor): Use @polkadot utils from @w3ux/utils to prevent multiple versions (#124)
1 parent 946ef1b commit 4fa5a48

File tree

11 files changed

+43
-33
lines changed

11 files changed

+43
-33
lines changed

builder/src/builders/util.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,14 @@ export const getTemplate = async (name) => {
9595
export const generatePackageJson = async (
9696
inputDir: string,
9797
outputDir: string,
98-
bundler: "gulp" | "tsup" | "module" | null
98+
bundler: "gulp" | "tsup" | "module" | null,
99+
additionalExports: Record<
100+
string,
101+
{
102+
import: string;
103+
require: string;
104+
}
105+
> = {}
99106
): Promise<boolean> => {
100107
try {
101108
// Read the original package.json.
@@ -134,6 +141,7 @@ export const generatePackageJson = async (
134141
import: "./mjs/index.js",
135142
require: "./cjs/index.js",
136143
},
144+
...additionalExports,
137145
},
138146
};
139147
}
@@ -148,6 +156,7 @@ export const generatePackageJson = async (
148156
import: "./index.js",
149157
require: "./index.cjs",
150158
},
159+
...additionalExports,
151160
},
152161
};
153162
}

builder/src/builders/utils/index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,19 @@ export const build = async () => {
3535
!(await generatePackageJson(
3636
libDirectory,
3737
`${libDirectory}/${PACKAGE_OUTPUT}`,
38-
"tsup"
38+
"tsup",
39+
// Defining the additional entry points as `polkadot/util` and `polkadot/util-crypto`
40+
// packages are re-exported.
41+
{
42+
"./util": {
43+
import: "./util/index.js",
44+
require: "./util/index.cjs",
45+
},
46+
"./util-crypto": {
47+
import: "./util-crypto/index.js",
48+
require: "./util-crypto/index.cjs",
49+
},
50+
}
3951
))
4052
) {
4153
throw `Failed to generate package.json file.`;

library/react-connect-kit/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
{
22
"name": "@w3ux/react-connect-kit-source",
33
"license": "GPL-3.0-only",
4-
"version": "1.6.0",
4+
"version": "1.7.0",
55
"type": "module",
66
"scripts": {
77
"clear": "rm -rf node_modules dist tsconfig.tsbuildinfo",
88
"build": "gulp --silent"
99
},
1010
"dependencies": {
1111
"@chainsafe/metamask-polkadot-adapter": "^0.6.0",
12-
"@polkadot/util": "^13.1.1",
1312
"@polkagate/extension-dapp": "^0.46.13",
1413
"@w3ux/extension-assets": "^0.3.1",
1514
"@w3ux/hooks": "^1.1.0",
16-
"@w3ux/utils": "^0.7.0"
15+
"@w3ux/utils": "^0.9.0"
1716
},
1817
"devDependencies": {
1918
"@chainsafe/metamask-polkadot-types": "^0.7.0",

library/react-connect-kit/src/ExtensionAccountsProvider/snap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import type {
1515
SignerPayloadRaw,
1616
SignerResult,
1717
} from "@polkadot/types/types";
18-
import type { HexString } from "@polkadot/util/types";
1918
import { SnapConfig } from "@chainsafe/metamask-polkadot-types";
2019
import { ExtensionAccount } from "../ExtensionsProvider/types";
20+
import { HexString } from "types";
2121

2222
interface Web3Window extends InjectedWindow {
2323
ethereum: unknown;

library/react-connect-kit/src/ExtensionAccountsProvider/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ export interface HandleImportExtension {
2828
removedActiveAccount: MaybeAddress;
2929
};
3030
}
31+
32+
export type HexString = `0x${string}`;

library/react-polkicon/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
{
22
"name": "@w3ux/react-polkicon-source",
33
"license": "GPL-3.0-only",
4-
"version": "1.2.0",
4+
"version": "1.3.0",
55
"type": "module",
66
"scripts": {
77
"clear": "rm -rf node_modules dist tsconfig.tsbuildinfo",
88
"build": "gulp --silent"
99
},
1010
"dependencies": {
11-
"@polkadot/util": "^12.6.2",
12-
"@w3ux/utils": "^0.4.0",
11+
"@w3ux/utils": "^0.9.0",
1312
"framer-motion": "^11.2.10"
1413
},
1514
"devDependencies": {

library/react-polkicon/src/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @license Copyright 2024 w3ux authors & contributors
22
SPDX-License-Identifier: GPL-3.0-only */
33

4-
import { decodeAddress, blake2AsU8a } from "@polkadot/util-crypto";
4+
import { decodeAddress, blake2AsU8a } from "@w3ux/utils/util-crypto";
55

66
/*
77
A generic identity icon, taken from

library/utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@w3ux/utils-source",
33
"license": "GPL-3.0-only",
4-
"version": "0.7.0",
4+
"version": "0.9.0",
55
"type": "module",
66
"scripts": {
77
"clear": "rm -rf node_modules dist tsconfig.tsbuildinfo",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "@polkadot/util-crypto";

library/utils/src/util/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "@polkadot/util";

0 commit comments

Comments
 (0)