Skip to content

Commit

Permalink
chore(sdk): switch to patch bigdeimal for better clarity (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
zfy0701 authored Jan 29, 2023
1 parent 55a92f5 commit ff757db
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 8 deletions.
9 changes: 7 additions & 2 deletions packages/cli/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ export async function buildProcessor(onlyGen: boolean) {
// }

if (!onlyGen) {
// TODO move this to SDK
const WEBPACK_CONFIG = path.join(__dirname, 'webpack.config.js')
let WEBPACK_CONFIG: string
try {
WEBPACK_CONFIG = require.resolve('@sentio/sdk/lib/webpack.config.js')
} catch (e) {
// In the future this should not need unless using very old sdk
WEBPACK_CONFIG = path.join(__dirname, 'webpack.config.js')
}
await execStep('yarn tsc -p .', 'Compile')
await execStep('yarn webpack --config=' + WEBPACK_CONFIG, 'Packaging')
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = {
if (/^nice-grpc.*$/.test(request)) {
return callback(null, 'commonjs ' + request)
}
if (/^@sentio\/(sdk|runtime|base|protos).*$/.test(request)) {
if (/^@sentio\/(sdk|runtime|base|protos|bigdecimal).*$/.test(request)) {
return callback(null, 'commonjs ' + request)
}
callback()
Expand Down
1 change: 0 additions & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"dependencies": {
"@sentio/protos": "^1.0.0-development",
"@ethersproject/providers": "~5.7.0",
"bignumber.js": "^9.1.0",
"command-line-args": "^5.2.1",
"command-line-usage": "^6.1.3",
"ethers": "~5.7.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0-development",
"scripts": {
"compile_target": "yarn tsc -b src/target-ethers-sentio/tsconfig.json",
"compile": "tsc -p . && cp src/utils/*.csv lib/utils",
"compile": "tsc -p . && cp src/utils/*.csv lib/utils && cp src/webpack.config.js lib",
"build": "yarn gen && yarn compile",
"build_all": "yarn lerna run --scope=@sentio/sdk build --include-dependencies",
"start_ts": "ts-node --files ../runtime/src/processor-runner.ts --log-format=json ../../examples/x2y2/src/processor.ts",
Expand All @@ -21,7 +21,7 @@
"@sentio/runtime": "^1.0.0-development",
"@sentio/protos": "^1.0.0-development",
"@typechain/ethers-v5": "^10.0.0",
"bignumber.js": "^9.1.0",
"@sentio/bigdecimal": "9.1.1-patch.1",
"command-line-args": "^5.2.1",
"command-line-usage": "^6.1.3",
"csv-parse": "^5.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/core/big-decimal.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { BigNumber as BigDecimal } from 'bignumber.js'
export { BigDecimal } from '@sentio/bigdecimal'
50 changes: 50 additions & 0 deletions packages/sdk/src/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/* eslint-disable */
const path = require('path')

module.exports = {
entry: {
lib: './src/processor.ts',
},
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.ts', '.js'],
},
output: {
filename: '[name].js',
path: path.resolve(process.cwd(), 'dist'),
},
target: 'node',
mode: 'production',
externals: [
{
protobufjs: 'commonjs2 protobufjs',
aptos: 'commonjs2 aptos-sdk',
ethers: 'commonjs2 ethers',
bs58: 'commonjs2 bs58',
"bignumber.js": 'commonjs2 bignumber.js',
'bn.js': 'commonjs2 bn.js',
'csv-parse': 'commonjs2 csv-parse',
},
function ({ context, request }, callback) {
if (/^@(ethersproject|solana|project-serum|nice-grpc).*$/.test(request)) {
return callback(null, 'commonjs ' + request)
}
if (/^nice-grpc.*$/.test(request)) {
return callback(null, 'commonjs ' + request)
}
if (/^@sentio\/(sdk|runtime|base|protos|bigdecimal).*$/.test(request)) {
return callback(null, 'commonjs ' + request)
}
callback()
},
],
}
7 changes: 6 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2701,6 +2701,11 @@
lodash "^4.17.4"
read-pkg-up "^7.0.0"

"@sentio/[email protected]":
version "9.1.1-patch.1"
resolved "https://registry.yarnpkg.com/@sentio/bigdecimal/-/bigdecimal-9.1.1-patch.1.tgz#0dfab1fcd85fc3b6e8c81c7d628455d6c113d9a9"
integrity sha512-jdqGsnxy+BwCGH1g1Qw5RAnSBsYAyNzOr2HQAc7q9MW2oluegQsMC8GTz4YahL8OdYQT2B42gQA3lloDdaOxZw==

"@sinclair/typebox@^0.24.1":
version "0.24.51"
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.24.51.tgz#645f33fe4e02defe26f2f5c0410e1c094eac7f5f"
Expand Down Expand Up @@ -3979,7 +3984,7 @@ bigint-buffer@^1.1.5:
dependencies:
bindings "^1.3.0"

bignumber.js@^9.0.0, bignumber.js@^9.0.1, bignumber.js@^9.1.0:
bignumber.js@^9.0.0, bignumber.js@^9.0.1:
version "9.1.1"
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.1.tgz#c4df7dc496bd849d4c9464344c1aa74228b4dac6"
integrity sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig==
Expand Down

0 comments on commit ff757db

Please sign in to comment.