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

fix(rgbpp-sdk): Upgrade ckb-sdk-js to fix SDK esm and commonjs issues #281

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 8 additions & 0 deletions .changeset/brown-pugs-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'rgbpp': major
ShookLyngs marked this conversation as resolved.
Show resolved Hide resolved
'@rgbpp-sdk/btc': major
'@rgbpp-sdk/ckb': major
'@rgbpp-sdk/service': minor
---

refactor: Upgrade ckb-sdk-js to fix esm and commonjs issues
3 changes: 1 addition & 2 deletions apps/service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "rgbpp-sdk-service",
"version": "0.0.1",
"private": true,
"type": "module",
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\"",
Expand All @@ -26,7 +25,7 @@
"json-rpc-2.0": "^1.7.0",
"lodash": "^4.17.21",
"reflect-metadata": "^0.2.0",
"rgbpp": "0.0.0-snap-20240813134030",
"rgbpp": "workspace:*",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we're referencing the workspace:* version of the rgbpp, it's required to run the command pnpm run build:packages before executing the start:dev or build commands. Should we mention this in the README? Does anything in the deployment files (e.g. docker-compose) need to be updated?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree. Maybe we can release v0.6.0 this week and update the dependency.

"rxjs": "^7.8.1",
"snakecase-keys": "^8.0.1",
"zod": "^3.23.8"
Expand Down
8 changes: 4 additions & 4 deletions apps/service/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { Global, Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { BtcAssetsApi } from 'rgbpp/service';
import { BTCTestnetType, Collector } from 'rgbpp/ckb';
import JsonRpcModule from './json-rpc/json-rpc.module.js';
import { RgbppModule } from './rgbpp/rgbpp.module.js';
import { AppService } from './app.service.js';
import { envSchema } from './env.js';
import JsonRpcModule from './json-rpc/json-rpc.module';
import { RgbppModule } from './rgbpp/rgbpp.module';
import { AppService } from './app.service';
import { envSchema } from './env';

@Global()
@Module({
Expand Down
2 changes: 1 addition & 1 deletion apps/service/src/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RpcHandler, RpcMethodHandler } from './json-rpc/json-rpc.decorators.js';
import pkg from '../package.json' with { type: 'json' };
import pkg from '../package.json';

@RpcHandler()
export class AppService {
Expand Down
2 changes: 1 addition & 1 deletion apps/service/src/json-rpc/json-rpc.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Inject, Logger, Module, OnModuleInit } from '@nestjs/common';
import { JsonRpcServer } from './json-rpc.server.js';
import { JsonRpcServer } from './json-rpc.server';

export const JSON_RPC_OPTIONS = '__JSON_RPC_OPTIONS__';

Expand Down
6 changes: 3 additions & 3 deletions apps/service/src/json-rpc/json-rpc.server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable, Logger } from '@nestjs/common';
import { HttpAdapterHost, ModuleRef, ModulesContainer } from '@nestjs/core';
import { JSONRPCServer, SimpleJSONRPCMethod } from 'json-rpc-2.0';
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper.js';
import { JsonRpcMetadataKey, JsonRpcMethodMetadataKey } from './json-rpc.decorators.js';
import { JsonRpcConfig } from './json-rpc.module.js';
import { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper';
import { JsonRpcMetadataKey, JsonRpcMethodMetadataKey } from './json-rpc.decorators';
import { JsonRpcConfig } from './json-rpc.module';

class JsonRpcServerError extends Error {
constructor(message: string) {
Expand Down
2 changes: 1 addition & 1 deletion apps/service/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Logger } from '@nestjs/common';
import { NestFactory } from '@nestjs/core';
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
import { AppModule } from './app.module.js';
import { AppModule } from './app.module';

async function bootstrap() {
const logger = new Logger('AppBootstrap');
Expand Down
2 changes: 1 addition & 1 deletion apps/service/src/rgbpp/rgbpp.module.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Module } from '@nestjs/common';
import { RgbppService } from './rgbpp.service.js';
import { RgbppService } from './rgbpp.service';

@Module({
imports: [],
Expand Down
2 changes: 1 addition & 1 deletion apps/service/src/utils/json.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import isPlainObject from 'lodash/isPlainObject.js';
import isPlainObject from 'lodash/isPlainObject';

export function ensureSafeJson<Input extends object, Output = Input>(json: Input): Output {
if (!isPlainObject(json) && !Array.isArray(json)) {
Expand Down
5 changes: 2 additions & 3 deletions apps/service/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"compilerOptions": {
"module": "ESNext",
"module": "NodeNext",
"declaration": true,
"resolveJsonModule": true,
"removeComments": true,
"esModuleInterop": true,
"moduleResolution": "Bundler",
"moduleResolution": "NodeNext",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion examples/rgbpp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint:fix": "tsc && eslint --fix --ext .js,.ts . && prettier --write '**/*.{js,ts}'"
},
"dependencies": {
"@nervosnetwork/ckb-sdk-utils": "0.109.2",
"@nervosnetwork/ckb-sdk-utils": "0.109.3",
"rgbpp": "workspace:*"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion examples/xudt-on-ckb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint:fix": "tsc && eslint --fix --ext .ts . && prettier --write '**/*.ts'"
},
"dependencies": {
"@nervosnetwork/ckb-sdk-utils": "0.109.2",
"@nervosnetwork/ckb-sdk-utils": "0.109.3",
"rgbpp": "workspace:*"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/btc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@bitcoinerlab/secp256k1": "^1.1.1",
"@ckb-lumos/codec": "0.22.2",
"@nervosnetwork/ckb-types": "0.109.2",
"@nervosnetwork/ckb-types": "0.109.3",
"@rgbpp-sdk/ckb": "workspace:^",
"@rgbpp-sdk/service": "workspace:^",
"bip32": "^4.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/ckb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"@ckb-lumos/base": "^0.22.2",
"@ckb-lumos/codec": "^0.22.2",
"@spore-sdk/core": "^0.2.0-beta.6",
"@nervosnetwork/ckb-sdk-core": "0.109.2",
"@nervosnetwork/ckb-sdk-utils": "0.109.2",
"@nervosnetwork/ckb-types": "0.109.2",
"@nervosnetwork/ckb-sdk-core": "0.109.3",
"@nervosnetwork/ckb-sdk-utils": "0.109.3",
"@nervosnetwork/ckb-types": "0.109.3",
"@rgbpp-sdk/service": "workspace:^",
"@exact-realty/multipart-parser": "^1.0.13",
"axios": "^1.6.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/rgbpp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"dependencies": {
"@ckb-lumos/base": "^0.22.2",
"@ckb-lumos/codec": "^0.22.2",
"@nervosnetwork/ckb-sdk-utils": "0.109.2",
"@nervosnetwork/ckb-sdk-utils": "0.109.3",
"@rgbpp-sdk/btc": "workspace:*",
"@rgbpp-sdk/ckb": "workspace:*",
"@rgbpp-sdk/service": "workspace:*"
Expand Down
2 changes: 1 addition & 1 deletion packages/service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@ckb-lumos/codec": "0.22.2",
"@ckb-lumos/base": "0.22.2",
"@nervosnetwork/ckb-types": "0.109.2",
"@nervosnetwork/ckb-types": "0.109.3",
"lodash": "^4.17.21"
},
"publishConfig": {
Expand Down
Loading