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

Use Node 20, Update Yarn and some dependencies. #3468

Merged
merged 23 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
with:
registry-url: 'https://registry.npmjs.org'
scope: '@planetarium'
node-version: 18
node-version: 'lts/*'
- id: determine-version
run: node scripts/determine-version.js
- shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/yarn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
strategy:
matrix:
node-version: [19] # TODO: Add LTS
node-version: ['lts/*']
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"typescript.enablePromptUseWorkspaceTsdk": true,
"eslint.nodePath": ".yarn/sdks",
"[typescript]": {
"editor.defaultFormatter": "rome.rome",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports.rome": true
Expand Down
9 changes: 0 additions & 9 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

This file was deleted.

28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

873 changes: 0 additions & 873 deletions .yarn/releases/yarn-3.4.1.cjs

This file was deleted.

893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.1.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .yarn/sdks/typescript/lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ const moduleWrapper = tsserver => {
str = `zip:${str}`;
} break;
}
} else {
str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
}
}

Expand Down
2 changes: 2 additions & 0 deletions .yarn/sdks/typescript/lib/tsserverlibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ const moduleWrapper = tsserver => {
str = `zip:${str}`;
} break;
}
} else {
str = str.replace(/^\/?/, process.platform === `win32` ? `` : `/`);
}
}

Expand Down
6 changes: 3 additions & 3 deletions .yarn/sdks/typescript/lib/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const absRequire = createRequire(absPnpApiPath);

if (existsSync(absPnpApiPath)) {
if (!process.versions.pnp) {
// Setup the environment to be able to require typescript/lib/typescript.js
// Setup the environment to be able to require typescript
require(absPnpApiPath).setup();
}
}

// Defer to the real typescript/lib/typescript.js your application uses
module.exports = absRequire(`typescript/lib/typescript.js`);
// Defer to the real typescript your application uses
module.exports = absRequire(`typescript`);
8 changes: 6 additions & 2 deletions .yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"name": "typescript",
"version": "4.9.5-sdk",
"version": "5.2.2-sdk",
"main": "./lib/typescript.js",
"type": "commonjs"
"type": "commonjs",
"bin": {
"tsc": "./bin/tsc",
"tsserver": "./bin/tsserver"
}
}
10 changes: 4 additions & 6 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
compressionLevel: mixed

yarnPath: .yarn/releases/yarn-3.4.1.cjs
enableGlobalCache: false

yarnPath: .yarn/releases/yarn-4.0.1.cjs
21 changes: 17 additions & 4 deletions @planetarium/account-aws-kms/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@
"description": "Libplanet account implementation using AWS KMS",
"type": "module",
"main": "./dist/index.js",
"imports": {
"#crypto": {
"node": "./src/crypto/node.ts",
"default": "./src/crypto/browser.ts"
}
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
"node": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"browser": "./dist/index.browser.mjs",
"default": "./dist/index.js"
}
},
"files": [
Expand Down Expand Up @@ -37,7 +47,7 @@
"@vitest/coverage-c8": "^0.29.3",
"@vitest/ui": "^0.29.3",
"es-aggregate-error": "^1.0.9",
"nanobundle": "^1.5.0",
"nanobundle": "^1.6.0",
"vite": "^4.1.1",
"vitest": "^0.29.3"
},
Expand All @@ -48,5 +58,8 @@
},
"peerDependencies": {
"@planetarium/account": "workspace:^"
},
"engines": {
"node": ">=19.0.0"
}
}
7 changes: 6 additions & 1 deletion @planetarium/account-aws-kms/src/AwsKmsAccount.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AwsKmsKeyId } from "./AwsKmsKeyId.js";
import { KMSClient, SignCommand } from "@aws-sdk/client-kms";
import { Signature as NobleSignature } from "@noble/secp256k1";
import { crypto } from "#crypto";
import {
Address,
type Account,
Expand Down Expand Up @@ -36,9 +37,13 @@ export class AwsKmsAccount implements Account {
}

async sign(message: Message): Promise<Signature> {
const digest = await crypto.subtle.digest("SHA-256", message);
const digestArray = new Uint8Array(digest);

const cmd = new SignCommand({
KeyId: this.keyId,
Message: message,
Message: digestArray,
MessageType: "DIGEST",
SigningAlgorithm: "ECDSA_SHA_256",
});
const response = await this.#client.send(cmd);
Expand Down
5 changes: 5 additions & 0 deletions @planetarium/account-aws-kms/src/crypto/browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare const globalThis: Record<string, any> | undefined;
export const crypto =
typeof globalThis === "object" && "crypto" in globalThis
? globalThis.crypto
: undefined;
6 changes: 6 additions & 0 deletions @planetarium/account-aws-kms/src/crypto/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as nc from "node:crypto";
export const crypto =
nc && typeof nc === "object" && "webcrypto" in nc
? // rome-ignore lint/suspicious/noExplicitAny: false
(nc.webcrypto as any)
: undefined;
8 changes: 5 additions & 3 deletions @planetarium/account-aws-kms/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"include": ["./src", "*.d.ts", "*.ts"],
"include": ["./src", "*.d.ts", "src/*.ts"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it included by ./src? 👀

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just src also works since it's "at" rootDir.

"compilerOptions": {
"rootDir": "./src",
"outDir": "dist",
"target": "ES2020",
"target": "ES2022",
"strict": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"module": "nodenext",
"moduleResolution": "nodenext",
"lib": ["ES2020"]
"lib": ["ES2022"]
}
}
3 changes: 3 additions & 0 deletions @planetarium/account-aws-kms/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ export default defineConfig({
test: {
cache: false,
testTimeout: 30000,
alias: {
"#crypto": "./src/crypto/node.ts",
},
},
});
2 changes: 1 addition & 1 deletion @planetarium/account-web3-secret-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@vitest/coverage-c8": "^0.29.2",
"@vitest/ui": "^0.29.2",
"fast-check": "^3.8.0",
"nanobundle": "^1.5.0",
"nanobundle": "^1.6.0",
"stream-buffers": "^3.0.2",
"vite": "^4.1.4",
"vitest": "^0.29.2"
Expand Down
2 changes: 1 addition & 1 deletion @planetarium/account-web3-secret-storage/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "nodenext",
"module": "ESNext",
"module": "NodeNext",
"lib": ["ESNext", "DOM"]
}
}
2 changes: 1 addition & 1 deletion @planetarium/account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@vitest/coverage-c8": "^0.29.2",
"@vitest/ui": "^0.29.2",
"fast-check": "^3.1.2",
"nanobundle": "^1.5.0",
"nanobundle": "^1.6.0",
"vite": "^4.1.1",
"vitest": "^0.29.2"
},
Expand Down
3 changes: 2 additions & 1 deletion @planetarium/account/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"include": ["./src", "*.d.ts", "*.ts"],
"compilerOptions": {
"outDir": "dist",
"target": "ES2020",
"target": "ES2022",
"strict": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"module": "nodenext",
"moduleResolution": "nodenext"
},
}
2 changes: 1 addition & 1 deletion @planetarium/tx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@vitest/ui": "^0.29.2",
"execa": "^6.1.0",
"fast-check": "^3.1.2",
"nanobundle": "^1.5.0",
"nanobundle": "^1.6.0",
"vite": "^4.1.3",
"vitest": "^0.29.2"
},
Expand Down
8 changes: 4 additions & 4 deletions @planetarium/tx/src/tx/signed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ export type SignedTx<T extends UnsignedTx> = T & { signature: Signature };

export async function signTx(
tx: UnsignedTx,
signAccount: Account,
signAccount: Account
): Promise<SignedTx<typeof tx>> {
if (
!bytesEqual(
tx.publicKey,
(await signAccount.getPublicKey()).toBytes("uncompressed"),
(await signAccount.getPublicKey()).toBytes("uncompressed")
)
) {
throw new Error("Public keys in the tx and the signAccount are mismatched");
} else if (
!bytesEqual(
tx.signer,
Address.deriveFrom(await signAccount.getPublicKey()).toBytes(),
Address.deriveFrom(await signAccount.getPublicKey()).toBytes()
)
) {
throw new Error("The transaction signer does not match to the signAccount");
Expand All @@ -35,7 +35,7 @@ export async function signTx(
}

export function encodeSignedTx<T extends UnsignedTx>(
tx: SignedTx<T>,
tx: SignedTx<T>
): Dictionary {
const dict = encodeUnsignedTx(tx);
const sig = tx.signature.toBytes();
Expand Down
3 changes: 2 additions & 1 deletion @planetarium/tx/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
"include": ["./src", "*.d.ts", "*.ts"],
"compilerOptions": {
"outDir": "dist",
"target": "ES2020",
"target": "ES2022",
"strict": true,
"noUnusedLocals": true,
"noImplicitReturns": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"module": "nodenext",
"moduleResolution": "nodenext"
}
}
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packageManager": "yarn@3.4.1",
"packageManager": "yarn@4.0.1",
"private": true,
"workspaces": [
"@planetarium/account",
Expand All @@ -9,17 +9,18 @@
"Libplanet.Tools"
],
"scripts": {
"build": "_libplanet_build=1 yarn workspaces foreach -p run build",
"pack-all": "yarn workspaces foreach -p --include @planetarium/\\* pack",
"build": "_libplanet_build=1 yarn workspaces foreach -p -A run build",
"pack-all": "yarn workspaces foreach -p -A --include @planetarium/\\* pack",
"postinstall": "env | grep -E '^_libplanet_build=1$' || yarn build && echo ran yarn build",
"prepack": "printf \"\\033[41;97mLibplanet note: `yarn pack` is not allowed on the project root level, as it produces useless empty package. use `yarn pack-all` instead.\\033[0m\n\" > /dev/stderr && false",
"test": "yarn workspaces foreach -p run test"
"test": "yarn workspaces foreach -p -A run test"
},
"devDependencies": {
"@vitest/coverage-c8": "^0.29.2",
"nanobundle": "^1.6.0",
"node-fetch": "^3.1.1",
"rome": "^11.0.0",
"typescript": "^4.8.4",
"typescript": "^4.5.0",
"unzipper": "^0.10.11",
"vitest": "^0.29.2"
},
Expand Down
3 changes: 2 additions & 1 deletion rome.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"./Libplanet.*/**/*",
"./@planetarium/*/dist/**/*",
"./@planetarium/*/coverage/**/*",
"./.pnp.*"
"./.pnp.*",
"./**/*/crypto/**/*"
]
},
"linter": {
Expand Down
Loading
Loading